Changeset 648 for soft/giet_vm/giet_kernel/kernel_init.c
- Timestamp:
- Jul 22, 2015, 1:11:08 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/kernel_init.c
r629 r648 266 266 // initialisation, from values stored in the tasks contexts. 267 267 // - set CTX_RA slot with the kernel _ctx_eret() virtual address. 268 // - set CTX_E PCslot that must contain the task entry point,268 // - set CTX_ENTRY slot that must contain the task entry point, 269 269 // and contain only at this point the virtual address of the 270 // memory slotcontaining this entry point.270 // memory word containing this entry point. 271 271 //////////////////////////////////////////////////////////////////////////// 272 272 … … 283 283 _ptabs_ptprs[vsid][x][y] = ptpr; 284 284 285 // set the ptprto use the local page table285 // set the PTPR to use the local page table 286 286 asm volatile( "mtc2 %0, $0" 287 287 : : "r" (ptpr) ); 288 288 289 // compute ctx_ra289 // set CTX_RA slot 290 290 unsigned int ctx_ra = (unsigned int)(&_ctx_eret); 291 291 _set_task_slot( x, y, p, ltid, CTX_RA_ID, ctx_ra ); 292 292 293 // compute ctx_epc 294 unsigned int* ptr = (unsigned int*)_get_task_slot(x,y,p,ltid,CTX_EPC_ID); 295 _set_task_slot( x , y , p , ltid , CTX_EPC_ID , *ptr ); 293 // set CTX_ENTRY slot 294 unsigned int* ptr = (unsigned int*)_get_task_slot(x , y , p , ltid , CTX_ENTRY_ID); 295 unsigned int ctx_entry = *ptr; 296 _set_task_slot( x , y , p , ltid , CTX_ENTRY_ID , ctx_entry ); 296 297 297 298 #if GIET_DEBUG_INIT … … 300 301 " - ptabs_vaddr[%d][%d][%d] = %x\n" 301 302 " - ptabs_paddr[%d][%d][%d] = %l\n" 302 " - ctx_e pc= %x\n"303 " - ctx_entry = %x\n" 303 304 " - ctx_ra = %x\n", 304 305 x , y , p , ltid , 305 306 vsid , x , y , ptab , 306 307 vsid , x , y , ((unsigned long long)ptpr)<<13 , 307 _get_task_slot( x, y, p, ltid, CTX_EPC_ID ), 308 _get_task_slot( x, y, p, ltid, CTX_RA_ID ) ); 308 ctx_entry, ctx_ra ); 309 309 #endif 310 310 … … 316 316 317 317 //////////////////////////////////////////////////////////////////////////// 318 // step 3 : - Each processor complete idle task context initialisation ,319 // (only the CTX_SP, CTX_RA, CTX_EPC slot, because the CTX_PTPR320 // and CTX_PTAB slotshave been initialised in boot code)318 // step 3 : - Each processor complete idle task context initialisation. 319 // Only CTX_SP, CTX_RA, CTX_EPC slots, because other slots 320 // have been initialised in boot code) 321 321 // The 4 Kbytes idle stack is implemented in the scheduler itself. 322 // - Each processor starts TICK timer, as soon as at least one task 323 // is allocated. 322 // - Each processor starts TICK timer, if at least one task. 324 323 // - P[0,0,0] initialises FAT (not done before, because it must 325 324 // be done after the _ptabs_vaddr[v][x][y] array initialisation, … … 327 326 //////////////////////////////////////////////////////////////////////////// 328 327 329 unsigned int sp = ((unsigned int)psched) + 0x2000;330 unsigned int ra = (unsigned int)(&_ctx_eret);331 unsigned int e pc= (unsigned int)(&_idle_task);332 333 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_SP_ID , sp );334 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_RA_ID , ra );335 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_E PC_ID , epc);328 unsigned int sp = ((unsigned int)psched) + 0x2000; 329 unsigned int ra = (unsigned int)(&_ctx_eret); 330 unsigned int entry = (unsigned int)(&_idle_task); 331 332 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_SP_ID , sp ); 333 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_RA_ID , ra ); 334 _set_task_slot( x , y , p , IDLE_TASK_INDEX , CTX_ENTRY_ID , entry ); 336 335 337 336 if (tasks > 0) _xcu_timer_start( cluster_xy, p, GIET_TICK_VALUE ); … … 358 357 359 358 //////////////////////////////////////////////////////////////////////////// 360 // step 4 : Each processor compute values for registers SP, SR, PTPR, EPC, 361 // corresponding to the first allocated task (can be idle task) 362 // and jumps to user code. 359 // step 4 : Each processor computes the task index (ltid), and the values 360 // to initialize the SP, SR, PTPR, EPC registers. 361 // It jumps to a runable task if possible, and jumps to IDLE-TASK 362 // if no task allocated or no runable task. 363 363 //////////////////////////////////////////////////////////////////////////// 364 364 … … 366 366 x, y, p ); 367 367 368 if (tasks == 0) ltid = IDLE_TASK_INDEX; 369 else ltid = 0; 370 368 // default value for ltid 369 ltid = IDLE_TASK_INDEX; 370 371 // scan allocated tasks to find a runable task 372 unsigned int task_id; 373 for ( task_id = 0 ; task_id < tasks ; task_id++ ) 374 { 375 if ( _get_task_slot( x, y, p, task_id, CTX_NORUN_ID ) == 0 ) 376 { 377 ltid = task_id; 378 break; 379 } 380 } 381 382 // update scheduler 383 psched->current = ltid; 384 385 // get values from selected task context 371 386 unsigned int sp_value = _get_task_slot( x, y, p, ltid, CTX_SP_ID); 372 387 unsigned int sr_value = _get_task_slot( x, y, p, ltid, CTX_SR_ID); 373 388 unsigned int ptpr_value = _get_task_slot( x, y, p, ltid, CTX_PTPR_ID); 374 unsigned int epc_value = _get_task_slot( x, y, p, ltid, CTX_E PC_ID);375 376 #if GIET_DEBUG_INIT 377 _printf("\n[DEBUG KINIT] P[%d,%d,%d] jumps to user codeat cycle %d\n"389 unsigned int epc_value = _get_task_slot( x, y, p, ltid, CTX_ENTRY_ID); 390 391 #if GIET_DEBUG_INIT 392 _printf("\n[DEBUG KINIT] P[%d,%d,%d] completes kernel_init at cycle %d\n" 378 393 " ltid = %d / sp = %x / sr = %x / ptpr = %x / epc = %x\n", 379 394 x , y , p , _get_proctime() ,
Note: See TracChangeset
for help on using the changeset viewer.