Attention is currently required from: Jason Glenesk, Raul Rangel, Furquan Shaikh, Marshall Dawson, Aaron Durbin, Felix Held. Hello Furquan Shaikh, Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/50349
to review the following change.
Change subject: amd: refcode_loader: Switch to new CBFS API ......................................................................
amd: refcode_loader: Switch to new CBFS API
This patch rewrites some parts of the Agesa refcode loader to eliminate the passing of raw rdevs between functions, so that we can get rid of cbfs_boot_locate() in favor of more high-level APIs.
Signed-off-by: Julius Werner jwerner@chromium.org Change-Id: I2a6e1158ed7425c69c214462bc52e8694a69997a --- M src/soc/amd/common/block/pi/refcode_loader.c 1 file changed, 19 insertions(+), 41 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/50349/1
diff --git a/src/soc/amd/common/block/pi/refcode_loader.c b/src/soc/amd/common/block/pi/refcode_loader.c index 887856c..009e2d1 100644 --- a/src/soc/amd/common/block/pi/refcode_loader.c +++ b/src/soc/amd/common/block/pi/refcode_loader.c @@ -8,32 +8,19 @@ #include <amdblocks/agesawrapper.h> #include <amdblocks/image.h>
-static int agesa_locate_file(const char *name, struct region_device *rdev, - uint32_t type) +static void *agesa_map_raw_file(const char *name, size_t *size) { - struct cbfsf fh; - - if (cbfs_boot_locate(&fh, name, &type)) - return -1; - - cbfs_file_data(rdev, &fh); - return 0; + enum cbfs_type type = CBFS_TYPE_RAW; + return cbfs_type_map(name, size, &type); }
-static int agesa_locate_raw_file(const char *name, struct region_device *rdev) +static void *agesa_map_stage_file_early(const char *name, size_t *size) { - return agesa_locate_file(name, rdev, CBFS_TYPE_RAW); + enum cbfs_type type = CBFS_TYPE_STAGE; + return cbfs_type_map(name, size, &type); }
-static int agesa_locate_stage_file_early(const char *name, - struct region_device *rdev) -{ - if (agesa_locate_file(name, rdev, CBFS_TYPE_STAGE)) - return -1; -} - -static int agesa_locate_stage_file_ramstage(const char *name, - struct region_device *rdev) +static void *agesa_map_stage_file_ramstage(const char *name, size_t *size) { struct prog prog = PROG_INIT(PROG_REFCODE, name); struct rmod_stage_load rmod_agesa = { @@ -45,21 +32,20 @@ stage_cache_load_stage(STAGE_REFCODE, &prog); } else { if (rmodule_stage_load(&rmod_agesa) < 0) - return -1; + return NULL;
stage_cache_add(STAGE_REFCODE, &prog); }
- prog_chain_rdev(&prog, rdev); - - return 0; + *size = prog_size(&prog); + return prog_start(&prog); }
-static int agesa_locate_stage_file(const char *name, struct region_device *rdev) +static void *agesa_map_stage_file(const char *name, size_t *size) { if (!ENV_RAMSTAGE || !CONFIG(AGESA_SPLIT_MEMORY_FILES)) - return agesa_locate_stage_file_early(name, rdev); - return agesa_locate_stage_file_ramstage(name, rdev); + return agesa_locate_stage_file_early(name, size); + return agesa_locate_stage_file_ramstage(name, size); }
static const char *get_agesa_cbfs_name(void) @@ -75,27 +61,19 @@ { const void *agesa; const AMD_IMAGE_HEADER *image; - struct region_device rdev; size_t file_size; const char *fname; int ret;
- fname = get_agesa_cbfs_name(); - - if (CONFIG(AGESA_BINARY_PI_AS_STAGE)) - ret = agesa_locate_stage_file(fname, &rdev); - else - ret = agesa_locate_raw_file(fname, &rdev); - - if (ret) - return NULL; - - file_size = region_device_sz(&rdev); - /* Assume boot device is memory mapped so the mapping can leak. */ assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED));
- agesa = rdev_mmap_full(&rdev); + fname = get_agesa_cbfs_name(); + + if (CONFIG(AGESA_BINARY_PI_AS_STAGE)) + agesa = agesa_map_stage_file(fname, &file_size); + else + agesa = agesa_map_raw_file(fname, &file_size);
if (!agesa) return NULL;