[PATCH 11/38] acpi: Add a comment to set the acpi tables
Simon Glass
sjg at chromium.org
Thu Mar 30 23:32:00 CEST 2023
Sometimes a previous bootloader has written ACPI tables. It is useful to
be able to find and list these. Add an 'acpi set' command to set the
address for these tables.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
cmd/acpi.c | 24 +++++++++++++++++++++---
doc/usage/cmd/acpi.rst | 29 +++++++++++++++++++++++++++--
test/dm/acpi.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 86 insertions(+), 5 deletions(-)
diff --git a/cmd/acpi.c b/cmd/acpi.c
index e70913e40bfe..ede9c8c7dcb4 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -118,6 +118,22 @@ static int do_acpi_list(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static int do_acpi_set(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong val;
+
+ if (argc < 2) {
+ printf("ACPI pointer: %lx\n", gd_acpi_start());
+ } else {
+ val = hextoul(argv[1], NULL);
+ printf("Setting ACPI pointer to %lx\n", val);
+ gd_set_acpi_start(val);
+ }
+
+ return 0;
+}
+
static int do_acpi_items(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -157,12 +173,14 @@ static int do_acpi_dump(struct cmd_tbl *cmdtp, int flag, int argc,
#ifdef CONFIG_SYS_LONGHELP
static char acpi_help_text[] =
- "list - list ACPI tables\n"
- "acpi items [-d] - List/dump each piece of ACPI data from devices\n"
- "acpi dump <name> - Dump ACPI table";
+ "list - list ACPI tables\n"
+ "acpi items [-d] - List/dump each piece of ACPI data from devices\n"
+ "acpi set [<addr>] - Set or show address of ACPI tables\n"
+ "acpi dump <name> - Dump ACPI table";
#endif
U_BOOT_CMD_WITH_SUBCMDS(acpi, "ACPI tables", acpi_help_text,
U_BOOT_SUBCMD_MKENT(list, 1, 1, do_acpi_list),
U_BOOT_SUBCMD_MKENT(items, 2, 1, do_acpi_items),
+ U_BOOT_SUBCMD_MKENT(set, 2, 1, do_acpi_set),
U_BOOT_SUBCMD_MKENT(dump, 2, 1, do_acpi_dump));
diff --git a/doc/usage/cmd/acpi.rst b/doc/usage/cmd/acpi.rst
index 14bafc8e3524..5aeb4f4b77bf 100644
--- a/doc/usage/cmd/acpi.rst
+++ b/doc/usage/cmd/acpi.rst
@@ -11,12 +11,14 @@ Synopis
acpi list
acpi items [-d]
acpi dump <name>
+ acpi set <address>
Description
-----------
-The *acpi* command is used to dump the ACPI tables generated by U-Boot for passing
-to the operating systems.
+The *acpi* command is used to dump the ACPI tables generated by U-Boot for
+passing to the operating systems. It allow allows manually setting the address
+to take a look at existing ACPI tables.
ACPI tables can be generated by various output functions and even devices can
output material to include in the Differentiated System Description Table (DSDT)
@@ -231,5 +233,28 @@ Example
00000000: 44 53 44 54 ea 32 00 00 02 eb 55 2d 42 4f 4f 54 DSDT.2....U-BOOT
00000010: 55 2d 42 4f 4f 54 42 4c 25 07 11 20 49 4e 54 4c U-BOOTBL%.. INTL
+This shows searching for tables in a known area of memory, then setting the
+pointer::
+
+ => acpi list
+ No ACPI tables present
+ => ms.s bff00000 80000 "RSD PTR"
+ bff75000: 52 53 44 20 50 54 52 20 cf 42 4f 43 48 53 20 00 RSD PTR .BOCHS .
+ 1 match
+ => acpi set bff75000
+ Setting ACPI pointer to bff75000
+ => acpi list
+ Name Base Size Detail
+ ---- -------- ----- ------
+ RSDP bff75000 0 v00 BOCHS
+ RSDT bff76a63 38 v01 BOCHS BXPC 1 BXPC 1
+ FACP bff768ff 74 v01 BOCHS BXPC 1 BXPC 1
+ DSDT bff75080 187f v01 BOCHS BXPC 1 BXPC 1
+ FACS bff75040 40
+ APIC bff76973 90 v01 BOCHS BXPC 1 BXPC 1
+ HPET bff76a03 38 v01 BOCHS BXPC 1 BXPC 1
+ WAET bff76a3b 28 v01 BOCHS BXPC 1 BXPC 1
+ SSDT bff95040 c5 v02 COREv4 COREBOOT 2a CORE 20221020
+
.. _`ACPI specification`: https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 9634fc2e9002..1511336a5ebc 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -611,3 +611,41 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_cmd_items, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* Test 'acpi set' command */
+static int dm_test_acpi_cmd_set(struct unit_test_state *uts)
+{
+ struct acpi_ctx ctx;
+ ulong addr;
+ void *buf;
+
+ gd_set_acpi_start(0);
+
+ console_record_reset();
+ ut_asserteq(0, gd_acpi_start());
+ ut_assertok(run_command("acpi set", 0));
+ ut_assert_nextline("ACPI pointer: 0");
+
+ buf = memalign(16, BUF_SIZE);
+ ut_assertnonnull(buf);
+ addr = map_to_sysmem(buf);
+ ut_assertok(setup_ctx_and_base_tables(uts, &ctx, addr));
+
+ ut_assertok(acpi_write_dev_tables(&ctx));
+
+ ut_assertok(run_command("acpi set", 0));
+ ut_assert_nextline("ACPI pointer: %lx", addr);
+
+ ut_assertok(run_command("acpi set 0", 0));
+ ut_assert_nextline("Setting ACPI pointer to 0");
+ ut_asserteq(0, gd_acpi_start());
+
+ ut_assertok(run_commandf("acpi set %lx", addr));
+ ut_assert_nextline("Setting ACPI pointer to %lx", addr);
+ ut_asserteq(addr, gd_acpi_start());
+
+ ut_assert_console_end();
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_cmd_set, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
--
2.40.0.348.gf938b09366-goog
More information about the U-Boot
mailing list