diff mbox series

[06/18] bootstd: Allow storing the OS command line in the bootflow

Message ID 20230428191819.3070393-6-sjg@chromium.org
State Superseded
Delegated to: Bin Meng
Headers show
Series bootstd: Add a bootmeth for ChromiumOS on x86 | expand

Commit Message

Simon Glass April 28, 2023, 7:18 p.m. UTC
Some operating systems have a command line which can be adjusted before
booting. Store this in the bootflow so it can be controlled within
U-Boot.

Fix up the example output while we are here, since there are a few new
items.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/bootflow.c             | 6 ++++++
 doc/usage/cmd/bootflow.rst | 5 ++++-
 include/bootflow.h         | 2 ++
 test/boot/bootflow.c       | 1 +
 4 files changed, 13 insertions(+), 1 deletion(-)

Comments

Bin Meng May 15, 2023, 7:42 a.m. UTC | #1
On Sat, Apr 29, 2023 at 3:19 AM Simon Glass <sjg@chromium.org> wrote:
>
> Some operating systems have a command line which can be adjusted before
> booting. Store this in the bootflow so it can be controlled within
> U-Boot.
>
> Fix up the example output while we are here, since there are a few new
> items.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  cmd/bootflow.c             | 6 ++++++
>  doc/usage/cmd/bootflow.rst | 5 ++++-
>  include/bootflow.h         | 2 ++
>  test/boot/bootflow.c       | 1 +
>  4 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/bootflow.c b/cmd/bootflow.c
> index aa06999e3db..59d1bdc25b7 100644
> --- a/cmd/bootflow.c
> +++ b/cmd/bootflow.c
> @@ -324,6 +324,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
>         printf("Buffer:    %lx\n", (ulong)map_to_sysmem(bflow->buf));
>         printf("Size:      %x (%d bytes)\n", bflow->size, bflow->size);
>         printf("OS:        %s\n", bflow->os_name ? bflow->os_name : "(none)");
> +       printf("Cmdline:   ");
> +       if (bflow->cmdline)
> +               puts(bflow->cmdline);
> +       else
> +               puts("(none)");
> +       putc('\n');
>         printf("Logo:      %s\n", bflow->logo ?
>                simple_xtoa((ulong)map_to_sysmem(bflow->logo)) : "(none)");
>         if (bflow->logo) {
> diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst
> index cad09bbec9a..1e14fd05ad5 100644
> --- a/doc/usage/cmd/bootflow.rst
> +++ b/doc/usage/cmd/bootflow.rst
> @@ -258,7 +258,6 @@ displayed and booted::
>      Name:      mmc@7e202000.bootdev.part_2
>      Device:    mmc@7e202000.bootdev
>      Block dev: mmc@7e202000.blk
> -    Sequence:  1
>      Method:    distro
>      State:     ready
>      Partition: 2
> @@ -266,6 +265,10 @@ displayed and booted::
>      Filename:  extlinux/extlinux.conf
>      Buffer:    3db7ae88
>      Size:      232 (562 bytes)
> +    OS:        Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
> +    Cmdline:   (none)
> +    Logo:      (none)
> +    FDT:       <NULL>
>      Error:     0
>      U-Boot> bootflow boot
>      ** Booting bootflow 'smsc95xx_eth.bootdev.0'
> diff --git a/include/bootflow.h b/include/bootflow.h
> index 018d021b810..e49f3a24864 100644
> --- a/include/bootflow.h
> +++ b/include/bootflow.h
> @@ -81,6 +81,7 @@ enum bootflow_flags_t {
>   * @fdt_size: Size of FDT file
>   * @fdt_addr: Address of loaded fdt
>   * @flags: Flags for the bootflow (see enum bootflow_flags_t)
> + * @cmdline: OS command line, or NULL it not known (allocated)

if not known

>   */
>  struct bootflow {
>         struct list_head bm_node;
> @@ -104,6 +105,7 @@ struct bootflow {
>         int fdt_size;
>         ulong fdt_addr;
>         int flags;
> +       char *cmdline;
>  };
>
>  /**
> diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
> index fd0e1d62435..b9ac539107b 100644
> --- a/test/boot/bootflow.c
> +++ b/test/boot/bootflow.c
> @@ -226,6 +226,7 @@ static int bootflow_cmd_info(struct unit_test_state *uts)
>         ut_assert_nextlinen("Buffer:    ");
>         ut_assert_nextline("Size:      253 (595 bytes)");
>         ut_assert_nextline("OS:        Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)");
> +       ut_assert_nextline("Cmdline:   (none)");
>         ut_assert_nextline("Logo:      (none)");
>         ut_assert_nextline("FDT:       <NULL>");
>         ut_assert_nextline("Error:     0");
> --

Otherwise,
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
diff mbox series

Patch

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index aa06999e3db..59d1bdc25b7 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -324,6 +324,12 @@  static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
 	printf("Buffer:    %lx\n", (ulong)map_to_sysmem(bflow->buf));
 	printf("Size:      %x (%d bytes)\n", bflow->size, bflow->size);
 	printf("OS:        %s\n", bflow->os_name ? bflow->os_name : "(none)");
+	printf("Cmdline:   ");
+	if (bflow->cmdline)
+		puts(bflow->cmdline);
+	else
+		puts("(none)");
+	putc('\n');
 	printf("Logo:      %s\n", bflow->logo ?
 	       simple_xtoa((ulong)map_to_sysmem(bflow->logo)) : "(none)");
 	if (bflow->logo) {
diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst
index cad09bbec9a..1e14fd05ad5 100644
--- a/doc/usage/cmd/bootflow.rst
+++ b/doc/usage/cmd/bootflow.rst
@@ -258,7 +258,6 @@  displayed and booted::
     Name:      mmc@7e202000.bootdev.part_2
     Device:    mmc@7e202000.bootdev
     Block dev: mmc@7e202000.blk
-    Sequence:  1
     Method:    distro
     State:     ready
     Partition: 2
@@ -266,6 +265,10 @@  displayed and booted::
     Filename:  extlinux/extlinux.conf
     Buffer:    3db7ae88
     Size:      232 (562 bytes)
+    OS:        Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+    Cmdline:   (none)
+    Logo:      (none)
+    FDT:       <NULL>
     Error:     0
     U-Boot> bootflow boot
     ** Booting bootflow 'smsc95xx_eth.bootdev.0'
diff --git a/include/bootflow.h b/include/bootflow.h
index 018d021b810..e49f3a24864 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -81,6 +81,7 @@  enum bootflow_flags_t {
  * @fdt_size: Size of FDT file
  * @fdt_addr: Address of loaded fdt
  * @flags: Flags for the bootflow (see enum bootflow_flags_t)
+ * @cmdline: OS command line, or NULL it not known (allocated)
  */
 struct bootflow {
 	struct list_head bm_node;
@@ -104,6 +105,7 @@  struct bootflow {
 	int fdt_size;
 	ulong fdt_addr;
 	int flags;
+	char *cmdline;
 };
 
 /**
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index fd0e1d62435..b9ac539107b 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -226,6 +226,7 @@  static int bootflow_cmd_info(struct unit_test_state *uts)
 	ut_assert_nextlinen("Buffer:    ");
 	ut_assert_nextline("Size:      253 (595 bytes)");
 	ut_assert_nextline("OS:        Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)");
+	ut_assert_nextline("Cmdline:   (none)");
 	ut_assert_nextline("Logo:      (none)");
 	ut_assert_nextline("FDT:       <NULL>");
 	ut_assert_nextline("Error:     0");