From 95a7323e86126560e0a37b3801bc6c12a8428cda Mon Sep 17 00:00:00 2001 From: Tuan Phan Date: Thu, 23 Jul 2026 00:06:57 -0700 Subject: [PATCH] DynamicTablesPkg/AmiLib: Make AmlCodeGenMethod public There is currently no API available for generating AML methods without a return value. This change exports the AmlCodeGenMethod API so it can be used to create non-returning methods when required. Signed-off-by: Tuan Phan --- .../Include/Library/AmlLib/AmlLib.h | 44 +++++++++++++++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 13 +++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h index 1e7642523d..f4edaecc41 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1447,6 +1447,50 @@ AmlCodeGenScope ( OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL ); +/** 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 := MethodOp PkgLength NameString MethodFlags TermList + MethodOp := 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 <= NumArgs <= 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 <= SyncLevel <= 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. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethod ( + IN CONST CHAR8 *NameString, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ); + /** AML code generation for a method returning a NameString. AmlCodeGenMethodRetNameString ( diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 60818866c6..41a43e7388 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1568,16 +1568,15 @@ error_handler1: @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 + IN CONST CHAR8 *NameString, + 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;