Rev 3107 | Rev 3191 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3107 | Rev 3149 | ||
---|---|---|---|
Line 151... | Line 151... | ||
151 | thread_ready(t); |
151 | thread_ready(t); |
152 | else |
152 | else |
153 | panic("thread_create/kconsole\n"); |
153 | panic("thread_create/kconsole\n"); |
154 | 154 | ||
155 | interrupts_enable(); |
155 | interrupts_enable(); |
156 | 156 | ||
- | 157 | /* |
|
- | 158 | * Create user tasks, load RAM disk images. |
|
- | 159 | */ |
|
157 | count_t i; |
160 | count_t i; |
- | 161 | thread_t *threads[CONFIG_INIT_TASKS]; |
|
- | 162 | ||
158 | for (i = 0; i < init.cnt; i++) { |
163 | for (i = 0; i < init.cnt; i++) { |
159 | /* |
- | |
160 | * Parse initial images |
- | |
161 | * - Run user tasks |
- | |
162 | * - load RAM disk images. |
- | |
163 | * - register program loader |
- | |
164 | */ |
- | |
165 | - | ||
166 | if (init.tasks[i].addr % FRAME_SIZE) { |
164 | if (init.tasks[i].addr % FRAME_SIZE) { |
167 | printf("init[%d].addr is not frame aligned", i); |
165 | printf("init[%" PRIc "].addr is not frame aligned", i); |
168 | continue; |
166 | continue; |
169 | } |
167 | } |
170 | 168 | ||
171 | task_t *utask; |
- | |
172 | int rc = task_parse_initial((void *) init.tasks[i].addr, |
169 | int rc = task_parse_initial((void *) init.tasks[i].addr, |
173 | "uspace", &utask); |
170 | "uspace", &threads[i]); |
174 | - | ||
175 | if (rc == 0 && utask) { |
- | |
176 | /* Make the task ready */ |
- | |
177 | task_ready(utask); |
- | |
178 | 171 | ||
- | 172 | if (rc == 0 && threads[i] != NULL) { |
|
179 | /* |
173 | /* |
180 | * Set capabilities to init userspace tasks. |
174 | * Set capabilities to init userspace tasks. |
181 | */ |
175 | */ |
182 | cap_set(utask, CAP_CAP | CAP_MEM_MANAGER | |
176 | cap_set(threads[i]->task, CAP_CAP | CAP_MEM_MANAGER | |
183 | CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG); |
177 | CAP_IO_MANAGER | CAP_PREEMPT_CONTROL | CAP_IRQ_REG); |
184 | 178 | ||
185 | 179 | ||
186 | if (!ipc_phone_0) |
180 | if (!ipc_phone_0) |
187 | ipc_phone_0 = &utask->answerbox; |
181 | ipc_phone_0 = &threads[i]->task->answerbox; |
188 | } else if (rc == 0) { |
182 | } else if (rc == 0) { |
189 | /* It was the program loader and was registered */ |
183 | /* It was the program loader and was registered */ |
190 | } else { |
184 | } else { |
191 | /* RAM disk image */ |
185 | /* RAM disk image */ |
192 | int rd = init_rd((rd_header_t *) init.tasks[i].addr, |
186 | int rd = init_rd((rd_header_t *) init.tasks[i].addr, |
193 | init.tasks[i].size); |
187 | init.tasks[i].size); |
194 | 188 | ||
195 | if (rd != RE_OK) |
189 | if (rd != RE_OK) |
196 | printf("Init binary %zd not used, error code %d.\n", i, rd); |
190 | printf("Init binary %" PRIc " not used, error code %d.\n", i, rd); |
- | 191 | } |
|
- | 192 | } |
|
- | 193 | ||
- | 194 | /* |
|
- | 195 | * Run user tasks with reasonable delays |
|
- | 196 | */ |
|
- | 197 | for (i = 0; i < init.cnt; i++) { |
|
- | 198 | if (threads[i] != NULL) { |
|
- | 199 | thread_usleep(50000); |
|
- | 200 | thread_ready(threads[i]); |
|
197 | } |
201 | } |
198 | } |
202 | } |
199 | - | ||
200 | 203 | ||
201 | if (!stdin) { |
204 | if (!stdin) { |
202 | while (1) { |
205 | while (1) { |
203 | thread_sleep(1); |
206 | thread_sleep(1); |
204 | printf("kinit... "); |
207 | printf("kinit... "); |