qfw: Add a subcommand to decode the QEMU E820 data
Provide a simple command to display the memory map described by this table. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
17
cmd/qfw.c
17
cmd/qfw.c
@@ -234,6 +234,19 @@ static int do_read(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_e820(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_X86)) {
|
||||
printf("Not supported on this architecture\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
cmd_qfw_e820(qfw_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct cmd_tbl fwcfg_commands[] = {
|
||||
U_BOOT_CMD_MKENT(list, 0, 1, qemu_fwcfg_do_list, "", ""),
|
||||
U_BOOT_CMD_MKENT(cpus, 0, 1, qemu_fwcfg_do_cpus, "", ""),
|
||||
@@ -242,6 +255,7 @@ static struct cmd_tbl fwcfg_commands[] = {
|
||||
U_BOOT_CMD_MKENT(table, 0, 1, do_table, "", ""),
|
||||
U_BOOT_CMD_MKENT(arch, 0, 1, do_arch, "", ""),
|
||||
U_BOOT_CMD_MKENT(read, 2, 1, do_read, "", ""),
|
||||
U_BOOT_CMD_MKENT(e820, 0, 1, do_e820, "", ""),
|
||||
};
|
||||
|
||||
static int do_qemu_fw(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
@@ -278,4 +292,5 @@ U_BOOT_CMD(
|
||||
" - load <kernel addr> <initrd addr> : load kernel and initrd (if any), and setup for zboot\n"
|
||||
" - table : show /etc/table-loader\n"
|
||||
" - arch : show arch-specific data\n"
|
||||
" - read <addr> <filename> : read a flle into memory");
|
||||
" - read <addr> <filename> : read a flle into memory\n"
|
||||
" - e820 : show QEMU e820 table");
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
obj-$(CONFIG_CMD_CBSYSINFO) += cbsysinfo.o
|
||||
obj-y += cpuid.o msr.o mtrr.o
|
||||
obj-$(CONFIG_CMD_CBCMOS) += cbcmos.o
|
||||
obj-y += qfw_x86.o
|
||||
obj-$(CONFIG_CMD_EXCEPTION) += exception.o
|
||||
obj-$(CONFIG_USE_HOB) += hob.o
|
||||
obj-$(CONFIG_HAVE_FSP) += fsp.o
|
||||
|
||||
25
cmd/x86/qfw_x86.c
Normal file
25
cmd/x86/qfw_x86.c
Normal file
@@ -0,0 +1,25 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* x86-specific qfw commands
|
||||
*
|
||||
* Copyright 2025 Simon Glass <sjg@chromium.org>
|
||||
*/
|
||||
|
||||
#include <abuf.h>
|
||||
#include <command.h>
|
||||
#include <qfw.h>
|
||||
#include <asm/e820.h>
|
||||
|
||||
int cmd_qfw_e820(struct udevice *dev)
|
||||
{
|
||||
struct abuf tab;
|
||||
int ret;
|
||||
|
||||
ret = qfw_get_file(dev, "etc/e820", &tab);
|
||||
if (ret)
|
||||
return CMD_RET_FAILURE;
|
||||
e820_dump(tab.data, tab.size / sizeof(struct e820_entry));
|
||||
abuf_uninit(&tab);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ Synopsis
|
||||
qfw table
|
||||
qfw arch
|
||||
qfw read <addr> <filename>
|
||||
qfw e820
|
||||
|
||||
Description
|
||||
-----------
|
||||
@@ -40,6 +41,9 @@ The *qfw arch* command shows some items marked as 'arch local' in QEMU.
|
||||
|
||||
The *qfw read* command allowing a QEMU file to be read into memory.
|
||||
|
||||
The *qfw e820* command shows the memory-map information provided by QEMU. It
|
||||
uses the x86 e820 format.
|
||||
|
||||
kernel_addr
|
||||
address to which the file specified by the -kernel parameter of QEMU shall
|
||||
be loaded. Defaults to environment variable *loadaddr* and further to
|
||||
@@ -199,6 +203,18 @@ provided size information:
|
||||
00001010: 40 1c 00 00 @...
|
||||
|
||||
|
||||
This shows dumping the E820 table, showing the emulated RAM as well as some
|
||||
reserved memory:
|
||||
|
||||
::
|
||||
|
||||
=> qfw e820
|
||||
Addr Size Type
|
||||
fd00000000 300000000 Reserved
|
||||
0 20000000 RAM
|
||||
=>
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
|
||||
@@ -464,4 +464,12 @@ int qfw_load_file(struct udevice *dev, const char *fname, ulong addr);
|
||||
*/
|
||||
int qfw_get_file(struct udevice *dev, const char *fname, struct abuf *loader);
|
||||
|
||||
/**
|
||||
* cmd_qfw_e820() - Execute the 'qfw e820' command for x86
|
||||
*
|
||||
* @dev: UCLASS_QFW device
|
||||
* Return: 0 on success (always), 1 if there is no E820 information
|
||||
*/
|
||||
int cmd_qfw_e820(struct udevice *dev);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -113,3 +113,21 @@ static int cmd_test_qfw_read(struct unit_test_state *uts)
|
||||
return 0;
|
||||
}
|
||||
CMD_TEST(cmd_test_qfw_read, UTF_CONSOLE);
|
||||
|
||||
/* Test 'qfw e820' command */
|
||||
static int cmd_test_qfw_e820(struct unit_test_state *uts)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = run_command("qfw e820", 0);
|
||||
if (!IS_ENABLED(CONFIG_X86)) {
|
||||
ut_asserteq(1, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ut_assertok(ret);
|
||||
ut_assert_nextline(" Addr Size Type");
|
||||
|
||||
return 0;
|
||||
}
|
||||
CMD_TEST(cmd_test_qfw_e820, UTF_CONSOLE);
|
||||
|
||||
Reference in New Issue
Block a user