| 356 | } |
| 357 | |
| 358 | void cbfs_preload(const char *name) |
| 359 | { |
| 360 | struct region_device rdev; |
| 361 | union cbfs_mdata mdata; |
| 362 | struct cbfs_preload_context *context; |
| 363 | bool force_ro = false; |
| 364 | size_t size; |
| 365 | |
| 366 | if (!CONFIG(CBFS_PRELOAD)) |
| 367 | dead_code(); |
| 368 | |
| 369 | /* We don't want to cross the vboot boundary */ |
| 370 | if (ENV_SEPARATE_ROMSTAGE && CONFIG(VBOOT_STARTS_IN_ROMSTAGE)) |
| 371 | return; |
| 372 | |
| 373 | DEBUG("%s(name='%s')\n", __func__, name); |
| 374 | |
| 375 | if (_cbfs_boot_lookup(name, force_ro, &mdata, &rdev)) |
| 376 | return; |
| 377 | |
| 378 | size = region_device_sz(&rdev); |
| 379 | |
| 380 | context = alloc_cbfs_preload_context(strlen(name) + 1); |
| 381 | if (!context) { |
| 382 | ERROR("%s(name='%s') failed to allocate preload context\n", __func__, name); |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | context->buffer = mem_pool_alloc(&cbfs_cache, size); |
| 387 | if (context->buffer == NULL) { |
| 388 | ERROR("%s(name='%s') failed to allocate %zu bytes for preload buffer\n", |
| 389 | __func__, name, size); |
| 390 | goto out; |
| 391 | } |
| 392 | |
| 393 | context->rdev = rdev; |
| 394 | strcpy(context->name, name); |
| 395 | |
| 396 | append_cbfs_preload_context(context); |
| 397 | |
| 398 | if (thread_run(&context->handle, cbfs_preload_thread_entry, context) == 0) |
| 399 | return; |
| 400 | |
| 401 | ERROR("%s(name='%s') failed to start preload thread\n", __func__, name); |
| 402 | mem_pool_free(&cbfs_cache, context->buffer); |
| 403 | |
| 404 | out: |
| 405 | free_cbfs_preload_context(context); |
| 406 | } |
| 407 | |
| 408 | void cbfs_preload_wait_for_all(void) |
| 409 | { |
no test coverage detected