summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2021-11-15 10:13:37 -0800
committerWerner Zeh <werner.zeh@siemens.com>2021-11-17 12:46:25 +0000
commit57d4bc63f03664240ed4d9585c288ac8e455ca4b (patch)
treeb00f91680986c74d7365ad27b02c2dc97303ff66 /src/lib
parent9a640c0f69597a47769b2a1f5e0f45cde4e9901e (diff)
downloadcoreboot-57d4bc63f03664240ed4d9585c288ac8e455ca4b.tar.gz
coreboot-57d4bc63f03664240ed4d9585c288ac8e455ca4b.tar.bz2
coreboot-57d4bc63f03664240ed4d9585c288ac8e455ca4b.zip
cbfs: Add helper functions to look up size and type of a file
This patch adds cbfs_get_size() and cbfs_get_type() helper functions (and _ro_ variations) to look up the size or type of a CBFS file without loading it. Generally, use of these should be discouraged because that tends to mean that the file needs to be looked up more than once, and cbfs_alloc() or cbfs_type_load() are usually the more efficient alternative... but sometimes they're unavoidable, so we might as well offer them. Also remove the <cbfs_private.h> header which had already become sort of unnecessary with previous changes. cbfs_boot_lookup() is now exported in <cbfs.h> for use in inlines, but should not be used directly by other files (and is prefixed with an underscore to highlight that). Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I8092d8f6e04bdfb4df6c626dc7d42b402fe0a8ba Reviewed-on: https://review.coreboot.org/c/coreboot/+/59312 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-by: Jakub Czapiga <jacz@semihalf.com> Reviewed-by: Lean Sheng Tan <lean.sheng.tan@intel.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbfs.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index dbb3b1a9133e..1ffc69508ab0 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -3,8 +3,8 @@
#include <assert.h>
#include <boot_device.h>
#include <cbfs.h>
-#include <cbfs_private.h>
#include <cbmem.h>
+#include <commonlib/bsd/cbfs_private.h>
#include <commonlib/bsd/compression.h>
#include <commonlib/endian.h>
#include <console/console.h>
@@ -35,8 +35,8 @@ static void switch_to_postram_cache(int unused)
}
ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache);
-cb_err_t cbfs_boot_lookup(const char *name, bool force_ro,
- union cbfs_mdata *mdata, struct region_device *rdev)
+cb_err_t _cbfs_boot_lookup(const char *name, bool force_ro,
+ union cbfs_mdata *mdata, struct region_device *rdev)
{
const struct cbfs_boot_device *cbd = cbfs_get_boot_device(force_ro);
if (!cbd)
@@ -65,7 +65,7 @@ cb_err_t cbfs_boot_lookup(const char *name, bool force_ro,
if (CONFIG(VBOOT_ENABLE_CBFS_FALLBACK) && !force_ro && err == CB_CBFS_NOT_FOUND) {
printk(BIOS_INFO, "CBFS: Fall back to RO region for %s\n", name);
- return cbfs_boot_lookup(name, true, mdata, rdev);
+ return _cbfs_boot_lookup(name, true, mdata, rdev);
}
if (err) {
if (err == CB_CBFS_NOT_FOUND)
@@ -90,7 +90,7 @@ cb_err_t cbfs_boot_lookup(const char *name, bool force_ro,
int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type)
{
- if (cbfs_boot_lookup(name, false, &fh->mdata, &fh->data))
+ if (_cbfs_boot_lookup(name, false, &fh->mdata, &fh->data))
return -1;
size_t msize = be32toh(fh->mdata.h.offset);
@@ -330,7 +330,7 @@ void cbfs_preload(const char *name)
DEBUG("%s(name='%s')\n", __func__, name);
- if (cbfs_boot_lookup(name, force_ro, &mdata, &rdev))
+ if (_cbfs_boot_lookup(name, force_ro, &mdata, &rdev))
return;
size = region_device_sz(&rdev);
@@ -422,7 +422,7 @@ void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg,
DEBUG("%s(name='%s', alloc=%p(%p), force_ro=%s, type=%d)\n", __func__, name, allocator,
arg, force_ro ? "true" : "false", type ? *type : -1);
- if (cbfs_boot_lookup(name, force_ro, &mdata, &rdev))
+ if (_cbfs_boot_lookup(name, force_ro, &mdata, &rdev))
return NULL;
if (type) {
@@ -525,7 +525,7 @@ cb_err_t cbfs_prog_stage_load(struct prog *pstage)
prog_locate_hook(pstage);
- if ((err = cbfs_boot_lookup(prog_name(pstage), false, &mdata, &rdev)))
+ if ((err = _cbfs_boot_lookup(prog_name(pstage), false, &mdata, &rdev)))
return err;
assert(be32toh(mdata.h.type) == CBFS_TYPE_STAGE);