[PATCH 31/40] acpi: Tidy up the item list

Simon Glass sjg at chromium.org
Wed Dec 1 17:03:05 CET 2021


At present this is really just a debugging aid, but it is a bit untidy.
Add proper columns and display the type name instead of a number.

Sample output for coral:

   => acpi items
   Seq  Type       Addr  Size  Device/Writer
   ---  -----  --------  ----  -------------
     0  other  79925000    240  0base
     1  other  79925240     40  1facs
     2  dsdt   799252a4     58  board
     3  dsdt   799252fc     10  lpc
     4  other  79925280   32f0  3dsdt
     5  other  79928570   1000  4gnvs
     6  other  79929570    100  5fact
     7  other  79929670     30  5mcfg
     8  other  799296a0     50  5spcr
     9  other  799296f0     50  5tpm2
     a  other  79929740     70  5x86
     b  ssdt   799297d4     fe  maxim-codec
     c  ssdt   799298d2     28  i2c2 at 16,0
     d  ssdt   799298fa    270  da-codec
     e  ssdt   79929b6a     28  i2c2 at 16,1
     f  ssdt   79929b92     28  i2c2 at 16,2
    10  ssdt   79929bba     83  tpm at 50
    11  ssdt   79929c3d     28  i2c2 at 16,3
    12  ssdt   79929c65    282  elan-touchscreen at 10
    13  ssdt   79929ee7    285  raydium-touchscreen at 39
    14  ssdt   7992a16c     28  i2c2 at 17,0
    15  ssdt   7992a194     d8  elan-touchpad at 15
    16  ssdt   7992a26c    163  synaptics-touchpad at 2c
    17  ssdt   7992a3cf     28  i2c2 at 17,1
    18  ssdt   7992a3f7    111  wacom-digitizer at 9
    19  ssdt   7992a508     8f  sdmmc at 1b,0
    1a  ssdt   7992a597     4b  wifi
    1b  ssdt   7992a5e2    1a0  cpu at 0
    1c  ssdt   7992a782    1a0  cpu at 1
    1d  ssdt   7992a922    1a0  cpu at 2
    1e  ssdt   7992aac2    211  cpu at 3
    1f  other  799297b0   1530  6ssdt
    20  other  7992ace0   2f10  8dev

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/core/acpi.c | 24 ++++++++++++++++++++----
 test/dm/acpi.c      | 20 ++++++++++++++------
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
index bb186444dd3..7a0653ddb0a 100644
--- a/drivers/core/acpi.c
+++ b/drivers/core/acpi.c
@@ -12,6 +12,7 @@
 #include <dm.h>
 #include <log.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <acpi/acpi_device.h>
 #include <dm/acpi.h>
 #include <dm/device-internal.h>
@@ -34,6 +35,13 @@ enum gen_type_t {
 	TYPE_OTHER,
 };
 
+const char *gen_type_str[] = {
+	"-",
+	"ssdt",
+	"dsdt",
+	"other",
+};
+
 /* Type of method to call */
 enum method_t {
 	METHOD_WRITE_TABLES,
@@ -51,13 +59,15 @@ typedef int (*acpi_method)(const struct udevice *dev, struct acpi_ctx *ctx);
  * @dev: Device that generated this data
  * @type: Table type it refers to
  * @writer: Writer that wrote this table
- * @buf: Buffer containing the data
+ * @base: Pointer to base of table in its original location
+ * @buf: Buffer allocated to contain the data (NULL if not allocated)
  * @size: Size of the data in bytes
  */
 struct acpi_item {
 	struct udevice *dev;
 	const struct acpi_writer *writer;
 	enum gen_type_t type;
+	const char *base;
 	char *buf;
 	int size;
 };
@@ -139,6 +149,7 @@ static int add_item(struct acpi_ctx *ctx, struct udevice *dev,
 	item->writer = writer;
 	item->type = type;
 	item->size = end - start;
+	item->base = start;
 	if (!item->size)
 		return 0;
 	if (type != TYPE_OTHER) {
@@ -164,13 +175,18 @@ void acpi_dump_items(enum acpi_dump_option option)
 {
 	int i;
 
+	printf("Seq  Type       Base   Size  Device/Writer\n");
+	printf("---  -----  --------   ----  -------------\n");
 	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);
+		printf("%3x  %-5s  %8lx  %5x  %s\n", i,
+		       gen_type_str[item->type],
+		       (ulong)map_to_sysmem(item->base), item->size,
+		       item->dev ? item->dev->name : item->writer->name);
 		if (option == ACPI_DUMP_CONTENTS) {
-			print_buffer(0, item->buf, 1, item->size, 0);
+			print_buffer(0, item->buf ? item->buf : item->base, 1,
+				     item->size, 0);
 			printf("\n");
 		}
 	}
diff --git a/test/dm/acpi.c b/test/dm/acpi.c
index da728692528..d648f3003a3 100644
--- a/test/dm/acpi.c
+++ b/test/dm/acpi.c
@@ -566,18 +566,22 @@ DM_TEST(dm_test_acpi_inject_dsdt, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
 {
 	struct acpi_ctx ctx;
+	ulong addr;
 	void *buf;
 
 	buf = malloc(BUF_SIZE);
 	ut_assertnonnull(buf);
+	addr = map_to_sysmem(buf);
 
 	acpi_reset_items();
 	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_nextline("Seq  Type       Base   Size  Device/Writer");
+	ut_assert_nextline("---  -----  --------   ----  -------------");
+	ut_assert_nextline("  0  ssdt   %8lx      2  acpi-test", addr);
+	ut_assert_nextline("  1  ssdt   %8lx      2  acpi-test2", addr + 2);
 	ut_assert_console_end();
 
 	acpi_reset_items();
@@ -585,16 +589,20 @@ static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
 	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_nextlinen("Seq");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  0  dsdt   %8lx      2  acpi-test", addr);
+	ut_assert_nextline("  1  dsdt   %8lx      2  acpi-test2", addr + 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_nextlinen("Seq");
+	ut_assert_nextlinen("---");
+	ut_assert_nextline("  0  dsdt   %8lx      2  acpi-test", addr);
 	ut_assert_nextlines_are_dump(2);
 	ut_assert_nextline("%s", "");
-	ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
+	ut_assert_nextline("  1  dsdt   %8lx      2  acpi-test2", addr + 2);
 	ut_assert_nextlines_are_dump(2);
 	ut_assert_nextline("%s", "");
 	ut_assert_console_end();
-- 
2.34.0.rc2.393.gf8c9666880-goog



More information about the U-Boot mailing list