Changes in kernel/generic/src/main/main.c [98000fb:1caeb2d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/main/main.c
r98000fb r1caeb2d 84 84 #include <main/main.h> 85 85 #include <ipc/event.h> 86 #include <sysinfo/sysinfo.h> 87 #include <sysinfo/stats.h> 86 88 87 89 /** Global configuration structure. */ … … 95 97 /** Boot allocations. */ 96 98 ballocs_t ballocs = { 97 .base = NULL,99 .base = (uintptr_t) NULL, 98 100 .size = 0 99 101 }; … … 101 103 context_t ctx; 102 104 103 /*104 * These 'hardcoded' variables will be intialized by105 * the linker or the low level assembler code with106 * appropriate sizes and addresses.107 */108 109 /** Virtual address of where the kernel is loaded. */110 uintptr_t hardcoded_load_address = 0;111 /** Size of the kernel code in bytes. */112 size_t hardcoded_ktext_size = 0;113 /** Size of the kernel data in bytes. */114 size_t hardcoded_kdata_size = 0;115 105 /** Lowest safe stack virtual address. */ 116 uintptr_t stack_safe = 0; 106 uintptr_t stack_safe = 0; 117 107 118 108 /* … … 123 113 */ 124 114 static void main_bsp_separated_stack(void); 115 125 116 #ifdef CONFIG_SMP 126 117 static void main_ap_separated_stack(void); 127 118 #endif 128 119 129 #define CONFIG_STACK_SIZE 120 #define CONFIG_STACK_SIZE ((1 << STACK_FRAMES) * STACK_SIZE) 130 121 131 122 /** Main kernel routine for bootstrap CPU. … … 140 131 * 141 132 */ 142 void main_bsp(void)133 NO_TRACE void main_bsp(void) 143 134 { 144 135 config.cpu_count = 1; … … 156 147 size_t i; 157 148 for (i = 0; i < init.cnt; i++) { 158 if (PA_ overlaps(config.stack_base, config.stack_size,149 if (PA_OVERLAPS(config.stack_base, config.stack_size, 159 150 init.tasks[i].addr, init.tasks[i].size)) 160 151 config.stack_base = ALIGN_UP(init.tasks[i].addr + 161 152 init.tasks[i].size, config.stack_size); 162 153 } 163 154 164 155 /* Avoid placing stack on top of boot allocations. */ 165 156 if (ballocs.size) { 166 if (PA_ overlaps(config.stack_base, config.stack_size,157 if (PA_OVERLAPS(config.stack_base, config.stack_size, 167 158 ballocs.base, ballocs.size)) 168 159 config.stack_base = ALIGN_UP(ballocs.base + … … 180 171 } 181 172 182 183 173 /** Main kernel routine for bootstrap CPU using new stack. 184 174 * … … 186 176 * 187 177 */ 188 void main_bsp_separated_stack(void) 178 void main_bsp_separated_stack(void) 189 179 { 190 180 /* Keep this the first thing. */ … … 193 183 version_print(); 194 184 195 LOG("\nconfig.base=% #" PRIp " config.kernel_size=%" PRIs196 "\nconfig.stack_base=% #" PRIp " config.stack_size=%" PRIs,197 config.base, config.kernel_size, config.stack_base,198 config.stack_size);185 LOG("\nconfig.base=%p config.kernel_size=%zu" 186 "\nconfig.stack_base=%p config.stack_size=%zu", 187 (void *) config.base, config.kernel_size, 188 (void *) config.stack_base, config.stack_size); 199 189 200 190 #ifdef CONFIG_KCONSOLE … … 204 194 * commands. 205 195 */ 206 LOG_EXEC(kconsole_init());196 kconsole_init(); 207 197 #endif 208 198 … … 211 201 * starts adding its own handlers 212 202 */ 213 LOG_EXEC(exc_init());203 exc_init(); 214 204 215 205 /* 216 206 * Memory management subsystems initialization. 217 207 */ 218 LOG_EXEC(arch_pre_mm_init());219 LOG_EXEC(frame_init());208 arch_pre_mm_init(); 209 frame_init(); 220 210 221 211 /* Initialize at least 1 memory segment big enough for slab to work. */ 222 LOG_EXEC(slab_cache_init()); 223 LOG_EXEC(btree_init()); 224 LOG_EXEC(as_init()); 225 LOG_EXEC(page_init()); 226 LOG_EXEC(tlb_init()); 227 LOG_EXEC(ddi_init()); 228 LOG_EXEC(tasklet_init()); 229 LOG_EXEC(arch_post_mm_init()); 230 LOG_EXEC(arch_pre_smp_init()); 231 LOG_EXEC(smp_init()); 212 slab_cache_init(); 213 sysinfo_init(); 214 btree_init(); 215 as_init(); 216 page_init(); 217 tlb_init(); 218 ddi_init(); 219 tasklet_init(); 220 arch_post_mm_init(); 221 arch_pre_smp_init(); 222 smp_init(); 232 223 233 224 /* Slab must be initialized after we know the number of processors. */ 234 LOG_EXEC(slab_enable_cpucache());235 236 printf("Detected % " PRIs " CPU(s), %" PRIu64" MiB free memory\n",237 config.cpu_count, SIZE2MB(zone _total_size()));238 239 LOG_EXEC(cpu_init());240 241 LOG_EXEC(calibrate_delay_loop());242 LOG_EXEC(clock_counter_init());243 LOG_EXEC(timeout_init());244 LOG_EXEC(scheduler_init());245 LOG_EXEC(task_init());246 LOG_EXEC(thread_init());247 LOG_EXEC(futex_init());225 slab_enable_cpucache(); 226 227 printf("Detected %u CPU(s), %" PRIu64 " MiB free memory\n", 228 config.cpu_count, SIZE2MB(zones_total_size())); 229 230 cpu_init(); 231 232 calibrate_delay_loop(); 233 clock_counter_init(); 234 timeout_init(); 235 scheduler_init(); 236 task_init(); 237 thread_init(); 238 futex_init(); 248 239 249 240 if (init.cnt > 0) { 250 241 size_t i; 251 242 for (i = 0; i < init.cnt; i++) 252 LOG("init[%" PRIs "].addr=%#" PRIp ", init[%" PRIs 253 "].size=%#" PRIs, i, init.tasks[i].addr, i, 254 init.tasks[i].size); 243 LOG("init[%zu].addr=%p, init[%zu].size=%zu", 244 i, (void *) init.tasks[i].addr, i, init.tasks[i].size); 255 245 } else 256 246 printf("No init binaries found.\n"); 257 247 258 LOG_EXEC(ipc_init()); 259 LOG_EXEC(event_init()); 260 LOG_EXEC(klog_init()); 248 ipc_init(); 249 event_init(); 250 klog_init(); 251 stats_init(); 261 252 262 253 /* … … 274 265 if (!kinit_thread) 275 266 panic("Cannot create kinit thread."); 276 LOG_EXEC(thread_ready(kinit_thread));267 thread_ready(kinit_thread); 277 268 278 269 /* … … 284 275 } 285 276 286 287 277 #ifdef CONFIG_SMP 278 288 279 /** Main kernel routine for application CPUs. 289 280 * … … 304 295 */ 305 296 config.cpu_active++; 306 297 307 298 /* 308 299 * The THE structure is well defined because ctx.sp is used as stack. … … 319 310 calibrate_delay_loop(); 320 311 arch_post_cpu_init(); 321 312 322 313 the_copy(THE, (the_t *) CPU->stack); 323 314 324 315 /* 325 316 * If we woke kmp up before we left the kernel stack, we could … … 334 325 } 335 326 336 337 327 /** Main kernel routine for application CPUs using new stack. 338 328 * … … 346 336 */ 347 337 timeout_init(); 348 338 349 339 waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST); 350 340 scheduler(); 351 341 /* not reached */ 352 342 } 343 353 344 #endif /* CONFIG_SMP */ 354 345
Note:
See TracChangeset
for help on using the changeset viewer.