diff mbox series

[08/16] x86: zboot: Add a 'go' subcommand

Message ID 20200801160824.17486-9-sjg@chromium.org
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: zboot: Enhance the 'zboot' command | expand

Commit Message

Simon Glass Aug. 1, 2020, 4:08 p.m. UTC
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>
---

 arch/x86/lib/zimage.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

Comments

Wolfgang Wallner Aug. 13, 2020, 11:22 a.m. UTC | #1
Hi Simon,

-----"Simon Glass" <sjg@chromium.org> schrieb: -----
> Betreff: [PATCH 08/16] x86: zboot: Add a 'go' subcommand
> 
> 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>
> ---
> 
>  arch/x86/lib/zimage.c | 26 +++++++++++++++++++++++---
>  1 file changed, 23 insertions(+), 3 deletions(-)

Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
diff mbox series

Patch

diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 3d3fe6ec05f..5b096e9b0b0 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;
 }