Changeset 167 for soft/giet_vm/sys/kernel_init.c
- Timestamp:
- Jul 16, 2012, 10:26:27 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/kernel_init.c
r166 r167 31 31 32 32 /////////////////////////////////////////////////////////////////////////////////// 33 // array of pointers on the page tables 34 // (both physical and virtual addresses) 35 /////////////////////////////////////////////////////////////////////////////////// 36 37 __attribute__((section (".kdata"))) unsigned int _kernel_ptabs_paddr[GIET_NB_VSPACE_MAX]; 38 __attribute__((section (".kdata"))) unsigned int _kernel_ptabs_vaddr[GIET_NB_VSPACE_MAX]; 39 40 /////////////////////////////////////////////////////////////////////////////////// 33 41 // declarations required to avoid forward references 34 42 /////////////////////////////////////////////////////////////////////////////////// 35 43 36 void _kernel_vobjs_init( unsigned int*);37 void _kernel_tasks_init( unsigned int*);44 void _kernel_vobjs_init(void); 45 void _kernel_tasks_init(void); 38 46 void _kernel_peripherals_init(void); 39 47 void _kernel_interrupt_vector_init(void); … … 45 53 in_kinit void _kernel_init() 46 54 { 47 // array of pointers on the page tables (used for task context initialisation)48 unsigned int kernel_ptabs[GIET_NB_VSPACE_MAX];49 50 55 // values to be written in registers 51 56 unsigned int sp_value; … … 59 64 if ( pid == 0 ) 60 65 { 61 _kernel_vobjs_init( kernel_ptabs);62 _kernel_tasks_init( kernel_ptabs);66 _kernel_vobjs_init(); 67 _kernel_tasks_init(); 63 68 _kernel_interrupt_vector_init(); 64 69 _kernel_peripherals_init(); … … 163 168 // - ptpr page table base address / 8K 164 169 // - mode mmu_mode = 0xF (TLBs and caches activated) 170 // - ptab page table virtual address 165 171 //////////////////////////////////////////////////////////////////////////////// 166 172 in_kinit void _task_map( unsigned int task_id, // global index 167 173 unsigned int vspace_id, // global index 168 174 unsigned int tty_id, // TTY index 169 unsigned int fb_id, // FB index 170 unsigned int pt_base ) // page table base adddress 175 unsigned int fbdma_id ) // FBDMA index 171 176 { 172 177 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 176 181 mapping_vobj_t* vobj = _get_vobj_base( header ); 177 182 183 178 184 // values to be initialised in task context 179 unsigned int ra = (unsigned int)&_eret;185 unsigned int ra = (unsigned int)&_eret; 180 186 unsigned int sr = 0x0000FF13; 181 187 unsigned int tty = tty_id; 182 unsigned int fb = fb_id; 183 unsigned int ptpr = pt_base >> 13; 188 unsigned int fb = fbdma_id; 189 unsigned int ptpr = _kernel_ptabs_paddr[vspace_id] >> 13; 190 unsigned int ptab = _kernel_ptabs_vaddr[vspace_id]; 184 191 unsigned int mode = 0xF; 185 192 unsigned int sp; 186 193 unsigned int epc; 187 194 188 // compute epc value 189 // Get the (virtual) base address of the start_vector that 190 // contains the start addresses for all tasks defined in a vspace. 195 // EPC : Get the (virtual) base address of the start_vector containing 196 // the start addresses for all tasks defined in a vspace. 191 197 mapping_vobj_t* vobj_data = &vobj[vspace[vspace_id].vobj_offset + 192 198 vspace[vspace_id].start_offset]; … … 194 200 epc = start_vector[task[task_id].startid]; 195 201 196 // compute sp value 197 // Get the vobj containing the stack 202 // SP : Get the vobj containing the stack 198 203 unsigned int vobj_id = task[task_id].vobjlocid + vspace[vspace_id].vobj_offset; 199 204 sp = vobj[vobj_id].vaddr + vobj[vobj_id].length; … … 220 225 _scheduler[proc_id].context[ltid][CTX_RA_ID] = ra; 221 226 _scheduler[proc_id].context[ltid][CTX_EPC_ID] = epc; 227 _scheduler[proc_id].context[ltid][CTX_PTPR_ID] = ptpr; 228 _scheduler[proc_id].context[ltid][CTX_MODE_ID] = mode; 222 229 _scheduler[proc_id].context[ltid][CTX_TTY_ID] = tty; 223 230 _scheduler[proc_id].context[ltid][CTX_FBDMA_ID] = fb; 224 _scheduler[proc_id].context[ltid][CTX_PTPR_ID] = ptpr; 225 _scheduler[proc_id].context[ltid][CTX_MODE_ID] = mode; 231 _scheduler[proc_id].context[ltid][CTX_PTAB_ID] = ptab; 226 232 _scheduler[proc_id].context[ltid][CTX_TASK_ID] = task_id; 227 233 228 #if INIT_DEBUG 234 #if INIT_DEBUG_CTX 229 235 _puts("Task "); 230 236 _puts( task[task_id].name ); … … 259 265 _puts("\n"); 260 266 267 _puts(" - PTPR = "); 268 _putw( ptpr<<13 ); 269 _puts(" saved at "); 270 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTPR_ID] ); 271 _puts("\n"); 272 261 273 _puts(" - TTY = "); 262 274 _putw( tty ); … … 271 283 _puts("\n"); 272 284 273 _puts(" - PT PR= ");274 _putw( pt pr<<13);275 _puts(" saved at "); 276 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PT PR_ID] );285 _puts(" - PTAB = "); 286 _putw( ptab ); 287 _puts(" saved at "); 288 _putw( (unsigned int)&_scheduler[proc_id].context[ltid][CTX_PTAB_ID] ); 277 289 _puts("\n"); 278 290 #endif … … 284 296 // such as mwmr channels, barriers and locks, depending on the vobj type. 285 297 // (Most of the vobjs are not known, and not initialised by the compiler). 286 // This function initialises the kernel_ptabs[] array indexed by the vspace_id,287 // and containin tthe base addresses of all page tables.288 // This kernel_ptabs[] array is used to initialise the task contexts.298 // This function initialises the _kernel_ptabs_paddr[] array indexed by the vspace_id, 299 // and containing the base addresses of all page tables. 300 // This _kernel_ptabs_paddr[] array is used to initialise the task contexts. 289 301 /////////////////////////////////////////////////////////////////////////////// 290 in_kinit void _kernel_vobjs_init( unsigned int* kernel_ptabs)302 in_kinit void _kernel_vobjs_init() 291 303 { 292 304 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 302 314 char ptab_found = 0; 303 315 304 #if INIT_DEBUG 316 #if INIT_DEBUG_CTX 305 317 _puts("[INIT] --- vobjs initialisation in vspace "); 306 318 _puts(vspace[vspace_id].name); … … 317 329 { 318 330 ptab_found = 1; 319 kernel_ptabs[vspace_id] = vobj[vobj_id].paddr; 320 321 #if INIT_DEBUG 331 _kernel_ptabs_paddr[vspace_id] = vobj[vobj_id].paddr; 332 _kernel_ptabs_vaddr[vspace_id] = vobj[vobj_id].vaddr; 333 334 #if INIT_DEBUG_CTX 322 335 _puts("[INIT] PTAB address = "); 323 _putw( kernel_ptabs[vspace_id]);336 _putw(_kernel_ptabs_paddr[vspace_id]); 324 337 _puts("\n"); 325 338 #endif … … 334 347 mwmr->depth = (vobj[vobj_id].length>>2) - 5; 335 348 mwmr->lock = 0; 336 #if INIT_DEBUG 349 #if INIT_DEBUG_CTX 337 350 _puts("[INIT] MWMR channel "); 338 351 _puts( vobj->name); … … 346 359 { 347 360 348 #if INIT_DEBUG 361 #if INIT_DEBUG_CTX 349 362 _puts("[INIT] ELF section "); 350 363 _puts( vobj->name); … … 360 373 barrier->count = 0; 361 374 barrier->init = vobj[vobj_id].init; 362 #if INIT_DEBUG 375 #if INIT_DEBUG_CTX 363 376 _puts(" BARRIER "); 364 377 _puts( vobj->name); … … 373 386 unsigned int* lock = (unsigned int*)(vobj[vobj_id].vaddr); 374 387 *lock = 0; 375 #if INIT_DEBUG 388 #if INIT_DEBUG_CTX 376 389 _puts(" LOCK "); 377 390 _puts( vobj->name); … … 383 396 { 384 397 385 #if INIT_DEBUG 398 #if INIT_DEBUG_CTX 386 399 _puts(" BUFFER "); 387 400 _puts( vobj->name); … … 425 438 // TTY[0] is reserved for the kernel. 426 439 /////////////////////////////////////////////////////////////////////////////// 427 in_kinit void _kernel_tasks_init( unsigned int* ptabs)440 in_kinit void _kernel_tasks_init() 428 441 { 429 442 mapping_header_t* header = (mapping_header_t*)&seg_mapping_base; … … 461 474 { 462 475 463 #if INIT_DEBUG 476 #if INIT_DEBUG_CTX 464 477 _puts("\n[INIT] mapping tasks in vspace "); 465 478 _puts(vspace[vspace_id].name); … … 486 499 vspace_id, // vspace index 487 500 tty_id, // global tty index 488 fb_id, // global fbdma index 489 ptabs[vspace_id] ); // page table pointer 501 fb_id ); // global fbdma index 490 502 } // end loop on tasks 491 503 } // end oop on vspaces … … 495 507 _puts("\n"); 496 508 497 #if INIT_DEBUG 509 #if INIT_DEBUG_CTX 498 510 for ( cluster_id = 0 ; cluster_id < header->clusters ; cluster_id++ ) 499 511 { … … 540 552 { 541 553 unsigned int* iob_address = (unsigned int*)&seg_iob_base; 542 unsigned int icu_address = (unsigned int)&seg_icu_base;543 554 544 555 // define IPI address mapping the IOC interrupt ...TODO...
Note: See TracChangeset
for help on using the changeset viewer.