From 8b83386cb2a40ea23ffc7b995b7bd4f1267da43d Mon Sep 17 00:00:00 2001 From: Abdul Lateef Attar Date: Fri, 30 Jan 2026 11:59:29 +0000 Subject: [PATCH] DynamicTablesPkg/AmlLib: Fix Notify to use NamePath instead of String Update AmlCodeGenNotify() to convert ASL names to AML NameString format using ConvertAslNameToAmlName() and create a EAmlNodeDataTypeNameString data node. This produces proper unquoted NamePath references in ASL: Method (_L0B, 0, Serialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF { Notify (\_SB.PC00.RP81.XHC0, 0x02) // Device Wake Notify (\_SB.PC02.RP81.XHC0, 0x02) // Device Wake } instead of quoted strings: Method (_L0B, 0, Serialized) // _Lxx: Level-Triggered GPE, xx=0x00-0xFF { Notify ("\\_SB.PC00.RP81.XHC0", 0x02) // Device Wake Notify ("\\_SB.PC02.RP81.XHC0", 0x02) // Device Wake } Signed-off-by: Abdul Lateef Attar --- .../Common/AmlLib/CodeGen/AmlCodeGen.c | 76 +++++++++++++------ 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 1c57681062..8d239901fd 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -5216,7 +5216,7 @@ error_handler: It assumes that NameString, Local, and Arg objects reference valid device, processor, or thermal zone objects. - @param [in] NotifyObject Object to be notified. + @param [in] NotifyObjectParam Object to be notified. @param [in] NotifyValue Notification value. @param [in] ParentNode If provided, set ParentNode as the parent of the node created. @@ -5231,14 +5231,17 @@ STATIC EFI_STATUS EFIAPI AmlCodeGenNotify ( - IN AML_METHOD_PARAM NotifyObject, + IN AML_METHOD_PARAM NotifyObjectParam, IN UINT8 NotifyValue, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL ) { - AML_OBJECT_NODE *NotifyObjectNode; + AML_NODE_HEADER *NotifyObject; AML_OBJECT_NODE *ValueObjectNode; + AML_DATA_NODE *DataNode; + CHAR8 *AmlNameString; + UINT32 AmlNameStringSize; EFI_STATUS Status; if ((ParentNode == NULL) && (NewObjectNode == NULL)) { @@ -5246,37 +5249,56 @@ AmlCodeGenNotify ( return EFI_INVALID_PARAMETER; } - if ((NotifyObject.Type != AmlMethodParamTypeString) && - (NotifyObject.Type != AmlMethodParamTypeArg) && - (NotifyObject.Type != AmlMethodParamTypeLocal)) + if ((NotifyObjectParam.Type != AmlMethodParamTypeString) && + (NotifyObjectParam.Type != AmlMethodParamTypeArg) && + (NotifyObjectParam.Type != AmlMethodParamTypeLocal)) { ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); return EFI_INVALID_PARAMETER; } - ValueObjectNode = NULL; - NotifyObjectNode = NULL; + ValueObjectNode = NULL; + NotifyObject = NULL; + DataNode = NULL; + AmlNameString = NULL; - switch (NotifyObject.Type) { + switch (NotifyObjectParam.Type) { case AmlMethodParamTypeString: - if (NotifyObject.Data.Buffer == NULL) { + if (NotifyObjectParam.Data.Buffer == NULL) { ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); Status = EFI_INVALID_PARAMETER; goto exit_handler; } - Status = AmlCodeGenString ( - NotifyObject.Data.Buffer, - &NotifyObjectNode - ); + Status = ConvertAslNameToAmlName (NotifyObjectParam.Data.Buffer, &AmlNameString); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); goto exit_handler; } + Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto exit_handler; + } + + Status = AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8 *)AmlNameString, + AmlNameStringSize, + &DataNode + ); + FreePool (AmlNameString); + AmlNameString = NULL; + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto exit_handler; + } + + NotifyObject = (AML_NODE_HEADER *)DataNode; break; case AmlMethodParamTypeArg: - if (NotifyObject.Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) { + if (NotifyObjectParam.Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) { ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); Status = EFI_INVALID_PARAMETER; goto exit_handler; @@ -5284,11 +5306,11 @@ AmlCodeGenNotify ( Status = AmlCreateObjectNode ( AmlGetByteEncodingByOpCode ( - AML_ARG0 + NotifyObject.Data.Arg, + AML_ARG0 + NotifyObjectParam.Data.Arg, 0 ), 0, - &NotifyObjectNode + (AML_OBJECT_NODE **)&NotifyObject ); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); @@ -5297,7 +5319,7 @@ AmlCodeGenNotify ( break; case AmlMethodParamTypeLocal: - if (NotifyObject.Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) { + if (NotifyObjectParam.Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) { ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); Status = EFI_INVALID_PARAMETER; goto exit_handler; @@ -5305,11 +5327,11 @@ AmlCodeGenNotify ( Status = AmlCreateObjectNode ( AmlGetByteEncodingByOpCode ( - AML_LOCAL0 + NotifyObject.Data.Local, + AML_LOCAL0 + NotifyObjectParam.Data.Local, 0 ), 0, - &NotifyObjectNode + (AML_OBJECT_NODE **)&NotifyObject ); if (EFI_ERROR (Status)) { ASSERT_EFI_ERROR (Status); @@ -5333,7 +5355,7 @@ AmlCodeGenNotify ( } Status = AmlCodeGenNotifyNode ( - (AML_NODE_HEADER *)NotifyObjectNode, + NotifyObject, (AML_NODE_HEADER *)ValueObjectNode, ParentNode, NewObjectNode @@ -5343,19 +5365,23 @@ AmlCodeGenNotify ( goto exit_handler; } - NotifyObjectNode = NULL; - ValueObjectNode = NULL; + NotifyObject = NULL; + ValueObjectNode = NULL; exit_handler: - if (NotifyObjectNode != NULL) { - AmlDeleteTree ((AML_NODE_HEADER *)NotifyObjectNode); + if (NotifyObject != NULL) { + AmlDeleteTree (NotifyObject); } if (ValueObjectNode != NULL) { AmlDeleteTree ((AML_NODE_HEADER *)ValueObjectNode); } + if (AmlNameString != NULL) { + FreePool (AmlNameString); + } + return Status; }