| 531 | } |
| 532 | |
| 533 | void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg, |
| 534 | size_t *size_out, bool force_ro, enum cbfs_type *type) |
| 535 | { |
| 536 | struct region_device rdev; |
| 537 | bool preload_successful = false; |
| 538 | union cbfs_mdata mdata; |
| 539 | |
| 540 | DEBUG("%s(name='%s', alloc=%p(%p), force_ro=%s, type=%d)\n", __func__, name, allocator, |
| 541 | arg, force_ro ? "true" : "false", type ? *type : -1); |
| 542 | |
| 543 | if (_cbfs_boot_lookup(name, force_ro, &mdata, &rdev)) |
| 544 | return NULL; |
| 545 | |
| 546 | if (check_or_query_type(&mdata, type) != CB_SUCCESS) |
| 547 | return NULL; |
| 548 | |
| 549 | /* Update the rdev with the preload content */ |
| 550 | if (!force_ro && get_preload_rdev(&rdev, name) == CB_SUCCESS) |
| 551 | preload_successful = true; |
| 552 | |
| 553 | void *ret = do_alloc(&mdata, &rdev, allocator, arg, size_out, false); |
| 554 | |
| 555 | /* When using cbfs_preload we need to free the preload buffer after populating the |
| 556 | * destination buffer. We know we must have a mem_rdev here, so extra mmap is fine. */ |
| 557 | if (preload_successful) |
| 558 | cbfs_unmap(rdev_mmap_full(&rdev)); |
| 559 | |
| 560 | return ret; |
| 561 | } |
| 562 | |
| 563 | void *_cbfs_unverified_area_alloc(const char *area, const char *name, |
| 564 | cbfs_allocator_t allocator, void *arg, size_t *size_out, |
no test coverage detected