MCPcopy Create free account
hub / github.com/coreboot/coreboot / _cbfs_alloc

Function _cbfs_alloc

src/lib/cbfs.c:533–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532
533void *_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
563void *_cbfs_unverified_area_alloc(const char *area, const char *name,
564 cbfs_allocator_t allocator, void *arg, size_t *size_out,

Callers 3

cbfs_type_allocFunction · 0.50
cbfs_ro_type_allocFunction · 0.50
_cbfs_loadFunction · 0.50

Calls 6

check_or_query_typeFunction · 0.85
get_preload_rdevFunction · 0.85
do_allocFunction · 0.85
rdev_mmap_fullFunction · 0.85
_cbfs_boot_lookupFunction · 0.70
cbfs_unmapFunction · 0.70

Tested by

no test coverage detected