Adds an AmlAddIntegerToNamedPackage() API to generate AML code, which adds an integer value to the package node.
Cc: Pierre Gondois <pierre.gond...@arm.com> Cc: Sami Mujawar <sami.muja...@arm.com> Signed-off-by: Abdul Lateef Attar <abdullateef.at...@amd.com> --- .../Include/Library/AmlLib/AmlLib.h | 41 +++++++++++- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 67 +++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h index 82d5464084..4427ab68fa 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -2,7 +2,7 @@ AML Lib. Copyright (c) 2019 - 2023, Arm Limited. All rights reserved.<BR> - Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR> + Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -1743,6 +1743,45 @@ AmlAddNameStringToNamedPackage ( IN AML_OBJECT_NODE_HANDLE NamedNode ); +/** Add an integer value to the named package node. + + AmlCodeGenNamePackage ("_CID", NULL, &PackageNode); + AmlGetEisaIdFromString ("PNP0A03", &EisaId); + AmlAddIntegerToNamedPackage (EisaId, NameNode); + AmlGetEisaIdFromString ("PNP0A08", &EisaId); + AmlAddIntegerToNamedPackage (EisaId, NameNode); + + equivalent of the following ASL code: + Name (_CID, Package (0x02) // _CID: Compatible ID + { + EisaId ("PNP0A03"), + EisaId ("PNP0A08") + }) + + The package is added at the tail of the list of the input package node + name: + Name ("NamePackageNode", Package () { + [Pre-existing package entries], + [Newly created integer entry] + }) + + + @ingroup CodeGenApis + + @param [in] Integer Integer value that need to be added to package node. + @param [in, out] NameNode Package named node to add the object to. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval Others Error occurred during the operation. +**/ +EFI_STATUS +EFIAPI +AmlAddIntegerToNamedPackage ( + IN UINT32 Integer, + IN OUT AML_OBJECT_NODE_HANDLE NameNode + ); + /** AML code generation to invoke/call another method. This method is a subset implementation of MethodInvocation diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 22c2d598d0..89fa4e06f8 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -3871,6 +3871,73 @@ exit_handler: return Status; } +/** Add an integer value to the named package node. + + AmlCodeGenNamePackage ("_CID", NULL, &PackageNode); + AmlGetEisaIdFromString ("PNP0A03", &EisaId); + AmlAddIntegerToNamedPackage (EisaId, NameNode); + AmlGetEisaIdFromString ("PNP0A08", &EisaId); + AmlAddIntegerToNamedPackage (EisaId, NameNode); + + equivalent of the following ASL code: + Name (_CID, Package (0x02) // _CID: Compatible ID + { + EisaId ("PNP0A03"), + EisaId ("PNP0A08") + }) + + The package is added at the tail of the list of the input package node + name: + Name ("NamePackageNode", Package () { + [Pre-existing package entries], + [Newly created integer entry] + }) + + + @ingroup CodeGenApis + + @param [in] Integer Integer value that need to be added to package node. + @param [in, out] NameNode Package named node to add the object to. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval Others Error occurred during the operation. +**/ +EFI_STATUS +EFIAPI +AmlAddIntegerToNamedPackage ( + IN UINT32 Integer, + IN OUT AML_OBJECT_NODE_HANDLE NameNode + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE *PackageNode; + + if (NameNode == NULL) { + ASSERT_EFI_ERROR (FALSE); + return EFI_INVALID_PARAMETER; + } + + PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + NameNode, + EAmlParseIndexTerm1 + ); + if ((PackageNode == NULL) || + (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) || + (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) + { + ASSERT_EFI_ERROR (FALSE); + return EFI_INVALID_PARAMETER; + } + + Status = AmlAddRegisterOrIntegerToPackage (NULL, Integer, PackageNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + } + + return Status; +} + /** AML code generation to invoke/call another method. This method is a subset implementation of MethodInvocation -- 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#118641): https://edk2.groups.io/g/devel/message/118641 Mute This Topic: https://groups.io/mt/105957057/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-