| 239 | } |
| 240 | |
| 241 | static void threads_initialize(void) |
| 242 | { |
| 243 | int i; |
| 244 | struct thread *t; |
| 245 | u8 *stack_top; |
| 246 | |
| 247 | if (initialized) |
| 248 | return; |
| 249 | |
| 250 | t = &all_threads[0]; |
| 251 | |
| 252 | set_current_thread(t); |
| 253 | |
| 254 | t->stack_orig = 0; /* We never free the main thread */ |
| 255 | t->id = 0; |
| 256 | t->can_yield = 1; |
| 257 | |
| 258 | for (i = 0; i < sizeof(thread_stacks) / sizeof(u32); i++) |
| 259 | ((u32 *)thread_stacks)[i] = 0xDEADBEEF; |
| 260 | |
| 261 | stack_top = &thread_stacks[CONFIG_THREAD_STACK_SIZE]; |
| 262 | for (i = 1; i < TOTAL_NUM_THREADS; i++) { |
| 263 | t = &all_threads[i]; |
| 264 | t->stack_orig = (uintptr_t)stack_top; |
| 265 | t->id = i; |
| 266 | stack_top += CONFIG_THREAD_STACK_SIZE; |
| 267 | free_thread(t); |
| 268 | } |
| 269 | |
| 270 | idle_thread_init(); |
| 271 | |
| 272 | initialized = 1; |
| 273 | } |
| 274 | |
| 275 | int thread_run(struct thread_handle *handle, enum cb_err (*func)(void *), void *arg) |
| 276 | { |
no test coverage detected