[PATCH 14/16] bootstd: Allow display of the x86 setup information

Simon Glass sjg at chromium.org
Sun Jul 30 19:17:00 CEST 2023


Provide an option to dump this information if available.

Move the funciion prototype to the common x86 header. Allow the command
line to be left out since 'bootflow info' show this itself and it is
not in the correct place in memory until the kernel is actually booted.

Fix a badly aligned heading while we are here.

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

 arch/x86/include/asm/zimage.h | 10 ------
 arch/x86/lib/zimage.c         |  8 ++---
 cmd/bootflow.c                | 14 +++++++--
 doc/usage/cmd/bootflow.rst    | 59 ++++++++++++++++++++++++++++++++++-
 include/bootflow.h            |  2 +-
 include/bootm.h               | 11 +++++++
 6 files changed, 86 insertions(+), 18 deletions(-)

diff --git a/arch/x86/include/asm/zimage.h b/arch/x86/include/asm/zimage.h
index 000b38ea8993..655675b66614 100644
--- a/arch/x86/include/asm/zimage.h
+++ b/arch/x86/include/asm/zimage.h
@@ -62,14 +62,4 @@ 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,
 		 ulong initrd_addr, ulong initrd_size, ulong cmdline_force);
 
-/**
- * zimage_dump() - Dump the metadata of a zimage
- *
- * This shows all available information in a zimage that has been loaded.
- *
- * @base_ptr: Pointer to the boot parameters, typically at address
- *	DEFAULT_SETUP_BASE
- */
-void zimage_dump(struct boot_params *base_ptr);
-
 #endif
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 062e3d3e3151..a41e1ccf8a65 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -692,7 +692,7 @@ static void show_loader(struct setup_header *hdr)
 	printf("\n");
 }
 
-void zimage_dump(struct boot_params *base_ptr)
+void zimage_dump(struct boot_params *base_ptr, bool show_cmdline)
 {
 	struct setup_header *hdr;
 	const char *version;
@@ -703,7 +703,7 @@ void zimage_dump(struct boot_params *base_ptr)
 
 	printf("E820: %d entries\n", base_ptr->e820_entries);
 	if (base_ptr->e820_entries) {
-		printf("%18s  %16s  %s\n", "Addr", "Size", "Type");
+		printf("%12s  %10s  %s\n", "Addr", "Size", "Type");
 		for (i = 0; i < base_ptr->e820_entries; i++) {
 			struct e820_entry *entry = &base_ptr->e820_map[i];
 
@@ -749,7 +749,7 @@ void zimage_dump(struct boot_params *base_ptr)
 	print_num("Ext loader ver", hdr->ext_loader_ver);
 	print_num("Ext loader type", hdr->ext_loader_type);
 	print_num("Command line ptr", hdr->cmd_line_ptr);
-	if (hdr->cmd_line_ptr) {
+	if (show_cmdline && hdr->cmd_line_ptr) {
 		printf("   ");
 		/* Use puts() to avoid limits from CONFIG_SYS_PBSIZE */
 		puts((char *)(ulong)hdr->cmd_line_ptr);
@@ -787,7 +787,7 @@ static int do_zboot_dump(struct cmd_tbl *cmdtp, int flag, int argc,
 		printf("No zboot setup_base\n");
 		return CMD_RET_FAILURE;
 	}
-	zimage_dump(base_ptr);
+	zimage_dump(base_ptr, true);
 
 	return 0;
 }
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index c0aa4f84fe8d..9562832ce438 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <bootdev.h>
 #include <bootflow.h>
+#include <bootm.h>
 #include <bootstd.h>
 #include <command.h>
 #include <console.h>
@@ -303,11 +304,14 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	struct bootstd_priv *std;
 	struct bootflow *bflow;
+	bool x86_setup = false;
 	bool dump = false;
 	int ret;
 
-	if (argc > 1 && *argv[1] == '-')
+	if (argc > 1 && *argv[1] == '-') {
 		dump = strchr(argv[1], 'd');
+		x86_setup = strchr(argv[1], 's');
+	}
 
 	ret = bootstd_get_priv(&std);
 	if (ret)
@@ -319,6 +323,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
 	}
 	bflow = std->cur_bootflow;
 
+	if (IS_ENABLED(CONFIG_X86) && x86_setup) {
+		zimage_dump(bflow->x86_setup, false);
+
+		return 0;
+	}
+
 	printf("Name:      %s\n", bflow->name);
 	printf("Device:    %s\n", bflow->dev->name);
 	printf("Block dev: %s\n", bflow->blk ? bflow->blk->name : "(none)");
@@ -508,7 +518,7 @@ static char bootflow_help_text[] =
 	"scan [-abeGl] [bdev]  - scan for valid bootflows (-l list, -a all, -e errors, -b boot, -G no global)\n"
 	"bootflow list [-e]             - list scanned bootflows (-e errors)\n"
 	"bootflow select [<num>|<name>] - select a bootflow\n"
-	"bootflow info [-d]             - show info on current bootflow (-d dump bootflow)\n"
+	"bootflow info [-ds]            - show info on current bootflow (-d dump bootflow)\n"
 	"bootflow boot                  - boot current bootflow (or first available if none selected)\n"
 	"bootflow menu [-t]             - show a menu of available bootflows\n"
 	"bootflow cmdline [set|get|clear|delete|auto] <param> [<value>] - update cmdline";
diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst
index a8af1f8f6030..d53f8373eff0 100644
--- a/doc/usage/cmd/bootflow.rst
+++ b/doc/usage/cmd/bootflow.rst
@@ -11,7 +11,7 @@ Synopis
     bootflow scan [-abelGH] [bootdev]
     bootflow list [-e]
     bootflow select [<num|name>]
-    bootflow info [-d]
+    bootflow info [-ds]
     bootflow boot
     bootflow cmdline [set|get|clear|delete|auto] <param> [<value>]
 
@@ -191,6 +191,8 @@ Error
 
 Use the `-d` flag to dump out the contents of the bootfile file.
 
+The `-s` flag shows any x86 setup block, instead of the above.
+
 
 bootflow boot
 ~~~~~~~~~~~~~
@@ -522,6 +524,61 @@ the cmdline is word-wrapped here and some parts of the command line are elided::
     [    0.000000] Command line: loglevel=7 ... usb-storage.quirks=13fe:6500:u earlycon=uart8250,mmio32,0xfe03e000,115200n8
     [    0.000000] x86/split lock detection: warning about user-space split_locks
 
+This shows looking at x86 setup information::
+
+    => bootfl sel 0
+    => bootfl i -s
+    Setup located at 77b56010:
+
+    ACPI RSDP addr      : 0
+    E820: 2 entries
+            Addr        Size  Type
+               0        1000  RAM
+        fffff000        1000  Reserved
+    Setup sectors       : 1e
+    Root flags          : 1
+    Sys size            : 63420
+    RAM size            : 0
+    Video mode          : ffff
+    Root dev            : 0
+    Boot flag           : 0
+    Jump                : 66eb
+    Header              : 53726448
+                          Kernel V2
+    Version             : 20d
+    Real mode switch    : 0
+    Start sys seg       : 1000
+    Kernel version      : 38cc
+       @00003acc:
+    Type of loader      : ff
+                          unknown
+    Load flags          : 1
+                        : loaded-high
+    Setup move size     : 8000
+    Code32 start        : 100000
+    Ramdisk image       : 0
+    Ramdisk size        : 0
+    Bootsect kludge     : 0
+    Heap end ptr        : 5160
+    Ext loader ver      : 0
+    Ext loader type     : 0
+    Command line ptr    : 735000
+    Initrd addr max     : 7fffffff
+    Kernel alignment    : 200000
+    Relocatable kernel  : 1
+    Min alignment       : 15
+                        : 200000
+    Xload flags         : 3
+                        : 64-bit-entry can-load-above-4gb
+    Cmdline size        : 7ff
+    Hardware subarch    : 0
+    HW subarch data     : 0
+    Payload offset      : 26e
+    Payload length      : 612045
+    Setup data          : 0
+    Pref address        : 1000000
+    Init size           : 1383000
+    Handover offset     : 0
 
 
 Return value
diff --git a/include/bootflow.h b/include/bootflow.h
index ff2bddb51515..fdcfeddc1a63 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -108,7 +108,7 @@ struct bootflow {
 	ulong fdt_addr;
 	int flags;
 	char *cmdline;
-	char *x86_setup;
+	void *x86_setup;
 	void *bootmeth_priv;
 };
 
diff --git a/include/bootm.h b/include/bootm.h
index 6fe418e00272..92870ff1a206 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -152,4 +152,15 @@ int zboot_start(ulong addr, ulong size, ulong initrd, ulong initrd_size,
 const char *zimage_get_kernel_version(struct boot_params *params,
 				      void *kernel_base);
 
+/**
+ * zimage_dump() - Dump the metadata of a zimage
+ *
+ * This shows all available information in a zimage that has been loaded.
+ *
+ * @base_ptr: Pointer to the boot parameters, typically at address
+ *	DEFAULT_SETUP_BASE
+ * @show_cmdline: true to show the full command line
+ */
+void zimage_dump(struct boot_params *base_ptr, bool show_cmdline);
+
 #endif
-- 
2.41.0.487.g6d72f3e995-goog



More information about the U-Boot mailing list