Rev 4012 | Rev 4020 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4012 | Rev 4014 | ||
|---|---|---|---|
| Line 30... | Line 30... | ||
| 30 | * @{ |
30 | * @{ |
| 31 | */ |
31 | */ |
| 32 | 32 | ||
| 33 | /** |
33 | /** |
| 34 | * @file |
34 | * @file |
| 35 | * @brief Kernel initialization thread. |
35 | * @brief Kernel initialization thread. |
| 36 | * |
36 | * |
| 37 | * This file contains kinit kernel thread which carries out |
37 | * This file contains kinit kernel thread which carries out |
| 38 | * high level system initialization. |
38 | * high level system initialization. |
| 39 | * |
39 | * |
| 40 | * This file is responsible for finishing SMP configuration |
40 | * This file is responsible for finishing SMP configuration |
| Line 78... | Line 78... | ||
| 78 | 78 | ||
| 79 | #ifdef CONFIG_KCONSOLE |
79 | #ifdef CONFIG_KCONSOLE |
| 80 | static char alive[ALIVE_CHARS] = "-\\|/"; |
80 | static char alive[ALIVE_CHARS] = "-\\|/"; |
| 81 | #endif |
81 | #endif |
| 82 | 82 | ||
| 83 | #define BOOT_PREFIX "boot:" |
83 | #define BOOT_PREFIX "boot:" |
| 84 | #define BOOT_PREFIX_LEN 5 |
84 | #define BOOT_PREFIX_LEN 5 |
| 85 | 85 | ||
| 86 | /** Kernel initialization thread. |
86 | /** Kernel initialization thread. |
| 87 | * |
87 | * |
| 88 | * kinit takes care of higher level kernel |
88 | * kinit takes care of higher level kernel |
| 89 | * initialization (i.e. thread creation, |
89 | * initialization (i.e. thread creation, |
| Line 95... | Line 95... | ||
| 95 | { |
95 | { |
| 96 | 96 | ||
| 97 | #if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE) |
97 | #if defined(CONFIG_SMP) || defined(CONFIG_KCONSOLE) |
| 98 | thread_t *thread; |
98 | thread_t *thread; |
| 99 | #endif |
99 | #endif |
| 100 | 100 | ||
| 101 | /* |
101 | /* |
| 102 | * Detach kinit as nobody will call thread_join_timeout() on it. |
102 | * Detach kinit as nobody will call thread_join_timeout() on it. |
| 103 | */ |
103 | */ |
| 104 | thread_detach(THREAD); |
104 | thread_detach(THREAD); |
| 105 | 105 | ||
| 106 | interrupts_disable(); |
106 | interrupts_disable(); |
| 107 | 107 | ||
| 108 | #ifdef CONFIG_SMP |
108 | #ifdef CONFIG_SMP |
| 109 | if (config.cpu_count > 1) { |
109 | if (config.cpu_count > 1) { |
| 110 | waitq_initialize(&ap_completion_wq); |
110 | waitq_initialize(&ap_completion_wq); |
| 111 | /* |
111 | /* |
| 112 | * Create the kmp thread and wait for its completion. |
112 | * Create the kmp thread and wait for its completion. |
| 113 | * cpu1 through cpuN-1 will come up consecutively and |
113 | * cpu1 through cpuN-1 will come up consecutively and |
| Line 123... | Line 123... | ||
| 123 | } else |
123 | } else |
| 124 | panic("Unable to create kmp thread."); |
124 | panic("Unable to create kmp thread."); |
| 125 | thread_join(thread); |
125 | thread_join(thread); |
| 126 | thread_detach(thread); |
126 | thread_detach(thread); |
| 127 | } |
127 | } |
| 128 | #endif /* CONFIG_SMP */ |
- | |
| 129 | 128 | ||
| 130 | #ifdef CONFIG_SMP |
- | |
| 131 | if (config.cpu_count > 1) { |
129 | if (config.cpu_count > 1) { |
| 132 | count_t i; |
130 | count_t i; |
| 133 | 131 | ||
| 134 | /* |
132 | /* |
| 135 | * For each CPU, create its load balancing thread. |
133 | * For each CPU, create its load balancing thread. |
| Line 141... | Line 139... | ||
| 141 | thread->cpu = &cpus[i]; |
139 | thread->cpu = &cpus[i]; |
| 142 | spinlock_unlock(&thread->lock); |
140 | spinlock_unlock(&thread->lock); |
| 143 | thread_ready(thread); |
141 | thread_ready(thread); |
| 144 | } else |
142 | } else |
| 145 | printf("Unable to create kcpulb thread for cpu" PRIc "\n", i); |
143 | printf("Unable to create kcpulb thread for cpu" PRIc "\n", i); |
| 146 | - | ||
| 147 | } |
144 | } |
| 148 | } |
145 | } |
| 149 | #endif /* CONFIG_SMP */ |
146 | #endif /* CONFIG_SMP */ |
| 150 | 147 | ||
| 151 | /* |
148 | /* |
| 152 | * At this point SMP, if present, is configured. |
149 | * At this point SMP, if present, is configured. |
| 153 | */ |
150 | */ |
| 154 | arch_post_smp_init(); |
151 | arch_post_smp_init(); |
| 155 | 152 | ||
| 156 | #ifdef CONFIG_KCONSOLE |
153 | #ifdef CONFIG_KCONSOLE |
| 157 | if (stdin) { |
154 | if (stdin) { |
| 158 | /* |
155 | /* |
| 159 | * Create kernel console. |
156 | * Create kernel console. |
| 160 | */ |
157 | */ |
| Line 177... | Line 174... | ||
| 177 | for (i = 0; i < init.cnt; i++) { |
174 | for (i = 0; i < init.cnt; i++) { |
| 178 | if (init.tasks[i].addr % FRAME_SIZE) { |
175 | if (init.tasks[i].addr % FRAME_SIZE) { |
| 179 | printf("init[%" PRIc "].addr is not frame aligned\n", i); |
176 | printf("init[%" PRIc "].addr is not frame aligned\n", i); |
| 180 | continue; |
177 | continue; |
| 181 | } |
178 | } |
| 182 | 179 | ||
| 183 | /* |
180 | /* |
| 184 | * Construct task name from the 'boot:' prefix and the |
181 | * Construct task name from the 'boot:' prefix and the |
| 185 | * name stored in the init structure (if any). |
182 | * name stored in the init structure (if any). |
| 186 | */ |
183 | */ |
| 187 | 184 | ||
| 188 | char namebuf[TASK_NAME_BUFLEN], *name; |
185 | char namebuf[TASK_NAME_BUFLEN]; |
| - | 186 | char *name; |
|
| 189 | 187 | ||
| 190 | name = init.tasks[i].name; |
188 | name = init.tasks[i].name; |
| 191 | if (name[0] == '\0') name = "<unknown>"; |
189 | if (name[0] == '\0') |
| - | 190 | name = "<unknown>"; |
|
| 192 | 191 | ||
| 193 | ASSERT(TASK_NAME_BUFLEN >= BOOT_PREFIX_LEN); |
192 | ASSERT(TASK_NAME_BUFLEN >= BOOT_PREFIX_LEN); |
| 194 | strncpy(namebuf, BOOT_PREFIX, TASK_NAME_BUFLEN); |
193 | strncpy(namebuf, BOOT_PREFIX, TASK_NAME_BUFLEN); |
| 195 | strncpy(namebuf + BOOT_PREFIX_LEN, name, |
194 | strncpy(namebuf + BOOT_PREFIX_LEN, name, |
| 196 | TASK_NAME_BUFLEN - BOOT_PREFIX_LEN); |
195 | TASK_NAME_BUFLEN - BOOT_PREFIX_LEN); |
| 197 | 196 | ||
| Line 231... | Line 230... | ||
| 231 | if (programs[i].task != NULL) { |
230 | if (programs[i].task != NULL) { |
| 232 | program_ready(&programs[i]); |
231 | program_ready(&programs[i]); |
| 233 | thread_usleep(10000); |
232 | thread_usleep(10000); |
| 234 | } |
233 | } |
| 235 | } |
234 | } |
| 236 | 235 | ||
| 237 | #ifdef CONFIG_KCONSOLE |
236 | #ifdef CONFIG_KCONSOLE |
| 238 | if (!stdin) { |
237 | if (!stdin) { |
| 239 | thread_sleep(10); |
238 | thread_sleep(10); |
| 240 | printf("kinit: No stdin\nKernel alive: ."); |
239 | printf("kinit: No stdin\nKernel alive: ."); |
| 241 | 240 | ||