From nobody Tue Oct 15 11:14:01 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 4XSWgs73kvz5YmLn; Tue, 15 Oct 2024 11:14:01 +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 4XSWgs4DqZz4ZNq; Tue, 15 Oct 2024 11:14:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990841; 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=1FbnzCB/ibdm91fFEk+vlkkhfEgYe47NICGrwhLuzW4=; b=Xu0ad1gm0u7NnL8px1Mqe3RTQvOeK+N6UZOVSf/v2DP3u+c/M7epn84hk/usRj3a6iUr/z 0BMfqUcw0Im4KPB4Qp7HqNGntZilsD8ksPN20A0mF8Z9wkMVF/o6JVHibmcSkuxi4ZWNhT PWH3bSLHGRWetLSqmZ8o3MxCbtVNFZFWeE315VcGIaYGkwZkENn66qF94sNGsjZIP8CRjQ x5M8EAD6RMc1PzG+on3PLdzJLjO6FDXXXRu9nRpYvZoWm7Tg+uMZ385xvmy+k6W0EmoXLN qNIf1f+SjnapiiPGv0dCagFpC6ssb6eTH/w1ANXF7/h123BPADZMtQFFm+hftQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990841; 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=1FbnzCB/ibdm91fFEk+vlkkhfEgYe47NICGrwhLuzW4=; b=Jw4xakmoxJWPoPPvCmaNtdj75fAJY50tRvJOGafUjL1RncY5yqnZ2OU67/1UDCdHaVhbFH UYdUjpob2upsyqnF07Lb0pGBAFFLHF/a4BuZnsip94zB7zjwXeXrrEVNfABNPG9rtbki25 jgHQ84OT7ACe29zU6lb2huCkNiRszbAjdSFZEGkO0Ll/kg5yqSRZfH93sSbZLW1enmDuAN 5vl7SVKMbeHI/BB5zBISpV3zgG3TDXAm4+XT3y5HSO0TbKD2WvPyxH53Bzon6SDyGdRXcw yAqffYGioqtGhon/9pePpAaTuI7QFa0pJXvksySLM0jJWnOTQiuCc2bScBkHnQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728990841; a=rsa-sha256; cv=none; b=NAqYtQodY44ORIBvPEMbdqW++r8jKb0iFV0vQzP8oA9dcgcjRBLYhPDZHUngXD3i+HPVYQ Jl0MFWL0Gw0lcwKRAbmEorpW6gon8//81BdHcD5vqApT2oDE56thbXcm4cUZAUQdEMF6kJ 9R5MErFeDhFYwfvhndGNrHDVDtG5GyBoiUniJD34j8tNUQopWhDnZS0eVwMnqKbieztynq mqieNO9lnHwvarbXtHh0mx9gMGkSIrioeVXtQVEf0MqOIaZEsjxL4yxkNsK7G5l2z4OUkS BmXZPdWuTpg0UQkVM8nN4P2bTewwB8YcBqqa/9ck9BYoFXVCWKJ1BP1zIw3DJg== 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 4XSWgs3q7fzKWM; Tue, 15 Oct 2024 11:14:01 +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 49FBE1tX097885; Tue, 15 Oct 2024 11:14:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FBE1s1097882; Tue, 15 Oct 2024 11:14:01 GMT (envelope-from git) Date: Tue, 15 Oct 2024 11:14:01 GMT Message-Id: <202410151114.49FBE1s1097882@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: e9ab827df94f - main - acpidump: Sort signature ifs alphabetically and make table driven 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: e9ab827df94fed8f129ca4f7756e23ce77d8a655 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e9ab827df94fed8f129ca4f7756e23ce77d8a655 commit e9ab827df94fed8f129ca4f7756e23ce77d8a655 Author: Warner Losh AuthorDate: 2024-10-15 11:09:45 +0000 Commit: Warner Losh CommitDate: 2024-10-15 11:09:45 +0000 acpidump: Sort signature ifs alphabetically and make table driven Sort the ACPI signatures alphabetically and move it into a table we can iterate through Sponsored by: Netflix Reviewed by: andrew, markj Differential Revision: https://reviews.freebsd.org/D47081 --- usr.sbin/acpi/acpidump/acpi.c | 87 ++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index 746db4a5583c..04097e7a5318 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -2545,6 +2545,49 @@ acpi_print_rsd_ptr(ACPI_TABLE_RSDP *rp) printf(END_COMMENT); } +static struct { + const char *sig; + void (*fnp)(ACPI_TABLE_HEADER *); +} known[] = { + { ACPI_SIG_BERT, acpi_handle_bert }, + { ACPI_SIG_DMAR, acpi_handle_dmar }, + { ACPI_SIG_ECDT, acpi_handle_ecdt }, + { ACPI_SIG_EINJ, acpi_handle_einj }, + { ACPI_SIG_ERST, acpi_handle_erst }, + { ACPI_SIG_FADT, acpi_handle_fadt }, + { ACPI_SIG_HEST, acpi_handle_hest }, + { ACPI_SIG_HPET, acpi_handle_hpet }, + { ACPI_SIG_IVRS, acpi_handle_ivrs }, + { ACPI_SIG_LPIT, acpi_handle_lpit }, + { ACPI_SIG_MADT, acpi_handle_madt }, + { ACPI_SIG_MCFG, acpi_handle_mcfg }, + { ACPI_SIG_NFIT, acpi_handle_nfit }, + { ACPI_SIG_SLIT, acpi_handle_slit }, + { ACPI_SIG_SPCR, acpi_handle_spcr }, + { ACPI_SIG_SRAT, acpi_handle_srat }, + { ACPI_SIG_TCPA, acpi_handle_tcpa }, + { ACPI_SIG_TPM2, acpi_handle_tpm2 }, + { ACPI_SIG_WDDT, acpi_handle_wddt }, +}; + +static void +acpi_report_sdp(ACPI_TABLE_HEADER *sdp) +{ + for (u_int i = 0; i < nitems(known); i++) { + if (memcmp(sdp->Signature, known[i].sig, ACPI_NAMESEG_SIZE) != 0) { + known[i].fnp(sdp); + return; + } + } + + /* + * Otherwise, do a generic thing. + */ + printf(BEGIN_COMMENT); + acpi_print_sdt(sdp); + printf(END_COMMENT); +} + static void acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) { @@ -2571,49 +2614,7 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) sdp->Signature); continue; } - if (!memcmp(sdp->Signature, ACPI_SIG_BERT, 4)) - acpi_handle_bert(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_MADT, 4)) - acpi_handle_madt(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_ECDT, 4)) - acpi_handle_ecdt(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_MCFG, 4)) - acpi_handle_mcfg(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_SLIT, 4)) - acpi_handle_slit(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_DMAR, 4)) - acpi_handle_dmar(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_IVRS, 4)) - acpi_handle_ivrs(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_NFIT, 4)) - acpi_handle_nfit(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_WDDT, 4)) - acpi_handle_wddt(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_LPIT, 4)) - acpi_handle_lpit(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4)) - acpi_handle_tpm2(sdp); - else if (!memcmp(sdp->Signature, ACPI_SIG_SPCR, 4)) - acpi_handle_spcr(sdp); - else { - printf(BEGIN_COMMENT); - acpi_print_sdt(sdp); - printf(END_COMMENT); - } + acpi_report_sdp(sdp); } }