1 | /////////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File : mwr_driver.c |
---|
3 | // Date : 23/05/2013 |
---|
4 | // Author : alain greiner |
---|
5 | // Copyright (c) UPMC-LIP6 |
---|
6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
7 | // The mwmr_driver.c and mwmr_driver.h files are part ot the GIET-VM nano-kernel. |
---|
8 | // This driver supports the SoClib vci_mwmr_controller component. |
---|
9 | // |
---|
10 | // This peripheral can be replicated (at most one component per cluster). |
---|
11 | /////////////////////////////////////////////////////////////////////////////////// |
---|
12 | // The (virtual) base address of the associated segment is: |
---|
13 | // |
---|
14 | // seg_mwr_base + cluster_id * vseg_cluster_increment |
---|
15 | // |
---|
16 | // The seg_mwr_base and vseg_cluster_increment values must be defined |
---|
17 | // in the giet_vsegs.ld file. |
---|
18 | //////////////////////////////////////////////////////////////////////////////// |
---|
19 | |
---|
20 | #include <giet_config.h> |
---|
21 | #include <mwr_driver.h> |
---|
22 | #include <utils.h> |
---|
23 | |
---|
24 | #if !defined(NB_CLUSTERS) |
---|
25 | # error: You must define NB_CLUSTERS in the hard_config.h file |
---|
26 | #endif |
---|
27 | |
---|
28 | #if (NB_CLUSTERS > 256) |
---|
29 | # error: NB_CLUSTERS cannot be larger than 256! |
---|
30 | #endif |
---|
31 | |
---|
32 | ////////////////////////////////////////////////////////////////////////////////// |
---|
33 | // _mwmr_hw_init() |
---|
34 | // This function initializes one MWMR controller channel (i.e. one coprocessor |
---|
35 | // port) in a given cluster. |
---|
36 | // - cluster_id : cluster index |
---|
37 | // _ port_id : port index |
---|
38 | // - way : direction (to_coproc/from_coproc) |
---|
39 | // - channel_pbase : physical base address of the MWMR channel |
---|
40 | // TODO : The MWMR controler should be modified to support 40 bits addresses... |
---|
41 | // Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor |
---|
42 | // To support addresses > 32 bits and remove this limitation... |
---|
43 | ////////////////////////////////////////////////////////////////////////////////// |
---|
44 | // Returns 0 if success, returns > 0 if error. |
---|
45 | ////////////////////////////////////////////////////////////////////////////////// |
---|
46 | unsigned int _mwmr_hw_init( unsigned int cluster_id, |
---|
47 | unsigned int port_id, |
---|
48 | unsigned int from_coproc, |
---|
49 | paddr_t channel_pbase ) |
---|
50 | { |
---|
51 | _puts(" [GIET_ERROR] _mwmr_hw_init() function not implemented yet\n"); |
---|
52 | _exit(); |
---|
53 | |
---|
54 | /* |
---|
55 | // parameters checking |
---|
56 | if (cluster_id >= NB_CLUSTERS) return 1; |
---|
57 | |
---|
58 | // compute MWMR base address |
---|
59 | unsigned int* mwmr_address = (unsigned int*) ((unsigned int)&seg_mwmr_base + |
---|
60 | (cluster_id * (unsigned int)&vseg_cluster_increment)); |
---|
61 | |
---|
62 | unsigned int lsb = (unsigned int)channel_pbase; |
---|
63 | unsigned int msb = (unsigned int)(channel_pbase>>32); |
---|
64 | |
---|
65 | // get depth and width from channel itself |
---|
66 | unsigned int depth = _physical_read( channel_pbase + 16 ); |
---|
67 | unsigned int width = _physical_read( channel_pbase + 20 ); |
---|
68 | |
---|
69 | // initializes and launches mwmr controler |
---|
70 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY] = from_coproc; |
---|
71 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO] = port_id; |
---|
72 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH] = width; |
---|
73 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH] = depth; |
---|
74 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS] = lsb; |
---|
75 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA] = lsb + 24; |
---|
76 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT] = msb; |
---|
77 | mwmr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING] = 1; |
---|
78 | */ |
---|
79 | return 0; |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | // Local Variables: |
---|
84 | // tab-width: 4 |
---|
85 | // c-basic-offset: 4 |
---|
86 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
87 | // indent-tabs-mode: nil |
---|
88 | // End: |
---|
89 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
90 | |
---|