summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-12-03 17:29:30 -0700
committerTom Rini <trini@konsulko.com>2024-04-10 13:49:16 -0600
commit42a99d0df66d3092dfc1c922de9143448a863118 (patch)
tree378c34677504eb03e9a6c8e4886efb80e7942a82 /cmd
parent228c6722d4468d8cd9a3688e657976968ee3cdb8 (diff)
downloadu-boot-42a99d0df66d3092dfc1c922de9143448a863118.tar.gz
u-boot-42a99d0df66d3092dfc1c922de9143448a863118.tar.bz2
u-boot-42a99d0df66d3092dfc1c922de9143448a863118.zip
x86: zboot: Create separate functions for the logic
Separate out the commands from the logic. This will eventually allow the logic to be used when CONFIG_CMDLINE is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/x86/zboot.c66
1 files changed, 52 insertions, 14 deletions
diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c
index 03cab1d67e..f5c90a8ba8 100644
--- a/cmd/x86/zboot.c
+++ b/cmd/x86/zboot.c
@@ -10,8 +10,7 @@
#include <vsprintf.h>
#include <asm/zimage.h>
-static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+static void zboot_start(int argc, char *const argv[])
{
const char *s;
@@ -53,6 +52,27 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
}
if (argc >= 7)
state.cmdline = env_get(argv[6]);
+}
+
+static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ zboot_start(argc, argv);
+
+ return 0;
+}
+
+static int _zboot_load(void)
+{
+ int ret;
+
+ ret = zboot_load();
+ if (!ret)
+ ret = env_set_hex("zbootbase", map_to_sysmem(state.base_ptr));
+ if (!ret)
+ ret = env_set_hex("zbootaddr", state.load_address);
+ if (ret)
+ return ret;
return 0;
}
@@ -60,18 +80,13 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_zboot_load(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- if (zboot_load())
- return CMD_RET_FAILURE;
-
- if (env_set_hex("zbootbase", map_to_sysmem(state.base_ptr)) ||
- env_set_hex("zbootaddr", state.load_address))
+ if (_zboot_load())
return CMD_RET_FAILURE;
return 0;
}
-static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+static int _zboot_setup(void)
{
struct boot_params *base_ptr = state.base_ptr;
@@ -87,24 +102,47 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
-static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
- char *const argv[])
+static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ return _zboot_setup();
+}
+
+static void zboot_info(void)
{
printf("Kernel loaded at %08lx, setup_base=%p\n",
state.load_address, state.base_ptr);
+}
+
+static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ zboot_info();
return 0;
}
+static int _zboot_go(void)
+{
+ int ret;
+
+ ret = zboot_go();
+
+ return ret;
+}
+
static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
int ret;
- ret = zboot_go();
- printf("Kernel returned! (err=%d)\n", ret);
+ ret = _zboot_go();
+ if (ret) {
+ printf("Kernel returned! (err=%d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
- return CMD_RET_FAILURE;
+ return 0;
}
static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc,