]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
qfw: Add more fields and a heading to qfw list
authorSimon Glass <sjg@chromium.org>
Wed, 29 Oct 2025 14:14:32 +0000 (15:14 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Thu, 6 Nov 2025 22:26:27 +0000 (23:26 +0100)
Update the command to show the size and selected file, since this is
useful information at times. Add a heading so it is clear what each
field refers to.

Add a simple test as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
cmd/qfw.c
doc/usage/cmd/qfw.rst
test/cmd/Makefile
test/cmd/qfw.c [new file with mode: 0644]

index 1b108118658e39c3cd039a53afb718a74df7ed81..09bd7d9849dba9c147806396f9e137614a11a789 100644 (file)
--- a/cmd/qfw.c
+++ b/cmd/qfw.c
@@ -22,10 +22,14 @@ static int qemu_fwcfg_cmd_list_firmware(void)
        if (ret)
                return ret;
 
+       printf("            Addr     Size Sel Name\n");
+       printf("---------------- -------- --- ------------\n");
        for (file = qfw_file_iter_init(qfw_dev, &iter);
             !qfw_file_iter_end(&iter);
             file = qfw_file_iter_next(&iter)) {
-               printf("%08lx %-56s\n", file->addr, file->cfg.name);
+               printf("%16lx %8x %3x %-48s\n", file->addr,
+                      be32_to_cpu(file->cfg.size),
+                      be16_to_cpu(file->cfg.select), file->cfg.name);
        }
 
        return 0;
index 40770acb3c04b35eb9966ec35dbcaf38635ea087..0a65a247b44db6330af6098ea7b9483b8fe13801 100644 (file)
@@ -44,18 +44,21 @@ QEMU firmware files are listed via the *qfw list* command:
 ::
 
     => qfw list
-    00000000 bios-geometry
-    00000000 bootorder
-    000f0060 etc/acpi/rsdp
-    bed14040 etc/acpi/tables
-    00000000 etc/boot-fail-wait
-    00000000 etc/e820
-    00000000 etc/smbios/smbios-anchor
-    00000000 etc/smbios/smbios-tables
-    00000000 etc/system-states
-    00000000 etc/table-loader
-    00000000 etc/tpm/log
-    00000000 genroms/kvmvapic.bin
+                Addr     Size Sel Name
+    ---------------- -------- --- ------------
+                   0        0  20 bios-geometry
+                   0        0  21 bootorder
+            1fc6c000       14  22 etc/acpi/rsdp
+            1fc6c040    20000  23 etc/acpi/tables
+                   0        4  24 etc/boot-fail-wait
+                   0       28  25 etc/e820
+                   0        8  26 etc/msr_feature_control
+                   0       18  27 etc/smbios/smbios-anchor
+                   0      151  28 etc/smbios/smbios-tables
+                   0        6  29 etc/system-states
+                   0     1000  2a etc/table-loader
+                   0        0  2b etc/tpm/log
+                   0     2400  2c genroms/kvmvapic.bin
 
 Where an address is shown, it indicates where the data is available for
 inspection, e.g. using the :doc:`md`.
index e71c80a5b2e6dcb2d6d7b2a7dbecd71b8632c74a..98731d9bdff015c4420edd2c88adbe541939d3b6 100644 (file)
@@ -27,6 +27,7 @@ obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
 ifdef CONFIG_CMD_PCI
 obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o
 endif
+obj-$(CONFIG_CMD_QFW) += qfw.o
 obj-$(CONFIG_CMD_SEAMA) += seama.o
 ifdef CONFIG_SANDBOX
 obj-$(CONFIG_CMD_MBR) += mbr.o
diff --git a/test/cmd/qfw.c b/test/cmd/qfw.c
new file mode 100644 (file)
index 0000000..e615a82
--- /dev/null
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for qfw command
+ *
+ * Copyright 2025 Simon Glass <sjg@chromium.org>
+ */
+
+#include <console.h>
+#include <dm.h>
+#include <mapmem.h>
+#include <qfw.h>
+#include <dm/test.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+
+/* Test 'qfw list' command */
+static int cmd_test_qfw_list(struct unit_test_state *uts)
+{
+       struct fw_cfg_file_iter iter;
+       struct fw_file *file;
+       struct udevice *dev;
+
+       ut_assertok(uclass_first_device_err(UCLASS_QFW, &dev));
+
+       ut_assertok(run_command("qfw list", 0));
+       ut_assert_nextline("            Addr     Size Sel Name");
+       ut_assert_nextlinen("--");
+
+       for (file = qfw_file_iter_init(dev, &iter); !qfw_file_iter_end(&iter);
+            file = qfw_file_iter_next(&iter)) {
+               ut_assert_nextline("%16lx %8x %3x %-48s", file->addr,
+                                  be32_to_cpu(file->cfg.size),
+                                  be16_to_cpu(file->cfg.select),
+                                  file->cfg.name);
+       }
+       ut_assert_console_end();
+
+       return 0;
+}
+CMD_TEST(cmd_test_qfw_list, UTF_CONSOLE);