From 74545d49c7d1558473118fab0f74de3c5976ee9b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 29 Oct 2025 15:14:32 +0100 Subject: [PATCH] qfw: Add more fields and a heading to qfw list 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 Signed-off-by: Heinrich Schuchardt --- 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 + */ + +#include +#include +#include +#include +#include +#include +#include + +/* 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.47.3