From nobody Tue Feb 10 15:46:20 2026 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+81599+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+81599+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633620783; cv=none; d=zohomail.com; s=zohoarc; b=UjYdy4zJjYXLxdbvr3tlH/btQxThdrBd4wxuhLzW/dt1vpzv1udH5nz76Pofv4hx4HouB4ZeYP8KlTYYgXVMGTqJYI906xvNxYCKAhjzmZlMEzB0nMve4rXAZTruCqoZJbL8UfRmQbVRb6W9YiArciB1CS3LThJHT3tb87USv2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633620783; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=8jlOBsjYVJu3od/XexOBXvIDFN+tdbycVO5AcV10Sog=; b=AORrGDkAmlti69RZCLzJGcPFghiFwhK7tZz5zAEsz4NueXaMr9Szqc+XqJEiGmNeN556/v1NbvBZCrLOutJLidBkOr1U9UauS+0qC0vBswQ8x71GTrvzUX2aRV6nmE0hFT4pG7UmdV7hzKHTjFU1vrL3q7LXb7BzDBynzramCww= 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+81599+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 1633620783904604.8891716703497; Thu, 7 Oct 2021 08:33:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id IlkfYY1788612xaDBBVUDlif; Thu, 07 Oct 2021 08:33:03 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.13678.1633620782494391028 for ; Thu, 07 Oct 2021 08:33: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 3316A1FB; Thu, 7 Oct 2021 08:33:02 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.72.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2903C3F66F; Thu, 7 Oct 2021 08:33:00 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v2 18/21] DynamicTablesPkg: AML code generation for a _LPI object Date: Thu, 7 Oct 2021 16:32:07 +0100 Message-Id: <20211007153210.26608-19-Pierre.Gondois@arm.com> In-Reply-To: <20211007153210.26608-1-Pierre.Gondois@arm.com> References: <20211007153210.26608-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: yhXqcVtrTab7e1T4BJGMYdAkx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633620783; bh=/XPVrJvceu6YdbZtfFh5x33HxGVuDq/sZHi0iZCMVOA=; h=Date:From:Reply-To:Subject:To; b=Y2KQT8b9EioG/NGER9M2SRO4N9bm3d06Ohc1ZhDhLpXEb2/LvShW7T8zfqqNPI49c5Y NeMrnPNkWlaVbrSHR6ktYWet9EFDcd5O7SFfWjiEx0GInqAN9XYS1uXxVO24unMqAFPHC V6rv5LofFad4BChB66oZsno5+aGAwp2toho= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633620785524100001 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 )) Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../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 67474094b975..2223e4bcfef9 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1442,3 +1442,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 (#81599): https://edk2.groups.io/g/devel/message/81599 Mute This Topic: https://groups.io/mt/86148214/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-