All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2 14/16] x86: zboot: Allow overriding the command line
Date: Sat, 29 Aug 2020 15:41:55 -0600	[thread overview]
Message-ID: <20200829214157.3795497-15-sjg@chromium.org> (raw)
In-Reply-To: <20200829214157.3795497-1-sjg@chromium.org>

When booting Chrome OS images the command line is stored separately
from the kernel. Add a way to specify this address so that images boot
correctly.

Also add comments to the zimage.h header.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
---

(no changes since v1)

 arch/x86/include/asm/zimage.h | 30 +++++++++++++++++++++++++++++-
 arch/x86/lib/bootm.c          |  2 +-
 arch/x86/lib/zimage.c         | 21 ++++++++++++++++-----
 3 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 80e128ccf36..64c0e6e857b 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -30,10 +30,38 @@
 #define BZIMAGE_LOAD_ADDR  0x100000
 #define ZIMAGE_LOAD_ADDR   0x10000
 
+/**
+ * load_zimage() - Load a zImage or bzImage
+ *
+ * This copies an image into the standard location ready for setup
+ *
+ * @image: Address of image to load
+ * @kernel_size: Size of kernel including setup block (or 0 if the kernel is
+ *	new enough to have a 'syssize' value)
+ * @load_addressp: Returns the address where the kernel has been loaded
+ * @return address of setup block, or NULL if something went wrong
+ */
 struct boot_params *load_zimage(char *image, unsigned long kernel_size,
 				ulong *load_addressp);
+
+/**
+ * setup_zimage() - Set up a loaded zImage or bzImage ready for booting
+ *
+ * @setup_base: Pointer to the boot parameters, typically at address
+ *	DEFAULT_SETUP_BASE
+ * @cmd_line: Place to put the command line, or NULL to use the one in the setup
+ *	block
+ * @initrd_addr: Address of the initial ramdisk, or 0 if none
+ * @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
+ * @cmdline_force: Address of 'override' command line, or 0 to use the one in
+ *	the *	setup block
+ * @return 0 (always)
+ */
 int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
-		 unsigned long initrd_addr, unsigned long initrd_size);
+		 ulong initrd_addr, ulong initrd_size, ulong cmdline_force);
+
 void setup_video(struct screen_info *screen_info);
 void setup_efi_info(struct efi_info *efi_info);
 
diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c
index 1198a52ecac..da6b8ce1ec1 100644
--- a/arch/x86/lib/bootm.c
+++ b/arch/x86/lib/bootm.c
@@ -136,7 +136,7 @@ static int boot_prep_linux(bootm_headers_t *images)
 	printf("Setup at %#08lx\n", images->ep);
 	ret = setup_zimage((void *)images->ep, cmd_line_dest,
 			0, images->rd_start,
-			images->rd_end - images->rd_start);
+			images->rd_end - images->rd_start, 0);
 
 	if (ret) {
 		printf("## Setting up boot parameters failed ...\n");
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index aacfffcee7d..8c3d677debc 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -56,6 +56,8 @@
  *	BZIMAGE_LOAD_ADDR or ZIMAGE_LOAD_ADDR
  * @base_ptr: Pointer to the boot parameters, typically at address
  *	DEFAULT_SETUP_BASE
+ * @cmdline: Address of 'override' command line, or 0 to use the one in the
+ *	setup block
  */
 struct zboot_state {
 	ulong bzimage_addr;
@@ -64,6 +66,7 @@ struct zboot_state {
 	ulong initrd_size;
 	ulong load_address;
 	struct boot_params *base_ptr;
+	ulong cmdline;
 } state;
 
 enum {
@@ -284,7 +287,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,
 }
 
 int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
-		 unsigned long initrd_addr, unsigned long initrd_size)
+		 ulong initrd_addr, ulong initrd_size, ulong cmdline_force)
 {
 	struct setup_header *hdr = &setup_base->hdr;
 	int bootproto = get_boot_protocol(hdr, false);
@@ -325,7 +328,10 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,
 		}
 
 		/* build command line at COMMAND_LINE_OFFSET */
-		build_command_line(cmd_line, auto_boot);
+		if (cmdline_force)
+			strcpy(cmd_line, (char *)cmdline_force);
+		else
+			build_command_line(cmd_line, auto_boot);
 	}
 
 	if (IS_ENABLED(CONFIG_INTEL_MID) && bootproto >= 0x0207)
@@ -384,6 +390,8 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc,
 		state.load_address = state.bzimage_addr;
 		state.bzimage_addr = 0;
 	}
+	if (argc >= 7)
+		state.cmdline = simple_strtoul(argv[6], NULL, 16);
 
 	return 0;
 }
@@ -427,7 +435,8 @@ static int do_zboot_setup(struct cmd_tbl *cmdtp, int flag, int argc,
 		return CMD_RET_FAILURE;
 	}
 	ret = setup_zimage(base_ptr, (char *)base_ptr + COMMAND_LINE_OFFSET,
-			   0, state.initrd_addr, state.initrd_size);
+			   0, state.initrd_addr, state.initrd_size,
+			   state.cmdline);
 	if (ret) {
 		puts("Setting up boot parameters failed ...\n");
 		return CMD_RET_FAILURE;
@@ -627,7 +636,7 @@ int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	if (hdr->cmd_line_ptr) {
 		printf("   ");
 		/* Use puts() to avoid limits from CONFIG_SYS_PBSIZE */
-		puts((char *)hdr->cmd_line_ptr);
+		puts((char *)(ulong)hdr->cmd_line_ptr);
 		printf("\n");
 	}
 	print_num("Initrd addr max", hdr->initrd_addr_max);
@@ -707,7 +716,7 @@ int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int argc,
 
 U_BOOT_CMDREP_COMPLETE(
 	zboot, 8, do_zboot_parent, "Boot bzImage",
-	"[addr] [size] [initrd addr] [initrd size] [setup]\n"
+	"[addr] [size] [initrd addr] [initrd size] [setup] [cmdline]\n"
 	"      addr -        The optional starting address of the bzimage.\n"
 	"                    If not set it defaults to the environment\n"
 	"                    variable \"fileaddr\".\n"
@@ -717,6 +726,8 @@ U_BOOT_CMDREP_COMPLETE(
 	"      initrd size - The size of the initrd image to use, if any.\n"
 	"      setup -       The address of the kernel setup region, if this\n"
 	"                    is not at addr\n"
+	"      cmdline -     The address of the kernel command line, to\n"
+	"                    override U-Boot's normal cmdline generation\n"
 	"\n"
 	"Sub-commands to do part of the zboot sequence:\n"
 	"\tstart [addr [arg ...]] - specify arguments\n"
-- 
2.28.0.402.g5ffc5be6b7-goog

  parent reply	other threads:[~2020-08-29 21:41 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-29 21:41 [PATCH v2 00/16] x86: zboot: Enhance the 'zboot' command Simon Glass
2020-08-29 21:41 ` [PATCH v2 01/16] x86: Update the bootparam header Simon Glass
2020-09-01  8:23   ` Bin Meng
2020-09-08 14:05     ` Andy Shevchenko
2020-09-21  2:34       ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 02/16] x86: zimage: Use a state struct to hold the state Simon Glass
2020-09-01  8:45   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 03/16] x86: zimage: Avoid using #ifdef Simon Glass
2020-09-01  8:45   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 04/16] x86: zboot: Move kernel-version code into a function Simon Glass
2020-09-01  8:48   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 05/16] x86: zboot: Correct image type Simon Glass
2020-09-01  8:56   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 06/16] x86: zimage: Disable interrupts just before booting Simon Glass
2020-09-01  9:35   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 07/16] x86: zboot: Set up a sub-command structure Simon Glass
2020-09-01  9:30   ` Bin Meng
2020-09-05 20:51     ` Simon Glass
2020-08-29 21:41 ` [PATCH v2 08/16] x86: zboot: Add a 'go' subcommand Simon Glass
2020-09-01  9:35   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 09/16] x86: zboot: Add an 'info' subcommand Simon Glass
2020-09-01  9:35   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 10/16] x86: zboot: Add an 'setup' subcommand Simon Glass
2020-09-01  9:35   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 11/16] x86: zboot: Set environment variables for image locations Simon Glass
2020-09-01  9:39   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 12/16] x86: zboot: Allow setting a separate setup base address Simon Glass
2020-09-01 10:12   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 13/16] x86: zboot: Add an option to dump the setup information Simon Glass
2020-09-01 10:08   ` Bin Meng
2020-08-29 21:41 ` Simon Glass [this message]
2020-09-01 10:12   ` [PATCH v2 14/16] x86: zboot: Allow overriding the command line Bin Meng
2020-08-29 21:41 ` [PATCH v2 15/16] cros: Update chromium documentation Simon Glass
2020-09-01 10:12   ` Bin Meng
2020-08-29 21:41 ` [PATCH v2 16/16] cros: Add information about booting Chrome OS on x86 Simon Glass
2020-09-01 10:12   ` Bin Meng
2020-08-31  7:23 ` [PATCH v2 07/16] x86: zboot: Set up a sub-command structure Wolfgang Wallner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200829214157.3795497-15-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.