From nobody Sat May 18 05:53:10 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+81324+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+81324+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988127; cv=none; d=zohomail.com; s=zohoarc; b=bnZOjVDx7cIeRfMGWZnCwSguijiVa1DGBrgbOZxxlHnglkAehdqeNG8dk45efm5GRhXGR1mTyfL5ykOJ0ys6FWzXKSBJZljtovwXOc4dS7zFkGd7ZLnfdjJVxfSJgVRkV/S2w9iYW3JhOX9ce+noqKmpHqu76CUOAlsiIWVQP3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988127; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=g/5TlGI03LHsQElhwSqQxaMRQ68lrK48j5RciPxuFks=; b=TF3zPdMVIc69jkQEVo5r2OhnT0YRPerVi/aPtvkc0X6m8PQiLD30Ux+eBHM37IxgBt1n2vdEC9Sul0XjRBY5xSAqqJr5qiZ1gZ0jmHIX7B1IC4VJk8JRrPIWNyBE5fXCjxcgJIxGgZgWMuIXWMV2qe2ltlQB1dxlb+O7kTNQGNk= 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+81324+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 1632988127223357.88549039645716; Thu, 30 Sep 2021 00:48:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id j6WyYY1788612x2FtxaQ1Kuh; Thu, 30 Sep 2021 00:48:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.9408.1632988125994776900 for ; Thu, 30 Sep 2021 00:48:46 -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 2EC8D106F; Thu, 30 Sep 2021 00:48:44 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0B83C3F70D; Thu, 30 Sep 2021 00:48:42 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 01/10] DynamicTablesPkg: Extract AcpiHelperLib from TableHelperLib Date: Thu, 30 Sep 2021 08:48:12 +0100 Message-Id: <20210930074821.12546-2-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: liB2il4jVg85uR5Ee0R0PzHmx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988126; bh=FN9Q8SeE1eUX7WBihkUURS0Fz9fJDDzKlVxwz+W/qd0=; h=Date:From:Reply-To:Subject:To; b=PAikuMZYB/2m3cX0W925HbR3ePUmJzKDqDGBlZ3dsJsf63hXGKviPvpVB57syE2TgJg oPcVE9/zU77uH48PSqqzlVM1VZpRKknNG/L82/Ud4JGn5sUIXLa+1J1ZWtWArHftGV+4d hOtOi2n0dwxPzGADsT9Dz8/5IPoioICPLnU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632989030791100001 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 AcpiHelperLib library. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: - Change AcpiTableHelperLib to AcpiHelperLib in commit message. [Sami] 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 (#81324): https://edk2.groups.io/g/devel/message/81324 Mute This Topic: https://groups.io/mt/85968535/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 05:53:10 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+81325+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+81325+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988127; cv=none; d=zohomail.com; s=zohoarc; b=D7YgTZ7Dd98OZ77jLykwOuDLi+G0EElbnO9KNrk0Q1vEuEZoCSgoFMFn25ze6VOV8GJH3IeIrNOqLkovRzO0YNNUrhM5WhdyTAC/FuSAtXyxdtRADwp4tccKbW2SP9RlkIQtThthdHGEVEkyTBgzqpU8qVp6uiLvqM9mIC0riZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988127; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=TAc/q+BFfBElfaOIisfko4SWoCdxLR9Wb1CLuPDFj4Y=; b=Wh3l8ycn6l8sh/NaKtBUWjmU0h+3iQFfBKRtaEpT5zKjIeB850CFfGng2q50Ue/hOZI3qnifdP6LRXxF4rHjDR9WS8fPJc6EcCdC+KbzqxgjQq1RaQXdkv9uxPxIDBVe1RM7oC/3aU0xw7VXcq2rXagos7+YgNgoeJGBetLzG5w= 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+81325+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 1632988127750615.575055173194; Thu, 30 Sep 2021 00:48:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sXB2YY1788612xSwL0En6EJw; Thu, 30 Sep 2021 00:48:47 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.9434.1632988126160170736 for ; Thu, 30 Sep 2021 00:48:46 -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 C37BCD6E; Thu, 30 Sep 2021 00:48:45 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8E6083F70D; Thu, 30 Sep 2021 00:48:44 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 02/10] DynamicTablesPkg: Update TableHelperLib.inf Date: Thu, 30 Sep 2021 08:48:13 +0100 Message-Id: <20210930074821.12546-3-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: 7PGYvnkID2hBWSG3w5kVkd2Mx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988127; bh=47KCLV+qkTisJl+8XgYEJCFfD8JsT6dEJW7Mjo07pkg=; h=Date:From:Reply-To:Subject:To; b=nOnCrHwHa+d44crnVWcJ5JqaQU3COmbAAR1MtHb1qFkCQqd6BotgKWdw8EucI9EIF4Z +r6hdQbzC2cCj8CAftkX41RSPDw34b6ABQfsTFqfE5QC5JTNzOuimjrqV4neZMmjrGuk2 bOXVXj9GbuNHpLbaI7F5NmY/JJIypaDqg1s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988129112100004 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. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../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 (#81325): https://edk2.groups.io/g/devel/message/81325 Mute This Topic: https://groups.io/mt/85968536/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 05:53:10 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+81327+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+81327+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988135; cv=none; d=zohomail.com; s=zohoarc; b=DhkMlaWruXKaolcHeK5Xvu6WVqEw8SFaYXbII0gtLKd0PyRomDbnKbmIU0fsiOVbAiZl/Xwc+y3/uH0Usif7qo0hWya/C5sh2p639ca2lVuK9m+BUu3EBKHnqTOe/BBkdiHch168pmmgyjnOICOhYGqKxYMV5vG7SPPcAo4oBjU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988135; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=zWyU72F0LepuN2n3ygIr7OC5DLpltbMg6q0v5a2drXg=; b=dajWtsJqSfimPdewP+/VNBQ7isGsulxxr7ZAopIux6ZBaK64MhbRjchhYGnvdAuPYSRGKeyiVl0HGiezl0iXBhJJWP3DswSwl0N//IGN2JYlnfoFFl/8T8IH3cFz0lrUF703JGxtt9Et2t0sw8c8c+y8KyNlvJ1sdqRJhy1sj2k= 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+81327+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 1632988135281590.9281973707265; Thu, 30 Sep 2021 00:48:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XMVUYY1788612xO0nCocHKyc; Thu, 30 Sep 2021 00:48:55 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.9406.1632988134436503324 for ; Thu, 30 Sep 2021 00:48: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 BD302D6E; Thu, 30 Sep 2021 00:48:47 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 814233F70D; Thu, 30 Sep 2021 00:48:46 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 03/10] DynamicTablesPkg: Rename single char input parameter Date: Thu, 30 Sep 2021 08:48:14 +0100 Message-Id: <20210930074821.12546-4-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: EZhWGVMn0m2b4BMRMG4ZdOaDx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988135; bh=5uVvKLPo9qKabQPyUFzcyUNM3YYUwaExR6uyEWcOD8s=; h=Date:From:Reply-To:Subject:To; b=Gt44W8/TnIqbtlJcjxz6tGgEQoAaCnUeOvBOdyCN9TFk3KztIg2x0aS7lT8qZTi3SyN nCaSL0d7k4OkQ40Kt7TlqFoORkwRf8gP4F4whcZmwh8KimNwbq3qDFt7+u1518hlUWysu Gs/Ub4yReZkMrfq0eUvgKNsaoCb1ZCI7EFI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988135798100008 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. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: -Document returned error code. [Sami] DynamicTablesPkg/Include/Library/AcpiHelperLib.h | 7 ++++--- .../Library/Common/AcpiHelperLib/AcpiHelper.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index 2731a2e4fb27..53ab19b1d139 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -22,15 +22,16 @@ =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. + -1 if error. **/ 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..434b472cbb14 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -14,23 +14,24 @@ =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. + -1 if error. **/ 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 (#81327): https://edk2.groups.io/g/devel/message/81327 Mute This Topic: https://groups.io/mt/85968538/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 05:53:10 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+81330+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+81330+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988136; cv=none; d=zohomail.com; s=zohoarc; b=PM71Na6jALgActZXjzqsN5Qe1DY4w0JhuPIh1eJ+CbpMeIPNuiGE/sGfWac39OhQbyUHjkyY+Szg53O4k9/sv+yYhGow9LaHr+gs5ZFNkgJmOqxZsgVmtwpZiyVYvi8ph/HU10URGPZWt08wzVHiBy3gceO2/hSOecdtoAYgY0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988136; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=S5q/UvST4XPM6+QdszpXfoB8Nd7j/ArHPsJ6bAbxyOQ=; b=D8VEfw0s/UjalOz+mATXowWhwpNZPwY1kBBkXkdqg2m7g9ypFh62ycBxrebXa+mFkRn92o75DLfmTZRZwoKzssumpivXEf0hqkvHrk81Z7scc+iF/SqTqyTMNjWD4ZvzPAxD54XTzrtrL7D0E6Xya0VI+lxdm1OjnDVYI2PkW9c= 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+81330+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 1632988136337578.1286887014958; Thu, 30 Sep 2021 00:48:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Xc3SYY1788612xteEQgChXOB; Thu, 30 Sep 2021 00:48:55 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.9382.1632988134434100838 for ; Thu, 30 Sep 2021 00:48: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 4C071106F; Thu, 30 Sep 2021 00:48:49 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 28F633F70D; Thu, 30 Sep 2021 00:48:47 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 04/10] DynamicTablesPkg: Add HexFromAscii() to AcpiHelperLib Date: Thu, 30 Sep 2021 08:48:15 +0100 Message-Id: <20210930074821.12546-5-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: ckLmJ1hpJKjlAEmeKiof5qnGx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988135; bh=Ymii2Oysq5vW+eJ9uTUvkGwJBYjtl6X6lC8jIwzhDsM=; h=Date:From:Reply-To:Subject:To; b=uQgep0UDwbjGUBcLHmOU/Wxd9WDpShBpm7N6CN+G49rRAh5HO58QQLgXkAjdfJu6mUu PCORSSr8CyoJqxGdrVQKIKXUQWOeCxlS1yx9IfaUwou8/ZyGYL/V5r4oUzAzC4YFvAKww HCD5jNbZL99nDaspvMYdMfd6HBukDJDUhlg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988137934100002 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. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: -Document returned error code. [Sami] .../Include/Library/AcpiHelperLib.h | 15 +++++++++ .../Library/Common/AcpiHelperLib/AcpiHelper.c | 31 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h b/DynamicTabl= esPkg/Include/Library/AcpiHelperLib.h index 53ab19b1d139..094392a1a6d0 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -34,6 +34,21 @@ 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). + -1 if error. +**/ +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 434b472cbb14..0b566f0502ac 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -38,6 +38,37 @@ 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). + -1 if error. +**/ +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 (#81330): https://edk2.groups.io/g/devel/message/81330 Mute This Topic: https://groups.io/mt/85968541/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 05:53:10 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+81328+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+81328+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988136; cv=none; d=zohomail.com; s=zohoarc; b=IP8nq6UH0nBfCJqSlGeSziP1Pf7RpuWTWewKekHd/zZY2vO9/FSZwRUq3QjjB3baU/2eYAiBhbocJKvnAWFDqQnbkP11GqTAFtajmjQW+USxkzv2KgHrkEOdb9CsfyLNAOOP7z2h2cS893LpFk9bB5t5HVnnMjlN9u+7UeJ1stU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988136; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Q1Az4z9Idg6WZoD39KE1vJNRpp8fuTadrOuNMrpnnGQ=; b=T8XoEgobm3GRuCZbZUhiRBLlI14s0CjwAIU50cxVwmPNxLCuJsnUc2Jj8gnvi6B7gkEyLm/Psa1IhN28B3YYF2ZOaIit/EPkIFPZYRuC1/XEuapFsRetkTJmSZZy9un7Fz+QlIAUGCjyDFyQsNaV8QXW2lVMQrx1gQ+I3FDn2bo= 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+81328+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 1632988136672559.9738081438705; Thu, 30 Sep 2021 00:48:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fOO6YY1788612xS0BhWB02EW; Thu, 30 Sep 2021 00:48:56 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.9226.1632988134436851627 for ; Thu, 30 Sep 2021 00:48: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 0C8A111D4; Thu, 30 Sep 2021 00:48:51 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D3B513F70D; Thu, 30 Sep 2021 00:48:49 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 05/10] DynamicTablesPkg: Add AmlGetEisaIdFromString() to AcpiHelperLib Date: Thu, 30 Sep 2021 08:48:16 +0100 Message-Id: <20210930074821.12546-6-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: 6rUwz9Vx51ZJ8EF7DmlY27t9x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988136; bh=/M1HYE2VPYGcitXK3n+zMkWJRbWEallj4GOqiK/UH2A=; h=Date:From:Reply-To:Subject:To; b=JXgLCBU/EFnum3vjo+X5SqjsyJLh64rjCtTSGtQkmx5sKqMpzCZv9Y/K1AQrmGr2LRc ukeRivlgf/xiwsOUEu7gPq4aHTisK3FR+mB4ZWcTvxit00YzmRZLIxmk/As9+Kl20JCfJ ZrY9f+mU1l7iY1ljfGvoysmfGuK4IW1qOAQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988137980100007 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". Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../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 094392a1a6d0..a93e95e91987 100644 --- a/DynamicTablesPkg/Include/Library/AcpiHelperLib.h +++ b/DynamicTablesPkg/Include/Library/AcpiHelperLib.h @@ -73,4 +73,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 0b566f0502ac..5afd257e4980 100644 --- a/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c +++ b/DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c @@ -139,3 +139,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 (#81328): https://edk2.groups.io/g/devel/message/81328 Mute This Topic: https://groups.io/mt/85968539/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 05:53:10 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+81326+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+81326+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988134; cv=none; d=zohomail.com; s=zohoarc; b=Af9JOUAvlq9jGqQRdH7KWPm6GOMO+1RIrdUTk8v50NSdIDF8qcIuiuQjLUFIv3FFyewvYj/hyoVhYFvROmwmIBRT0oCg6UWV8KChqzf8hnBn4QICJzjDiWhYOkgP58AzpQePiRClf8lI8m8fYsoMJz2LoR8JJYNAFfl1GUNutNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988134; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=FYmqkPu/R3EvFg3zCgj4fn+r8ldQn8879y7LH1wYhsk=; b=k+Z+pAD5hM1AgyrrWxKIhYdagUi72Q5ocU3+yeTa7YJ+t1NU/DdwNH/YGAfUJeGtnrzJbtRQTQJdNxeROtfkY4b9w+QM18clE/29R/jWr+1xE42J+ih/xGd+L8uKlTEUrXZGViNSizhPPABBhZO7Rf2yVYa6KLHiLi6xwAJ18B0= 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+81326+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 163298813423024.630699426740193; Thu, 30 Sep 2021 00:48:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XKvXYY1788612xfe5m5F3IhB; Thu, 30 Sep 2021 00:48:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.9381.1632988133110329166 for ; Thu, 30 Sep 2021 00:48:53 -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 A84A81396; Thu, 30 Sep 2021 00:48:52 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6D1393F70D; Thu, 30 Sep 2021 00:48:51 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 06/10] DynamicTablesPkg: Add Configuration Manager Object parser Date: Thu, 30 Sep 2021 08:48:17 +0100 Message-Id: <20210930074821.12546-7-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: AUPabuCOeMPrAynrv18jvypUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988133; bh=MdDOLgsVUZXgIhnWf6Psh8FLYtq054qvU3ozFREW7Rc=; h=Date:From:Reply-To:Subject:To; b=OxByDFDuMDmq+t+MdgkRfafj5w5sEYxJU9qcKrNVMq/lxuQKggXx/oKeAe0yarBKne+ hMHQG0vzYFEWLYOTPHiNEWpD84d9JSi7cmPyONmqracJ7FS9UHkSacYk/FQ/upC8uuKdq ypEetuX3rYbRz2QNBUgltOQXAiuaZObo8bY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988135614100004 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. Reviewed-by: Joey Gouly Signed-off-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: - Changed wrong field name: GTBlockTimerFrameToken to Token. [Joey] .../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..ee2918ab5cc6 --- /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 { + {"Token", 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 (#81326): https://edk2.groups.io/g/devel/message/81326 Mute This Topic: https://groups.io/mt/85968537/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 05:53:10 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+81329+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+81329+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988137; cv=none; d=zohomail.com; s=zohoarc; b=Q/Kh3N5iYIs45eggy/SK8XNhNGM0C0DJ3FfQqjkzxHBIeiyHy77LwkzDgmMu0WyDGq0ezA01Mns66J67lRy6xq6rzeJYnggtuerjyCOjTgqIZ/gV0EiGrM/zuqAOtUWj91yZxIdMwpQJsmdIpBgoXZWqvR0e9t0k4Z3rGcsWIfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988137; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=sxGPIR2xIMPelm8WlBQhXwsXKa1h8St6diMNOqMFUoM=; b=Sl5Wr1pv4fsLwtp+/R5X1XZD/WzTcR3kvxH+ypd1mIaLDCX8ik6C58JuEqYcIQbEHT4ciTlwKAhNAO73kUgl4Qqr9E6s5M6T2MV4YJ5dvwnnEpfVFTdTwupdbc/GQtOYwBuOpEgYmFvxMhq0tHR5jcpZGcOwoUCB9uZ1z8JcMPY= 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+81329+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 1632988137265350.2769780998765; Thu, 30 Sep 2021 00:48:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id F0EYYY1788612xvmadO93kQN; Thu, 30 Sep 2021 00:48:56 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.9436.1632988134574590578 for ; Thu, 30 Sep 2021 00:48: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 38D1913A1; Thu, 30 Sep 2021 00:48:54 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 146F23F70D; Thu, 30 Sep 2021 00:48:52 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 07/10] DynamicTablesPkg: Use %a formatter in AmlDbgPrint Date: Thu, 30 Sep 2021 08:48:18 +0100 Message-Id: <20210930074821.12546-8-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: Lq5dTD6vONE8xIBwc08baceHx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988136; bh=ttq5+S/h6r6/c9EFwygetEN9sF+hClzAxUtr7svsJhQ=; h=Date:From:Reply-To:Subject:To; b=BdVhCxLD+gpA3u5hVJH9INYHqLfPd6CadSZDmM2E7OtI2B4wnk4KPUjapYyKpDcD9k4 mIspNNHSfdx82HAXGv/G0wLhQW+Xnz4zgNQtm7wFzC46LLLVq20kk4J7j5qH4ZIyxPikh 5iczM0H3IncwE3TvAR9sd/rRfupoWyfDFLU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988137984100008 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'. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../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 (#81329): https://edk2.groups.io/g/devel/message/81329 Mute This Topic: https://groups.io/mt/85968540/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 05:53:10 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+81331+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+81331+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988137; cv=none; d=zohomail.com; s=zohoarc; b=QkeykhMx2Rwb6L199vHmNiCEQflTfiq8QfDLI/T/gvGDVpNxmmZq5Ij65f/VYEPNhcQILiWdgRM6uPPC/Alhx7G9plWJQJ7ZvBzwkqSUjM68/qS3e0BwUYCIHLf9ZYSmWwSc6fnpn2lfkOCMLxZhKefRsgIIYwPLPpRzFvrPoXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988137; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=oV7y80Lwdci5jYDkOTqxn/Z7hpxLc2O1vPtcp+giU7o=; b=Tly25/7BZKSp/QJd4LMDy52r7hZ65pVDtTSjgjz3B6AW7hhwc5okEmH4k14GmR79xHuS8JV0imqWYWdl+rVV6iYNGT7ti7QsEOSaXvTizat1ifKfxkG+3yaxw6wF1EmPReXPrSrWkyH17DOjwiN90xvnrW5nRPz0R3CJAIeCRbo= 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+81331+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 1632988137559705.6799267901056; Thu, 30 Sep 2021 00:48:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xzlCYY1788612xreSRzG0cKb; Thu, 30 Sep 2021 00:48:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.9437.1632988135790614548 for ; Thu, 30 Sep 2021 00:48: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 75B8CD6E; Thu, 30 Sep 2021 00:48:55 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9789A3F70D; Thu, 30 Sep 2021 00:48:54 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 08/10] DynamicTablesPkg: Update DynamicTablesPkg.ci.yaml Date: Thu, 30 Sep 2021 08:48:19 +0100 Message-Id: <20210930074821.12546-9-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: omrGgeXFrSp1gVxxRkmJKnUtx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988137; bh=MjEjE8vcxM1uyfr/ugnTOa+R7FJ8CaYK0v1Zlp5tJwE=; h=Date:From:Reply-To:Subject:To; b=nJWLKZAy1/QraAJw5dh4REZiMV0+12tfPB5x499Co12rXmKfCnId7NQAgt0hyhtq8Kf b3JhOR6np+vWHs8dyBcei4rVerdgh/DGK0BpUBKd+xECO3ioRZENfAuiSTSghifNPJSPY flVvzYIhWC+38MFPxF+xkhaaXQjRVmEF8Bc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988137975100006 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. Reviewed-by: Sami Mujawar 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 (#81331): https://edk2.groups.io/g/devel/message/81331 Mute This Topic: https://groups.io/mt/85968542/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 05:53:10 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+81332+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+81332+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988138; cv=none; d=zohomail.com; s=zohoarc; b=fFSkJNnSPHnTWLcRQNqP5NOpnWpLtW8vX3K7Mg2+sGE2NdjZBHvnSwO/LKvmx7x1VSTfY09cbsVMqrCyVp14JH/uhau5xFFG24v8UsCAy2Mj2416QtGIqB34wyMKkjZKBAyt8OSSUwa7T1sTxnNbzRurDmkPtAe52Ojl+5ZZ8PI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988138; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=fcgubE28bzc982MOcRZ81QPmha2O5ha3B5R4J/5JhXI=; b=N9m6HNCuIltB8RcK7mze/WShwX+bj3wNSJV/hSh1NXvqCB5jMwSmXJDxiv3mxNIdZoLER64LvdVNHJ2OYaVyhMfVQ6PDJh3IFnXuyyhLOqhldpooHOmRTVdUM9Q6MkAAS5iBLCb3V1lO1E4vR2qRP0mdwhrcIJoIC0EitzQOJ6I= 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+81332+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 1632988138316177.27463354797317; Thu, 30 Sep 2021 00:48:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ON02YY1788612x1aqxmhHPql; Thu, 30 Sep 2021 00:48:58 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.9228.1632988137399396500 for ; Thu, 30 Sep 2021 00:48:57 -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 F1A57D6E; Thu, 30 Sep 2021 00:48:56 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B558B3F70D; Thu, 30 Sep 2021 00:48:55 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 09/10] DynamicTablesPkg: Deprecate Crs specific methods in AmlLib Date: Thu, 30 Sep 2021 08:48:20 +0100 Message-Id: <20210930074821.12546-10-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: 9YYEWKk2nDOAes1S7tIhX5B2x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988138; bh=aRprEDCsiY4J7OHRA/dUmpmj3eeWgUFmxpktpXhoCSg=; h=Date:From:Reply-To:Subject:To; b=YQcyyt9MgPaAnraBb5lIeV7ockZ/s/JCwJ/wdrOstId9SPn4uThcPwbdf4QZr5yGWrT lOD8huuh6SfV423nuFhkUrbv6W8Iv/E3DFHLMDpTRxiUtJ+L0/8u/ofi8m0xtxkYTkplh lNuJkwElyIhEJcdEXLddZDPwNbmrpZxGXQk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988140161100002 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. The deprecated functions are: - AmlNameOpCrsGetFirstRdNode() - AmlNameOpCrsGetNextRdNode() - AmlCodeGenCrsAddRdInterrupt() Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: - List deprecated APIs in commit message. [Sami] .../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 (#81332): https://edk2.groups.io/g/devel/message/81332 Mute This Topic: https://groups.io/mt/85968543/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 05:53:10 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+81333+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+81333+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1632988139; cv=none; d=zohomail.com; s=zohoarc; b=llN5ZZQS+f4+dy/PJM1EvZexFMh2pNsLcgRFkytx2a9nO3VQ9XAyx1nr2ZOl3omB6yuYEZ3jzxz7IJQlHu4xxUbix5yYl8EAKnFoBF2lVjCaSSxc9MMB3F6iSIpCiKe2y2uNA/2EDrzfOF2uUTVriSYHq14MM46HsHv6pDziTEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632988139; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=94p+N5odSFBUgdMrjSustz1OyOB80K1kxIlTwL7uBXU=; b=W49YCr7/kJjmotGUBRpRLQERCJUSAkR1iQhMqeKtRSkQHQoHk7h9wn3VoascbUgi0VOkSMs7jKTC1Ha6pKAp9hMNCsjDrMtiR1zJrUej20WyQkXQLkcxcmKtl/si499h4xqgMQ5YL0sOW8jLpLOfha9Vv1SS5f6ChNN9GensSPk= 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+81333+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 1632988139804148.32948240783548; Thu, 30 Sep 2021 00:48:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7D7DYY1788612xydswsat9fj; Thu, 30 Sep 2021 00:48:59 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.9383.1632988138738418636 for ; Thu, 30 Sep 2021 00:48:58 -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 4F24A106F; Thu, 30 Sep 2021 00:48:58 -0700 (PDT) X-Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 46FD13F70D; Thu, 30 Sep 2021 00:48:57 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com, Joey Gouly Subject: [edk2-devel] [PATCH v2 10/10] DynamicTablesPkg: Rework AmlResourceDataCodegen.c/h Date: Thu, 30 Sep 2021 08:48:21 +0100 Message-Id: <20210930074821.12546-11-Pierre.Gondois@arm.com> In-Reply-To: <20210930074821.12546-1-Pierre.Gondois@arm.com> References: <20210930074821.12546-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: lOmqMGesBKcSeutEqRqoMrIwx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632988139; bh=TYHQma7Cg33f7vUOA3xWiw1YHJGIWlI75bjCL411tZ4=; h=Date:From:Reply-To:Subject:To; b=sr9/h/oCW+NfUA+k0RK4NrXG+s07ge0JuDmyeCAyXrhXrSWZUkcxaLhJpXbaMMgrif+ M5tsIwSosWH/uhsYTa9p74c99NBRYrdFSycE6B3i4IgJmF2sZnUd/ErlW1qf/pyIRYbXx pW4iiepHPnuhrvNaMR2+sTZMLLcDpU7t13A= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632988140196100003 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. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../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 (#81333): https://edk2.groups.io/g/devel/message/81333 Mute This Topic: https://groups.io/mt/85968544/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-