aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-07-07 13:12:12 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-07-17 14:32:24 +0800
commita4f8208919a4458ebe93d46d43a7cb0a13f7a0d8 (patch)
tree5dfc4356dcc6ead5dcb7f819965216377207c274
parentfefac0b0643b14e72c356cf05dabcbe7512c4709 (diff)
downloadu-boot-a4f8208919a4458ebe93d46d43a7cb0a13f7a0d8.zip
u-boot-a4f8208919a4458ebe93d46d43a7cb0a13f7a0d8.tar.gz
u-boot-a4f8208919a4458ebe93d46d43a7cb0a13f7a0d8.tar.bz2
acpi: Add an acpi command to list/dump generated ACPI items
Add a command that shows the individual blocks of data generated by each device, effectively splitting the full table into its component parts. This can be helpful for debugging. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--cmd/acpi.c15
-rw-r--r--drivers/core/acpi.c16
-rw-r--r--include/dm/acpi.h16
-rw-r--r--test/dm/acpi.c39
4 files changed, 84 insertions, 2 deletions
diff --git a/cmd/acpi.c b/cmd/acpi.c
index e9a9161..085a3a6 100644
--- a/cmd/acpi.c
+++ b/cmd/acpi.c
@@ -153,6 +153,17 @@ static int do_acpi_list(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static int do_acpi_items(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ bool dump_contents;
+
+ dump_contents = argc >= 2 && !strcmp("-d", argv[1]);
+ acpi_dump_items(dump_contents ? ACPI_DUMP_CONTENTS : ACPI_DUMP_LIST);
+
+ return 0;
+}
+
static int do_acpi_dump(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -160,8 +171,6 @@ static int do_acpi_dump(struct cmd_tbl *cmdtp, int flag, int argc,
char sig[ACPI_NAME_LEN];
int ret;
- if (argc < 2)
- return CMD_RET_USAGE;
name = argv[1];
if (strlen(name) != ACPI_NAME_LEN) {
printf("Table name '%s' must be four characters\n", name);
@@ -179,8 +188,10 @@ static int do_acpi_dump(struct cmd_tbl *cmdtp, int flag, int argc,
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";
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(dump, 2, 1, do_acpi_dump));
diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index 076fb4f..b566f4f 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -119,6 +119,22 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev,
return 0;
}
+void acpi_dump_items(enum acpi_dump_option option)
+{
+ int i;
+
+ for (i = 0; i < item_count; i++) {
+ struct acpi_item *item = &acpi_item[i];
+
+ printf("dev '%s', type %d, size %x\n", item->dev->name,
+ item->type, item->size);
+ if (option == ACPI_DUMP_CONTENTS) {
+ print_buffer(0, item->buf, 1, item->size, 0);
+ printf("\n");
+ }
+ }
+}
+
static struct acpi_item *find_acpi_item(const char *devname)
{
int i;
diff --git a/include/dm/acpi.h b/include/dm/acpi.h
index fceb1ae..aa1071a 100644
--- a/include/dm/acpi.h
+++ b/include/dm/acpi.h
@@ -27,6 +27,12 @@
#if !defined(__ACPI__)
+/** enum acpi_dump_option - selects what ACPI information to dump */
+enum acpi_dump_option {
+ ACPI_DUMP_LIST, /* Just the list of items */
+ ACPI_DUMP_CONTENTS, /* Include the binary contents also */
+};
+
/**
* struct acpi_ctx - Context used for writing ACPI tables
*
@@ -171,6 +177,16 @@ int acpi_fill_ssdt(struct acpi_ctx *ctx);
*/
int acpi_inject_dsdt(struct acpi_ctx *ctx);
+/**
+ * acpi_dump_items() - Dump out the collected ACPI items
+ *
+ * This lists the ACPI DSDT and SSDT items generated by the various U-Boot
+ * drivers.
+ *
+ * @option: Sets what should be dumpyed
+ */
+void acpi_dump_items(enum acpi_dump_option option);
+
#endif /* __ACPI__ */
#endif
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index 69ca090..7768f95 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -525,3 +525,42 @@ static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test 'acpi items' command */
+static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
+{
+ struct acpi_ctx ctx;
+ void *buf;
+
+ buf = malloc(BUF_SIZE);
+ ut_assertnonnull(buf);
+
+ ctx.current = buf;
+ ut_assertok(acpi_fill_ssdt(&ctx));
+ console_record_reset();
+ run_command("acpi items", 0);
+ ut_assert_nextline("dev 'acpi-test', type 1, size 2");
+ ut_assert_nextline("dev 'acpi-test2', type 1, size 2");
+ ut_assert_console_end();
+
+ ctx.current = buf;
+ ut_assertok(acpi_inject_dsdt(&ctx));
+ console_record_reset();
+ run_command("acpi items", 0);
+ ut_assert_nextline("dev 'acpi-test', type 2, size 2");
+ ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
+ ut_assert_console_end();
+
+ console_record_reset();
+ run_command("acpi items -d", 0);
+ ut_assert_nextline("dev 'acpi-test', type 2, size 2");
+ ut_assert_nextlines_are_dump(2);
+ ut_assert_nextline("%s", "");
+ ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
+ ut_assert_nextlines_are_dump(2);
+ ut_assert_nextline("%s", "");
+ ut_assert_console_end();
+
+ return 0;
+}
+DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);