From nobody Tue Oct 15 11:14:02 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XSWgv0l18z5YmLp; Tue, 15 Oct 2024 11:14:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XSWgt5YPzz4ZGW; Tue, 15 Oct 2024 11:14:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GudyjN4Nl4y1OMNWn+34q59SQ3jzrKI+qBBZAQnMrsI=; b=TUm6AvPtEudqvjQOnVQGzYgf76d1a26jyWWYCJbzBDdB3ZJjBUxgnKZ+2emkBYrn2854Kv KbwTPGFsfWAfGD0u8qoo+3SiITpLAUSOMZ8iof0kN8TicqhRgxflW5FxgueeLkoZovgEMm kY9iEeDqKfPTt5kk6fbZhXqCYqzpKPnfWiEjW7UCyc34LqJ3tQ92jylrrI/wlos7Ah7Tdv /g260dZl4yCFJ9kYUxvw2l7MOebdxhJfcIGcH2EFnJHi0qbDBcHLKge6rHeLkruIoT2mBs OWwx9u6wcZAx+i6exHw+yVar9Ch645qkKxljYPtCJ60lqBrdDi1hXZKwgb/CWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GudyjN4Nl4y1OMNWn+34q59SQ3jzrKI+qBBZAQnMrsI=; b=vK001Ry6oxSza+fSJY6JKtIarln/XvkGSMXyYcVl9oS1VkbeRsusK/TVqUTOKj03qozFe1 kgGoyLeC6viUFXZnGUvUZBLdmuD/xVOsQ+8jQ6qx2J03jyidlKEbGtgtguY75Z3E0hV2zY k6Rq3KfdvQHkE6LulVtbC7ukEx/0GYvzqw9Ng+qqOhARTmhV6VtW0VRrgcyuJrmn/fYQPD wScESdumsnXuiZo/Bwkn1FmeBaXrtqkG7ZYSiKYCivhl6bnREgGWd4w71UtMssYusqLzIP nvEL+VLPucE2OeKlBVv7IBrVPKF0t0xNVlJwHevKmmlbgicdXjBG3hHKW5vtzQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728990842; a=rsa-sha256; cv=none; b=lZliXUChL02gqG8DOUdA+ZVVjFP5AMJl8b480FkyCbn+wYgr5COpmuwYaIe6OlJ2ZVZhOm OilSpokPGIvIvN1aPmbC/z4pmbPFm3XiWtKI9w83NjE88iSXy3YKyjIKKOQHK9TdaSKzES t6vTLkU4YoqdvFbvbIVcBTTc77ziimGSgACmiNq/XsVa2n+OKy1e/jA8kZJkOJxjmdfg1g GU9BYPju6lfyH5epDtIEvpEAasQ4kffbwYsBxYw9q5GNIAKKXlzv3Cfef1EgRANl8wJXMd tFxwfJzOxUmBNEFL8N989GbiGS28vNnWjyeZq/e2OSJ0UYMZVNSHAOslEx/o/g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XSWgt59FLzKc2; Tue, 15 Oct 2024 11:14:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49FBE2BM097945; Tue, 15 Oct 2024 11:14:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FBE2Kh097942; Tue, 15 Oct 2024 11:14:02 GMT (envelope-from git) Date: Tue, 15 Oct 2024 11:14:02 GMT Message-Id: <202410151114.49FBE2Kh097942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 3ff9ea7dc2c5 - main - acpidump: Add -T TBLN to print a specific ACPI fixed table List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ff9ea7dc2c52fcb67b7f6234cd351c3e2fbfafd Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3ff9ea7dc2c52fcb67b7f6234cd351c3e2fbfafd commit 3ff9ea7dc2c52fcb67b7f6234cd351c3e2fbfafd Author: Warner Losh AuthorDate: 2024-10-15 11:10:06 +0000 Commit: Warner Losh 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 *);