Changeset 709 for soft/giet_vm/giet_drivers/bdv_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/bdv_driver.c
r657 r709 37 37 spin_lock_t _bdv_lock __attribute__((aligned(64))); 38 38 39 // global index of the waiting t ask(only used in descheduling mode)39 // global index of the waiting thread (only used in descheduling mode) 40 40 __attribute__((section(".kdata"))) 41 unsigned int _bdv_ gtid;41 unsigned int _bdv_trdid; 42 42 43 43 // BDV peripheral status (only used in descheduling mode) … … 75 75 unsigned int count) 76 76 { 77 unsigned int procid = _get_procid(); 78 unsigned int x = procid >> (Y_WIDTH + P_WIDTH); 79 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH) - 1);80 unsigned int p = procid & ((1<<P_WIDTH)-1);81 82 #if GIET_DEBUG_IOC 77 78 #if GIET_DEBUG_IOC 79 unsigned int procid = _get_procid(); 80 unsigned int x = procid >> (Y_WIDTH + P_WIDTH); 81 unsigned int y = (procid >> P_WIDTH) & ((1<<Y_WIDTH) - 1); 82 unsigned int p = procid & ((1<<P_WIDTH)-1); 83 83 if ( _get_proctime() > GIET_DEBUG_IOC ) 84 84 _printf("\n[BDV DEBUG] P[%d,%d,%d] enters _bdv_access at cycle %d\n" … … 97 97 unsigned int status; 98 98 99 // get the lock protecting BDV 99 // get the BDV lock and register it in task context 100 static_scheduler_t* psched = _get_sched(); 101 unsigned int ltid = _get_thread_ltid(); 100 102 _spin_lock_acquire( &_bdv_lock ); 103 _atomic_or( &psched->context[ltid].slot[CTX_LOCKS_ID] , LOCKS_MASK_BDV ); 101 104 102 105 // set device registers … … 149 152 150 153 ///////////////////////////////////////////////////////////////// 151 // in descheduling mode, we deschedule the t ask152 // and use an interrupt to reschedule the t ask.154 // in descheduling mode, we deschedule the thread 155 // and use an interrupt to reschedule the thread. 153 156 // We need a critical section, because we must reset the RUN bit 154 157 // before to launch the transfer, and we don't want to be … … 158 161 { 159 162 unsigned int save_sr; 160 unsigned int ltid = _get_current_task_id();161 163 162 164 // activates BDV interrupt 163 165 _bdv_set_register( BLOCK_DEVICE_IRQ_ENABLE, 1 ); 164 166 165 // set _bdv_ gtid166 _bdv_ gtid = (procid<<16) + ltid;167 // set _bdv_trdid 168 _bdv_trdid = _get_thread_trdid(); 167 169 168 170 // enters critical section … … 170 172 171 173 // Set NORUN_MASK_IOC bit 172 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 173 _atomic_or( &psched->context[ltid][CTX_NORUN_ID] , NORUN_MASK_IOC ); 174 static_scheduler_t* psched = (static_scheduler_t*)_get_sched(); 175 unsigned int ltid = psched->current; 176 _atomic_or( &psched->context[ltid].slot[CTX_NORUN_ID] , NORUN_MASK_IOC ); 174 177 175 178 // launch transfer … … 184 187 #endif 185 188 186 // deschedule t ask189 // deschedule thread 187 190 _ctx_switch(); 188 191 … … 201 204 } 202 205 203 // release lock206 // release BDV lock and clear task context 204 207 _spin_lock_release( &_bdv_lock ); 208 _atomic_and( &psched->context[ltid].slot[CTX_LOCKS_ID] , ~LOCKS_MASK_BDV ); 205 209 206 210 #if GIET_DEBUG_IOC … … 241 245 _bdv_status = status; 242 246 243 // identify task waiting on BDV 244 unsigned int procid = _bdv_gtid>>16; 245 unsigned int ltid = _bdv_gtid & 0xFFFF; 246 unsigned int cluster = procid >> P_WIDTH; 247 unsigned int x = cluster >> Y_WIDTH; 248 unsigned int y = cluster & ((1<<Y_WIDTH)-1); 249 unsigned int p = procid & ((1<<P_WIDTH)-1); 247 // identify thread waiting on BDV 248 unsigned int x = (_bdv_trdid >> 24) & 0xFF; 249 unsigned int y = (_bdv_trdid >> 16) & 0xFF; 250 unsigned int p = (_bdv_trdid >> 8) & 0xFF; 251 unsigned int ltid = (_bdv_trdid ) & 0xFF; 250 252 251 253 // Reset NORUN_MASK_IOC bit 252 254 static_scheduler_t* psched = (static_scheduler_t*)_schedulers[x][y][p]; 253 unsigned int* ptr = &psched->context[ltid] [CTX_NORUN_ID];255 unsigned int* ptr = &psched->context[ltid].slot[CTX_NORUN_ID]; 254 256 _atomic_and( ptr , ~NORUN_MASK_IOC ); 255 257 256 // send a WAKUP WTI to processor running the sleeping t ask257 _xcu_send_wti( cluster,258 // send a WAKUP WTI to processor running the sleeping thread 259 _xcu_send_wti( (x<<Y_WIDTH) + y, 258 260 p, 259 261 0 ); // don't force context switch … … 266 268 if ( _get_proctime() > GIET_DEBUG_IOC ) 267 269 _printf("\n[BDV DEBUG] Processor[%d,%d,%d] enters _bdv_isr() at cycle %d\n" 268 " for t ask%d running on P[%d,%d,%d] / bdv_status = %x\n",270 " for thread %d running on P[%d,%d,%d] / bdv_status = %x\n", 269 271 c_x , c_y , c_p , _get_proctime() , 270 272 ltid , x , y , p , status );
Note: See TracChangeset
for help on using the changeset viewer.