git: 3ff9ea7dc2c5 - main - acpidump: Add -T TBLN to print a specific ACPI fixed table
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Oct 2024 11:14:02 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3ff9ea7dc2c52fcb67b7f6234cd351c3e2fbfafd commit 3ff9ea7dc2c52fcb67b7f6234cd351c3e2fbfafd Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-10-15 11:10:06 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-10-15 11:10:06 +0000 acpidump: Add -T TBLN to print a specific ACPI fixed table Add the ability to dump a specific ACPI table rather than all of them. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D47082 --- usr.sbin/acpi/acpidump/acpi.c | 21 +++++++++++++++------ usr.sbin/acpi/acpidump/acpidump.8 | 4 ++++ usr.sbin/acpi/acpidump/acpidump.c | 16 ++++++++++++---- usr.sbin/acpi/acpidump/acpidump.h | 2 +- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 04097e7a5318..18a0ae486387 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -87,7 +87,7 @@ static void acpi_print_facs(ACPI_TABLE_FACS *facs); static void acpi_print_dsdt(ACPI_TABLE_HEADER *dsdp); static ACPI_TABLE_HEADER *acpi_map_sdt(vm_offset_t pa); static void acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp); -static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp); +static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp, const char *elm); static void acpi_walk_subtables(ACPI_TABLE_HEADER *table, void *first, void (*action)(ACPI_SUBTABLE_HEADER *)); static void acpi_walk_nfit(ACPI_TABLE_HEADER *table, void *first, @@ -275,7 +275,7 @@ acpi_handle_fadt(ACPI_TABLE_HEADER *sdp) if (addr != 0) { facs = (ACPI_TABLE_FACS *)acpi_map_sdt(addr); - if (memcmp(facs->Signature, ACPI_SIG_FACS, 4) != 0 || + if (memcmp(facs->Signature, ACPI_SIG_FACS, ACPI_NAMESEG_SIZE) != 0 || facs->Length < 64) errx(1, "FACS is corrupt"); acpi_print_facs(facs); @@ -2589,7 +2589,7 @@ acpi_report_sdp(ACPI_TABLE_HEADER *sdp) } static void -acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) +acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp, const char *tbl) { ACPI_TABLE_HEADER *sdp; ACPI_TABLE_RSDT *rsdt; @@ -2597,7 +2597,14 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) vm_offset_t addr; int entries, i; - acpi_print_rsdt(rsdp); + if (tbl == NULL) { + acpi_print_rsdt(rsdp); + } else { + if (memcmp(tbl, rsdp->Signature, ACPI_NAMESEG_SIZE) == 0) { + acpi_print_rsdt(rsdp); + return; + } + } rsdt = (ACPI_TABLE_RSDT *)rsdp; xsdt = (ACPI_TABLE_XSDT *)rsdp; entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; @@ -2614,6 +2621,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) sdp->Signature); continue; } + if (tbl != NULL && memcmp(sdp->Signature, tbl, ACPI_NAMESEG_SIZE) != 0) + continue; acpi_report_sdp(sdp); } } @@ -2802,9 +2811,9 @@ aml_disassemble_separate(ACPI_TABLE_HEADER *rsdt, ACPI_TABLE_HEADER *dsdp) } void -sdt_print_all(ACPI_TABLE_HEADER *rsdp) +sdt_print_all(ACPI_TABLE_HEADER *rsdp, const char *tbl) { - acpi_handle_rsdt(rsdp); + acpi_handle_rsdt(rsdp, tbl); } /* Fetch a table matching the given signature via the RSDT. */ diff --git a/usr.sbin/acpi/acpidump/acpidump.8 b/usr.sbin/acpi/acpidump/acpidump.8 index 98e0a4d9f524..70a53b479fc4 100644 --- a/usr.sbin/acpi/acpidump/acpidump.8 +++ b/usr.sbin/acpi/acpidump/acpidump.8 @@ -40,6 +40,7 @@ .Op Fl h .Op Fl o Ar dsdt_output .Op Fl t +.Op Fl T Ar table_name .Op Fl v .Sh DESCRIPTION The @@ -175,6 +176,9 @@ Concatenate the DSDT and the SSDT's into single image and disassemble the image and print the results to stdout. .It Fl t Dump the contents of the various fixed tables listed above. +.It Fl T ar table_name +Dump the contents of the specific table. +All ACPI tables are exactly 4 characters long. .It Fl h Displays usage and exit. .It Fl s diff --git a/usr.sbin/acpi/acpidump/acpidump.c b/usr.sbin/acpi/acpidump/acpidump.c index 0fad7e68ef47..477b56958d1f 100644 --- a/usr.sbin/acpi/acpidump/acpidump.c +++ b/usr.sbin/acpi/acpidump/acpidump.c @@ -45,7 +45,7 @@ usage(const char *progname) { fprintf(stderr, "usage: %s [-d] [-t] [-h] [-v] [-f dsdt_input] " - "[-o dsdt_output]\n", progname); + "[-o dsdt_output] [-T table_name]\n", progname); fprintf(stderr, "To send ASL:\n\t%s -dt | gzip -c9 > foo.asl.gz\n", progname); exit(1); @@ -58,6 +58,7 @@ main(int argc, char *argv[]) int c; char *progname; char *dsdt_input_file, *dsdt_output_file; + char *tbl = NULL; dsdt_input_file = dsdt_output_file = NULL; progname = argv[0]; @@ -65,11 +66,18 @@ main(int argc, char *argv[]) if (argc < 2) usage(progname); - while ((c = getopt(argc, argv, "dhtvsf:o:")) != -1) { + while ((c = getopt(argc, argv, "df:ho:tT:vs")) != -1) { switch (c) { case 'd': dflag = 1; break; + case 'T': + tbl = optarg; + if (strlen(tbl) != 4) { + warnx("Illegal table name %s", tbl); + usage(progname); + } + break; case 't': tflag = 1; break; @@ -113,10 +121,10 @@ main(int argc, char *argv[]) } /* Display misc. SDT tables (only available when using /dev/mem) */ - if (tflag) { + if (tflag || tbl != NULL) { if (vflag) warnx("printing various SDT tables"); - sdt_print_all(rsdt); + sdt_print_all(rsdt, tbl); } /* Translate RSDT to DSDT pointer */ diff --git a/usr.sbin/acpi/acpidump/acpidump.h b/usr.sbin/acpi/acpidump/acpidump.h index 872facbad59d..8755a96dd8af 100644 --- a/usr.sbin/acpi/acpidump/acpidump.h +++ b/usr.sbin/acpi/acpidump/acpidump.h @@ -140,7 +140,7 @@ ACPI_TABLE_HEADER *dsdt_load_file(char *); void dsdt_save_file(char *, ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *); /* Print out as many fixed tables as possible, given the RSD PTR */ -void sdt_print_all(ACPI_TABLE_HEADER *); +void sdt_print_all(ACPI_TABLE_HEADER *, const char *); /* Disassemble the AML in the DSDT */ void aml_disassemble(ACPI_TABLE_HEADER *, ACPI_TABLE_HEADER *);