[258] | 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). |
---|
[320] | 11 | // |
---|
[258] | 12 | // The (virtual) base address of the associated segment is: |
---|
[333] | 13 | // SEG_MWR_BASE + cluster_xy * PERI_CLUSTER_INCREMENT |
---|
[258] | 14 | // |
---|
[333] | 15 | // SEG_MWR_BASE and PERI_CLUSTER_INCREMENT must be defined in hard_config.h |
---|
[258] | 16 | //////////////////////////////////////////////////////////////////////////////// |
---|
| 17 | |
---|
| 18 | #include <giet_config.h> |
---|
[320] | 19 | #include <hard_config.h> |
---|
[258] | 20 | #include <mwr_driver.h> |
---|
| 21 | #include <utils.h> |
---|
[456] | 22 | #include <tty0.h> |
---|
[258] | 23 | |
---|
[263] | 24 | #if !defined(X_SIZE) |
---|
| 25 | # error: You must define X_SIZE in the hard_config.h file |
---|
[258] | 26 | #endif |
---|
| 27 | |
---|
[263] | 28 | #if !defined(Y_SIZE) |
---|
| 29 | # error: You must define X_SIZE in the hard_config.h file |
---|
[258] | 30 | #endif |
---|
| 31 | |
---|
[263] | 32 | #if !defined(X_WIDTH) |
---|
| 33 | # error: You must define X_WIDTH in the hard_config.h file |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | #if !defined(Y_WIDTH) |
---|
| 37 | # error: You must define X_WIDTH in the hard_config.h file |
---|
| 38 | #endif |
---|
| 39 | |
---|
[320] | 40 | #if !defined(SEG_MWR_BASE) |
---|
| 41 | # error: You must define SEG_MWR_BASE in the hard_config.h file |
---|
| 42 | #endif |
---|
| 43 | |
---|
[333] | 44 | #if !defined(PERI_CLUSTER_INCREMENT) |
---|
| 45 | # error: You must define PERI_CLUSTER_INCREMENT in the hard_config.h file |
---|
[320] | 46 | #endif |
---|
| 47 | |
---|
[258] | 48 | ////////////////////////////////////////////////////////////////////////////////// |
---|
[263] | 49 | // _mwr_hw_init() |
---|
[258] | 50 | // This function initializes one MWMR controller channel (i.e. one coprocessor |
---|
| 51 | // port) in a given cluster. |
---|
[263] | 52 | // - cluster_xy : cluster index |
---|
[258] | 53 | // _ port_id : port index |
---|
| 54 | // - way : direction (to_coproc/from_coproc) |
---|
| 55 | // - channel_pbase : physical base address of the MWMR channel |
---|
| 56 | // TODO : The MWMR controler should be modified to support 40 bits addresses... |
---|
| 57 | // Introduce a MWMR_CONFIG_PADDR_EXT register in the MWMR coprocessor |
---|
| 58 | ////////////////////////////////////////////////////////////////////////////////// |
---|
| 59 | // Returns 0 if success, returns > 0 if error. |
---|
| 60 | ////////////////////////////////////////////////////////////////////////////////// |
---|
[263] | 61 | unsigned int _mwr_hw_init( unsigned int cluster_xy, |
---|
| 62 | unsigned int port_id, |
---|
| 63 | unsigned int from_coproc, |
---|
| 64 | paddr_t channel_pbase ) |
---|
[258] | 65 | { |
---|
[437] | 66 | _puts(" [GIET_ERROR] _mwr_hw_init() function not supported yet\n"); |
---|
[258] | 67 | _exit(); |
---|
| 68 | |
---|
| 69 | /* |
---|
| 70 | // parameters checking |
---|
[263] | 71 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 72 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
| 73 | if (x >= X_SIZE) return 1; |
---|
| 74 | if (y >= Y_SIZE) return 1; |
---|
[258] | 75 | |
---|
[263] | 76 | // compute base address |
---|
[320] | 77 | unsigned int* mwr_address = (unsigned int*) ( SEG_MWR_BASE + |
---|
[333] | 78 | (cluster_xy * PERI_CLUSTER_INCREMENT) ); |
---|
[258] | 79 | |
---|
| 80 | unsigned int lsb = (unsigned int)channel_pbase; |
---|
| 81 | unsigned int msb = (unsigned int)(channel_pbase>>32); |
---|
| 82 | |
---|
| 83 | // get depth and width from channel itself |
---|
| 84 | unsigned int depth = _physical_read( channel_pbase + 16 ); |
---|
| 85 | unsigned int width = _physical_read( channel_pbase + 20 ); |
---|
| 86 | |
---|
| 87 | // initializes and launches mwmr controler |
---|
[263] | 88 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_WAY] = from_coproc; |
---|
| 89 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_FIFO_NO] = port_id; |
---|
| 90 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_WIDTH] = width; |
---|
| 91 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DEPTH] = depth; |
---|
| 92 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_STATUS] = lsb; |
---|
| 93 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_DATA] = lsb + 24; |
---|
| 94 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_EXT] = msb; |
---|
| 95 | mwr_address[port_id * MWMR_SPAN + MWMR_CONFIG_RUNNING] = 1; |
---|
[258] | 96 | */ |
---|
| 97 | return 0; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | // Local Variables: |
---|
| 102 | // tab-width: 4 |
---|
| 103 | // c-basic-offset: 4 |
---|
| 104 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 105 | // indent-tabs-mode: nil |
---|
| 106 | // End: |
---|
| 107 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 108 | |
---|