From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.5559.1574732449563984070 for ; Mon, 25 Nov 2019 17:40:49 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: zhichao.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 17:40:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,243,1571727600"; d="scan'208";a="239748958" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 25 Nov 2019 17:40:48 -0800 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 25 Nov 2019 17:40:48 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 25 Nov 2019 17:40:48 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.127]) with mapi id 14.03.0439.000; Tue, 26 Nov 2019 09:40:46 +0800 From: "Gao, Zhichao" To: Sami Mujawar , "devel@edk2.groups.io" CC: "Ni, Ray" , "Matteo.Carlini@arm.com" , "Laura.Moretta@arm.com" , "nd@arm.com" Subject: Re: [PATCH v2 1/1] ShellPkg: acpiview: Add support for parsing FACS Thread-Topic: [PATCH v2 1/1] ShellPkg: acpiview: Add support for parsing FACS Thread-Index: AQHVo3GPHW7EVf2L4kawS+nn6u/9PaecrhBA Date: Tue, 26 Nov 2019 01:40:45 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B87AB27@SHSMSX101.ccr.corp.intel.com> References: <20191125091947.14360-1-sami.mujawar@arm.com> In-Reply-To: <20191125091947.14360-1-sami.mujawar@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: zhichao.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Zhichao Gao > -----Original Message----- > From: Sami Mujawar [mailto:sami.mujawar@arm.com] > Sent: Monday, November 25, 2019 5:20 PM > To: devel@edk2.groups.io > Cc: Sami Mujawar ; Ni, Ray ; Gao, > Zhichao ; Matteo.Carlini@arm.com; > Laura.Moretta@arm.com; nd@arm.com > Subject: [PATCH v2 1/1] ShellPkg: acpiview: Add support for parsing FACS >=20 > Add support for parsing the ACPI FACS table. >=20 > The FADT parser has also been updated as it links the FACS table using th= e > FIRMWARE_CTRL or X_FIRMWARE_CTRL fields. >=20 > Since the FACS table does not follow the standard ACPI header, the FADT p= arser > extracts the FACS signature, length and version fields before invoking th= e FACS > parser. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Sami Mujawar > --- >=20 > The changes can be seen at: > https://github.com/samimujawar/edk2/tree/656_acpiview_facs_parser_v1 >=20 > 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= ] >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h = | 21 > +++++ > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c > | 71 +++++++++++++++ > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c > | 90 ++++++++++++++++++-- >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib > .c | 1 + >=20 > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib > .inf | 1 + > 5 files changed, 179 insertions(+), 5 deletions(-) >=20 > diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > index > 20ca358bddfa5953bfb1d1bebaebbf3079eaba01..f374f8ebfe313954c05b2a4328 > 16cf7ad3af9e32 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h > @@ -528,6 +528,27 @@ ParseAcpiDsdt ( > IN UINT8 AcpiTableRevision > ); >=20 > +/** > + 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 dif= f --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c > new file mode 100644 > index > 0000000000000000000000000000000000000000..d6bea86bdbaa79aa35b86840 > c809394b3c7a3bf6 > --- /dev/null > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsPars > +++ er.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[] =3D { > + {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, NUL= L, > + NULL}, > + {L"Reserved", 8, 48, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NUL= L, > + NULL}, > + {L"Reserved", 8, 56, L"%x %x %x %x %x %x %x %x", Dump8Chars, NULL, NUL= L, > + 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..5b8cc174f16afb3d4feb6a51895 > 2e60c6564ee34 100644 > --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParse= r.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars > +++ er.c > @@ -5,17 +5,21 @@ > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > - - ACPI 6.2 Specification - Errata A, September 2017 > + - ACPI 6.3 Specification - January 2019 > **/ >=20 > #include > #include > #include "AcpiParser.h" > #include "AcpiTableParser.h" > +#include "AcpiView.h" >=20 > // 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; >=20 > @@ -24,6 +28,21 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; > **/ > #define HW_REDUCED_ACPI BIT20 >=20 > +/** > + 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[] =3D { > 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[] =3D { > {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**)&FadtMinorRevis= ion, > 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; >=20 > ParseAcpi ( > Trace, > @@ -214,6 +240,60 @@ ParseAcpiFadt ( > } > } >=20 > + // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore > + // FIRMWARE_CTRL, else use FIRMWARE_CTRL. > + if ((X_FirmwareCtrl !=3D NULL) && (*X_FirmwareCtrl !=3D 0)) { > + FirmwareCtrlPtr =3D (UINT8*)(UINTN)(*X_FirmwareCtrl); } else if > + ((FirmwareCtrl !=3D NULL) && (*FirmwareCtrl !=3D 0)) { > + FirmwareCtrlPtr =3D (UINT8*)(UINTN)(*FirmwareCtrl); } else { > + FirmwareCtrlPtr =3D 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 !=3D NULL) && > + ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) !=3D 0)) { > + IncrementErrorCount (); > + Print (L"ERROR: No FACS table found, " > + L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"); > + } > + } > + > + if (FirmwareCtrlPtr !=3D NULL) { > + // The FACS table does not have a standard ACPI table header. Theref= ore, > + // the signature, length and version needs to be initially parsed. > + // The FACS signature is 4 bytes starting at offset 0. > + FacsSignature =3D *(UINT32*)(FirmwareCtrlPtr + > + FACS_SIGNATURE_OFFSET); > + > + // The FACS length is 4 bytes starting at offset 4. > + FacsLength =3D *(UINT32*)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET); > + > + // The FACS version is 1 byte starting at offset 32. > + FacsRevision =3D *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET); > + > + Trace =3D ProcessTableReportOptions ( > + FacsSignature, > + FirmwareCtrlPtr, > + FacsLength > + ); > + > + Status =3D 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 !=3D 0) { > diff --git > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand > Lib.c > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand > Lib.c > index > 3ee0f0fe421c6acdde33becca80d8efcbeda0fde..e0d5a81085525a91110d9a2527 > 9adf3376286342 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand > Lib.c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm > +++ andLib.c > @@ -29,6 +29,7 @@ ACPI_TABLE_PARSER ParserList[] =3D { > {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/UefiShellAcpiViewCommand > Lib.inf > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand > Lib.inf > index > 1e2fa52b00a37f73d789ba4049c531f5bc29fb5b..ea504c934aeebaa452a380e6e > a169586e467642a 100644 > --- > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommand > Lib.inf > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm > +++ andLib.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)' >=20