From: Simon Glass Date: Mon, 4 Dec 2023 00:29:30 +0000 (-0700) Subject: x86: zboot: Create separate functions for the logic X-Git-Url: http://git.dujemihanovic.xyz/html/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=42a99d0df66d3092dfc1c922de9143448a863118;p=u-boot.git 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 --- 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 #include -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,