Changeset 709 for soft/giet_vm/giet_drivers/hba_driver.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/hba_driver.c
r657 r709 46 46 sqt_lock_t _hba_allocator_lock __attribute__((aligned(64))); 47 47 48 // state of each slot (allocated to a t askor not)48 // state of each slot (allocated to a thread or not) 49 49 // access must be protected by the allocator_lock in descheduling mode 50 50 __attribute__((section(".kdata"))) … … 56 56 unsigned int _hba_active_cmd[32]; 57 57 58 // global index of the t ask, for each entry in the command list59 __attribute__((section(".kdata"))) 60 unsigned int _hba_ gtid[32];58 // global index of the thread, for each entry in the command list 59 __attribute__((section(".kdata"))) 60 unsigned int _hba_trid[32]; 61 61 62 62 // status of HBA commands … … 97 97 98 98 /////////////////////////////////////////////////////////////////////////////// 99 // This blocking fonction allocates a free command index to the t ask.99 // This blocking fonction allocates a free command index to the thread. 100 100 // The hba_allocator_lock is not used in boot mode. 101 101 // It returns the allocated command index (between 0 and 31) … … 132 132 /////////////////////////////////////////////////////////////////////////////// 133 133 // This function releases the command index in the hba_allocated_cmd table. 134 // There is no need to take the lock because only the t askwhich owns the134 // There is no need to take the lock because only the thread which owns the 135 135 // command can release it. 136 136 // return 0 if success, -1 if error … … 281 281 282 282 ///////////////////////////////////////////////////////////////// 283 // in descheduling mode, we deschedule the t ask284 // and use an interrupt to reschedule the t ask.283 // in descheduling mode, we deschedule the thread 284 // and use an interrupt to reschedule the thread. 285 285 // We need a critical section, because we must set the NORUN bit 286 286 // before to launch the transfer, and we don't want to be … … 297 297 #endif 298 298 unsigned int save_sr; 299 unsigned int ltid = _get_ current_task_id();299 unsigned int ltid = _get_thread_ltid(); 300 300 301 301 // activates HBA interrupts 302 302 _hba_set_register( HBA_PXIE , 0x00000001 ); 303 303 304 // set _hba_ gtid[cmd_id]305 _hba_ gtid[cmd_id] = (procid<<16) + ltid;304 // set _hba_trid[cmd_id] 305 _hba_trid[cmd_id] = (x<<24) + (y<<16) + (p<<8) + ltid; 306 306 307 307 // enters critical section … … 310 310 // Set NORUN_MASK_IOC bit 311 311 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 312 unsigned int* ptr = &psched->context[ltid] [CTX_NORUN_ID];312 unsigned int* ptr = &psched->context[ltid].slot[CTX_NORUN_ID]; 313 313 _atomic_or( ptr , NORUN_MASK_IOC ); 314 314 … … 319 319 _hba_active_cmd[cmd_id] = 1; 320 320 321 // deschedule t ask321 // deschedule thread 322 322 _ctx_switch(); 323 323 324 324 #if GIET_DEBUG_IOC 325 325 if (_get_proctime() > GIET_DEBUG_IOC) 326 _printf("\n[DEBUG HBA] _hba_access() : t ask%d on P[%d,%d,%d] resume at cycle %d\n",326 _printf("\n[DEBUG HBA] _hba_access() : thread %d on P[%d,%d,%d] resume at cycle %d\n", 327 327 ltid , x , y , p , _get_proctime() ); 328 328 #endif … … 438 438 _hba_active_cmd[cmd_id] = 0; 439 439 440 // identify waiting task 441 unsigned int procid = _hba_gtid[cmd_id]>>16; 442 unsigned int ltid = _hba_gtid[cmd_id] & 0xFFFF; 443 unsigned int cluster = procid >> P_WIDTH; 444 unsigned int x = cluster >> Y_WIDTH; 445 unsigned int y = cluster & ((1<<Y_WIDTH)-1); 446 unsigned int p = procid & ((1<<P_WIDTH)-1); 440 // identify waiting thread 441 unsigned int x = (_hba_trid[cmd_id]>>24) & 0xFF; 442 unsigned int y = (_hba_trid[cmd_id]>>16) & 0xFF; 443 unsigned int p = (_hba_trid[cmd_id]>> 8) & 0xFF; 444 unsigned int ltid = (_hba_trid[cmd_id] ) & 0xFF; 447 445 448 446 // Reset NORUN_MASK_IOC bit 449 447 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 450 _atomic_and( &psched->context[ltid] [CTX_NORUN_ID] , ~NORUN_MASK_IOC );451 452 // send a WAKUP WTI to processor running the waiting t ask453 _xcu_send_wti( cluster ,448 _atomic_and( &psched->context[ltid].slot[CTX_NORUN_ID] , ~NORUN_MASK_IOC ); 449 450 // send a WAKUP WTI to processor running the waiting thread 451 _xcu_send_wti( (x<<Y_WIDTH) + y, 454 452 p , 455 453 0 ); // don't force context switch … … 458 456 if (_get_proctime() > GIET_DEBUG_IOC) 459 457 _printf("\n[DEBUG HBA] _hba_isr() : command %d completed at cycle %d\n" 460 " resume t ask%d running on P[%d,%d,%d]\n",458 " resume thread %d running on P[%d,%d,%d]\n", 461 459 cmd_id , _get_proctime() , 462 460 ltid , x , y , p );
Note: See TracChangeset
for help on using the changeset viewer.