[528] | 1 | /////////////////////////////////////////////////////////////////////////// |
---|
[258] | 2 | // File : irq_handler.c |
---|
| 3 | // Date : 01/04/2012 |
---|
| 4 | // Author : alain greiner |
---|
| 5 | // Copyright (c) UPMC-LIP6 |
---|
[528] | 6 | /////////////////////////////////////////////////////////////////////////// |
---|
[258] | 7 | |
---|
| 8 | #include <giet_config.h> |
---|
| 9 | #include <irq_handler.h> |
---|
| 10 | #include <sys_handler.h> |
---|
| 11 | #include <ctx_handler.h> |
---|
| 12 | #include <tim_driver.h> |
---|
| 13 | #include <xcu_driver.h> |
---|
[528] | 14 | #include <pic_driver.h> |
---|
[258] | 15 | #include <tty_driver.h> |
---|
[294] | 16 | #include <nic_driver.h> |
---|
| 17 | #include <cma_driver.h> |
---|
[297] | 18 | #include <mmc_driver.h> |
---|
[294] | 19 | #include <bdv_driver.h> |
---|
[547] | 20 | #include <hba_driver.h> |
---|
[258] | 21 | #include <dma_driver.h> |
---|
[547] | 22 | #include <sdc_driver.h> |
---|
[528] | 23 | #include <mwr_driver.h> |
---|
[281] | 24 | #include <mapping_info.h> |
---|
[258] | 25 | #include <utils.h> |
---|
[459] | 26 | #include <tty0.h> |
---|
[258] | 27 | |
---|
[528] | 28 | ///////////////////////////////////////////////////////////////////////// |
---|
| 29 | // Global variables |
---|
| 30 | ///////////////////////////////////////////////////////////////////////// |
---|
[258] | 31 | |
---|
[528] | 32 | // array of external IRQ indexes for each (isr/channel) couple |
---|
| 33 | __attribute__((section(".kdata"))) |
---|
| 34 | unsigned char _ext_irq_index[GIET_ISR_TYPE_MAX][GIET_ISR_CHANNEL_MAX]; |
---|
| 35 | |
---|
| 36 | // WTI mailbox allocators for external IRQ routing (3 allocators per proc) |
---|
| 37 | __attribute__((section(".kdata"))) |
---|
| 38 | unsigned char _wti_alloc_one[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 39 | __attribute__((section(".kdata"))) |
---|
| 40 | unsigned char _wti_alloc_two[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 41 | __attribute__((section(".kdata"))) |
---|
| 42 | unsigned char _wti_alloc_ter[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 43 | |
---|
[519] | 44 | ///////////////////////////////////////////////////////////////////////// |
---|
[528] | 45 | // this array is allocated in the boot.c or kernel_init.c |
---|
| 46 | ///////////////////////////////////////////////////////////////////////// |
---|
| 47 | |
---|
| 48 | extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; |
---|
| 49 | |
---|
| 50 | ///////////////////////////////////////////////////////////////////////// |
---|
[519] | 51 | // These ISR_TYPE names for display must be consistent with values in |
---|
| 52 | // irq_handler.h / mapping.py / xml_driver.c |
---|
| 53 | ///////////////////////////////////////////////////////////////////////// |
---|
[547] | 54 | |
---|
[494] | 55 | __attribute__((section(".kdata"))) |
---|
[547] | 56 | char* _isr_type_str[] = { "DEFAULT", |
---|
| 57 | "TICK" , |
---|
| 58 | "TTY_RX" , |
---|
| 59 | "TTY_TX" , |
---|
| 60 | "BDV" , |
---|
| 61 | "TIMER" , |
---|
| 62 | "WAKUP" , |
---|
| 63 | "NIC_RX" , |
---|
| 64 | "NIC_TX" , |
---|
| 65 | "CMA" , |
---|
| 66 | "MMC" , |
---|
| 67 | "DMA" , |
---|
| 68 | "SPI" , |
---|
| 69 | "MWR" , |
---|
| 70 | "HBA" }; |
---|
[528] | 71 | |
---|
[547] | 72 | __attribute__((section(".kdata"))) |
---|
| 73 | char* _irq_type_str[] = { "HWI", |
---|
| 74 | "WTI", |
---|
| 75 | "PTI" }; |
---|
| 76 | |
---|
[528] | 77 | //////////////////// |
---|
| 78 | void _ext_irq_init() |
---|
| 79 | { |
---|
| 80 | mapping_header_t* header = (mapping_header_t *)SEG_BOOT_MAPPING_BASE; |
---|
| 81 | mapping_cluster_t* cluster = _get_cluster_base(header); |
---|
| 82 | mapping_periph_t* periph = _get_periph_base(header); |
---|
| 83 | mapping_irq_t* irq = _get_irq_base(header); |
---|
| 84 | unsigned int periph_id; // peripheral index in mapping_info |
---|
| 85 | unsigned int irq_id; // irq index in mapping_info |
---|
| 86 | |
---|
| 87 | // get cluster_io index in mapping |
---|
| 88 | unsigned int x_io = header->x_io; |
---|
| 89 | unsigned int y_io = header->y_io; |
---|
| 90 | unsigned int cluster_io = (x_io * Y_SIZE) + y_io; |
---|
| 91 | mapping_periph_t* pic = NULL; |
---|
| 92 | |
---|
[547] | 93 | // scan external peripherals to find PIC |
---|
[528] | 94 | unsigned int min = cluster[cluster_io].periph_offset ; |
---|
| 95 | unsigned int max = min + cluster[cluster_io].periphs ; |
---|
| 96 | |
---|
| 97 | for ( periph_id = min ; periph_id < max ; periph_id++ ) |
---|
| 98 | { |
---|
| 99 | if ( periph[periph_id].type == PERIPH_TYPE_PIC ) |
---|
| 100 | { |
---|
| 101 | pic = &periph[periph_id]; |
---|
| 102 | break; |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | if ( pic == NULL ) |
---|
| 107 | { |
---|
| 108 | _printf("\n[GIET ERROR] in _ext_irq_init() : No PIC component found\n"); |
---|
| 109 | _exit(); |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | // scan PIC IRQS defined in mapping |
---|
| 113 | for ( irq_id = pic->irq_offset ; |
---|
| 114 | irq_id < pic->irq_offset + pic->irqs ; |
---|
| 115 | irq_id++ ) |
---|
| 116 | { |
---|
| 117 | unsigned int type = irq[irq_id].srctype; |
---|
| 118 | unsigned int srcid = irq[irq_id].srcid; |
---|
| 119 | unsigned int isr = irq[irq_id].isr; |
---|
| 120 | unsigned int channel = irq[irq_id].channel; |
---|
| 121 | |
---|
| 122 | if ( (type != IRQ_TYPE_HWI) || |
---|
| 123 | (srcid > 31) || |
---|
| 124 | (isr >= GIET_ISR_TYPE_MAX) || |
---|
| 125 | (channel >= GIET_ISR_CHANNEL_MAX) ) |
---|
| 126 | { |
---|
| 127 | _printf("\n[GIET ERROR] in _ext_irq_init() : Bad PIC IRQ\n" |
---|
| 128 | " type = %d / srcid = %d / isr = %d / channel = %d\n", |
---|
| 129 | type , srcid , isr , channel ); |
---|
| 130 | _exit(); |
---|
| 131 | } |
---|
| 132 | _ext_irq_index[isr][channel] = srcid; |
---|
| 133 | } |
---|
| 134 | } // end _ext_irq_init() |
---|
| 135 | |
---|
| 136 | //////////////////////////////////////////// |
---|
| 137 | void _ext_irq_alloc( unsigned int isr_type, |
---|
| 138 | unsigned int isr_channel, |
---|
| 139 | unsigned int* wti_index ) |
---|
| 140 | { |
---|
| 141 | unsigned int wti_id; // allocated WTI mailbox index in XCU |
---|
| 142 | unsigned int irq_id; // external IRQ index in PIC (input) |
---|
| 143 | unsigned int wti_addr; // WTI mailbox physical address (32 lsb bits) |
---|
| 144 | |
---|
| 145 | // check arguments |
---|
| 146 | if ( isr_type >= GIET_ISR_TYPE_MAX ) |
---|
| 147 | { |
---|
| 148 | _printf("\n[GIET ERROR] in _ext_irq_alloc() : illegal ISR type\n"); |
---|
| 149 | _exit(); |
---|
| 150 | } |
---|
| 151 | if ( isr_channel >= GIET_ISR_CHANNEL_MAX ) |
---|
| 152 | { |
---|
| 153 | _printf("\n[GIET ERROR] in _ext_irq_alloc() : illegal ISR channel\n"); |
---|
| 154 | _exit(); |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | // get processor coordinates [x,y,p] |
---|
| 158 | unsigned int gpid = _get_procid(); |
---|
| 159 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
| 160 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 161 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
| 162 | unsigned int p = gpid & ((1<<P_WIDTH)-1); |
---|
| 163 | |
---|
| 164 | // allocate a WTI mailbox to proc[x,y,p] (blocking until success) |
---|
| 165 | while ( 1 ) |
---|
| 166 | { |
---|
| 167 | if ( _wti_alloc_one[x][y][p] == 0 ) |
---|
| 168 | { |
---|
| 169 | _wti_alloc_one[x][y][p] = 1; |
---|
| 170 | wti_id = p + NB_PROCS_MAX; |
---|
| 171 | break; |
---|
| 172 | } |
---|
| 173 | if ( _wti_alloc_two[x][y][p] == 0 ) |
---|
| 174 | { |
---|
| 175 | _wti_alloc_two[x][y][p] = 1; |
---|
| 176 | wti_id = p + 2*NB_PROCS_MAX; |
---|
| 177 | break; |
---|
| 178 | } |
---|
| 179 | if ( _wti_alloc_ter[x][y][p] == 0 ) |
---|
| 180 | { |
---|
| 181 | _wti_alloc_ter[x][y][p] = 1; |
---|
| 182 | wti_id = p + 3*NB_PROCS_MAX; |
---|
| 183 | break; |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | *wti_index = wti_id; |
---|
| 187 | |
---|
| 188 | // register the mailbox physical address in IOPIC |
---|
| 189 | irq_id = _ext_irq_index[isr_type][isr_channel]; |
---|
| 190 | _xcu_get_wti_address( wti_id , &wti_addr ); |
---|
| 191 | _pic_init( irq_id , wti_addr, cluster_xy ); |
---|
| 192 | |
---|
[547] | 193 | // initializes the WTI interrupt vector entry for target XCU |
---|
| 194 | static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); |
---|
| 195 | psched->wti_vector[wti_id] = isr_channel<<16 | isr_type; |
---|
[528] | 196 | |
---|
[547] | 197 | #if GIET_DEBUG_IRQS |
---|
| 198 | _printf("\n[DEBUG IRQS] _ext_irq_alloc() for P[%d,%d,%d] at cycle %d\n" |
---|
| 199 | " wti_id = %d / isr_type = %s / channel = %d / pic_input = %d\n", |
---|
| 200 | x , y , p , _get_proctime() , |
---|
| 201 | wti_id , _isr_type_str[isr_type] , isr_channel , irq_id ); |
---|
| 202 | #endif |
---|
| 203 | |
---|
[528] | 204 | } // end ext_irq_alloc() |
---|
| 205 | |
---|
| 206 | //////////////////////////////////////////// |
---|
| 207 | void _ext_irq_release( unsigned int isr_type, |
---|
| 208 | unsigned int isr_channel, |
---|
| 209 | unsigned int wti_index ) |
---|
| 210 | { |
---|
| 211 | unsigned int irq_id; // external IRQ index in PIC (input) |
---|
| 212 | |
---|
| 213 | // get processor coordinates [x,y,p] |
---|
| 214 | unsigned int gpid = _get_procid(); |
---|
| 215 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
| 216 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 217 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
| 218 | unsigned int p = gpid & ((1<<P_WIDTH)-1); |
---|
| 219 | |
---|
| 220 | // check arguments |
---|
| 221 | if ( isr_type >= GIET_ISR_TYPE_MAX ) |
---|
| 222 | { |
---|
| 223 | _printf("\n[GIET ERROR] in _ext_irq_release() illegal ISR type\n"); |
---|
| 224 | _exit(); |
---|
| 225 | } |
---|
| 226 | if ( isr_channel >= GIET_ISR_CHANNEL_MAX ) |
---|
| 227 | { |
---|
| 228 | _printf("\n[GIET ERROR] in _ext_irq_release() : illegal ISR channel\n"); |
---|
| 229 | _exit(); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | // desactivates dynamically allocated PIC entry |
---|
| 233 | irq_id = _ext_irq_index[isr_type][isr_channel]; |
---|
| 234 | _pic_set_register( irq_id , IOPIC_MASK , 0 ); |
---|
| 235 | |
---|
| 236 | // releases dynamically allocated WTI mailbox |
---|
| 237 | if ( wti_index == p + NB_PROCS_MAX ) _wti_alloc_one[x][y][p] = 0; |
---|
| 238 | else if ( wti_index == p + 2*NB_PROCS_MAX ) _wti_alloc_two[x][y][p] = 0; |
---|
| 239 | else if ( wti_index == p + 3*NB_PROCS_MAX ) _wti_alloc_ter[x][y][p] = 0; |
---|
| 240 | else |
---|
| 241 | { |
---|
| 242 | _printf("\n[GIET ERROR] in _ext_irq_release() : illegal WTI index\n"); |
---|
| 243 | _exit(); |
---|
| 244 | } |
---|
| 245 | } // end ext_irq_release() |
---|
| 246 | |
---|
[440] | 247 | ///////////////// |
---|
[258] | 248 | void _irq_demux() |
---|
| 249 | { |
---|
[294] | 250 | unsigned int gpid = _get_procid(); |
---|
[428] | 251 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
[294] | 252 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 253 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[428] | 254 | unsigned int lpid = gpid & ((1<<P_WIDTH)-1); |
---|
[258] | 255 | unsigned int irq_id; |
---|
[294] | 256 | unsigned int irq_type; |
---|
[258] | 257 | |
---|
| 258 | // get the highest priority active IRQ index |
---|
[294] | 259 | unsigned int icu_out_index = lpid * IRQ_PER_PROCESSOR; |
---|
[258] | 260 | |
---|
[294] | 261 | _xcu_get_index( cluster_xy, icu_out_index, &irq_id, &irq_type ); |
---|
[258] | 262 | |
---|
| 263 | if (irq_id < 32) |
---|
| 264 | { |
---|
[294] | 265 | static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); |
---|
[346] | 266 | unsigned int entry = 0; |
---|
[294] | 267 | unsigned int isr_type; |
---|
| 268 | unsigned int channel; |
---|
[258] | 269 | |
---|
[294] | 270 | if (irq_type == IRQ_TYPE_HWI) entry = psched->hwi_vector[irq_id]; |
---|
| 271 | else if (irq_type == IRQ_TYPE_PTI) entry = psched->pti_vector[irq_id]; |
---|
| 272 | else if (irq_type == IRQ_TYPE_WTI) entry = psched->wti_vector[irq_id]; |
---|
| 273 | else |
---|
[258] | 274 | { |
---|
[294] | 275 | _printf("\n[GIET ERROR] illegal irq_type in irq_demux()\n"); |
---|
| 276 | _exit(); |
---|
[258] | 277 | } |
---|
[294] | 278 | |
---|
| 279 | isr_type = (entry ) & 0x0000FFFF; |
---|
| 280 | channel = (entry>>16) & 0x00007FFF; |
---|
| 281 | |
---|
[547] | 282 | #if GIET_DEBUG_IRQS // we don't take the TTY lock to avoid deadlocks |
---|
| 283 | _nolock_printf("\n[DEBUG IRQS] _irq_demux() Processor[%d,%d,%d] enters at cycle %d\n" |
---|
| 284 | " irq_type = %s / irq_id = %d / isr_type = %s / channel = %d\n", |
---|
| 285 | x , y , lpid , _get_proctime() , |
---|
| 286 | _irq_type_str[irq_type] , irq_id , _isr_type_str[isr_type] , channel ); |
---|
[294] | 287 | #endif |
---|
| 288 | |
---|
| 289 | // ISR call |
---|
| 290 | if ( isr_type == ISR_TICK ) _isr_tick ( irq_type, irq_id, channel ); |
---|
| 291 | else if ( isr_type == ISR_TTY_RX ) _tty_rx_isr ( irq_type, irq_id, channel ); |
---|
| 292 | else if ( isr_type == ISR_TTY_TX ) _tty_tx_isr ( irq_type, irq_id, channel ); |
---|
[547] | 293 | else if ( isr_type == ISR_BDV ) _bdv_isr ( irq_type, irq_id, channel ); |
---|
| 294 | else if ( isr_type == ISR_TIMER ) _timer_isr ( irq_type, irq_id, channel ); |
---|
| 295 | else if ( isr_type == ISR_WAKUP ) _isr_wakup ( irq_type, irq_id, channel ); |
---|
[294] | 296 | else if ( isr_type == ISR_NIC_RX ) _nic_rx_isr ( irq_type, irq_id, channel ); |
---|
| 297 | else if ( isr_type == ISR_NIC_TX ) _nic_tx_isr ( irq_type, irq_id, channel ); |
---|
[547] | 298 | else if ( isr_type == ISR_CMA ) _cma_isr ( irq_type, irq_id, channel ); |
---|
[297] | 299 | else if ( isr_type == ISR_MMC ) _mmc_isr ( irq_type, irq_id, channel ); |
---|
[322] | 300 | else if ( isr_type == ISR_DMA ) _dma_isr ( irq_type, irq_id, channel ); |
---|
[547] | 301 | else if ( isr_type == ISR_SDC ) _sdc_isr ( irq_type, irq_id, channel ); |
---|
[519] | 302 | else if ( isr_type == ISR_MWR ) _mwr_isr ( irq_type, irq_id, channel ); |
---|
[547] | 303 | else if ( isr_type == ISR_HBA ) _hba_isr ( irq_type, irq_id, channel ); |
---|
[294] | 304 | else |
---|
[258] | 305 | { |
---|
[310] | 306 | _printf("\n[GIET ERROR] in _irq_demux() :" |
---|
| 307 | " illegal ISR type on processor[%d,%d,%d] at cycle %d\n" |
---|
[547] | 308 | " - irq_type = %s\n" |
---|
[310] | 309 | " - irq_id = %d\n" |
---|
[547] | 310 | " - isr_type = %s\n", |
---|
| 311 | x, y, lpid, _get_proctime(), |
---|
| 312 | _irq_type_str[irq_type] , irq_id , _isr_type_str[isr_type] ); |
---|
| 313 | _exit(); |
---|
[258] | 314 | } |
---|
| 315 | } |
---|
[294] | 316 | else // no interrupt active |
---|
| 317 | { |
---|
| 318 | _isr_default(); |
---|
| 319 | } |
---|
[258] | 320 | } |
---|
| 321 | |
---|
[440] | 322 | /////////////////// |
---|
[294] | 323 | void _isr_default() |
---|
[258] | 324 | { |
---|
[294] | 325 | unsigned int gpid = _get_procid(); |
---|
[428] | 326 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
[294] | 327 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 328 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[428] | 329 | unsigned int lpid = gpid & ((1<<P_WIDTH)-1); |
---|
[258] | 330 | |
---|
[322] | 331 | _printf("\n[GIET WARNING] IRQ handler called but no active IRQ " |
---|
| 332 | "on processor[%d,%d,%d] at cycle %d\n", |
---|
| 333 | x, y, lpid, _get_proctime() ); |
---|
[258] | 334 | } |
---|
| 335 | |
---|
| 336 | |
---|
[440] | 337 | //////////////////////////////////////////////////////////// |
---|
[294] | 338 | void _isr_wakup( unsigned int irq_type, // HWI / WTI / PTI |
---|
| 339 | unsigned int irq_id, // index returned by ICU |
---|
| 340 | unsigned int channel ) // unused |
---|
[258] | 341 | { |
---|
[428] | 342 | unsigned int gpid = _get_procid(); |
---|
| 343 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
[294] | 344 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 345 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[528] | 346 | unsigned int p = gpid & ((1<<P_WIDTH)-1); |
---|
[428] | 347 | |
---|
[528] | 348 | unsigned int value; // WTI mailbox value |
---|
| 349 | unsigned int save_sr; // save SR value in pre-empted task stack |
---|
[258] | 350 | |
---|
[528] | 351 | unsigned int ltid = _get_current_task_id(); |
---|
| 352 | |
---|
[294] | 353 | if ( irq_type != IRQ_TYPE_WTI ) |
---|
[258] | 354 | { |
---|
[528] | 355 | _printf("[GIET ERROR] P[%d,%d,%d] enters _isr_wakup() at cycle %d\n" |
---|
| 356 | " but not called by a WTI interrupt\n", |
---|
| 357 | x , y , p , _get_proctime() ); |
---|
[294] | 358 | _exit(); |
---|
[258] | 359 | } |
---|
| 360 | |
---|
[294] | 361 | // get mailbox value and acknowledge WTI |
---|
| 362 | _xcu_get_wti_value( cluster_xy, irq_id, &value ); |
---|
| 363 | |
---|
[528] | 364 | #if GIET_DEBUG_SWITCH |
---|
| 365 | _printf("\n[DEBUG SWITCH] P[%d,%d,%d] enters _isr_wakup() at cycle %d\n" |
---|
| 366 | " WTI index = %d / current ltid = %d / mailbox value = %x\n", |
---|
| 367 | x , y , p , _get_proctime() , irq_id , ltid , value ); |
---|
[258] | 368 | #endif |
---|
| 369 | |
---|
[528] | 370 | // enter critical section and swich context (if required) |
---|
| 371 | if ( (ltid == IDLE_TASK_INDEX) || (value != 0) ) |
---|
| 372 | { |
---|
| 373 | _it_disable( &save_sr ); |
---|
| 374 | _ctx_switch(); |
---|
| 375 | _it_restore( &save_sr ); |
---|
| 376 | } |
---|
| 377 | |
---|
[440] | 378 | } // end _isr_wakup |
---|
[258] | 379 | |
---|
[440] | 380 | /////////////////////////////////////////////////////////// |
---|
[294] | 381 | void _isr_tick( unsigned int irq_type, // HWI / WTI / PTI |
---|
| 382 | unsigned int irq_id, // index returned by ICU |
---|
| 383 | unsigned int channel ) // channel index if HWI |
---|
[258] | 384 | { |
---|
[428] | 385 | unsigned int gpid = _get_procid(); |
---|
| 386 | unsigned int cluster_xy = gpid >> P_WIDTH; |
---|
[440] | 387 | unsigned int x = cluster_xy >> Y_WIDTH; |
---|
| 388 | unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); |
---|
[528] | 389 | unsigned int p = gpid & ((1<<P_WIDTH)-1); |
---|
[258] | 390 | |
---|
[528] | 391 | unsigned int save_sr; // save SR value in pre-empted task stack |
---|
| 392 | |
---|
[440] | 393 | if ( irq_type != IRQ_TYPE_PTI ) |
---|
| 394 | { |
---|
[528] | 395 | _printf("[GIET ERROR] P[%d,%d,%d] enters _isr_tick() at cycle %d\n" |
---|
| 396 | " but not called by a PTI interrupt\n", |
---|
| 397 | x , y , p , _get_proctime() ); |
---|
[440] | 398 | _exit(); |
---|
| 399 | } |
---|
[258] | 400 | |
---|
[440] | 401 | // acknowledge PTI |
---|
| 402 | _xcu_timer_reset_irq( cluster_xy, irq_id ); |
---|
| 403 | |
---|
[528] | 404 | #if GIET_DEBUG_SWITCH |
---|
| 405 | unsigned int ltid = _get_current_task_id(); |
---|
| 406 | _printf("\n[DEBUG SWITCH] P[%d,%d,%d] enters _isr_tick() at cycle %d\n" |
---|
| 407 | " WTI index = %d / current ltid = %d\n", |
---|
| 408 | x , y , p , _get_proctime() , irq_id , ltid ); |
---|
[258] | 409 | #endif |
---|
| 410 | |
---|
[528] | 411 | // enter critical section and switch context |
---|
| 412 | _it_disable( &save_sr ); |
---|
[258] | 413 | _ctx_switch(); |
---|
[528] | 414 | _it_restore( &save_sr ); |
---|
| 415 | |
---|
[440] | 416 | } // end _isr_tick |
---|
[258] | 417 | |
---|
| 418 | |
---|
| 419 | // Local Variables: |
---|
| 420 | // tab-width: 4 |
---|
| 421 | // c-basic-offset: 4 |
---|
| 422 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 423 | // indent-tabs-mode: nil |
---|
| 424 | // End: |
---|
| 425 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 426 | |
---|