[PATCH 1/1] qfw: Add more fields and a heading to qfw list
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Wed Oct 29 15:14:32 CET 2025
From: Simon Glass <sjg at chromium.org>
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 at chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
cmd/qfw.c | 6 +++++-
doc/usage/cmd/qfw.rst | 27 +++++++++++++++------------
test/cmd/Makefile | 1 +
test/cmd/qfw.c | 40 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 13 deletions(-)
create mode 100644 test/cmd/qfw.c
diff --git a/cmd/qfw.c b/cmd/qfw.c
index 1b108118658..09bd7d9849d 100644
--- 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;
diff --git a/doc/usage/cmd/qfw.rst b/doc/usage/cmd/qfw.rst
index 40770acb3c0..0a65a247b44 100644
--- a/doc/usage/cmd/qfw.rst
+++ b/doc/usage/cmd/qfw.rst
@@ -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`.
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index e71c80a5b2e..98731d9bdff 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -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
index 00000000000..e615a82b31a
--- /dev/null
+++ b/test/cmd/qfw.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for qfw command
+ *
+ * Copyright 2025 Simon Glass <sjg at 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);
--
2.51.0
More information about the U-Boot
mailing list