From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76930+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76930+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446354; cv=none; d=zohomail.com; s=zohoarc; b=NrXhLvWm+i9VfZQYm+PHrtIZQWCqdNG4/khHugP9k8c33dRa4LHSc/+yb9dzCna+xJNiNX5G4IncJFrohHSe/e/nxS73FueswouIdSGKc5vu+ti3KolazVgl856AkxiodYJmVo1InZuSdIIlBYucP6RF+NflkaVSmcgRfR7PTJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446354; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=6PYFhBGjGAskWCHLuKc8EWdOnVCLCg6zabgtTxMIEXE=; b=eB7y18oguV/v83xt+483gFk30cK5CaHXp8A2zDald5JaBZVpfduEG4fbd+mcmCrmSqx1mwYQJsZvnJpxBMsPlWK8BQUBI3Ztv5M3lobH+uyQfwHA3VWrX4ApssxeQxBagY31iTPSZaxS5vIilmU3+yjs02pLTAL2WNT0eJlidJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76930+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446354402241.50112641309534; Wed, 23 Jun 2021 04:05:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7FRmYY1788612xl29Rv0Z4mE; Wed, 23 Jun 2021 04:05:54 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5934.1624446342980244455 for ; Wed, 23 Jun 2021 04:05:43 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8CA861063; Wed, 23 Jun 2021 04:05:42 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8591F3F719; Wed, 23 Jun 2021 04:05:41 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 01/10] DynamicTablesPkg: Extract AcpiTableHelperLib from TableHelperLib Date: Wed, 23 Jun 2021 12:05:15 +0100 Message-Id: <20210623110525.6171-2-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: A9lXAQVcTvCDJR45XmOpYR8Jx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446354; bh=a57oiVTHQl1FOzBY+e7p6tZK4qo/CSsTLIl6h8BYk24=; h=Date:From:Reply-To:Subject:To; b=esgyKch6KiJ0N8Y33yE5OPUFVP4SXGPKnONfefYxCLebZ0SQ+foUlmtCTpqVfD4jRLT Wg1Ra12tUei7rw9xPfo2eIfNKDPhQZGekHOCyQ4/jk6AGp0pHr2jxOmJdZD0h6lKmeWph Y3gEpO96l5HkmmXC2d7+LghWUl5s9mzrawM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The TableHelperLib contains helper functions. Some rely on DynamicTablesPkg definitions (they use Configuration Manager objects). Some others are more generic. To allow using these generic functions without including DynamicTablesPkg definitions, move them to a new AcpiTableHelperLib library. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- DynamicTablesPkg/DynamicTables.dsc.inc | 3 +- DynamicTablesPkg/DynamicTablesPkg.dec | 4 + DynamicTablesPkg/DynamicTablesPkg.dsc | 1 + .../Include/Library/AcpiHelperLib.h | 60 ++++++++++ .../Include/Library/TableHelperLib.h | 49 -------- .../SsdtCmn600Generator.c | 2 +- .../AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.inf | 3 +- .../SsdtSerialPortGenerator.c | 3 +- .../SsdtSerialPortLibArm.inf | 4 +- .../Library/Common/AcpiHelperLib/AcpiHelper.c | 109 ++++++++++++++++++ .../Common/AcpiHelperLib/AcpiHelperLib.inf | 25 ++++ .../Library/Common/AmlLib/AmlLib.inf | 3 +- .../SsdtSerialPortFixupLib.c | 2 +- .../SsdtSerialPortFixupLib.inf | 1 + .../Common/TableHelperLib/TableHelper.c | 96 --------------- 15 files changed, 212 insertions(+), 153 deletions(-) create mode 100644 DynamicTablesPkg/Include/Library/AcpiHelperLib.h create mode 100644 DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelpe= r.c create mode 100644 DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelpe= rLib.inf diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dyna= micTables.dsc.inc index fa33b7ee67e6..ed221d1681eb 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -1,7 +1,7 @@ ## @file # Dsc include file for Dynamic Tables Framework. # -# Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -13,6 +13,7 @@ [BuildOptions] RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG =20 [LibraryClasses.common] + AcpiHelperLib|DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLi= b.inf AmlLib|DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFix= upLib/SsdtSerialPortFixupLib.inf TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelpe= rLib.inf diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec b/DynamicTablesPkg/Dynam= icTablesPkg.dec index b242df010587..9996bdf6f520 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dec +++ b/DynamicTablesPkg/DynamicTablesPkg.dec @@ -17,6 +17,10 @@ [Includes] Include =20 [LibraryClasses] + ## @libraryclass Defines a set of Acpi helper methods + # independent from the Dynamic Tables Framework. + AcpiHelperLib|Include/Library/AcpiHelperLib.h + ## @libraryclass Defines a set of APIs for Dynamic AML generation. AmlLib|Include/Library/AmlLib/AmlLib.h =20 diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/Dynam= icTablesPkg.dsc index 33b2a84c9dd9..46b2e667fd25 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dsc +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc @@ -38,6 +38,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64] PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf =20 [Components.common] + DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFix= upLib.inf DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h new file mode 100644 index 000000000000..2731a2e4fb27 --- /dev/null +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -0,0 +1,60 @@ +/** @file + + Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef ACPI_HELPER_LIB_H_ +#define ACPI_HELPER_LIB_H_ + +/** Is a character upper case +*/ +#define IS_UPPER_CHAR(x) ((x >=3D 'A') && (x <=3D 'Z')) + +/** Is a character a decimal digit +*/ +#define IS_DIGIT(x) ((x >=3D '0') && (x <=3D '9')) + +/** Is a character an upper case hexadecimal digit +*/ +#define IS_UPPER_HEX(x) (((x >=3D 'A') && (x <=3D 'F')) || IS_DIGIT (x)) + +/** Convert a hex number to its ASCII code. + + @param [in] x Hex number to convert. + Must be 0 <=3D x < 16. + + @return The ASCII code corresponding to x. +**/ +UINT8 +EFIAPI +AsciiFromHex ( + IN UINT8 x + ); + +/** Check if a HID is a valid PNP ID. + + @param [in] Hid The Hid to validate. + + @retval TRUE The Hid is a valid PNP ID. + @retval FALSE The Hid is not a valid PNP ID. +**/ +BOOLEAN +IsValidPnpId ( + IN CONST CHAR8 * Hid + ); + +/** Check if a HID is a valid ACPI ID. + + @param [in] Hid The Hid to validate. + + @retval TRUE The Hid is a valid ACPI ID. + @retval FALSE The Hid is not a valid ACPI ID. +**/ +BOOLEAN +IsValidAcpiId ( + IN CONST CHAR8 * Hid + ); + +#endif // ACPI_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 0f93cdbf0895..57af51134546 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -12,18 +12,6 @@ #ifndef TABLE_HELPER_LIB_H_ #define TABLE_HELPER_LIB_H_ =20 -/** Is a character upper case -*/ -#define IS_UPPER_CHAR(x) ((x >=3D 'A') && (x <=3D 'Z')) - -/** Is a character a decimal digit -*/ -#define IS_DIGIT(x) ((x >=3D '0') && (x <=3D '9')) - -/** Is a character an upper case hexadecimal digit -*/ -#define IS_UPPER_HEX(x) (((x >=3D 'A') && (x <=3D 'F')) || IS_DIGIT (x)) - /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO object from the Configuration Manager. =20 @@ -119,41 +107,4 @@ FindDuplicateValue ( IN PFN_IS_EQUAL EqualTestFunction ); =20 -/** Convert a hex number to its ASCII code. - - @param [in] x Hex number to convert. - Must be 0 <=3D x < 16. - - @return The ASCII code corresponding to x. -**/ -UINT8 -EFIAPI -AsciiFromHex ( - IN UINT8 x - ); - -/** Check if a HID is a valid PNP ID. - - @param [in] Hid The Hid to validate. - - @retval TRUE The Hid is a valid PNP ID. - @retval FALSE The Hid is not a valid PNP ID. -**/ -BOOLEAN -IsValidPnpId ( - IN CONST CHAR8 * Hid - ); - -/** Check if a HID is a valid ACPI ID. - - @param [in] Hid The Hid to validate. - - @retval TRUE The Hid is a valid ACPI ID. - @retval FALSE The Hid is not a valid ACPI ID. -**/ -BOOLEAN -IsValidAcpiId ( - IN CONST CHAR8 * Hid - ); - #endif // TABLE_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn= 600Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/Ssd= tCmn600Generator.c index 1e8c2bfca5de..cc730cd90fea 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include #include #include "SsdtCmn600Generator.h" =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn= 600LibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/Ssdt= Cmn600LibArm.inf index 821c0d531b98..12b028fcde22 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibA= rm.inf +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibA= rm.inf @@ -1,7 +1,7 @@ ## @file # Ssdt CMN-600 Table Generator # -# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2021, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -29,6 +29,7 @@ [Packages] DynamicTablesPkg/DynamicTablesPkg.dec =20 [LibraryClasses] + AcpiHelperLib AmlLib BaseLib =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/Ssd= tSerialPortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPo= rtLibArm/SsdtSerialPortGenerator.c index 570f53aacf16..1b70fe1db1d7 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortGenerator.c @@ -19,8 +19,9 @@ #include #include #include +#include +#include #include -#include #include =20 /** ARM standard SSDT Serial Port Table Generator diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/Ssd= tSerialPortLibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPor= tLibArm/SsdtSerialPortLibArm.inf index fb7663e280ad..36e61ea9b132 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortLibArm.inf +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortLibArm.inf @@ -1,7 +1,7 @@ ## @file # Ssdt Serial Port Table Generator # -# Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -27,7 +27,7 @@ [Packages] DynamicTablesPkg/DynamicTablesPkg.dec =20 [LibraryClasses] + AcpiHelperLib AmlLib BaseLib - TableHelperLib SsdtSerialPortFixupLib diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/D= ynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c new file mode 100644 index 000000000000..85a32269aae5 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -0,0 +1,109 @@ +/** @file + Acpi Helper + + Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include + +// Module specific include files. +#include + +/** Convert a hex number to its ASCII code. + + @param [in] x Hex number to convert. + Must be 0 <=3D x < 16. + + @return The ASCII code corresponding to x. +**/ +UINT8 +EFIAPI +AsciiFromHex ( + IN UINT8 x + ) +{ + if (x < 10) { + return (UINT8)(x + '0'); + } + + if (x < 16) { + return (UINT8)(x - 10 + 'A'); + } + + ASSERT (FALSE); + return (UINT8)-1; +} + +/** Check if a HID is a valid PNP ID. + + @param [in] Hid The Hid to validate. + + @retval TRUE The Hid is a valid PNP ID. + @retval FALSE The Hid is not a valid PNP ID. +**/ +BOOLEAN +IsValidPnpId ( + IN CONST CHAR8 * Hid + ) +{ + UINTN Index; + + if (AsciiStrLen (Hid) !=3D 7) { + return FALSE; + } + + // A valid PNP ID must be of the form "AAA####" + // where A is an uppercase letter and # is a hex digit. + for (Index =3D 0; Index < 3; Index++) { + if (!IS_UPPER_CHAR (Hid[Index])) { + return FALSE; + } + } + + for (Index =3D 3; Index < 7; Index++) { + if (!IS_UPPER_HEX (Hid[Index])) { + return FALSE; + } + } + + return TRUE; +} + +/** Check if a HID is a valid ACPI ID. + + @param [in] Hid The Hid to validate. + + @retval TRUE The Hid is a valid ACPI ID. + @retval FALSE The Hid is not a valid ACPI ID. +**/ +BOOLEAN +IsValidAcpiId ( + IN CONST CHAR8 * Hid + ) +{ + UINTN Index; + + if (AsciiStrLen (Hid) !=3D 8) { + return FALSE; + } + + // A valid ACPI ID must be of the form "NNNN####" + // where N is an uppercase letter or a digit ('0'-'9') + // and # is a hex digit. + for (Index =3D 0; Index < 4; Index++) { + if (!(IS_UPPER_CHAR (Hid[Index]) || IS_DIGIT (Hid[Index]))) { + return FALSE; + } + } + + for (Index =3D 4; Index < 8; Index++) { + if (!IS_UPPER_HEX (Hid[Index])) { + return FALSE; + } + } + + return TRUE; +} diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.in= f b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf new file mode 100644 index 000000000000..ba7a04eb5a77 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf @@ -0,0 +1,25 @@ +## @file +# Acpi Helper +# +# Copyright (c) 2021, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D AcpiHelperLib + FILE_GUID =3D 45968FB4-A724-46FC-822D-F9E557601F9B + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D AcpiHelperLib + +[Sources] + AcpiHelper.c + +[Packages] + MdePkg/MdePkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[LibraryClasses] + BaseLib diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf b/DynamicTab= lesPkg/Library/Common/AmlLib/AmlLib.inf index e2babef445d5..723de3ad4482 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf +++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf @@ -1,7 +1,7 @@ ## @file # AML Generation Library # -# Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent ## @@ -66,6 +66,7 @@ [Packages] DynamicTablesPkg/DynamicTablesPkg.dec =20 [LibraryClasses] + AcpiHelperLib BaseLib =20 [BuildOptions] diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/= SsdtSerialPortFixupLib.c index f2b4831ad596..8c77f172b795 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include #include =20 /** C array containing the compiled AML template. diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.inf b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLi= b/SsdtSerialPortFixupLib.inf index 54bf71a3b739..965167bdc4e1 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.inf +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.inf @@ -25,6 +25,7 @@ [Packages] DynamicTablesPkg/DynamicTablesPkg.dec =20 [LibraryClasses] + AcpiHelperLib AmlLib BaseLib =20 diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index 9830ce62b3cb..9249e6b87f70 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -245,99 +245,3 @@ FindDuplicateValue ( } return FALSE; } - -/** Convert a hex number to its ASCII code. - - @param [in] x Hex number to convert. - Must be 0 <=3D x < 16. - - @return The ASCII code corresponding to x. -**/ -UINT8 -EFIAPI -AsciiFromHex ( - IN UINT8 x - ) -{ - if (x < 10) { - return (UINT8)(x + '0'); - } - - if (x < 16) { - return (UINT8)(x - 10 + 'A'); - } - - ASSERT (FALSE); - return (UINT8)0; -} - -/** Check if a HID is a valid PNP ID. - - @param [in] Hid The Hid to validate. - - @retval TRUE The Hid is a valid PNP ID. - @retval FALSE The Hid is not a valid PNP ID. -**/ -BOOLEAN -IsValidPnpId ( - IN CONST CHAR8 * Hid - ) -{ - UINTN Index; - - if (AsciiStrLen (Hid) !=3D 7) { - return FALSE; - } - - // A valid PNP ID must be of the form "AAA####" - // where A is an uppercase letter and # is a hex digit. - for (Index =3D 0; Index < 3; Index++) { - if (!IS_UPPER_CHAR (Hid[Index])) { - return FALSE; - } - } - - for (Index =3D 3; Index < 7; Index++) { - if (!IS_UPPER_HEX (Hid[Index])) { - return FALSE; - } - } - - return TRUE; -} - -/** Check if a HID is a valid ACPI ID. - - @param [in] Hid The Hid to validate. - - @retval TRUE The Hid is a valid ACPI ID. - @retval FALSE The Hid is not a valid ACPI ID. -**/ -BOOLEAN -IsValidAcpiId ( - IN CONST CHAR8 * Hid - ) -{ - UINTN Index; - - if (AsciiStrLen (Hid) !=3D 8) { - return FALSE; - } - - // A valid ACPI ID must be of the form "NNNN####" - // where N is an uppercase letter or a digit ('0'-'9') - // and # is a hex digit. - for (Index =3D 0; Index < 4; Index++) { - if (!(IS_UPPER_CHAR (Hid[Index]) || IS_DIGIT (Hid[Index]))) { - return FALSE; - } - } - - for (Index =3D 4; Index < 8; Index++) { - if (!IS_UPPER_HEX (Hid[Index])) { - return FALSE; - } - } - - return TRUE; -} --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76930): https://edk2.groups.io/g/devel/message/76930 Mute This Topic: https://groups.io/mt/83735183/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76931+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76931+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446350; cv=none; d=zohomail.com; s=zohoarc; b=g+KfDh920nuXOTI927WyyT8n52dPSzUKnG5lHSuBUAyDxrmMvO9mnu4GVo8WQgwxF67nc0zoth8jD7LvBGM8iA80y3FM1eIUxrBpQfY9IyeUNyu8sGzXeCaUOcuKmtoPOhaKMPREi8+NcD0bRDksnrE8jFPc8CLTJUwHa0Atr1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446350; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=2v4EThFIfTTh0Y2k39hpNtLSlXP/OjnVT/NRo2E6ric=; b=bdTTz139iOi+odH/W8yANM9eoMEbLK1kFO+AGfbBt2CuPcipHMVDgnMJkGX4SiSjKX7OMLV6Ddlqt9Kk8ljXZyhKdVqSL6CGMTuLefx0lsOrAOxc4E46dt8KgJJmm4rHAEwQKGM+Okg739vhjRGlMJry4E45t0GJwcPNJsOhAJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76931+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446350755194.83189182813737; Wed, 23 Jun 2021 04:05:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xYUBYY1788612xkJiLXhKHJa; Wed, 23 Jun 2021 04:05:50 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.5909.1624446344308813213 for ; Wed, 23 Jun 2021 04:05:44 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EE9CC31B; Wed, 23 Jun 2021 04:05:43 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 06D813F719; Wed, 23 Jun 2021 04:05:42 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 02/10] DynamicTablesPkg: Update TableHelperLib.inf Date: Wed, 23 Jun 2021 12:05:16 +0100 Message-Id: <20210623110525.6171-3-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: zYVNmW1aHwCaCXKwqbkJzqVAx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446350; bh=ZsqL/kOGLj6DBYO8nleUrWvJRXrmpLXdYhiLRHZBPXQ=; h=Date:From:Reply-To:Subject:To; b=QbBw0/RNRRApgEDf5nEQrJS5Mmdou7uNFiFPHqKQ2EwtHzotIygePhR8iz4MAlBhLT5 Q40Ap5PbQA6qj+0rB0GRUG1PIzXnGtx/i8wzslEF6PWJTVzxbvJrIsOWKUac9e9uQpLJ9 geGepk0gZe5qiAm3YMO71TDE15pL94VjO+c= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Update the inf file version and BASE_NAME of the library. Remove unused sections. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Library/Common/TableHelperLib/TableHelperLib.inf | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.= inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf index 26d82e68501b..5435f74aa0b8 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf @@ -1,14 +1,14 @@ ## @file # Table Helper # -# Copyright (c) 2017 - 2018, ARM Limited. All rights reserved. +# Copyright (c) 2017 - 2021, ARM Limited. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent ## =20 [Defines] - INF_VERSION =3D 0x00010019 - BASE_NAME =3D DynamicTableHelperLib + INF_VERSION =3D 0x0001001B + BASE_NAME =3D TableHelperLib FILE_GUID =3D E315C738-3A39-4D0D-A0AF-8EDFA770AB39 VERSION_STRING =3D 1.0 MODULE_TYPE =3D DXE_DRIVER @@ -23,8 +23,3 @@ [Packages] =20 [LibraryClasses] BaseLib - -[Protocols] - -[Guids] - --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76931): https://edk2.groups.io/g/devel/message/76931 Mute This Topic: https://groups.io/mt/83735184/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76932+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76932+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446349; cv=none; d=zohomail.com; s=zohoarc; b=MgRfsiNFocAesgH0u3j7WQo/X4/wpc+9atR6m9Qsy6sgWSjLbpy1lVVZyY9Cmi+TtS4O+NeJ0lzoFmF+vi2+DOBy0zuHL168V6Sl2Nf+NHau1Axhn+Pt3RshS0rV7MFxWOmfuzlzwP2SJEKw0mLtHIQJhKPq8Z60ta8T5KoOTis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446349; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=y2q8Vhz6Bu32m8nc08NsPT4usZMA6nC+BK5ks2BHxJU=; b=ZEPooEaGSJxOtQFJy9PhkwJMMpRVd8Ue+NwwKjO27z/U8J2ilitKFVr/WMtB9Tlxc4+VtulRz6fZzaSJoEfGt1jO2Q20jtLabeG1EsjorgkrS1995/3XamwDgmdDJyFcjbbh727tvC6JiBmwIJ2C41G43fNMtPK7SyMZ7xSNJY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76932+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446349453789.2886927660415; Wed, 23 Jun 2021 04:05:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id wtvgYY1788612xPMzcUKHW7R; Wed, 23 Jun 2021 04:05:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.6034.1624446345595381956 for ; Wed, 23 Jun 2021 04:05:45 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 37EEF31B; Wed, 23 Jun 2021 04:05:45 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3A5693F719; Wed, 23 Jun 2021 04:05:44 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 03/10] DynamicTablesPkg: Rename single char input parameter Date: Wed, 23 Jun 2021 12:05:17 +0100 Message-Id: <20210623110525.6171-4-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: cCiYthGxugVoDrkPi5xoNfg5x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446349; bh=C2umKzic397cRx3fVLRBRLcwvhLVZ2fJTc+Lo+6qKJc=; h=Date:From:Reply-To:Subject:To; b=GOeBScDgUvwLEkfNNC0jFcwcpfkZA9zQj4NReA6GhWNjWbVgLXOuwY8G2yopZDZd2dC NJ6hwiwSLqUvLYifWWxeOy53qX7GGGZtJhb+lcjjjRKw8k+UOf2DCOCNmKwo87CJPo6XJ Pdzg83kImj29iihrGAfXxafSiJBrCWQ//iQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The Ecc tool forbids the usage of one char variable: Ecc error 8007: "There should be no use of short (single character) variable names" To follow this policy, rename this one letter parameter. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- DynamicTablesPkg/Include/Library/AcpiHelperLib.h | 6 +++--- .../Library/Common/AcpiHelperLib/AcpiHelper.c | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index 2731a2e4fb27..b653c3cb69ef 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -22,15 +22,15 @@ =20 /** Convert a hex number to its ASCII code. =20 - @param [in] x Hex number to convert. - Must be 0 <=3D x < 16. + @param [in] Hex Hex number to convert. + Must be 0 <=3D x < 16. =20 @return The ASCII code corresponding to x. **/ UINT8 EFIAPI AsciiFromHex ( - IN UINT8 x + IN UINT8 Hex ); =20 /** Check if a HID is a valid PNP ID. diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/D= ynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c index 85a32269aae5..19840fb173eb 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -14,23 +14,23 @@ =20 /** Convert a hex number to its ASCII code. =20 - @param [in] x Hex number to convert. - Must be 0 <=3D x < 16. + @param [in] Hex Hex number to convert. + Must be 0 <=3D x < 16. =20 @return The ASCII code corresponding to x. **/ UINT8 EFIAPI AsciiFromHex ( - IN UINT8 x + IN UINT8 Hex ) { - if (x < 10) { - return (UINT8)(x + '0'); + if (Hex < 10) { + return (UINT8)(Hex + '0'); } =20 - if (x < 16) { - return (UINT8)(x - 10 + 'A'); + if (Hex < 16) { + return (UINT8)(Hex - 10 + 'A'); } =20 ASSERT (FALSE); --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76932): https://edk2.groups.io/g/devel/message/76932 Mute This Topic: https://groups.io/mt/83735186/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76933+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76933+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446349; cv=none; d=zohomail.com; s=zohoarc; b=XaxgBJlSAsMWmpeSQrYBPzqzrFGZ/JYRTt2GNNeQ6eGfgbTMO//DhF+JUU/DwHGw2vNcsXzmVvN6ybfq/7WwpfkYA/Tdikrooz+29S8bFgL46eL53CpKFcoy5VAutrLIjEkBqt7jDAlV/b34LM1d+uiuPutqLw9ZmwrzbvsAfcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446349; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=0LlMpTfYARPtQqBUfpr4/vVAyJcWNiF7yADR6JIjQe0=; b=jr7pKH7zPsgDuyxs+iCBf3mKVkr5uF77WGNNiRhD+jnndXX6paldqo2QrOe9OS66NJ9G0iCWiUKKN+mXLowYknRHa1NzLHKUw0mmdGMHGzD1fkWTgACPE85HxJUagsCnDIj74cmr6Mg8sLlvrRAJkmsxMsZ0hCVW8rLz4v3pjbs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76933+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446349828850.0462613517371; Wed, 23 Jun 2021 04:05:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RQW2YY1788612xufvz76nS2R; Wed, 23 Jun 2021 04:05:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.6010.1624446347206495226 for ; Wed, 23 Jun 2021 04:05:47 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D58851063; Wed, 23 Jun 2021 04:05:46 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BA9A33F719; Wed, 23 Jun 2021 04:05:45 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 04/10] DynamicTablesPkg: Add HexFromAscii() to AcpiHelperLib Date: Wed, 23 Jun 2021 12:05:18 +0100 Message-Id: <20210623110525.6171-5-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: Heb9HnZStHT0IrzZNGMwEF2cx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446349; bh=xqohERzW4LnpSIHgyek8xsflyJcpX9uiZOyva3B3B2w=; h=Date:From:Reply-To:Subject:To; b=ardcwpyYA1CpTtHg8MjLSTWYIAYYwCxE5Ublpe8eulwM4l3i6bMQTRjfYzhh/2iz7AB K0zMRAxYSbgnG0lUCkkrWuxIWGDksiEvnzj/LKXLjljz3jJNQ+Min2u7tSUG2IsyM+ZHW 9cxn3D9/Ip0rYf1JTwdUqy3/NH1EO/v+JQA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add HexFromAscii(), converting an hexadecimal ascii char to an integer. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AcpiHelperLib.h | 14 +++++++++ .../Library/Common/AcpiHelperLib/AcpiHelper.c | 30 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index b653c3cb69ef..eec0cf75e084 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -33,6 +33,20 @@ AsciiFromHex ( IN UINT8 Hex ); =20 +/** Convert an ASCII char representing an hexadecimal number + to its integer value. + + @param [in] Char Char to convert. + Must be between '0'-'9' or 'A'-'F' or 'a'-'f'. + + @return The corresponding integer (between 0-16). +**/ +UINT8 +EFIAPI +HexFromAscii ( + IN CHAR8 Char + ); + /** Check if a HID is a valid PNP ID. =20 @param [in] Hid The Hid to validate. diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/D= ynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c index 19840fb173eb..c7097c8ff432 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -37,6 +37,36 @@ AsciiFromHex ( return (UINT8)-1; } =20 +/** Convert an ASCII char representing an hexadecimal number + to its integer value. + + @param [in] Char Char to convert. + Must be between '0'-'9' or 'A'-'F' or 'a'-'f'. + + @return The corresponding integer (between 0-16). +**/ +UINT8 +EFIAPI +HexFromAscii ( + IN CHAR8 Char + ) +{ + if ((Char >=3D '0') && (Char <=3D '9')) { + return (UINT8)(Char - '0'); + } + + if ((Char >=3D 'A') && (Char <=3D 'F')) { + return (UINT8)(Char - 'A' + 10); + } + + if ((Char >=3D 'a') && (Char <=3D 'f')) { + return (UINT8)(Char - 'a' + 10); + } + + ASSERT (FALSE); + return (UINT8)-1; +} + /** Check if a HID is a valid PNP ID. =20 @param [in] Hid The Hid to validate. --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76933): https://edk2.groups.io/g/devel/message/76933 Mute This Topic: https://groups.io/mt/83735187/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76934+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76934+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446354; cv=none; d=zohomail.com; s=zohoarc; b=BOESIypcT69Db7kSYgpyKrZDorwiuFjVCDMlXk7P6my+VDVt0jPRK6S/eet4wxmOjPS3eoeUczAs1Lp4YO4kRMawguWqSGS5a1DsbTj0VK7Y7x5mE67NI3Md6NabnfMdkSXJuTq5Wptwg6gGAcufdHGtMIXViXAl7SxUpGb7XTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446354; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=QV5jiJiPVfoyrwKI3rruxYAFuotx1hibfTacCfxSpIw=; b=ZH2wl8cTTAPnEhGP0feGSIJl65wSjosd7DKH3/B3hoKOexLYHucnW/nqA8V9aesS0f4Zmzenyw6O4TVqaUPX+pmD0MedMI0nSz2dycX+5qtoZdasJGd6XMy+WPQ0cptr6WyotmCzMh8ZvD2zmPsn5zvo6FByK76bzljE2yErkWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76934+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446354627441.77587329362586; Wed, 23 Jun 2021 04:05:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SXCwYY1788612xY5GarLv4xz; Wed, 23 Jun 2021 04:05:54 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5935.1624446348595156657 for ; Wed, 23 Jun 2021 04:05:48 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4243931B; Wed, 23 Jun 2021 04:05:48 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 376C03F719; Wed, 23 Jun 2021 04:05:47 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 05/10] DynamicTablesPkg: Add AmlGetEisaIdFromString() to AcpiHelperLib Date: Wed, 23 Jun 2021 12:05:19 +0100 Message-Id: <20210623110525.6171-6-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 8ruurpFOCytT6xYmDhhpdyMPx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446354; bh=4iDJkbIlR9fe8faots9NCsKiqK7E71d6GRaRKdssvpg=; h=Date:From:Reply-To:Subject:To; b=GN+tgHxDWJNw3BOT3lw6AER/HHI7Eal6Z8tVKglnlhNNF67A84XVhut3cFNVjPl1aAE YAr4iasywgdqC1px4k5P5v676MlpdupoorygqKvkxCdCPU6kUG4rJa40u2FhdnUdKCGqZ rUPVdGFYPC/Dq+P0zOeEprfqU7VXqvViFu0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a function converting a 7 characters string to its UINT32 EISAID. The algorithm used to create the EISAID is described in the ACPI 6.4 specification, s19.3.4 "ASL Macros". Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AcpiHelperLib.h | 17 +++++ .../Library/Common/AcpiHelperLib/AcpiHelper.c | 69 +++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index eec0cf75e084..e7962a2b931a 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -71,4 +71,21 @@ IsValidAcpiId ( IN CONST CHAR8 * Hid ); =20 +/** Convert a EisaId string to its compressed UINT32 equivalent. + + Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + @param [in] EisaIdStr Input EisaId string. + @param [out] EisaIdInt Output EisaId UINT32 (compressed). + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlGetEisaIdFromString ( + IN CONST CHAR8 * EisaIdStr, + OUT UINT32 * EisaIdInt + ); + #endif // ACPI_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c b/D= ynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c index c7097c8ff432..4b6756054c0c 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -137,3 +137,72 @@ IsValidAcpiId ( =20 return TRUE; } + +/** Convert a EisaId string to its compressed UINT32 equivalent. + + Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + @param [in] EisaIdStr Input EisaId string. + @param [out] EisaIdInt Output EisaId UINT32 (compressed). + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlGetEisaIdFromString ( + IN CONST CHAR8 * EisaIdStr, + OUT UINT32 * EisaIdInt + ) +{ + if ((EisaIdStr =3D=3D NULL) || + (!IsValidPnpId (EisaIdStr)) || + (EisaIdInt =3D=3D NULL)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + /* Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid" + + Converts and compresses the 7-character text argument into its correspon= ding + 4-byte numeric EISA ID encoding (Integer). This can be used when declari= ng + IDs for devices that are EISA IDs. + + The algorithm used to convert the TextID is as shown in the following + example: + Starting with a seven character input string "PNP0303", we want to cre= ate + a DWordConst. This string contains a three character manufacturer code + "PNP", a three character hex product identifier "030", and a one chara= cter + revision identifier "3". + The compressed manufacturer code is created as follows: + 1) Find hex ASCII value for each letter + 2) Subtract 40h from each ASCII value + 3) Retain 5 least significant bits for each letter and discard remai= ning + 0's: + + Byte 0: + Bit 7: reserved (0) + Bit 6-2: 1st character of compressed mfg code "P" + Bit 1-0: Upper 2 bits of 2nd character of mfg code "N" + Byte 1: + Bit 7-5: Lower 3 bits of 2nd character of mfg code "N" + Bit 4-0: 3rd character of mfg code "P" + Byte 2: + Bit 7-4: 1st hex digit of product number "0" + Bit 3-0: 2nd hex digit of product number "3" + Byte 3: + Bit 7-4: 3rd hex digit of product number "0" + Bit 3-0: 4th hex digit of product number "3" + */ + *EisaIdInt =3D SwapBytes32 ( + ((EisaIdStr[0] - 0x40) << 26) | + ((EisaIdStr[1] - 0x40) << 21) | + ((EisaIdStr[2] - 0x40) << 16) | + (HexFromAscii (EisaIdStr[3]) << 12) | + (HexFromAscii (EisaIdStr[4]) << 8) | + (HexFromAscii (EisaIdStr[5]) << 4) | + (HexFromAscii (EisaIdStr[6])) + ); + + return EFI_SUCCESS; +} --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76934): https://edk2.groups.io/g/devel/message/76934 Mute This Topic: https://groups.io/mt/83735188/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76935+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76935+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446351; cv=none; d=zohomail.com; s=zohoarc; b=GwE2mx0ShvMSOmdQNw8MeLBkrGq57vcZGCB27nJeK2CS/IOqEIsG8xethLIa39YJXM8Mc8ridDQX3pn7Q0xvbQcO38ZAf7E01AQwtG8xv1/RpYMb3n+b275+xeIXAr4QzQjB8qe/a8eQegi4A3r6fqLN+F6ZhzRxfvM+Vb8IcOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446351; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=AppontKDUP8pBrCMmiRKlp1wBOMChkr13Gcamj7+Ruc=; b=SE4K2RgEyTWv83f+cfXKgfcltEuzQRThtXdPB2u5jaRk8H22JUuPpagvNCthWRNgV17WBZFZrOPjYADxwoor28gvlO0dFvz45Dj09ajg10a4uUghfrCY6i35tapI7Me6r5H8zNa1a7OmweQjcJoFpZTIZ2fTGnJjfwx5W10kRR4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76935+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446351190756.3085387265398; Wed, 23 Jun 2021 04:05:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ok4NYY1788612xlJYWJUukdr; Wed, 23 Jun 2021 04:05:50 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.5910.1624446350192127244 for ; Wed, 23 Jun 2021 04:05:50 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C4E6E31B; Wed, 23 Jun 2021 04:05:49 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9C7553F719; Wed, 23 Jun 2021 04:05:48 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 06/10] DynamicTablesPkg: Add Configuration Manager Object parser Date: Wed, 23 Jun 2021 12:05:20 +0100 Message-Id: <20210623110525.6171-7-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: riUv9IbEvt2x6DW2qMEyh7vZx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446350; bh=byyDz1ZM0d1EK98iHbnyZN1xS81VA0HeU0TlTYdKBGA=; h=Date:From:Reply-To:Subject:To; b=ri86IqJojnNz1U1uwCc+EQZgqQefw+KMtZezSWVg/zwg6LIRU0AlSCblmf84E6r/rqa iZp87szKbxkO78rRqT434Z7ZkjH4jjXQNR2WeE5AiaweQp/7E3oYdkBVoaVtSepsA9sEE oicBXOcOmIC7IMlNfQUcDpWpxUkxnn4k6Z8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sami Mujawar The Platform information repository in the Configuration Manager may be dynamically populated, for e.g. by a Hardware Information Parser like FdtHwInfoParser. In such cases it is useful to trace the CM objects that were populated by the parser. Therefore, introduce helper functions that can parse and trace the Configuration Manager Objects. Signed-off-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/TableHelperLib.h | 10 + .../ConfigurationManagerObjectParser.c | 678 ++++++++++++++++++ .../ConfigurationManagerObjectParser.h | 73 ++ .../Common/TableHelperLib/TableHelperLib.inf | 2 + 4 files changed, 763 insertions(+) create mode 100644 DynamicTablesPkg/Library/Common/TableHelperLib/Configur= ationManagerObjectParser.c create mode 100644 DynamicTablesPkg/Library/Common/TableHelperLib/Configur= ationManagerObjectParser.h diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 57af51134546..6d362ff99a27 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -107,4 +107,14 @@ FindDuplicateValue ( IN PFN_IS_EQUAL EqualTestFunction ); =20 +/** Parse and print a CmObjDesc. + + @param [in] CmObjDesc The CmObjDesc to parse and print. +**/ +VOID +EFIAPI +ParseCmObjDesc ( + IN CONST CM_OBJ_DESCRIPTOR * CmObjDesc + ); + #endif // TABLE_HELPER_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.c new file mode 100644 index 000000000000..654ead6878e6 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c @@ -0,0 +1,678 @@ +/** @file + Configuration Manager Object parser. + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include "ConfigurationManagerObjectParser.h" + +STATIC +VOID +EFIAPI +PrintOemId ( + CONST CHAR8* Format, + UINT8* Ptr + ); + +/** A parser for EArmObjBootArchInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmBootArchInfoParser[] =3D { + {"BootArchFlags", 2, "0x%x", NULL} +}; + +/** A parser for EArmObjPowerManagementProfileInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmPowerManagementProfileInfoParser[] =3D { + {"PowerManagementProfile", 1, "0x%x", NULL} +}; + +/** A parser for EArmObjGicCInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicCInfoParser[] =3D { + {"CPUInterfaceNumber", 4, "0x%x", NULL}, + {"AcpiProcessorUid", 4, "0x%x", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"ParkingProtocolVersion", 4, "0x%x", NULL}, + {"PerformanceInterruptGsiv", 4, "0x%x", NULL}, + {"ParkedAddress", 8, "0x%llx", NULL}, + {"PhysicalBaseAddress", 8, "0x%llx", NULL}, + {"GICV", 8, "0x%llx", NULL}, + {"GICH", 8, "0x%llx", NULL}, + {"VGICMaintenanceInterrupt", 4, "0x%x", NULL}, + {"GICRBaseAddress", 8, "0x%llx", NULL}, + {"MPIDR", 8, "0x%llx", NULL}, + {"ProcessorPowerEfficiencyClass", 1, "0x%x", NULL}, + {"SpeOverflowInterrupt", 2, "0x%x", NULL}, + {"ProximityDomain", 4, "0x%x", NULL}, + {"ClockDomain", 4, "0x%x", NULL}, + {"AffinityFlags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjGicDInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicDInfoParser[] =3D { + {"PhysicalBaseAddress", 8, "0x%llx", NULL}, + {"SystemVectorBase", 4, "0x%x", NULL}, + {"GicVersion", 1, "0x%x", NULL}, +}; + +/** A parser for EArmObjGicMsiFrameInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicMsiFrameInfoParser[] =3D { + {"GicMsiFrameId", 4, "0x%x", NULL}, + {"PhysicalBaseAddress", 8, "0x%llx", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"SPICount", 2, "0x%x", NULL}, + {"SPIBase", 2, "0x%x", NULL} +}; + +/** A parser for EArmObjGicRedistributorInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicRedistInfoParser[] =3D { + {"DiscoveryRangeBaseAddress", 8, "0x%llx", NULL}, + {"DiscoveryRangeLength", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjGicItsInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicItsInfoParser[] =3D { + {"GicItsId", 4, "0x%x", NULL}, + {"PhysicalBaseAddress", 8, "0x%llx", NULL}, + {"ProximityDomain", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjSerialConsolePortInfo, + EArmObjSerialDebugPortInfo and EArmObjSerialPortInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmSerialPortInfoParser[] =3D { + {"BaseAddress", 8, "0x%llx", NULL}, + {"Interrupt", 4, "0x%x", NULL}, + {"BaudRate", 8, "0x%llx", NULL}, + {"Clock", 4, "0x%x", NULL}, + {"PortSubtype", 2, "0x%x", NULL}, + {"BaseAddressLength", 8, "0x%llx", NULL}, + {"AccessSize", 1, "0x%d", NULL} +}; + +/** A parser for EArmObjGenericTimerInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGenericTimerInfoParser[] =3D { + {"CounterControlBaseAddress", 8, "0x%llx", NULL}, + {"CounterReadBaseAddress", 8, "0x%llx", NULL}, + {"SecurePL1TimerGSIV", 4, "0x%x", NULL}, + {"SecurePL1TimerFlags", 4, "0x%x", NULL}, + {"NonSecurePL1TimerGSIV", 4, "0x%x", NULL}, + {"NonSecurePL1TimerFlags", 4, "0x%x", NULL}, + {"VirtualTimerGSIV", 4, "0x%x", NULL}, + {"VirtualTimerFlags", 4, "0x%x", NULL}, + {"NonSecurePL2TimerGSIV", 4, "0x%x", NULL}, + {"NonSecurePL2TimerFlags", 4, "0x%x", NULL}, + {"VirtualPL2TimerGSIV", 4, "0x%x", NULL}, + {"VirtualPL2TimerFlags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjPlatformGTBlockInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGTBlockTimerFrameInfoParser[] =3D { + {"FrameNumber", 1, "0x%x", NULL}, + {"PhysicalAddressCntBase", 8, "0x%llx", NULL}, + {"PhysicalAddressCntEL0Base", 8, "0x%llx", NULL}, + {"PhysicalTimerGSIV", 4, "0x%x", NULL}, + {"PhysicalTimerFlags", 4, "0x%x", NULL}, + {"VirtualTimerGSIV", 4, "0x%x", NULL}, + {"VirtualTimerFlags", 4, "0x%x", NULL}, + {"CommonFlags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjGTBlockTimerFrameInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGTBlockInfoParser[] =3D { + {"GTBlockPhysicalAddress", 8, "0x%llx", NULL}, + {"GTBlockTimerFrameCount", 4, "0x%x", NULL}, + {"GTBlockTimerFrameToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjPlatformGenericWatchdogInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGenericWatchdogInfoParser[] =3D { + {"ControlFrameAddress", 8, "0x%llx", NULL}, + {"RefreshFrameAddress", 8, "0x%llx", NULL}, + {"TimerGSIV", 4, "0x%x", NULL}, + {"Flags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjPciConfigSpaceInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmPciConfigSpaceInfoParser[] =3D { + {"BaseAddress", 8, "0x%llx", NULL}, + {"PciSegmentGroupNumber", 2, "0x%x", NULL}, + {"StartBusNumber", 1, "0x%x", NULL}, + {"EndBusNumber", 1, "0x%x", NULL} +}; + +/** A parser for EArmObjHypervisorVendorIdentity. +*/ +STATIC CONST CM_OBJ_PARSER CmArmHypervisorVendorIdParser[] =3D { + {"HypervisorVendorId", 8, "0x%llx", NULL} +}; + +/** A parser for EArmObjFixedFeatureFlags. +*/ +STATIC CONST CM_OBJ_PARSER CmArmFixedFeatureFlagsParser[] =3D { + {"Flags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjItsGroup. +*/ +STATIC CONST CM_OBJ_PARSER CmArmItsGroupNodeParser[] =3D { + {"GTBlockTimerFrameToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"ItsIdCount", 4, "0x%x", NULL}, + {"ItsIdToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjNamedComponent. +*/ +STATIC CONST CM_OBJ_PARSER CmArmNamedComponentNodeParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"IdMappingCount", 4, "0x%x", NULL}, + {"IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"CacheCoherent", 4, "0x%x", NULL}, + {"AllocationHints", 1, "0x%x", NULL}, + {"MemoryAccessFlags", 1, "0x%x", NULL}, + {"AddressSizeLimit", 1, "0x%x", NULL}, + {"ObjectName", sizeof (CHAR8*), "%a", NULL} +}; + +/** A parser for EArmObjRootComplex. +*/ +STATIC CONST CM_OBJ_PARSER CmArmRootComplexNodeParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"IdMappingCount", 4, "0x%x", NULL}, + {"IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"CacheCoherent", 4, "0x%x", NULL}, + {"AllocationHints", 1, "0x%x", NULL}, + {"MemoryAccessFlags", 1, "0x%x", NULL}, + {"AtsAttribute", 4, "0x%x", NULL}, + {"PciSegmentNumber", 4, "0x%x", NULL}, + {"MemoryAddressSize", 1, "0x%x", NULL} +}; + +/** A parser for EArmObjSmmuV1SmmuV2. +*/ +STATIC CONST CM_OBJ_PARSER CmArmSmmuV1SmmuV2NodeParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"IdMappingCount", 4, "0x%x", NULL}, + {"IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"BaseAddress", 8, "0x%llx", NULL}, + {"Span", 8, "0x%llx", NULL}, + {"Model", 4, "0x%x", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"ContextInterruptCount", 4, "0x%x", NULL}, + {"ContextInterruptToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"PmuInterruptCount", 4, "0x%x", NULL}, + {"PmuInterruptToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"SMMU_NSgIrpt", 4, "0x%x", NULL}, + {"SMMU_NSgIrptFlags", 4, "0x%x", NULL}, + {"SMMU_NSgCfgIrpt", 4, "0x%x", NULL}, + {"SMMU_NSgCfgIrptFlags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjSmmuV3. +*/ +STATIC CONST CM_OBJ_PARSER CmArmSmmuV3NodeParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"IdMappingCount", 4, "0x%x", NULL}, + {"IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"BaseAddress", 8, "0x%llx", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"VatosAddress", 8, "0x%llx", NULL}, + {"Model", 4, "0x%x", NULL}, + {"EventInterrupt", 4, "0x%x", NULL}, + {"PriInterrupt", 4, "0x%x", NULL}, + {"GerrInterrupt", 4, "0x%x", NULL}, + {"SyncInterrupt", 4, "0x%x", NULL}, + {"ProximityDomain", 4, "0x%x", NULL}, + {"DeviceIdMappingIndex", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjPmcg. +*/ +STATIC CONST CM_OBJ_PARSER CmArmPmcgNodeParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"IdMappingCount", 4, "0x%x", NULL}, + {"IdMappingToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"BaseAddress", 8, "0x%llx", NULL}, + {"OverflowInterrupt", 4, "0x%x", NULL}, + {"Page1BaseAddress", 8, "0x%llx", NULL}, + {"ReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjGicItsIdentifierArray. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGicItsIdentifierParser[] =3D { + {"ItsId", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjIdMappingArray. +*/ +STATIC CONST CM_OBJ_PARSER CmArmIdMappingParser[] =3D { + {"InputBase", 4, "0x%x", NULL}, + {"NumIds", 4, "0x%x", NULL}, + {"OutputBase", 4, "0x%x", NULL}, + {"OutputReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"Flags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjSmmuInterruptArray. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGenericInterruptParser[] =3D { + {"Interrupt", 4, "0x%x", NULL}, + {"Flags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjProcHierarchyInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmProcHierarchyInfoParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"ParentToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"GicCToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"NoOfPrivateResources", 4, "0x%x", NULL}, + {"PrivateResourcesArrayToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjCacheInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmCacheInfoParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"NextLevelOfCacheToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"Size", 4, "0x%x", NULL}, + {"NumberOfSets", 4, "0x%x", NULL}, + {"Associativity", 4, "0x%x", NULL}, + {"Attributes", 1, "0x%x", NULL}, + {"LineSize", 2, "0x%x", NULL} +}; + +/** A parser for EArmObjProcNodeIdInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmProcNodeIdInfoParser[] =3D { + {"Token", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL}, + {"VendorId", 4, "0x%p", NULL}, + {"Level1Id", 8, "0x%x", NULL}, + {"Level2Id", 8, "0x%x", NULL}, + {"MajorRev", 2, "0x%x", NULL}, + {"MinorRev", 2, "0x%x", NULL}, + {"SpinRev", 2, "0x%x", NULL} +}; + +/** A parser for EArmObjCmRef. +*/ +STATIC CONST CM_OBJ_PARSER CmArmObjRefParser[] =3D { + {"ReferenceToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjMemoryAffinityInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmMemoryAffinityInfoParser[] =3D { + {"ProximityDomain", 4, "0x%x", NULL}, + {"BaseAddress", 8, "0x%llx", NULL}, + {"Length", 8, "0x%llx", NULL}, + {"Flags", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjDeviceHandleAcpi. +*/ +STATIC CONST CM_OBJ_PARSER CmArmDeviceHandleAcpiParser[] =3D { + {"Hid", 8, "0x%llx", NULL}, + {"Uid", 4, "0x%x", NULL} +}; + +/** A parser for EArmObjDeviceHandlePci. +*/ +STATIC CONST CM_OBJ_PARSER CmArmDeviceHandlePciParser[] =3D { + {"SegmentNumber", 2, "0x%x", NULL}, + {"BusNumber", 1, "0x%x", NULL}, + {"DeviceNumber", 1, "0x%x", NULL}, + {"FunctionNumber", 1, "0x%x", NULL} +}; + +/** A parser for EArmObjGenericInitiatorAffinityInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmGenericInitiatorAffinityInfoParser[] =3D { + {"ProximityDomain", 4, "0x%x", NULL}, + {"Flags", 4, "0x%x", NULL}, + {"DeviceHandleType", 1, "0x%x", NULL}, + {"DeviceHandleToken", sizeof (CM_OBJECT_TOKEN), "0x%p", NULL} +}; + +/** A parser for EArmObjCmn600Info. +*/ +STATIC CONST CM_OBJ_PARSER CmArmCmn600InfoParser[] =3D { + {"PeriphBaseAddress", 8, "0x%llx", NULL}, + {"PeriphBaseAddressLength", 8, "0x%llx", NULL}, + {"RootNodeBaseAddress", 8, "0x%llx", NULL}, + {"DtcCount", 1, "0x%x", NULL}, + {"DtcInterrupt[0]", 4, "0x%x", NULL}, + {"DtcFlags[0]", 4, "0x%x", NULL}, + {"DtcInterrupt[1]", 4, "0x%x", NULL}, + {"DtcFlags[1]", 4, "0x%x", NULL}, + {"DtcInterrupt[2]", 4, "0x%x", NULL}, + {"DtcFlags[2]", 4, "0x%x", NULL}, + {"DtcInterrupt[3]", 4, "0x%x", NULL}, + {"DtcFlags[3]", 4, "0x%x", NULL} +}; + +/** A parser for Arm namespace objects. +*/ +STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectParser[] =3D { + {"EArmObjReserved", NULL, 0}, + {"EArmObjBootArchInfo", CmArmBootArchInfoParser, + ARRAY_SIZE (CmArmBootArchInfoParser)}, + {"EArmObjCpuInfo", NULL, 0}, + {"EArmObjPowerManagementProfileInfo", CmArmPowerManagementProfileInfoPar= ser, + ARRAY_SIZE (CmArmPowerManagementProfileInfoParser)}, + {"EArmObjGicCInfo", CmArmGicCInfoParser, ARRAY_SIZE (CmArmGicCInfoParser= )}, + {"EArmObjGicDInfo", CmArmGicDInfoParser, ARRAY_SIZE (CmArmGicDInfoParser= )}, + {"EArmObjGicMsiFrameInfo", CmArmGicMsiFrameInfoParser, + ARRAY_SIZE (CmArmGicMsiFrameInfoParser)}, + {"EArmObjGicRedistributorInfo", CmArmGicRedistInfoParser, + ARRAY_SIZE (CmArmGicRedistInfoParser)}, + {"EArmObjGicItsInfo", CmArmGicItsInfoParser, + ARRAY_SIZE (CmArmGicItsInfoParser)}, + {"EArmObjSerialConsolePortInfo", CmArmSerialPortInfoParser, + ARRAY_SIZE (CmArmSerialPortInfoParser)}, + {"EArmObjSerialDebugPortInfo", CmArmSerialPortInfoParser, + ARRAY_SIZE (CmArmSerialPortInfoParser)}, + {"EArmObjGenericTimerInfo", CmArmGenericTimerInfoParser, + ARRAY_SIZE (CmArmGenericTimerInfoParser)}, + {"EArmObjPlatformGTBlockInfo", CmArmGTBlockTimerFrameInfoParser, + ARRAY_SIZE (CmArmGTBlockTimerFrameInfoParser)}, + {"EArmObjGTBlockTimerFrameInfo", CmArmGTBlockInfoParser, + ARRAY_SIZE (CmArmGTBlockInfoParser)}, + {"EArmObjPlatformGenericWatchdogInfo", CmArmGenericWatchdogInfoParser, + ARRAY_SIZE (CmArmGenericWatchdogInfoParser)}, + {"EArmObjPciConfigSpaceInfo", CmArmPciConfigSpaceInfoParser, + ARRAY_SIZE (CmArmPciConfigSpaceInfoParser)}, + {"EArmObjHypervisorVendorIdentity", CmArmHypervisorVendorIdParser, + ARRAY_SIZE (CmArmHypervisorVendorIdParser)}, + {"EArmObjFixedFeatureFlags", CmArmFixedFeatureFlagsParser, + ARRAY_SIZE (CmArmFixedFeatureFlagsParser)}, + {"EArmObjItsGroup", CmArmItsGroupNodeParser, + ARRAY_SIZE (CmArmItsGroupNodeParser)}, + {"EArmObjNamedComponent", CmArmNamedComponentNodeParser, + ARRAY_SIZE (CmArmNamedComponentNodeParser)}, + {"EArmObjRootComplex", CmArmRootComplexNodeParser, + ARRAY_SIZE (CmArmRootComplexNodeParser)}, + {"EArmObjSmmuV1SmmuV2", CmArmSmmuV1SmmuV2NodeParser, + ARRAY_SIZE (CmArmSmmuV1SmmuV2NodeParser)}, + {"EArmObjSmmuV3", CmArmSmmuV3NodeParser, + ARRAY_SIZE (CmArmSmmuV3NodeParser)}, + {"EArmObjPmcg", CmArmPmcgNodeParser, ARRAY_SIZE (CmArmPmcgNodeParser)}, + {"EArmObjGicItsIdentifierArray", CmArmGicItsIdentifierParser, + ARRAY_SIZE (CmArmGicItsIdentifierParser)}, + {"EArmObjIdMappingArray", CmArmIdMappingParser, + ARRAY_SIZE (CmArmIdMappingParser)}, + {"EArmObjSmmuInterruptArray", CmArmGenericInterruptParser, + ARRAY_SIZE (CmArmGenericInterruptParser)}, + {"EArmObjProcHierarchyInfo", CmArmProcHierarchyInfoParser, + ARRAY_SIZE (CmArmProcHierarchyInfoParser)}, + {"EArmObjCacheInfo", CmArmCacheInfoParser, + ARRAY_SIZE (CmArmCacheInfoParser)}, + {"EArmObjProcNodeIdInfo", CmArmProcNodeIdInfoParser, + ARRAY_SIZE (CmArmProcNodeIdInfoParser)}, + {"EArmObjCmRef", CmArmObjRefParser, ARRAY_SIZE (CmArmObjRefParser)}, + {"EArmObjMemoryAffinityInfo", CmArmMemoryAffinityInfoParser, + ARRAY_SIZE (CmArmMemoryAffinityInfoParser)}, + {"EArmObjDeviceHandleAcpi", CmArmDeviceHandleAcpiParser, + ARRAY_SIZE (CmArmDeviceHandleAcpiParser)}, + {"EArmObjDeviceHandlePci", CmArmDeviceHandlePciParser, + ARRAY_SIZE (CmArmDeviceHandlePciParser)}, + {"EArmObjGenericInitiatorAffinityInfo", + CmArmGenericInitiatorAffinityInfoParser, + ARRAY_SIZE (CmArmGenericInitiatorAffinityInfoParser)}, + {"EArmObjSerialPortInfo", CmArmSerialPortInfoParser, + ARRAY_SIZE (CmArmSerialPortInfoParser)}, + {"EArmObjCmn600Info", CmArmCmn600InfoParser, + ARRAY_SIZE (CmArmCmn600InfoParser)}, + {"EArmObjMax", NULL, 0}, +}; + +/** A parser for EStdObjCfgMgrInfo. +*/ +STATIC CONST CM_OBJ_PARSER StdObjCfgMgrInfoParser[] =3D { + {"Revision", 4, "0x%x", NULL}, + {"OemId[6]", 6, "%C%C%C%C%C%C", PrintOemId} +}; + +/** A parser for EStdObjAcpiTableList. +*/ +STATIC CONST CM_OBJ_PARSER StdObjAcpiTableInfoParser[] =3D { + {"AcpiTableSignature", 4, "0x%x", NULL}, + {"AcpiTableRevision", 1, "%d", NULL}, + {"TableGeneratorId", sizeof (ACPI_TABLE_GENERATOR_ID), "0x%x", NULL}, + {"AcpiTableData", sizeof (EFI_ACPI_DESCRIPTION_HEADER*), "0x%p", NULL}, + {"OemTableId", 8, "0x%LLX", NULL}, + {"OemRevision", 4, "0x%x", NULL} +}; + +/** A parser for EStdObjSmbiosTableList. +*/ +STATIC CONST CM_OBJ_PARSER StdObjSmbiosTableInfoParser[] =3D { + {"TableGeneratorId", sizeof (SMBIOS_TABLE_GENERATOR_ID), "0x%x", NULL}, + {"SmbiosTableData", sizeof (SMBIOS_STRUCTURE*), "0x%p", NULL} +}; + +/** A parser for Standard namespace objects. +*/ +STATIC CONST CM_OBJ_PARSER_ARRAY StdNamespaceObjectParser[] =3D { + {"EStdObjCfgMgrInfo", StdObjCfgMgrInfoParser, + ARRAY_SIZE (StdObjCfgMgrInfoParser)}, + {"EStdObjAcpiTableList", StdObjAcpiTableInfoParser, + ARRAY_SIZE (StdObjAcpiTableInfoParser)}, + {"EStdObjSmbiosTableList", StdObjSmbiosTableInfoParser, + ARRAY_SIZE (StdObjSmbiosTableInfoParser)}, +}; + +/** Print OEM Id. + + @param [in] Format Format to print the Ptr. + @param [in] Ptr Pointer to the OEM Id. +**/ +STATIC +VOID +EFIAPI +PrintOemId ( + IN CONST CHAR8 * Format, + IN UINT8 * Ptr + ) +{ + DEBUG (( + DEBUG_ERROR, + (Format !=3D NULL) ? Format : "%C%C%C%C%C%C", + Ptr[0], + Ptr[1], + Ptr[2], + Ptr[3], + Ptr[4], + Ptr[5] + )); +} + +/** Print fields of the objects. + + @param [in] Data Pointer to the object to print. + @param [in] Parser Parser containing the object fields. + @param [in] ItemCount Number of entries/fields in the Parser. + @param [in] RemainingSize Parse at most *RemainingSize bytes. + This function decrements the value + from the number bytes consumed. + @param [in] IndentLevel Indentation to use when printing. +**/ +STATIC +VOID +PrintCmObjDesc ( + IN VOID *Data, + IN CONST CM_OBJ_PARSER *Parser, + IN UINTN ItemCount, + IN INTN *RemainingSize, + IN UINT32 IndentLevel + ) +{ + UINT32 Index; + UINT32 IndentIndex; + INTN SubStructSize; + + if ((Data =3D=3D NULL) || + (Parser =3D=3D NULL) || + (ItemCount =3D=3D 0) || + (RemainingSize =3D=3D NULL)) { + ASSERT (0); + return; + } + + // Print each field. + for (Index =3D 0; Index < ItemCount; Index++) { + // Check there is enough space in left. + *RemainingSize -=3D Parser[Index].Length; + if (*RemainingSize < 0) { + DEBUG (( + DEBUG_ERROR, + "\nERROR: %a: Buffer overrun\n", + Parser[Index].NameStr + )); + ASSERT (0); + return; + } + + // Indentation + for (IndentIndex =3D 0; IndentIndex < IndentLevel; IndentIndex++) { + DEBUG ((DEBUG_ERROR, " ")); + } + + DEBUG (( + DEBUG_ERROR, + "%-*a :", + OUTPUT_FIELD_COLUMN_WIDTH - 2 * IndentLevel, + Parser[Index].NameStr + )); + if (Parser[Index].PrintFormatter !=3D NULL) { + Parser[Index].PrintFormatter (Parser[Index].Format, Data); + } else if (Parser[Index].Format !=3D NULL) { + switch (Parser[Index].Length) { + case 1: + DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT8*)Data)); + break; + case 2: + DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT16*)Data)); + break; + case 4: + DEBUG ((DEBUG_ERROR, Parser[Index].Format, *(UINT32*)Data)); + break; + case 8: + DEBUG ((DEBUG_ERROR, Parser[Index].Format, ReadUnaligned64(Data)= )); + break; + default: + DEBUG (( + DEBUG_ERROR, + "\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length =3D %d\n", + Parser[Index].NameStr, + Parser[Index].Length + )); + } // switch + } else if (Parser[Index].SubObjParser !=3D NULL) { + SubStructSize =3D Parser[Index].Length; + + DEBUG ((DEBUG_ERROR, "\n")); + PrintCmObjDesc ( + Data, + Parser[Index].SubObjParser, + Parser[Index].SubObjItemCount, + &SubStructSize, + IndentLevel + 1 + ); + } else { + ASSERT (0); + DEBUG (( + DEBUG_ERROR, + "\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length =3D %d\n", + Parser[Index].NameStr, + Parser[Index].Length + )); + } + DEBUG ((DEBUG_ERROR, "\n")); + Data +=3D Parser[Index].Length; + } // for +} + +/** Parse and print a CmObjDesc. + + @param [in] CmObjDesc The CmObjDesc to parse and print. +**/ +VOID +EFIAPI +ParseCmObjDesc ( + IN CONST CM_OBJ_DESCRIPTOR * CmObjDesc + ) +{ + UINTN ObjId; + UINTN NameSpaceId; + UINT32 ObjIndex; + UINT32 ObjectCount; + INTN RemainingSize; + CONST CM_OBJ_PARSER_ARRAY * ParserArray; + + if ((CmObjDesc =3D=3D NULL) || (CmObjDesc->Data =3D=3D NULL)) { + return; + } + + NameSpaceId =3D GET_CM_NAMESPACE_ID (CmObjDesc->ObjectId); + ObjId =3D GET_CM_OBJECT_ID (CmObjDesc->ObjectId); + + switch (NameSpaceId) { + case EObjNameSpaceStandard: + if (ObjId >=3D EStdObjMax) { + ASSERT (0); + return; + } + ParserArray =3D &StdNamespaceObjectParser[ObjId]; + break; + case EObjNameSpaceArm: + if (ObjId >=3D EArmObjMax) { + ASSERT (0); + return; + } + ParserArray =3D &ArmNamespaceObjectParser[ObjId]; + break; + default: + // Not supported + ASSERT (0); + return; + } // switch + + ObjectCount =3D CmObjDesc->Count; + RemainingSize =3D CmObjDesc->Size; + + for (ObjIndex =3D 0; ObjIndex < ObjectCount; ObjIndex++) { + DEBUG (( + DEBUG_ERROR, + "\n%-*a [%d/%d]:\n", + OUTPUT_FIELD_COLUMN_WIDTH, + ParserArray->ObjectName, + ObjIndex + 1, + ObjectCount + )); + PrintCmObjDesc ( + CmObjDesc->Data, + ParserArray->Parser, + ParserArray->ItemCount, + &RemainingSize, + 1 + ); + } // for +} diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.h b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.h new file mode 100644 index 000000000000..e229df7095d9 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.h @@ -0,0 +1,73 @@ +/** @file + Configuration Manager Object parser. + + Copyright (c) 2021, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef CONFIGURATION_MANAGER_OBJECT_PARSER_H_ +#define CONFIGURATION_MANAGER_OBJECT_PARSER_H_ + +#define OUTPUT_FIELD_COLUMN_WIDTH 32 + +/** Function prototype to format a field print. + + @param [in] Format Format string for tracing the data as specified by + the 'Format' member of ACPI_PARSER. + @param [in] Ptr Pointer to the start of the buffer. +**/ +typedef VOID (EFIAPI *FNPTR_PRINT_FORMATTER)(CONST CHAR8* Format, UINT8* P= tr); + +/** + The CM_OBJ_PARSER structure describes the fields of an CmObject and + provides means for the parser to interpret and trace appropriately. + + ParseAcpi() uses the format string specified by 'Format' for tracing + the field data. +*/ +typedef struct CmObjParser CM_OBJ_PARSER; +struct CmObjParser { + + /// String describing the Cm Object + CONST CHAR8* NameStr; + + /// The length of the field. + UINT32 Length; + + /// Optional Print() style format string for tracing the data. If not + /// used this must be set to NULL. + CONST CHAR8* Format; + + /// Optional pointer to a print formatter function which + /// is typically used to trace complex field information. + /// If not used this must be set to NULL. + /// The Format string is passed to the PrintFormatter function + /// but may be ignored by the implementation code. + FNPTR_PRINT_FORMATTER PrintFormatter; + + /// Optional pointer to print the fields of another CM_OBJ_PARSER + /// structure. This is useful to print sub-structures. + CONST CM_OBJ_PARSER *SubObjParser; + + /// Count of items in the SubObj. + UINTN SubObjItemCount; +}; + +/** + A structure mapping an array of Configuration Manager Object parsers + with their object names. +*/ +typedef struct CmObjParserArray { + + /// Object name + CONST CHAR8 * ObjectName; + + /// Function pointer to the parser + CONST CM_OBJ_PARSER * Parser; + + /// Count of items + UINTN ItemCount; +} CM_OBJ_PARSER_ARRAY; + +#endif // CONFIGURATION_MANAGER_OBJECT_PARSER_H_ diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.= inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf index 5435f74aa0b8..abbf4bc38cab 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf @@ -15,6 +15,8 @@ [Defines] LIBRARY_CLASS =3D TableHelperLib =20 [Sources] + ConfigurationManagerObjectParser.c + ConfigurationManagerObjectParser.h TableHelper.c =20 [Packages] --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76935): https://edk2.groups.io/g/devel/message/76935 Mute This Topic: https://groups.io/mt/83735189/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76936+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76936+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446357; cv=none; d=zohomail.com; s=zohoarc; b=GoMJ43pG7I1GC/f2vZJU2Qu2v1zrSW3DoaQ7YSj4ofTbJ/iPtvlcK8+2L0g55FIF/xrNUQILGFydFN3sFFCa7sJ7sow3H08fyZFShSTe05ngmnJFMnsFyyGjNNEUBkaiAAy1tyKM0+OY4j1V4N3GySfDAAoGI5r+sdjIJJHMCfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446357; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=7WDr1UhBJjPtQ0V+8cL07kOskoK306I4Z33CFEiImHA=; b=flXyuvX9r0+PvF9+gAfFljpmgiO1TpSJUlDsDXgy7NCXe+5CkUOO3cXLFJnn4tJ12o5JPQxtUn02agjwnfQF1TucYU83XJSGSiXca+xFyWvI31WXnCtAwlJmfE4Wm+tWfwclgamZYnGj49Wyb5bxtKzujLISK1mLke2yWQ76Y5E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76936+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446357898174.34448866273215; Wed, 23 Jun 2021 04:05:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1rjcYY1788612xbadzvHGzZM; Wed, 23 Jun 2021 04:05:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.5911.1624446351402392408 for ; Wed, 23 Jun 2021 04:05:51 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08B421063; Wed, 23 Jun 2021 04:05:51 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1FC013F719; Wed, 23 Jun 2021 04:05:49 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 07/10] DynamicTablesPkg: Use %a formatter in AmlDbgPrint Date: Wed, 23 Jun 2021 12:05:21 +0100 Message-Id: <20210623110525.6171-8-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: KsV7pj8KvAOd25WYEACfNFatx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446357; bh=4a+SI/BuVG4t58rMT0ik/O9VKEvRW33bokFDUl/ih9M=; h=Date:From:Reply-To:Subject:To; b=oCn/cHN1chwlxxFDTVw4m9shlpTSqMfrIeG8SKQUNi2lZU0OeWzPEs3Nakt8N0N8lMI +8OGLwJbvWpVhGqutEeDI1UknsMCApt139YZGh7jfxttPBfXvBOPHgtRJ51kjmRYndvt5 qiUo0rlkxRqTTxAkN9xzI4FL6UR8vqyq/Yw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The correct formatter to print a CHAR8 char in edk2 is '%a'. Replace the '%s' formatters by '%a'. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Common/AmlLib/AmlDbgPrint/AmlDbgPrint.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlDbgPrint/AmlDbgPrint= .c b/DynamicTablesPkg/Library/Common/AmlLib/AmlDbgPrint/AmlDbgPrint.c index 00a61a2fe63a..7f4cd3404dbb 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/AmlDbgPrint/AmlDbgPrint.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlDbgPrint/AmlDbgPrint.c @@ -2,7 +2,7 @@ AML Print Function. =20 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
- Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -199,7 +199,7 @@ AmlDbgPrintNodeHeader ( =20 DEBUG (( DEBUG_INFO, - "%3d | %-15s | ", + "%3d | %-15a | ", Level, NodeTypeStrTbl[Node->NodeType] )); @@ -227,7 +227,7 @@ AmlDbgPrintDataNode ( =20 AmlDbgPrintNodeHeader ((AML_NODE_HEADER*)DataNode, Level); =20 - DEBUG ((DEBUG_INFO, "%-36s | ", NodeDataTypeStrTbl[DataNode->DataType])); + DEBUG ((DEBUG_INFO, "%-36a | ", NodeDataTypeStrTbl[DataNode->DataType])); DEBUG ((DEBUG_INFO, "0x%04x | ", DataNode->Size)); =20 if ((DataNode->DataType =3D=3D EAmlNodeDataTypeNameString) || @@ -300,13 +300,13 @@ AmlDbgPrintObjectNode ( =20 // Print a string corresponding to the field object OpCode/SubOpCode. if (AmlNodeHasAttribute (ObjectNode, AML_IS_FIELD_ELEMENT)) { - DEBUG ((DEBUG_INFO, "%-15s ", AmlGetFieldOpCodeStr ( + DEBUG ((DEBUG_INFO, "%-15a ", AmlGetFieldOpCodeStr ( ObjectNode->AmlByteEncoding->OpCode, 0 ))); } else { // Print a string corresponding to the object OpCode/SubOpCode. - DEBUG ((DEBUG_INFO, "%-15s | ", AmlGetOpCodeStr ( + DEBUG ((DEBUG_INFO, "%-15a | ", AmlGetOpCodeStr ( ObjectNode->AmlByteEncoding->OpCode, ObjectNode->AmlByteEncoding->SubOpCo= de) )); @@ -378,19 +378,19 @@ AmlDbgPrintTableHeader ( DEBUG ((DEBUG_INFO, "Lvl | Node Type |\n")); DEBUG (( DEBUG_INFO, - " | %-15s | Signature| Length | Rev | CSum | OemId | " + " | %-15a | Signature| Length | Rev | CSum | OemId | " "OemTableId | OemRev | CreatorId| CreatorRev\n", NodeTypeStrTbl[EAmlNodeRoot] )); DEBUG (( DEBUG_INFO, - " | %-15s | Op | SubOp| OpName | MaxI| Attribute | " + " | %-15a | Op | SubOp| OpName | MaxI| Attribute | " "PkgLen | NodeName (opt)\n", NodeTypeStrTbl[EAmlNodeObject] )); DEBUG (( DEBUG_INFO, - " | %-15s | Data Type | Size | " + " | %-15a | Data Type | Size | " "Buffer\n", NodeTypeStrTbl[EAmlNodeData] )); --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76936): https://edk2.groups.io/g/devel/message/76936 Mute This Topic: https://groups.io/mt/83735190/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76937+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76937+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446354; cv=none; d=zohomail.com; s=zohoarc; b=e6WZReJHlemJeQJyYasLXH0/Izx0Fzk5WuVsAnOKNgK+kwtrKWqS+hOcRGGisxpFydVX/NB7qJE3etGDaz2Y5Vo4qWXjuA3mlwKn0i2DTpF/khqGRZ5TKEh5eXExlrIHrrZjzK0PNXebXgAxWwAzKlJexOnpbdHVDdcsucm/4mA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446354; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=ZGkSX8a3QsqYYTrgZ2wxjdMd6gAyo6l5stxsEc7+h+Q=; b=VpOpMh+XOizheG0TW9y/D1oE4D5Aa+rti+YdJumC2O1dqnGa6u5M1G1MERizUZeapH12nKdpiiHGUkHlBENkv3uC2W7OhAFs4qJshkbsmuGsvEwe6SHtjuvYAjNs7UbKwcxr4JH+ZLuatrBcokqohR2Ib9G7fj5Anw6GcMTdNqY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76937+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446354255994.7078612395912; Wed, 23 Jun 2021 04:05:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ORknYY1788612xlMVLwQPWOi; Wed, 23 Jun 2021 04:05:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5937.1624446352805770123 for ; Wed, 23 Jun 2021 04:05:52 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 729D631B; Wed, 23 Jun 2021 04:05:52 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 67C5E3F719; Wed, 23 Jun 2021 04:05:51 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 08/10] DynamicTablesPkg: Update DynamicTablesPkg.ci.yaml Date: Wed, 23 Jun 2021 12:05:22 +0100 Message-Id: <20210623110525.6171-9-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 6ti6FihQWDarDbMGVTQfOb3ix1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446353; bh=sPEK0ILBGofNMZ/WgnfbVPkFhC5avZgb+Q144WD/844=; h=Date:From:Reply-To:Subject:To; b=AvNg1w1fAjH+EZWnzzaNZGP475Vl7vRSnEYNLv+abYb25XxwWnVisnXHjpplUK5Zpj7 oeuuZ6Z9ahbZ4UVqTcBiu32wO6/BGE+RhGo6jSnrgtkqepggVPAJ4SoR1B7OxpuegnMDL r7q2Kx/jB7/DhuCXQLF5VoMscTh3kCqckM8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois To prepare edk2 upstream CI for incoming modifications: 1- Disable the Ecc check 9005: "Only Doxygen commands '@bug', '@todo', [...], '@{', '@}' are allowed to mark the code Unknown doxygen command [...]" 2- Disable the Ecc check 8003 for the following keyword: "DISABLE_NEW_DEPRECATED_INTERFACES" Indeed, this error has been corrected on the latest version of BaseTools, but is still triggered when using the older python packages containing the BaseTools. 3- Add word exceptions for the cspell tool. Signed-off-by: Pierre Gondois --- DynamicTablesPkg/DynamicTablesPkg.ci.yaml | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml b/DynamicTablesPkg/D= ynamicTablesPkg.ci.yaml index 211615bc80e2..bfa282926e48 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.ci.yaml +++ b/DynamicTablesPkg/DynamicTablesPkg.ci.yaml @@ -5,6 +5,28 @@ # SPDX-License-Identifier: BSD-2-Clause-Patent ## { + "EccCheck": { + ## Exception sample looks like below: + ## "ExceptionList": [ + ## "", "" + ## ] + "ExceptionList": [ + # "The #ifndef at the start of an include file should use + # both prefix and postfix underscore characters, '_'" + # This error is not triggered for the latest BaseTools code. + # @TODO The error should be re-enabled when the python packages + # containing the BaseTools are updated to the latest version. + "8003", "DISABLE_NEW_DEPRECATED_INTERFACES", + "9005", "@defgroup", # Use extra Doxygen commands + "9005", "@ingroup", # Use extra Doxygen commands + "9005", "@mainpage", # Use extra Doxygen commands + "9005", "@ref", # Use extra Doxygen commands + ], + ## Both file path and directory path are accepted. + "IgnoreFiles": [ + ] + }, + ## options defined .pytool/Plugin/CompilerPlugin "CompilerPlugin": { "DscPath": "DynamicTablesPkg.dsc" @@ -23,6 +45,7 @@ ## options defined .pytool/Plugin/DependencyCheck "DependencyCheck": { "AcceptableDependencies": [ + "ArmPkg/ArmPkg.dec", "ArmPlatformPkg/ArmPlatformPkg.dec", "EmbeddedPkg/EmbeddedPkg.dec", "DynamicTablesPkg/DynamicTablesPkg.dec", @@ -77,19 +100,25 @@ "CCIDX", "CCSIDR", "countof", + "edynamic", "EOBJECT", "invoc", + "ITARGETSR", "GTBLOCK", "lgreater", "lless", "MPIDR", "PERIPHBASE", + "phandle", "pytool", + "Rdword", "Roadmap", "ROOTNODEBASE", "ssdtcmn", "ssdtserialporttemplate", "SMMUV", + "ssdtpcieosctemplate", + "SSDTPC", "standardised", "TABLEEX", "TNSID", --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76937): https://edk2.groups.io/g/devel/message/76937 Mute This Topic: https://groups.io/mt/83735191/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76938+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76938+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446360; cv=none; d=zohomail.com; s=zohoarc; b=NKfKzSy8C6P0uP+jBIc5PoDBeGRBSVhLIxkCbhRfQVOcdowciQldQthiy136ZgF0zbKT80SA2+E8w1AkB33c5jL2URpqUiHtyp8UyiErzA0zG+99t6QFlK6DfYW0a0THWxRqbU/+1gXn1kA0yUrbb1qDaYKiI5qrB6PZFmuZlJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446360; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=3QXU5jybDw8PAsPq3m2m7zm68XI3iyDHiTrNCkRm4qo=; b=Y32DiT6232FMPnpIWQBjN08OyVHtABzYyGCITEuXEE+xf+KAskwKxqPc9lRd0nUEOe5GdITkXl7ZoSnOHI6kjqeY6OiYJXgMYTrujmGqGoN8eN3V6InzevrluX1W6jtt9eKxKRbkdaptPRmVG/vAaIdC7UNLkiEF9emJ5YI5rfY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76938+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446360074671.8169153227884; Wed, 23 Jun 2021 04:06:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XC24YY1788612x9ZqrzKAmEz; Wed, 23 Jun 2021 04:05:59 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.5938.1624446354038169996 for ; Wed, 23 Jun 2021 04:05:54 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B523731B; Wed, 23 Jun 2021 04:05:53 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D1B9E3F719; Wed, 23 Jun 2021 04:05:52 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 09/10] DynamicTablesPkg: Deprecate Crs specific methods in AmlLib Date: Wed, 23 Jun 2021 12:05:23 +0100 Message-Id: <20210623110525.6171-10-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: eI62n2FognJweWpfJMrIjrwGx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446359; bh=b6vv2Q1pljh1ms5fe5ZucQVGZFEURuiNBxLzIgZwdtY=; h=Date:From:Reply-To:Subject:To; b=rAzq3xxuH+QovngwyXT5VdrjB/oHO/5bW4b/AA5vi37ltHQsRGw/sMJfhCwOfe/awfJ tJdvPXSG071QNoT3s/bRQc9iTkq7yQiJCvkzKW1qaD3TPi7/RhnAEvu4sGz8nhfcTi3/n hVQ88zkyjaGgBkWC5MWSKmwdPE2loo4NeG8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Some functions in the AmlLib have 'Crs' in their name and can only be applied to '_CRS' AML objects. To re-use them on AML objects that have different names: - Rename them and remove the '_CRS' name check. - Create aliases having of the 'Crs' function prototypes. These aliases are available when DISABLE_NEW_DEPRECATED_INTERFACES is not defined. They will be deprecated in a near future. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AmlLib/AmlLib.h | 189 +++++++++++++++--- .../SsdtCmn600Generator.c | 6 +- .../Library/Common/AmlLib/Api/AmlApi.c | 147 +++++++++++--- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 105 ++++++++-- .../SsdtSerialPortFixupLib.c | 4 +- 5 files changed, 371 insertions(+), 80 deletions(-) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 1dcb93861436..c40808343fce 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1,7 +1,7 @@ /** @file AML Lib. =20 - Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -301,7 +301,7 @@ AmlNameOpUpdateString ( IN CONST CHAR8 * NewName ); =20 -/** Get the first Resource Data element contained in a "_CRS" object. +/** Get the first Resource Data element contained in a named object. =20 In the following ASL code, the function will return the Resource Data node corresponding to the "QWordMemory ()" ASL macro. @@ -312,27 +312,26 @@ AmlNameOpUpdateString ( ) =20 Note: - - The "_CRS" object must be declared using ASL "Name (Declare Named Obj= ect)". - - "_CRS" declared using ASL "Method (Declare Control Method)" is not - supported. + "_CRS" names defined as methods are not handled by this function. + They must be defined as names, using the "Name ()" statement. =20 @ingroup UserApis =20 - @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object. - Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. - NameOp object nodes are defined in ASL - using the "Name ()" function. - @param [out] OutRdNode Pointer to the first Resource Data element of - the "_CRS" object. A Resource Data element - is stored in a data node. + @param [in] NameOpNode NameOp object node defining a named object. + Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [out] OutRdNode Pointer to the first Resource Data element of + the named object. A Resource Data element + is stored in a data node. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. **/ EFI_STATUS EFIAPI -AmlNameOpCrsGetFirstRdNode ( - IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, +AmlNameOpGetFirstRdNode ( + IN AML_OBJECT_NODE_HANDLE NameOpNode, OUT AML_DATA_NODE_HANDLE * OutRdNode ); =20 @@ -347,13 +346,14 @@ AmlNameOpCrsGetFirstRdNode ( } ) =20 - The CurrRdNode Resource Data node must be defined in an object named "_C= RS" - and defined by a "Name ()" ASL function. + Note: + "_CRS" names defined as methods are not handled by this function. + They must be defined as names, using the "Name ()" statement. =20 @ingroup UserApis =20 @param [in] CurrRdNode Pointer to the current Resource Data element = of - the "_CRS" variable. + the named object. @param [out] OutRdNode Pointer to the Resource Data element following the CurrRdNode. Contain a NULL pointer if CurrRdNode is the @@ -366,7 +366,7 @@ AmlNameOpCrsGetFirstRdNode ( **/ EFI_STATUS EFIAPI -AmlNameOpCrsGetNextRdNode ( +AmlNameOpGetNextRdNode ( IN AML_DATA_NODE_HANDLE CurrRdNode, OUT AML_DATA_NODE_HANDLE * OutRdNode ); @@ -423,7 +423,7 @@ AmlUpdateRdQWord ( This function creates a Resource Data element corresponding to the "Interrupt ()" ASL function, stores it in an AML Data Node. =20 - It then adds it after the input CurrRdNode in the list of resource data + It then adds it after the input NameOpNode in the list of resource data element. =20 The Resource Data effectively created is an Extended Interrupt Resource @@ -437,14 +437,9 @@ AmlUpdateRdQWord ( - attach this node to an AML tree; - delete this node. =20 - Note: The _CRS node must be defined using the ASL Name () function. - e.g. Name (_CRS, ResourceTemplate () { - ... - } + @ingroup CodeGenApis =20 - @ingroup UserApis - - @param [in] NameOpCrsNode NameOp object node defining a "_CRS" obje= ct. + @param [in] NameOpNode NameOp object node defining a named objec= t. Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. NameOp object nodes are defined in ASL using the "Name ()" function. @@ -465,8 +460,8 @@ AmlUpdateRdQWord ( **/ EFI_STATUS EFIAPI -AmlCodeGenCrsAddRdInterrupt ( - IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, +AmlCodeGenAddRdInterrupt ( + IN AML_OBJECT_NODE_HANDLE NameOpNode, IN BOOLEAN ResourceConsumer, IN BOOLEAN EdgeTriggered, IN BOOLEAN ActiveLow, @@ -628,4 +623,142 @@ AmlCodeGenScope ( OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL ); =20 +// DEPRECATED APIS +#ifndef DISABLE_NEW_DEPRECATED_INTERFACES + +/** DEPRECATED API + + Get the first Resource Data element contained in a "_CRS" object. + + In the following ASL code, the function will return the Resource Data + node corresponding to the "QWordMemory ()" ASL macro. + Name (_CRS, ResourceTemplate() { + QWordMemory (...) {...}, + Interrupt (...) {...} + } + ) + + Note: + - The "_CRS" object must be declared using ASL "Name (Declare Named Obj= ect)". + - "_CRS" declared using ASL "Method (Declare Control Method)" is not + supported. + + @ingroup UserApis + + @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object. + Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [out] OutRdNode Pointer to the first Resource Data element of + the "_CRS" object. A Resource Data element + is stored in a data node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlNameOpCrsGetFirstRdNode ( + IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, + OUT AML_DATA_NODE_HANDLE * OutRdNode + ); + +/** DEPRECATED API + + Get the Resource Data element following the CurrRdNode Resource Data. + + In the following ASL code, if CurrRdNode corresponds to the first + "QWordMemory ()" ASL macro, the function will return the Resource Data + node corresponding to the "Interrupt ()" ASL macro. + Name (_CRS, ResourceTemplate() { + QwordMemory (...) {...}, + Interrupt (...) {...} + } + ) + + The CurrRdNode Resource Data node must be defined in an object named "_C= RS" + and defined by a "Name ()" ASL function. + + @ingroup UserApis + + @param [in] CurrRdNode Pointer to the current Resource Data element = of + the "_CRS" variable. + @param [out] OutRdNode Pointer to the Resource Data element following + the CurrRdNode. + Contain a NULL pointer if CurrRdNode is the + last Resource Data element in the list. + The "End Tag" is not considered as a resource + data element and is not returned. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlNameOpCrsGetNextRdNode ( + IN AML_DATA_NODE_HANDLE CurrRdNode, + OUT AML_DATA_NODE_HANDLE * OutRdNode + ); + +/** DEPRECATED API + + Add an Interrupt Resource Data node. + + This function creates a Resource Data element corresponding to the + "Interrupt ()" ASL function, stores it in an AML Data Node. + + It then adds it after the input CurrRdNode in the list of resource data + element. + + The Resource Data effectively created is an Extended Interrupt Resource + Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" + for more information about Extended Interrupt Resource Data. + + The Extended Interrupt contains one single interrupt. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + Note: The _CRS node must be defined using the ASL Name () function. + e.g. Name (_CRS, ResourceTemplate () { + ... + } + + @ingroup CodeGenApis + + @param [in] NameOpCrsNode NameOp object node defining a "_CRS" obje= ct. + Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [in] ResourceConsumer The device consumes the specified interru= pt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-lo= w. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenCrsAddRdInterrupt ( + IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 * IrqList, + IN UINT8 IrqCount + ); + +#endif // DISABLE_NEW_DEPRECATED_INTERFACES + #endif // AML_LIB_H_ diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn= 600Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/Ssd= tCmn600Generator.c index cc730cd90fea..fb93a5d2e70c 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c @@ -286,7 +286,7 @@ FixupCmn600Info ( =20 // Get the first Rd node in the "_CRS" object. // This is the PERIPHBASE node. - Status =3D AmlNameOpCrsGetFirstRdNode (NameOpCrsNode, &CmnPeriphBaseRdNo= de); + Status =3D AmlNameOpGetFirstRdNode (NameOpCrsNode, &CmnPeriphBaseRdNode); if (EFI_ERROR (Status)) { goto error_handler; } @@ -309,7 +309,7 @@ FixupCmn600Info ( // Get the QWord node corresponding to the ROOTNODEBASE. // It is the second Resource Data element in the BufferNode's // variable list of arguments. - Status =3D AmlNameOpCrsGetNextRdNode ( + Status =3D AmlNameOpGetNextRdNode ( CmnPeriphBaseRdNode, &CmnRootNodeBaseRdNode ); @@ -338,7 +338,7 @@ FixupCmn600Info ( // Resource Data nodes. for (Index =3D 0; Index < Cmn600Info->DtcCount; Index++) { DtcInt =3D &Cmn600Info->DtcInterrupt[Index]; - Status =3D AmlCodeGenCrsAddRdInterrupt ( + Status =3D AmlCodeGenAddRdInterrupt ( NameOpCrsNode, ((DtcInt->Flags & EFI_ACPI_EXTENDED_INTERRUPT_FLAG_PRODUCER_CONSUMER_MASK) = !=3D 0), diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c b/DynamicT= ablesPkg/Library/Common/AmlLib/Api/AmlApi.c index fdf04acc6212..6f9e3f6f2805 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c @@ -1,7 +1,7 @@ /** @file AML Api. =20 - Copyright (c) 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -222,7 +222,7 @@ AmlNameOpUpdateString ( return Status; } =20 -/** Get the first Resource Data element contained in a "_CRS" object. +/** Get the first Resource Data element contained in a named object. =20 In the following ASL code, the function will return the Resource Data node corresponding to the "QWordMemory ()" ASL macro. @@ -233,35 +233,33 @@ AmlNameOpUpdateString ( ) =20 Note: - - The "_CRS" object must be declared using ASL "Name (Declare Named Obj= ect)". - - "_CRS" declared using ASL "Method (Declare Control Method)" is not - supported. + "_CRS" names defined as methods are not handled by this function. + They must be defined as names, using the "Name ()" statement. =20 - @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object. - Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. - NameOp object nodes are defined in ASL - using the "Name ()" function. - @param [out] OutRdNode Pointer to the first Resource Data element of - the "_CRS" object. A Resource Data element - is stored in a data node. + @param [in] NameOpNode NameOp object node defining a named object. + Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [out] OutRdNode Pointer to the first Resource Data element of + the named object. A Resource Data element + is stored in a data node. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. **/ EFI_STATUS EFIAPI -AmlNameOpCrsGetFirstRdNode ( - IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, +AmlNameOpGetFirstRdNode ( + IN AML_OBJECT_NODE_HANDLE NameOpNode, OUT AML_DATA_NODE_HANDLE * OutRdNode ) { AML_OBJECT_NODE_HANDLE BufferOpNode; AML_DATA_NODE_HANDLE FirstRdNode; =20 - if ((NameOpCrsNode =3D=3D NULL) = || - (AmlGetNodeType ((AML_NODE_HANDLE)NameOpCrsNode) !=3D EAmlNodeObject= ) || - (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0)) = || - (!AmlNameOpCompareName (NameOpCrsNode, "_CRS")) = || + if ((NameOpNode =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)NameOpNode) !=3D EAmlNodeObject) = || + (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0)) || (OutRdNode =3D=3D NULL)) { ASSERT (0); return EFI_INVALID_PARAMETER; @@ -269,10 +267,10 @@ AmlNameOpCrsGetFirstRdNode ( =20 *OutRdNode =3D NULL; =20 - // Get the _CRS value which is represented as a BufferOp object node - // which is the 2nd fixed argument (i.e. index 1). + // Get the value of the variable which is represented as a BufferOp obje= ct + // node which is the 2nd fixed argument (i.e. index 1). BufferOpNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( - NameOpCrsNode, + NameOpNode, EAmlParseIndexTerm1 ); if ((BufferOpNode =3D=3D NULL) = || @@ -310,11 +308,12 @@ AmlNameOpCrsGetFirstRdNode ( } ) =20 - The CurrRdNode Resource Data node must be defined in an object named "_C= RS" - and defined by a "Name ()" ASL function. + Note: + "_CRS" names defined as methods are not handled by this function. + They must be defined as names, using the "Name ()" statement. =20 @param [in] CurrRdNode Pointer to the current Resource Data element = of - the "_CRS" object. + the named object. @param [out] OutRdNode Pointer to the Resource Data element following the CurrRdNode. Contain a NULL pointer if CurrRdNode is the @@ -327,12 +326,12 @@ AmlNameOpCrsGetFirstRdNode ( **/ EFI_STATUS EFIAPI -AmlNameOpCrsGetNextRdNode ( +AmlNameOpGetNextRdNode ( IN AML_DATA_NODE_HANDLE CurrRdNode, OUT AML_DATA_NODE_HANDLE * OutRdNode ) { - AML_OBJECT_NODE_HANDLE NameOpCrsNode; + AML_OBJECT_NODE_HANDLE NameOpNode; AML_OBJECT_NODE_HANDLE BufferOpNode; =20 if ((CurrRdNode =3D=3D NULL) = || @@ -356,12 +355,11 @@ AmlNameOpCrsGetNextRdNode ( } =20 // The parent of the BufferOpNode must be a NameOp node. - NameOpCrsNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetParent ( - (AML_NODE_HANDLE)BufferOpNode - ); - if ((NameOpCrsNode =3D=3D NULL) || - (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0)) || - (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))) { + NameOpNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetParent ( + (AML_NODE_HANDLE)BufferOpNode + ); + if ((NameOpNode =3D=3D NULL) || + (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))) { ASSERT (0); return EFI_INVALID_PARAMETER; } @@ -380,3 +378,88 @@ AmlNameOpCrsGetNextRdNode ( =20 return EFI_SUCCESS; } + +// DEPRECATED APIS +#ifndef DISABLE_NEW_DEPRECATED_INTERFACES + +/** DEPRECATED API + + Get the first Resource Data element contained in a "_CRS" object. + + In the following ASL code, the function will return the Resource Data + node corresponding to the "QWordMemory ()" ASL macro. + Name (_CRS, ResourceTemplate() { + QWordMemory (...) {...}, + Interrupt (...) {...} + } + ) + + Note: + - The "_CRS" object must be declared using ASL "Name (Declare Named Obj= ect)". + - "_CRS" declared using ASL "Method (Declare Control Method)" is not + supported. + + @ingroup UserApis + + @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object. + Must have an OpCode=3DAML_NAME_OP, SubOpCode= =3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [out] OutRdNode Pointer to the first Resource Data element of + the "_CRS" object. A Resource Data element + is stored in a data node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlNameOpCrsGetFirstRdNode ( + IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, + OUT AML_DATA_NODE_HANDLE * OutRdNode + ) +{ + return AmlNameOpGetFirstRdNode (NameOpCrsNode, OutRdNode); +} + +/** DEPRECATED API + + Get the Resource Data element following the CurrRdNode Resource Data. + + In the following ASL code, if CurrRdNode corresponds to the first + "QWordMemory ()" ASL macro, the function will return the Resource Data + node corresponding to the "Interrupt ()" ASL macro. + Name (_CRS, ResourceTemplate() { + QwordMemory (...) {...}, + Interrupt (...) {...} + } + ) + + The CurrRdNode Resource Data node must be defined in an object named "_C= RS" + and defined by a "Name ()" ASL function. + + @ingroup UserApis + + @param [in] CurrRdNode Pointer to the current Resource Data element = of + the "_CRS" variable. + @param [out] OutRdNode Pointer to the Resource Data element following + the CurrRdNode. + Contain a NULL pointer if CurrRdNode is the + last Resource Data element in the list. + The "End Tag" is not considered as a resource + data element and is not returned. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlNameOpCrsGetNextRdNode ( + IN AML_DATA_NODE_HANDLE CurrRdNode, + OUT AML_DATA_NODE_HANDLE * OutRdNode + ) +{ + return AmlNameOpGetNextRdNode (CurrRdNode, OutRdNode); +} + +#endif // DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index d40a27410dd6..c7348aa5daf7 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -1,7 +1,7 @@ /** @file AML Resource Data Code Generation. =20 - Copyright (c) 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -161,7 +161,7 @@ AmlCodeGenInterrupt ( This function creates a Resource Data element corresponding to the "Interrupt ()" ASL function, stores it in an AML Data Node. =20 - It then adds it after the input CurrRdNode in the list of resource data + It then adds it after the input NameOpNode in the list of resource data element. =20 The Resource Data effectively created is an Extended Interrupt Resource @@ -175,12 +175,12 @@ AmlCodeGenInterrupt ( - attach this node to an AML tree; - delete this node. =20 - Note: The _CRS node must be defined using the ASL Name () function. - e.g. Name (_CRS, ResourceTemplate () { - ... - } + Note: + The named node must be defined using the ASL "Name ()" statement. + E.g. Name (_CRS, ResourceTemplate () { ... }) + Methods cannot be modified with this function. =20 - @param [in] NameOpCrsNode NameOp object node defining a "_CRS" obje= ct. + @param [in] NameOpNode NameOp object node defining a named objec= t. Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. NameOp object nodes are defined in ASL using the "Name ()" function. @@ -201,8 +201,8 @@ AmlCodeGenInterrupt ( **/ EFI_STATUS EFIAPI -AmlCodeGenCrsAddRdInterrupt ( - IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, +AmlCodeGenAddRdInterrupt ( + IN AML_OBJECT_NODE_HANDLE NameOpNode, IN BOOLEAN ResourceConsumer, IN BOOLEAN EdgeTriggered, IN BOOLEAN ActiveLow, @@ -215,18 +215,17 @@ AmlCodeGenCrsAddRdInterrupt ( =20 AML_OBJECT_NODE_HANDLE BufferOpNode; =20 - if ((IrqList =3D=3D NULL) = || - (IrqCount =3D=3D 0) = || - (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0)) = || - (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))) { + if ((IrqList =3D=3D NULL) || + (IrqCount =3D=3D 0) || + (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))) { ASSERT (0); return EFI_INVALID_PARAMETER; } =20 - // Get the _CRS value which is represented as a BufferOp object node + // Get the value which is represented as a BufferOp object node // which is the 2nd fixed argument (i.e. index 1). BufferOpNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( - NameOpCrsNode, + NameOpNode, EAmlParseIndexTerm1 ); if ((BufferOpNode =3D=3D NULL) = || @@ -254,3 +253,79 @@ AmlCodeGenCrsAddRdInterrupt ( =20 return Status; } + +// DEPRECATED APIS +#ifndef DISABLE_NEW_DEPRECATED_INTERFACES + +/** DEPRECATED API + + Add an Interrupt Resource Data node. + + This function creates a Resource Data element corresponding to the + "Interrupt ()" ASL function, stores it in an AML Data Node. + + It then adds it after the input CurrRdNode in the list of resource data + element. + + The Resource Data effectively created is an Extended Interrupt Resource + Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" + for more information about Extended Interrupt Resource Data. + + The Extended Interrupt contains one single interrupt. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + Note: The _CRS node must be defined using the ASL Name () function. + e.g. Name (_CRS, ResourceTemplate () { + ... + } + + @ingroup UserApis + + @param [in] NameOpCrsNode NameOp object node defining a "_CRS" obje= ct. + Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [in] ResourceConsumer The device consumes the specified interru= pt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-lo= w. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenCrsAddRdInterrupt ( + IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 * IrqList, + IN UINT8 IrqCount + ) +{ + return AmlCodeGenAddRdInterrupt ( + NameOpCrsNode, + NameOpNode, + ResourceConsumer, + EdgeTriggered, + ActiveLow, + Shared, + IrqList, + IrqCount + ); +} + +#endif // DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/= SsdtSerialPortFixupLib.c index 8c77f172b795..6966410b2c34 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c @@ -275,7 +275,7 @@ FixupCrs ( } =20 // Get the first Rd node in the "_CRS" object. - Status =3D AmlNameOpCrsGetFirstRdNode (NameOpCrsNode, &QWordRdNode); + Status =3D AmlNameOpGetFirstRdNode (NameOpCrsNode, &QWordRdNode); if (EFI_ERROR (Status)) { return Status; } @@ -298,7 +298,7 @@ FixupCrs ( // Get the Interrupt node. // It is the second Resource Data element in the NameOpCrsNode's // variable list of arguments. - Status =3D AmlNameOpCrsGetNextRdNode (QWordRdNode, &InterruptRdNode); + Status =3D AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode); if (EFI_ERROR (Status)) { return Status; } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76938): https://edk2.groups.io/g/devel/message/76938 Mute This Topic: https://groups.io/mt/83735192/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:09:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+76939+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76939+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624446358; cv=none; d=zohomail.com; s=zohoarc; b=n57yqwAS6SEx2j/S3+fbDRGgqTozkMl4pCZ2M4Sb+amL984pnFLbKgUQKMP7umEN765R/7LDdH0pqt0V2PLibL+ERR7o+HOxEbF2nFd2zGQd0G59XxYBzC7gSFrYhbl0yn/wQ0g5jrYlqV0YxgzgILTjXy2OkSMIVYD295xQJ4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624446358; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=sm9wLv79xw/U71wZ11klfZLl8IRihca7loZCnXfKRjw=; b=BO9nPcg8t9VBMEhAujOrzTIAh4cvsAVnKMCQkBzcFTYonWfzbx9a2a2VcTYvzDCk53fPdV8oykLlF4Wz9Pf230sjNWz5dC0JmQknmKhJ8voelE9bvXtQRI1qZbapFVj9B1rJhBIwNccRutf71pghoqi6eqHtK/9wb2/n5f4tXdo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+76939+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1624446358399784.4170096090368; Wed, 23 Jun 2021 04:05:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SJHZYY1788612xkBmYsZfFpB; Wed, 23 Jun 2021 04:05:56 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.6096.1624446355244172115 for ; Wed, 23 Jun 2021 04:05:55 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E28031063; Wed, 23 Jun 2021 04:05:54 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F26E43F719; Wed, 23 Jun 2021 04:05:53 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v1 10/10] DynamicTablesPkg: Rework AmlResourceDataCodegen.c/h Date: Wed, 23 Jun 2021 12:05:24 +0100 Message-Id: <20210623110525.6171-11-Pierre.Gondois@arm.com> In-Reply-To: <20210623110525.6171-1-Pierre.Gondois@arm.com> References: <20210623110525.6171-1-Pierre.Gondois@arm.com> Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: Dy09J9RGYEM2Y6HIBKij1SdXx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624446356; bh=ugHuKiENUDCKhV8ToAD08fBGLsgXR1jHvh11zyQ3B6Y=; h=Date:From:Reply-To:Subject:To; b=t+BQivzbVTdruVWHGKq2fR96APfSjddZEr/G8xJ4SKKTIfqrP3BIXVb/SaGF1u6GNPZ Jw4OMuCYytAnfR4htK1Oph2eo9UJstKZQKGtDLcdedKVwBWIdRIdlu1rt9qGjfJ3bJ0JT NTIEjKKJCasg2FVIUUIFoBreuPgxclnxuts= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Rework all the functions to to have a generic prototype: - First take take the resource data specific arguments. E.g.: for a Register(): the AddressSpace, BitWidth, ... - The penultimate parameter is a NameOpNode. The resource data created is appended to the ResourceTemplate() contained in the NameOpNode. - The last parameter is a pointer holding the created resource data. A least one of the two last parameter must be provided. One of them can be omitted. This generic interface allows to either: - Add the resource data to a NameOpNode. This is a common case for the Ssdt tables generator. - Get the created resource data and let the caller place it in an AML tree. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AmlLib/AmlLib.h | 60 +++-- .../SsdtCmn600Generator.c | 8 +- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 235 +++++++----------- .../AmlLib/CodeGen/AmlResourceDataCodeGen.h | 67 +++-- 4 files changed, 150 insertions(+), 220 deletions(-) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index c40808343fce..6824cf3a6c82 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -418,41 +418,36 @@ AmlUpdateRdQWord ( IN UINT64 BaseAddressLength ); =20 -/** Add an Interrupt Resource Data node. - - This function creates a Resource Data element corresponding to the - "Interrupt ()" ASL function, stores it in an AML Data Node. - - It then adds it after the input NameOpNode in the list of resource data - element. +/** Code generation for the "Interrupt ()" ASL function. =20 The Resource Data effectively created is an Extended Interrupt Resource - Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" - for more information about Extended Interrupt Resource Data. + Data. Cf ACPI 6.4: + - s6.4.3.6 "Extended Interrupt Descriptor" + - s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)" =20 - The Extended Interrupt contains one single interrupt. - - This function allocates memory to create a data node. It is the caller's - responsibility to either: - - attach this node to an AML tree; - - delete this node. + The created resource data node can be: + - appended to the list of resource data elements of the NameOpNode. + In such case NameOpNode must be defined by a the "Name ()" ASL statem= ent + and initially contain a "ResourceTemplate ()". + - returned through the NewRdNode parameter. =20 @ingroup CodeGenApis =20 + @param [in] ResourceConsumer The device consumes the specified interru= pt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-lo= w. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. @param [in] NameOpNode NameOp object node defining a named objec= t. - Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. - NameOp object nodes are defined in ASL - using the "Name ()" function. - @param [in] ResourceConsumer The device consumes the specified interru= pt - or produces it for use by a child device. - @param [in] EdgeTriggered The interrupt is edge triggered or - level triggered. - @param [in] ActiveLow The interrupt is active-high or active-lo= w. - @param [in] Shared The interrupt can be shared with other - devices or not (Exclusive). - @param [in] IrqList Interrupt list. Must be non-NULL. - @param [in] IrqCount Interrupt count. Must be non-zero. - + If provided, append the new resource data= node + to the list of resource data elements of = this + node. + @param [out] NewRdNode If provided and success, + contain the created node. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -460,14 +455,15 @@ AmlUpdateRdQWord ( **/ EFI_STATUS EFIAPI -AmlCodeGenAddRdInterrupt ( - IN AML_OBJECT_NODE_HANDLE NameOpNode, +AmlCodeGenRdInterrupt ( IN BOOLEAN ResourceConsumer, IN BOOLEAN EdgeTriggered, IN BOOLEAN ActiveLow, IN BOOLEAN Shared, - IN UINT32 * IrqList, - IN UINT8 IrqCount + IN UINT32 *IrqList, + IN UINT8 IrqCount, + IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL + OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ); =20 /** AML code generation for DefinitionBlock. diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn= 600Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/Ssd= tCmn600Generator.c index fb93a5d2e70c..19b7b128a08d 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c @@ -338,8 +338,8 @@ FixupCmn600Info ( // Resource Data nodes. for (Index =3D 0; Index < Cmn600Info->DtcCount; Index++) { DtcInt =3D &Cmn600Info->DtcInterrupt[Index]; - Status =3D AmlCodeGenAddRdInterrupt ( - NameOpCrsNode, + + Status =3D AmlCodeGenRdInterrupt ( ((DtcInt->Flags & EFI_ACPI_EXTENDED_INTERRUPT_FLAG_PRODUCER_CONSUMER_MASK) = !=3D 0), ((DtcInt->Flags & @@ -349,7 +349,9 @@ FixupCmn600Info ( ((DtcInt->Flags & EFI_ACPI_EXTENDED_INTERRUPT_FLAG_SHARABLE_MASK) !=3D 0), (UINT32*)&DtcInt->Interrupt, - 1 + 1, + NameOpCrsNode, + NULL ); if (EFI_ERROR (Status)) { goto error_handler; diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index c7348aa5daf7..089597a6c906 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -24,11 +24,15 @@ If NewRdNode is not NULL, update its value to RdNode. =20 @param [in] RdNode Newly created Resource Data node. - @param [in] ParentNode If not NULL, add the generated node - to the end of the variable list of - argument of the ParentNode, but - before the "End Tag" Resource Data. - Must be a BufferOpNode. + RdNode is deleted if an error occurs. + @param [in] ParentNode If not NULL, ParentNode must: + - be a NameOp node, i.e. have the AML_NAME_OP + opcode (cf "Name ()" ASL statement) + - contain a list of resource data elements + (cf "ResourceTemplate ()" ASL statement) + RdNode is then added at the end of the variable + list of resource data elements, but before the + "End Tag" Resource Data. @param [out] NewRdNode If not NULL, update the its value to RdNode. =20 @retval EFI_SUCCESS The function completed successfully. @@ -43,57 +47,81 @@ LinkRdNode ( OUT AML_DATA_NODE ** NewRdNode ) { - EFI_STATUS Status; - EFI_STATUS Status1; + EFI_STATUS Status; + EFI_STATUS Status1; + AML_OBJECT_NODE *BufferOpNode; =20 if (NewRdNode !=3D NULL) { *NewRdNode =3D RdNode; } =20 - // Add RdNode as the last element, but before the EndTag. if (ParentNode !=3D NULL) { - Status =3D AmlAppendRdNode (ParentNode, RdNode); + // Check this is a NameOp node. + if ((!AmlNodeHasOpCode (ParentNode, AML_NAME_OP, 0))) { + ASSERT (0); + Status =3D EFI_INVALID_PARAMETER; + goto error_handler; + } + + // Get the value which is represented as a BufferOp object node + // which is the 2nd fixed argument (i.e. index 1). + BufferOpNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + ParentNode, + EAmlParseIndexTerm1 + ); + if ((BufferOpNode =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)BufferOpNode) !=3D EAmlNodeObjec= t) || + (!AmlNodeHasOpCode (BufferOpNode, AML_BUFFER_OP, 0))) { + ASSERT (0); + Status =3D EFI_INVALID_PARAMETER; + goto error_handler; + } + + // Add RdNode as the last element, but before the EndTag. + Status =3D AmlAppendRdNode (BufferOpNode, RdNode); if (EFI_ERROR (Status)) { ASSERT (0); - Status1 =3D AmlDeleteTree ((AML_NODE_HEADER*)RdNode); - ASSERT_EFI_ERROR (Status1); - // Return original error. - return Status; + goto error_handler; } } =20 - return EFI_SUCCESS; + return Status; + +error_handler: + Status1 =3D AmlDeleteTree ((AML_NODE_HEADER*)RdNode); + ASSERT_EFI_ERROR (Status1); + // Return original error. + return Status; } =20 /** Code generation for the "Interrupt ()" ASL function. =20 - This function creates a Resource Data element corresponding to the - "Interrupt ()" ASL function and stores it in an AML Data Node. - The Resource Data effectively created is an Extended Interrupt Resource - Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" - for more information about Extended Interrupt Resource Data. + Data. Cf ACPI 6.4: + - s6.4.3.6 "Extended Interrupt Descriptor" + - s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)" =20 - This function allocates memory to create a data node. It is the caller's - responsibility to either: - - attach this node to an AML tree; - - delete this node. + The created resource data node can be: + - appended to the list of resource data elements of the NameOpNode. + In such case NameOpNode must be defined by a the "Name ()" ASL statem= ent + and initially contain a "ResourceTemplate ()". + - returned through the NewRdNode parameter. =20 - @param [in] ResourceConsumer The device consumes the specified inter= rupt - or produces it for use by a child devic= e. - @param [in] EdgeTriggered The interrupt is edge triggered or - level triggered. - @param [in] ActiveLow The interrupt is active-high or active-= low. - @param [in] Shared The interrupt can be shared with other - devices or not (Exclusive). - @param [in] IrqList Interrupt list. Must be non-NULL. - @param [in] IrqCount Interrupt count. Must be non-zero. - @param [in] ParentNode If not NULL, add the generated node - to the end of the variable list of - argument of the ParentNode, but - before the "End Tag" Resource Data. - Must be a BufferOpNode. - @param [out] NewRdNode If success, contains the generated node. + @param [in] ResourceConsumer The device consumes the specified interru= pt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-lo= w. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + @param [in] NameOpNode NameOp object node defining a named objec= t. + If provided, append the new resource data= node + to the list of resource data elements of = this + node. + @param [out] NewRdNode If provided and success, + contain the created node. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -101,15 +129,15 @@ LinkRdNode ( **/ EFI_STATUS EFIAPI -AmlCodeGenInterrupt ( - IN BOOLEAN ResourceConsumer, - IN BOOLEAN EdgeTriggered, - IN BOOLEAN ActiveLow, - IN BOOLEAN Shared, - IN UINT32 * IrqList, - IN UINT8 IrqCount, - IN AML_OBJECT_NODE * ParentNode, OPTIONAL - OUT AML_DATA_NODE ** NewRdNode OPTIONAL +AmlCodeGenRdInterrupt ( + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 *IrqList, + IN UINT8 IrqCount, + IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL + OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ) { EFI_STATUS Status; @@ -120,16 +148,19 @@ AmlCodeGenInterrupt ( =20 if ((IrqList =3D=3D NULL) || (IrqCount =3D=3D 0) || - ((ParentNode =3D=3D NULL) && (NewRdNode =3D=3D NULL))) { + ((NameOpNode =3D=3D NULL) && (NewRdNode =3D=3D NULL))) { ASSERT (0); return EFI_INVALID_PARAMETER; } =20 + // Header RdInterrupt.Header.Header.Bits.Name =3D ACPI_LARGE_EXTENDED_IRQ_DESCRIPTOR_NAME; RdInterrupt.Header.Header.Bits.Type =3D ACPI_LARGE_ITEM_FLAG; RdInterrupt.Header.Length =3D sizeof (EFI_ACPI_EXTENDED_INTERRUPT_DESCRI= PTOR) - sizeof (ACPI_LARGE_RESOURCE_HEADER); + + // Body RdInterrupt.InterruptVectorFlags =3D (ResourceConsumer ? BIT0 : 0) | (EdgeTriggered ? BIT1 : 0) | (ActiveLow ? BIT2 : 0) | @@ -153,105 +184,7 @@ AmlCodeGenInterrupt ( return Status; } =20 - return LinkRdNode (RdNode, ParentNode, NewRdNode); -} - -/** Add an Interrupt Resource Data node. - - This function creates a Resource Data element corresponding to the - "Interrupt ()" ASL function, stores it in an AML Data Node. - - It then adds it after the input NameOpNode in the list of resource data - element. - - The Resource Data effectively created is an Extended Interrupt Resource - Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" - for more information about Extended Interrupt Resource Data. - - The Extended Interrupt contains one single interrupt. - - This function allocates memory to create a data node. It is the caller's - responsibility to either: - - attach this node to an AML tree; - - delete this node. - - Note: - The named node must be defined using the ASL "Name ()" statement. - E.g. Name (_CRS, ResourceTemplate () { ... }) - Methods cannot be modified with this function. - - @param [in] NameOpNode NameOp object node defining a named objec= t. - Must have an OpCode=3DAML_NAME_OP, SubOpC= ode=3D0. - NameOp object nodes are defined in ASL - using the "Name ()" function. - @param [in] ResourceConsumer The device consumes the specified interru= pt - or produces it for use by a child device. - @param [in] EdgeTriggered The interrupt is edge triggered or - level triggered. - @param [in] ActiveLow The interrupt is active-high or active-lo= w. - @param [in] Shared The interrupt can be shared with other - devices or not (Exclusive). - @param [in] IrqList Interrupt list. Must be non-NULL. - @param [in] IrqCount Interrupt count. Must be non-zero. - - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_INVALID_PARAMETER Invalid parameter. - @retval EFI_OUT_OF_RESOURCES Could not allocate memory. -**/ -EFI_STATUS -EFIAPI -AmlCodeGenAddRdInterrupt ( - IN AML_OBJECT_NODE_HANDLE NameOpNode, - IN BOOLEAN ResourceConsumer, - IN BOOLEAN EdgeTriggered, - IN BOOLEAN ActiveLow, - IN BOOLEAN Shared, - IN UINT32 * IrqList, - IN UINT8 IrqCount - ) -{ - EFI_STATUS Status; - - AML_OBJECT_NODE_HANDLE BufferOpNode; - - if ((IrqList =3D=3D NULL) || - (IrqCount =3D=3D 0) || - (!AmlNodeHasOpCode (NameOpNode, AML_NAME_OP, 0))) { - ASSERT (0); - return EFI_INVALID_PARAMETER; - } - - // Get the value which is represented as a BufferOp object node - // which is the 2nd fixed argument (i.e. index 1). - BufferOpNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( - NameOpNode, - EAmlParseIndexTerm1 - ); - if ((BufferOpNode =3D=3D NULL) = || - (AmlGetNodeType ((AML_NODE_HANDLE)BufferOpNode) !=3D EAmlNodeObject)= || - (!AmlNodeHasOpCode (BufferOpNode, AML_BUFFER_OP, 0))) { - ASSERT (0); - return EFI_INVALID_PARAMETER; - } - - // Generate the Extended Interrupt Resource Data node, - // and attach it as the last variable argument of the BufferOpNode. - Status =3D AmlCodeGenInterrupt ( - ResourceConsumer, - EdgeTriggered, - ActiveLow, - Shared, - IrqList, - IrqCount, - BufferOpNode, - NULL - ); - if (EFI_ERROR (Status)) { - ASSERT (0); - } - - return Status; + return LinkRdNode (RdNode, NameOpNode, NewRdNode); } =20 // DEPRECATED APIS @@ -316,15 +249,15 @@ AmlCodeGenCrsAddRdInterrupt ( IN UINT8 IrqCount ) { - return AmlCodeGenAddRdInterrupt ( - NameOpCrsNode, - NameOpNode, + return AmlCodeGenRdInterrupt ( ResourceConsumer, EdgeTriggered, ActiveLow, Shared, IrqList, - IrqCount + IrqCount, + NameOpCrsNode, + NULL ); } =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.h index 08364db4431f..764051e3d7c9 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h @@ -1,7 +1,7 @@ /** @file AML Resource Data Code Generation. =20 - Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -11,33 +11,32 @@ =20 /** Code generation for the "Interrupt ()" ASL function. =20 - This function creates a Resource Data element corresponding to the - "Interrupt ()" ASL function and stores it in an AML Data Node. - The Resource Data effectively created is an Extended Interrupt Resource - Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descripto= r" - for more information about Extended Interrupt Resource Data. + Data. Cf ACPI 6.4: + - s6.4.3.6 "Extended Interrupt Descriptor" + - s19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)" =20 - This function allocates memory to create a data node. It is the caller's - responsibility to either: - - attach this node to an AML tree; - - delete this node. + The created resource data node can be: + - appended to the list of resource data elements of the NameOpNode. + In such case NameOpNode must be defined by a the "Name ()" ASL statem= ent + and initially contain a "ResourceTemplate ()". + - returned through the NewRdNode parameter. =20 - @param [in] ResourceConsumer The device consumes the specified inter= rupt - or produces it for use by a child devic= e. - @param [in] EdgeTriggered The interrupt is edge triggered or - level triggered. - @param [in] ActiveLow The interrupt is active-high or active-= low. - @param [in] Shared The interrupt can be shared with other - devices or not (Exclusive). - @param [in] IrqList Interrupt list. Must be non-NULL. - @param [in] IrqCount Interrupt count. Must be non-zero. - @param [in] ParentNode If not NULL, add the generated node - to the end of the variable list of - argument of the ParentNode, but - before the "End Tag" Resource Data. - Must be a BufferOpNode. - @param [out] NewRdNode If success, contains the generated node. + @param [in] ResourceConsumer The device consumes the specified interru= pt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-lo= w. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + @param [in] NameOpNode NameOp object node defining a named objec= t. + If provided, append the new resource data= node + to the list of resource data elements of = this + node. + @param [out] NewRdNode If provided and success, + contain the created node. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -45,15 +44,15 @@ **/ EFI_STATUS EFIAPI -AmlCodeGenInterrupt ( - IN BOOLEAN ResourceConsumer, - IN BOOLEAN EdgeTriggered, - IN BOOLEAN ActiveLow, - IN BOOLEAN Shared, - IN UINT32 * IrqList, - IN UINT8 IrqCount, - IN AML_OBJECT_NODE * ParentNode, OPTIONAL - OUT AML_DATA_NODE ** NewRdNode OPTIONAL +AmlCodeGenRdInterrupt ( + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 *IrqList, + IN UINT8 IrqCount, + IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL + OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ); =20 #endif // AML_RESOURCE_DATA_CODE_GEN_H_ --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#76939): https://edk2.groups.io/g/devel/message/76939 Mute This Topic: https://groups.io/mt/83735193/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-