From nobody Fri Apr 26 01:22:25 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+81689+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+81689+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704404; cv=none; d=zohomail.com; s=zohoarc; b=jPeGwciWbnVpAvQnEq9ff9FdNI5Kql+hDEZISM0UXHPZpXU0N5REmG0qkEXBIE9vtIQjpTzJrqIH9y2xNNw9pvarmFgXajwyEwVKfcLbEpaVmNETMjf5LS4q+DdZ/jvt6cJ8RRA8/St7U+yZdTyICoe37sACSOtSbN57FTQcZ3c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704404; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=GwCWRSIrhPJR3nBu7oAeml8KRuJGImMjx8RhKD60E2w=; b=Rh2kPEQkBe5ASJhXfcz6P6QgJ64FFaJZzrymPOj1gBPYGsdYiZc/gkltxeHrpgNMT+N5Q/3YQsBgHCwSZxDyTFXgszyySH84mrxJqJmyRKNRvz1W/agURWrPCLCQgZIVot7Ut40MJT386wMJ9des1EAEJqHIyP/xxixhgNcwvQo= 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+81689+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 1633704404549817.7916839346368; Fri, 8 Oct 2021 07:46:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SAeWYY1788612xnfRxy1bGOS; Fri, 08 Oct 2021 07:46:44 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.10318.1633704403126140605 for ; Fri, 08 Oct 2021 07:46:43 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BBEB1063; Fri, 8 Oct 2021 07:46:37 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 95E813F66F; Fri, 8 Oct 2021 07:46:36 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 01/21] DynamicTablesPkg: Remove unnecessary includes Date: Fri, 8 Oct 2021 15:46:12 +0100 Message-Id: <20211008144632.31894-2-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: FJCN5QNg2uCDCvh8SUD0JtX0x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704404; bh=cIsxLzxHYMIoxEPqZu+tAhYTd7b/NfH72DiByRt4sP8=; h=Date:From:Reply-To:Subject:To; b=ovXBLQTW3CbMi5IObCRkmBn/voxVWAK0VpSE0chVQ6t1tuqGGwJ6shm2ymL/EhHEvRp 8nEvq3yaGQirzHeAARYOqkTT4MiH7ZViXfEmoe1OL60EHNb6bB70KSXIATV6PBG6vuyd4 U0tKY70KJgv8gEHwEsMCjF+0/IGid9bTjXM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704405929100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Some includes are not necessary. Remove them. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- Notes: v2: - New patch. [Pierre] .../Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Generator.c | 2 -- .../Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPortGenerator.c | 3 --- .../Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c | 1 - 3 files changed, 6 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn= 600Generator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/Ssd= tCmn600Generator.c index 19b7b128a08d..b46ad25cdd26 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600Gene= rator.c @@ -10,13 +10,11 @@ - Generic ACPI for Arm Components 1.0 Platform Design Document **/ =20 -#include #include #include #include #include #include -#include #include =20 // Module specific include files. diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/Ssd= tSerialPortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPo= rtLibArm/SsdtSerialPortGenerator.c index 1b70fe1db1d7..d62aee1056ad 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerial= PortGenerator.c @@ -6,13 +6,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 -#include #include #include #include #include #include -#include #include =20 // Module specific include files. @@ -20,7 +18,6 @@ #include #include #include -#include #include #include =20 diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/= SsdtSerialPortFixupLib.c index 6966410b2c34..79e1fabc9223 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c @@ -16,7 +16,6 @@ #include #include #include -#include #include =20 // Module specific include files. --=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 (#81689): https://edk2.groups.io/g/devel/message/81689 Mute This Topic: https://groups.io/mt/86172095/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 Fri Apr 26 01:22:25 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+81690+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+81690+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704405; cv=none; d=zohomail.com; s=zohoarc; b=EeIRZhCL+EFsBL5WXUYK0hL80ufuqQ1nL/MRopbStHt9nEIwaYlswjMh6GyqA8ME6I1zlq2fp2r2VvCmVsTH8NqqUWLLKLA9sq4/+j/URsmp6bZlEzrXq/sLDlJ9/deqzL0xxd41/yUn4eKCP5rGOzF4MNHHFksFR8rBmyejhGI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704405; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=yIg9nW4Q0lfTj8cu5dsRQDuWuSiED+29B44DLZO+96U=; b=RIbAXxuzvr31JF2VIUWLXw2uiWZGtzIyGMbxoE8NWVgByKNQNjvj73J5ZamDXaNLOxi/TWV3uu3v22Z8T4criKSJAGo9d3dt0DR0p+VkC33N4ECl/Q/8075Nz7VJuGwDZz6tBHBuWkw7SayDlNuu67E11074BW8iRgx9eH3H2No= 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+81690+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 1633704405345844.163816048654; Fri, 8 Oct 2021 07:46:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gW4cYY1788612x57iiTTysKx; Fri, 08 Oct 2021 07:46:45 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.10535.1633704403128097183 for ; Fri, 08 Oct 2021 07:46:43 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C587C11FB; Fri, 8 Oct 2021 07:46:38 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D2BA73F66F; Fri, 8 Oct 2021 07:46:37 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 02/21] DynamicTablesPkg: Add missing parameter check Date: Fri, 8 Oct 2021 15:46:13 +0100 Message-Id: <20211008144632.31894-3-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: UbftqKUDkvRzyaMV1zy4hL7nx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704405; bh=2EltCtdO8ouAGaMOY5e8V20GWqvWH/m68ovEveySZAk=; h=Date:From:Reply-To:Subject:To; b=JHS6GRFefyTyHr4tgemv23PPMdiLDuFu9qxBjL5nmsvOSgazffYJj+9XEgoq+23ecIC vxt12C9TCriGCVnVu7bSpvlH+30+fLtvAAljGVwhjdruEYbU5UOv1KYcogfTn6gu4N1sN cWhY/oOVNzFXvKU9Xhi8gGyeLKX8wP5a6q8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704406069100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add missing check of 'AcpiTableInfo' in AddAcpiHeader(). Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index 9249e6b87f70..f98da7ffdd67 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -122,11 +122,13 @@ AddAcpiHeader ( ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Generator !=3D NULL); ASSERT (AcpiHeader !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); ASSERT (Length >=3D sizeof (EFI_ACPI_DESCRIPTION_HEADER)); =20 if ((CfgMgrProtocol =3D=3D NULL) || (Generator =3D=3D NULL) || (AcpiHeader =3D=3D NULL) || + (AcpiTableInfo =3D=3D NULL) || (Length < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) ) { return EFI_INVALID_PARAMETER; --=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 (#81690): https://edk2.groups.io/g/devel/message/81690 Mute This Topic: https://groups.io/mt/86172096/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 Fri Apr 26 01:22:25 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+81699+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+81699+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704415; cv=none; d=zohomail.com; s=zohoarc; b=PoI03/S1847f8ua/zbYOWBpzhLSERYQ20x+Dc6Mfy7BpiK5kgQzHn2ClWcfmCXjN4SGROTbpBFVkJog9MxfYiEFL/b7ZxA0bWGUM2s4z7mucNcOLBZ0ITKypYdHXDUlx8H8ykpEMVpZ8Mzmm2STXbNs/QYh4M54c8X1u0lvg+Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704415; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=lwQVo9c8LkudWlEA69Nxrf60Z6bsxpLL81nqX2MDz/g=; b=PEgmSMNt3IbjBfXmLo+UK3qEj1dXvoO53DBvXLW1RcfIGI3vLrSs1Wotzixvldty4HjFbFiOQ6vlx3s4AsoZxcvlDQr8wUuVTKf3SPMWiRuv4jq6d3rKaM5QV979j6XBFDH0wAdbcEIW2Ya6j3HKWtr1/ikJaybSz+IeOAIyGhY= 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+81699+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 163370441530038.9663669531285; Fri, 8 Oct 2021 07:46:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1EesYY1788612xNlfiXKbTsA; Fri, 08 Oct 2021 07:46:54 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10308.1633704413042657108 for ; Fri, 08 Oct 2021 07:46: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 B211012FC; Fri, 8 Oct 2021 07:46:40 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2AB9E3F66F; Fri, 8 Oct 2021 07:46:38 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 03/21] DynamicTablesPkg: Add AddSsdtAcpiHeader() Date: Fri, 8 Oct 2021 15:46:14 +0100 Message-Id: <20211008144632.31894-4-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: GLhVJUoSvKGQG86nFM1Whq7yx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704414; bh=YhjR2RqPCLugh7jTDOqXey6e7Qsi7OcNXhOm4sjZhPE=; h=Date:From:Reply-To:Subject:To; b=Sw9K0GTqVeobho8n9MqeSVKTgqJzXWJNVwsPwxiK39rSIRygxDt2C8U/SWy7DlTgwCf gTX8tDoEZBiblp284O6WiLfcDL6x7hy/v84gPl0o0QJXr1FsXfueOixKGKQnv57wK/j33 dyy4uQEMMiOvALc/b/Qn/zlCH9XRBTjEWss= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704417367100009 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois To fetch the Oem information from the ConfigurationManagerProtocol and the AcpiTableInfo, and populate the SSDT ACPI header when creating a RootNode via the AmlLib, create AddSsdtAcpiHeader(). Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/TableHelperLib.h | 35 ++++++++ .../Common/TableHelperLib/TableHelper.c | 87 +++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 6d362ff99a27..76f9e8c25fea 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -12,6 +12,8 @@ #ifndef TABLE_HELPER_LIB_H_ #define TABLE_HELPER_LIB_H_ =20 +#include + /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO object from the Configuration Manager. =20 @@ -62,6 +64,39 @@ AddAcpiHeader ( IN CONST UINT32 Length ); =20 +/** Build a RootNode containing SSDT ACPI header information using the Aml= Lib. + + The function utilizes the ACPI table Generator and the Configuration + Manager protocol to obtain any information required for constructing the + header. It then creates a RootNode. The SSDT ACPI header is part of the + RootNode. + + This is essentially a wrapper around AmlCodeGenDefinitionBlock () + from the AmlLib. + + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + protocol interface. + @param [in] Generator Pointer to the ACPI table Generator. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. + @param [out] RootNode If success, contains the created RootNode. + The SSDT ACPI header is part of the RootNod= e. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not fou= nd. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for t= he + requested object. +**/ +EFI_STATUS +EFIAPI +AddSsdtAcpiHeader ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, + IN CONST ACPI_TABLE_GENERATOR * CONST Generator, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInf= o, + OUT AML_ROOT_NODE_HANDLE * RootNode + ); + /** Function prototype for testing if two arbitrary objects are equal. =20 diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index f98da7ffdd67..d92c82eac99e 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -185,6 +185,93 @@ error_handler: return Status; } =20 +/** Build a RootNode containing SSDT ACPI header information using the Aml= Lib. + + The function utilizes the ACPI table Generator and the Configuration + Manager protocol to obtain any information required for constructing the + header. It then creates a RootNode. The SSDT ACPI header is part of the + RootNode. + + This is essentially a wrapper around AmlCodeGenDefinitionBlock () + from the AmlLib. + + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + protocol interface. + @param [in] Generator Pointer to the ACPI table Generator. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. + @param [out] RootNode If success, contains the created RootNode. + The SSDT ACPI header is part of the RootNod= e. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object information is not fou= nd. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for t= he + requested object. +**/ +EFI_STATUS +EFIAPI +AddSsdtAcpiHeader ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, + IN CONST ACPI_TABLE_GENERATOR * CONST Generator, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInf= o, + OUT AML_ROOT_NODE_HANDLE * RootNode + ) +{ + EFI_STATUS Status; + UINT64 OemTableId; + UINT32 OemRevision; + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO * CfgMfrInfo; + + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Generator !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + + if ((CfgMgrProtocol =3D=3D NULL) || + (Generator =3D=3D NULL) || + (AcpiTableInfo =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", + Status + )); + return Status; + } + + if (AcpiTableInfo->OemTableId !=3D 0) { + OemTableId =3D AcpiTableInfo->OemTableId; + } else { + OemTableId =3D SIGNATURE_32 ( + CfgMfrInfo->OemId[0], + CfgMfrInfo->OemId[1], + CfgMfrInfo->OemId[2], + CfgMfrInfo->OemId[3] + ) | + ((UINT64)Generator->AcpiTableSignature << 32); + } + + if (AcpiTableInfo->OemRevision !=3D 0) { + OemRevision =3D AcpiTableInfo->OemRevision; + } else { + OemRevision =3D CfgMfrInfo->Revision; + } + + Status =3D AmlCodeGenDefinitionBlock ( + "SSDT", + (CONST CHAR8*)&CfgMfrInfo->OemId, + (CONST CHAR8*)&OemTableId, + OemRevision, + RootNode + ); + ASSERT_EFI_ERROR (Status); + return Status; +} + /** Test and report if a duplicate entry exists in the given array of compar= able elements. --=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 (#81699): https://edk2.groups.io/g/devel/message/81699 Mute This Topic: https://groups.io/mt/86172106/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 Fri Apr 26 01:22:25 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+81694+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+81694+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704408; cv=none; d=zohomail.com; s=zohoarc; b=IE6kxyi/odxHcb1srDfc8X++gf127omWJ6VKUK8QUG9rtHNoHgH5Xa0s2aR3RJAUldtFvqgUZc/pr4lkO89srPafBnSHq2bOToCOlGNBUwagFT6tpW6knnVvVbMvPQ7hlbS8Z9P7tBWzneAx45w/hgQF/haGkifENpt3W7C5UAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704408; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=A82u7IYeskAkL6cVg/0Ze1JpiaLTYf5l7G3OMyAaEGk=; b=Wxr0meg1gbmQMEYStwid1bmGuBp3/9fOv6GkaCiCZt9w8BrW+zvYTWOccHqhBogJzDYnIt3JhXEe2wRgYv3B6NArq7mROAFQMRtjobMp/1q+HSvg4W9OwALbH/pHA2M02D1VS8YoECKhOpBtVB24idiD6/4ATNqLyUrMKVUxeYk= 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+81694+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 1633704408894346.6528041382202; Fri, 8 Oct 2021 07:46:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id N19MYY1788612xQMqLT6qNyB; Fri, 08 Oct 2021 07:46:48 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.10319.1633704407799675002 for ; Fri, 08 Oct 2021 07:46:48 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 664C91396; Fri, 8 Oct 2021 07:46:42 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 541E63F66F; Fri, 8 Oct 2021 07:46:41 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum() Date: Fri, 8 Oct 2021 15:46:15 +0100 Message-Id: <20211008144632.31894-5-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: 4ZrtgNjyzFz8WUg1l6DIuD57x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704408; bh=nNDpuLN8YpDmYLsyIWywZPkfkwejZ214thYzXjLH/Rg=; h=Date:From:Reply-To:Subject:To; b=qgI2yZQChxjxzPynScvWPsncCv5yM7yjfJWf34R1sQi3Ms5KCM3IGhFKWck5QoJiHrh pp2+tgcJiBpr0I7NhfzCArkAcYkDIG5B4ePVNJbtWjV2Q/MVxfEFAW/2vcLa3PU50+yfU F2/WgsoS3dTiXr4hiuh+h4wR4A7i1G+/OmE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704410577100010 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlRdSetEndTagChecksum(), setting the CheckSum value contained in a Resource Data element. ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../AmlLib/ResourceData/AmlResourceData.c | 33 +++++++++++++++++++ .../AmlLib/ResourceData/AmlResourceData.h | 21 ++++++++++++ 2 files changed, 54 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourc= eData.c b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceDa= ta.c index 8b46c7232df3..41cf0bc45314 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c @@ -101,3 +101,36 @@ AmlRdGetSize ( return ((ACPI_SMALL_RESOURCE_HEADER*)Header)->Bits.Length + sizeof (ACPI_SMALL_RESOURCE_HEADER); } + +/** Set the Checksum of an EndTag resource data. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + @param [in] Header Pointer to the first byte of a resource data. + @param [in] CheckSum Checksum value to set. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlRdSetEndTagChecksum ( + IN CONST AML_RD_HEADER * Header, + IN UINT8 CheckSum + ) +{ + if ((Header =3D=3D NULL) || + !AmlRdCompareDescId ( + Header, + AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + ((EFI_ACPI_END_TAG_DESCRIPTOR*)Header)->Checksum =3D CheckSum; + return EFI_SUCCESS; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourc= eData.h b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceDa= ta.h index 48e4e2aaddb4..e478107dffbd 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h @@ -171,4 +171,25 @@ AmlRdGetSize ( IN CONST AML_RD_HEADER * Header ); =20 +/** Set the Checksum of an EndTag resource data. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + @param [in] Header Pointer to the first byte of a resource data. + @param [in] CheckSum Checksum value to set. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlRdSetEndTagChecksum ( + IN CONST AML_RD_HEADER * Header, + IN UINT8 CheckSum + ); + #endif // AML_RESOURCE_DATA_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 (#81694): https://edk2.groups.io/g/devel/message/81694 Mute This Topic: https://groups.io/mt/86172100/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 Fri Apr 26 01:22:25 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+81696+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+81696+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704410; cv=none; d=zohomail.com; s=zohoarc; b=N+eXX3liE9ihh9eVnXVX3nnSaicuRdgL2jrrZrgReCboquBH5e/UJL4II0/hAPqK0moTdQWaOWrQnvk6I+EQDi3wzR7Ouschv4XjT3U3jKNGYB1+Op5d8rEiNk3OwIZZEBnGeoGm/LHxzva4U1ENh19PVFgqBxHG2trWBMZ+UYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704410; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=fHYfXsfw1OnPu3v1S+fyklimHXaqx92Q5j1XpXhs6g0=; b=eGOkrxF0I3ZLihkmnlj/AT+aqetHd57K5zkiIA4M31ubODrJ2x/XZgGmFK4RURIabBgoPn2T4Ijn4g7GsCKlD8MbzCxbng0cscI0oFV9ra6CjR90GnnsverEr0Hy+aVU9v4LQ3FUvF4J/jjcLoQVwW40r1FfrV4iCkaVXXbua9A= 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+81696+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 1633704410520780.4672679153545; Fri, 8 Oct 2021 07:46:50 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id V7x1YY1788612xIqVldBxrSh; Fri, 08 Oct 2021 07:46:50 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10306.1633704409160139632 for ; Fri, 08 Oct 2021 07:46:49 -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 C2DC26D; Fri, 8 Oct 2021 07:46:43 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B90C63F66F; Fri, 8 Oct 2021 07:46:42 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 05/21] DynamicTablesPkg: Add AmlSetRdListCheckSum() Date: Fri, 8 Oct 2021 15:46:16 +0100 Message-Id: <20211008144632.31894-6-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: cO33V6g941w6eGjAMaB1RYH6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704410; bh=ID+2MyyyWSoJMNK+awIgSCyOE1vv+cMTS3VOtyePIWo=; h=Date:From:Reply-To:Subject:To; b=jFD+XH7wtwSyVIcEAi38pn7DtapHPChOtUSy8KxbsQ/lwqNMZk2NM1GJVUEHMQvLV3I 6PdRJjFgrQEmP+0wSbUG8hUdsOt6LJxyQOiyIhP61bpDyhon9MzVoP+CBp993IxVcbHNi 6HbISHSsADp5/wT45/1JaxvVi6NN8O+Snvk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704423455100017 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Lists of Resource Data elements end with an EndTag (most of the time). This function finds the EndTag (if present) in a list of Resource Data elements and sets the checksum. ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Library/Common/AmlLib/Utils/AmlUtility.c | 76 +++++++++++++++++++ .../Library/Common/AmlLib/Utils/AmlUtility.h | 32 ++++++++ 2 files changed, 108 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c index 7ebd08f945c0..ef159e3b831e 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c @@ -904,3 +904,79 @@ AmlPropagateInformation ( =20 return EFI_SUCCESS; } + +/** Find and set the EndTag's Checksum of a list of Resource Data elements. + + Lists of Resource Data elements end with an EndTag (most of the time). T= his + function finds the EndTag (if present) in a list of Resource Data elemen= ts + and sets the checksum. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] BufferOpNode Node having a list of Resource Data elements. + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND No EndTag found. +**/ +EFI_STATUS +EFIAPI +AmlSetRdListCheckSum ( + IN AML_OBJECT_NODE * BufferOpNode, + IN UINT8 CheckSum + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * LastRdNode; + AML_RD_HEADER RdDataType; + + if (!AmlNodeCompareOpCode (BufferOpNode, AML_BUFFER_OP, 0)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Get the last Resource data node in the variable list of + // argument of the BufferOp node. + LastRdNode =3D (AML_DATA_NODE*)AmlGetPreviousVariableArgument ( + (AML_NODE_HEADER*)BufferOpNode, + NULL + ); + if ((LastRdNode =3D=3D NULL) || + !IS_AML_DATA_NODE (LastRdNode) || + (LastRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D AmlGetResourceDataType (LastRdNode, &RdDataType); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Check the LastRdNode is an EndTag. + // It is possible to have only one Resource Data in a BufferOp with + // no EndTag. Return EFI_NOT_FOUND is such case. + if (!AmlRdCompareDescId ( + &RdDataType, + AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))) { + ASSERT (0); + return EFI_NOT_FOUND; + } + + Status =3D AmlRdSetEndTagChecksum (LastRdNode->Buffer, CheckSum); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h index c57d780140d4..4667f57d7f08 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h @@ -91,5 +91,37 @@ AmlPropagateInformation ( IN UINT8 NodeCount ); =20 +/** Find and set the EndTag's Checksum of a list of Resource Data elements. + + Lists of Resource Data elements end with an EndTag (most of the time). T= his + function finds the EndTag (if present) in a list of Resource Data elemen= ts + and sets the checksum. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] BufferOpNode Node having a list of Resource Data elements. + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND No EndTag found. +**/ +EFI_STATUS +EFIAPI +AmlSetRdListCheckSum ( + IN AML_OBJECT_NODE * BufferOpNode, + IN UINT8 CheckSum + ); + #endif // AML_UTILITY_H_ =20 --=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 (#81696): https://edk2.groups.io/g/devel/message/81696 Mute This Topic: https://groups.io/mt/86172102/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 Fri Apr 26 01:22:25 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+81692+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+81692+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704406; cv=none; d=zohomail.com; s=zohoarc; b=mj3qqRm1uVwj8TQCVuK6101EUxlU8+UG0nTbCUEMt0K74j+/cvU+YHdtpTnEkS/zUtnXVRRocpibpvt3S+ijZnLBj8f3iB72HtfofuXSRLBoUvlV6NeX77c8nwU+f1D3QBXR29yAr2pLepx2LWvc1k4zZrbdn1rOG63773/RXko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704406; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=zr7YTJCSzahe/9aXgh+UIXlJsecudD6HKOYNPcByHtQ=; b=idGsL2xMhkuOevcoGXRxAzGQTct18pr1j7+bqrXSwoMpicCBGUIhAGuihk7rnLeUgNQljJjNcLy2HaPhj13RvoGrKHAMu53U8DdTKqJkTItKGQBxy5MVTJLGNaqGB3x6cVJJz16wUrpss4dc+q/HGQN5qahuN2jlfopXsnlzsvI= 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+81692+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 1633704406619713.1693502191782; Fri, 8 Oct 2021 07:46:46 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xenVYY1788612xY4XSHNvmBW; Fri, 08 Oct 2021 07:46:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46:45 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5695C1063; Fri, 8 Oct 2021 07:46:45 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CA523F66F; Fri, 8 Oct 2021 07:46:44 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 06/21] DynamicTablesPkg: Set EndTag's Checksum if RdList is modified Date: Fri, 8 Oct 2021 15:46:17 +0100 Message-Id: <20211008144632.31894-7-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: syxEXSSJXwLsiP87CWQaX7umx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704406; bh=VspnJo5fgo3+r9ZIZ01QJUyOP6JWp+EPyxfx30Wratc=; h=Date:From:Reply-To:Subject:To; b=bdG1VA7swUXuvZT9RhdOaTHr83RV0ze1KWH4UyMxYJLWrmNfSNMDkMiSeWnap3Ddtwr 6Kki4OsrEP85m9sMyH2tbMmRGxp8zXqMQIDY6Twp9g7hWJONtNCVh1DXQbT6h/M/5n0QM OmXxjK2t4PAuzFlMZIbbVt4tn6IC7v1KC7Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704408304100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally." To avoid re-computing checksums, if a new resource data elements is added/removed/modified in a list of resource data elements, the AmlLib resets the checksum to 0. This patch also refactors the AmlAppendRdNode() function by getting the last Resource Data node directly instead of iterating over all the elements of the list of Resource Data node. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/Tree/AmlNodeInterface.c | 7 ++ .../Library/Common/AmlLib/Tree/AmlTree.c | 72 +++++++------------ 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c= b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c index 870346c40a5d..f91bc5fd55d2 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNodeInterface.c @@ -513,6 +513,13 @@ AmlUpdateDataNode ( ASSERT (0); return EFI_INVALID_PARAMETER; } + + Status =3D AmlSetRdListCheckSum (ParentNode, 0); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + break; } case EAmlNodeDataTypeFieldPkgLen: diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c b/Dynami= cTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c index 0931e751709e..2772e915f468 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTree.c @@ -566,8 +566,7 @@ AmlAppendRdNode ( ) { EFI_STATUS Status; - AML_DATA_NODE * CurrRdNode; - AML_RD_HEADER RdDataType; + AML_DATA_NODE * LastRdNode; =20 if (!AmlNodeCompareOpCode (BufferOpNode, AML_BUFFER_OP, 0) || !IS_AML_DATA_NODE (NewRdNode) || @@ -576,56 +575,39 @@ AmlAppendRdNode ( return EFI_INVALID_PARAMETER; } =20 - // Get the first Resource data node in the variable list of - // argument of the BufferOp node. - CurrRdNode =3D (AML_DATA_NODE*)AmlGetNextVariableArgument ( + // To avoid re-computing checksums, if a new resource data elements is + // added/removed/modified in a list of resource data elements, the AmlLib + // resets the checksum to 0. + // It is possible to have only one Resource Data in a BufferOp with + // no EndTag, but it should not be possible to add a new Resource Data + // in the list in this case. + Status =3D AmlSetRdListCheckSum (BufferOpNode, 0); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Get the last Resource data node in the variable list of argument of t= he + // BufferOp node. This must be an EndTag, otherwise setting the checksum + // would have failed. + LastRdNode =3D (AML_DATA_NODE*)AmlGetPreviousVariableArgument ( (AML_NODE_HEADER*)BufferOpNode, NULL ); - if ((CurrRdNode =3D=3D NULL) || - !IS_AML_DATA_NODE (CurrRdNode) || - (CurrRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { + if ((LastRdNode =3D=3D NULL) || + !IS_AML_DATA_NODE (LastRdNode) || + (LastRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { ASSERT (0); return EFI_INVALID_PARAMETER; } =20 - // Iterate through the Resource Data nodes to find the End Tag. - while (TRUE) { - Status =3D AmlGetResourceDataType (CurrRdNode, &RdDataType); - if (EFI_ERROR (Status)) { - ASSERT (0); - return Status; - } - - // If the Resource Data is an End Tag, - // add the new node before and return. - if (AmlRdCompareDescId ( - &RdDataType, - AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))= ) { - Status =3D AmlVarListAddBefore ( - (AML_NODE_HEADER*)CurrRdNode, - (AML_NODE_HEADER*)NewRdNode) - ; - if (EFI_ERROR (Status)) { - ASSERT (0); - } - return Status; - } - - // Get the next Resource Data node. - // If this was the last node and no End Tag was found, return error. - // It is possible to have only one Resource Data in a BufferOp, - // but it should not be possible to add a new Resource Data in the list - // in this case. - CurrRdNode =3D (AML_DATA_NODE*)AmlGetSiblingVariableArgument ( - (AML_NODE_HEADER*)CurrRdNode - ); - if (!IS_AML_DATA_NODE (CurrRdNode) || - (CurrRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { - ASSERT (0); - return EFI_INVALID_PARAMETER; - } - } // while + // Add NewRdNode before the EndTag. + Status =3D AmlVarListAddBefore ( + (AML_NODE_HEADER*)LastRdNode, + (AML_NODE_HEADER*)NewRdNode) + ; + ASSERT_EFI_ERROR (Status); + return Status; } =20 /** Replace the fixed argument at the Index of the ParentNode with the New= Node. --=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 (#81692): https://edk2.groups.io/g/devel/message/81692 Mute This Topic: https://groups.io/mt/86172098/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 Fri Apr 26 01:22:25 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+81693+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+81693+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704408; cv=none; d=zohomail.com; s=zohoarc; b=HqCK8XByicvKV7u8lj7znOq1NrqrWOTuYbSpImBYytmJZSiuawHIA+owvqnd7dRFGGJ/3jThFDPxBuHBeIiBFyLjF1bWmG+eFkgm/ESRraum8JN3f/EDTXoxuVn81aeTycMLRmtl63no6je6m7NIn4BGaToWEyDezOEgmYjPeHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704408; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=IQ6BvTShKoo/S8ns4KVN9aloL22sixXLEXckU++ZSzQ=; b=ie+Dftf8TWdfKR0Qx+NU+T4eBHLpknsVo5AiukQvKWB+dIdXZv9C3JdMUv0DWo2iJs+3bKHr3g/7uQ3coKSU3I9Ria4KyDaZbYNYTMyuJYVKNyl0AaGayfs4tvg/MbILg1DqZwLKDWX0cykZ2rMnQJQe43c9CgrDSCTsyLylu7o= 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+81693+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 1633704408009323.72044747007703; Fri, 8 Oct 2021 07:46:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Jz4nYY1788612x1niq7GNHEP; Fri, 08 Oct 2021 07:46:47 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46:47 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C0B0211FB; Fri, 8 Oct 2021 07:46:46 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B66283F66F; Fri, 8 Oct 2021 07:46:45 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 07/21] DynamicTablesPkg: Clear pointer in node creation fcts Date: Fri, 8 Oct 2021 15:46:18 +0100 Message-Id: <20211008144632.31894-8-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: 0lKrCvfUbgoYOkSgNZGfrCBhx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704407; bh=uY7bltnEADPrNZq6AUIip4aB0TIcGOrqSEEZZV8mMVY=; h=Date:From:Reply-To:Subject:To; b=SLUZVI9/i5QxGTAXRuLdgGK9myPyUO4IwAYZYpQHpTB5b7l925fB37lbK1JErTdyxni LLg8WT0nLpspEkjmN/vPxOUSJqEnW8+DOL3XofxutMEuItFeluPLgnKFbWlCdRO2IsUNh nYfEClJqOe5+xReJD0aiPpjydYY8pHJH8x4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704408504100005 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The following functions: - AmlCreateRootNode() - AmlCreateObjectNode() - AmlCreateDataNode() create a node and return it by populating a pointer. This pointer should only be considered/used if the function returns successfully. Otherwise, the value stored in this pointer should be ignored. For their error handling, some other functions assume that this pointer is reset to NULL if an error occurs during a node creation. To make this assumption correct, explicitly clear this input pointer. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Library/Common/AmlLib/CodeGen/AmlCodeGen.c | 10 ++++++++-- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 10 ++++++++-- .../Library/Common/AmlLib/Tree/AmlNode.c | 18 +++++++++++++++--- .../Library/Common/AmlLib/Tree/AmlNode.h | 12 +++++++++--- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 5d310f201319..4775b68cd974 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -22,7 +22,9 @@ @param [in] Node Newly created node. @param [in] ParentNode If provided, set ParentNode as the parent of the node created. - @param [out] NewObjectNode If success, contains the created object node. + @param [out] NewObjectNode If not NULL: + - and Success, contains the created Node. + - and Error, reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -39,7 +41,7 @@ LinkNode ( EFI_STATUS Status; =20 if (NewObjectNode !=3D NULL) { - *NewObjectNode =3D Node; + *NewObjectNode =3D NULL; } =20 // Add RdNode as the last element. @@ -51,6 +53,10 @@ LinkNode ( } } =20 + if (NewObjectNode !=3D NULL) { + *NewObjectNode =3D Node; + } + return EFI_SUCCESS; } =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index 089597a6c906..cba942c0fd1a 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -33,7 +33,9 @@ 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. + @param [out] NewRdNode If not NULL: + - and Success, contains RdNode. + - and Error, reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -52,7 +54,7 @@ LinkRdNode ( AML_OBJECT_NODE *BufferOpNode; =20 if (NewRdNode !=3D NULL) { - *NewRdNode =3D RdNode; + *NewRdNode =3D NULL; } =20 if (ParentNode !=3D NULL) { @@ -85,6 +87,10 @@ LinkRdNode ( } } =20 + if (NewRdNode !=3D NULL) { + *NewRdNode =3D RdNode; + } + return Status; =20 error_handler: diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c b/Dynami= cTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c index 3740c0ac7bb8..300b07a2efe4 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.c @@ -79,7 +79,9 @@ AmlDeleteRootNode ( =20 @param [in] SdtHeader Pointer to an ACPI DSDT/SSDT header to copy the data from. - @param [out] NewRootNodePtr The created AML_ROOT_NODE. + @param [out] NewRootNodePtr If success, contains the created + AML_ROOT_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -101,6 +103,8 @@ AmlCreateRootNode ( return EFI_INVALID_PARAMETER; } =20 + *NewRootNodePtr =3D NULL; + RootNode =3D AllocateZeroPool (sizeof (AML_ROOT_NODE)); if (RootNode =3D=3D NULL) { ASSERT (0); @@ -163,7 +167,9 @@ AmlDeleteObjectNode ( @param [in] PkgLength PkgLength of the node if the AmlByteEnco= ding has the PkgLen attribute. 0 otherwise. - @param [out] NewObjectNodePtr The created AML_OBJECT_NODE. + @param [out] NewObjectNodePtr If success, contains the created + AML_OBJECT_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -186,6 +192,8 @@ AmlCreateObjectNode ( return EFI_INVALID_PARAMETER; } =20 + *NewObjectNodePtr =3D NULL; + ObjectNode =3D AllocateZeroPool (sizeof (AML_OBJECT_NODE)); if (ObjectNode =3D=3D NULL) { ASSERT (0); @@ -252,7 +260,9 @@ AmlDeleteDataNode ( this node. Data is copied from there. @param [in] DataSize Number of bytes to consider at the address pointed by Data. - @param [out] NewDataNodePtr The created AML_DATA_NODE. + @param [out] NewDataNodePtr If success, contains the created + AML_DATA_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -284,6 +294,8 @@ AmlCreateDataNode ( return EFI_INVALID_PARAMETER; } =20 + *NewDataNodePtr =3D NULL; + DataNode =3D AllocateZeroPool (sizeof (AML_DATA_NODE)); if (DataNode =3D=3D NULL) { ASSERT (0); diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.h b/Dynami= cTablesPkg/Library/Common/AmlLib/Tree/AmlNode.h index 3584b572baae..465a0e2b4b2f 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlNode.h @@ -17,7 +17,9 @@ =20 @param [in] SdtHeader Pointer to an ACPI DSDT/SSDT header to copy the data from. - @param [out] NewRootNodePtr The created AML_ROOT_NODE. + @param [out] NewRootNodePtr If success, contains the created + AML_ROOT_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -36,7 +38,9 @@ AmlCreateRootNode ( @param [in] PkgLength PkgLength of the node if the AmlByteEnco= ding has the PkgLen attribute. 0 otherwise. - @param [out] NewObjectNodePtr The created AML_OBJECT_NODE. + @param [out] NewObjectNodePtr If success, contains the created + AML_OBJECT_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. @@ -57,7 +61,9 @@ AmlCreateObjectNode ( this node. Data is copied from there. @param [in] DataSize Number of bytes to consider at the address pointed by Data. - @param [out] NewDataNodePtr The created AML_DATA_NODE. + @param [out] NewDataNodePtr If success, contains the created + AML_DATA_NODE. + Otherwise reset to NULL. =20 @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. --=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 (#81693): https://edk2.groups.io/g/devel/message/81693 Mute This Topic: https://groups.io/mt/86172099/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 Fri Apr 26 01:22:25 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+81695+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+81695+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704410; cv=none; d=zohomail.com; s=zohoarc; b=e5eWqoyoagKJwb96kiXZ80Ho59HhNI04Af2izN+T/qX9rBVtuFjAR+UnCon5SK0B6T61bPVIb6zXqbDfgQ0Ocm+UxGD95z6Kv3tzkMMI3Td1qYsw46NCNLfxsdKwJcWcqTfXXH+LsJlCNybrV0tcft9d7TzcXqmlcbrnprDKYTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704410; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=AffKYW/bbO8bNeeNY3P5/5fDuhDFzGcnncemYnWVJCE=; b=FZcoddju12jaLhGWCN1fRrs9WMiKgKwniCpp6ow0OmvnaSo4kM54XP+UXZzFiD9liLZRCKbJAWPKequ/OOA4HjL0vbxaoiJTKJ1QfNS9XOyjxBGQDgKK4oxvQYoKK8vuyoDzyHWdmu0t6mq2ARuVf/sCq6/ZPk55tsC0kkSKuZQ= 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+81695+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 163370440984261.14551138114791; Fri, 8 Oct 2021 07:46:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id nLBbYY1788612x88T15ACdA4; Fri, 08 Oct 2021 07:46:49 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46:49 -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 9A95D1063; Fri, 8 Oct 2021 07:46:48 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2C5673F66F; Fri, 8 Oct 2021 07:46:46 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 08/21] DynamicTablesPkg: Update error handling for node creation Date: Fri, 8 Oct 2021 15:46:19 +0100 Message-Id: <20211008144632.31894-9-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: trTnq6BfRN4Qu5yWgqpb26fvx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704409; bh=wmJHPoBmKyE4yp3/YDm0okUjAg27FEsZeb9XWbOkqaA=; h=Date:From:Reply-To:Subject:To; b=AdSCxM2uUBGjHJTBRgRieyIKfm0yjc8+uVoSHfXZeMfiQEFgRbISht0z3JV1JSKO2P0 PCBx4SXkDzfZ1am9k57ubiUCjiinCkmeUp1bps1tTjql+H2fResl942Oazl/x5nodN/u2 3cv3dYi3Clka/qizCr4neCwXRTMSRbaKDDs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704410766100014 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois The node creation functions: - AmlCreateRootNode() - AmlCreateObjectNode() - AmlCreateDataNode() are now resetting the input pointer where the created node is stored. Thus, it is not necessary to set some local variables to NULL or check a node value before trying to delete it. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c | 6 +----- DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 4775b68cd974..cbfd9cbb68b6 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -148,7 +148,6 @@ AmlCodeGenString ( return EFI_INVALID_PARAMETER; } =20 - ObjectNode =3D NULL; DataNode =3D NULL; =20 Status =3D AmlCreateObjectNode ( @@ -187,10 +186,7 @@ AmlCodeGenString ( return Status; =20 error_handler: - if (ObjectNode !=3D NULL) { - AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode); - } - + AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode); return Status; } =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c b/Dynam= icTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c index e09372b039f1..7aafa957a8c4 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlClone.c @@ -43,8 +43,6 @@ AmlCloneNode ( return EFI_INVALID_PARAMETER; } =20 - *ClonedNode =3D NULL; - if (IS_AML_DATA_NODE (Node)) { DataNode =3D (AML_DATA_NODE*)Node; Status =3D AmlCreateDataNode ( --=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 (#81695): https://edk2.groups.io/g/devel/message/81695 Mute This Topic: https://groups.io/mt/86172101/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 Fri Apr 26 01:22:25 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+81697+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+81697+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704411; cv=none; d=zohomail.com; s=zohoarc; b=E9j7LJodK1ez/Uoj+djN+YCMeTwlj4Z68Pw/r6DZiusZZwyzBKVR/9XCsvguAwAA8WZcXV12H+BEKw0uL/6gNVqGGK7dfddhGHcTBgZ57dkbd/+qQuMaDGE9mnsLf94sqlQGuBRhw0Jy+gZS4xBA1u38jo3HbJ4VQiaOMK6ROF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704411; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=ZNAWcM5tUg6cQq+Vz/6n2IqQ1SwZaHHG/cr31cTKdvY=; b=f3MlRVXwCbEOjKIHUu4mn98ZRk2UV0dd5s8Apbm8m9vyn+rFEjeIpV6UBacwJHxlY4FW1ZCAEd5YVbaVRAwF8QnmdCQ4X2HvCScFLIIYZE0Xfv1crOJol3sXxcBkW1uSRDhUHdr3f862jhy/LJvjmJ/XLLBLl1pbFsS89P8CojI= 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+81697+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 1633704411329573.1807938544545; Fri, 8 Oct 2021 07:46:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id f1vSYY1788612xrNP0WLyNiy; Fri, 08 Oct 2021 07:46:51 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46:50 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 41C9E6D; Fri, 8 Oct 2021 07:46:50 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 37EE03F66F; Fri, 8 Oct 2021 07:46:49 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 09/21] DynamicTablesPkg: Make AmlNodeGetIntegerValue public Date: Fri, 8 Oct 2021 15:46:20 +0100 Message-Id: <20211008144632.31894-10-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: dRrQPaH4VGe3JwIp7BTDoYCwx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704411; bh=sHUahEi7BSW9gYVkANiEI9zboozzRj1buSnEb1P30Yc=; h=Date:From:Reply-To:Subject:To; b=lKv85Wk15gCAGSTKwgdIrM3ehLznWDj5SMyaSsKNj+1eEIfeWL1vw0mF5ebhTbyc4Vd DjeZGF3f4zleYnxQiKlSqD4vmxRK9XStcyq+GG5eu9FjB6eMcykojFC8Fm8YRjJylSoMk jHnlct6ywvyhLt4Kp2JezsafPPeeasm9vOA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704412920100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Remove the STATIC qualifier for the AmlUtility function AmlNodeGetIntegerValue() and add the definition to the header file so that it can be used by other AmlLib sub-modules. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Library/Common/AmlLib/Utils/AmlUtility.c | 3 +-- .../Library/Common/AmlLib/Utils/AmlUtility.h | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c index ef159e3b831e..8b5153f916a4 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c @@ -1,7 +1,7 @@ /** @file AML Utility. =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 **/ @@ -192,7 +192,6 @@ AmlComputeSize ( @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Invalid parameter. **/ -STATIC EFI_STATUS EFIAPI AmlNodeGetIntegerValue ( diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h index 4667f57d7f08..0c42d23cbdb9 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h @@ -1,7 +1,7 @@ /** @file AML Utility. =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 **/ @@ -39,6 +39,22 @@ AmlComputeSize ( IN OUT UINT32 * Size ); =20 +/** Get the value contained in an integer node. + + @param [in] Node Pointer to an integer node. + Must be an object node. + @param [out] Value Value contained in the integer node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlNodeGetIntegerValue ( + IN AML_OBJECT_NODE * Node, + OUT UINT64 * Value + ); + /** Set the value contained in an integer node. =20 The OpCode is updated accordingly to the new value --=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 (#81697): https://edk2.groups.io/g/devel/message/81697 Mute This Topic: https://groups.io/mt/86172104/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 Fri Apr 26 01:22:25 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+81698+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+81698+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704412; cv=none; d=zohomail.com; s=zohoarc; b=ISOZ9V54guYGRMeS6BcWJ9P1pNoD1i17qbK+ZU22NJ1HB08l3mCZKP51IkNQxfC+vM5TDxHM+F2F/Z0YpVIL99F5MAcT5qXtmMO73yTe9kjpzlET1nFKtnBKAllJa8p15fTu+Rpfz8XUIKyFQBUCN8FMVnYrw8u96EZAjARAUg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704412; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=ovYyIll/+H6wIohDzTQhplVb+loJ15ugS1KhCq4NypE=; b=XqjV1CyoP3EM/oXCRmjPl7/hufppG8msPdqo/njkYu+t2jU2Ri2PGxSCv3O/LMyox9w/m1hhnyIISTTMSQoivFGaC53NUZxeXvsT8lBRsR05NJnBoIOZwebhbs2dV/ZE9Tx4nz5BuKhe4UCmV99l+lui9kIpP3WCXJTLAKGWqWg= 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+81698+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 1633704412956702.6702816314403; Fri, 8 Oct 2021 07:46:52 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 13eSYY1788612xm9SbtkYgFE; Fri, 08 Oct 2021 07:46:52 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46:52 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AC2FA1063; Fri, 8 Oct 2021 07:46:51 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A1E633F66F; Fri, 8 Oct 2021 07:46:50 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 10/21] DynamicTablesPkg: AML Code generation for Register() Date: Fri, 8 Oct 2021 15:46:21 +0100 Message-Id: <20211008144632.31894-11-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: kXV6bRxZxfgGVmNBQzOqIKLsx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704412; bh=4YO9gFR1iP2G5zCJfMDw0HTaXO0zd8toKYihHhvhrGM=; h=Date:From:Reply-To:Subject:To; b=srF/5K99TSsv5f/8mJulTFc3c7z5lUNGM87pUepyZKlW4wXvEsEsOedUr1bqy+DMIoY CAURH0Z5wqzIiZTbBbglj1Ja/gEic4jhp1yfrBWpYMawVYHDHT54kjmoHsJ5QCd3fOjfN OBX6aEKluWIhzaqD1aGOI/Kxe9qQOucWCMg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704415252100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenRegister() to generate AML code for the Generic Register Resource Descriptor. This function is equivalent to the ASL macro Register(). Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 87 +++++++++++++++++++ .../AmlLib/CodeGen/AmlResourceDataCodeGen.h | 49 +++++++++++ 2 files changed, 136 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index cba942c0fd1a..20b745f27a2b 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -193,6 +193,93 @@ AmlCodeGenRdInterrupt ( return LinkRdNode (RdNode, NameOpNode, NewRdNode); } =20 +/** Code generation for the "Register ()" ASL function. + + The Resource Data effectively created is a Generic Register Descriptor. + Data. Cf ACPI 6.4: + - s6.4.3.7 "Generic Register Descriptor". + - s19.6.114 "Register". + + 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. + + @param [in] AddressSpace Address space where the register exists. + Can be one of I/O space, System Memory, etc. + @param [in] BitWidth Number of bits in the register. + @param [in] BitOffset Offset in bits from the start of the regist= er + indicated by the Address. + @param [in] Address Register address. + @param [in] AccessSize Size of data values used when accessing the + address space. Can be one of: + 0 - Undefined, legacy (EFI_ACPI_6_4_UNDEF= INED) + 1 - Byte access (EFI_ACPI_6_4_BYTE) + 2 - Word access (EFI_ACPI_6_4_WORD) + 3 - DWord access (EFI_ACPI_6_4_DWORD) + 4 - QWord access (EFI_ACPI_6_4_QWORD) + @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. + + @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 +AmlCodeGenRdRegister ( + IN UINT8 AddressSpace, + IN UINT8 BitWidth, + IN UINT8 BitOffset, + IN UINT64 Address, + IN UINT8 AccessSize, + IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL + OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * RdNode; + EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR RdRegister; + + if ((AccessSize > EFI_ACPI_6_4_QWORD) || + ((NameOpNode =3D=3D NULL) && (NewRdNode =3D=3D NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Header + RdRegister.Header.Header.Bits.Name =3D + ACPI_LARGE_GENERIC_REGISTER_DESCRIPTOR_NAME; + RdRegister.Header.Header.Bits.Type =3D ACPI_LARGE_ITEM_FLAG; + RdRegister.Header.Length =3D sizeof (EFI_ACPI_GENERIC_REGISTER_DESCRIPTO= R) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + + // Body + RdRegister.AddressSpaceId =3D AddressSpace; + RdRegister.RegisterBitWidth =3D BitWidth; + RdRegister.RegisterBitOffset =3D BitOffset; + RdRegister.AddressSize =3D AccessSize; + RdRegister.RegisterAddress =3D Address; + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeResourceData, + (UINT8*)&RdRegister, + sizeof (EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR), + &RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + return LinkRdNode (RdNode, NameOpNode, NewRdNode); +} + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.h index 764051e3d7c9..831d6a7462ae 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h @@ -55,4 +55,53 @@ AmlCodeGenRdInterrupt ( OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ); =20 +/** Code generation for the "Register ()" ASL function. + + The Resource Data effectively created is a Generic Register Descriptor. + Data. Cf ACPI 6.4: + - s6.4.3.7 "Generic Register Descriptor". + - s19.6.114 "Register". + + 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. + + @param [in] AddressSpace Address space where the register exists. + Can be one of I/O space, System Memory, etc. + @param [in] BitWidth Number of bits in the register. + @param [in] BitOffset Offset in bits from the start of the regist= er + indicated by the Address. + @param [in] Address Register address. + @param [in] AccessSize Size of data values used when accessing the + address space. Can be one of: + 0 - Undefined, legacy (EFI_ACPI_6_4_UNDEF= INED) + 1 - Byte access (EFI_ACPI_6_4_BYTE) + 2 - Word access (EFI_ACPI_6_4_WORD) + 3 - DWord access (EFI_ACPI_6_4_DWORD) + 4 - QWord access (EFI_ACPI_6_4_QWORD) + @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. + + @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 +AmlCodeGenRdRegister ( + IN UINT8 AddressSpace, + IN UINT8 BitWidth, + IN UINT8 BitOffset, + IN UINT64 Address, + IN UINT8 AccessSize, + IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL + OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL + ); + #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 (#81698): https://edk2.groups.io/g/devel/message/81698 Mute This Topic: https://groups.io/mt/86172105/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 Fri Apr 26 01:22:25 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+81700+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+81700+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704414; cv=none; d=zohomail.com; s=zohoarc; b=GaXEYMvvZiYjdak1RC/XLIngAyTrM3EMnX0M94IgWLNQKjf1I6z8gyXzVPAVvsBkTgiNm/nBVmIeHs4GJvxm2iJ0bImwReEQ003lBAivcwpVh57a3a7qpezIfzP9kcAS3RTq2ThwhfbeL/+f8U30+vhdmygfYQZN4l51gdecGa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704414; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=invayR+ON1JAEv0et/cqCmkfKCA0SkLW2P1n9YcoMys=; b=Q/5QJHIQ+oVNNE1lIvOrFZR3ZZ+jOrsGeFR8iVZ6VFpnv1KP8GoieD2AECFHnlqCA8UJG33sHs3BJyk3Fuecb3ZskfHv2F3hxn5ayTxnH0AVbtRZ+1HKfKOBIBmx0hCDiz5TxUgNBQ6G22faTI82xQmk3mZ+Tp1V05XsYJdDjuE= 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+81700+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 1633704414159946.4004593658111; Fri, 8 Oct 2021 07:46:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8vs1YY1788612xfsE1o7ph7F; Fri, 08 Oct 2021 07:46:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10571.1633704405766240838 for ; Fri, 08 Oct 2021 07:46: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 E3B316D; Fri, 8 Oct 2021 07:46:52 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 069993F66F; Fri, 8 Oct 2021 07:46:51 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 11/21] DynamicTablesPkg: AML Code generation for Resource data EndTag Date: Fri, 8 Oct 2021 15:46:22 +0100 Message-Id: <20211008144632.31894-12-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: smIRKEacVz5W58X6d0iwFU98x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704413; bh=0Oyc+2egjyv9nPfxdzEbkTbpwhTxFWQh70FlypLmP7E=; h=Date:From:Reply-To:Subject:To; b=F3pmmRhtBoeE57TSXelYmf78XB5F1P7kMthYoOLiF6KUoTIKWSXLPA8JcX8wdW7ExbB D9DBO4L92ciT5dgkvUqgOPFHFSND4XH+Q3A95vDNB//pEUlGnSQEB+1WRLu7kdPMIvrjc MqNsTxFqMHQWPnB6rOS5aCfLZl8fjyt0z3Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704415434100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a helper function AmlCodeGenEndTag() to generate AML Resource Data EndTag. The EndTag resource data is automatically generated by the ASL compiler at the end of a list of resource data elements. Therefore, an equivalent function is not present in ASL. However, AmlCodeGenEndTag() is useful when generating AML code for the ResourceTemplate() macro. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 113 ++++++++++++++++++ .../AmlLib/CodeGen/AmlResourceDataCodeGen.h | 43 +++++++ 2 files changed, 156 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index 20b745f27a2b..0bdb6c24c5bb 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -280,6 +280,119 @@ AmlCodeGenRdRegister ( return LinkRdNode (RdNode, NameOpNode, NewRdNode); } =20 +/** Code generation for the EndTag resource data. + + The EndTag resource data is automatically generated by the ASL compiler + at the end of a list of resource data elements. Thus, it doesn't have + a corresponding ASL function. + + 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. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode. + The ParentNode must not initially contain + an EndTag resource data element. + @param [out] NewRdNode If success, contains the generated node. + + @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 +AmlCodeGenEndTag ( + IN UINT8 CheckSum, OPTIONAL + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * RdNode; + EFI_ACPI_END_TAG_DESCRIPTOR EndTag; + ACPI_SMALL_RESOURCE_HEADER SmallResHdr; + + if ((ParentNode =3D=3D NULL) && (NewRdNode =3D=3D NULL)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + RdNode =3D NULL; + + // Header + SmallResHdr.Bits.Length =3D sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) - + sizeof (ACPI_SMALL_RESOURCE_HEADER); + SmallResHdr.Bits.Name =3D ACPI_SMALL_END_TAG_DESCRIPTOR_NAME; + SmallResHdr.Bits.Type =3D ACPI_SMALL_ITEM_FLAG; + + // Body + EndTag.Desc =3D SmallResHdr.Byte; + EndTag.Checksum =3D CheckSum; + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeResourceData, + (UINT8*)&EndTag, + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR), + &RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + if (NewRdNode !=3D NULL) { + *NewRdNode =3D RdNode; + } + + if (ParentNode !=3D NULL) { + // Check the BufferOp doesn't contain any resource data yet. + // This is a hard check: do not allow to add an EndTag if the BufferNo= de + // already has resource data elements attached. Indeed, the EndTag sho= uld + // have already been added. + if (AmlGetNextVariableArgument ((AML_NODE_HEADER*)ParentNode, NULL) != =3D + NULL) { + ASSERT (0); + Status =3D EFI_INVALID_PARAMETER; + goto error_handler; + } + + // Add the EndTag RdNode. Indeed, the AmlAppendRdNode function + // is looking for an EndTag, which we are adding here. + Status =3D AmlVarListAddTail ( + (AML_NODE_HEADER*)ParentNode, + (AML_NODE_HEADER*)RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + } + + return Status; + +error_handler: + if (RdNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)RdNode); + } + return Status; +} + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.h index 831d6a7462ae..102340495933 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h @@ -104,4 +104,47 @@ AmlCodeGenRdRegister ( OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ); =20 +/** Code generation for the EndTag resource data. + + The EndTag resource data is automatically generated by the ASL compiler + at the end of a list of resource data elements. Thus, it doesn't have + a corresponding ASL function. + + 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. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode. + The ParentNode must not initially contain + an EndTag resource data element. + @param [out] NewRdNode If success, contains the generated node. + + @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 +AmlCodeGenEndTag ( + IN UINT8 CheckSum, OPTIONAL + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ); + #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 (#81700): https://edk2.groups.io/g/devel/message/81700 Mute This Topic: https://groups.io/mt/86172107/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 Fri Apr 26 01:22:25 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+81701+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+81701+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704416; cv=none; d=zohomail.com; s=zohoarc; b=hUd2iK/GWogPKng4HCh4W+CCC9OKC0qaiwoUmANwDjT2vpTjl8xNzCppjQ331vNcWK9ducnkp9IDPE+xi/hrs1Ru28GMulbe7elzBtjh+KKWft3b49e6i/PobNyeUQYHTMwEBRTQbx2d58DsOa3oo0ng3zNdv2ONsFZMDpNof7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704416; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Jte/PGzv3ooZlR7FYXtPesfOg+M/gHNFdGyyx+h/zH4=; b=F35fP1M1RyHPuY11/zgT7Us5beBE75GWezk0AyS/t3gFv108QjaK2uPA0IUf+DXj5zadBjMXPha4Ix1GwikYtSZpkVeaypK4mDSN95rmySWygwO5DtWWnDiKcU96if4jPNQng1QYAhg9lm0tVmLAMdYeoRJQI2gIhxdMpJ7JQL8= 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+81701+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 1633704416169742.6559878346385; Fri, 8 Oct 2021 07:46:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BtO2YY1788612xey160NL5JF; Fri, 08 Oct 2021 07:46:55 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10572.1633704415206621542 for ; Fri, 08 Oct 2021 07:46: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 D6C206D; Fri, 8 Oct 2021 07:46:54 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4F9743F66F; Fri, 8 Oct 2021 07:46:53 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 12/21] DynamicTablesPkg: AML code generation for a Package Date: Fri, 8 Oct 2021 15:46:23 +0100 Message-Id: <20211008144632.31894-13-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: b7lddCzPVKuQ3p5wIasUnA7Fx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704415; bh=N6ruJlk+HQzlpd+UCCZZtWpzwbTrgckxd5Qpmbpl+os=; h=Date:From:Reply-To:Subject:To; b=NrOgCC+FjMf2/xzjAyu5vYctt2ab9XIc3Dhv/H10/7ZhBqds+PlQPvkbdrX8ax7rpaS hVMpLAb0JdO+TP6VdMeku3X0uhK8lHWLi+n1TlS/J31mUaYynvmCXwkf5WzKvanXqyiOt 2O2SX6JbjUXTgluCnIsDsI/Y9ad/D0QWGZ8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704417502100012 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenPackage() to generate AML code for declaring a Package() object. This function generates an empty package node. New elements can then be added to the package's variable argument list. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 81 ++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index cbfd9cbb68b6..a4cd2502dc56 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1,7 +1,7 @@ /** @file AML 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 **/ @@ -237,6 +237,85 @@ AmlCodeGenInteger ( return Status; } =20 +/** AML code generation for a Package object node. + + The package generated is empty. New elements can be added via its + list of variable arguments. + + @param [out] NewObjectNode If success, contains the created + Package object node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenPackage ( + OUT AML_OBJECT_NODE ** NewObjectNode + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * DataNode; + UINT8 NodeCount; + + if (NewObjectNode =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + NodeCount =3D 0; + + // Create an object node. + // PkgLen is 2: + // - one byte to store the PkgLength + // - one byte for the NumElements. + // Cf ACPI6.3, s20.2.5 "Term Objects Encoding" + // DefPackage :=3D PackageOp PkgLength NumElements PackageElementList + // NumElements :=3D ByteData + Status =3D AmlCreateObjectNode ( + AmlGetByteEncodingByOpCode (AML_PACKAGE_OP, 0), + 2, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // NumElements is a ByteData. + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeUInt, + &NodeCount, + sizeof (NodeCount), + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + Status =3D AmlSetFixedArgument ( + *NewObjectNode, + EAmlParseIndexTerm0, + (AML_NODE_HEADER*)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + AmlDeleteTree ((AML_NODE_HEADER*)*NewObjectNode); + if (DataNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)DataNode); + } + return Status; +} + /** AML code generation for a Name object node. =20 @param [in] NameString The new variable name. --=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 (#81701): https://edk2.groups.io/g/devel/message/81701 Mute This Topic: https://groups.io/mt/86172108/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 Fri Apr 26 01:22:25 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+81702+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+81702+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704417; cv=none; d=zohomail.com; s=zohoarc; b=HvO18nrH35HvMMLsX64/bT9PeEyXyy4otZEPyQZSYQKrnAdgTDPkW/ra2gxLH9E7iTE2+hoAz/3hx8Ge0Ahxg+TyC8DeQmt29Z1/jHZ9qSXaqFLslLOQzCgEzwrxbeC1vh1nR94O0+uMokY3dN9YMyKsb+gd8bYJnOM6TgeyspU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704417; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=RI2jATI/dKM7kcotzqGHdyF7q8f2IifnL2BAKXW3pOA=; b=l9BM20/OZKwiLBURQsc4lICvcrRJ1WQ3A0uYobWa34byyWI9/PH5DactwC7bwsHcQ1hkA/GYCs6S3p8YACLAQW13WgV+zsUDSGdI/u4UjWAsxFoz6aFM29U8FFRR3jhDErReOkRBrZKIIL5I5nGref6u1em3szRSOvKusVC8uCQ= 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+81702+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 1633704417783204.90408759085528; Fri, 8 Oct 2021 07:46:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jfkoYY1788612xputF31Y86g; Fri, 08 Oct 2021 07:46:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10313.1633704416815814264 for ; Fri, 08 Oct 2021 07:46: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 7E4401063; Fri, 8 Oct 2021 07:46:56 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7432A3F66F; Fri, 8 Oct 2021 07:46:55 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 13/21] DynamicTablesPkg: Helper function to compute package length Date: Fri, 8 Oct 2021 15:46:24 +0100 Message-Id: <20211008144632.31894-14-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: rrvcgEz0OhMbHvYYeqDE8fe7x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704417; bh=iuQtFsCcFR1z0aspvLkRKghH3ugIcE6wNViB1jLKJXg=; h=Date:From:Reply-To:Subject:To; b=tl7BP3mxbpP7kRjBaKt8Ldqnq3+OGqDWwdoXQjl3Rxef4dDuY02bdWD5zqf+5SsKrjF ozKCw52g4hmLxLOqmA6EZzw0AaTlMIZDKD+KqAoGi4ai77t3lIcmc53qtLM/KEtOBrTK+ gKDDOIy+bLWe7hwWDrIsVNVDQ5N3L+cvg8s= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704419668100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Some AML object have a PkgLen which indicates the size of the AML object. The package length can be encoded in 1 to 4 bytes. The bytes used to encode the PkgLen is itself counted in the PkgLen value. So, if an AML object's size increments/decrements, the number of bytes used to encode the PkgLen value can itself increment/decrement. Therefore, a helper function AmlComputePkgLength() is introduced to simply computation of the PkgLen. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Library/Common/AmlLib/AmlEncoding/Aml.c | 87 ++++++++++++++++++- .../Library/Common/AmlLib/AmlEncoding/Aml.h | 47 +++++++++- 2 files changed, 132 insertions(+), 2 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.c b/Dyn= amicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.c index eadafca97ea5..d829b1869846 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.c @@ -2,7 +2,7 @@ AML grammar definitions. =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 **/ @@ -803,3 +803,88 @@ AmlComputePkgLengthWidth ( // Length < 2^6 return 1; } + +/** Given a length, compute the value of a PkgLen. + + In AML, some object have a PkgLen, telling the size of the AML object. + It can be encoded in 1 to 4 bytes. The bytes used to encode the PkgLen is + itself counted in the PkgLen value. + This means that if an AML object sees its size increment/decrement, + the number of bytes used to encode the PkgLen value can itself + increment/decrement. + + For instance, the AML encoding of a DeviceOp is: + DefDevice :=3D DeviceOp PkgLength NameString TermList + If: + - sizeof (NameString) =3D 4 (the name is "DEV0" for instance); + - sizeof (TermList) =3D (2^6-6) + then the PkgLen is encoded on 1 byte. Indeed, its value is: + sizeof (PkgLen) + sizeof (NameString) + sizeof (TermList) =3D + sizeof (PkgLen) + 4 + (2^6-6) + So: + PkgLen =3D sizeof (PkgLen) + (2^6-2) + + The input arguments Length and PkgLen represent, for the DefDevice: + DefDevice :=3D DeviceOp PkgLength NameString TermList + |------Length-----| + |--------*PgkLength---------| + + @param [in] Length The length to encode as a PkgLen. + Length cannot exceed 2^28 - 4 (4 bytes for the + PkgLen encoding). + The size of the PkgLen encoding bytes should not be + counted in this length value. + @param [out] PkgLen If success, contains the value of the PkgLen, + ready to encode in the PkgLen format. + This value takes into account the size of PkgLen + encoding. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlComputePkgLength ( + IN UINT32 Length, + OUT UINT32 * PkgLen + ) +{ + UINT32 PkgLenWidth; + UINT32 ReComputedPkgLenWidth; + + if (PkgLen =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Compute the PkgLenWidth. + PkgLenWidth =3D AmlComputePkgLengthWidth (Length); + if (PkgLenWidth =3D=3D 0) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Add it to the Length. + Length +=3D PkgLenWidth; + + // Check that adding the PkgLenWidth didn't trigger a domino effect, + // increasing the encoding width of the PkgLen again. + // The PkgLen is encoded in at most 4 bytes. It is possible to increase + // the PkgLen width if its encoding is less than 3 bytes. + ReComputedPkgLenWidth =3D AmlComputePkgLengthWidth (Length); + if (ReComputedPkgLenWidth !=3D PkgLenWidth) { + if ((ReComputedPkgLenWidth !=3D 0) && + (ReComputedPkgLenWidth < 4)) { + // No need to recompute the PkgLen since a new threshold cannot + // be reached by incrementing the value by one. + Length +=3D 1; + } else { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + } + + *PkgLen =3D Length; + + return EFI_SUCCESS; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.h b/Dyn= amicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.h index 35c0680b6159..0641500fcd5f 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlEncoding/Aml.h @@ -2,7 +2,7 @@ AML grammar definitions. =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 **/ @@ -326,5 +326,50 @@ AmlComputePkgLengthWidth ( IN UINT32 Length ); =20 +/** Given a length, compute the value of a PkgLen. + + In AML, some object have a PkgLen, telling the size of the AML object. + It can be encoded in 1 to 4 bytes. The bytes used to encode the PkgLen is + itself counted in the PkgLen value. + This means that if an AML object sees its size increment/decrement, + the number of bytes used to encode the PkgLen value can itself + increment/decrement. + + For instance, the AML encoding of a DeviceOp is: + DefDevice :=3D DeviceOp PkgLength NameString TermList + If: + - sizeof (NameString) =3D 4 (the name is "DEV0" for instance); + - sizeof (TermList) =3D (2^6-6) + then the PkgLen is encoded on 1 byte. Indeed, its value is: + sizeof (PkgLen) + sizeof (NameString) + sizeof (TermList) =3D + sizeof (PkgLen) + 4 + (2^6-6) + So: + PkgLen =3D sizeof (PkgLen) + (2^6-2) + + The input arguments Length and PkgLen represent, for the DefDevice: + DefDevice :=3D DeviceOp PkgLength NameString TermList + |------Length-----| + |--------*PgkLength---------| + + @param [in] Length The length to encode as a PkgLen. + Length cannot exceed 2^28 - 4 (4 bytes for the + PkgLen encoding). + The size of the PkgLen encoding bytes should not be + counted in this length value. + @param [out] PkgLen If success, contains the value of the PkgLen, + ready to encode in the PkgLen format. + This value takes into account the size of PkgLen + encoding. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlComputePkgLength ( + IN UINT32 Length, + OUT UINT32 * PkgLen + ); + #endif // AML_H_ =20 --=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 (#81702): https://edk2.groups.io/g/devel/message/81702 Mute This Topic: https://groups.io/mt/86172111/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 Fri Apr 26 01:22:25 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+81703+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+81703+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704419; cv=none; d=zohomail.com; s=zohoarc; b=RnXkTVgJ/ujdi4ymsx6P6FVNN86AMJdwWCOBGq1uGCW8i5Szwj4iNOxIuSAAccweXOVGM+t8zuflR1ucC+YiCNKC9/Hcdz1+HQcFZhX8DLTtW/3Tqq7HdwsxKyicWLMKKBf86c35cjWXizkK4HSJFRGIETIaKajDfpDHVpHNDZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704419; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=0MKHo2b2UaxG+8YazB40PmWDlHR3aFmDrUlnCU56JRA=; b=OpuLDNuzIL53YpU3xy11N2MQ5ICaeHYO/3oNU+iBVy1QN2zUfVjWhSld+01FM3ZkoQl7BX2gmHFg9Hjb2cWRBTN9Z52K+iHFDoa76J6KMYbVXlobtAKM6KCPowqhgUfFqiRsz0V4Ly/9H2h2YQkI4tYmRmqTV4TCsBQ6DxS6Vn4= 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+81703+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 1633704419042459.3272363841884; Fri, 8 Oct 2021 07:46:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id BdzKYY1788612xUpt3c9NxLI; Fri, 08 Oct 2021 07:46:58 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10314.1633704418090489032 for ; Fri, 08 Oct 2021 07:46: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 B5DB011FB; Fri, 8 Oct 2021 07:46:57 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CDCCF3F66F; Fri, 8 Oct 2021 07:46:56 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 14/21] DynamicTablesPkg: AML code generation for a ResourceTemplate Date: Fri, 8 Oct 2021 15:46:25 +0100 Message-Id: <20211008144632.31894-15-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: AJeD5WKuwllooAfAHS0xaqyyx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704418; bh=oveOVP30H0FMWg0uDRQek1go23ysj0AAOFhWpBDGYjE=; h=Date:From:Reply-To:Subject:To; b=CnExqtyOap+YPWJM1CssU5ll8X067Qs+qd87SDILlhPw0Hi0X+c5Bwq6A9DTKd4WHE/ irKjabJaXnNu5lv1aKE0WKtwfn8fTx6FTlwGAtUlKph5G7ShmpzYz+IW1vnkGII9DoVlp 2VRAwRazvSzblsjhJ3NmY2Bk8blIRn4SxHc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704419856100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois ASL provides a ResourceTemplate macro that creates a Buffer in which resource descriptor macros can be listed. The ResourceTemplate macro automatically generates an End descriptor and calculates the checksum for the resource template. Therefore, add AmlCodeGenResourceTemplate() to generate AML code for the ResourceTemplate() macro. This function generates a Buffer node with an EndTag resource data descriptor, which is similar to the ASL ResourceTemplate() macro. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index a4cd2502dc56..da80e9d77cc2 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -12,6 +12,7 @@ =20 #include #include +#include #include #include #include @@ -316,6 +317,195 @@ error_handler: return Status; } =20 +/** AML code generation for a Buffer object node. + + To create a Buffer object node with an empty buffer, + call the function with (Buffer=3DNULL, BufferSize=3D0). + + @param [in] Buffer Buffer to set for the created Buffer + object node. The Buffer's content is copied. + NULL if there is no buffer to set for + the Buffer node. + @param [in] BufferSize Size of the Buffer. + 0 if there is no buffer to set for + the Buffer node. + @param [out] NewObjectNode If success, contains the created + Buffer object node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenBuffer ( + IN CONST UINT8 * Buffer, OPTIONAL + IN UINT32 BufferSize, OPTIONAL + OUT AML_OBJECT_NODE ** NewObjectNode + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE * BufferNode; + AML_OBJECT_NODE * BufferSizeNode; + UINT32 BufferSizeNodeSize; + AML_DATA_NODE * DataNode; + UINT32 PkgLen; + + // Buffer and BufferSize must be either both set, or both clear. + if ((NewObjectNode =3D=3D NULL) || + ((Buffer =3D=3D NULL) !=3D (BufferSize =3D=3D 0))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + BufferNode =3D NULL; + DataNode =3D NULL; + + // Cf ACPI 6.3 specification, s20.2.5.4 "Type 2 Opcodes Encoding" + // DefBuffer :=3D BufferOp PkgLength BufferSize ByteList + // BufferOp :=3D 0x11 + // BufferSize :=3D TermArg =3D> Integer + + Status =3D AmlCodeGenInteger (BufferSize, &BufferSizeNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Get the number of bytes required to encode the BufferSizeNode. + Status =3D AmlComputeSize ( + (AML_NODE_HEADER*)BufferSizeNode, + &BufferSizeNodeSize + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + // Compute the size to write in the PkgLen. + Status =3D AmlComputePkgLength (BufferSizeNodeSize + BufferSize, &PkgLen= ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + // Create an object node for the buffer. + Status =3D AmlCreateObjectNode ( + AmlGetByteEncodingByOpCode (AML_BUFFER_OP, 0), + PkgLen, + &BufferNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + // Set the BufferSizeNode as a fixed argument of the BufferNode. + Status =3D AmlSetFixedArgument ( + BufferNode, + EAmlParseIndexTerm0, + (AML_NODE_HEADER*)BufferSizeNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + // BufferSizeNode is now attached. + BufferSizeNode =3D NULL; + + // If there is a buffer, create a DataNode and attach it to the BufferNo= de. + if (Buffer !=3D NULL) { + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeRaw, + Buffer, + BufferSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HEADER*)BufferNode, + (AML_NODE_HEADER*)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + } + + *NewObjectNode =3D BufferNode; + return Status; + +error_handler: + if (BufferSizeNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)BufferSizeNode); + } + if (BufferNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)BufferNode); + } + if (DataNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)DataNode); + } + return Status; +} + +/** AML code generation for a ResourceTemplate. + + "ResourceTemplate" is a macro defined in ACPI 6.3, s19.3.3 + "ASL Resource Templates". It allows to store resource data elements. + + In AML, a ResourceTemplate is implemented as a Buffer storing resource + data elements. An EndTag resource data descriptor must be at the end + of the list of resource data elements. + This function generates a Buffer node with an EndTag resource data + descriptor. It can be seen as an empty list of resource data elements. + + @param [out] NewObjectNode If success, contains the created + ResourceTemplate object node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenResourceTemplate ( + OUT AML_OBJECT_NODE ** NewObjectNode + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE * BufferNode; + + if (NewObjectNode =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Create a BufferNode with an empty buffer. + Status =3D AmlCodeGenBuffer (NULL, 0, &BufferNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Create an EndTag resource data element and attach it to the Buffer. + Status =3D AmlCodeGenEndTag (0, BufferNode, NULL); + if (EFI_ERROR (Status)) { + ASSERT (0); + AmlDeleteTree ((AML_NODE_HEADER*)BufferNode); + return Status; + } + + *NewObjectNode =3D BufferNode; + return Status; +} + /** AML code generation for a Name object node. =20 @param [in] NameString The new variable name. --=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 (#81703): https://edk2.groups.io/g/devel/message/81703 Mute This Topic: https://groups.io/mt/86172112/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 Fri Apr 26 01:22:25 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+81704+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+81704+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704420; cv=none; d=zohomail.com; s=zohoarc; b=ahrhmzIkPAuKTF0lNlzwYwcxJZ/utso1ICRG+10nrw92JwY9NDJHDMSYQ85x2u+Bqbz6R/xVxZ1/4zRu1+EV/3scFDatxcXY91CML99QFXMm5xo05oGgXTNZULwQil2A/bXk2+CSnvYqcwTaBlZXuh5rthOuaXLuGtJ16XEg6qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704420; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=YZ4gqcaDymOF49VK5RJHWs3orMogSF627G9zwAsQVGU=; b=nLm7lm/tQszKqNTvKEYEBpkJVbkLP9v2Pj+pve4YIyLrlM9ld9SKwIBizhGRStQXyL1p1WcBYS+tddx2bGtcoXirGif7i+JIdB3VHIHL9JHLK11L7f0K7XJ6B3zjMH2XkCiVaTUjk+LFf6ELLqtIgcrfxQ85lPuqS18s0AQD2Zk= 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+81704+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 1633704420166102.60168335504909; Fri, 8 Oct 2021 07:47:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XKcgYY1788612xueb8UUfG1a; Fri, 08 Oct 2021 07:46:59 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.10321.1633704419173677233 for ; Fri, 08 Oct 2021 07:46:59 -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 DDA0E6D; Fri, 8 Oct 2021 07:46:58 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 11D073F66F; Fri, 8 Oct 2021 07:46:57 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 15/21] DynamicTablesPkg: AML code generation for a Method Date: Fri, 8 Oct 2021 15:46:26 +0100 Message-Id: <20211008144632.31894-16-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: MFbleaskMF13z62LetP51lLpx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704419; bh=I7mVijDH3UlQt40yl6Qk5Mgr+7sSPTPiQhi12pY9IyQ=; h=Date:From:Reply-To:Subject:To; b=LR3tUbVrCIGC9GH/ieI9MyH0n1LU43S/v7JEXVmi2CKd1XE8MOpiU5D+ATRneSNNqpP F+1JOafq3ZV6X1xsI+ruWYer3BvbYTxmpA0Y1oUhYZjiFqrz07xE9AS4UyDT04T7Ckq4t MOWgKqA6rsaqCGCW3npgljo4Q/aAl36+Pdk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704421939100011 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenMethod() to generate code for a control method. AmlCodeGenMethod ("MET0", 1, TRUE, 3, ParentNode, NewObjectNode) is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) {} Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index da80e9d77cc2..dd519bc67007 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -970,3 +970,187 @@ error_handler1: =20 return Status; } + +/** AML code generation for a Method object node. + + AmlCodeGenMethod ("MET0", 1, TRUE, 3, ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Method(MET0, 1, Serialized, 3) {} + + ACPI 6.4, s20.2.5.2 "Named Objects Encoding": + DefMethod :=3D MethodOp PkgLength NameString MethodFlags TermList + MethodOp :=3D 0x14 + + The ASL parameters "ReturnType" and "ParameterTypes" are not asked + in this function. They are optional parameters in ASL. + + @param [in] NameString The new Method's name. + Must be a NULL-terminated ASL NameString + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] NumArgs Number of arguments. + Must be 0 <=3D NumArgs <=3D 6. + @param [in] IsSerialized TRUE is equivalent to Serialized. + FALSE is equivalent to NotSerialized. + Default is NotSerialized in ASL spec. + @param [in] SyncLevel Synchronization level for the method. + Must be 0 <=3D SyncLevel <=3D 15. + Default is 0 in ASL. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenMethod ( + IN CONST CHAR8 * NameString, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN AML_NODE_HEADER * ParentNode, OPTIONAL + OUT AML_OBJECT_NODE ** NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + UINT32 PkgLen; + UINT8 Flags; + AML_OBJECT_NODE * ObjectNode; + AML_DATA_NODE * DataNode; + CHAR8 * AmlNameString; + UINT32 AmlNameStringSize; + + if ((NameString =3D=3D NULL) || + (NumArgs > 6) || + (SyncLevel > 15) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + ObjectNode =3D NULL; + DataNode =3D NULL; + + // ACPI 6.4, s20.2.5.2 "Named Objects Encoding": + // DefMethod :=3D MethodOp PkgLength NameString MethodFlags TermList + // MethodOp :=3D 0x14 + // So: + // 1- Create the NameString + // 2- Compute the size to write in the PkgLen + // 3- Create nodes for the NameString and Method object node + // 4- Set the NameString DataNode as a fixed argument + // 5- Create and link the MethodFlags node + + // 1- Create the NameString + Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler1; + } + + // 2- Compute the size to write in the PkgLen + // Add 1 byte (ByteData) for MethodFlags. + Status =3D AmlComputePkgLength (AmlNameStringSize + 1, &PkgLen); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler1; + } + + // 3- Create nodes for the NameString and Method object node + Status =3D AmlCreateObjectNode ( + AmlGetByteEncodingByOpCode (AML_METHOD_OP, 0), + PkgLen, + &ObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler1; + } + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8*)AmlNameString, + AmlNameStringSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler2; + } + + // 4- Set the NameString DataNode as a fixed argument + Status =3D AmlSetFixedArgument ( + ObjectNode, + EAmlParseIndexTerm0, + (AML_NODE_HEADER*)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler2; + } + + DataNode =3D NULL; + + // 5- Create and link the MethodFlags node + Flags =3D NumArgs | + (IsSerialized ? BIT3 : 0) | + (SyncLevel << 4); + + Status =3D AmlCreateDataNode (EAmlNodeDataTypeUInt, &Flags, 1, &DataNode= ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler2; + } + + Status =3D AmlSetFixedArgument ( + ObjectNode, + EAmlParseIndexTerm1, + (AML_NODE_HEADER*)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler2; + } + + // Data node is attached so set the pointer to + // NULL to ensure correct error handling. + DataNode =3D NULL; + + Status =3D LinkNode ( + ObjectNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler2; + } + + // Free AmlNameString before returning as it is copied + // in the call to AmlCreateDataNode(). + goto error_handler1; + +error_handler2: + if (ObjectNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode); + } + if (DataNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)DataNode); + } + +error_handler1: + if (AmlNameString !=3D NULL) { + FreePool (AmlNameString); + } + 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 (#81704): https://edk2.groups.io/g/devel/message/81704 Mute This Topic: https://groups.io/mt/86172113/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 Fri Apr 26 01:22:25 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+81705+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+81705+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704421; cv=none; d=zohomail.com; s=zohoarc; b=Agll/WXTMHiG+nNh7XNVwUcuqkR2M5KYjrVM06hmn9GTtPdmb9Xz/YMPrSvI7Snc9Uddx1gohtsRiVETHFLDLdNBA7Sw+VDB7zKzOdZ2sXlLz35wPODDQf/XaQ0m26Q+elS23Tqt7BmtkG7K1l/81eFOMh8MX2Bmu6lO3HYIiZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704421; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=puVsdVu5iq4aNKvA/yjzp9uHGbxMqZTYDe/GnvIU7cI=; b=YofiBoho+3MeAtmh7yXXYr3vyjq6NLRz5TjyATFBHaLKViS4pN1wJK5Oe0thbTj6trrJLv5SOPxE1LALEHMrEOxPcCBWL5JEViYA8JB1V7kfCG/kHW/jIC2d7KTMgfGeaCY9YGDSzk3kEAEDJcyu8E4qgma852d+DXdsbL+Diu8= 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+81705+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 1633704421832166.1734279163236; Fri, 8 Oct 2021 07:47:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id p2rRYY1788612xwXazU4Lsl6; Fri, 08 Oct 2021 07:47:01 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.10389.1633704420908275259 for ; Fri, 08 Oct 2021 07:47:01 -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 95A926D; Fri, 8 Oct 2021 07:47:00 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 68F983F66F; Fri, 8 Oct 2021 07:46:59 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 16/21] DynamicTablesPkg: AML code generation to Return a NameString Date: Fri, 8 Oct 2021 15:46:27 +0100 Message-Id: <20211008144632.31894-17-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: fQd63vspp5xzkME3OM9Lgy3ix1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704421; bh=lD6xmiDw/zPiFryftTezOCHZ6Pxy8k0oqn9KsT7rQWA=; h=Date:From:Reply-To:Subject:To; b=xS9VH0JvYYBSEKpqUri09rEwC0Wvlpuiha13R348Cfqrb9CyYi5+ZSRLVI2SF2Hmbxw rzbK1Ibj6rRDNeOQasEaP6DndHDPyph8k6FSB4oxm8cDG2tWcqZ6LbArgH9vIPNliSGbW E6Sklmz3hb0FJu+19aXgBvyV/3VBIMvVi5g= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704422162100015 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenReturnNameString() to generate AML code for a Return object node, returning the object as a NameString. AmlCodeGenReturn ("NAM1", ParentNode, NewObjectNode) is equivalent of the following ASL code: Return(NAM1) Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 181 ++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index dd519bc67007..93d4ba79e937 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1154,3 +1154,184 @@ error_handler1: } return Status; } + +/** AML code generation for a Return object node. + + AmlCodeGenReturn (ReturnNode, ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Return([Content of the ReturnNode]) + + The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: + DefReturn :=3D ReturnOp ArgObject + ReturnOp :=3D 0xA4 + ArgObject :=3D TermArg =3D> DataRefObject + + Thus, the ReturnNode must be evaluated as a DataRefObject. It can + be a NameString referencing an object. As this CodeGen Api doesn't + do semantic checking, it is strongly advised to check the AML bytecode + generated by this function against an ASL compiler. + + The ReturnNode must be generated inside a Method body scope. + + @param [in] ReturnNode The object returned by the Return ASL statem= ent. + This node is deleted if an error occurs. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + Must be a MethodOp node. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenReturn ( + IN AML_NODE_HEADER * ReturnNode, + IN AML_NODE_HEADER * ParentNode, OPTIONAL + OUT AML_OBJECT_NODE ** NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE * ObjectNode; + + if ((ReturnNode =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL)) || + ((ParentNode !=3D NULL) && + !AmlNodeCompareOpCode ( + (AML_OBJECT_NODE*)ParentNode, AML_METHOD_OP, 0))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D AmlCreateObjectNode ( + AmlGetByteEncodingByOpCode (AML_RETURN_OP, 0), + 0, + &ObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + Status =3D AmlSetFixedArgument ( + ObjectNode, + EAmlParseIndexTerm0, + (AML_NODE_HEADER*)ReturnNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + ReturnNode =3D NULL; + + Status =3D LinkNode ( + ObjectNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + if (ReturnNode !=3D NULL) { + AmlDeleteTree (ReturnNode); + } + if (ObjectNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)ObjectNode); + } + return Status; +} + +/** AML code generation for a Return object node, + returning the object as an input NameString. + + AmlCodeGenReturn ("NAM1", ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Return(NAM1) + + The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: + DefReturn :=3D ReturnOp ArgObject + ReturnOp :=3D 0xA4 + ArgObject :=3D TermArg =3D> DataRefObject + + Thus, the ReturnNode must be evaluated as a DataRefObject. It can + be a NameString referencing an object. As this CodeGen Api doesn't + do semantic checking, it is strongly advised to check the AML bytecode + generated by this function against an ASL compiler. + + The ReturnNode must be generated inside a Method body scope. + + @param [in] NameString The object referenced by this NameString + is returned by the Return ASL statement. + Must be a NULL-terminated ASL NameString + e.g.: "NAM1", "_SB.NAM1", etc. + The input string is copied. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + Must be a MethodOp node. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenReturnNameString ( + IN CONST CHAR8 * NameString, + IN AML_NODE_HEADER * ParentNode, OPTIONAL + OUT AML_OBJECT_NODE ** NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * DataNode; + CHAR8 * AmlNameString; + UINT32 AmlNameStringSize; + + DataNode =3D NULL; + + Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8*)AmlNameString, + AmlNameStringSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + // AmlCodeGenReturn() deletes DataNode if error. + Status =3D AmlCodeGenReturn ( + (AML_NODE_HEADER*)DataNode, + ParentNode, + NewObjectNode + ); + ASSERT_EFI_ERROR (Status); + +exit_handler: + if (AmlNameString !=3D NULL) { + FreePool (AmlNameString); + } + 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 (#81705): https://edk2.groups.io/g/devel/message/81705 Mute This Topic: https://groups.io/mt/86172115/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 Fri Apr 26 01:22:25 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+81706+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+81706+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704423; cv=none; d=zohomail.com; s=zohoarc; b=nLqC0Pude7p0SkexL53zZtyi+qkGXa27yxkRnfQ/qR0WHelV+6YadcUOOpliCHJiRhK6YwTtvtNzwxtZ/VCKU6nDis8GKDkFm2sqWD7P149hS1SlFJ428UTegE0RnxrfKt5Hhm6rUqLL71Tm6bd8jwRY4v9DFSPaghGt9Tx/WaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704423; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=CTQu6VIhmbeFzEa59lRdxk7G4rl4iJHDTj4WG7npw/Y=; b=TafBROo4TTJ+WrgPBfgCHOUDf+vV4hZh7/T3HSvVx176L3AohBBA5RhoBwg0g7sT6QQcotBl6zzI+cSzKBC8R4uBY90qmPe50dPo7nQehZBYMAzi6YwEaFqHwfZroOjPIa0qWHc5DlL/xvbdgZ1rO4gkuBSmjTbIoQhvSJEkX6M= 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+81706+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 1633704423644178.35996832568287; Fri, 8 Oct 2021 07:47:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MjkZYY1788612xDixMqGYL3k; Fri, 08 Oct 2021 07:47:03 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10575.1633704422676439959 for ; Fri, 08 Oct 2021 07:47:02 -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 3E10A1063; Fri, 8 Oct 2021 07:47:02 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 012293F66F; Fri, 8 Oct 2021 07:47:00 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 17/21] DynamicTablesPkg: AML code generation for a Method returning a NS Date: Fri, 8 Oct 2021 15:46:28 +0100 Message-Id: <20211008144632.31894-18-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: 200xiOaHJU4KmFVkY5jqHmLkx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704423; bh=8fh7qBjTuEYS6uEpREdg/WEqYDoqlcztSXnETbcJgz4=; h=Date:From:Reply-To:Subject:To; b=dTKN33GG1t3keyW3PYZXKNzlZ8s0r5E7G2/hnkimKLqDU5t1zN5UGe4bxHyiq1+kWbQ DhGYIfSVf2XXJeu04pERXKHWRc8d4UuyC5l2aSlZMP0J3bHUtETW//FDu4gl+7QNbpikM dEFd6r/Kh6nEA86NVNeO0XO0vFO0BvS0Ngg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704424300100021 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenMethodRetNameString() to generate AML code to create a Method returning a NameString (NS). AmlCodeGenMethodRetNameString ( "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode ); is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) { Return (_CRS) } Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/AmlLib/AmlLib.h | 53 +++++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 106 ++++++++++++++++++ 2 files changed, 159 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 6824cf3a6c82..7740aac24470 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -619,6 +619,59 @@ AmlCodeGenScope ( OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL ); =20 +/** AML code generation for a method returning a NameString. + + AmlCodeGenMethodRetNameString ( + "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 1, Serialized, 3) { + Return (_CRS) + } + + The ASL parameters "ReturnType" and "ParameterTypes" are not asked + in this function. They are optional parameters in ASL. + + @ingroup CodeGenApis + + @param [in] MethodNameString The new Method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] ReturnedNameString The name of the object returned by the + method. Optional parameter, can be: + - NULL (ignored). + - A NULL-terminated ASL NameString. + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] NumArgs Number of arguments. + Must be 0 <=3D NumArgs <=3D 6. + @param [in] IsSerialized TRUE is equivalent to Serialized. + FALSE is equivalent to NotSerialized. + Default is NotSerialized in ASL spec. + @param [in] SyncLevel Synchronization level for the method. + Must be 0 <=3D SyncLevel <=3D 15. + Default is 0 in ASL. + @param [in] ParentNode If provided, set ParentNode as the par= ent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodRetNameString ( + IN CONST CHAR8 * MethodNameString, + IN CONST CHAR8 * ReturnedNameString, OPTIONAL + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN AML_NODE_HANDLE ParentNode, OPTIONAL + OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL + ); + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 93d4ba79e937..f59a9599930f 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1335,3 +1335,109 @@ exit_handler: } return Status; } + +/** AML code generation for a method returning a NameString. + + AmlCodeGenMethodRetNameString ( + "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 1, Serialized, 3) { + Return (_CRS) + } + + The ASL parameters "ReturnType" and "ParameterTypes" are not asked + in this function. They are optional parameters in ASL. + + @param [in] MethodNameString The new Method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] ReturnedNameString The name of the object returned by the + method. Optional parameter, can be: + - NULL (ignored). + - A NULL-terminated ASL NameString. + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] NumArgs Number of arguments. + Must be 0 <=3D NumArgs <=3D 6. + @param [in] IsSerialized TRUE is equivalent to Serialized. + FALSE is equivalent to NotSerialized. + Default is NotSerialized in ASL spec. + @param [in] SyncLevel Synchronization level for the method. + Must be 0 <=3D SyncLevel <=3D 15. + Default is 0 in ASL. + @param [in] ParentNode If provided, set ParentNode as the par= ent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodRetNameString ( + IN CONST CHAR8 * MethodNameString, + IN CONST CHAR8 * ReturnedNameString, OPTIONAL + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN AML_NODE_HANDLE ParentNode, OPTIONAL + OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE MethodNode; + + if ((MethodNameString =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Create a Method named MethodNameString. + Status =3D AmlCodeGenMethod ( + MethodNameString, + NumArgs, + IsSerialized, + SyncLevel, + NULL, + &MethodNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Return ReturnedNameString if provided. + if (ReturnedNameString !=3D NULL) { + Status =3D AmlCodeGenReturnNameString ( + ReturnedNameString, + (AML_NODE_HANDLE)MethodNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + } + + Status =3D LinkNode ( + MethodNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + if (MethodNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)MethodNode); + } + 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 (#81706): https://edk2.groups.io/g/devel/message/81706 Mute This Topic: https://groups.io/mt/86172116/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 Fri Apr 26 01:22:25 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+81707+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+81707+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704424; cv=none; d=zohomail.com; s=zohoarc; b=T10qmVUfC9WncqwbnxkwOZRh9l3+7f+Ny4Cegt9ZLNAOIj41KUiOX3ByGx7PW/YEqhP+NmCwpWtw0FJnMqmxgiMVzXBAVRLSBZlc/QcCKS9nEUZ0bAfxVJzkzNkEggGcbX9V+pkFEqKVd3enoLVKV13VwJGQQduXwiTgqkUNYV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704424; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=C3BYBIcSNjjvO7Z/w0Wp9t/PcJmhg+u0lSFt3ThjQzE=; b=hZiV1Smc+rzIaQGjU7N1JRoQ9Z20pgHL6HDHfZgXBH+3Pr9eO4tm8P0ABuVw8LThHPMtAtYG+9wl+yxmJLABNOSNaZU1XKKyEI1G9X4Ge4g/cDgpOS/zCLEcKWJMxayhGc4GOSxkrzikoV4QDZiWTiQlsPxZFKWvVil9E2ROwmY= 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+81707+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 1633704424849732.3147770785616; Fri, 8 Oct 2021 07:47:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8YcBYY1788612xxQTAfS24N2; Fri, 08 Oct 2021 07:47:04 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.10317.1633704423847723540 for ; Fri, 08 Oct 2021 07:47:04 -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 8E48E6D; Fri, 8 Oct 2021 07:47:03 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7C4293F66F; Fri, 8 Oct 2021 07:47:02 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 18/21] DynamicTablesPkg: AML code generation for a _LPI object Date: Fri, 8 Oct 2021 15:46:29 +0100 Message-Id: <20211008144632.31894-19-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: unBjJjaCCxsZd9QngdFzykcBx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704424; bh=Otxehn0qyb+9szwMGN72n91tDyUBPCuqPxUCPzbbklk=; h=Date:From:Reply-To:Subject:To; b=BQg/w12r7O/O4UBwdv8+bc8tQLl19ZFkGDOG4IoDf/2+iMppAba/cJeomY2WzqWGBsn Nd6sJpNhwAD8qbA1yiRlfk3O/Gy4HOFyxd+hmfj++LZsCAHupQGgqVnFiym7TB3MDe8x8 MqlP68U1KWysPb+pKTZWz1pxP6O+fpFMBiY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704426479100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois _LPI object provides a method to describe Low Power Idle states that define the local power states for each node in a hierarchical processor topology. Therefore, add AmlCreateLpiNode() to generate code for a _LPI object. AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is equivalent of the following ASL code: Name (_LPI, Package ( 0, // Revision 1, // LevelId 0 // Count )) Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/AmlLib/AmlLib.h | 44 ++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 133 ++++++++++++++++++ 2 files changed, 177 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 7740aac24470..40c45073d303 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -672,6 +672,50 @@ AmlCodeGenMethodRetNameString ( OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL ); =20 +/** Create a _LPI name. + + AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is + equivalent of the following ASL code: + Name (_LPI, Package ( + 0, // Revision + 1, // LevelId + 0 // Count + )) + + This function doesn't define any LPI state. As shown above, the count + of _LPI state is set to 0. + The AmlAddLpiState () function must be used to add LPI states. + + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". + + @ingroup CodeGenApis + + @param [in] LpiNameString The new LPI 's object name. + Must be a NULL-terminated ASL NameString + e.g.: "_LPI", "DEV0.PLPI", etc. + The input string is copied. + @param [in] Revision Revision number of the _LPI states. + @param [in] LevelId A platform defined number that identifies the + level of hierarchy of the processor node to + which the LPI states apply. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + @param [out] NewLpiNode If success, contains the created node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCreateLpiNode ( + IN CONST CHAR8 * LpiNameString, + IN UINT16 Revision, + IN UINT64 LevelId, + IN AML_NODE_HANDLE ParentNode, OPTIONAL + OUT AML_OBJECT_NODE_HANDLE * NewLpiNode OPTIONAL + ); + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index f59a9599930f..9af7a725d5c1 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1441,3 +1441,136 @@ error_handler: } return Status; } + +/** Create a _LPI name. + + AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is + equivalent of the following ASL code: + Name (_LPI, Package ( + 0, // Revision + 1, // LevelId + 0 // Count + )) + + This function doesn't define any LPI state. As shown above, the count + of _LPI state is set to 0. + The AmlAddLpiState () function allows to add LPI states. + + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". + + @param [in] LpiNameString The new LPI 's object name. + Must be a NULL-terminated ASL NameString + e.g.: "_LPI", "DEV0.PLPI", etc. + The input string is copied. + @param [in] Revision Revision number of the _LPI states. + @param [in] LevelId A platform defined number that identifies the + level of hierarchy of the processor node to + which the LPI states apply. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + @param [out] NewLpiNode If success, contains the created node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCreateLpiNode ( + IN CONST CHAR8 * LpiNameString, + IN UINT16 Revision, + IN UINT64 LevelId, + IN AML_NODE_HANDLE ParentNode, OPTIONAL + OUT AML_OBJECT_NODE_HANDLE * NewLpiNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE PackageNode; + AML_OBJECT_NODE_HANDLE IntegerNode; + + if ((LpiNameString =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewLpiNode =3D=3D NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + IntegerNode =3D NULL; + + Status =3D AmlCodeGenPackage (&PackageNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Create and attach Revision + Status =3D AmlCodeGenInteger (Revision, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + IntegerNode =3D NULL; + + // Create and attach LevelId + Status =3D AmlCodeGenInteger (LevelId, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + IntegerNode =3D NULL; + + // Create and attach Count. No LPI state is added, so 0. + Status =3D AmlCodeGenInteger (0, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + IntegerNode =3D NULL; + + Status =3D AmlCodeGenName (LpiNameString, PackageNode, ParentNode, NewLp= iNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + AmlDeleteTree ((AML_NODE_HANDLE)PackageNode); + if (IntegerNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode); + } + 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 (#81707): https://edk2.groups.io/g/devel/message/81707 Mute This Topic: https://groups.io/mt/86172118/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 Fri Apr 26 01:22:25 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+81708+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+81708+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704426; cv=none; d=zohomail.com; s=zohoarc; b=mF5SFg4qi35O+kloT/utnqSsLHy+UPq69XOA/25nc0Jcoy1XPfIpCPZ6o6q8BrL4bDDDx/ulqjfX4mSTARueMfvlU/1sYyKnk9bIkNK1KPS0EEmpQt7vUIq1lGaPpJigPOovHDaSlYZQsgsm4mENsVIdj5yLPNakM+1bOesa4Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704426; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=aKtuUBd7Cf4y4dKH9WMOhNL9kWGGPJQRhjvOKILMMDo=; b=bfGiTRSJPauJfP6M546YhdJfy5XYpo+4tPuohvkjCxdRW9afTNWv76eOOTLW4Uy05uBtrKtAbcf7XcVACYFpTlfNG18LTTvN3yiMTaG6HAfsr1Nk9+z0zNaOj1gBmNZBIe8DCS1HJteSZDB1mRwfo1hjCkVE5u9AYwSrhKhQfCo= 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+81708+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 1633704426760219.29104975566827; Fri, 8 Oct 2021 07:47:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Km7YYY1788612xIPBY72HZaa; Fri, 08 Oct 2021 07:47:06 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.10578.1633704425625536767 for ; Fri, 08 Oct 2021 07:47:05 -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 4EB086D; Fri, 8 Oct 2021 07:47:05 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EDC5C3F66F; Fri, 8 Oct 2021 07:47:03 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 19/21] DynamicTablesPkg: AML code generation to add an _LPI state Date: Fri, 8 Oct 2021 15:46:30 +0100 Message-Id: <20211008144632.31894-20-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: ru7wbUJLbuuLrxoYkxPbVPplx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704426; bh=4VTIWhHQE2wQ+/edetgyMqSJHYfHgCROspHRJnBPRTM=; h=Date:From:Reply-To:Subject:To; b=Y4CkEtmh48npN0u1PRwOTLxDsd2fZDZZWgqBGqMNA7BmyuQg8kO49RtT/4Ezttcl2g/ LbHQWi3H/Oe0N3D4GGVUPHgpJT+2aUYUVQII+0GN4lEzKZgBYJUP0xUtGz5Tq6hJQFkpz 2vQzBwZuBCwPbiMKpgT0Oqo2iU43mhmo1jw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704428618100006 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlAddLpiState() to generates AML code to add an _LPI state to an _LPI object created using AmlCreateLpiNode(). AmlAddLpiState increments the count of LPI states in the LPI node by one, and adds the following package: Package() { MinResidency, WorstCaseWakeLatency, Flags, ArchFlags, ResCntFreq, EnableParentState, (GenericRegisterDescriptor !=3D NULL) ? // Entry method. If a ResourceTemplate(GenericRegisterDescriptor) : // Register is given, Integer, // use it. Use the // Integer otherwise ResourceTemplate() { // NULL Residency Register (SystemMemory, 0, 0, 0, 0) // Counter }, ResourceTemplate() { // NULL Usage Counter Register (SystemMemory, 0, 0, 0, 0) }, "" // NULL State Name }, Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/AmlLib/AmlLib.h | 71 +++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 459 ++++++++++++++++++ 2 files changed, 530 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 40c45073d303..4932f6fd9c8b 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -716,6 +716,77 @@ AmlCreateLpiNode ( OUT AML_OBJECT_NODE_HANDLE * NewLpiNode OPTIONAL ); =20 +/** Add an _LPI state to a LPI node created using AmlCreateLpiNode (). + + AmlAddLpiState () increments the Count of LPI states in the LPI node by = one, + and adds the following package: + Package() { + MinResidency, + WorstCaseWakeLatency, + Flags, + ArchFlags, + ResCntFreq, + EnableParentState, + (GenericRegisterDescriptor !=3D NULL) ? // Entry method. I= f a + ResourceTemplate(GenericRegisterDescriptor) : // Register is given, + Integer, // use it. Use the + // Integer otherwise. + ResourceTemplate() { // NULL Residency Co= unter + Register (SystemMemory, 0, 0, 0, 0) + }, + ResourceTemplate() { // NULL Usage Counter + Register (SystemMemory, 0, 0, 0, 0) + }, + "" // NULL State Name + }, + + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". + + @ingroup CodeGenApis + + @param [in] MinResidency Minimum Residency. + @param [in] WorstCaseWakeLatency Worst case wake-up latency. + @param [in] Flags Flags. + @param [in] ArchFlags Architectural flags. + @param [in] ResCntFreq Residency Counter Frequency. + @param [in] EnableParentState Enabled Parent State. + @param [in] GenericRegisterDescriptor Entry Method. + If not NULL, use this Register to + describe the entry method addres= s. + @param [in] Integer Entry Method. + If GenericRegisterDescriptor is = NULL, + take this value. + @param [in] ResidencyCounterRegister If not NULL, use it to populate = the + residency counter register. + @param [in] UsageCounterRegister If not NULL, use it to populate = the + usage counter register. + @param [in] StateName If not NULL, use it to populate = the + state name. + @param [in] LpiNode Lpi node created with the functi= on + AmlCreateLpiNode to which the ne= w LPI + state is appended. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlAddLpiState ( + IN UINT32 MinResidency, + IN UINT32 WorstCaseWakeLatency, + IN UINT32 Flags, + IN UINT32 ArchFlags, + IN UINT32 ResCntFreq, + IN UINT32 EnableParentState, + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * GenericRegisterDescriptor,= OPTIONAL + IN UINT64 Integer, = OPTIONAL + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * ResidencyCounterRegister, = OPTIONAL + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * UsageCounterRegister, = OPTIONAL + IN CHAR8 * StateName, = OPTIONAL + IN AML_OBJECT_NODE_HANDLE LpiNode + ); + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 9af7a725d5c1..64064018aecb 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -12,6 +12,7 @@ =20 #include #include +#include #include #include #include @@ -1574,3 +1575,461 @@ error_handler: } return Status; } + +/** Add an _LPI state to a LPI node created using AmlCreateLpiNode. + + AmlAddLpiState increments the Count of LPI states in the LPI node by one, + and adds the following package: + Package() { + MinResidency, + WorstCaseWakeLatency, + Flags, + ArchFlags, + ResCntFreq, + EnableParentState, + (GenericRegisterDescriptor !=3D NULL) ? // Entry method. I= f a + ResourceTemplate(GenericRegisterDescriptor) : // Register is given, + Integer, // use it. Use the + // Integer otherwise. + ResourceTemplate() { // NULL Residency Co= unter + Register (SystemMemory, 0, 0, 0, 0) + }, + ResourceTemplate() { // NULL Usage Counter + Register (SystemMemory, 0, 0, 0, 0) + }, + "" // NULL State Name + }, + + Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States". + + @param [in] MinResidency Minimum Residency. + @param [in] WorstCaseWakeLatency Worst case wake-up latency. + @param [in] Flags Flags. + @param [in] ArchFlags Architectural flags. + @param [in] ResCntFreq Residency Counter Frequency. + @param [in] EnableParentState Enabled Parent State. + @param [in] GenericRegisterDescriptor Entry Method. + If not NULL, use this Register to + describe the entry method addres= s. + @param [in] Integer Entry Method. + If GenericRegisterDescriptor is = NULL, + take this value. + @param [in] ResidencyCounterRegister If not NULL, use it to populate = the + residency counter register. + @param [in] UsageCounterRegister If not NULL, use it to populate = the + usage counter register. + @param [in] StateName If not NULL, use it to populate = the + state name. + @param [in] LpiNode Lpi node created with the functi= on + AmlCreateLpiNode to which the ne= w LPI + state is appended. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlAddLpiState ( + IN UINT32 MinResidency, + IN UINT32 WorstCaseWakeLatency, + IN UINT32 Flags, + IN UINT32 ArchFlags, + IN UINT32 ResCntFreq, + IN UINT32 EnableParentState, + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * GenericRegisterDescriptor,= OPTIONAL + IN UINT64 Integer, = OPTIONAL + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * ResidencyCounterRegister, = OPTIONAL + IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE * UsageCounterRegister, = OPTIONAL + IN CHAR8 * StateName, = OPTIONAL + IN AML_OBJECT_NODE_HANDLE LpiNode + ) +{ + EFI_STATUS Status; + AML_DATA_NODE_HANDLE RdNode; + AML_OBJECT_NODE_HANDLE PackageNode; + AML_OBJECT_NODE_HANDLE IntegerNode; + AML_OBJECT_NODE_HANDLE StringNode; + AML_OBJECT_NODE_HANDLE NewLpiPackageNode; + AML_OBJECT_NODE_HANDLE ResourceTemplateNode; + + UINT32 Index; + AML_OBJECT_NODE_HANDLE CountNode; + UINT64 Count; + + if ((LpiNode =3D=3D NULL) || + (AmlGetNodeType ((AML_NODE_HANDLE)LpiNode) !=3D EAmlNodeObject) || + (!AmlNodeHasOpCode (LpiNode, AML_NAME_OP, 0))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + RdNode =3D 0; + StringNode =3D NULL; + IntegerNode =3D NULL; + ResourceTemplateNode =3D NULL; + + // AmlCreateLpiNode () created a LPI container such as: + // Name (_LPI, Package ( + // 0, // Revision + // 1, // LevelId + // 0 // Count + // )) + // Get the LPI container, a PackageOp object node stored as the 2nd fixed + // argument (i.e. index 1) of LpiNode. + PackageNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + LpiNode, + EAmlParseIndexTerm1 + ); + if ((PackageNode =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) !=3D EAmlNodeObject) = || + (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + CountNode =3D NULL; + // The third variable argument is the LPI Count node. + for (Index =3D 0; Index < 3; Index++) { + CountNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetNextVariableArgument ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)CountNode + ); + if (CountNode =3D=3D NULL) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + } + + Status =3D AmlNodeGetIntegerValue (CountNode, &Count); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + Status =3D AmlUpdateInteger (CountNode, Count + 1); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenPackage (&NewLpiPackageNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // MinResidency + Status =3D AmlCodeGenInteger (MinResidency, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // WorstCaseWakeLatency + Status =3D AmlCodeGenInteger (WorstCaseWakeLatency, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // Flags + Status =3D AmlCodeGenInteger (Flags, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // ArchFlags + Status =3D AmlCodeGenInteger (ArchFlags, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // ResCntFreq + Status =3D AmlCodeGenInteger (ResCntFreq, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // EnableParentState + Status =3D AmlCodeGenInteger (EnableParentState, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + + // Entry Method + if (GenericRegisterDescriptor !=3D NULL) { + // Entry Method: As a Register resource data + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + ResourceTemplateNode =3D NULL; + goto error_handler; + } + Status =3D AmlCodeGenRdRegister ( + GenericRegisterDescriptor->AddressSpaceId, + GenericRegisterDescriptor->RegisterBitWidth, + GenericRegisterDescriptor->RegisterBitOffset, + GenericRegisterDescriptor->Address, + GenericRegisterDescriptor->AccessSize, + NULL, + &RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + RdNode =3D NULL; + goto error_handler; + } + + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + RdNode =3D NULL; + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)ResourceTemplateNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + ResourceTemplateNode =3D NULL; + } else { + // Entry Method: As an integer + Status =3D AmlCodeGenInteger (Integer, &IntegerNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + IntegerNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)IntegerNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + IntegerNode =3D NULL; + } + + // Residency Counter Register. + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + ResourceTemplateNode =3D NULL; + goto error_handler; + } + if (ResidencyCounterRegister !=3D NULL) { + Status =3D AmlCodeGenRdRegister ( + ResidencyCounterRegister->AddressSpaceId, + ResidencyCounterRegister->RegisterBitWidth, + ResidencyCounterRegister->RegisterBitOffset, + ResidencyCounterRegister->Address, + ResidencyCounterRegister->AccessSize, + NULL, + &RdNode + ); + } else { + Status =3D AmlCodeGenRdRegister ( + EFI_ACPI_6_4_SYSTEM_MEMORY, + 0, + 0, + 0, + 0, + NULL, + &RdNode + ); + } + if (EFI_ERROR (Status)) { + ASSERT (0); + RdNode =3D NULL; + goto error_handler; + } + + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + RdNode =3D NULL; + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)ResourceTemplateNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + ResourceTemplateNode =3D NULL; + + // Usage Counter Register. + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + ResourceTemplateNode =3D NULL; + goto error_handler; + } + if (UsageCounterRegister !=3D NULL) { + Status =3D AmlCodeGenRdRegister ( + UsageCounterRegister->AddressSpaceId, + UsageCounterRegister->RegisterBitWidth, + UsageCounterRegister->RegisterBitOffset, + UsageCounterRegister->Address, + UsageCounterRegister->AccessSize, + NULL, + &RdNode + ); + } else { + Status =3D AmlCodeGenRdRegister ( + EFI_ACPI_6_4_SYSTEM_MEMORY, + 0, + 0, + 0, + 0, + NULL, + &RdNode + ); + } + if (EFI_ERROR (Status)) { + ASSERT (0); + RdNode =3D NULL; + goto error_handler; + } + + Status =3D AmlAppendRdNode (ResourceTemplateNode, RdNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + RdNode =3D NULL; + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)ResourceTemplateNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + ResourceTemplateNode =3D NULL; + + // State name. + if (UsageCounterRegister !=3D NULL) { + Status =3D AmlCodeGenString (StateName, &StringNode); + } else { + Status =3D AmlCodeGenString ("", &StringNode); + } + if (EFI_ERROR (Status)) { + ASSERT (0); + StringNode =3D NULL; + goto error_handler; + } + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)NewLpiPackageNode, + (AML_NODE_HANDLE)StringNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + StringNode =3D NULL; + + // Add the new LPI state to the LpiNode. + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)NewLpiPackageNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + if (RdNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)RdNode); + } + if (NewLpiPackageNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)NewLpiPackageNode); + } + if (StringNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)StringNode); + } + if (IntegerNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)IntegerNode); + } + if (ResourceTemplateNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)ResourceTemplateNode); + } + + 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 (#81708): https://edk2.groups.io/g/devel/message/81708 Mute This Topic: https://groups.io/mt/86172121/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 Fri Apr 26 01:22:25 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+81709+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+81709+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704428; cv=none; d=zohomail.com; s=zohoarc; b=M9V+f4P8IIu2OlP0sdzt0kIsv4dV83LtIk3tR4Ush7LYGWRePVSfheXCifbBFsUxF4ddnEfP8yjuvinwkXI9XUkTgOis65IrD87yFJszUQ6fb+XtLEWqt3AhPHxZbhgQU66Hs4dUx2xQJv/hXg/aVbimMO6XZ0BdmINNs+ChzVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704428; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=5X83mtcmvp7GoA7G7XoC4aPcBOt5l3rDqGN/VY+Ka4w=; b=LOexqb2ACOfiGLfjXeMVEgrLC0znfRBt1eP/aopMvYlfjX/xYcf8BQNf2iGCfaz1EQ2DjwlcgfMukJpQXNTDI2zkF1hKszVqLxe01aRuG40O+NrzILYi7JwWAnygSuzVWUcXQRxAs2Vv/jmC6H14Z0saQ7pw0WM7LPy0cfurqb0= 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+81709+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 1633704428115408.79462865922596; Fri, 8 Oct 2021 07:47:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id DleXYY1788612xGdmB8KGvGu; Fri, 08 Oct 2021 07:47:07 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.10544.1633704427046193672 for ; Fri, 08 Oct 2021 07:47:07 -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 B8E741063; Fri, 8 Oct 2021 07:47:06 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AFC523F66F; Fri, 8 Oct 2021 07:47:05 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 20/21] DynamicTablesPkg: Add CM_ARM_LPI_INFO object Date: Fri, 8 Oct 2021 15:46:31 +0100 Message-Id: <20211008144632.31894-21-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: NkYonPgrASejjaIDo6FNujx4x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704427; bh=t5tPRyFSU2SVjOoGJzORMxMj2NxL80hThJ5fiTfJLbU=; h=Date:From:Reply-To:Subject:To; b=RtIPedyaEjnQbjXzRpKM4Y0me+c1wsLX3X3Gs8ldb5De6g45OTt7jSt79cNlmxXx6VL WJ90mo/c/cscssNpbqTVnJrJQFg09Q0JWK+lrBwOGJL/nXE6zog7UPZK2n+MzYXuLOy29 nmREVliUsPTQntyypNUoc1Xyl6L7AKS9g+Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704428728100007 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Introduce the CM_ARM_LPI_INFO CmObj in the ArmNameSpaceObjects. This allows to describe LPI state information, as described in ACPI 6.4, s8.4.4.3 "_LPI (Low Power Idle States)". Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/ArmNameSpaceObjects.h | 68 +++++++++++++++++++ .../ConfigurationManagerObjectParser.c | 35 ++++++++++ 2 files changed, 103 insertions(+) diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTables= Pkg/Include/ArmNameSpaceObjects.h index 2244eafaf009..f19c9c706669 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -58,6 +58,7 @@ typedef enum ArmObjectID { EArmObjGenericInitiatorAffinityInfo, ///< 34 - Generic Initiator Affinity EArmObjSerialPortInfo, ///< 35 - Generic Serial Port Info EArmObjCmn600Info, ///< 36 - CMN-600 Info + EArmObjLpiInfo, ///< 37 - Lpi Info EArmObjMax } EARM_OBJECT_ID; =20 @@ -711,6 +712,10 @@ typedef struct CmArmProcHierarchyInfo { /// the NoOfPrivateResources is 0, in which case it is recommended to set /// this field to CM_NULL_TOKEN. CM_OBJECT_TOKEN PrivateResourcesArrayToken; + /// Optional field: Reference Token for the Lpi state of this processor. + /// Token identifying a CM_ARM_OBJ_REF structure, itself referencing + /// CM_ARM_LPI_INFO objects. + CM_OBJECT_TOKEN LpiToken; } CM_ARM_PROC_HIERARCHY_INFO; =20 /** A structure that describes the Cache Type Structure (Type 1) in PPTT @@ -878,6 +883,69 @@ typedef struct CmArmCmn600Info { CM_ARM_EXTENDED_INTERRUPT DtcInterrupt[4]; } CM_ARM_CMN_600_INFO; =20 +/** A structure that describes the Lpi information. + + The Low Power Idle states are described in DSDT/SSDT and associated + to cpus/clusters in the cpu topology. + + ID: EArmObjLpiInfo +*/ +typedef struct CmArmLpiInfo { + /** Minimum Residency. Time in microseconds after which a + state becomes more energy efficient than any shallower state. + */ + UINT32 MinResidency; + + /** Worst case time in microseconds from a wake interrupt + being asserted to the return to a running state + */ + UINT32 WorstCaseWakeLatency; + + /** Flags. + */ + UINT32 Flags; + + /** Architecture specific context loss flags. + */ + UINT32 ArchFlags; + + /** Residency counter frequency in cycles-per-second (Hz). + */ + UINT32 ResCntFreq; + + /** Every shallower power state in the parent is also enabled. + */ + UINT32 EnableParentState; + + /** The EntryMethod _LPI field can be described as an integer + or in a Register resource data descriptor. + + If IsInteger is TRUE, the IntegerEntryMethod field is used. + If IsInteger is FALSE, the RegisterEntryMethod field is used. + */ + BOOLEAN IsInteger; + + /** EntryMethod described as an Integer. + */ + UINT64 IntegerEntryMethod; + + /** EntryMethod described as a EFI_ACPI_GENERIC_REGISTER_DESCRIPTOR. + */ + EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE RegisterEntryMethod; + + /** Residency counter register. + */ + EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE ResidencyCounterRegister; + + /** Usage counter register. + */ + EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE UsageCounterRegister; + + /** String representing the Lpi state + */ + CHAR8 StateName[16]; +} CM_ARM_LPI_INFO; + #pragma pack() =20 #endif // ARM_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationMa= nagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Config= urationManagerObjectParser.c index ee2918ab5cc6..2337d47e3fb3 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerOb= jectParser.c @@ -368,6 +368,39 @@ STATIC CONST CM_OBJ_PARSER CmArmCmn600InfoParser[] =3D= { {"DtcFlags[3]", 4, "0x%x", NULL} }; =20 +/** A parser for the EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE structure. +*/ +STATIC CONST CM_OBJ_PARSER AcpiGenericAddressParser[] =3D { + {"AddressSpaceId", 1, "%d", NULL}, + {"RegisterBitWidth", 1, "%d", NULL}, + {"RegisterBitOffset", 1, "%d", NULL}, + {"AccessSize", 1, "%d", NULL}, + {"Address", 8, "0x%llx", NULL}, +}; + +/** A parser for EArmObjLpiInfo. +*/ +STATIC CONST CM_OBJ_PARSER CmArmLpiInfoParser[] =3D { + {"MinResidency", 4, "0x%llx", NULL}, + {"WorstCaseWakeLatency", 4, "0x%llx", NULL}, + {"Flags", 4, "0x%llx", NULL}, + {"ArchFlags", 4, "0x%llx", NULL}, + {"ResCntFreq", 4, "0x%llx", NULL}, + {"EnableParentState", 4, "0x%llx", NULL}, + {"IsInteger", 1, "%d", NULL}, + {"IntegerEntryMethod", 8, "0x%llx", NULL}, + {"RegisterEntryMethod", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE), + NULL, NULL, AcpiGenericAddressParser, + ARRAY_SIZE (AcpiGenericAddressParser)}, + {"ResidencyCounterRegister", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCT= URE), + NULL, NULL, AcpiGenericAddressParser, + ARRAY_SIZE (AcpiGenericAddressParser)}, + {"UsageCounterRegister", sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE), + NULL, NULL, AcpiGenericAddressParser, + ARRAY_SIZE (AcpiGenericAddressParser)}, + {"StateName", 16, "0x%a", NULL}, +}; + /** A parser for Arm namespace objects. */ STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectParser[] =3D { @@ -440,6 +473,8 @@ STATIC CONST CM_OBJ_PARSER_ARRAY ArmNamespaceObjectPars= er[] =3D { ARRAY_SIZE (CmArmSerialPortInfoParser)}, {"EArmObjCmn600Info", CmArmCmn600InfoParser, ARRAY_SIZE (CmArmCmn600InfoParser)}, + {"EArmObjLpiInfo", CmArmLpiInfoParser, + ARRAY_SIZE (CmArmLpiInfoParser)}, {"EArmObjMax", NULL, 0}, }; =20 --=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 (#81709): https://edk2.groups.io/g/devel/message/81709 Mute This Topic: https://groups.io/mt/86172123/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 Fri Apr 26 01:22:25 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+81710+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+81710+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633704429; cv=none; d=zohomail.com; s=zohoarc; b=l+AHUWL5Uw8NcfQfAI//aqzCO9xiduL1a3FU0Muc+At+Qa9EOGPn0RAVvdWctcsda1ufbgcChjD6MGoT3852u+RzeJloIDyoDjkKh08QZPV1QIh8PAUcpSyFS6hHFO1LO6cTOAxGZdK2mM8on7uE/+ybqluuSyVzr1aDa2OYu0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633704429; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=vQT6Z06GA8qDi9Smr+TVk2AJW2KVsXeI0z5vMTt43ys=; b=NQXuv+j+TVU6EvpLHGOCzJFxB5A22fBoVssF8Z0Qri6rS3t1it97PfgsKRWXSFplR0COh1t8wUSuPEmFyNbrQSrGCRe7k3QjLJ/ctBelzQuubTTLTJYD9/APUVQRMXozV9Z9jWTuVFkqX1/l/oUHRvqRceb+30D0dJGqXS1mhVc= 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+81710+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 1633704429653135.97787874556775; Fri, 8 Oct 2021 07:47:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vHFnYY1788612xuBwZ91OJpS; Fri, 08 Oct 2021 07:47:09 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.10547.1633704428528725392 for ; Fri, 08 Oct 2021 07:47:08 -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 2ECF96D; Fri, 8 Oct 2021 07:47:08 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1570B3F66F; Fri, 8 Oct 2021 07:47:06 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v3 21/21] DynamicTablesPkg: SSDT CPU topology and LPI state generator Date: Fri, 8 Oct 2021 15:46:32 +0100 Message-Id: <20211008144632.31894-22-Pierre.Gondois@arm.com> In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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: iYsnrDeidnLL6BxIDLATW0fIx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633704429; bh=TuzMbTVhDGX2Z/9PLo43qQKtzuTkM83g/9Kfq2KcSQ0=; h=Date:From:Reply-To:Subject:To; b=IOZ6DnYQzjhwIYJf8uqcVC2BHGsTucBuhv6qz/rnVMsIl0qZ1LYy2pQwzEzjJ00nBCC 7i9irvK2VS4ncFSDOsbUUF+zQvkcj5nfZ4QcXQ6x1CxSKV/R7DLlIOZiOuk3w58YNZ2MO ljkXxzCgqEyzHbbTovcpaCMYCywEN6wsx28= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633704430887100015 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois In the GIC interrupt model, logical processors are required to have a Processor Device object in the DSDT and must convey each processor's GIC information to the OS using the GICC structure. Additionally, _LPI objects may be needed as they provide a method to describe Low Power Idle states that defines the local power states for each node in a hierarchical processor topology. Therefore, add support to generate the CPU topology and the LPI state information in an SSDT table. Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- DynamicTablesPkg/DynamicTables.dsc.inc | 6 + DynamicTablesPkg/Include/AcpiTableGenerator.h | 7 +- .../SsdtCpuTopologyGenerator.c | 1228 +++++++++++++++++ .../SsdtCpuTopologyGenerator.h | 134 ++ .../SsdtCpuTopologyLibArm.inf | 33 + 5 files changed, 1407 insertions(+), 1 deletion(-) create mode 100644 DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLi= bArm/SsdtCpuTopologyGenerator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLi= bArm/SsdtCpuTopologyGenerator.h create mode 100644 DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLi= bArm/SsdtCpuTopologyLibArm.inf diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dyna= micTables.dsc.inc index ed221d1681eb..292215c39456 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -37,6 +37,9 @@ [Components.common] DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/SsdtSerialPor= tLibArm.inf DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn600LibArm.= inf =20 + # AML Codegen + DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopol= ogyLibArm.inf + # # Dynamic Table Factory Dxe # @@ -56,6 +59,9 @@ [Components.common] # AML Fixup NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtSerialPortLibArm/Ssdt= SerialPortLibArm.inf NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCmn600LibArm/SsdtCmn6= 00LibArm.inf + + # AML Codegen + NULL|DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ssd= tCpuTopologyLibArm.inf } =20 # diff --git a/DynamicTablesPkg/Include/AcpiTableGenerator.h b/DynamicTablesP= kg/Include/AcpiTableGenerator.h index 352331d6dc95..45c808ba740d 100644 --- a/DynamicTablesPkg/Include/AcpiTableGenerator.h +++ b/DynamicTablesPkg/Include/AcpiTableGenerator.h @@ -1,6 +1,6 @@ /** @file =20 - Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -63,6 +63,10 @@ The Dynamic Tables Framework implements the following AC= PI table generators: The SSDT CMN-600 generator collates the CMN-600 information from the Configuration Manager and patches the SSDT CMN-600 template to build the SSDT CMN-600 table. + - SSDT Cpu-Topology: + The SSDT Cpu-Topology generator collates the cpu and LPI + information from the Configuration Manager and generates a + SSDT table describing the CPU hierarchy. */ =20 /** The ACPI_TABLE_GENERATOR_ID type describes ACPI table generator ID. @@ -88,6 +92,7 @@ typedef enum StdAcpiTableId { EStdAcpiTableIdSrat, ///< SRAT Generator EStdAcpiTableIdSsdtSerialPort, ///< SSDT Serial-Port Gene= rator EStdAcpiTableIdSsdtCmn600, ///< SSDT Cmn-600 Generator + EStdAcpiTableIdSsdtCpuTopology, ///< SSDT Cpu Topology EStdAcpiTableIdMax } ESTD_ACPI_TABLE_ID; =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ss= dtCpuTopologyGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTop= ologyLibArm/SsdtCpuTopologyGenerator.c new file mode 100644 index 000000000000..3f6cef3ba555 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTo= pologyGenerator.c @@ -0,0 +1,1228 @@ +/** @file + SSDT Cpu Topology Table Generator. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors +**/ + +#include +#include +#include +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include +#include +#include + +#include "SsdtCpuTopologyGenerator.h" + +/** ARM standard SSDT Cpu Topology Table Generator. + +Requirements: + The following Configuration Manager Object(s) are required by + this Generator: + - EArmObjGicCInfo + - EArmObjProcHierarchyInfo (OPTIONAL) along with + - EArmObjCmRef (OPTIONAL) + - EArmObjLpiInfo (OPTIONAL) +*/ + +/** This macro expands to a function that retrieves the GIC + CPU interface Information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjGicCInfo, + CM_ARM_GICC_INFO + ); + +/** + This macro expands to a function that retrieves the Processor Hierarchy + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjProcHierarchyInfo, + CM_ARM_PROC_HIERARCHY_INFO + ); + +/** + This macro expands to a function that retrieves the cross-CM-object- + reference information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjCmRef, + CM_ARM_OBJ_REF + ); + +/** + This macro expands to a function that retrieves the Lpi + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjLpiInfo, + CM_ARM_LPI_INFO + ); + +/** Initialize the TokenTable. + + One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO + structure of the platform. The TokenTable allows to have a mapping: + Index <-> CM_OBJECT_TOKEN (to CM_ARM_LPI_INFO structures). + + There will always be less sets of Lpi states (CM_ARM_OBJ_REF) + than the number of cpus/clusters (CM_ARM_PROC_HIERARCHY_INFO). + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] Count Number of entries to allocate in the TokenTable. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +TokenTableInitialize ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN UINT32 Count + ) +{ + CM_OBJECT_TOKEN * Table; + + if ((Generator =3D=3D NULL) || + (Count =3D=3D 0) || + (Count >=3D MAX_NODE_COUNT)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Table =3D AllocateZeroPool (sizeof (CM_OBJECT_TOKEN) * Count); + if (Table =3D=3D NULL) { + ASSERT (0); + return EFI_OUT_OF_RESOURCES; + } + + Generator->TokenTable.Table =3D Table; + + return EFI_SUCCESS; +} + +/** Free the TokenTable. + + @param [in] Generator The SSDT Cpu Topology generator. +**/ +STATIC +VOID +EFIAPI +TokenTableFree ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator + ) +{ + ASSERT (Generator !=3D NULL); + ASSERT (Generator->TokenTable.Table !=3D NULL); + + if (Generator->TokenTable.Table !=3D NULL) { + FreePool (Generator->TokenTable.Table); + } +} + +/** Add a new entry to the TokenTable and return its index. + + If an entry with Token is already available in the table, + return its index without adding a new entry. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] Token New Token entry to add. + + @retval The index of the token entry in the TokenTable. +**/ +STATIC +UINT32 +EFIAPI +TokenTableAdd ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CM_OBJECT_TOKEN Token + ) +{ + CM_OBJECT_TOKEN * Table; + UINT32 Index; + UINT32 LastIndex; + + ASSERT (Generator !=3D NULL); + ASSERT (Generator->TokenTable.Table !=3D NULL); + + Table =3D Generator->TokenTable.Table; + LastIndex =3D Generator->TokenTable.LastIndex; + + // Search if there is already an entry with this Token. + for (Index =3D 0; Index < LastIndex; Index++) { + if (Table[Index] =3D=3D Token) { + return Index; + } + } + + ASSERT (LastIndex < MAX_NODE_COUNT); + ASSERT (LastIndex < Generator->ProcNodeCount); + + // If no, create a new entry. + Table[LastIndex] =3D Token; + + return Generator->TokenTable.LastIndex++; +} + +/** Write a string 'Xxxx\0' in AslName (5 bytes long), + with 'X' being the leading char of the name, and + with 'xxx' being Value in hexadecimal. + + As 'xxx' in hexadecimal represents a number on 12 bits, + we have Value < (1 << 12). + + @param [in] LeadChar Leading char of the name. + @param [in] Value Hex value of the name. + Must be lower than (2 << 12). + @param [in, out] AslName Pointer to write the 'Xxxx' string to. + Must be at least 5 bytes long. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +STATIC +EFI_STATUS +EFIAPI +WriteAslName ( + IN CHAR8 LeadChar, + IN UINT32 Value, + IN OUT CHAR8 * AslName + ) +{ + UINT8 Index; + + if ((Value >=3D MAX_NODE_COUNT) || + (AslName =3D=3D NULL)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + AslName[0] =3D LeadChar; + AslName[AML_NAME_SEG_SIZE] =3D '\0'; + + for (Index =3D 0; Index < AML_NAME_SEG_SIZE - 1; Index++) { + AslName[AML_NAME_SEG_SIZE - Index - 1] =3D + AsciiFromHex (((Value >> (4 * Index)) & 0xF)); + } + + return EFI_SUCCESS; +} + +/** Create and add an _LPI method to Cpu/Cluster Node. + + For instance, transform an AML node from: + Device (C002) + { + Name (_UID, 2) + Name (_HID, "ACPI0007") + } + + To: + Device (C002) + { + Name (_UID, 2) + Name (_HID, "ACPI0007") + Method (_LPI, 0, NotSerialized) + { + Return (\_SB.L003) + } + } + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] ProcHierarchyNodeInfo CM_ARM_PROC_HIERARCHY_INFO describing + the Cpu. + @param [in] Node Node to which the _LPI method is + attached. Can represent a Cpu or a + Cluster. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateAmlLpiMethod ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNodeInfo, + IN AML_OBJECT_NODE_HANDLE * Node + ) +{ + EFI_STATUS Status; + UINT32 TokenIndex; + CHAR8 AslName[SB_SCOPE_PREFIX_SIZE + AML_NAME_SEG_SIZE]; + + ASSERT (Generator !=3D NULL); + ASSERT (ProcHierarchyNodeInfo !=3D NULL); + ASSERT (ProcHierarchyNodeInfo->LpiToken !=3D CM_NULL_TOKEN); + ASSERT (Node !=3D NULL); + + TokenIndex =3D TokenTableAdd (Generator, ProcHierarchyNodeInfo->LpiToken= ); + + CopyMem (AslName, SB_SCOPE_PREFIX, SB_SCOPE_PREFIX_SIZE); + + Status =3D WriteAslName ( + 'L', + TokenIndex, + AslName + SB_SCOPE_PREFIX_SIZE - 1 + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // ASL: + // Method (_LPI, 0) { + // Return ([AslName]) + // } + Status =3D AmlCodeGenMethodRetNameString ( + "_LPI", + AslName, + 0, + FALSE, + 0, + Node, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + } + + return Status; +} + +/** Generate all the Lpi states under the '_SB' scope. + + This function generates the following ASL code: + Scope (\_SB) { + Name (L000, Package() { + 0, // Version + 0, // Level Index + X, // Count + Package() { + [An Lpi state] + }, + Package() { + [Another Lpi state] + }, + } // Name L000 + + Name (L001, Package() { + ... + } // Name L001 + + ... + } // Scope /_SB + + The Lpi states are fetched from the Configuration Manager. + The names of the Lpi states are generated from the TokenTable. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ScopeNode Scope node handle ('\_SB' scope). + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +GenerateLpiStates ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN AML_OBJECT_NODE_HANDLE ScopeNode + ) +{ + EFI_STATUS Status; + + UINT32 Index; + UINT32 LastIndex; + + AML_OBJECT_NODE_HANDLE LpiNode; + CM_ARM_OBJ_REF * LpiRefInfo; + UINT32 LpiRefInfoCount; + UINT32 LpiRefIndex; + CM_ARM_LPI_INFO * LpiInfo; + CHAR8 AslName[AML_NAME_SEG_SIZE + 1]; + + ASSERT (Generator !=3D NULL); + ASSERT (Generator->TokenTable.Table !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (ScopeNode !=3D NULL); + + LastIndex =3D Generator->TokenTable.LastIndex; + + // For each entry in the TokenTable, create a name in the AML namespace + // under SB_SCOPE, to store the Lpi states associated with the LpiToken. + for (Index =3D 0; Index < LastIndex; Index++) { + Status =3D WriteAslName ('L', Index, AslName); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // We do not support the LevelId field for now, let it to 0. + Status =3D AmlCreateLpiNode (AslName, 1, 0, ScopeNode, &LpiNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Fetch the LPI objects referenced by the token. + Status =3D GetEArmObjCmRef ( + CfgMgrProtocol, + Generator->TokenTable.Table[Index], + &LpiRefInfo, + &LpiRefInfoCount + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + for (LpiRefIndex =3D 0; LpiRefIndex < LpiRefInfoCount; LpiRefIndex++) { + // For each CM_ARM_LPI_INFO referenced by the token, add an Lpi stat= e. + Status =3D GetEArmObjLpiInfo ( + CfgMgrProtocol, + LpiRefInfo[LpiRefIndex].ReferenceToken, + &LpiInfo, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlAddLpiState ( + LpiInfo->MinResidency, + LpiInfo->WorstCaseWakeLatency, + LpiInfo->Flags, + LpiInfo->ArchFlags, + LpiInfo->ResCntFreq, + LpiInfo->EnableParentState, + LpiInfo->IsInteger ? + NULL : + &LpiInfo->RegisterEntryMethod, + LpiInfo->IsInteger ? + LpiInfo->IntegerEntryMethod : + 0, + &LpiInfo->ResidencyCounterRegister, + &LpiInfo->UsageCounterRegister, + LpiInfo->StateName, + LpiNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + } // for LpiRefIndex + } // for Index + + return EFI_SUCCESS; +} + +/** Create a Cpu in the AML namespace. + + This generates the following ASL code: + Device (C002) + { + Name (_UID, 2) + Name (_HID, "ACPI0007") + } + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] ParentNode Parent node to attach the Cpu node to. + @param [in] GicCInfo CM_ARM_GICC_INFO object used to create the nod= e. + @param [in] CpuIndex Index used to generate the node name. + @param [out] CpuNodePtr If not NULL, return the created Cpu node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateAmlCpu ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN AML_NODE_HANDLE ParentNode, + IN CM_ARM_GICC_INFO * GicCInfo, + IN UINT32 CpuIndex, + OUT AML_OBJECT_NODE_HANDLE * CpuNodePtr OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE CpuNode; + CHAR8 AslName[AML_NAME_SEG_SIZE + 1]; + + ASSERT (Generator !=3D NULL); + ASSERT (ParentNode !=3D NULL); + ASSERT (GicCInfo !=3D NULL); + + Status =3D WriteAslName ('C', CpuIndex, AslName); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenDevice (AslName, ParentNode, &CpuNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenNameInteger ( + "_UID", + GicCInfo->AcpiProcessorUid, + CpuNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenNameString ( + "_HID", + ACPI_HID_PROCESSOR_DEVICE, + CpuNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // If requested, return the handle to the CpuNode. + if (CpuNodePtr !=3D NULL) { + *CpuNodePtr =3D CpuNode; + } + + return Status; +} + +/** Create a Cpu in the AML namespace from a CM_ARM_PROC_HIERARCHY_INFO + CM object. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ParentNode Parent node to attach the Cpu node t= o. + @param [in] CpuIndex Index used to generate the node name. + @param [in] ProcHierarchyNodeInfo CM_ARM_PROC_HIERARCHY_INFO describing + the Cpu. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateAmlCpuFromProcHierarchy ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN AML_NODE_HANDLE ParentNode, + IN UINT32 CpuIndex, + IN CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNod= eInfo + ) +{ + EFI_STATUS Status; + CM_ARM_GICC_INFO * GicCInfo; + AML_OBJECT_NODE_HANDLE CpuNode; + + ASSERT (Generator !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (ParentNode !=3D NULL); + ASSERT (ProcHierarchyNodeInfo !=3D NULL); + ASSERT (ProcHierarchyNodeInfo->GicCToken !=3D CM_NULL_TOKEN); + + Status =3D GetEArmObjGicCInfo ( + CfgMgrProtocol, + ProcHierarchyNodeInfo->GicCToken, + &GicCInfo, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D CreateAmlCpu (Generator, ParentNode, GicCInfo, CpuIndex, &Cpu= Node); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // If a set of Lpi states is associated with the + // CM_ARM_PROC_HIERARCHY_INFO, create an _LPI method returning them. + if (ProcHierarchyNodeInfo->LpiToken !=3D CM_NULL_TOKEN) { + Status =3D CreateAmlLpiMethod (Generator, ProcHierarchyNodeInfo, CpuNo= de); + ASSERT_EFI_ERROR (Status); + } + + return Status; +} + +/** Create a Cluster in the AML namespace. + + Any CM_ARM_PROC_HIERARCHY_INFO object with the following flags is + assumed to be a cluster: + - EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL + - EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID + - EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF + + This generates the following ASL code: + Device (C002) + { + Name (_UID, 2) + Name (_HID, "ACPI0010") + } + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ParentNode Parent node to attach the Cluster + node to. + @param [in] ProcHierarchyNodeInfo CM_ARM_PROC_HIERARCHY_INFO object us= ed + to create the node. + @param [in] ClusterIndex Index used to generate the node name. + @param [out] ClusterNodePtr If success, contains the created Clu= ster + node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateAmlCluster ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN AML_NODE_HANDLE ParentNode, + IN CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNod= eInfo, + IN UINT32 ClusterIndex, + OUT AML_OBJECT_NODE_HANDLE * ClusterNodePtr + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE ClusterNode; + CHAR8 AslNameCluster[AML_NAME_SEG_SIZE + 1]; + + ASSERT (Generator !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (ParentNode !=3D NULL); + ASSERT (ProcHierarchyNodeInfo !=3D NULL); + ASSERT (ClusterNodePtr !=3D NULL); + + Status =3D WriteAslName ('C', ClusterIndex, AslNameCluster); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenDevice (AslNameCluster, ParentNode, &ClusterNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Use the ClusterIndex for the _UID value as there is no AcpiProcessorU= id + // and EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID is set for non-Cpus. + Status =3D AmlCodeGenNameInteger ( + "_UID", + ClusterIndex, + ClusterNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenNameString ( + "_HID", + ACPI_HID_PROCESSOR_CONTAINER_DEVICE, + ClusterNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // If a set of Lpi states are associated with the + // CM_ARM_PROC_HIERARCHY_INFO, create an _LPI method returning them. + if (ProcHierarchyNodeInfo->LpiToken !=3D CM_NULL_TOKEN) { + Status =3D CreateAmlLpiMethod ( + Generator, + ProcHierarchyNodeInfo, + ClusterNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + } + + *ClusterNodePtr =3D ClusterNode; + + return Status; +} + +/** Create an AML representation of the Cpu topology. + + A cluster is by extension any non-leave device in the cpu topology. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] NodeToken Token of the CM_ARM_PROC_HIERARCHY_INFO + currently handled. + Cannot be CM_NULL_TOKEN. + @param [in] ParentNode Parent node to attach the created + node to. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateAmlCpuTopologyTree ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CM_OBJECT_TOKEN NodeToken, + IN AML_NODE_HANDLE ParentNode + ) +{ + EFI_STATUS Status; + UINT32 Index; + UINT32 CpuIndex; + UINT32 ClusterIndex; + AML_OBJECT_NODE_HANDLE ClusterNode; + + ASSERT (Generator !=3D NULL); + ASSERT (Generator->ProcNodeList !=3D NULL); + ASSERT (Generator->ProcNodeCount !=3D 0); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (NodeToken !=3D CM_NULL_TOKEN); + ASSERT (ParentNode !=3D NULL); + + CpuIndex =3D 0; + ClusterIndex =3D 0; + + for (Index =3D 0; Index < Generator->ProcNodeCount; Index++) { + // Find the children of the CM_ARM_PROC_HIERARCHY_INFO + // currently being handled (i.e. ParentToken =3D=3D NodeToken). + if (Generator->ProcNodeList[Index].ParentToken =3D=3D NodeToken) { + + // Only Cpus (leaf nodes in this tree) have a GicCToken. + // Create a Cpu node. + if (Generator->ProcNodeList[Index].GicCToken !=3D CM_NULL_TOKEN) { + if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) != =3D + PPTT_CPU_PROCESSOR_MASK) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SSDT-CPU-TOPOLOGY: Invalid flags for cpu: 0x%x.\n", + Generator->ProcNodeList[Index].Flags + )); + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D CreateAmlCpuFromProcHierarchy ( + Generator, + CfgMgrProtocol, + ParentNode, + CpuIndex, + &Generator->ProcNodeList[Index] + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + CpuIndex++; + + } else { + // If this is not a Cpu, then this is a cluster. + + // Acpi processor Id for clusters is not handled. + if ((Generator->ProcNodeList[Index].Flags & PPTT_PROCESSOR_MASK) != =3D + PPTT_CLUSTER_PROCESSOR_MASK) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SSDT-CPU-TOPOLOGY: Invalid flags for cluster: 0x%x.\n", + Generator->ProcNodeList[Index].Flags + )); + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D CreateAmlCluster ( + Generator, + CfgMgrProtocol, + ParentNode, + &Generator->ProcNodeList[Index], + ClusterIndex, + &ClusterNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Nodes must have a unique name in the ASL namespace. + // Reset the Cpu index whenever we create a new Cluster. + ClusterIndex++; + CpuIndex =3D 0; + + // Recursively continue creating an AML tree. + Status =3D CreateAmlCpuTopologyTree ( + Generator, + CfgMgrProtocol, + Generator->ProcNodeList[Index].Token, + ClusterNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + } + } // if ParentToken =3D=3D NodeToken + } // for + + return EFI_SUCCESS; +} + +/** Create the processor hierarchy AML tree from CM_ARM_PROC_HIERARCHY_INFO + CM objects. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ScopeNode Scope node handle ('\_SB' scope). + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateTopologyFromProcHierarchy ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN AML_OBJECT_NODE_HANDLE ScopeNode + ) +{ + EFI_STATUS Status; + UINT32 Index; + UINT32 TopLevelProcNodeIndex; + + ASSERT (Generator !=3D NULL); + ASSERT (Generator->ProcNodeCount !=3D 0); + ASSERT (Generator->ProcNodeList !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (ScopeNode !=3D NULL); + + TopLevelProcNodeIndex =3D MAX_UINT32; + + Status =3D TokenTableInitialize (Generator, Generator->ProcNodeCount); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // It is assumed that there is one unique CM_ARM_PROC_HIERARCHY_INFO + // structure with no ParentToken and the EFI_ACPI_6_3_PPTT_PACKAGE_PHYSI= CAL + // flag set. All other CM_ARM_PROC_HIERARCHY_INFO are non-physical and + // have a ParentToken. + for (Index =3D 0; Index < Generator->ProcNodeCount; Index++) { + if ((Generator->ProcNodeList[Index].ParentToken =3D=3D CM_NULL_TOKEN) = && + (Generator->ProcNodeList[Index].Flags & + EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL)) { + if (TopLevelProcNodeIndex !=3D MAX_UINT32) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SSDT-CPU-TOPOLOGY: Top level CM_ARM_PROC_HIERARCHY_INFO " + "must be unique\n" + )); + ASSERT (0); + goto exit_handler; + } + TopLevelProcNodeIndex =3D Index; + } + } // for + + Status =3D CreateAmlCpuTopologyTree ( + Generator, + CfgMgrProtocol, + Generator->ProcNodeList[TopLevelProcNodeIndex].Token, + ScopeNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D GenerateLpiStates (Generator, CfgMgrProtocol, ScopeNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + +exit_handler: + TokenTableFree (Generator); + return Status; +} + +/** Create the processor hierarchy AML tree from CM_ARM_GICC_INFO + CM objects. + + A cluster is by extension any non-leave device in the cpu topology. + + @param [in] Generator The SSDT Cpu Topology generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] ScopeNode Scope node handle ('\_SB' scope). + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +CreateTopologyFromGicC ( + IN ACPI_CPU_TOPOLOGY_GENERATOR * Generator, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN AML_OBJECT_NODE_HANDLE ScopeNode + ) +{ + EFI_STATUS Status; + CM_ARM_GICC_INFO * GicCInfo; + UINT32 GicCInfoCount; + UINT32 Index; + + ASSERT (Generator !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (ScopeNode !=3D NULL); + + Status =3D GetEArmObjGicCInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &GicCInfo, + &GicCInfoCount + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // For each CM_ARM_GICC_INFO object, create an AML node. + for (Index =3D 0; Index < GicCInfoCount; Index++) { + Status =3D CreateAmlCpu ( + Generator, + ScopeNode, + &GicCInfo[Index], + Index, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + break; + } + } // for + + return Status; +} + +/** Construct the SSDT Cpu Topology ACPI table. + + This function invokes the Configuration Manager protocol interface + to get the required hardware information for generating the ACPI + table. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [out] Table Pointer to the constructed ACPI Table. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object was not found. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for t= he + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildSsdtCpuTopologyTable ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table + ) +{ + EFI_STATUS Status; + AML_ROOT_NODE_HANDLE RootNode; + AML_OBJECT_NODE_HANDLE ScopeNode; + CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNodeList; + UINT32 ProcHierarchyNodeCount; + ACPI_CPU_TOPOLOGY_GENERATOR * Generator; + + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); + + Generator =3D (ACPI_CPU_TOPOLOGY_GENERATOR*)This; + + Status =3D AddSsdtAcpiHeader ( + CfgMgrProtocol, + This, + AcpiTableInfo, + &RootNode + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D AmlCodeGenScope (SB_SCOPE, RootNode, &ScopeNode); + if (EFI_ERROR (Status)) { + goto exit_handler; + } + + // Get the processor hierarchy info and update the processor topology + // structure count with Processor Hierarchy Nodes (Type 0) + Status =3D GetEArmObjProcHierarchyInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &ProcHierarchyNodeList, + &ProcHierarchyNodeCount + ); + if (EFI_ERROR (Status) && + (Status !=3D EFI_NOT_FOUND)) { + goto exit_handler; + } + + if (Status =3D=3D EFI_NOT_FOUND) { + // If hierarchy information is not found generate a flat topology + // using CM_ARM_GICC_INFO objects. + Status =3D CreateTopologyFromGicC ( + Generator, + CfgMgrProtocol, + ScopeNode + ); + if (EFI_ERROR (Status)) { + goto exit_handler; + } + } else { + // Generate the topology from CM_ARM_PROC_HIERARCHY_INFO objects. + Generator->ProcNodeList =3D ProcHierarchyNodeList; + Generator->ProcNodeCount =3D ProcHierarchyNodeCount; + + Status =3D CreateTopologyFromProcHierarchy ( + Generator, + CfgMgrProtocol, + ScopeNode + ); + if (EFI_ERROR (Status)) { + goto exit_handler; + } + } + + Status =3D AmlSerializeDefinitionBlock ( + RootNode, + Table + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SSDT-CPU-TOPOLOGY: Failed to Serialize SSDT Table Data." + " Status =3D %r\n", + Status + )); + goto exit_handler; + } + +exit_handler: + // Delete the RootNode and its attached children. + return AmlDeleteTree (RootNode); +} + +/** Free any resources allocated for constructing the + SSDT Cpu Topology ACPI table. + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in, out] Table Pointer to the ACPI Table. + + @retval EFI_SUCCESS The resources were freed successfully. + @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid. +**/ +STATIC +EFI_STATUS +FreeSsdtCpuTopologyTableResources ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInf= o, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, + IN OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table + ) +{ + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); + + if ((Table =3D=3D NULL) || (*Table =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: SSDT-CPU-TOPOLOGY: Invalid Table Pointer\= n")); + ASSERT ((Table !=3D NULL) && (*Table !=3D NULL)); + return EFI_INVALID_PARAMETER; + } + + FreePool (*Table); + *Table =3D NULL; + return EFI_SUCCESS; +} + +/** This macro defines the SSDT Cpu Topology Table Generator revision. +*/ +#define SSDT_CPU_TOPOLOGY_GENERATOR_REVISION CREATE_REVISION (1, 0) + +/** The interface for the SSDT Cpu Topology Table Generator. +*/ +STATIC +ACPI_CPU_TOPOLOGY_GENERATOR SsdtCpuTopologyGenerator =3D { + // ACPI table generator header + { + // Generator ID + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdSsdtCpuTopology), + // Generator Description + L"ACPI.STD.SSDT.CPU.TOPOLOGY.GENERATOR", + // ACPI Table Signature + EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + // ACPI Table Revision - Unused + 0, + // Minimum ACPI Table Revision - Unused + 0, + // Creator ID + TABLE_GENERATOR_CREATOR_ID_ARM, + // Creator Revision + SSDT_CPU_TOPOLOGY_GENERATOR_REVISION, + // Build Table function + BuildSsdtCpuTopologyTable, + // Free Resource function + FreeSsdtCpuTopologyTableResources, + // Extended build function not needed + NULL, + // Extended build function not implemented by the generator. + // Hence extended free resource function is not required. + NULL + }, + + // Private fields are defined from here. + + // TokenTable + { + // Table + NULL, + // LastIndex + 0 + }, + // ProcNodeList + NULL, + // ProcNodeCount + 0 +}; + +/** Register the Generator with the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +AcpiSsdtCpuTopologyLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * SystemTable + ) +{ + EFI_STATUS Status; + Status =3D RegisterAcpiTableGenerator (&SsdtCpuTopologyGenerator.Header); + DEBUG (( + DEBUG_INFO, + "SSDT-CPU-TOPOLOGY: Register Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** Deregister the Generator from the ACPI Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +AcpiSsdtCpuTopologyLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * SystemTable + ) +{ + EFI_STATUS Status; + Status =3D DeregisterAcpiTableGenerator (&SsdtCpuTopologyGenerator.Heade= r); + DEBUG (( + DEBUG_INFO, + "SSDT-CPU-TOPOLOGY: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ss= dtCpuTopologyGenerator.h b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTop= ologyLibArm/SsdtCpuTopologyGenerator.h new file mode 100644 index 000000000000..f6e8a754af7d --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTo= pologyGenerator.h @@ -0,0 +1,134 @@ +/** @file + SSDT Cpu Topology Table Generator. + + Copyright (c) 2021, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - ACPI 6.3 Specification - January 2019 - s8.4 Declaring Processors +**/ + +#ifndef SSDT_CPU_TOPOLOGY_GENERATOR_H_ +#define SSDT_CPU_TOPOLOGY_GENERATOR_H_ + +#pragma pack(1) + +// Mask for the flags that need to be checked. +#define PPTT_PROCESSOR_MASK ( = \ + (EFI_ACPI_6_3_PPTT_PACKAGE_PHYSICAL) | = \ + (EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID << 1) | = \ + (EFI_ACPI_6_3_PPTT_NODE_IS_LEAF << 3)) + +// Mask for the cpu flags. +#define PPTT_CPU_PROCESSOR_MASK ( = \ + (EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL) | = \ + (EFI_ACPI_6_3_PPTT_PROCESSOR_ID_VALID << 1) | = \ + (EFI_ACPI_6_3_PPTT_NODE_IS_LEAF << 3)) + +// Mask for the cluster flags. +// Even though a _UID is generated for clusters, it is simpler to use +// EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID and to not match the cluster id = of +// the PPTT table (not sure the PPTT table is generated). +#define PPTT_CLUSTER_PROCESSOR_MASK ( = \ + (EFI_ACPI_6_3_PPTT_PACKAGE_NOT_PHYSICAL) | = \ + (EFI_ACPI_6_3_PPTT_PROCESSOR_ID_INVALID << 1) | = \ + (EFI_ACPI_6_3_PPTT_NODE_IS_NOT_LEAF << 3)) + +/** LPI states are stored in the ASL namespace at '\_SB_.Lxxx', + with xxx being the node index of the LPI state. +*/ +#define SB_SCOPE "\\_SB_" +#define SB_SCOPE_PREFIX SB_SCOPE "." +/// Size of the SB_SCOPE_PREFIX string. +#define SB_SCOPE_PREFIX_SIZE sizeof (SB_SCOPE_PREFIX) + +/// HID for a processor device. +#define ACPI_HID_PROCESSOR_DEVICE "ACPI0007" + +/// HID for a processor container device. +#define ACPI_HID_PROCESSOR_CONTAINER_DEVICE "ACPI0010" + +/** Node names of Cpus and Clusters are 'Cxxx', and 'Lxxx' for LPI states. + The 'xxx' is an index on 12 bits is given to node name, + thus the limitation in the number of nodes. +*/ +#define MAX_NODE_COUNT (1 << 12) + +/** A structure used to handle the Lpi structures referencing. + + A CM_ARM_PROC_HIERARCHY_INFO structure references a CM_ARM_OBJ_REF. + This CM_ARM_OBJ_REF references CM_ARM_LPI_INFO structures. + + Example: + (Cpu0) (Cpu1) + CM_ARM_PROC_HIERARCHY_INFO CM_ARM_PROC_HIERARCHY_INFO + | | + +---------------------------------------- + | + v + (List of references to Lpi states) + CM_ARM_OBJ_REF + | + +---------------------------------------- + | | + v v + (A first Lpi state) (A second Lpi state) + CM_ARM_LPI_INFO[0] CM_ARM_LPI_INFO[1] + + Here, Cpu0 and Cpu1 have the same Lpi states. Both CM_ARM_PROC_HIERARCHY= _INFO + structures reference the same CM_ARM_OBJ_REF. An entry is created in the + TokenTable such as: + 0 <-> CM_ARM_OBJ_REF + + This will lead to the creation of this pseudo-ASL code where Cpu0 and Cp= u1 + return the same object at \_SB.L000: + Scope (\_SB) { + Device (C000) { + [...] + Method (_LPI) { + Return (\_SB.L000) + } + } // C000 + + Device (C001) { + [...] + Method (_LPI) { + Return (\_SB.L000) + } + } // C001 + + // Lpi states + Name (L000, Package (0x05) { + [...] + } + } +*/ +typedef struct TokenTable { + /// TokenTable, a table allowing to map: + /// Index <-> CM_OBJECT_TOKEN (to CM_ARM_LPI_INFO structures). + CM_OBJECT_TOKEN * Table; + + /// Last used index of the TokenTable. + /// LastIndex is bound by ProcNodeCount. + UINT32 LastIndex; +} TOKEN_TABLE; + +/** A structure holding the Cpu topology generator and additional private = data. +*/ +typedef struct AcpiCpuTopologyGenerator { + /// ACPI Table generator header + ACPI_TABLE_GENERATOR Header; + + // Private fields are defined from here. + + /// Private object used to handle token referencing. + TOKEN_TABLE TokenTable; + /// List of CM_ARM_PROC_HIERARCHY_INFO CM objects. + CM_ARM_PROC_HIERARCHY_INFO * ProcNodeList; + /// Count of CM_ARM_PROC_HIERARCHY_INFO CM objects. + UINT32 ProcNodeCount; +} ACPI_CPU_TOPOLOGY_GENERATOR; + +#pragma pack() + +#endif // SSDT_CPU_TOPOLOGY_GENERATOR_H_ diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/Ss= dtCpuTopologyLibArm.inf b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopo= logyLibArm/SsdtCpuTopologyLibArm.inf new file mode 100644 index 000000000000..3e2d15474980 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTo= pologyLibArm.inf @@ -0,0 +1,33 @@ +## @file +# Ssdt Cpu Topology Table Generator +# +# Copyright (c) 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SsdtCpuTopologyLibArm + FILE_GUID =3D F2835EB6-4B05-48D4-A475-147DA0F3755C + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D AcpiSsdtCpuTopologyLibConstructor + DESTRUCTOR =3D AcpiSsdtCpuTopologyLibDestructor + +[Sources] + SsdtCpuTopologyGenerator.c + SsdtCpuTopologyGenerator.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[LibraryClasses] + AcpiHelperLib + AmlLib + BaseLib --=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 (#81710): https://edk2.groups.io/g/devel/message/81710 Mute This Topic: https://groups.io/mt/86172125/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-