32,7 → 32,7 |
|
/** |
* @file |
* @brief Kernel initialization thread. |
* @brief Kernel initialization thread. |
* |
* This file contains kinit kernel thread which carries out |
* high level system initialization. |
64,6 → 64,8 |
#include <security/cap.h> |
#include <lib/rd.h> |
#include <ipc/ipc.h> |
#include <debug.h> |
#include <string.h> |
|
#ifdef CONFIG_SMP |
#include <smp/smp.h> |
78,6 → 80,9 |
static char alive[ALIVE_CHARS] = "-\\|/"; |
#endif |
|
#define INIT_PREFIX "init:" |
#define INIT_PREFIX_LEN 5 |
|
/** Kernel initialization thread. |
* |
* kinit takes care of higher level kernel |
92,15 → 97,15 |
#if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE) |
thread_t *thread; |
#endif |
|
|
/* |
* Detach kinit as nobody will call thread_join_timeout() on it. |
*/ |
thread_detach(THREAD); |
|
|
interrupts_disable(); |
|
#ifdef CONFIG_SMP |
|
#ifdef CONFIG_SMP |
if (config.cpu_count > 1) { |
waitq_initialize(&ap_completion_wq); |
/* |
120,9 → 125,7 |
thread_join(thread); |
thread_detach(thread); |
} |
#endif /* CONFIG_SMP */ |
|
#ifdef CONFIG_SMP |
if (config.cpu_count > 1) { |
count_t i; |
|
138,7 → 141,6 |
thread_ready(thread); |
} else |
printf("Unable to create kcpulb thread for cpu" PRIc "\n", i); |
|
} |
} |
#endif /* CONFIG_SMP */ |
147,7 → 149,7 |
* At this point SMP, if present, is configured. |
*/ |
arch_post_smp_init(); |
|
|
#ifdef CONFIG_KCONSOLE |
if (stdin) { |
/* |
174,12 → 176,26 |
printf("init[%" PRIc "].addr is not frame aligned\n", i); |
continue; |
} |
|
char *name = init.tasks[i].name; |
if (name[0] == '\0') name = "init-bin"; |
|
/* |
* Construct task name from the 'init:' prefix and the |
* name stored in the init structure (if any). |
*/ |
|
char namebuf[TASK_NAME_BUFLEN]; |
char *name; |
|
name = init.tasks[i].name; |
if (name[0] == '\0') |
name = "<unknown>"; |
|
ASSERT(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN); |
strncpy(namebuf, INIT_PREFIX, TASK_NAME_BUFLEN); |
strncpy(namebuf + INIT_PREFIX_LEN, name, |
TASK_NAME_BUFLEN - INIT_PREFIX_LEN); |
|
int rc = program_create_from_image((void *) init.tasks[i].addr, |
name, &programs[i]); |
namebuf, &programs[i]); |
|
if ((rc == 0) && (programs[i].task != NULL)) { |
/* |
202,15 → 218,21 |
} |
|
/* |
* Run user tasks with reasonable delays |
* Run user tasks with small delays |
* to avoid intermixed klog output. |
* |
* TODO: This certainly does not guarantee |
* anything, it just works in most of the |
* cases. Some better way how to achieve |
* nice klog output should be found. |
*/ |
for (i = 0; i < init.cnt; i++) { |
if (programs[i].task != NULL) { |
thread_usleep(50000); |
program_ready(&programs[i]); |
thread_usleep(10000); |
} |
} |
|
|
#ifdef CONFIG_KCONSOLE |
if (!stdin) { |
thread_sleep(10); |