Changeset 554 for soft/giet_vm
- Timestamp:
- Apr 13, 2015, 5:18:17 PM (10 years ago)
- Location:
- soft/giet_vm/giet_drivers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/mwr_driver.c
r529 r554 10 10 #include <mapping_info.h> 11 11 #include <mwr_driver.h> 12 #include <ctx_handler.h> 12 13 #include <utils.h> 13 14 #include <kernel_locks.h> … … 41 42 42 43 ///////////////////////////////////////////////////////////////////////////// 43 // Global variables 44 ///////////////////////////////////////////////////////////////////////////// 45 44 // Global variables (all arrays are indexed by the cluster index) 45 ///////////////////////////////////////////////////////////////////////////// 46 47 // Lock protecting exclusive access 46 48 __attribute__((section(".kdata"))) 47 49 simple_lock_t _coproc_lock[X_SIZE*Y_SIZE]; 48 50 49 __attribute__((section(".kdata"))) 50 unsigned int _coproc_done[X_SIZE*Y_SIZE]; 51 // Coprocessor type 52 __attribute__((section(".kdata"))) 53 unsigned int _coproc_type[X_SIZE*Y_SIZE]; 54 55 // coprocessor characteristics 56 __attribute__((section(".kdata"))) 57 unsigned int _coproc_info[X_SIZE*Y_SIZE]; 58 59 // Coprocessor running mode 60 __attribute__((section(".kdata"))) 61 unsigned int _coproc_mode[X_SIZE*Y_SIZE]; 62 63 // coprocessor status (for MODE_DMA_IRQ) 64 __attribute__((section(".kdata"))) 65 unsigned int _coproc_error[X_SIZE*Y_SIZE]; 66 67 // descheduled task gtid (for MODE_DMA_IRQ) 68 __attribute__((section(".kdata"))) 69 unsigned int _coproc_gtid[X_SIZE*Y_SIZE]; 51 70 52 71 ///////////////////////////////////////////////////////////////////////////// … … 93 112 SEG_MWR_BASE + 94 113 (cluster_xy * PERI_CLUSTER_INCREMENT) + 95 ((channel + 1) * ( CHANNEL_SPAN << 2)) +114 ((channel + 1) * (MWR_CHANNEL_SPAN << 2)) + 96 115 (index << 2); 97 116 … … 103 122 // defined by the "index" and "channel") arguments, in the MWMR_DMA component 104 123 // contained in cluster "cluster_xy". 105 //////////////////////////////////////////////////////////////////////////// /124 ////////////////////////////////////////////////////////////////////////////yy 106 125 void _mwr_set_channel_register( unsigned int cluster_xy, // cluster index 107 126 unsigned int channel, // channel index … … 112 131 SEG_MWR_BASE + 113 132 (cluster_xy * PERI_CLUSTER_INCREMENT) + 114 ((channel + 1) * ( CHANNEL_SPAN << 2)) +133 ((channel + 1) * (MWR_CHANNEL_SPAN << 2)) + 115 134 (index << 2); 116 135 … … 118 137 } 119 138 120 /////////////////////////////////////////////////////// 121 void _mwr_isr( unsigned int irq_type, // should be HWI 139 ////////////////////////////////////////////////////////////////////////////yy 140 // This Interrupt service routine is called in two situations: 141 // - The MWR_DMA component is running in MODE_DMA_IRQ, and all the 142 // communication channels have successfully completed. 143 // - The MWR_DMA component is running in any mode, and at least one 144 // communication channel is reporting a VCI error. 145 ////////////////////////////////////////////////////////////////////////////yy 146 void _mwr_isr( unsigned int irq_type, // unused : should be HWI 122 147 unsigned int irq_id, // index returned by XCU 123 unsigned int channel ) // MWMR_DMA channel 124 { 148 unsigned int bloup ) // unused : should be 0 149 { 150 // get coprocessor coordinates and characteristics 151 // the processor executing the ISR an the coprocessor 152 // are in the same cluster 125 153 unsigned int gpid = _get_procid(); 126 154 unsigned int cluster_xy = gpid >> P_WIDTH; 127 155 unsigned int x = cluster_xy >> Y_WIDTH; 128 156 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 129 130 // acknowledge IRQ 131 _mwr_set_channel_register( cluster_xy, channel, CHANNEL_RUNNING, 0 ); 132 133 // compute coproc_id from cluster coordinates 134 unsigned int coproc_id = x * Y_SIZE + y; 135 136 // set synchronisation variable 137 _coproc_done[coproc_id] = 1; 157 unsigned int p = gpid & ((1<<P_WIDTH)-1); 158 unsigned int cluster_id = x * Y_SIZE + y; 159 unsigned int info = _coproc_info[cluster_id]; 160 unsigned int nb_to = info & 0xFF; 161 unsigned int nb_from = (info>>8) & 0xFF; 162 unsigned int channel; 163 unsigned int status; 164 unsigned int error = 0; 165 166 // check status, report errors and reset all channels 167 for ( channel = 0 ; channel < (nb_to + nb_from) ; channel++ ) 168 { 169 status = _mwr_get_channel_register( cluster_xy , channel , MWR_CHANNEL_STATUS ); 170 171 if ( status == MWR_CHANNEL_BUSY ) // strange => report error 172 { 173 _printf("\n[GIET_ERROR] in _mwr_isr() : channel %d is busy\n", channel ); 174 error = 1; 175 } 176 else if ( status == MWR_CHANNEL_ERROR_DATA ) 177 { 178 _printf("\n[GIET_ERROR] in _mwr_isr() : DATA_ERROR / channel %d\n", channel ); 179 error = 1; 180 } 181 else if ( status == MWR_CHANNEL_ERROR_LOCK ) 182 { 183 _printf("\n[GIET_ERROR] in _mwr_isr() : LOCK_ERROR / channel %d\n", channel ); 184 error = 1; 185 } 186 else if ( status == MWR_CHANNEL_ERROR_DESC ) 187 { 188 _printf("\n[GIET_ERROR] in _mwr_isr() : DESC_ERROR / channel %d\n", channel ); 189 error = 1; 190 } 191 192 // reset channel 193 _mwr_set_channel_register( cluster_xy , channel , MWR_CHANNEL_RUNNING , 0 ); 194 } 195 196 // register error 197 _coproc_error[cluster_id] = error; 198 199 // identify task waiting on coprocessor completion 200 // this task can run in a remote cluster 201 unsigned int gtid = _coproc_gtid[cluster_id]; 202 unsigned int remote_procid = gtid>>16; 203 unsigned int ltid = gtid & 0xFFFF; 204 unsigned int remote_cluster = remote_procid >> P_WIDTH; 205 unsigned int remote_x = remote_cluster >> Y_WIDTH; 206 unsigned int remote_y = remote_cluster & ((1<<Y_WIDTH)-1); 207 unsigned int remote_p = remote_procid & ((1<<P_WIDTH)-1); 208 209 // re-activates sleeping task 210 _set_task_slot( remote_x, 211 remote_y, 212 remote_p, 213 ltid, 214 CTX_RUN_ID, // CTX_RUN slot 215 1 ); // running value 216 217 // send a WAKUP WTI to processor running the sleeping task 218 _xcu_send_wti( remote_cluster, 219 remote_p, 220 0 ); // don't force context switch 221 222 #if GIET_DEBUG_COPROC 223 _printf("\n[GIET DEBUG COPROC] P[%d,%d,%d] executes _mwr_isr() at cycle %d\n" 224 " for task %d running on P[%d,%d,%d] / error = %d\n", 225 x , y , p , _get_proctime() , ltid , remote_x , remote_y , remote_p , error ); 226 #endif 138 227 } 139 228 -
soft/giet_vm/giet_drivers/mwr_driver.h
r518 r554 36 36 enum MwmrDmaRegisters 37 37 { 38 CHANNEL_BUFFER_LSB = 0, // Data buffer paddr 32 LSB bits39 CHANNEL_BUFFER_MSB = 1, // Data buffer paddr extension40 CHANNEL_MWMR_LSB = 2, // MWMR descriptor paddr 32 LSB bits41 CHANNEL_MWMR_MSB = 3, // MWMR descriptor paddr extension42 CHANNEL_LOCK_LSB = 4, // MWMR lock paddr 32 LSB bits43 CHANNEL_LOCK_MSB = 5, // MWMR lock paddr extension44 CHANNEL_WAY = 6, // TO_COPROC / FROMCOPROC (Read-only)45 CHANNEL_MODE = 7, // MWMR / DMA / DMA_IRQ46 CHANNEL_SIZE = 8, // Data Buffer size (bytes)47 CHANNEL_RUNNING = 9, // channel running48 CHANNEL_STATUS = 10, // channel FSM state (Read-Only)49 CHANNEL_INFO = 11, // STS | CFG | FROM | TO (Read-Only)38 MWR_CHANNEL_BUFFER_LSB = 0, // Data buffer paddr 32 LSB bits 39 MWR_CHANNEL_BUFFER_MSB = 1, // Data buffer paddr extension 40 MWR_CHANNEL_MWMR_LSB = 2, // MWMR descriptor paddr 32 LSB bits 41 MWR_CHANNEL_MWMR_MSB = 3, // MWMR descriptor paddr extension 42 MWR_CHANNEL_LOCK_LSB = 4, // MWMR lock paddr 32 LSB bits 43 MWR_CHANNEL_LOCK_MSB = 5, // MWMR lock paddr extension 44 MWR_CHANNEL_WAY = 6, // TO_COPROC / FROMCOPROC (Read-only) 45 MWR_CHANNEL_MODE = 7, // MWMR / DMA / DMA_IRQ 46 MWR_CHANNEL_SIZE = 8, // Data Buffer size (bytes) 47 MWR_CHANNEL_RUNNING = 9, // channel running 48 MWR_CHANNEL_STATUS = 10, // channel FSM state (Read-Only) 49 MWR_CHANNEL_INFO = 11, // STS | CFG | FROM | TO (Read-Only) 50 50 // 51 CHANNEL_SPAN = 16, 51 MWR_CHANNEL_SPAN = 16, 52 }; 53 54 enum MwrDmaStatus 55 { 56 MWR_CHANNEL_SUCCESS = 0, 57 MWR_CHANNEL_ERROR_DATA = 1, 58 MWR_CHANNEL_ERROR_LOCK = 2, 59 MWR_CHANNEL_ERROR_DESC = 3, 60 MWR_CHANNEL_BUSY = 4, 52 61 }; 53 62
Note: See TracChangeset
for help on using the changeset viewer.