
Split out the code that actually boots linux into a separate sub-command. Add base_ptr to the state to support this.
Show an error if the boot fails, since this should not happen.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Wolfgang Wallner wolfgang.wallner@br-automation.com ---
(no changes since v1)
arch/x86/lib/zimage.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c index e3e3efdde43..82c7e118ffb 100644 --- a/arch/x86/lib/zimage.c +++ b/arch/x86/lib/zimage.c @@ -54,6 +54,8 @@ * @initrd_size: Size of the initial ramdisk, or 0 if none * @load_address: Address where the bzImage is moved before booting, either * BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR + * @base_ptr: Pointer to the boot parameters, typically at address + * DEFAULT_SETUP_BASE */ struct zboot_state { ulong bzimage_addr; @@ -61,12 +63,14 @@ struct zboot_state { ulong initrd_addr; ulong initrd_size; ulong load_address; + struct boot_params *base_ptr; } state;
enum { ZBOOT_STATE_START = BIT(0), + ZBOOT_STATE_GO = BIT(1),
- ZBOOT_STATE_COUNT = 1, + ZBOOT_STATE_COUNT = 2, };
static void build_command_line(char *command_line, int auto_boot) @@ -368,6 +372,7 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, puts("## Kernel loading failed ...\n"); return -1; } + state.base_ptr = base_ptr;
if (setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET, 0, state.initrd_addr, state.initrd_size)) { @@ -375,13 +380,27 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, return -1; }
+ return 0; +} + +static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret; + disable_interrupts(); + /* we assume that the kernel is in place */ - return boot_linux_kernel((ulong)base_ptr, state.load_address, false); + ret = boot_linux_kernel((ulong)state.base_ptr, state.load_address, + false); + printf("Kernel returned! (err=%d)\n", ret); + + return CMD_RET_FAILURE; }
U_BOOT_SUBCMDS(zboot, U_BOOT_CMD_MKENT(start, 8, 1, do_zboot_start, "", ""), + U_BOOT_CMD_MKENT(go, 1, 1, do_zboot_go, "", ""), )
int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc, @@ -420,7 +439,8 @@ int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int argc, return do_zboot(cmdtp, flag, argc, argv, repeatable); }
- do_zboot_states(cmdtp, flag, argc, argv, ZBOOT_STATE_START); + do_zboot_states(cmdtp, flag, argc, argv, ZBOOT_STATE_START | + ZBOOT_STATE_GO);
return CMD_RET_FAILURE; }