summaryrefslogtreecommitdiff
path: root/src/soc
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2021-02-05 17:04:04 -0800
committerPatrick Georgi <pgeorgi@google.com>2021-03-17 08:10:28 +0000
commit806deb666110d231a4800a5a1adcc932242aefa5 (patch)
tree6410d4e1854ae0eb2aafd4e897676db83c238676 /src/soc
parent77639e4537cc9e56e65880e022e154af6d042453 (diff)
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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50349 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/soc')
-rw-r--r--src/soc/amd/common/block/pi/refcode_loader.c59
1 files changed, 18 insertions, 41 deletions
diff --git a/src/soc/amd/common/block/pi/refcode_loader.c b/src/soc/amd/common/block/pi/refcode_loader.c
index 70cedb3c1c..d9704e0548 100644
--- a/src/soc/amd/common/block/pi/refcode_loader.c
+++ b/src/soc/amd/common/block/pi/refcode_loader.c
@@ -9,32 +9,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;
-}
-
-static int agesa_locate_raw_file(const char *name, struct region_device *rdev)
-{
- return agesa_locate_file(name, rdev, CBFS_TYPE_RAW);
+ enum cbfs_type type = CBFS_TYPE_RAW;
+ return cbfs_type_map(name, size, &type);
}
-static int agesa_locate_stage_file_early(const char *name,
- struct region_device *rdev)
+static void *agesa_map_stage_file_early(const char *name, size_t *size)
{
- if (agesa_locate_file(name, rdev, CBFS_TYPE_STAGE))
- return -1;
+ enum cbfs_type type = CBFS_TYPE_STAGE;
+ return cbfs_type_map(name, size, &type);
}
-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 = {
@@ -46,21 +33,20 @@ static int agesa_locate_stage_file_ramstage(const char *name,
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_map_stage_file_early(name, size);
+ return agesa_map_stage_file_ramstage(name, size);
}
static const char *get_agesa_cbfs_name(void)
@@ -76,27 +62,18 @@ const void *agesawrapper_locate_module(const char name[8])
{
const void *agesa;
const AMD_IMAGE_HEADER *image;
- struct region_device rdev;
size_t file_size;
const char *fname;
- int ret;
+
+ /* Assume boot device is memory mapped so the mapping can leak. */
+ assert(CONFIG(BOOT_DEVICE_MEMORY_MAPPED));
fname = get_agesa_cbfs_name();
if (CONFIG(AGESA_BINARY_PI_AS_STAGE))
- ret = agesa_locate_stage_file(fname, &rdev);
+ agesa = agesa_map_stage_file(fname, &file_size);
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);
+ agesa = agesa_map_raw_file(fname, &file_size);
if (!agesa)
return NULL;