| 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) |
| 305 | { |
| 306 | struct thread *current; |
| 307 | struct thread *t; |
| 308 | struct block_boot_state *bbs; |
| 309 | |
| 310 | /* This is a ramstage specific API */ |
| 311 | if (!ENV_RAMSTAGE) |
| 312 | dead_code(); |
| 313 | |
| 314 | /* Lazy initialization */ |
| 315 | threads_initialize(); |
| 316 | |
| 317 | current = current_thread(); |
| 318 | |
| 319 | if (!thread_can_yield(current)) { |
| 320 | printk(BIOS_ERR, "%s() called from non-yielding context!\n", __func__); |
| 321 | return -1; |
| 322 | } |
| 323 | |
| 324 | t = get_free_thread(); |
| 325 | |
| 326 | if (t == NULL) { |
| 327 | printk(BIOS_ERR, "%s: No more threads!\n", __func__); |
| 328 | return -1; |
| 329 | } |
| 330 | |
| 331 | bbs = thread_alloc_space(t, sizeof(*bbs)); |
| 332 | bbs->state = state; |
| 333 | bbs->seq = seq; |
| 334 | prepare_thread(t, handle, func, arg, call_wrapper_block_state, bbs); |
| 335 | schedule(t); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | int thread_yield(void) |
| 341 | { |
nothing calls this directly
no test coverage detected