Changeset a35b458 in mainline for kernel/generic/src/main
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/generic/src/main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/main/kinit.c
r3061bc1 ra35b458 102 102 { 103 103 thread_t *thread; 104 104 105 105 /* 106 106 * Detach kinit as nobody will call thread_join_timeout() on it. … … 109 109 110 110 interrupts_disable(); 111 111 112 112 /* Start processing RCU callbacks. RCU is fully functional afterwards. */ 113 113 rcu_kinit_init(); 114 114 115 115 /* 116 116 * Start processing work queue items. Some may have been queued during boot. 117 117 */ 118 118 workq_global_worker_init(); 119 119 120 120 #ifdef CONFIG_SMP 121 121 if (config.cpu_count > 1) { 122 122 waitq_initialize(&ap_completion_wq); 123 123 124 124 /* 125 125 * Create the kmp thread and wait for its completion. … … 135 135 } else 136 136 panic("Unable to create kmp thread."); 137 137 138 138 thread_join(thread); 139 139 thread_detach(thread); 140 140 141 141 /* 142 142 * For each CPU, create its load balancing thread. 143 143 */ 144 144 unsigned int i; 145 145 146 146 for (i = 0; i < config.cpu_count; i++) { 147 147 thread = thread_create(kcpulb, NULL, TASK, … … 156 156 } 157 157 #endif /* CONFIG_SMP */ 158 158 159 159 /* 160 160 * At this point SMP, if present, is configured. 161 161 */ 162 162 ARCH_OP(post_smp_init); 163 163 164 164 /* Start thread computing system load */ 165 165 thread = thread_create(kload, NULL, TASK, THREAD_FLAG_NONE, … … 169 169 else 170 170 log(LF_OTHER, LVL_ERROR, "Unable to create kload thread"); 171 171 172 172 #ifdef CONFIG_KCONSOLE 173 173 if (stdin) { … … 184 184 } 185 185 #endif /* CONFIG_KCONSOLE */ 186 186 187 187 /* 188 188 * Store the default stack size in sysinfo so that uspace can create … … 190 190 */ 191 191 sysinfo_set_item_val("default.stack_size", NULL, STACK_SIZE_USER); 192 192 193 193 interrupts_enable(); 194 194 195 195 /* 196 196 * Create user tasks, load RAM disk images. … … 198 198 size_t i; 199 199 program_t programs[CONFIG_INIT_TASKS]; 200 200 201 201 // FIXME: do not propagate arguments through sysinfo 202 202 // but pass them directly to the tasks … … 228 228 continue; 229 229 } 230 230 231 231 /* 232 232 * Construct task name from the 'init:' prefix and the 233 233 * name stored in the init structure (if any). 234 234 */ 235 235 236 236 char namebuf[TASK_NAME_BUFLEN]; 237 237 238 238 const char *name = init.tasks[i].name; 239 239 if (name[0] == 0) 240 240 name = "<unknown>"; 241 241 242 242 static_assert(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN, ""); 243 243 str_cpy(namebuf, TASK_NAME_BUFLEN, INIT_PREFIX); 244 244 str_cpy(namebuf + INIT_PREFIX_LEN, 245 245 TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name); 246 246 247 247 /* 248 248 * Create virtual memory mappings for init task images. … … 252 252 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 253 253 assert(page); 254 254 255 255 errno_t rc = program_create_from_image((void *) page, namebuf, 256 256 &programs[i]); 257 257 258 258 if (rc == 0) { 259 259 if (programs[i].task != NULL) { … … 264 264 PERM_PERM | PERM_MEM_MANAGER | 265 265 PERM_IO_MANAGER | PERM_IRQ_REG); 266 266 267 267 if (!ipc_phone_0) { 268 268 ipc_phone_0 = &programs[i].task->answerbox; … … 276 276 } 277 277 } 278 278 279 279 /* 280 280 * If programs[i].task == NULL then it is … … 293 293 str_error_name(rc), programs[i].loader_status); 294 294 } 295 295 296 296 /* 297 297 * Run user tasks. … … 301 301 program_ready(&programs[i]); 302 302 } 303 303 304 304 #ifdef CONFIG_KCONSOLE 305 305 if (!stdin) { 306 306 thread_sleep(10); 307 307 printf("kinit: No stdin\nKernel alive: ."); 308 308 309 309 unsigned int i = 0; 310 310 while (true) { -
kernel/generic/src/main/main.c
r3061bc1 ra35b458 166 166 config.cpu_count = 1; 167 167 config.cpu_active = 1; 168 168 169 169 config.base = hardcoded_load_address; 170 170 config.kernel_size = ALIGN_UP(hardcoded_ktext_size + 171 171 hardcoded_kdata_size, PAGE_SIZE); 172 172 config.stack_size = STACK_SIZE; 173 173 174 174 /* Initialy the stack is placed just after the kernel */ 175 175 config.stack_base = config.base + config.kernel_size; 176 176 177 177 /* Avoid placing stack on top of init */ 178 178 size_t i; … … 190 190 } 191 191 } 192 192 193 193 /* Avoid placing stack on top of boot allocations. */ 194 194 if (ballocs.size) { … … 198 198 ballocs.size, PAGE_SIZE); 199 199 } 200 200 201 201 if (config.stack_base < stack_safe) 202 202 config.stack_base = ALIGN_UP(stack_safe, PAGE_SIZE); 203 203 204 204 context_save(&ctx); 205 205 context_set(&ctx, FADDR(main_bsp_separated_stack), … … 218 218 /* Keep this the first thing. */ 219 219 the_initialize(THE); 220 220 221 221 version_print(); 222 222 223 223 LOG("\nconfig.base=%p config.kernel_size=%zu" 224 224 "\nconfig.stack_base=%p config.stack_size=%zu", 225 225 (void *) config.base, config.kernel_size, 226 226 (void *) config.stack_base, config.stack_size); 227 227 228 228 #ifdef CONFIG_KCONSOLE 229 229 /* … … 234 234 kconsole_init(); 235 235 #endif 236 236 237 237 /* 238 238 * Exception handler initialization, before architecture … … 240 240 */ 241 241 exc_init(); 242 242 243 243 /* 244 244 * Memory management subsystems initialization. … … 260 260 ARCH_OP(pre_smp_init); 261 261 smp_init(); 262 262 263 263 /* Slab must be initialized after we know the number of processors. */ 264 264 slab_enable_cpucache(); 265 265 266 266 uint64_t size; 267 267 const char *size_suffix; … … 269 269 printf("Detected %u CPU(s), %" PRIu64 " %s free memory\n", 270 270 config.cpu_count, size, size_suffix); 271 271 272 272 cpu_init(); 273 273 calibrate_delay_loop(); … … 293 293 } else 294 294 printf("No init binaries found.\n"); 295 295 296 296 ipc_init(); 297 297 event_init(); … … 299 299 log_init(); 300 300 stats_init(); 301 301 302 302 /* 303 303 * Create kernel task. … … 306 306 if (!kernel) 307 307 panic("Cannot create kernel task."); 308 308 309 309 /* 310 310 * Create the first thread. … … 315 315 panic("Cannot create kinit thread."); 316 316 thread_ready(kinit_thread); 317 317 318 318 /* 319 319 * This call to scheduler() will return to kinit, … … 344 344 */ 345 345 config.cpu_active++; 346 346 347 347 /* 348 348 * The THE structure is well defined because ctx.sp is used as stack. 349 349 */ 350 350 the_initialize(THE); 351 351 352 352 ARCH_OP(pre_mm_init); 353 353 frame_init(); … … 355 355 tlb_init(); 356 356 ARCH_OP(post_mm_init); 357 357 358 358 cpu_init(); 359 359 calibrate_delay_loop(); 360 360 ARCH_OP(post_cpu_init); 361 361 362 362 the_copy(THE, (the_t *) CPU->stack); 363 363 364 364 /* 365 365 * If we woke kmp up before we left the kernel stack, we could … … 382 382 { 383 383 smp_call_init(); 384 384 385 385 /* 386 386 * Configure timeouts for this cpu. 387 387 */ 388 388 timeout_init(); 389 389 390 390 waitq_wakeup(&ap_completion_wq, WAKEUP_FIRST); 391 391 scheduler(); -
kernel/generic/src/main/shutdown.c
r3061bc1 ra35b458 45 45 { 46 46 task_done(); 47 47 48 48 #ifdef CONFIG_DEBUG 49 49 log(LF_OTHER, LVL_DEBUG, "Rebooting the system"); 50 50 #endif 51 51 52 52 arch_reboot(); 53 53 halt(); -
kernel/generic/src/main/uinit.c
r3061bc1 ra35b458 65 65 */ 66 66 thread_detach(THREAD); 67 67 68 68 #ifdef CONFIG_UDEBUG 69 69 udebug_stoppable_end(); 70 70 #endif 71 71 72 72 uspace_arg_t *uarg = (uspace_arg_t *) arg; 73 73 uspace_arg_t local_uarg; 74 74 75 75 local_uarg.uspace_entry = uarg->uspace_entry; 76 76 local_uarg.uspace_stack = uarg->uspace_stack; … … 79 79 local_uarg.uspace_thread_function = NULL; 80 80 local_uarg.uspace_thread_arg = NULL; 81 81 82 82 free(uarg); 83 83 84 84 userspace(&local_uarg); 85 85 }
Note:
See TracChangeset
for help on using the changeset viewer.