Changeset 467 for soft/giet_vm/giet_kernel/kernel_init.c
- Timestamp:
- Dec 12, 2014, 5:00:43 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_kernel/kernel_init.c
r459 r467 12 12 #include <utils.h> 13 13 #include <tty0.h> 14 #include <kernel_malloc.h> 14 15 #include <fat32.h> 15 16 #include <xcu_driver.h> … … 60 61 #endif 61 62 63 #if !defined(NB_TTY_CHANNELS) 64 # error: You must define NB_TTY_CHANNELS in the hard_config.h file 65 #endif 66 67 #if (NB_TTY_CHANNELS < 1) 68 # error: NB_TTY_CHANNELS cannot be smaller than 1 69 #endif 70 71 72 73 /////////////////////////////////////////////////////////////////////////////////// 74 // Ditributed kernel heap descriptors array (for dynamic memory allocation) 75 /////////////////////////////////////////////////////////////////////////////////// 76 77 kernel_heap_t kernel_heap[X_SIZE][Y_SIZE]; 78 62 79 /////////////////////////////////////////////////////////////////////////////////// 63 80 // FAT internal representation for kernel code 64 81 /////////////////////////////////////////////////////////////////////////////////// 65 82 66 __attribute__((section (".kdata"))) 67 fat32_fs_t fat __attribute__((aligned(512))); 83 fat32_fs_t fat __attribute__((aligned(512))); 68 84 69 85 /////////////////////////////////////////////////////////////////////////////////// … … 71 87 /////////////////////////////////////////////////////////////////////////////////// 72 88 73 __attribute__((section (".kdata")))74 89 volatile unsigned int _ptabs_vaddr[GIET_NB_VSPACE_MAX]; // virtual addresses 75 76 __attribute__((section (".kdata")))77 90 volatile unsigned int _ptabs_ptprs[GIET_NB_VSPACE_MAX]; // physical addresses >> 13 78 91 79 92 /////////////////////////////////////////////////////////////////////////////////// 80 // array of pointers on the schedulers (physical addresses) 81 /////////////////////////////////////////////////////////////////////////////////// 82 83 __attribute__((section (".kdata"))) 84 volatile static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 93 // Array of pointers on the schedulers (physical addresses) 94 /////////////////////////////////////////////////////////////////////////////////// 95 96 volatile static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX]; 85 97 86 98 //////////////////////////////////////////////////////////////////////////////////// … … 88 100 //////////////////////////////////////////////////////////////////////////////////// 89 101 90 __attribute__((section (".kdata")))91 102 volatile unsigned int kernel_init_barrier = 0; 92 103 104 //////////////////////////////////////////////////////////////////////////////////// 105 // Global variables for TTY/kernel communications 106 //////////////////////////////////////////////////////////////////////////////////// 107 108 sbt_lock_t _tty_tx_lock[NB_TTY_CHANNELS] __attribute__((aligned(64))); 109 110 unsigned int _tty_rx_buf[NB_TTY_CHANNELS]; 111 unsigned int _tty_rx_full[NB_TTY_CHANNELS]; 112 113 114 115 116 117 /////////////////////////////////////////////////////////////////////////////////// 118 // This kernel_init() function completes the kernel initialisation in 7 steps: 119 // All processors execute this code, but this is done sequencially. 120 // - step 0 : Initialise fat, heap descriptors, and tty locks 121 // - step 1 : Initialise scheduler pointers array 122 // - step 2 : Initialise PTAB pointers arrays 123 // - step 3 : Initialise private XCU masks 124 // - step 4 : 125 // - step 5 : 126 // - step 6 : 93 127 /////////////////////////////////////////////////////////////////////////////////// 94 128 __attribute__((section (".kinit"))) void kernel_init() 95 129 { 96 130 // gpid : hardware processor index (fixed format: X_WIDTH|Y_WIDTH|P_WIDTH) 97 // p : local processor id in a cluster ( p < NB_PROCS_MAX)98 // cpid : "continuous"processor index = (((x * Y_SIZE + y) * NB_PROCS_MAX) + p131 // p : local processor id in a cluster ( p < NB_PROCS_MAX) 132 // cpid : continuous processor index = (((x * Y_SIZE + y) * NB_PROCS_MAX) + p 99 133 100 134 unsigned int gpid = _get_procid(); … … 105 139 unsigned int cpid = ((( x * Y_SIZE) + y) * NB_PROCS_MAX) + p; 106 140 107 108 141 // This initialisation is done sequencially by each processor 109 142 while( cpid != kernel_init_barrier ) asm volatile ( "nop" ); 110 143 111 // Step 0 : Processor[0,0,0] initialises the kernel FAT 112 if ( gpid == 0 ) _fat_init( IOC_BOOT_MODE ); 144 // Step 0 : P[0,0,0] initialises the kernel FAT 145 // and the distributed kernel_heap descriptors array. 146 if ( gpid == 0 ) 147 { 148 _heap_init(); 149 150 #if GIET_DEBUG_INIT 151 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes kernel HEAP init\n", x, y, p ); 152 #endif 153 unsigned int channel; 154 for ( channel = 0 ; channel < NB_TTY_CHANNELS ; channel++ ) 155 { 156 _sbt_lock_init( &_tty_tx_lock[channel] ); 157 } 158 159 #if GIET_DEBUG_INIT 160 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes TTY locks init\n", x, y, p ); 161 #endif 162 163 _fat_init( IOC_BOOT_MODE ); 164 165 #if GIET_DEBUG_INIT 166 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] completes kernel FAT init\n", x, y, p ); 167 #endif 168 169 } 113 170 114 171 // Step 1 : each processor get its scheduler virtual address from CP0_SCHED register … … 121 178 122 179 #if GIET_DEBUG_INIT 123 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] starts kernel init\n"124 " - scheduler vbase = %x\n"125 " - tasks = %d\n",126 x, y, p, (unsigned int)psched, tasks );180 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initialises SCHED array\n" 181 " - scheduler vbase = %x\n" 182 " - tasks = %d\n", 183 x, y, p, (unsigned int)psched, tasks ); 127 184 #endif 128 185 … … 148 205 149 206 #if GIET_DEBUG_INIT 150 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] contributes toPTABS arrays\n"207 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initialises PTABS arrays\n" 151 208 " - ptabs_vaddr[%d] = %x / ptpr_paddr[%d] = %l\n", 152 209 x, y, p, … … 167 224 168 225 #if GIET_DEBUG_INIT 169 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] updates context for task %d\n"170 " - ctx_epc = %x\n"171 " - ctx_ra = %x\n",172 x, y, p, ltid,173 _get_task_slot( x, y, p, ltid, CTX_EPC_ID ),174 _get_task_slot( x, y, p, ltid, CTX_RA_ID ) );226 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] updates context for task %d\n" 227 " - ctx_epc = %x\n" 228 " - ctx_ra = %x\n", 229 x, y, p, ltid, 230 _get_task_slot( x, y, p, ltid, CTX_EPC_ID ), 231 _get_task_slot( x, y, p, ltid, CTX_RA_ID ) ); 175 232 #endif 176 233 … … 202 259 203 260 #if GIET_DEBUG_INIT 204 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] sets XCU masks\n"205 " - XCU HWI_MASK = %x\n"206 " - XCU WTI_MASK = %x\n"207 " - XCU PTI_MASK = %x\n",208 x, y, p, hwi_mask, wti_mask, pti_mask );261 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] sets XCU masks\n" 262 " - XCU HWI_MASK = %x\n" 263 " - XCU WTI_MASK = %x\n" 264 " - XCU PTI_MASK = %x\n", 265 x, y, p, hwi_mask, wti_mask, pti_mask ); 209 266 #endif 210 267 … … 221 278 if (isr_switch_index == 0xFFFFFFFF) 222 279 { 223 _ printf("\n[GIET ERROR] ISR_TICK not found for processor[%d,%d,%d]\n",224 x, y, p );280 _nolock_printf("\n[GIET ERROR] ISR_TICK not found for processor[%d,%d,%d]\n", 281 x, y, p ); 225 282 _exit(); 226 283 } … … 232 289 233 290 #if GIET_DEBUG_INIT 234 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] starts TICK timer\n",235 x, y, p );291 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] starts TICK timer\n", 292 x, y, p ); 236 293 #endif 237 294 … … 249 306 250 307 #if GIET_DEBUG_INIT 251 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] initializes IDLE task\n"252 " - stack_base = %x\n"253 " - stack_size = 0x1000\n",254 x, y, p, pstack - 0x1000 );308 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initializes IDLE task\n" 309 " - stack_base = %x\n" 310 " - stack_size = 0x1000\n", 311 x, y, p, pstack - 0x1000 ); 255 312 #endif 256 313 … … 265 322 ltid = IDLE_TASK_INDEX; 266 323 267 _ printf("\n[GIET WARNING] No task allocated to processor[%d,%d,%d]\n",268 x, y, p );324 _nolock_printf("\n[GIET WARNING] No task allocated to processor[%d,%d,%d]\n", 325 x, y, p ); 269 326 } 270 327 else … … 279 336 280 337 #if GIET_DEBUG_INIT 281 _ printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] reach barrier at cycle %d\n",282 x, y, p, _get_proctime() );338 _nolock_printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] reach barrier at cycle %d\n", 339 x, y, p, _get_proctime() ); 283 340 #endif 284 341 … … 290 347 291 348 #if GIET_DEBUG_INIT 292 _printf("\n[ GIET DEBUG INIT] Processor[%d,%d,%d] initializes registers at cycle %d\n"349 _printf("\n[DEBUG KERNEL_INIT] P[%d,%d,%d] initializes registers at cycle %d\n" 293 350 " - sp = %x\n" 294 351 " - sr = %x\n"
Note: See TracChangeset
for help on using the changeset viewer.