Changeset 686 for trunk/hal/tsar_mips32/drivers/soclib_pic.c
- Timestamp:
- Jan 13, 2021, 12:47:53 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/hal/tsar_mips32/drivers/soclib_pic.c
r679 r686 2 2 * soclib_pic.c - soclib PIC driver implementation. 3 3 * 4 * Author Alain Greiner (2016,2017,2018,2019 )4 * Author Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 39 39 ////////////////////////////////////////////////////////////////////////////////////// 40 40 41 extern chdev_directory_t chdev_dir; 41 extern chdev_directory_t chdev_dir; // defined in chdev.h / allocated in kerneL-init.c 42 42 43 43 extern iopic_input_t iopic_input; // defined in dev_pic.h / allocated in kernel_init.c … … 58 58 soclib_pic_cluster_t * ext_ptr = LOCAL_CLUSTER->pic_extend; 59 59 60 61 "no free WTI found : too much external IRQs\n");60 assert( __FUNCTION__, (ext_ptr->first_free_wti < ext_ptr->wti_nr) , 61 "no free WTI found : too much external IRQs"); 62 62 63 63 // update WTI allocator … … 147 147 if( index < LOCAL_CLUSTER->cores_nr ) // it is an IPI 148 148 { 149 assert( __FUNCTION__, (index == core->lid) , "illegal IPI index" ); 149 150 assert( __FUNCTION__, (index == core->lid), 151 "illegal IPI index" ); 150 152 151 153 #if DEBUG_HAL_IRQS … … 170 172 { 171 173 printk("\n[WARNING] in %s : no handler for WTI %d on core %d in cluster %x\n", 172 __FUNCTION__ , index , core->lid , local_cxy ); 173 174 core->spurious_irqs ++; 174 __FUNCTION__ , index , core->lid , local_cxy ); 175 175 176 176 // disable WTI in local XCU controller … … 204 204 { 205 205 printk("\n[WARNING] in %s : no handler for HWI %d on core %d in cluster %x\n", 206 __FUNCTION__ , index , core->lid , local_cxy ); 207 208 core->spurious_irqs ++; 206 __FUNCTION__ , index , core->lid , local_cxy ); 209 207 210 208 // disable HWI in local XCU controller … … 230 228 index = pti_status - 1; 231 229 232 assert( __FUNCTION__, (index == core->lid) , "unconsistent PTI index\n"); 230 assert( __FUNCTION__, (index == core->lid), 231 "unconsistent PTI index\n"); 233 232 234 233 #if DEBUG_HAL_IRQS … … 278 277 soclib_pic_cluster_t * cluster_ext_ptr; 279 278 soclib_pic_core_t * core_ext_ptr; 280 kmem_req_t req;281 279 uint32_t lid; 282 280 uint32_t idx; … … 288 286 { 289 287 // allocate memory for core extension 290 req.type = KMEM_KCM; 291 req.order = bits_log2( sizeof(soclib_pic_core_t) ); 292 req.flags = AF_KERNEL; 293 core_ext_ptr = kmem_alloc( &req ); 288 core_ext_ptr = kmem_alloc( bits_log2( sizeof(soclib_pic_core_t)) , AF_KERNEL ); 294 289 295 290 if( core_ext_ptr == NULL ) … … 308 303 309 304 // allocate memory for cluster extension 310 req.type = KMEM_KCM; 311 req.order = bits_log2( sizeof(soclib_pic_cluster_t) ); 312 req.flags = AF_KERNEL; 313 cluster_ext_ptr = kmem_alloc( &req ); 305 cluster_ext_ptr = kmem_alloc( bits_log2( sizeof(soclib_pic_cluster_t) ), AF_KERNEL ); 314 306 315 307 if( cluster_ext_ptr == NULL ) … … 319 311 } 320 312 321 assert( __FUNCTION__, (cluster_ext_ptr != NULL) , "cannot allocate memory for cluster extension");322 323 313 // get XCU characteristics from the XCU config register 324 314 uint32_t config = xcu_base[XCU_CONFIG<<5]; … … 380 370 bool_t is_rx = src_chdev->is_rx; 381 371 382 if( (func == DEV_FUNC_IOC && impl == IMPL_IOC_BDV) || (func == DEV_FUNC_NIC) || 383 (func == DEV_FUNC_TXT && impl == IMPL_TXT_TTY) || (func == DEV_FUNC_IOB) ) // external IRQ => WTI 372 if( ((func == DEV_FUNC_IOC) && (impl == IMPL_IOC_BDV)) || 373 (func == DEV_FUNC_NIC) || 374 ((func == DEV_FUNC_TXT) && (impl == IMPL_TXT_TTY)) || 375 (func == DEV_FUNC_IOB) ) // external IRQ => WTI 384 376 { 385 377 // get external IRQ index 386 378 uint32_t hwi_id = 0; 387 379 if ( func == DEV_FUNC_IOC ) hwi_id = iopic_input.ioc[channel]; 388 else if( func == DEV_FUNC_TXT&& is_rx ) hwi_id = iopic_input.txt_rx[channel];389 else if( func == DEV_FUNC_TXT&& !is_rx ) hwi_id = iopic_input.txt_tx[channel];380 else if( (func == DEV_FUNC_TXT) && is_rx ) hwi_id = iopic_input.txt_rx[channel]; 381 else if( (func == DEV_FUNC_TXT) && !is_rx ) hwi_id = iopic_input.txt_tx[channel]; 390 382 else if( (func == DEV_FUNC_NIC) && is_rx ) hwi_id = iopic_input.nic_rx[channel]; 391 383 else if( (func == DEV_FUNC_NIC) && !is_rx ) hwi_id = iopic_input.nic_tx[channel]; 392 384 else if( func == DEV_FUNC_IOB ) hwi_id = iopic_input.iob; 393 else assert( __FUNCTION__, false , "illegal device functionnal type\n"); 385 else 386 { 387 printk("\n[WARNING] from %s : illegal device / func %s / is_rx %d\n", 388 __FUNCTION__, chdev_func_str(func), is_rx ); 389 } 394 390 395 391 // get a WTI mailbox from local XCU descriptor … … 420 416 #if DEBUG_HAL_IRQS 421 417 if( DEBUG_HAL_IRQS < cycle ) 422 printk("\n[DBG] %s : %s / channel = %d / rx = %d / hwi_id = %d / wti_id = %d / cluster =%x\n",418 printk("\n[DBG] %s : %s / channel %d / rx %d / hwi_id %d / wti_id %d / cluster %x\n", 423 419 __FUNCTION__ , chdev_func_str( func ) , channel , is_rx , hwi_id , wti_id , local_cxy ); 424 420 #endif 425 421 426 422 } 427 else if( (func == DEV_FUNC_DMA) || (func == DEV_FUNC_MMC) || 423 else if( (func == DEV_FUNC_DMA) || 424 (func == DEV_FUNC_MMC) || 428 425 (func == DEV_FUNC_TXT && impl == IMPL_TXT_MTY) || 429 426 (func == DEV_FUNC_IOC && impl == IMPL_IOC_SPI) ) // internal IRQ => HWI … … 431 428 // get internal IRQ index 432 429 uint32_t hwi_id; 433 if( func == DEV_FUNC_DMA ) hwi_id = lapic_input.dma[channel];430 if( func == DEV_FUNC_DMA ) hwi_id = lapic_input.dma[channel]; 434 431 else if (func == DEV_FUNC_TXT ) hwi_id = lapic_input.mtty; 435 432 else if (func == DEV_FUNC_IOC ) hwi_id = lapic_input.sdcard; 436 else hwi_id = lapic_input.mmc;433 else hwi_id = lapic_input.mmc; 437 434 438 435 // register IRQ type and index in chdev … … 453 450 else 454 451 { 455 assert( __FUNCTION__, false , "illegal device functionnal type\n" ); 452 printk("\n[WARNING] from %s : illegal device / func %s / is_rx %d / impl %d\n", 453 __FUNCTION__, chdev_func_str(func), is_rx, impl ); 456 454 } 457 455 } // end soclib_pic_bind_irq(); … … 477 475 // in TSAR : XCU output [4*lid] is connected to core [lid] 478 476 hal_remote_s32( XPTR( src_chdev_cxy , 479 477 &seg_xcu_ptr[ (XCU_MSK_HWI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) ); 480 478 } 481 479 else if( irq_type == SOCLIB_TYPE_WTI ) … … 484 482 // in TSAR : XCU output [4*lid] is connected to core [lid] 485 483 hal_remote_s32( XPTR( src_chdev_cxy , 486 484 &seg_xcu_ptr[ (XCU_MSK_WTI_ENABLE << 5) | (lid<<2) ] ) , (1 << irq_id) ); 487 485 } 488 486 else 489 487 { 490 assert( __FUNCTION__, false , "illegal IRQ type\n" ); 488 printk("\n[WARNING] from %s : illegal IRQ type %d\n", 489 __FUNCTION__, irq_type ); 491 490 } 492 491 } // end soclib_pic_enable_irq() … … 512 511 // in TSAR : XCU output [4*lid] is connected to core [lid] 513 512 hal_remote_s32( XPTR( src_chdev_cxy , 514 513 &seg_xcu_ptr[(XCU_MSK_HWI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) ); 515 514 } 516 515 else if( irq_type == SOCLIB_TYPE_WTI ) … … 519 518 // in TSAR : XCU output [4*lid] is connected to core [lid] 520 519 hal_remote_s32( XPTR( src_chdev_cxy , 521 520 &seg_xcu_ptr[(XCU_MSK_WTI_DISABLE << 5) | (lid<<2) ] ) , (1 << irq_id) ); 522 521 } 523 522 else 524 523 { 525 assert( __FUNCTION__, false , "illegal IRQ type\n" ); 524 printk("\n[WARNING] from %s : illegal IRQ type %d\n", 525 __FUNCTION__, irq_type ); 526 526 } 527 527 } // end soclib_pic_enable_irq() … … 570 570 } 571 571 572 ///////////////////////// 572 /////////////////////////////// 573 573 void soclib_pic_ack_ipi( void ) 574 574 { … … 582 582 uint32_t ack = base[ (XCU_WTI_REG << 5) | lid ]; 583 583 584 // we m ust make a fake use for ack value to avoid a warning584 // we make a fake use for ack value to avoid a warning 585 585 if( (ack + 1) == 0 ) asm volatile( "nop" ); 586 586 }
Note: See TracChangeset
for help on using the changeset viewer.