| 273 | } |
| 274 | |
| 275 | int thread_run(struct thread_handle *handle, enum cb_err (*func)(void *), void *arg) |
| 276 | { |
| 277 | struct thread *current; |
| 278 | struct thread *t; |
| 279 | |
| 280 | /* Lazy initialization */ |
| 281 | threads_initialize(); |
| 282 | |
| 283 | current = current_thread(); |
| 284 | |
| 285 | if (!thread_can_yield(current)) { |
| 286 | printk(BIOS_ERR, "%s() called from non-yielding context!\n", __func__); |
| 287 | return -1; |
| 288 | } |
| 289 | |
| 290 | t = get_free_thread(); |
| 291 | |
| 292 | if (t == NULL) { |
| 293 | printk(BIOS_ERR, "%s: No more threads!\n", __func__); |
| 294 | return -1; |
| 295 | } |
| 296 | |
| 297 | prepare_thread(t, handle, func, arg, call_wrapper, NULL); |
| 298 | schedule(t); |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | int thread_run_until(struct thread_handle *handle, enum cb_err (*func)(void *), void *arg, |
| 304 | boot_state_t state, boot_state_sequence_t seq) |
no test coverage detected