Changeset 128
- Timestamp:
- Jul 3, 2017, 3:06:59 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_icu.c
r23 r128 56 56 icu->ext.icu.wti_bitmap = 0; 57 57 spinlock_init( &icu->ext.icu.wti_lock ); 58 58 59 59 // get implementation 60 60 uint32_t impl = icu->impl; … … 73 73 assert( false , __FUNCTION__ , "undefined ICU implementation" ); 74 74 } 75 } // end dev_icu_init()75 } 76 76 77 77 ///////////////////////////////////////////////////////////////////////////////////// … … 83 83 uint32_t irq_index ) 84 84 { 85 if( irq_type == HWI_TYPE ) 85 if( irq_type == HWI_TYPE ) 86 86 { 87 87 if( irq_index >= icu->ext.icu.hwi_nr ) 88 88 { 89 printk("\n[PANIC] in %s : illegal HWI index = %d / max = %d\n", 89 printk("\n[PANIC] in %s : illegal HWI index = %d / max = %d\n", 90 90 __FUNCTION__ , irq_index , icu->ext.icu.hwi_nr ); 91 91 hal_core_sleep(); … … 96 96 if( irq_index >= icu->ext.icu.wti_nr ) 97 97 { 98 printk("\n[PANIC] in %s : illegal WTI index = %d / max = %d\n", 98 printk("\n[PANIC] in %s : illegal WTI index = %d / max = %d\n", 99 99 __FUNCTION__ , irq_index , icu->ext.icu.wti_nr ); 100 100 hal_core_sleep(); 101 101 } 102 102 } 103 else // irq_type == PTI_TYPE 103 else // irq_type == PTI_TYPE 104 104 { 105 105 if( irq_index >= icu->ext.icu.pti_nr ) … … 110 110 } 111 111 } 112 } // end dev_icu_check_irq()112 } 113 113 114 114 //////////////////////////////////////// … … 126 126 127 127 // call implementation specific ICU driver to enable IRQ 128 if( icu->impl == IMPL_ICU_XCU ) 128 if( icu->impl == IMPL_ICU_XCU ) 129 129 { 130 130 soclib_xcu_enable_irq( icu , 1<<irq_index , irq_type , lid ); … … 137 137 // source chdev pointer in relevant interrupt vector 138 138 core_t * core = &LOCAL_CLUSTER->core_tbl[lid]; 139 139 core_set_irq_vector_entry( core , irq_type , irq_index , src_chdev ); 140 140 141 141 // (3) register IRQ type and index in source chdev descriptor … … 143 143 src_chdev->irq_id = irq_index; 144 144 } 145 } // end dev_icu_enable_irq()145 } 146 146 147 147 ///////////////////////////////////////// … … 157 157 dev_icu_check_irq( icu , irq_type , irq_index ); 158 158 159 // call the implementation specific ICU driver to disable IRQ 160 if( icu->impl == IMPL_ICU_XCU ) 159 // call the implementation specific ICU driver to disable IRQ 160 if( icu->impl == IMPL_ICU_XCU ) 161 161 { 162 162 soclib_xcu_disable_irq( icu , 1<<irq_index , irq_type , lid ); … … 169 169 // the source chdev xptr from relevant interrupt vector 170 170 core_t * core = &LOCAL_CLUSTER->core_tbl[lid]; 171 172 } 173 } // end dev_icu_disable_irq()171 core_set_irq_vector_entry( core , irq_type , irq_index , NULL ); 172 } 173 } 174 174 175 175 /////////////////////////////////////// … … 198 198 199 199 // check PTI index 200 assert( (pti_index < icu->ext.icu.pti_nr) , __FUNCTION__ , "illegal PTI index" ); 201 202 // call the implementation specific driver ICU to set period 203 if( icu->impl == IMPL_ICU_XCU ) 200 assert( (pti_index < icu->ext.icu.pti_nr) , __FUNCTION__ , "illegal PTI index" ); 201 202 // call the implementation specific driver ICU to set period 203 if( icu->impl == IMPL_ICU_XCU ) 204 204 { 205 205 soclib_xcu_set_period( icu , pti_index , period ); 206 206 } 207 } // end dev_icu_set_period()207 } 208 208 209 209 //////////////////////////////////////////// … … 215 215 216 216 // check PTI index 217 assert( (pti_index < icu->ext.icu.pti_nr) , __FUNCTION__ , "illegal PTI index" ); 217 assert( (pti_index < icu->ext.icu.pti_nr) , __FUNCTION__ , "illegal PTI index" ); 218 218 219 219 // call the implementation specific driver ICU to acknowledge PTI IRQ 220 if( icu->impl == IMPL_ICU_XCU ) 220 if( icu->impl == IMPL_ICU_XCU ) 221 221 { 222 222 soclib_xcu_ack_timer( icu , pti_index ); 223 223 } 224 } // end dev_icu_ack_timer()224 } 225 225 226 226 //////////////////////////////////// … … 228 228 lid_t lid ) 229 229 { 230 // check arguments 230 // check arguments 231 231 cluster_t * cluster = LOCAL_CLUSTER; 232 232 uint32_t y_width = cluster->y_width; … … 249 249 250 250 // get implementation from remote ICU chdev 251 uint32_t impl = hal_remote_lw( XPTR( icu_cxy , &icu_ptr->impl ) ); 251 uint32_t impl = hal_remote_lw( XPTR( icu_cxy , &icu_ptr->impl ) ); 252 252 253 253 // call the implementation specific ICU driver to send IPI 254 if( impl == IMPL_ICU_XCU ) 254 if( impl == IMPL_ICU_XCU ) 255 255 { 256 256 soclib_xcu_send_ipi( icu_xp , lid ); 257 257 } 258 } // end dev_icu_send_ipi()258 } 259 259 260 260 ////////////////////////// … … 273 273 chdev_t * icu = (chdev_t *)GET_PTR( icu_xp ); 274 274 275 // call the implementation specific ICU driver 275 // call the implementation specific ICU driver 276 276 // to return highest priority pending IRQ of each type 277 277 if( icu->impl == IMPL_ICU_XCU ) … … 282 282 // analyse ICU status and handle up to 3 pending IRQ (one WTI, one HWI, one PTI) 283 283 284 if( wti_status ) // pending WTI 285 284 if( wti_status ) // pending WTI 285 { 286 286 index = wti_status - 1; 287 287 … … 297 297 { 298 298 // get pointer on IRQ source chdev 299 300 301 302 299 src_chdev = core->wti_vector[index]; 300 301 if( src_chdev == NULL ) // strange, but not fatal => disable IRQ 302 { 303 303 printk("\n[WARNING] in %s : no handler for WTI %d on core %d in cluster %x\n", 304 304 __FUNCTION__ , index , core->lid , local_cxy ); 305 306 dev_icu_disable_irq( core->lid , WTI_TYPE , index ); 305 core->spurious_irqs ++; 306 dev_icu_disable_irq( core->lid , WTI_TYPE , index ); 307 307 } 308 308 else // call relevant ISR 309 309 { 310 310 icu_dmsg("\n[INFO] %s received WTI : index = %d for cpu %d in cluster %d\n", 311 311 __FUNCTION__ , index , core->lid , local_cxy ); 312 312 313 313 // call ISR 314 314 src_chdev->isr( src_chdev ); 315 315 } 316 316 } 317 318 319 320 317 } 318 319 if( hwi_status ) // pending HWI 320 { 321 321 index = hwi_status - 1; 322 322 323 323 // get pointer on IRQ source chdev 324 325 326 327 324 src_chdev = core->hwi_vector[index]; 325 326 if( src_chdev == NULL ) // strange, but not fatal => disable IRQ 327 { 328 328 printk("\n[WARNING] in %s : no handler for HWI %d on core %d in cluster %x\n", 329 329 __FUNCTION__ , index , core->lid , local_cxy ); 330 331 dev_icu_disable_irq( core->lid , HWI_TYPE , index ); 332 330 core->spurious_irqs ++; 331 dev_icu_disable_irq( core->lid , HWI_TYPE , index ); 332 } 333 333 else // call relevant ISR 334 334 { 335 335 icu_dmsg("\n[INFO] %s received HWI : index = %d for cpu %d in cluster %d\n", 336 336 __FUNCTION__ , index , core->lid , local_cxy ); 337 337 338 338 // call ISR 339 340 } 341 339 src_chdev->isr( src_chdev ); 340 } 341 } 342 342 343 343 if( pti_status ) // pending PTI 344 344 { 345 345 index = pti_status - 1; 346 346 347 347 icu_dmsg("\n[INFO] %s received PTI : index = %d for cpu %d in cluster %d\n", 348 348 __FUNCTION__ , index , core->lid , local_cxy ); 349 349 … … 360 360 printk("\n[WARNING] in %s : no handler for PTI %d on core %d in cluster %x\n", 361 361 __FUNCTION__ , index , core->lid , local_cxy ); 362 363 dev_icu_disable_irq( core->lid , PTI_TYPE , index ); 364 } 365 366 } // end dev_icu_irq_handler()362 core->spurious_irqs ++; 363 dev_icu_disable_irq( core->lid , PTI_TYPE , index ); 364 } 365 } 366 } 367 367 368 368 //////////////////////////// … … 383 383 // get first free mailbox index 384 384 uint32_t index = (uint32_t)bitmap_ffc( bitmap , size ); 385 385 386 386 // set bitmap entry if found 387 387 if( index < size ) bitmap_set( bitmap , index ); … … 389 389 // release lock 390 390 spinlock_unlock( lock ); 391 391 392 392 return index; 393 } // end dev_icu_wti_alloc()393 } 394 394 395 395 ////////////////////////////////////////// … … 411 411 spinlock_lock( lock ); 412 412 413 // clear bitmap entry 413 // clear bitmap entry 414 414 bitmap_clear( bitmap , index ); 415 415 416 416 // release lock 417 417 spinlock_unlock( lock ); 418 419 } // end dev_icu_wti_release() 418 } 420 419 421 420 ////////////////////////////////////////////// … … 431 430 if( icu->impl == IMPL_ICU_XCU ) 432 431 { 433 wti_ptr = soclib_xcu_wti_ptr( icu , wti_id ); 432 wti_ptr = soclib_xcu_wti_ptr( icu , wti_id ); 434 433 } 435 434 436 435 return wti_ptr; 437 } // end dev_icu_wti_xptr() 438 439 436 } 437
Note: See TracChangeset
for help on using the changeset viewer.