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 <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Simon Glass
2025-10-29 15:14:32 +01:00
committed by Heinrich Schuchardt
parent ddc916334a
commit 74545d49c7
4 changed files with 61 additions and 13 deletions

View File

@@ -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;

View 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`.

View 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

40
test/cmd/qfw.c Normal file
View File

@@ -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);