diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -87,7 +87,7 @@ 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, @@ -2545,8 +2545,59 @@ printf(END_COMMENT); } + +static void +acpi_report_sdp(ACPI_TABLE_HEADER *sdp, const char *tbl) +{ + if (tbl != NULL && memcmp(sdp->Signature, tbl, 4) != 0) + return; + if (!memcmp(sdp->Signature, ACPI_SIG_BERT, 4)) + acpi_handle_bert(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4)) + acpi_handle_dmar(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_ECDT, 4)) + acpi_handle_ecdt(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_EINJ, 4)) + acpi_handle_einj(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_ERST, 4)) + acpi_handle_erst(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_FADT, 4)) + acpi_handle_fadt(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_HEST, 4)) + acpi_handle_hest(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_HPET, 4)) + acpi_handle_hpet(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_IVRS, 4)) + acpi_handle_ivrs(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_LPIT, 4)) + acpi_handle_lpit(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_MADT, 4)) + acpi_handle_madt(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_MCFG, 4)) + acpi_handle_mcfg(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) + acpi_handle_nfit(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_SLIT, 4)) + acpi_handle_slit(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_SPCR, 4)) + acpi_handle_spcr(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_SRAT, 4)) + acpi_handle_srat(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_TCPA, 4)) + acpi_handle_tcpa(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4)) + acpi_handle_tpm2(sdp); + else if (!memcmp(sdp->Signature, ACPI_SIG_WDDT, 4)) + acpi_handle_wddt(sdp); + else { + printf(BEGIN_COMMENT); + acpi_print_sdt(sdp); + printf(END_COMMENT); + } +} + 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; @@ -2554,7 +2605,14 @@ vm_offset_t addr; int entries, i; - acpi_print_rsdt(rsdp); + if (tbl == NULL) { + acpi_print_rsdt(rsdp); + } else { + if (memcmp(tbl, rsdp->Signature, 4) == 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; @@ -2571,49 +2629,7 @@ sdp->Signature); continue; } - if (!memcmp(sdp->Signature, ACPI_SIG_BERT, 4)) - acpi_handle_bert(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_DMAR, 4)) - acpi_handle_dmar(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_ECDT, 4)) - acpi_handle_ecdt(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_EINJ, 4)) - acpi_handle_einj(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_ERST, 4)) - acpi_handle_erst(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_FADT, 4)) - acpi_handle_fadt(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_HEST, 4)) - acpi_handle_hest(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_HPET, 4)) - acpi_handle_hpet(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_IVRS, 4)) - acpi_handle_ivrs(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_LPIT, 4)) - acpi_handle_lpit(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_MADT, 4)) - acpi_handle_madt(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_MCFG, 4)) - acpi_handle_mcfg(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) - acpi_handle_nfit(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_SLIT, 4)) - acpi_handle_slit(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_SPCR, 4)) - acpi_handle_spcr(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_SRAT, 4)) - acpi_handle_srat(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_TCPA, 4)) - acpi_handle_tcpa(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4)) - acpi_handle_tpm2(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_WDDT, 4)) - acpi_handle_wddt(sdp); - else { - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - printf(END_COMMENT); - } + acpi_report_sdp(sdp, tbl); } } @@ -2801,9 +2817,9 @@ } 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.h b/usr.sbin/acpi/acpidump/acpidump.h --- a/usr.sbin/acpi/acpidump/acpidump.h +++ b/usr.sbin/acpi/acpidump/acpidump.h @@ -140,7 +140,7 @@ 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 *); diff --git a/usr.sbin/acpi/acpidump/acpidump.8 b/usr.sbin/acpi/acpidump/acpidump.8 --- 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 @@ -174,6 +175,9 @@ 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 --- a/usr.sbin/acpi/acpidump/acpidump.c +++ b/usr.sbin/acpi/acpidump/acpidump.c @@ -45,7 +45,7 @@ { 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 @@ 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 @@ 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 @@ } /* 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 */