* [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O
@ 2023-12-11 10:37 Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
PR: https://github.com/tianocore/edk2/pull/5131/
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Abdul Lateef Attar (5):
DynamicTablesPkg: AML Code generation for word I/O ranges
DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
DynamicTablesPkg: Corrects function pointer typedef of
AML_PARSE_FUNCTION
DynamicTablesPkg: Adds API to generate a method with ArgN
DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn
.../Include/Library/AmlLib/AmlLib.h | 189 +++++++++-
.../Common/AmlLib/CodeGen/AmlCodeGen.c | 339 ++++++++++++++++++
.../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 98 ++++-
.../Library/Common/AmlLib/Parser/AmlParser.c | 3 +-
4 files changed, 617 insertions(+), 12 deletions(-)
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112287): https://edk2.groups.io/g/devel/message/112287
Mute This Topic: https://groups.io/mt/103106351/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: AML Code generation for word I/O ranges
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
@ 2023-12-11 10:37 ` Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 2/5] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Add helper functions to generate AML resource data
for word I/O.
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
---
.../Include/Library/AmlLib/AmlLib.h | 65 ++++++++++++++
.../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 88 +++++++++++++++++++
2 files changed, 153 insertions(+)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 71e8539b30..5e340b94ce 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -2,6 +2,7 @@
AML Lib.
Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -724,6 +725,70 @@ AmlCodeGenRdWordBusNumber (
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
+/** Code generation for the "WordIO ()" ASL function.
+
+ The Resource Data effectively created is a Word Address Space Resource
+ Data. Cf ACPI 6.5:
+ - s6.4.3.5.3 "Word Address Space Descriptor".
+
+ 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 statement
+ and initially contain a "ResourceTemplate ()".
+ - returned through the NewRdNode parameter.
+
+ @param [in] IsResourceConsumer ResourceUsage parameter.
+ @param [in] IsMinFixed Minimum address is fixed.
+ @param [in] IsMaxFixed Maximum address is fixed.
+ @param [in] IsPosDecode Decode parameter
+ @param [in] IsaRanges Possible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+ @param [in] AddressGranularity Address granularity.
+ @param [in] AddressMinimum Minimum address.
+ @param [in] AddressMaximum Maximum address.
+ @param [in] AddressTranslation Address translation.
+ @param [in] RangeLength Range length.
+ @param [in] ResourceSourceIndex Resource Source index.
+ Not supported. Must be 0.
+ @param [in] ResourceSource Resource Source.
+ Not supported. Must be NULL.
+ @param [in] IsDenseTranslation TranslationDensity parameter.
+ @param [in] IsTypeStatic TranslationType parameter.
+ @param [in] NameOpNode NameOp object node defining a named object.
+ 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
+AmlCodeGenRdWordIo (
+ IN BOOLEAN IsResourceConsumer,
+ IN BOOLEAN IsMinFixed,
+ IN BOOLEAN IsMaxFixed,
+ IN BOOLEAN IsPosDecode,
+ IN UINT8 IsaRanges,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ IN UINT8 ResourceSourceIndex,
+ IN CONST CHAR8 *ResourceSource,
+ IN BOOLEAN IsDenseTranslation,
+ IN BOOLEAN IsTypeStatic,
+ IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+ OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
+ );
+
/** Code generation for the "QWordIO ()" ASL function.
The Resource Data effectively created is a QWord Address Space Resource
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bc1c1d119..60fe69ba6d 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -2,6 +2,7 @@
AML Resource Data Code Generation.
Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR>
+ Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -878,6 +879,93 @@ AmlCodeGenRdWordBusNumber (
);
}
+/** Code generation for the "WordIO ()" ASL function.
+
+ The Resource Data effectively created is a Word Address Space Resource
+ Data. Cf ACPI 6.5:
+ - s6.4.3.5.3 "Word Address Space Descriptor".
+
+ 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 statement
+ and initially contain a "ResourceTemplate ()".
+ - returned through the NewRdNode parameter.
+
+ @param [in] IsResourceConsumer ResourceUsage parameter.
+ @param [in] IsMinFixed Minimum address is fixed.
+ @param [in] IsMaxFixed Maximum address is fixed.
+ @param [in] IsPosDecode Decode parameter
+ @param [in] IsaRanges Possible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+ @param [in] AddressGranularity Address granularity.
+ @param [in] AddressMinimum Minimum address.
+ @param [in] AddressMaximum Maximum address.
+ @param [in] AddressTranslation Address translation.
+ @param [in] RangeLength Range length.
+ @param [in] ResourceSourceIndex Resource Source index.
+ Not supported. Must be 0.
+ @param [in] ResourceSource Resource Source.
+ Not supported. Must be NULL.
+ @param [in] IsDenseTranslation TranslationDensity parameter.
+ @param [in] IsTypeStatic TranslationType parameter.
+ @param [in] NameOpNode NameOp object node defining a named object.
+ 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
+AmlCodeGenRdWordIo (
+ IN BOOLEAN IsResourceConsumer,
+ IN BOOLEAN IsMinFixed,
+ IN BOOLEAN IsMaxFixed,
+ IN BOOLEAN IsPosDecode,
+ IN UINT8 IsaRanges,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
+ IN UINT8 ResourceSourceIndex,
+ IN CONST CHAR8 *ResourceSource,
+ IN BOOLEAN IsDenseTranslation,
+ IN BOOLEAN IsTypeStatic,
+ IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+ OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
+ )
+{
+ return AmlCodeGenRdWordSpace (
+ ACPI_ADDRESS_SPACE_TYPE_IO,
+ IsResourceConsumer,
+ IsPosDecode,
+ IsMinFixed,
+ IsMaxFixed,
+ RdIoRangeSpecificFlags (
+ IsaRanges,
+ IsDenseTranslation,
+ IsTypeStatic
+ ),
+ AddressGranularity,
+ AddressMinimum,
+ AddressMaximum,
+ AddressTranslation,
+ RangeLength,
+ ResourceSourceIndex,
+ ResourceSource,
+ NameOpNode,
+ NewRdNode
+ );
+}
+
/** Code generation for the "QWordSpace ()" ASL function.
The Resource Data effectively created is a QWord Address Space Resource
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112283): https://edk2.groups.io/g/devel/message/112283
Mute This Topic: https://groups.io/mt/103106347/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH v3 2/5] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
@ 2023-12-11 10:37 ` Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 3/5] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Corrects the parameters of AmlCodeGenRdWordBusNumber() to
UINT16 to generate word bus number.
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
---
DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h | 10 +++++-----
.../Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 5e340b94ce..eb8740692f 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -714,11 +714,11 @@ AmlCodeGenRdWordBusNumber (
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
- IN UINT32 AddressGranularity,
- IN UINT32 AddressMinimum,
- IN UINT32 AddressMaximum,
- IN UINT32 AddressTranslation,
- IN UINT32 RangeLength,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 60fe69ba6d..46243f981c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -848,11 +848,11 @@ AmlCodeGenRdWordBusNumber (
IN BOOLEAN IsMinFixed,
IN BOOLEAN IsMaxFixed,
IN BOOLEAN IsPosDecode,
- IN UINT32 AddressGranularity,
- IN UINT32 AddressMinimum,
- IN UINT32 AddressMaximum,
- IN UINT32 AddressTranslation,
- IN UINT32 RangeLength,
+ IN UINT16 AddressGranularity,
+ IN UINT16 AddressMinimum,
+ IN UINT16 AddressMaximum,
+ IN UINT16 AddressTranslation,
+ IN UINT16 RangeLength,
IN UINT8 ResourceSourceIndex,
IN CONST CHAR8 *ResourceSource,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112284): https://edk2.groups.io/g/devel/message/112284
Mute This Topic: https://groups.io/mt/103106348/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH v3 3/5] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 2/5] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
@ 2023-12-11 10:37 ` Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn Abdul Lateef Attar via groups.io
4 siblings, 0 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Corrects the function pointer typedef AML_PARSE_FUNCTION,
otherwise some compiler like VS2019 gives error.
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
---
DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
index 8e584d4930..d3a51a94c7 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
@@ -100,8 +100,7 @@ AmlParseStream (
**/
typedef
EFI_STATUS
-EFIAPI
-(*AML_PARSE_FUNCTION) (
+(EFIAPI *AML_PARSE_FUNCTION)(
IN CONST AML_NODE_HEADER *Node,
IN AML_PARSE_FORMAT ExpectedFormat,
IN OUT AML_STREAM *FStream,
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112285): https://edk2.groups.io/g/devel/message/112285
Mute This Topic: https://groups.io/mt/103106349/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
` (2 preceding siblings ...)
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 3/5] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
@ 2023-12-11 10:37 ` Abdul Lateef Attar via groups.io
2023-12-11 14:26 ` PierreGondois
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn Abdul Lateef Attar via groups.io
4 siblings, 1 reply; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds an API to generate a method which invokes another
method with arguments.
This help to generate dynamic code to invoke another
method(might be in static ASL file) with build-in
argument parameters.
e.g:
Method (MET0, 6, Serialized)
{
\_SB.MET1 (Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)
}
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
---
.../Include/Library/AmlLib/AmlLib.h | 46 ++++++
.../Common/AmlLib/CodeGen/AmlCodeGen.c | 152 ++++++++++++++++++
2 files changed, 198 insertions(+)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index eb8740692f..5ab205b5f0 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1693,4 +1693,50 @@ AmlAddNameStringToNamedPackage (
IN AML_OBJECT_NODE_HANDLE NamedNode
);
+/** AML code generation for a method invoking another method
+ with ArgN arguments.
+
+ AmlCodeGenMethodInvokeMethodArgn (
+ "MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
+ );
+ is equivalent of the following ASL code:
+ Method(MET0, 4, Serialized, 3) {
+ MET1 (Arg0, Arg1, Arg2, Arg3)
+ }
+
+ @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
+ Must be a NULL-terminated ASL NameString
+ e.g.: "MET1", "_SB.MET1", 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.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodInvokeMethodArgn (
+ IN CONST CHAR8 *MethodNameString,
+ IN CONST CHAR8 *InvokeMethodNameString,
+ IN UINT8 NumArgs,
+ IN BOOLEAN IsSerialized,
+ IN UINT8 SyncLevel,
+ IN AML_NODE_HANDLE ParentNode OPTIONAL,
+ OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
+ );
+
#endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a6db34fb97..b05fa6d109 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3849,3 +3849,155 @@ exit_handler:
return Status;
}
+
+/** AML code generation for a method invoking another method
+ with ArgN arguments.
+
+ AmlCodeGenMethodInvokeMethodArgn (
+ "MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
+ );
+ is equivalent of the following ASL code:
+ Method(MET0, 4, Serialized, 3) {
+ MET1 (Arg0, Arg1, Arg2, Arg3)
+ }
+
+ @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
+ Must be a NULL-terminated ASL NameString
+ e.g.: "MET1", "_SB.MET1", 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.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodInvokeMethodArgn (
+ IN CONST CHAR8 *MethodNameString,
+ IN CONST CHAR8 *InvokeMethodNameString,
+ 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;
+ AML_DATA_NODE *DataNode;
+ AML_OBJECT_NODE *ObjectNode;
+ CHAR8 *AmlNameString;
+ UINT32 AmlNameStringSize;
+ UINT8 ArgnCount;
+
+ if ((MethodNameString == NULL) || (InvokeMethodNameString == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Create a Method named MethodNameString
+ Status = AmlCodeGenMethod (
+ MethodNameString,
+ NumArgs,
+ IsSerialized,
+ SyncLevel,
+ NULL,
+ &MethodNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ DataNode = NULL;
+ Status = ConvertAslNameToAmlName (InvokeMethodNameString, &AmlNameString);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ FreePool (AmlNameString);
+ goto exit_handler;
+ }
+
+ Status = AmlCreateDataNode (
+ EAmlNodeDataTypeNameString,
+ (UINT8 *)AmlNameString,
+ AmlNameStringSize,
+ &DataNode
+ );
+ FreePool (AmlNameString);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ Status = AmlVarListAddTail (
+ (AML_NODE_HEADER *)MethodNode,
+ (AML_NODE_HEADER *)DataNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ DataNode = NULL;
+
+ for (ArgnCount = 0; ArgnCount < NumArgs; ArgnCount++) {
+ Status = AmlCreateObjectNode (
+ AmlGetByteEncodingByOpCode (AML_ARG0 + ArgnCount, 0),
+ 0,
+ &ObjectNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ Status = AmlVarListAddTail (
+ (AML_NODE_HEADER *)MethodNode,
+ (AML_NODE_HEADER *)ObjectNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ ObjectNode = NULL;
+ }
+
+ Status = LinkNode (
+ MethodNode,
+ ParentNode,
+ NewObjectNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ return Status;
+
+exit_handler:
+ if (MethodNode != NULL) {
+ AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
+ }
+
+ return Status;
+}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112286): https://edk2.groups.io/g/devel/message/112286
Mute This Topic: https://groups.io/mt/103106350/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
` (3 preceding siblings ...)
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN Abdul Lateef Attar via groups.io
@ 2023-12-11 10:37 ` Abdul Lateef Attar via groups.io
4 siblings, 0 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-11 10:37 UTC (permalink / raw)
To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar
From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Adds a wrapper API AmlCodeGenMethodInvokeMethodArgnWithInteger() to
the AmlCodeGenMethodInvokeMethodArgn().
Wrapper API provides ability to add integer arguments along
with ArgN argument.
This help to generate dynamic code to invoke another
method(might be in static ASL file) with build-in
argument parameters plus integer arguments.
e.g:
Method (MET0, 3, Serialized)
{
\_SB.MET1 (Arg0, Arg1, Arg2, 0x10, 0x20))
}
Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
---
.../Include/Library/AmlLib/AmlLib.h | 68 +++++++
.../Common/AmlLib/CodeGen/AmlCodeGen.c | 187 ++++++++++++++++++
2 files changed, 255 insertions(+)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 5ab205b5f0..132846a38a 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1739,4 +1739,72 @@ AmlCodeGenMethodInvokeMethodArgn (
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
+/** AML code generation for a method invoking another method
+ with ArgN arguments and optionally integer arguments.
+
+ Arg0Int = 0x10;
+ Arg1Int = 0x20;
+ AmlCodeGenMethodInvokeMethodArgnWithInteger (
+ "MET0", "MET1", 4, TRUE, 3,
+ Arg0Int, Arg1Int, NULL, NULL, NULL, NULL,
+ ParentNode, NewObjectNode
+ );
+ is equivalent of the following ASL code:
+ Method(MET0, 4, Serialized, 3) {
+ MET1 (Arg0, Arg1, Arg2, Arg3, 0x10, 0x20)
+ }
+
+ @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
+ Must be a NULL-terminated ASL NameString
+ e.g.: "MET1", "_SB.MET1", 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] IntegerArg0 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg1 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg2 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg3 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg4 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg5 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @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.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodInvokeMethodArgnWithInteger (
+ IN CONST CHAR8 *MethodNameString,
+ IN CONST CHAR8 *InvokeMethodNameString,
+ IN UINT8 NumArgs,
+ IN BOOLEAN IsSerialized,
+ IN UINT8 SyncLevel,
+ IN UINT64 *IntegerArg0 OPTIONAL,
+ IN UINT64 *IntegerArg1 OPTIONAL,
+ IN UINT64 *IntegerArg2 OPTIONAL,
+ IN UINT64 *IntegerArg3 OPTIONAL,
+ IN UINT64 *IntegerArg4 OPTIONAL,
+ IN UINT64 *IntegerArg5 OPTIONAL,
+ IN AML_NODE_HANDLE ParentNode OPTIONAL,
+ OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
+ );
+
#endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index b05fa6d109..b3b01e7baf 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -4001,3 +4001,190 @@ exit_handler:
return Status;
}
+
+/** AML code generation for a method invoking another method
+ with ArgN arguments and optionally integer arguments.
+
+ Arg0Int = 0x10;
+ Arg1Int = 0x20;
+ AmlCodeGenMethodInvokeMethodArgnWithInteger (
+ "MET0", "MET1", 4, TRUE, 3,
+ Arg0Int, Arg1Int, NULL, NULL, NULL, NULL,
+ ParentNode, NewObjectNode
+ );
+ is equivalent of the following ASL code:
+ Method(MET0, 4, Serialized, 3) {
+ MET1 (Arg0, Arg1, Arg2, Arg3, 0x10, 0x20)
+ }
+
+ @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
+ Must be a NULL-terminated ASL NameString
+ e.g.: "MET1", "_SB.MET1", 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] IntegerArg0 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg1 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg2 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg3 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg4 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @param [in] IntegerArg5 If provided and meets the validation criteria,
+ then set as integer argument to invoked method.
+ @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.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenMethodInvokeMethodArgnWithInteger (
+ IN CONST CHAR8 *MethodNameString,
+ IN CONST CHAR8 *InvokeMethodNameString,
+ IN UINT8 NumArgs,
+ IN BOOLEAN IsSerialized,
+ IN UINT8 SyncLevel,
+ IN UINT64 *IntegerArg0 OPTIONAL,
+ IN UINT64 *IntegerArg1 OPTIONAL,
+ IN UINT64 *IntegerArg2 OPTIONAL,
+ IN UINT64 *IntegerArg3 OPTIONAL,
+ IN UINT64 *IntegerArg4 OPTIONAL,
+ IN UINT64 *IntegerArg5 OPTIONAL,
+ IN AML_NODE_HANDLE ParentNode OPTIONAL,
+ OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ AML_OBJECT_NODE_HANDLE MethodObjectNode;
+ AML_OBJECT_NODE *IntNode;
+ UINT64 LocalIntegerArg[6];
+ UINT8 LocalIntegerArgCount;
+ UINT8 Index;
+
+ if ((MethodNameString == NULL) || (InvokeMethodNameString == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ /// Sanity check optional argument
+ /// AML library allows max 6 argument
+ /// Hence Integer argument count should be within the range
+ /// (NumArgs + Integer argument) should not be grater than 6
+ LocalIntegerArgCount = 0;
+ if (IntegerArg0 != NULL) {
+ if (NumArgs > 5) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg0;
+ }
+
+ if (IntegerArg1 != NULL) {
+ if (NumArgs > 4) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg1;
+ }
+
+ if (IntegerArg2 != NULL) {
+ if (NumArgs > 3) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg2;
+ }
+
+ if (IntegerArg3 != NULL) {
+ if (NumArgs > 2) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg3;
+ }
+
+ if (IntegerArg4 != NULL) {
+ if (NumArgs > 1) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg4;
+ }
+
+ if (IntegerArg5 != NULL) {
+ if (NumArgs > 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocalIntegerArg[LocalIntegerArgCount++] = *IntegerArg5;
+ }
+
+ /// Create a method invoking another method with Argn
+ Status = AmlCodeGenMethodInvokeMethodArgn (
+ MethodNameString,
+ InvokeMethodNameString,
+ NumArgs,
+ IsSerialized,
+ SyncLevel,
+ NULL,
+ &MethodObjectNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ /// Now append the integer argument
+ for (Index = 0; Index < LocalIntegerArgCount; Index++) {
+ IntNode = NULL;
+ Status = AmlCodeGenInteger (LocalIntegerArg[Index], &IntNode);
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ Status = AmlVarListAddTail (
+ (AML_NODE_HANDLE)MethodObjectNode,
+ (AML_NODE_HANDLE)IntNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+ }
+
+ IntNode = NULL;
+ Status = LinkNode (
+ MethodObjectNode,
+ ParentNode,
+ NewObjectNode
+ );
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ goto exit_handler;
+ }
+
+ return Status;
+
+exit_handler:
+ if (MethodObjectNode != NULL) {
+ AmlDeleteTree ((AML_NODE_HANDLE)MethodObjectNode);
+ }
+
+ return Status;
+}
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112288): https://edk2.groups.io/g/devel/message/112288
Mute This Topic: https://groups.io/mt/103106352/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN Abdul Lateef Attar via groups.io
@ 2023-12-11 14:26 ` PierreGondois
2023-12-14 4:13 ` Abdul Lateef Attar via groups.io
0 siblings, 1 reply; 8+ messages in thread
From: PierreGondois @ 2023-12-11 14:26 UTC (permalink / raw)
To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Sami Mujawar
Hello Abdul,
Thanks for the new patches. I reviewed this one, but I think it would
be better to have one single generic function to handle the 2 cases
(and the many more that might spawn) that you have.
Would it be possible to make a function based on this kind of interface instead ?
/* Type of the function parameter. There are some missing types,
like the Local arguments, packages, etc. but this should be sufficient
for your use case.
*/
typedef enum {
AmlMethodParamTypeArg = 0,
AmlMethodParamTypeInteger,
AmlMethodParamTypeString,
} AML_METHOD_PARAM_TYPE;
/* Structure to describe each method parameter. */
struct {
AML_METHOD_TYPE Type;
union {
UINTN ArgN;
UINT64 Integer;
VOID *Data;
} Data;
UINTN Length;
/* In case packages are added one day and we need to count the elements. */
UINTN Count;
}
/* The function */
EFI_STATUS
EFIAPI
AmlCodeGenMethodInvokeMethodArgn (
IN CONST CHAR8 *MethodNameString,
IN CONST CHAR8 *InvokeMethodNameString,
IN UINT8 NumArgs,
IN BOOLEAN IsSerialized,
IN UINT8 SyncLevel,
IN AML_METHOD_PARAM_TYPE *MethodParamArray,
IN UINTN MethodParamCount,
IN AML_NODE_HANDLE ParentNode OPTIONAL,
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
);
{
/* Based on the type of each element of MethodParamArray,
some Data node might be necessary to allocate.
*/
}
/* And to use this function: */
AML_METHOD_PARAM_TYPE MethodParamArray[4] = {
{ // [0]
.Type = AmlMethodParamTypeArg,
.Data = 2,
// Length and Count are unused.
},
{ // [1]
.Type = AmlMethodParamTypeInteger,
.Data = 1000,
// Length and Count are unused.
},
{ // [2]
.Type = AmlMethodParamTypeString,
.Data = "Hello",
.Length = strlen("Hello");
// Count is unused.
},
{ // [3]
.Type = AmlMethodParamTypeArg,
.Data = 0,
// Length and Count are unused.
},
}
AmlCodeGenMethodInvokeMethodArgn (
"MET0", "MET1", 4, TRUE, 3, MethodParamArray, 4, ParentNode, NewObjectNode
);
is equivalent of the following ASL code:
Method(MET0, 4, Serialized, 3) {
MET1 (Arg2, 1000, "Hello", Arg0)
}
Regards,
Pierre
On 12/11/23 11:37, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>
> Adds an API to generate a method which invokes another
> method with arguments.
> This help to generate dynamic code to invoke another
> method(might be in static ASL file) with build-in
> argument parameters.
>
> e.g:
> Method (MET0, 6, Serialized)
> {
> \_SB.MET1 (Arg0, Arg1, Arg2, Arg3, Arg4, Arg5)
> }
>
> Cc: Pierre Gondois <pierre.gondois@arm.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> ---
> .../Include/Library/AmlLib/AmlLib.h | 46 ++++++
> .../Common/AmlLib/CodeGen/AmlCodeGen.c | 152 ++++++++++++++++++
> 2 files changed, 198 insertions(+)
>
> diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> index eb8740692f..5ab205b5f0 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -1693,4 +1693,50 @@ AmlAddNameStringToNamedPackage (
> IN AML_OBJECT_NODE_HANDLE NamedNode
> );
>
> +/** AML code generation for a method invoking another method
> + with ArgN arguments.
> +
> + AmlCodeGenMethodInvokeMethodArgn (
> + "MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
> + );
> + is equivalent of the following ASL code:
> + Method(MET0, 4, Serialized, 3) {
> + MET1 (Arg0, Arg1, Arg2, Arg3)
> + }
> +
> + @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
> + Must be a NULL-terminated ASL NameString
> + e.g.: "MET1", "_SB.MET1", 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.
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenMethodInvokeMethodArgn (
> + IN CONST CHAR8 *MethodNameString,
> + IN CONST CHAR8 *InvokeMethodNameString,
> + IN UINT8 NumArgs,
> + IN BOOLEAN IsSerialized,
> + IN UINT8 SyncLevel,
> + IN AML_NODE_HANDLE ParentNode OPTIONAL,
> + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL
> + );
> +
> #endif // AML_LIB_H_
> diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> index a6db34fb97..b05fa6d109 100644
> --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> @@ -3849,3 +3849,155 @@ exit_handler:
>
> return Status;
> }
> +
> +/** AML code generation for a method invoking another method
> + with ArgN arguments.
> +
> + AmlCodeGenMethodInvokeMethodArgn (
> + "MET0", "MET1", 4, TRUE, 3, ParentNode, NewObjectNode
> + );
> + is equivalent of the following ASL code:
> + Method(MET0, 4, Serialized, 3) {
> + MET1 (Arg0, Arg1, Arg2, Arg3)
> + }
> +
> + @param [in] MethodNameString 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] InvokeMethodNameString The called/invoked method's name.
> + Must be a NULL-terminated ASL NameString
> + e.g.: "MET1", "_SB.MET1", 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.
aswell I think. Same comment for the function declaration.
> +**/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenMethodInvokeMethodArgn (
> + IN CONST CHAR8 *MethodNameString,
> + IN CONST CHAR8 *InvokeMethodNameString,
> + 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;
> + AML_DATA_NODE *DataNode;
> + AML_OBJECT_NODE *ObjectNode;
> + CHAR8 *AmlNameString;
> + UINT32 AmlNameStringSize;
> + UINT8 ArgnCount;
> +
> + if ((MethodNameString == NULL) || (InvokeMethodNameString == NULL)) {
Is it possible to also check that ParentNode and NewObjectNode are not
NULL together ?
((ParentNode == NULL) && (NewObjectNode == NULL))
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + // Create a Method named MethodNameString
> + Status = AmlCodeGenMethod (
> + MethodNameString,
> + NumArgs,
> + IsSerialized,
> + SyncLevel,
> + NULL,
> + &MethodNode
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + return Status;
> + }
> +
> + DataNode = NULL;
> + Status = ConvertAslNameToAmlName (InvokeMethodNameString, &AmlNameString);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + goto exit_handler;
> + }
> +
> + Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + FreePool (AmlNameString);
> + goto exit_handler;
> + }
> +
> + Status = AmlCreateDataNode (
> + EAmlNodeDataTypeNameString,
> + (UINT8 *)AmlNameString,
> + AmlNameStringSize,
> + &DataNode
> + );
> + FreePool (AmlNameString);
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + goto exit_handler;
> + }
> +
> + Status = AmlVarListAddTail (
> + (AML_NODE_HEADER *)MethodNode,
> + (AML_NODE_HEADER *)DataNode
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + goto exit_handler;
> + }
> +
> + DataNode = NULL;
> +
> + for (ArgnCount = 0; ArgnCount < NumArgs; ArgnCount++) {
> + Status = AmlCreateObjectNode (
> + AmlGetByteEncodingByOpCode (AML_ARG0 + ArgnCount, 0),
> + 0,
> + &ObjectNode
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + goto exit_handler;
> + }
> +
> + Status = AmlVarListAddTail (
> + (AML_NODE_HEADER *)MethodNode,
> + (AML_NODE_HEADER *)ObjectNode
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
I think 'ObjectNode' needs to be free here if the function fails.
> + goto exit_handler;
> + }
> +
> + ObjectNode = NULL;
> + }
> +
> + Status = LinkNode (
> + MethodNode,
> + ParentNode,
> + NewObjectNode
> + );
> + if (EFI_ERROR (Status)) {
> + ASSERT_EFI_ERROR (Status);
> + goto exit_handler;
> + }
> +
> + return Status;
> +
> +exit_handler:
> + if (MethodNode != NULL) {
I don't think it's possible to have MethodNode == NULL here.
> + AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
> + }
> +
> + return Status;
> +}
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112299): https://edk2.groups.io/g/devel/message/112299
Mute This Topic: https://groups.io/mt/103106350/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN
2023-12-11 14:26 ` PierreGondois
@ 2023-12-14 4:13 ` Abdul Lateef Attar via groups.io
0 siblings, 0 replies; 8+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-14 4:13 UTC (permalink / raw)
To: PierreGondois, devel
[-- Attachment #1: Type: text/plain, Size: 515 bytes --]
Hi Pierre,
Thanks for reviewing the patch series.
I'll address the review comments and work on the suggested alternative solution.
Thanks
Abdul
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112497): https://edk2.groups.io/g/devel/message/112497
Mute This Topic: https://groups.io/mt/103106350/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 1013 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-12-14 4:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-11 10:37 [edk2-devel] [PATCH v3 0/5] DynamicTablesPkg: Updated word I/O Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 2/5] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 3/5] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Adds API to generate a method with ArgN Abdul Lateef Attar via groups.io
2023-12-11 14:26 ` PierreGondois
2023-12-14 4:13 ` Abdul Lateef Attar via groups.io
2023-12-11 10:37 ` [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn Abdul Lateef Attar via groups.io
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox