From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.46]) by mx.groups.io with SMTP id smtpd.web12.1802.1574673609924026519 for ; Mon, 25 Nov 2019 01:20:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=mtbpNkIb; spf=pass (domain: arm.com, ip: 40.107.6.46, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WirprBVnUJmuZ9jUOmnqyJJ4AodXsehv36XsSmiXza4=; b=mtbpNkIbctxrhPzxC6SdvED1SHjWAhnRhAVd6/PCiWRjUFQd+OL35mB39/6dufzYv6Z49dDbXVrwwDZ4GaIyLYFPfUYA0fQHbzX7EP7W6WixvpqfzBOq8jxW58rc86iZwzHVOwiTnjVr1p8KJ2w89sXMdB8TnZrMx+IjJ1667DI= Received: from HE1PR0802CA0006.eurprd08.prod.outlook.com (2603:10a6:3:bd::16) by VI1PR0802MB2224.eurprd08.prod.outlook.com (2603:10a6:800:9f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.16; Mon, 25 Nov 2019 09:20:07 +0000 Received: from DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::202) by HE1PR0802CA0006.outlook.office365.com (2603:10a6:3:bd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17 via Frontend Transport; Mon, 25 Nov 2019 09:20:07 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT026.mail.protection.outlook.com (10.152.20.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.17 via Frontend Transport; Mon, 25 Nov 2019 09:20:07 +0000 Received: ("Tessian outbound a8f166c1f585:v33"); Mon, 25 Nov 2019 09:20:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cc5075eafa4325e8 X-CR-MTA-TID: 64aa7808 Received: from ecfebdb50403.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.10.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 04915435-23AE-4326-9D86-C82EE18AA654.1; Mon, 25 Nov 2019 09:20:01 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2058.outbound.protection.outlook.com [104.47.10.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ecfebdb50403.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 25 Nov 2019 09:20:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j64DZX+I0BNMzmi1jROKM1FEpDmwFjieKh90e2jBEI8W3TLAPkvaft6PgqQqthFpcoeGFbhXbJ5Z6iVKBLAmonRuVp7VtYh8zuf14QJczliv8xel0Oc/iMSk2CinrivJdUKZ5j3e5w6h0XPx2d64A7vr4LxMz7/NNFwd4R2FYNxYwbWx+agPj0KaZvxi/Z+y/T9AZHyOCblXdVzUqgGJzbf3o63pW7ktgfpjTRIt+QRUYbSdpCTNduCu362ywsB66Hrn5oP4wDf7aVNt5Vt+47zNTkTqcC1//ARTKvjU02osmxs3j0DTpA/H+r/1WDuYKf1Sd0RyAmY/DU+UCtpnsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WirprBVnUJmuZ9jUOmnqyJJ4AodXsehv36XsSmiXza4=; b=lIRpaO5zBZKTeMQCLxq80NyebQu/SNLobloVsmMAm2Gosd6lLLvCTWpaILtakxWQStkwy9wkUXv1BnjrlT1PacUVEh/bHLJi7RQ7NBRu4kFzvg9tFZ3W4fifXZ1b/QsbMKS8tF+CqPDom/cDmmHcson9Nd/ygBDnFnVGryYf3t6XU2yPp72hbqFy3vRoY9bggAs9ebiKkAg/1TXrp1ajF3pY/6exIxhPqTBvmjQDP+H+bJWBy3xmLHyDpyTVnDOp6Juqsr839pL1RtvfS2vtW6o++61LIhPFkMhNBlN+/1BCclKveWnMsG9ecn8UDkuVrDup7iuoc1Q+5UXLdv1KFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WirprBVnUJmuZ9jUOmnqyJJ4AodXsehv36XsSmiXza4=; b=mtbpNkIbctxrhPzxC6SdvED1SHjWAhnRhAVd6/PCiWRjUFQd+OL35mB39/6dufzYv6Z49dDbXVrwwDZ4GaIyLYFPfUYA0fQHbzX7EP7W6WixvpqfzBOq8jxW58rc86iZwzHVOwiTnjVr1p8KJ2w89sXMdB8TnZrMx+IjJ1667DI= Received: from HE1PR0802CA0018.eurprd08.prod.outlook.com (2603:10a6:3:bd::28) by AM6PR08MB4897.eurprd08.prod.outlook.com (2603:10a6:20b:c2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.16; Mon, 25 Nov 2019 09:20:00 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::205) by HE1PR0802CA0018.outlook.office365.com (2603:10a6:3:bd::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2474.16 via Frontend Transport; Mon, 25 Nov 2019 09:20:00 +0000 Authentication-Results-Original: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2474.17 via Frontend Transport; Mon, 25 Nov 2019 09:19:59 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Mon, 25 Nov 2019 09:19:55 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Mon, 25 Nov 2019 09:19:54 +0000 Received: from E114225.Arm.com (10.1.195.19) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 25 Nov 2019 09:19:54 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , Subject: [PATCH v2 1/1] ShellPkg: acpiview: Add support for parsing FACS Date: Mon, 25 Nov 2019 09:19:47 +0000 Message-ID: <20191125091947.14360-1-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(396003)(346002)(136003)(376002)(189003)(199004)(2616005)(16586007)(8936002)(70586007)(70206006)(81156014)(81166006)(50226002)(19627235002)(5660300002)(2906002)(50466002)(2351001)(316002)(14444005)(47776003)(54906003)(1076003)(426003)(36756003)(305945005)(336012)(106002)(478600001)(30864003)(966005)(26005)(8676002)(6916009)(6306002)(4326008)(356004)(6666004)(48376002)(53416004)(44832011)(51416003)(7696005)(186003)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR08MB4897;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 129f4b0f-6f26-4a66-2652-08d77188a9c0 X-MS-TrafficTypeDiagnostic: AM6PR08MB4897:|VI1PR0802MB2224: X-MS-Exchange-PUrlCount: 1 X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:270;OLM:270; X-Forefront-PRVS: 0232B30BBC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dJhkl0W+IUT7izZ/YPKE7llPALuTej+5Z9EM1q01USJKY/P2Ifi27+OkkaPtifR2LQ1lDsGuFvvrZApVg0Af6rGI8BnHhQZfxzaD7Ia4oX8zF0X2PRtRS9nqxFZZ8jw8oXSg0mH5bTj8GGRSyQ/doQ1UjNXzgrMi7lBTkwmphXgxpzfbCBNtUjoy9t7W+AQSmYSVcDi4QGxUBV+nz2XaGsW0IY0RNOSkSKz7H1p6VY7zGfG1/h+18BgfxAKj0dVPxvD4zM25oOYkUcijStuPK5wPwOEOqH+zJ4ZZSvAyLQ9cS378zwtNEdrG2pxKWtg6uQdVOm0dUmpjFepwMluEmFD3Hz+ttmT1rECIIjcO5PdBc8L9nFTKIoUoSSbXA5Y3FM5rjd7/PjAAfP9bKgqnLlFdZM5wIabU6Z/8RzvCNiGYviDMCfUil9pptKkh3gij0ARqszUcolmy+aEpSlYX2MDt3YGBdW4BzlJtZUUh7Ek= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4897 Original-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT026.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(136003)(39860400002)(396003)(346002)(376002)(189003)(199004)(2616005)(16586007)(70586007)(70206006)(81156014)(81166006)(50226002)(8936002)(22756006)(19627235002)(5660300002)(50466002)(2906002)(2351001)(316002)(14444005)(54906003)(26005)(8676002)(1076003)(36756003)(426003)(47776003)(336012)(106002)(478600001)(26826003)(30864003)(966005)(6916009)(6306002)(6666004)(4326008)(76130400001)(48376002)(53416004)(305945005)(186003)(44832011)(51416003)(7696005)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0802MB2224;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Pass;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: b123bd48-0c12-445d-04f7-08d77188a544 NoDisclaimer: True X-Forefront-PRVS: 0232B30BBC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2q5WpEWJGAt037dQ3WCEwOUhtbXEbLBmZ6Ado17E4RVMNvWAoDijaqwE4VnEbFedKN+ptiSObObf4SwmPWXJT9VhgJwrl21eqibXXGRrIUvbYqPeJOkZ6LCMyRQumrM9usFSMTtjsS7VsURmSRtr1y9TQy08mtC3szCBWKcQAIRHMXVktqKalr9JFVb6UUVz2F/Eeh9n4JVhYO8Kf7dpCF5XreEIeQ24e+Rfh55aiRuW8Awv+QzD10r35vWW7NuYWVFr+/XnPG0Od5gtiAZtTs/18xtIr8WMg0PR0fxTQ/FdmithW822w8A2YBlSZe0YLTjQIp/K854hMJCx63UThX+FFoQjP6ZQgTg1GbP5dPjD0eRB7qyYN7FwP+R6iHSKF+74qVL9h0hrdYm09JOEqHtzyzVE3qv+6G8BJV8RUnP/JBD/AzjXa8CflSN75bDs55BJaMsPmpzL+3IUc8uuafm+Ogd1pMQV+kFyUsibt5k= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2019 09:20:07.2997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 129f4b0f-6f26-4a66-2652-08d77188a9c0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2224 Content-Type: text/plain Add support for parsing the ACPI FACS table. The FADT parser has also been updated as it links the FACS table using the FIRMWARE_CTRL or X_FIRMWARE_CTRL fields. Since the FACS table does not follow the standard ACPI header, the FADT parser extracts the FACS signature, length and version fields before invoking the FACS parser. Cc: Ray Ni Cc: Zhichao Gao Signed-off-by: Sami Mujawar --- The changes can be seen at: https://github.com/samimujawar/edk2/tree/656_acpiview_facs_parser_v1 Notes: v2: - Fixed patch check failure in commit message, [SAMI] changed 'CC' to 'Cc'. No code change. v1: - Add support for parsing FACS table [SAMI] ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 21 +++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c | 71 +++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 90 ++++++++++++++++++-- ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 1 + ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 1 + 5 files changed, 179 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index 20ca358bddfa5953bfb1d1bebaebbf3079eaba01..f374f8ebfe313954c05b2a432816cf7ad3af9e32 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h @@ -528,6 +528,27 @@ ParseAcpiDsdt ( IN UINT8 AcpiTableRevision ); +/** + This function parses the ACPI FACS table. + When trace is enabled this function parses the FACS table and + traces the ACPI table fields. + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiFacs ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ); + /** This function parses the ACPI FADT table. This function parses the FADT table and optionally traces the ACPI diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c new file mode 100644 index 0000000000000000000000000000000000000000..d6bea86bdbaa79aa35b86840c809394b3c7a3bf6 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c @@ -0,0 +1,71 @@ +/** @file + FACS table parser + + Copyright (c) 2019, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 +**/ + +#include +#include +#include "AcpiParser.h" +#include "AcpiTableParser.h" + +/** + An ACPI_PARSER array describing the ACPI FACS Table. +**/ +STATIC CONST ACPI_PARSER FacsParser[] = { + {L"Signature", 4, 0, L"%c%c%c%c", Dump4Chars, NULL, NULL, NULL}, + {L"Length", 4, 4, L"%d", NULL, NULL, NULL, NULL}, + {L"Hardware Signature", 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Firmware Waking Vector", 4, 12, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Global Lock", 4, 16, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Flags", 4, 20, L"0x%x", NULL, NULL, NULL, NULL}, + {L"X Firmware Walking Vector", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL}, + {L"Version", 1, 32, L"%d", NULL, NULL, NULL, NULL}, + {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}, + {L"OSPM Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL}, + {L"Reserved", 8, 40, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, + NULL}, + {L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, + NULL}, + {L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NULL, + NULL} +}; + +/** + This function parses the ACPI FACS table. + When trace is enabled this function parses the FACS table and + traces the ACPI table fields. + + This function also performs validation of the ACPI table fields. + + @param [in] Trace If TRUE, trace the ACPI fields. + @param [in] Ptr Pointer to the start of the buffer. + @param [in] AcpiTableLength Length of the ACPI table. + @param [in] AcpiTableRevision Revision of the ACPI table. +**/ +VOID +EFIAPI +ParseAcpiFacs ( + IN BOOLEAN Trace, + IN UINT8* Ptr, + IN UINT32 AcpiTableLength, + IN UINT8 AcpiTableRevision + ) +{ + if (!Trace) { + return; + } + + ParseAcpi ( + Trace, + 0, + "FACS", + Ptr, + AcpiTableLength, + PARSER_PARAMS (FacsParser) + ); +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c index e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..5b8cc174f16afb3d4feb6a518952e60c6564ee34 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -5,17 +5,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): - - ACPI 6.2 Specification - Errata A, September 2017 + - ACPI 6.3 Specification - January 2019 **/ #include #include #include "AcpiParser.h" #include "AcpiTableParser.h" +#include "AcpiView.h" // Local variables STATIC CONST UINT32* DsdtAddress; STATIC CONST UINT64* X_DsdtAddress; +STATIC CONST UINT32* Flags; +STATIC CONST UINT32* FirmwareCtrl; +STATIC CONST UINT64* X_FirmwareCtrl; STATIC CONST UINT8* FadtMinorRevision; STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; @@ -24,6 +28,21 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; **/ #define HW_REDUCED_ACPI BIT20 +/** + Offset to the FACS signature from the start of the FACS. +**/ +#define FACS_SIGNATURE_OFFSET 0 + +/** + Offset to the FACS revision from the start of the FACS. +**/ +#define FACS_VERSION_OFFSET 32 + +/** + Offset to the FACS length from the start of the FACS. +**/ +#define FACS_LENGTH_OFFSET 4 + /** Get the ACPI XSDT header info. **/ @@ -113,7 +132,8 @@ ValidateFlags ( **/ STATIC CONST ACPI_PARSER FadtParser[] = { PARSE_ACPI_HEADER (&AcpiHdrInfo), - {L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, NULL, ValidateFirmwareCtrl, NULL}, + {L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID**)&FirmwareCtrl, + ValidateFirmwareCtrl, NULL}, {L"DSDT", 4, 40, L"0x%x", NULL, (VOID**)&DsdtAddress, NULL, NULL}, {L"Reserved", 1, 44, L"%x", NULL, NULL, NULL, NULL}, {L"Preferred_PM_Profile", 1, 45, L"0x%x", NULL, NULL, NULL, NULL}, @@ -150,13 +170,13 @@ STATIC CONST ACPI_PARSER FadtParser[] = { {L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL}, {L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL}, {L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL}, - {L"Flags", 4, 112, L"0x%x", NULL, NULL, ValidateFlags, NULL}, + {L"Flags", 4, 112, L"0x%x", NULL, (VOID**)&Flags, ValidateFlags, NULL}, {L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL}, {L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL}, {L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL}, {L"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID**)&FadtMinorRevision, NULL, NULL}, - {L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, NULL, + {L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID**)&X_FirmwareCtrl, ValidateXFirmwareCtrl, NULL}, {L"X_DSDT", 8, 140, L"0x%lx", NULL, (VOID**)&X_DsdtAddress, NULL, NULL}, {L"X_PM1a_EVT_BLK", 12, 148, NULL, DumpGas, NULL, NULL, NULL}, @@ -192,7 +212,13 @@ ParseAcpiFadt ( IN UINT8 AcpiTableRevision ) { - UINT8* DsdtPtr; + EFI_STATUS Status; + UINT8* DsdtPtr; + UINT8* FirmwareCtrlPtr; + UINT32 FacsSignature; + UINT32 FacsLength; + UINT8 FacsRevision; + PARSE_ACPI_TABLE_PROC FacsParserProc; ParseAcpi ( Trace, @@ -214,6 +240,60 @@ ParseAcpiFadt ( } } + // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore + // FIRMWARE_CTRL, else use FIRMWARE_CTRL. + if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) { + FirmwareCtrlPtr = (UINT8*)(UINTN)(*X_FirmwareCtrl); + } else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) { + FirmwareCtrlPtr = (UINT8*)(UINTN)(*FirmwareCtrl); + } else { + FirmwareCtrlPtr = NULL; + // if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and + // X_FIRMWARE_CTRL cannot be zero, and the FACS Table must be + // present. + if ((Trace) && + (Flags != NULL) && + ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != 0)) { + IncrementErrorCount (); + Print (L"ERROR: No FACS table found, " + L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"); + } + } + + if (FirmwareCtrlPtr != NULL) { + // The FACS table does not have a standard ACPI table header. Therefore, + // the signature, length and version needs to be initially parsed. + // The FACS signature is 4 bytes starting at offset 0. + FacsSignature = *(UINT32*)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET); + + // The FACS length is 4 bytes starting at offset 4. + FacsLength = *(UINT32*)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET); + + // The FACS version is 1 byte starting at offset 32. + FacsRevision = *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET); + + Trace = ProcessTableReportOptions ( + FacsSignature, + FirmwareCtrlPtr, + FacsLength + ); + + Status = GetParser (FacsSignature, &FacsParserProc); + if (EFI_ERROR (Status)) { + Print ( + L"ERROR: No registered parser found for FACS.\n" + ); + return; + } + + FacsParserProc ( + Trace, + FirmwareCtrlPtr, + FacsLength, + FacsRevision + ); + } + // If X_DSDT is not zero then use X_DSDT and ignore DSDT, // else use DSDT. if (*X_DsdtAddress != 0) { diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c index 3ee0f0fe421c6acdde33becca80d8efcbeda0fde..e0d5a81085525a91110d9a25279adf3376286342 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c @@ -29,6 +29,7 @@ ACPI_TABLE_PARSER ParserList[] = { {EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, ParseAcpiDbg2}, {EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiDsdt}, + {EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE, ParseAcpiFacs}, {EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiFadt}, {EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, ParseAcpiGtdt}, {EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, ParseAcpiIort}, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf index 1e2fa52b00a37f73d789ba4049c531f5bc29fb5b..ea504c934aeebaa452a380e6ea169586e467642a 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf @@ -31,6 +31,7 @@ [Sources.common] Parsers/Bgrt/BgrtParser.c Parsers/Dbg2/Dbg2Parser.c Parsers/Dsdt/DsdtParser.c + Parsers/Facs/FacsParser.c Parsers/Fadt/FadtParser.c Parsers/Gtdt/GtdtParser.c Parsers/Iort/IortParser.c -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'