Changeset 428 for soft/giet_vm/giet_kernel/kernel_init.c
- Timestamp:
- Oct 4, 2014, 3:19:32 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/kernel_init.c
r410 r428 133 133 134 134 __attribute__((section (".kdata"))) 135 volatile static_scheduler_t* _schedulers[ NB_PROCS_MAX<<(X_WIDTH+Y_WIDTH)];135 volatile static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 136 136 137 137 //////////////////////////////////////////////////////////////////////////////////// … … 140 140 141 141 __attribute__((section (".kdata"))) 142 volatile unsigned int _init_barrier = 0;142 volatile unsigned int kernel_init_barrier = 0; 143 143 144 144 /////////////////////////////////////////////////////////////////////////////////// 145 145 __attribute__((section (".kinit"))) void kernel_init() 146 146 { 147 unsigned int global_pid = _get_procid(); 148 unsigned int cluster_xy = global_pid / NB_PROCS_MAX; 149 unsigned int x = cluster_xy >> Y_WIDTH; 147 // gpid : hardware processor index (fixed format: X_WIDTH|Y_WIDTH|P_WIDTH) 148 // lpid : local processor id in a cluster ( lpid < NB_PROCS_MAX) 149 // cpid : "continuous" processor index = (((x * Y_SIZE + y) * NB_PROCS_MAX) + p 150 151 unsigned int gpid = _get_procid(); 152 unsigned int cluster_xy = gpid >> P_WIDTH; 153 unsigned int x = cluster_xy >> Y_WIDTH & ((1<<X_WIDTH)-1); 150 154 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 151 unsigned int lpid = global_pid % NB_PROCS_MAX; 152 unsigned int pid = ((( x * Y_SIZE) + y) * NB_PROCS_MAX) + lpid; 153 154 // This last initialisation phase is done sequencially: 155 while( pid != _init_barrier ) asm volatile ( "nop" ); 155 unsigned int lpid = gpid & ((1<<P_WIDTH)-1); 156 unsigned int cpid = ((( x * Y_SIZE) + y) * NB_PROCS_MAX) + lpid; 157 158 159 // This initialisation is done sequencially by each processor 160 while( cpid != kernel_init_barrier ) asm volatile ( "nop" ); 156 161 157 162 // Step 1 : each processor get its scheduler virtual address from CP0 register … … 161 166 unsigned int tasks = psched->tasks; 162 167 163 _schedulers[ global_pid] = psched;168 _schedulers[x][y][lpid] = psched; 164 169 165 170 #if GIET_DEBUG_INIT … … 183 188 for (ltid = 0; ltid < tasks; ltid++) 184 189 { 185 unsigned int vsid = _get_task_slot( global_pid, ltid , CTX_VSID_ID );186 unsigned int ptab = _get_task_slot( global_pid, ltid , CTX_PTAB_ID );187 unsigned int ptpr = _get_task_slot( global_pid, ltid , CTX_PTPR_ID );190 unsigned int vsid = _get_task_slot( x, y, lpid, ltid , CTX_VSID_ID ); 191 unsigned int ptab = _get_task_slot( x, y, lpid, ltid , CTX_PTAB_ID ); 192 unsigned int ptpr = _get_task_slot( x, y, lpid, ltid , CTX_PTPR_ID ); 188 193 189 194 // initialize PTABS arrays … … 204 209 // compute ctx_ra 205 210 unsigned int ctx_ra = (unsigned int)(&_ctx_eret); 206 _set_task_slot( global_pid, ltid, CTX_RA_ID, ctx_ra );211 _set_task_slot( x, y, lpid, ltid, CTX_RA_ID, ctx_ra ); 207 212 208 213 // compute ctx_epc 209 unsigned int* ptr = (unsigned int*)_get_task_slot( global_pid, ltid, CTX_EPC_ID );210 _set_task_slot( global_pid, ltid, CTX_EPC_ID, *ptr );214 unsigned int* ptr = (unsigned int*)_get_task_slot( x, y, lpid, ltid, CTX_EPC_ID ); 215 _set_task_slot( x, y, lpid, ltid, CTX_EPC_ID, *ptr ); 211 216 212 217 #if GIET_DEBUG_INIT … … 215 220 " - ctx_ra = %x\n", 216 221 x, y, lpid, ltid, 217 _get_task_slot( global_pid, ltid, CTX_EPC_ID ),218 _get_task_slot( global_pid, ltid, CTX_RA_ID ) );222 _get_task_slot( x, y, lpid, ltid, CTX_EPC_ID ), 223 _get_task_slot( x, y, lpid, ltid, CTX_RA_ID ) ); 219 224 #endif 220 225 … … 297 302 unsigned int pstack = ((unsigned int)psched) + 0x2000; 298 303 299 _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_SP_ID, pstack);300 _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_RA_ID, (unsigned int) &_ctx_eret);301 _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int) &_idle_task);304 _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_SP_ID, pstack); 305 _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_RA_ID, (unsigned int) &_ctx_eret); 306 _set_task_slot( x, y, lpid, IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int) &_idle_task); 302 307 303 308 #if GIET_DEBUG_INIT … … 326 331 } 327 332 328 unsigned int sp_value = _get_task_slot( global_pid, ltid, CTX_SP_ID);329 unsigned int sr_value = _get_task_slot( global_pid, ltid, CTX_SR_ID);330 unsigned int ptpr_value = _get_task_slot( global_pid, ltid, CTX_PTPR_ID);331 unsigned int epc_value = _get_task_slot( global_pid, ltid, CTX_EPC_ID);333 unsigned int sp_value = _get_task_slot( x, y, lpid, ltid, CTX_SP_ID); 334 unsigned int sr_value = _get_task_slot( x, y, lpid, ltid, CTX_SR_ID); 335 unsigned int ptpr_value = _get_task_slot( x, y, lpid, ltid, CTX_PTPR_ID); 336 unsigned int epc_value = _get_task_slot( x, y, lpid, ltid, CTX_EPC_ID); 332 337 333 338 #if GIET_DEBUG_INIT … … 337 342 338 343 // increment barrier counter 339 _init_barrier++;344 kernel_init_barrier++; 340 345 341 346 // busy waiting until all processors synchronized 342 while ( _init_barrier != NB_TOTAL_PROCS );347 while ( kernel_init_barrier != NB_TOTAL_PROCS ); 343 348 344 349 #if GIET_DEBUG_INIT
Note: See TracChangeset
for help on using the changeset viewer.