public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability
@ 2023-12-20  9:38 Abdul Lateef Attar via groups.io
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-20  9:38 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/5171/

V5: delta changes
  Addressed review comments.
V4: 
  Address Pierre's review comments.
  Merged patch 4 & patch 5.
  Also added parameter logic suggested by Pierre.
V3: delta changes
  CI fix and error handling for 
    DynamicTablesPkg: Adds API to generate a method with ArgN.
  Added new patch "DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn"
V2:
  Added new API to generate a method which
  invokes another method with argument.
V1:
Code changes to
Add API to generate word I/O ranges.
Correct the parameter to generate word bus number.
Corrects the function pointer typedef

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 (4):
  DynamicTablesPkg: AML Code generation for word I/O ranges
  DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  DynamicTablesPkg: Corrects function pointer typedef of
    AML_PARSE_FUNCTION
  DynamicTablesPkg: AML Code generation to invoke a method

 .../Include/Library/AmlLib/AmlLib.h           | 187 +++++++++++++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++++++-
 .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
 4 files changed, 510 insertions(+), 13 deletions(-)

-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112753): https://edk2.groups.io/g/devel/message/112753
Mute This Topic: https://groups.io/mt/103278517/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges
  2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
@ 2023-12-20  9:38 ` Abdul Lateef Attar via groups.io
  2023-12-21 13:53   ` Sami Mujawar
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-20  9:38 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 (#112754): https://edk2.groups.io/g/devel/message/112754
Mute This Topic: https://groups.io/mt/103278518/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] 16+ messages in thread

* [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
@ 2023-12-20  9:38 ` Abdul Lateef Attar via groups.io
  2023-12-21 13:53   ` Sami Mujawar
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-20  9:38 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 (#112755): https://edk2.groups.io/g/devel/message/112755
Mute This Topic: https://groups.io/mt/103278519/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] 16+ messages in thread

* [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION
  2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
@ 2023-12-20  9:38 ` Abdul Lateef Attar via groups.io
  2023-12-21 13:54   ` Sami Mujawar
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method Abdul Lateef Attar via groups.io
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-20  9:38 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 (#112756): https://edk2.groups.io/g/devel/message/112756
Mute This Topic: https://groups.io/mt/103278520/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] 16+ messages in thread

* [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method
  2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
                   ` (2 preceding siblings ...)
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
@ 2023-12-20  9:38 ` Abdul Lateef Attar via groups.io
  2023-12-20 10:19   ` PierreGondois
  2023-12-21 13:55   ` Sami Mujawar
  2023-12-21 13:56 ` [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Sami Mujawar
       [not found] ` <17A2DD5CE37E2833.24485@groups.io>
  5 siblings, 2 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-20  9:38 UTC (permalink / raw)
  To: devel; +Cc: Abdul Lateef Attar, Pierre Gondois, Sami Mujawar

From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>

Adds API to generate AML code to invoke/call another
method. Also provides ability to pass arguments of
type integer, string, ArgObj or LocalObj.

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           | 112 +++++++++
 .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
 2 files changed, 346 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index eb8740692f..043ec3d842 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -101,6 +101,56 @@ typedef enum {
   AmlAddressRangeMax      = 4
 } AML_MEMORY_ATTRIBUTES_MTP;
 
+/** Method parameter types
+
+  Possible values are:
+    0 - AmlMethodParamTypeInteger
+    1 - AmlMethodParamTypeString
+    2 - AmlMethodParamTypeArg
+    3 - AmlMethodParamTypeLocal
+
+  @par Reference(s)
+  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
+
+**/
+typedef enum {
+  AmlMethodParamTypeInteger = 0,
+  AmlMethodParamTypeString  = 1,
+  AmlMethodParamTypeArg     = 2,
+  AmlMethodParamTypeLocal   = 3
+} AML_METHOD_PARAM_TYPE;
+
+/** AML Method parameter data
+  holds the AML method parameter data.
+**/
+typedef union {
+  UINT8     Arg;
+  UINT8     Local;
+  UINT64    Integer;
+  VOID      *Buffer;
+} AML_METHOD_PARAM_DATA;
+
+/** structure to hold AML method parameter types
+  Type  -   Type of parameter
+  Data  -   holds data of parameter
+            if Type is AmlMethodParamTypeInteger
+              then Data is of type Integer to hold integer value.
+            if Type is AmlMethodParamTypeString
+              then Data contains null terminated string.
+            If Type is AmlMethodParamTypeArg
+              then Data contains the Argument number,
+              0 to 6 are supported value.
+            If Type is AmlMethodParamTypeLocal
+              then Data contains the Local variable number,
+              0 to 7 are supported value.
+  DataSize - for future use
+**/
+typedef struct {
+  AML_METHOD_PARAM_TYPE    Type;
+  AML_METHOD_PARAM_DATA    Data;
+  UINTN                    DataSize;
+} AML_METHOD_PARAM;
+
 /** Parse the definition block.
 
   The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
@@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage (
   IN AML_OBJECT_NODE_HANDLE  NamedNode
   );
 
+/** AML code generation to invoke/call another method.
+
+  This method is a subset implementation of MethodInvocation
+  defined in the ACPI specification 6.5,
+  section 20.2.5 "Term Objects Encoding".
+  Added integer, string, ArgObj and LocalObj support.
+
+  Example 1:
+    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
+    is equivalent to the following ASL code:
+      MET0 ();
+
+  Example 2:
+    AML_METHOD_PARAM  Param[4];
+    Param[0].Data.Integer = 0x100;
+    Param[0].Type = AmlMethodParamTypeInteger;
+    Param[1].Data.Buffer = "TEST";
+    Param[1].Type = AmlMethodParamTypeString;
+    Param[2].Data.Arg = 0;
+    Param[2].Type = AmlMethodParamTypeArg;
+    Param[3].Data.Local = 2;
+    Param[3].Type = AmlMethodParamTypeLocal;
+    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
+
+    is equivalent to the following ASL code:
+      MET0 (0x100, "TEST", Arg0, Local2);
+
+  Example 3:
+    AML_METHOD_PARAM  Param[2];
+    Param[0].Data.Arg = 0;
+    Param[0].Type = AmlMethodParamTypeArg;
+    Param[1].Data.Integer = 0x100;
+    Param[1].Type = AmlMethodParamTypeInteger;
+    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
+    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
+
+    is equivalent to the following ASL code:
+    Method (MET2, 2, Serialized)
+    {
+      MET3 (Arg0, 0x0100)
+    }
+
+  @param [in] MethodNameString  The method name to be called or invoked.
+  @param [in] NumArgs           Number of arguments to be passed,
+                                0 to 7 are permissible values.
+  @param [in] Parameters        Contains the parameter data.
+  @param [in] ParentNode        The parent node to which the method invocation
+                                nodes are attached.
+
+  @retval EFI_SUCCESS             Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
+ **/
+EFI_STATUS
+EFIAPI
+AmlCodeGenInvokeMethod (
+  IN  CONST CHAR8             *MethodNameString,
+  IN        UINT8             NumArgs,
+  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
+  IN        AML_NODE_HANDLE   ParentNode
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a6db34fb97..ddec9b67ed 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -2,6 +2,7 @@
   AML Code Generation.
 
   Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.<BR>
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString (
   Status = AmlCreateDataNode (
              EAmlNodeDataTypeRaw,
              (CONST UINT8 *)String,
-             StrSize (String),
+             (UINT32)StrSize (String),
              &DataNode
              );
   if (EFI_ERROR (Status)) {
@@ -3849,3 +3850,235 @@ exit_handler:
 
   return Status;
 }
+
+/** AML code generation to invoke/call another method.
+
+  This method is a subset implementation of MethodInvocation
+  defined in the ACPI specification 6.5,
+  section 20.2.5 "Term Objects Encoding".
+  Added integer, string, ArgObj and LocalObj support.
+
+  Example 1:
+    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
+    is equivalent to the following ASL code:
+      MET0 ();
+
+  Example 2:
+    AML_METHOD_PARAM  Param[4];
+    Param[0].Data.Integer = 0x100;
+    Param[0].Type = AmlMethodParamTypeInteger;
+    Param[1].Data.Buffer = "TEST";
+    Param[1].Type = AmlMethodParamTypeString;
+    Param[2].Data.Arg = 0;
+    Param[2].Type = AmlMethodParamTypeArg;
+    Param[3].Data.Local = 2;
+    Param[3].Type = AmlMethodParamTypeLocal;
+    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
+
+    is equivalent to the following ASL code:
+      MET0 (0x100, "TEST", Arg0, Local2);
+
+  Example 3:
+    AML_METHOD_PARAM  Param[2];
+    Param[0].Data.Arg = 0;
+    Param[0].Type = AmlMethodParamTypeArg;
+    Param[1].Data.Integer = 0x100;
+    Param[1].Type = AmlMethodParamTypeInteger;
+    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
+    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
+
+    is equivalent to the following ASL code:
+    Method (MET2, 2, Serialized)
+    {
+      MET3 (Arg0, 0x0100)
+    }
+
+  @param [in] MethodNameString  The method name to be called or invoked.
+  @param [in] NumArgs           Number of arguments to be passed,
+                                0 to 7 are permissible values.
+  @param [in] Parameters        Contains the parameter data.
+  @param [in] ParentNode        The parent node to which the method invocation
+                                nodes are attached.
+
+  @retval EFI_SUCCESS             Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
+ **/
+EFI_STATUS
+EFIAPI
+AmlCodeGenInvokeMethod (
+  IN  CONST CHAR8             *MethodNameString,
+  IN        UINT8             NumArgs,
+  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
+  IN        AML_NODE_HANDLE   ParentNode
+  )
+{
+  EFI_STATUS       Status;
+  UINT8            Index;
+  CHAR8            *AmlNameString;
+  UINT32           AmlNameStringSize;
+  AML_DATA_NODE    *DataNode;
+  AML_OBJECT_NODE  *ObjectNode;
+  AML_NODE_HANDLE  *NodeStream;
+
+  if ((MethodNameString == NULL) || (ParentNode == NULL)) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if ((NumArgs > 7) ||
+      ((Parameters == NULL) && (NumArgs > 0)))
+  {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  /// Allocate space to store methodname, object, data node pointers
+  NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs + 1));
+  if (NodeStream == NULL) {
+    ASSERT (0);
+    return EFI_OUT_OF_RESOURCES;
+  }
+
+  /// Create a called or invoked method name string.
+  Status = ConvertAslNameToAmlName (MethodNameString, &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;
+  }
+
+  DataNode = NULL;
+  Status   = AmlCreateDataNode (
+               EAmlNodeDataTypeNameString,
+               (UINT8 *)AmlNameString,
+               AmlNameStringSize,
+               &DataNode
+               );
+  FreePool (AmlNameString);
+  if (EFI_ERROR (Status)) {
+    ASSERT_EFI_ERROR (Status);
+    goto exit_handler;
+  }
+
+  NodeStream[0] = (AML_NODE_HANDLE)DataNode;
+
+  if (Parameters != NULL) {
+    /// Validate and convert the Parameters to the stream of nodes.
+    for (Index = 0; Index < NumArgs; Index++) {
+      switch (Parameters[Index].Type) {
+        case AmlMethodParamTypeInteger:
+          ObjectNode = NULL;
+          Status     = AmlCodeGenInteger (Parameters[Index].Data.Integer, &ObjectNode);
+          if (EFI_ERROR (Status)) {
+            ASSERT_EFI_ERROR (Status);
+            goto exit_handler;
+          }
+
+          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
+          break;
+        case AmlMethodParamTypeString:
+          ObjectNode = NULL;
+          if (Parameters[Index].Data.Buffer == NULL) {
+            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+            Status = EFI_INVALID_PARAMETER;
+            goto exit_handler;
+          }
+
+          Status = AmlCodeGenString (Parameters[Index].Data.Buffer, &ObjectNode);
+          if (EFI_ERROR (Status)) {
+            ASSERT_EFI_ERROR (Status);
+            goto exit_handler;
+          }
+
+          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
+          break;
+        case AmlMethodParamTypeArg:
+          ObjectNode = NULL;
+          if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) {
+            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+            Status = EFI_INVALID_PARAMETER;
+            goto exit_handler;
+          }
+
+          Status = AmlCreateObjectNode (
+                     AmlGetByteEncodingByOpCode (AML_ARG0 + Parameters[Index].Data.Arg, 0),
+                     0,
+                     &ObjectNode
+                     );
+          if (EFI_ERROR (Status)) {
+            ASSERT_EFI_ERROR (Status);
+            goto exit_handler;
+          }
+
+          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
+          break;
+        case AmlMethodParamTypeLocal:
+          ObjectNode = NULL;
+          if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) {
+            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+            Status = EFI_INVALID_PARAMETER;
+            goto exit_handler;
+          }
+
+          Status = AmlCreateObjectNode (
+                     AmlGetByteEncodingByOpCode (AML_LOCAL0 + Parameters[Index].Data.Local, 0),
+                     0,
+                     &ObjectNode
+                     );
+          if (EFI_ERROR (Status)) {
+            ASSERT_EFI_ERROR (Status);
+            goto exit_handler;
+          }
+
+          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
+          break;
+        default:
+          ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
+          Status = EFI_INVALID_PARAMETER;
+          goto exit_handler;
+          break;
+      }
+    }
+  }
+
+  /// Index <= NumArgs, because an additional method name was added.
+  for (Index = 0; Index <= NumArgs; Index++) {
+    Status = AmlVarListAddTail (
+               (AML_NODE_HANDLE)ParentNode,
+               (AML_NODE_HANDLE)NodeStream[Index]
+               );
+    if (EFI_ERROR (Status)) {
+      ASSERT_EFI_ERROR (Status);
+      goto exit_handler_detach;
+    }
+  }
+
+  FreePool (NodeStream);
+  return Status;
+
+exit_handler_detach:
+  /// The index contains the last successful node attached.
+  for ( ; Index > 0; Index--) {
+    /// Index contains the node number that is failed for AmlVarListAddTail().
+    /// Hence, start detaching from the last successful
+    AmlDetachNode (NodeStream[Index-1]);
+  }
+
+exit_handler:
+  /// Index <= NumArgs, because an additional method name was added.
+  for (Index = 0; Index <= NumArgs; Index++) {
+    if (NodeStream[Index] != 0) {
+      AmlDeleteTree (NodeStream[Index]);
+    }
+  }
+
+  FreePool (NodeStream);
+  return Status;
+}
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112757): https://edk2.groups.io/g/devel/message/112757
Mute This Topic: https://groups.io/mt/103278521/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] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method Abdul Lateef Attar via groups.io
@ 2023-12-20 10:19   ` PierreGondois
  2023-12-21 13:55   ` Sami Mujawar
  1 sibling, 0 replies; 16+ messages in thread
From: PierreGondois @ 2023-12-20 10:19 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Sami Mujawar

Hello Abdul,
Thanks for the update!

Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>

On 12/20/23 10:38, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
> 
> Adds API to generate AML code to invoke/call another
> method. Also provides ability to pass arguments of
> type integer, string, ArgObj or LocalObj.
> 
> 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           | 112 +++++++++
>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>   2 files changed, 346 insertions(+), 1 deletion(-)
> 
> diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> index eb8740692f..043ec3d842 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -101,6 +101,56 @@ typedef enum {
>     AmlAddressRangeMax      = 4
>   } AML_MEMORY_ATTRIBUTES_MTP;
>   
> +/** Method parameter types
> +
> +  Possible values are:
> +    0 - AmlMethodParamTypeInteger
> +    1 - AmlMethodParamTypeString
> +    2 - AmlMethodParamTypeArg
> +    3 - AmlMethodParamTypeLocal
> +
> +  @par Reference(s)
> +  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
> +
> +**/
> +typedef enum {
> +  AmlMethodParamTypeInteger = 0,
> +  AmlMethodParamTypeString  = 1,
> +  AmlMethodParamTypeArg     = 2,
> +  AmlMethodParamTypeLocal   = 3
> +} AML_METHOD_PARAM_TYPE;
> +
> +/** AML Method parameter data
> +  holds the AML method parameter data.
> +**/
> +typedef union {
> +  UINT8     Arg;
> +  UINT8     Local;
> +  UINT64    Integer;
> +  VOID      *Buffer;
> +} AML_METHOD_PARAM_DATA;
> +
> +/** structure to hold AML method parameter types
> +  Type  -   Type of parameter
> +  Data  -   holds data of parameter
> +            if Type is AmlMethodParamTypeInteger
> +              then Data is of type Integer to hold integer value.
> +            if Type is AmlMethodParamTypeString
> +              then Data contains null terminated string.
> +            If Type is AmlMethodParamTypeArg
> +              then Data contains the Argument number,
> +              0 to 6 are supported value.
> +            If Type is AmlMethodParamTypeLocal
> +              then Data contains the Local variable number,
> +              0 to 7 are supported value.
> +  DataSize - for future use
> +**/
> +typedef struct {
> +  AML_METHOD_PARAM_TYPE    Type;
> +  AML_METHOD_PARAM_DATA    Data;
> +  UINTN                    DataSize;
> +} AML_METHOD_PARAM;
> +
>   /** Parse the definition block.
>   
>     The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
> @@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage (
>     IN AML_OBJECT_NODE_HANDLE  NamedNode
>     );
>   
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation
> +  defined in the ACPI specification 6.5,
> +  section 20.2.5 "Term Objects Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  );
> +
>   #endif // AML_LIB_H_
> diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> index a6db34fb97..ddec9b67ed 100644
> --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> @@ -2,6 +2,7 @@
>     AML Code Generation.
>   
>     Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.<BR>
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
>   
>     SPDX-License-Identifier: BSD-2-Clause-Patent
>   **/
> @@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString (
>     Status = AmlCreateDataNode (
>                EAmlNodeDataTypeRaw,
>                (CONST UINT8 *)String,
> -             StrSize (String),
> +             (UINT32)StrSize (String),
>                &DataNode
>                );
>     if (EFI_ERROR (Status)) {
> @@ -3849,3 +3850,235 @@ exit_handler:
>   
>     return Status;
>   }
> +
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation
> +  defined in the ACPI specification 6.5,
> +  section 20.2.5 "Term Objects Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  )
> +{
> +  EFI_STATUS       Status;
> +  UINT8            Index;
> +  CHAR8            *AmlNameString;
> +  UINT32           AmlNameStringSize;
> +  AML_DATA_NODE    *DataNode;
> +  AML_OBJECT_NODE  *ObjectNode;
> +  AML_NODE_HANDLE  *NodeStream;
> +
> +  if ((MethodNameString == NULL) || (ParentNode == NULL)) {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if ((NumArgs > 7) ||
> +      ((Parameters == NULL) && (NumArgs > 0)))
> +  {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  /// Allocate space to store methodname, object, data node pointers
> +  NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs + 1));
> +  if (NodeStream == NULL) {
> +    ASSERT (0);
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  /// Create a called or invoked method name string.
> +  Status = ConvertAslNameToAmlName (MethodNameString, &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;
> +  }
> +
> +  DataNode = NULL;
> +  Status   = AmlCreateDataNode (
> +               EAmlNodeDataTypeNameString,
> +               (UINT8 *)AmlNameString,
> +               AmlNameStringSize,
> +               &DataNode
> +               );
> +  FreePool (AmlNameString);
> +  if (EFI_ERROR (Status)) {
> +    ASSERT_EFI_ERROR (Status);
> +    goto exit_handler;
> +  }
> +
> +  NodeStream[0] = (AML_NODE_HANDLE)DataNode;
> +
> +  if (Parameters != NULL) {
> +    /// Validate and convert the Parameters to the stream of nodes.
> +    for (Index = 0; Index < NumArgs; Index++) {
> +      switch (Parameters[Index].Type) {
> +        case AmlMethodParamTypeInteger:
> +          ObjectNode = NULL;
> +          Status     = AmlCodeGenInteger (Parameters[Index].Data.Integer, &ObjectNode);
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        case AmlMethodParamTypeString:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Buffer == NULL) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCodeGenString (Parameters[Index].Data.Buffer, &ObjectNode);
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        case AmlMethodParamTypeArg:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_ARG0 + Parameters[Index].Data.Arg, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        case AmlMethodParamTypeLocal:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_LOCAL0 + Parameters[Index].Data.Local, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        default:
> +          ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +          Status = EFI_INVALID_PARAMETER;
> +          goto exit_handler;
> +          break;
> +      }
> +    }
> +  }
> +
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    Status = AmlVarListAddTail (
> +               (AML_NODE_HANDLE)ParentNode,
> +               (AML_NODE_HANDLE)NodeStream[Index]
> +               );
> +    if (EFI_ERROR (Status)) {
> +      ASSERT_EFI_ERROR (Status);
> +      goto exit_handler_detach;
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +
> +exit_handler_detach:
> +  /// The index contains the last successful node attached.
> +  for ( ; Index > 0; Index--) {
> +    /// Index contains the node number that is failed for AmlVarListAddTail().
> +    /// Hence, start detaching from the last successful
> +    AmlDetachNode (NodeStream[Index-1]);
> +  }
> +
> +exit_handler:
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    if (NodeStream[Index] != 0) {
> +      AmlDeleteTree (NodeStream[Index]);
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +}


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112760): https://edk2.groups.io/g/devel/message/112760
Mute This Topic: https://groups.io/mt/103278521/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
@ 2023-12-21 13:53   ` Sami Mujawar
  0 siblings, 0 replies; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 13:53 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

Hi Abdul,

Thank you for this patch.

These changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112814): https://edk2.groups.io/g/devel/message/112814
Mute This Topic: https://groups.io/mt/103278518/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
@ 2023-12-21 13:53   ` Sami Mujawar
  0 siblings, 0 replies; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 13:53 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

Hi Abdul,

Thank you for this fix. These changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> 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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112815): https://edk2.groups.io/g/devel/message/112815
Mute This Topic: https://groups.io/mt/103278519/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
@ 2023-12-21 13:54   ` Sami Mujawar
  2023-12-22  4:16     ` Abdul Lateef Attar via groups.io
  0 siblings, 1 reply; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 13:54 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

[-- Attachment #1: Type: text/plain, Size: 2070 bytes --]

Hi Abdul,

Thank you for this fix.

For Arm EFIAPI evaluates to nothing, hence we could not catch such issues.

Do you use the rest of the Dynamic Tables Framework? I guess we have not 
included the calling convention at other places e.g. 
https://github.com/tianocore/edk2/blob/master/DynamicTablesPkg/Include/AcpiTableGenerator.h#L217

Maybe we need to find and fix those issues as well.

In either case, this patch looks good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> 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,


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112816): https://edk2.groups.io/g/devel/message/112816
Mute This Topic: https://groups.io/mt/103278520/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: 4070 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method Abdul Lateef Attar via groups.io
  2023-12-20 10:19   ` PierreGondois
@ 2023-12-21 13:55   ` Sami Mujawar
  2023-12-22  4:10     ` Abdul Lateef Attar via groups.io
  1 sibling, 1 reply; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 13:55 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

Hi Abdul,

I have some minor feedback maked inline as [SAMI].

I think other than the typecast change for the value returned by 
StrSize(), the remainder of the patch looks ok to me (i.e. with the 
minor changes I suggested).

Please let me know if you agree with my suggestions and I will make the 
changes and get this patch merged.

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>
> Adds API to generate AML code to invoke/call another
> method. Also provides ability to pass arguments of
> type integer, string, ArgObj or LocalObj.
>
> 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           | 112 +++++++++
>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>   2 files changed, 346 insertions(+), 1 deletion(-)
>
> diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> index eb8740692f..043ec3d842 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -101,6 +101,56 @@ typedef enum {
>     AmlAddressRangeMax      = 4
>   } AML_MEMORY_ATTRIBUTES_MTP;
>   
> +/** Method parameter types
> +
> +  Possible values are:
> +    0 - AmlMethodParamTypeInteger
> +    1 - AmlMethodParamTypeString
> +    2 - AmlMethodParamTypeArg
> +    3 - AmlMethodParamTypeLocal
> +
> +  @par Reference(s)
> +  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
> +
> +**/
> +typedef enum {
> +  AmlMethodParamTypeInteger = 0,
> +  AmlMethodParamTypeString  = 1,
> +  AmlMethodParamTypeArg     = 2,
> +  AmlMethodParamTypeLocal   = 3
> +} AML_METHOD_PARAM_TYPE;
> +
> +/** AML Method parameter data
> +  holds the AML method parameter data.
> +**/
> +typedef union {
> +  UINT8     Arg;
> +  UINT8     Local;
> +  UINT64    Integer;
> +  VOID      *Buffer;
> +} AML_METHOD_PARAM_DATA;
> +
> +/** structure to hold AML method parameter types
> +  Type  -   Type of parameter
> +  Data  -   holds data of parameter
> +            if Type is AmlMethodParamTypeInteger
> +              then Data is of type Integer to hold integer value.
> +            if Type is AmlMethodParamTypeString
> +              then Data contains null terminated string.
> +            If Type is AmlMethodParamTypeArg
> +              then Data contains the Argument number,
> +              0 to 6 are supported value.
> +            If Type is AmlMethodParamTypeLocal
> +              then Data contains the Local variable number,
> +              0 to 7 are supported value.
> +  DataSize - for future use
> +**/
> +typedef struct {
> +  AML_METHOD_PARAM_TYPE    Type;
> +  AML_METHOD_PARAM_DATA    Data;
> +  UINTN                    DataSize;
> +} AML_METHOD_PARAM;
> +
>   /** Parse the definition block.
>   
>     The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
> @@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage (
>     IN AML_OBJECT_NODE_HANDLE  NamedNode
>     );
>   
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation
> +  defined in the ACPI specification 6.5,
> +  section 20.2.5 "Term Objects Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  );
> +
>   #endif // AML_LIB_H_
> diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> index a6db34fb97..ddec9b67ed 100644
> --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> @@ -2,6 +2,7 @@
>     AML Code Generation.
>   
>     Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.<BR>
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.<BR>
>   
>     SPDX-License-Identifier: BSD-2-Clause-Patent
>   **/
> @@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString (
>     Status = AmlCreateDataNode (
>                EAmlNodeDataTypeRaw,
>                (CONST UINT8 *)String,
> -             StrSize (String),
> +             (UINT32)StrSize (String),

[SAMI] This does not seem to be related to this patch. Were you getting 
any issues when building? If so, can you submit a separate patch, please?

If you agree, I will drop the above line from this patch and merge.

[/SAMI]

>                &DataNode
>                );
>     if (EFI_ERROR (Status)) {
> @@ -3849,3 +3850,235 @@ exit_handler:
>   
>     return Status;
>   }
> +
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation
> +  defined in the ACPI specification 6.5,
> +  section 20.2.5 "Term Objects Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  )
> +{
> +  EFI_STATUS       Status;
> +  UINT8            Index;
> +  CHAR8            *AmlNameString;
> +  UINT32           AmlNameStringSize;
> +  AML_DATA_NODE    *DataNode;
> +  AML_OBJECT_NODE  *ObjectNode;
> +  AML_NODE_HANDLE  *NodeStream;
> +
> +  if ((MethodNameString == NULL) || (ParentNode == NULL)) {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if ((NumArgs > 7) ||
> +      ((Parameters == NULL) && (NumArgs > 0)))
> +  {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  /// Allocate space to store methodname, object, data node pointers
> +  NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs + 1));
> +  if (NodeStream == NULL) {
> +    ASSERT (0);
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  /// Create a called or invoked method name string.
> +  Status = ConvertAslNameToAmlName (MethodNameString, &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;
> +  }
> +
> +  DataNode = NULL;
> +  Status   = AmlCreateDataNode (
> +               EAmlNodeDataTypeNameString,
> +               (UINT8 *)AmlNameString,
> +               AmlNameStringSize,
> +               &DataNode
> +               );
> +  FreePool (AmlNameString);
> +  if (EFI_ERROR (Status)) {
> +    ASSERT_EFI_ERROR (Status);
> +    goto exit_handler;
> +  }
> +
> +  NodeStream[0] = (AML_NODE_HANDLE)DataNode;
> +
> +  if (Parameters != NULL) {
> +    /// Validate and convert the Parameters to the stream of nodes.
> +    for (Index = 0; Index < NumArgs; Index++) {
> +      switch (Parameters[Index].Type) {
> +        case AmlMethodParamTypeInteger:
> +          ObjectNode = NULL;
[SAMI] I think the above line can be moved right after the 'for' 
statement. If you agree I can fix this before merging.
> +          Status     = AmlCodeGenInteger (Parameters[Index].Data.Integer, &ObjectNode);
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
[SAMI] Minor, a space is required before and after '+'. I will fix that 
before merging.
> +          break;
> +        case AmlMethodParamTypeString:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Buffer == NULL) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCodeGenString (Parameters[Index].Data.Buffer, &ObjectNode);
[SAMI] Minor, I prefer to keep the code within 80 characters. I will fix 
that before merging.
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
[SAMI] I believe the above line can be moved after the switch block. I 
can do that if you agree.
> +          break;
> +        case AmlMethodParamTypeArg:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_ARG0 + Parameters[Index].Data.Arg, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        case AmlMethodParamTypeLocal:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_LOCAL0 + Parameters[Index].Data.Local, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        default:
> +          ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +          Status = EFI_INVALID_PARAMETER;
> +          goto exit_handler;
> +          break;
> +      }
> +    }
> +  }
> +
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    Status = AmlVarListAddTail (
> +               (AML_NODE_HANDLE)ParentNode,
> +                (AML_NODE_HANDLE)NodeStream[Index]
> +               );
> +    if (EFI_ERROR (Status)) {
> +      ASSERT_EFI_ERROR (Status);
> +      goto exit_handler_detach;
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +
> +exit_handler_detach:
> +  /// The index contains the last successful node attached.
> +  for ( ; Index > 0; Index--) {
> +    /// Index contains the node number that is failed for AmlVarListAddTail().
> +    /// Hence, start detaching from the last successful
> +    AmlDetachNode (NodeStream[Index-1]);
> +  }
> +
> +exit_handler:
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    if (NodeStream[Index] != 0) {
> +      AmlDeleteTree (NodeStream[Index]);
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +}


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112817): https://edk2.groups.io/g/devel/message/112817
Mute This Topic: https://groups.io/mt/103278521/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability
  2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
                   ` (3 preceding siblings ...)
  2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method Abdul Lateef Attar via groups.io
@ 2023-12-21 13:56 ` Sami Mujawar
       [not found] ` <17A2DD5CE37E2833.24485@groups.io>
  5 siblings, 0 replies; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 13:56 UTC (permalink / raw)
  To: Abdul Lateef Attar, devel; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

Hi Abdul,

Glad to see your contribution to the Dynamic Tables Framework. It would 
be great to hear how you are using this package.

I have some minor comments for the last patch 4/4. If you can reply 
back, I will try to get the changes merged before the end of this week.

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>
> PR: https://github.com/tianocore/edk2/pull/5171/
>
> V5: delta changes
>    Addressed review comments.
> V4:
>    Address Pierre's review comments.
>    Merged patch 4 & patch 5.
>    Also added parameter logic suggested by Pierre.
> V3: delta changes
>    CI fix and error handling for
>      DynamicTablesPkg: Adds API to generate a method with ArgN.
>    Added new patch "DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn"
> V2:
>    Added new API to generate a method which
>    invokes another method with argument.
> V1:
> Code changes to
> Add API to generate word I/O ranges.
> Correct the parameter to generate word bus number.
> Corrects the function pointer typedef
>
> 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 (4):
>    DynamicTablesPkg: AML Code generation for word I/O ranges
>    DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
>    DynamicTablesPkg: Corrects function pointer typedef of
>      AML_PARSE_FUNCTION
>    DynamicTablesPkg: AML Code generation to invoke a method
>
>   .../Include/Library/AmlLib/AmlLib.h           | 187 +++++++++++++-
>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>   .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++++++-
>   .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
>   4 files changed, 510 insertions(+), 13 deletions(-)
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112818): https://edk2.groups.io/g/devel/message/112818
Mute This Topic: https://groups.io/mt/103278517/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability
       [not found] ` <17A2DD5CE37E2833.24485@groups.io>
@ 2023-12-21 16:34   ` Sami Mujawar
  2023-12-22  3:59     ` Abdul Lateef Attar via groups.io
  0 siblings, 1 reply; 16+ messages in thread
From: Sami Mujawar @ 2023-12-21 16:34 UTC (permalink / raw)
  To: devel, Abdul Lateef Attar; +Cc: Abdul Lateef Attar, Pierre Gondois, nd@arm.com

Hi Abdul,

Can you check if the patch 4/4 at 
https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocation_v5 
looks ok to you,  please?

If you confim, I will apply the push label.

Regards,

Sami Mujawar

On 21/12/2023 01:56 pm, Sami Mujawar via groups.io wrote:
> Hi Abdul,
>
> Glad to see your contribution to the Dynamic Tables Framework. It 
> would be great to hear how you are using this package.
>
> I have some minor comments for the last patch 4/4. If you can reply 
> back, I will try to get the changes merged before the end of this week.
>
> Regards,
>
> Sami Mujawar
>
> On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
>> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>>
>> PR: https://github.com/tianocore/edk2/pull/5171/
>>
>> V5: delta changes
>>    Addressed review comments.
>> V4:
>>    Address Pierre's review comments.
>>    Merged patch 4 & patch 5.
>>    Also added parameter logic suggested by Pierre.
>> V3: delta changes
>>    CI fix and error handling for
>>      DynamicTablesPkg: Adds API to generate a method with ArgN.
>>    Added new patch "DynamicTablesPkg: Adds wrapper API 
>> AmlCodeGenMethodInvokeMethodArgn"
>> V2:
>>    Added new API to generate a method which
>>    invokes another method with argument.
>> V1:
>> Code changes to
>> Add API to generate word I/O ranges.
>> Correct the parameter to generate word bus number.
>> Corrects the function pointer typedef
>>
>> 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 (4):
>>    DynamicTablesPkg: AML Code generation for word I/O ranges
>>    DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
>>    DynamicTablesPkg: Corrects function pointer typedef of
>>      AML_PARSE_FUNCTION
>>    DynamicTablesPkg: AML Code generation to invoke a method
>>
>>   .../Include/Library/AmlLib/AmlLib.h           | 187 +++++++++++++-
>>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>>   .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++++++-
>>   .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
>>   4 files changed, 510 insertions(+), 13 deletions(-)
>>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112822): https://edk2.groups.io/g/devel/message/112822
Mute This Topic: https://groups.io/mt/103278517/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability
  2023-12-21 16:34   ` Sami Mujawar
@ 2023-12-22  3:59     ` Abdul Lateef Attar via groups.io
  2023-12-22  8:49       ` Sami Mujawar
  0 siblings, 1 reply; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-22  3:59 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io; +Cc: Pierre Gondois, nd@arm.com

[AMD Official Use Only - General]

Hi Sami,
        Below mentioned patch looks good; https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocatio .
Please go ahead and merge the patch series.
Thanks
AbduL

-----Original Message-----
From: Sami Mujawar <sami.mujawar@arm.com>
Sent: Thursday, December 21, 2023 10:04 PM
To: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>
Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Pierre Gondois <pierre.gondois@arm.com>; nd@arm.com
Subject: Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


Hi Abdul,

Can you check if the patch 4/4 at
https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocation_v5
looks ok to you,  please?

If you confim, I will apply the push label.

Regards,

Sami Mujawar

On 21/12/2023 01:56 pm, Sami Mujawar via groups.io wrote:
> Hi Abdul,
>
> Glad to see your contribution to the Dynamic Tables Framework. It
> would be great to hear how you are using this package.
>
> I have some minor comments for the last patch 4/4. If you can reply
> back, I will try to get the changes merged before the end of this week.
>
> Regards,
>
> Sami Mujawar
>
> On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
>> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>>
>> PR: https://github.com/tianocore/edk2/pull/5171/
>>
>> V5: delta changes
>>    Addressed review comments.
>> V4:
>>    Address Pierre's review comments.
>>    Merged patch 4 & patch 5.
>>    Also added parameter logic suggested by Pierre.
>> V3: delta changes
>>    CI fix and error handling for
>>      DynamicTablesPkg: Adds API to generate a method with ArgN.
>>    Added new patch "DynamicTablesPkg: Adds wrapper API
>> AmlCodeGenMethodInvokeMethodArgn"
>> V2:
>>    Added new API to generate a method which
>>    invokes another method with argument.
>> V1:
>> Code changes to
>> Add API to generate word I/O ranges.
>> Correct the parameter to generate word bus number.
>> Corrects the function pointer typedef
>>
>> 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 (4):
>>    DynamicTablesPkg: AML Code generation for word I/O ranges
>>    DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
>>    DynamicTablesPkg: Corrects function pointer typedef of
>>      AML_PARSE_FUNCTION
>>    DynamicTablesPkg: AML Code generation to invoke a method
>>
>>   .../Include/Library/AmlLib/AmlLib.h           | 187 +++++++++++++-
>>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>>   .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++++++-
>>   .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
>>   4 files changed, 510 insertions(+), 13 deletions(-)
>>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112833): https://edk2.groups.io/g/devel/message/112833
Mute This Topic: https://groups.io/mt/103278517/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method
  2023-12-21 13:55   ` Sami Mujawar
@ 2023-12-22  4:10     ` Abdul Lateef Attar via groups.io
  0 siblings, 0 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-22  4:10 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io; +Cc: Pierre Gondois, nd@arm.com

[AMD Official Use Only - General]

Hi Sami,
        Thanks for the in-depth review and making the changes.
Regarding below comment.
[SAMI] This does not seem to be related to this patch. Were you getting any issues when building? If so, can you submit a separate patch, please?

If you agree, I will drop the above line from this patch and merge.

[/SAMI]

[Abdul] With VS2019 I am seeing compilation error, I'll submit a separate patch for this.

Thanks
AbduL


-----Original Message-----
From: Sami Mujawar <sami.mujawar@arm.com>
Sent: Thursday, December 21, 2023 7:26 PM
To: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; devel@edk2.groups.io
Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Pierre Gondois <pierre.gondois@arm.com>; nd@arm.com
Subject: Re: [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


Hi Abdul,

I have some minor feedback maked inline as [SAMI].

I think other than the typecast change for the value returned by StrSize(), the remainder of the patch looks ok to me (i.e. with the minor changes I suggested).

Please let me know if you agree with my suggestions and I will make the changes and get this patch merged.

Regards,

Sami Mujawar

On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
>
> Adds API to generate AML code to invoke/call another method. Also
> provides ability to pass arguments of type integer, string, ArgObj or
> LocalObj.
>
> 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           | 112 +++++++++
>   .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 235 +++++++++++++++++-
>   2 files changed, 346 insertions(+), 1 deletion(-)
>
> diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> index eb8740692f..043ec3d842 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -101,6 +101,56 @@ typedef enum {
>     AmlAddressRangeMax      = 4
>   } AML_MEMORY_ATTRIBUTES_MTP;
>
> +/** Method parameter types
> +
> +  Possible values are:
> +    0 - AmlMethodParamTypeInteger
> +    1 - AmlMethodParamTypeString
> +    2 - AmlMethodParamTypeArg
> +    3 - AmlMethodParamTypeLocal
> +
> +  @par Reference(s)
> +  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
> +
> +**/
> +typedef enum {
> +  AmlMethodParamTypeInteger = 0,
> +  AmlMethodParamTypeString  = 1,
> +  AmlMethodParamTypeArg     = 2,
> +  AmlMethodParamTypeLocal   = 3
> +} AML_METHOD_PARAM_TYPE;
> +
> +/** AML Method parameter data
> +  holds the AML method parameter data.
> +**/
> +typedef union {
> +  UINT8     Arg;
> +  UINT8     Local;
> +  UINT64    Integer;
> +  VOID      *Buffer;
> +} AML_METHOD_PARAM_DATA;
> +
> +/** structure to hold AML method parameter types
> +  Type  -   Type of parameter
> +  Data  -   holds data of parameter
> +            if Type is AmlMethodParamTypeInteger
> +              then Data is of type Integer to hold integer value.
> +            if Type is AmlMethodParamTypeString
> +              then Data contains null terminated string.
> +            If Type is AmlMethodParamTypeArg
> +              then Data contains the Argument number,
> +              0 to 6 are supported value.
> +            If Type is AmlMethodParamTypeLocal
> +              then Data contains the Local variable number,
> +              0 to 7 are supported value.
> +  DataSize - for future use
> +**/
> +typedef struct {
> +  AML_METHOD_PARAM_TYPE    Type;
> +  AML_METHOD_PARAM_DATA    Data;
> +  UINTN                    DataSize;
> +} AML_METHOD_PARAM;
> +
>   /** Parse the definition block.
>
>     The function parses the whole AML blob. It starts with the ACPI
> DSDT/SSDT @@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage (
>     IN AML_OBJECT_NODE_HANDLE  NamedNode
>     );
>
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation  defined
> + in the ACPI specification 6.5,  section 20.2.5 "Term Objects
> + Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  );
> +
>   #endif // AML_LIB_H_
> diff --git
> a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> index a6db34fb97..ddec9b67ed 100644
> --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> @@ -2,6 +2,7 @@
>     AML Code Generation.
>
>     Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.<BR>
> +  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights
> + reserved.<BR>
>
>     SPDX-License-Identifier: BSD-2-Clause-Patent
>   **/
> @@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString (
>     Status = AmlCreateDataNode (
>                EAmlNodeDataTypeRaw,
>                (CONST UINT8 *)String,
> -             StrSize (String),
> +             (UINT32)StrSize (String),

[SAMI] This does not seem to be related to this patch. Were you getting any issues when building? If so, can you submit a separate patch, please?

If you agree, I will drop the above line from this patch and merge.

[/SAMI]

>                &DataNode
>                );
>     if (EFI_ERROR (Status)) {
> @@ -3849,3 +3850,235 @@ exit_handler:
>
>     return Status;
>   }
> +
> +/** AML code generation to invoke/call another method.
> +
> +  This method is a subset implementation of MethodInvocation  defined
> + in the ACPI specification 6.5,  section 20.2.5 "Term Objects
> + Encoding".
> +  Added integer, string, ArgObj and LocalObj support.
> +
> +  Example 1:
> +    AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
> +    is equivalent to the following ASL code:
> +      MET0 ();
> +
> +  Example 2:
> +    AML_METHOD_PARAM  Param[4];
> +    Param[0].Data.Integer = 0x100;
> +    Param[0].Type = AmlMethodParamTypeInteger;
> +    Param[1].Data.Buffer = "TEST";
> +    Param[1].Type = AmlMethodParamTypeString;
> +    Param[2].Data.Arg = 0;
> +    Param[2].Type = AmlMethodParamTypeArg;
> +    Param[3].Data.Local = 2;
> +    Param[3].Type = AmlMethodParamTypeLocal;
> +    AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
> +
> +    is equivalent to the following ASL code:
> +      MET0 (0x100, "TEST", Arg0, Local2);
> +
> +  Example 3:
> +    AML_METHOD_PARAM  Param[2];
> +    Param[0].Data.Arg = 0;
> +    Param[0].Type = AmlMethodParamTypeArg;
> +    Param[1].Data.Integer = 0x100;
> +    Param[1].Type = AmlMethodParamTypeInteger;
> +    AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode);
> +    AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
> +
> +    is equivalent to the following ASL code:
> +    Method (MET2, 2, Serialized)
> +    {
> +      MET3 (Arg0, 0x0100)
> +    }
> +
> +  @param [in] MethodNameString  The method name to be called or invoked.
> +  @param [in] NumArgs           Number of arguments to be passed,
> +                                0 to 7 are permissible values.
> +  @param [in] Parameters        Contains the parameter data.
> +  @param [in] ParentNode        The parent node to which the method invocation
> +                                nodes are attached.
> +
> +  @retval EFI_SUCCESS             Success.
> +  @retval EFI_INVALID_PARAMETER   Invalid parameter.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate memory.
> + **/
> +EFI_STATUS
> +EFIAPI
> +AmlCodeGenInvokeMethod (
> +  IN  CONST CHAR8             *MethodNameString,
> +  IN        UINT8             NumArgs,
> +  IN        AML_METHOD_PARAM  *Parameters   OPTIONAL,
> +  IN        AML_NODE_HANDLE   ParentNode
> +  )
> +{
> +  EFI_STATUS       Status;
> +  UINT8            Index;
> +  CHAR8            *AmlNameString;
> +  UINT32           AmlNameStringSize;
> +  AML_DATA_NODE    *DataNode;
> +  AML_OBJECT_NODE  *ObjectNode;
> +  AML_NODE_HANDLE  *NodeStream;
> +
> +  if ((MethodNameString == NULL) || (ParentNode == NULL)) {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  if ((NumArgs > 7) ||
> +      ((Parameters == NULL) && (NumArgs > 0)))  {
> +    ASSERT (0);
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  /// Allocate space to store methodname, object, data node pointers
> + NodeStream = AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs +
> + 1));  if (NodeStream == NULL) {
> +    ASSERT (0);
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  /// Create a called or invoked method name string.
> +  Status = ConvertAslNameToAmlName (MethodNameString,
> + &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;
> +  }
> +
> +  DataNode = NULL;
> +  Status   = AmlCreateDataNode (
> +               EAmlNodeDataTypeNameString,
> +               (UINT8 *)AmlNameString,
> +               AmlNameStringSize,
> +               &DataNode
> +               );
> +  FreePool (AmlNameString);
> +  if (EFI_ERROR (Status)) {
> +    ASSERT_EFI_ERROR (Status);
> +    goto exit_handler;
> +  }
> +
> +  NodeStream[0] = (AML_NODE_HANDLE)DataNode;
> +
> +  if (Parameters != NULL) {
> +    /// Validate and convert the Parameters to the stream of nodes.
> +    for (Index = 0; Index < NumArgs; Index++) {
> +      switch (Parameters[Index].Type) {
> +        case AmlMethodParamTypeInteger:
> +          ObjectNode = NULL;
[SAMI] I think the above line can be moved right after the 'for'
statement. If you agree I can fix this before merging.
> +          Status     = AmlCodeGenInteger (Parameters[Index].Data.Integer, &ObjectNode);
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
[SAMI] Minor, a space is required before and after '+'. I will fix that before merging.
> +          break;
> +        case AmlMethodParamTypeString:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Buffer == NULL) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCodeGenString (Parameters[Index].Data.Buffer,
> + &ObjectNode);
[SAMI] Minor, I prefer to keep the code within 80 characters. I will fix that before merging.
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
[SAMI] I believe the above line can be moved after the switch block. I can do that if you agree.
> +          break;
> +        case AmlMethodParamTypeArg:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_ARG0 + Parameters[Index].Data.Arg, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        case AmlMethodParamTypeLocal:
> +          ObjectNode = NULL;
> +          if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LOCAL0)) {
> +            ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +            Status = EFI_INVALID_PARAMETER;
> +            goto exit_handler;
> +          }
> +
> +          Status = AmlCreateObjectNode (
> +                     AmlGetByteEncodingByOpCode (AML_LOCAL0 + Parameters[Index].Data.Local, 0),
> +                     0,
> +                     &ObjectNode
> +                     );
> +          if (EFI_ERROR (Status)) {
> +            ASSERT_EFI_ERROR (Status);
> +            goto exit_handler;
> +          }
> +
> +          NodeStream[Index+1] = (AML_NODE_HANDLE)ObjectNode;
> +          break;
> +        default:
> +          ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER);
> +          Status = EFI_INVALID_PARAMETER;
> +          goto exit_handler;
> +          break;
> +      }
> +    }
> +  }
> +
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    Status = AmlVarListAddTail (
> +               (AML_NODE_HANDLE)ParentNode,
> +                (AML_NODE_HANDLE)NodeStream[Index]
> +               );
> +    if (EFI_ERROR (Status)) {
> +      ASSERT_EFI_ERROR (Status);
> +      goto exit_handler_detach;
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +
> +exit_handler_detach:
> +  /// The index contains the last successful node attached.
> +  for ( ; Index > 0; Index--) {
> +    /// Index contains the node number that is failed for AmlVarListAddTail().
> +    /// Hence, start detaching from the last successful
> +    AmlDetachNode (NodeStream[Index-1]);
> +  }
> +
> +exit_handler:
> +  /// Index <= NumArgs, because an additional method name was added.
> +  for (Index = 0; Index <= NumArgs; Index++) {
> +    if (NodeStream[Index] != 0) {
> +      AmlDeleteTree (NodeStream[Index]);
> +    }
> +  }
> +
> +  FreePool (NodeStream);
> +  return Status;
> +}


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112834): https://edk2.groups.io/g/devel/message/112834
Mute This Topic: https://groups.io/mt/103278521/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION
  2023-12-21 13:54   ` Sami Mujawar
@ 2023-12-22  4:16     ` Abdul Lateef Attar via groups.io
  0 siblings, 0 replies; 16+ messages in thread
From: Abdul Lateef Attar via groups.io @ 2023-12-22  4:16 UTC (permalink / raw)
  To: Sami Mujawar, devel@edk2.groups.io; +Cc: Pierre Gondois, nd@arm.com

[-- Attachment #1: Type: text/plain, Size: 3083 bytes --]

[AMD Official Use Only - General]

Hi Sami,
                Currently we are using the AML library and evaluating the Dynamic Tables Framework.
Soon we will be publishing(upstreaming) the usage of AML library under the edk2-platforms/Platform/AMD/AmdPlatformPkg.

Thanks
AbduL

From: Sami Mujawar <sami.mujawar@arm.com>
Sent: Thursday, December 21, 2023 7:24 PM
To: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; devel@edk2.groups.io
Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com>; Pierre Gondois <pierre.gondois@arm.com>; nd@arm.com
Subject: Re: [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.


Hi Abdul,

Thank you for this fix.

For Arm EFIAPI evaluates to nothing, hence we could not catch such issues.

Do you use the rest of the Dynamic Tables Framework? I guess we have not included the calling convention at other places e.g. https://github.com/tianocore/edk2/blob/master/DynamicTablesPkg/Include/AcpiTableGenerator.h#L217

Maybe we need to find and fix those issues as well.

In either case, this patch looks good to me.

Reviewed-by: Sami Mujawar

<sami.mujawar@arm.com><mailto:sami.mujawar@arm.com>

Regards,

Sami Mujawar


On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:

From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto: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><mailto:pierre.gondois@arm.com>

Cc: Sami Mujawar <sami.mujawar@arm.com><mailto:sami.mujawar@arm.com>

Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com><mailto:AbdulLateef.Attar@amd.com>

Reviewed-by: Pierre Gondois <pierre.gondois@arm.com><mailto: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,


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112835): https://edk2.groups.io/g/devel/message/112835
Mute This Topic: https://groups.io/mt/103278520/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: 8648 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability
  2023-12-22  3:59     ` Abdul Lateef Attar via groups.io
@ 2023-12-22  8:49       ` Sami Mujawar
  0 siblings, 0 replies; 16+ messages in thread
From: Sami Mujawar @ 2023-12-22  8:49 UTC (permalink / raw)
  To: Attar, AbdulLateef (Abdul Lateef), devel@edk2.groups.io
  Cc: Pierre Gondois, nd

Series merged as 5d533bbc2773..d01defe06b35

Thanks.

Regards,

Sami Mujawar

On 22/12/2023, 03:59, "Attar, AbdulLateef (Abdul Lateef)" <AbdulLateef.Attar@amd.com <mailto:AbdulLateef.Attar@amd.com>> wrote:


[AMD Official Use Only - General]


Hi Sami,
Below mentioned patch looks good; https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocatio <https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocatio> .
Please go ahead and merge the patch series.
Thanks
AbduL


-----Original Message-----
From: Sami Mujawar <sami.mujawar@arm.com <mailto:sami.mujawar@arm.com>>
Sent: Thursday, December 21, 2023 10:04 PM
To: devel@edk2.groups.io <mailto:devel@edk2.groups.io>; Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com <mailto:AbdulLateef.Attar@amd.com>>
Cc: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@amd.com <mailto:AbdulLateef.Attar@amd.com>>; Pierre Gondois <pierre.gondois@arm.com <mailto:pierre.gondois@arm.com>>; nd@arm.com <mailto:nd@arm.com>
Subject: Re: [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability


Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.




Hi Abdul,


Can you check if the patch 4/4 at
https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocation_v5 <https://github.com/samimujawar/edk2/tree/REVIEW_2923_dynamictables_word_io_method_invocation_v5>
looks ok to you, please?


If you confim, I will apply the push label.


Regards,


Sami Mujawar


On 21/12/2023 01:56 pm, Sami Mujawar via groups.io wrote:
> Hi Abdul,
>
> Glad to see your contribution to the Dynamic Tables Framework. It
> would be great to hear how you are using this package.
>
> I have some minor comments for the last patch 4/4. If you can reply
> back, I will try to get the changes merged before the end of this week.
>
> Regards,
>
> Sami Mujawar
>
> On 20/12/2023 09:38 am, Abdul Lateef Attar wrote:
>> From: Abdul Lateef Attar <AbdulLateef.Attar@amd.com <mailto:AbdulLateef.Attar@amd.com>>
>>
>> PR: https://github.com/tianocore/edk2/pull/5171/ <https://github.com/tianocore/edk2/pull/5171/>
>>
>> V5: delta changes
>> Addressed review comments.
>> V4:
>> Address Pierre's review comments.
>> Merged patch 4 & patch 5.
>> Also added parameter logic suggested by Pierre.
>> V3: delta changes
>> CI fix and error handling for
>> DynamicTablesPkg: Adds API to generate a method with ArgN.
>> Added new patch "DynamicTablesPkg: Adds wrapper API
>> AmlCodeGenMethodInvokeMethodArgn"
>> V2:
>> Added new API to generate a method which
>> invokes another method with argument.
>> V1:
>> Code changes to
>> Add API to generate word I/O ranges.
>> Correct the parameter to generate word bus number.
>> Corrects the function pointer typedef
>>
>> Cc: Pierre Gondois <pierre.gondois@arm.com <mailto:pierre.gondois@arm.com>>
>> Cc: Sami Mujawar <sami.mujawar@arm.com <mailto:sami.mujawar@arm.com>>
>> Cc: Abdul Lateef Attar <AbdulLateef.Attar@amd.com <mailto:AbdulLateef.Attar@amd.com>>
>>
>> Abdul Lateef Attar (4):
>> DynamicTablesPkg: AML Code generation for word I/O ranges
>> DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
>> DynamicTablesPkg: Corrects function pointer typedef of
>> AML_PARSE_FUNCTION
>> DynamicTablesPkg: AML Code generation to invoke a method
>>
>> .../Include/Library/AmlLib/AmlLib.h | 187 +++++++++++++-
>> .../Common/AmlLib/CodeGen/AmlCodeGen.c | 235 +++++++++++++++++-
>> .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 98 +++++++-
>> .../Library/Common/AmlLib/Parser/AmlParser.c | 3 +-
>> 4 files changed, 510 insertions(+), 13 deletions(-)
>>
>
>
> 
>
>





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112842): https://edk2.groups.io/g/devel/message/112842
Mute This Topic: https://groups.io/mt/103278517/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-12-22  8:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-20  9:38 [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Abdul Lateef Attar via groups.io
2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges Abdul Lateef Attar via groups.io
2023-12-21 13:53   ` Sami Mujawar
2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters Abdul Lateef Attar via groups.io
2023-12-21 13:53   ` Sami Mujawar
2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION Abdul Lateef Attar via groups.io
2023-12-21 13:54   ` Sami Mujawar
2023-12-22  4:16     ` Abdul Lateef Attar via groups.io
2023-12-20  9:38 ` [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method Abdul Lateef Attar via groups.io
2023-12-20 10:19   ` PierreGondois
2023-12-21 13:55   ` Sami Mujawar
2023-12-22  4:10     ` Abdul Lateef Attar via groups.io
2023-12-21 13:56 ` [edk2-devel] [Resend PATCH v5 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability Sami Mujawar
     [not found] ` <17A2DD5CE37E2833.24485@groups.io>
2023-12-21 16:34   ` Sami Mujawar
2023-12-22  3:59     ` Abdul Lateef Attar via groups.io
2023-12-22  8:49       ` Sami Mujawar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox