Changeset 238 for soft/giet_vm/sys/irq_handler.c
- Timestamp:
- May 29, 2013, 1:24:09 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/irq_handler.c
r237 r238 19 19 #include <hwr_mapping.h> 20 20 21 #if NB_TIM ERS_MAX22 extern volatile unsigned char _user_timer_event[NB_CLUSTERS * NB_TIM ERS_MAX] ;21 #if NB_TIM_CHANNELS 22 extern volatile unsigned char _user_timer_event[NB_CLUSTERS * NB_TIM_CHANNELS] ; 23 23 #endif 24 24 … … 33 33 // 34 34 // There is one interrupt vector per processor (stored in the scheduler associated 35 // to the processor. Each interrupt vector entry contains two 16 bits fields: 36 // - isr_id : defines the type of ISR to be executed. 35 // to the processor. Each interrupt vector entry contains three bits fields: 36 // - isr_id : defines the type of ISR to be executed. 37 // - type_id : HWI if zero / PTI if non zero 37 38 // - channel_id : defines the specific channel for multi-channels peripherals. 38 39 // … … 40 41 // a global index : channel_id = cluster_id * NB_CHANNELS_MAX + loc_id 41 42 /////////////////////////////////////////////////////////////////////////////////// 42 void _irq_demux() { 43 void _irq_demux() 44 { 43 45 unsigned int pid = _procid(); 44 46 unsigned int irq_id; 45 47 46 47 48 // get the highest priority active IRQ index 48 if (_icu_get_index( pid / NB_PROCS_MAX, pid % NB_PROCS_MAX, &irq_id)) { 49 if (_icu_get_index( pid / NB_PROCS_MAX, pid % NB_PROCS_MAX, &irq_id)) 50 { 49 51 _get_lock(&_tty_put_lock); 50 52 _puts("\n[GIET ERROR] Strange... Wrong _icu_read in _irq_demux()\n"); … … 52 54 } 53 55 54 55 if (irq_id < 32) { 56 // do nothing if no interrupt active 57 unsigned int entry = _get_interrupt_vector_entry(irq_id); 58 unsigned int isr_id = entry & 0x000000FF; 59 unsigned int type_id = (entry >> 8) & 0x000000FF; 60 unsigned int channel_id = (entry >> 16) & 0x0000FFFF; 56 // do nothing if no interrupt active 57 if (irq_id < 32) 58 { 59 static_scheduler_t* psched = _get_sched(); 60 unsigned int entry = psched->interrupt_vector[irq_id]; 61 unsigned int isr_id = entry & 0x000000FF; 62 unsigned int type_id = (entry >> 8) & 0x000000FF; 63 unsigned int channel_id = (entry >> 16) & 0x0000FFFF; 64 61 65 if(type_id == 0) // HARD irq type 62 66 { … … 76 80 } 77 81 78 79 82 /////////////////////////////////////////////////////////////////////////////////// 80 83 // _isr_default() … … 82 85 // interrupt vector. It simply displays an error message on kernel TTY[0]. 83 86 /////////////////////////////////////////////////////////////////////////////////// 84 void _isr_default() { 87 void _isr_default() 88 { 85 89 _get_lock(&_tty_put_lock); 86 90 _puts("\n[GIET ERROR] Strange... Default ISR activated for processor "); … … 96 100 // The multi_dma components can be distributed in the clusters. 97 101 // The channel_id argument is the local DMA channel index. 98 // dma_global_id = cluster_id*NB_DMA S_MAX+ channel_id102 // dma_global_id = cluster_id*NB_DMA_CHANNELS + channel_id 99 103 // - The ISR saves the transfert status in _dma_status[dma_global_id]. 100 104 // - It acknowledges the interrupt to reinitialize the DMA controler. 101 105 // - it resets the synchronisation variable _dma_busy[dma_global_id]. 102 106 /////////////////////////////////////////////////////////////////////////////////// 103 void _isr_dma(unsigned int channel_id) { 104 #if NB_DMAS_MAX > 0 107 void _isr_dma(unsigned int channel_id) 108 { 109 #if NB_DMA_CHANNELS > 0 105 110 // compute cluster_id 106 111 unsigned int cluster_id = _procid() / NB_PROCS_MAX; 107 112 108 113 // compute dma_global_id 109 unsigned int dma_global_id = cluster_id * NB_DMA S_MAX+ channel_id;114 unsigned int dma_global_id = cluster_id * NB_DMA_CHANNELS + channel_id; 110 115 111 116 // save DMA channel status 112 117 if (_dma_get_status(cluster_id, channel_id, 113 (unsigned int *) &_dma_status[dma_global_id])) { 118 (unsigned int *) &_dma_status[dma_global_id])) 119 { 114 120 _get_lock(&_tty_put_lock); 115 121 _puts("[GIET ERROR] illegal DMA channel detected by _isr_dma\n"); … … 119 125 120 126 // reset DMA channel irq 121 if (_dma_reset_irq(cluster_id, channel_id)) { 127 if (_dma_reset_irq(cluster_id, channel_id)) 128 { 122 129 _get_lock(&_tty_put_lock); 123 130 _puts("[GIET ERROR] illegal DMA channel detected by _isr_dma\n"); … … 128 135 // release DMA channel 129 136 _dma_done[dma_global_id] = 1; 137 130 138 #else 131 _puts("[GIET ERROR] NB_DMAS_MAX is set to zero\n"); 132 139 _get_lock(&_tty_put_lock); 140 _puts("[GIET ERROR] NB_DMA_CHANNELS is set to zero\n"); 141 _release_lock(&_tty_put_lock); 133 142 #endif 134 143 } … … 140 149 // - It sets the _ioc_done variable to signal completion. 141 150 /////////////////////////////////////////////////////////////////////////////////// 142 void _isr_ioc() { 151 void _isr_ioc() 152 { 143 153 // save status & reset IRQ 144 if (_ioc_get_status((unsigned int *) &_ioc_status )) { 154 if (_ioc_get_status((unsigned int *) &_ioc_status )) 155 { 145 156 _get_lock(&_tty_put_lock); 146 157 _puts("[GIET ERROR] bad access to IOC status detected by _isr_ioc\n"); … … 161 172 // in a vci_multi_timer component, or in a vci_xicu component. 162 173 // The timer_id argument is the user timer local index. 163 // timer_globa_id = cluster_id*(NB_TIM ERS_MAX) + timer_id174 // timer_globa_id = cluster_id*(NB_TIM_CHANNELS) + timer_id 164 175 // The ISR acknowledges the IRQ and registers the event in the proper entry 165 176 // of the _timer_event[] array, and a log message is displayed on kernel terminal. 166 177 /////////////////////////////////////////////////////////////////////////////////// 167 void _isr_timer(unsigned int timer_id) { 178 void _isr_timer(unsigned int timer_id) 179 { 168 180 // compute cluster_id 169 181 unsigned int cluster_id = _procid() / NB_PROCS_MAX; 170 182 171 183 // aknowledge IRQ 172 if (_timer_reset_irq( cluster_id, timer_id)) { 184 if (_timer_reset_irq( cluster_id, timer_id)) 185 { 173 186 _get_lock(&_tty_put_lock); 174 187 _puts("[GIET ERROR] illegal timer index detected by _isr_timer\n"); … … 177 190 } 178 191 179 #if NB_TIM ERS_MAX192 #if NB_TIM_CHANNELS 180 193 // register the event 181 unsigned int timer_global_id = cluster_id * NB_TIM ERS_MAX+ timer_id;194 unsigned int timer_global_id = cluster_id * NB_TIM_CHANNELS + timer_id; 182 195 _user_timer_event[timer_global_id] = 1; 183 196 #endif … … 207 220 // A character is lost if the buffer is full when the ISR is executed. 208 221 /////////////////////////////////////////////////////////////////////////////////// 209 void _isr_tty(unsigned int tty_id) { 222 void _isr_tty(unsigned int tty_id) 223 { 210 224 // save character and reset IRQ 211 if (_tty_get_char( tty_id, (unsigned char *) &_tty_get_buf[tty_id])) { 225 if (_tty_get_char( tty_id, (unsigned char *) &_tty_get_buf[tty_id])) 226 { 212 227 _get_lock(&_tty_put_lock); 213 228 _puts("[GIET ERROR] illegal tty index detected by _isr_tty\n"); … … 229 244 // The ISR acknowledges the IRQ and calls the _ctx_switch() function. 230 245 ///////////////////////////////////////////////////////////////////////////////////// 231 void _isr_switch( unsigned int timer_id) { 246 void _isr_switch( unsigned int timer_id) 247 { 232 248 // get cluster index and proc local index 233 249 unsigned int cluster_id = _procid() / NB_PROCS_MAX; 234 250 235 251 // acknowledge IRQ 236 if (_timer_reset_irq(cluster_id, timer_id)) { 252 if (_timer_reset_irq(cluster_id, timer_id)) 253 { 237 254 _get_lock(&_tty_put_lock); 238 255 _puts("[GIET ERROR] illegal proc index detected by _isr_switch\n");
Note: See TracChangeset
for help on using the changeset viewer.