summaryrefslogtreecommitdiff
path: root/boot/bootm.c
diff options
context:
space:
mode:
authorPhilippe Reynes <philippe.reynes@softathome.com>2022-03-28 22:57:00 +0200
committerTom Rini <trini@konsulko.com>2022-03-31 14:12:01 -0400
commit9d46e63d9771c789c2c934bb6f5f6af042f1bba0 (patch)
tree203636401a0370414a4ec1074ae69cde649b6d63 /boot/bootm.c
parent982207435a7b96d594336a88c08cb5b09e5f2963 (diff)
downloadu-boot-9d46e63d9771c789c2c934bb6f5f6af042f1bba0.tar.gz
u-boot-9d46e63d9771c789c2c934bb6f5f6af042f1bba0.tar.bz2
u-boot-9d46e63d9771c789c2c934bb6f5f6af042f1bba0.zip
cmd: bootm: add a stage pre-load
Add a stage pre-load to the command bootm. Right now, this stage may be used to read a header and check the signature of the full image. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'boot/bootm.c')
-rw-r--r--boot/bootm.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/boot/bootm.c b/boot/bootm.c
index 00c00aef84..714406ab66 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -87,6 +87,33 @@ static int bootm_start(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static ulong bootm_data_addr(int argc, char *const argv[])
+{
+ ulong addr;
+
+ if (argc > 0)
+ addr = simple_strtoul(argv[0], NULL, 16);
+ else
+ addr = image_load_addr;
+
+ return addr;
+}
+
+static int bootm_pre_load(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong data_addr = bootm_data_addr(argc, argv);
+ int ret = 0;
+
+ if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD))
+ ret = image_pre_load(data_addr);
+
+ if (ret)
+ ret = CMD_RET_FAILURE;
+
+ return ret;
+}
+
static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -677,6 +704,9 @@ int do_bootm_states(struct cmd_tbl *cmdtp, int flag, int argc,
if (states & BOOTM_STATE_START)
ret = bootm_start(cmdtp, flag, argc, argv);
+ if (!ret && (states & BOOTM_STATE_PRE_LOAD))
+ ret = bootm_pre_load(cmdtp, flag, argc, argv);
+
if (!ret && (states & BOOTM_STATE_FINDOS))
ret = bootm_find_os(cmdtp, flag, argc, argv);
@@ -866,6 +896,9 @@ static const void *boot_get_kernel(struct cmd_tbl *cmdtp, int flag, int argc,
&fit_uname_config,
&fit_uname_kernel);
+ if (CONFIG_IS_ENABLED(CMD_BOOTM_PRE_LOAD))
+ img_addr += image_load_offset;
+
bootstage_mark(BOOTSTAGE_ID_CHECK_MAGIC);
/* check image type, for FIT images get FIT kernel node */