[edk2-devel] [PATCH v1 1/7] DynamicTablesPkg: AML Code generation for memory ranges

PierreGondois pierre.gondois at arm.com
Wed Jun 23 11:58:28 UTC 2021


From: Pierre Gondois <Pierre.Gondois at arm.com>

Add helper functions to generate AML Resource Data describing memory
ranges. Memory ranges can be one, double or four words long. They
can be of 'normal', IO or bus number memory type. The following
APIs are exposed:
 - AmlCodeGenRdDWordIo ()
 - AmlCodeGenRdDWordMemory ()
 - AmlCodeGenRdWordBusNumber ()
 - AmlCodeGenRdQWordMemory ()

Signed-off-by: Pierre Gondois <Pierre.Gondois at arm.com>
---
 .../Include/Library/AmlLib/AmlLib.h           | 289 ++++++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 945 ++++++++++++++++++
 2 files changed, 1234 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 4932f6fd9c8b..cbbbb7a478f7 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -418,6 +418,295 @@ AmlUpdateRdQWord (
   IN  UINT64                BaseAddressLength
   );
 
+/** Code generation for the "DWordIO ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.2 "DWord Address Space Descriptor".
+   - s19.6.34 "DWordIO".
+
+  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.
+
+  @ingroup CodeGenApis
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsaRanges            Available values are:
+                                     0-Reserved
+                                     1-NonISAOnly
+                                     2-ISAOnly
+                                     3-EntireRange
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.34 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.34 for more.
+                                    Not supported.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @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
+AmlCodeGenRdDWordIo (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        UINT8                   IsaRanges,
+  IN        UINT32                  AddressGranularity,
+  IN        UINT32                  AddressMinimum,
+  IN        UINT32                  AddressMaximum,
+  IN        UINT32                  AddressTranslation,
+  IN        UINT32                  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 "DWordMemory ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.2 "DWord Address Space Descriptor".
+   - s19.6.35 "DWordMemory".
+
+  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.
+
+  @ingroup CodeGenApis
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  Cacheable            Available values are:
+                                    0-The memory is non-cacheable
+                                    1-The memory is cacheable
+                                    2-The memory is cacheable and supports
+                                      write combining
+                                    3-The memory is cacheable and prefetchable
+  @param [in]  IsReadWrite          ReadAndWrite parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.35 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.35 for more.
+                                    Not supported.
+  @param [in]  MemoryRangeType      Available values are:
+                                      0-AddressRangeMemory
+                                      1-AddressRangeReserved
+                                      2-AddressRangeACPI
+                                      3-AddressRangeNVS
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @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
+AmlCodeGenRdDWordMemory (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   Cacheable,
+  IN        BOOLEAN                 IsReadWrite,
+  IN        UINT32                  AddressGranularity,
+  IN        UINT32                  AddressMinimum,
+  IN        UINT32                  AddressMaximum,
+  IN        UINT32                  AddressTranslation,
+  IN        UINT32                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        UINT8                   MemoryRangeType,
+  IN        BOOLEAN                 IsTypeStatic,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  );
+
+/** Code generation for the "WordBusNumber ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+   - s19.6.149 "WordBusNumber".
+
+  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.
+
+  @ingroup CodeGenApis
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.149 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.149 for more.
+                                    Not supported.
+  @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
+AmlCodeGenRdWordBusNumber (
+  IN        BOOLEAN                 IsResourceConsumer,
+  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        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  );
+
+/** Code generation for the "QWordMemory ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.110 "QWordMemory".
+
+  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.
+
+  @ingroup CodeGenApis
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  Cacheable            Available values are:
+                                    0-The memory is non-cacheable
+                                    1-The memory is cacheable
+                                    2-The memory is cacheable and supports
+                                      write combining
+                                    3-The memory is cacheable and prefetchable
+  @param [in]  IsReadWrite          ReadAndWrite parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.110 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.110 for more.
+                                    Not supported.
+  @param [in]  MemoryRangeType      Available values are:
+                                      0-AddressRangeMemory
+                                      1-AddressRangeReserved
+                                      2-AddressRangeACPI
+                                      3-AddressRangeNVS
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @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
+AmlCodeGenRdQWordMemory (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   Cacheable,
+  IN        BOOLEAN                 IsReadWrite,
+  IN        UINT64                  AddressGranularity,
+  IN        UINT64                  AddressMinimum,
+  IN        UINT64                  AddressMaximum,
+  IN        UINT64                  AddressTranslation,
+  IN        UINT64                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        UINT8                   MemoryRangeType,
+  IN        BOOLEAN                 IsTypeStatic,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "Interrupt ()" ASL function.
 
   The Resource Data effectively created is an Extended Interrupt Resource
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 78910cc5d4b4..3ab78d4fce22 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -94,6 +94,951 @@ error_handler:
   return Status;
 }
 
+/** Populate the TypeSpecificFlags field for IO ranges.
+
+  @param [in]  IsaRanges            Available values are:
+                                     0-Reserved
+                                     1-NonISAOnly
+                                     2-ISAOnly
+                                     3-EntireRange
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+
+  @return A TypeSpecificFlagsvalue.
+          MAX_UINT8 if error.
+**/
+STATIC
+UINT8
+EFIAPI
+RdIoRangeSpecificFlags (
+  IN  UINT8     IsaRanges,
+  IN  BOOLEAN   IsDenseTranslation,
+  IN  BOOLEAN   IsTypeStatic
+  )
+{
+  // Only check type specific parameters.
+  if (IsaRanges > 3) {
+    ASSERT (0);
+    return MAX_UINT8;
+  }
+
+  // Populate TypeSpecificFlags and call the generic function.
+  // Cf ACPI 6.4 specification, Table 6.50:
+  // "Table 6.50: I/O Resource Flag (Resource Type = 1) Definitions"
+  return  IsaRanges                 |
+          (IsTypeStatic ? 0 : BIT4) |
+          (IsDenseTranslation ? 0 : BIT5);
+}
+
+/** Populate the TypeSpecificFlags field for Memory ranges.
+
+  @param [in]  Cacheable            Available values are:
+                                    0-The memory is non-cacheable
+                                    1-The memory is cacheable
+                                    2-The memory is cacheable and supports
+                                      write combining
+                                    3-The memory is cacheable and prefetchable
+  @param [in]  IsReadWrite          ReadAndWrite parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  MemoryRangeType      Available values are:
+                                      0-AddressRangeMemory
+                                      1-AddressRangeReserved
+                                      2-AddressRangeACPI
+                                      3-AddressRangeNVS
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+
+  @return A TypeSpecificFlagsvalue.
+          MAX_UINT8 if error.
+**/
+STATIC
+UINT8
+EFIAPI
+MemoryRangeSpecificFlags (
+  IN  UINT8     Cacheable,
+  IN  BOOLEAN   IsReadWrite,
+  IN  UINT8     MemoryRangeType,
+  IN  BOOLEAN   IsTypeStatic
+  )
+{
+  // Only check type specific parameters.
+  if ((Cacheable > 3) ||
+      (MemoryRangeType > 3)) {
+    ASSERT (0);
+    return MAX_UINT8;
+  }
+
+  // Populate TypeSpecificFlags and call the generic function.
+  // Cf ACPI 6.4 specification, Table 6.49:
+  // "Memory Resource Flag (Resource Type = 0) Definitions"
+  return (IsReadWrite ? BIT0 : 0)  |
+         (Cacheable << 1)          |
+         (MemoryRangeType << 3)    |
+         (IsTypeStatic ? 0 : BIT5);
+}
+
+/** Populate the GeneralFlags field of any Address Space Resource Descriptors.
+
+  E.g.:
+  ACPI 6.4 specification, s6.4.3.5.1 "QWord Address Space Descriptor"
+  for QWord
+
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.36 for more.
+
+  @return A TypeSpecificFlagsvalue.
+**/
+STATIC
+UINT8
+EFIAPI
+AddressSpaceGeneralFlags (
+  IN  BOOLEAN   IsPosDecode,
+  IN  BOOLEAN   IsMinFixed,
+  IN  BOOLEAN   IsMaxFixed
+  )
+{
+  return (IsPosDecode ? 0 : BIT1)    |
+         (IsMinFixed ? BIT2 : 0)     |
+         (IsMaxFixed ? BIT3 : 0);
+}
+
+/** Check Address Space Descriptor Fields.
+
+  Cf. ACPI 6.4 Table 6.44:
+  "Valid Combination of Address Space Descriptor Fields"
+
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.36 for more.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+CheckAddressSpaceFields (
+  IN  BOOLEAN   IsMinFixed,
+  IN  BOOLEAN   IsMaxFixed,
+  IN  UINT64    AddressGranularity,
+  IN  UINT64    AddressMinimum,
+  IN  UINT64    AddressMaximum,
+  IN  UINT64    AddressTranslation,
+  IN  UINT64    RangeLength
+  )
+{
+  if ((AddressMinimum > AddressMaximum)                     ||
+      (RangeLength > (AddressMaximum - AddressMinimum + 1)) ||
+      ((AddressGranularity != 0) &&
+       ((AddressGranularity + 1) & AddressGranularity) != 0)) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if (RangeLength != 0) {
+    if (IsMinFixed ^ IsMaxFixed) {
+      ASSERT (0);
+      return EFI_INVALID_PARAMETER;
+    } else if (IsMinFixed                 &&
+               IsMaxFixed                 &&
+               (AddressGranularity != 0)  &&
+               ((AddressMaximum - AddressMinimum + 1) != RangeLength)) {
+      ASSERT (0);
+      return EFI_INVALID_PARAMETER;
+    }
+  } else {
+    if (IsMinFixed && IsMaxFixed) {
+      ASSERT (0);
+      return EFI_INVALID_PARAMETER;
+    } else if (IsMinFixed &&
+              ((AddressMinimum & AddressGranularity) != 0)) {
+      ASSERT (0);
+      return EFI_INVALID_PARAMETER;
+    } else if (IsMaxFixed &&
+              (((AddressMaximum + 1) & AddressGranularity) != 0)) {
+      ASSERT (0);
+      return EFI_INVALID_PARAMETER;
+    }
+  }
+
+  return EFI_SUCCESS;
+}
+
+/** Code generation for the "DWordSpace ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.2 "DWord Address Space Descriptor".
+   - s19.6.36 "DWordSpace".
+
+  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]  ResourceType         See ACPI 6.4 spec, s6.4.3.5.2 for more.
+                                    Available values are:
+                                      0:        Memory range
+                                      1:        I/O range
+                                      2:        Bus number range
+                                      3-191:    Reserved
+                                      192-255:  Hardware Vendor Defined
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  TypeSpecificFlags    See ACPI 6.4 spec, s6.4.3.5.5
+                                    "Resource Type Specific Flags".
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.36 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.36 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.36 for more.
+                                    Not supported.
+  @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.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdDWordSpace (
+  IN        UINT8                   ResourceType,
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   TypeSpecificFlags,
+  IN        UINT32                  AddressGranularity,
+  IN        UINT32                  AddressMinimum,
+  IN        UINT32                  AddressMaximum,
+  IN        UINT32                  AddressTranslation,
+  IN        UINT32                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  EFI_STATUS                                Status;
+  AML_DATA_NODE                           * RdNode;
+  EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR   RdDWord;
+
+  // ResourceSource and ResourceSourceIndex are not supported.
+  if ((TypeSpecificFlags == MAX_UINT8)  ||
+      (ResourceSourceIndex != 0)        ||
+      (ResourceSource != NULL)          ||
+      ((NameOpNode == NULL) && (NewRdNode == NULL))) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = CheckAddressSpaceFields (
+             IsMinFixed,
+             IsMaxFixed,
+             AddressGranularity,
+             AddressMinimum,
+             AddressMaximum,
+             AddressTranslation,
+             RangeLength
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  // Header
+  RdDWord.Header.Header.Bits.Name =
+    ACPI_LARGE_DWORD_ADDRESS_SPACE_DESCRIPTOR_NAME;
+  RdDWord.Header.Header.Bits.Type = ACPI_LARGE_ITEM_FLAG;
+  RdDWord.Header.Length = sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR) -
+                               sizeof (ACPI_LARGE_RESOURCE_HEADER);
+
+  // Body
+  RdDWord.ResType = ResourceType;
+  RdDWord.GenFlag = AddressSpaceGeneralFlags (
+                      IsPosDecode,
+                      IsMinFixed,
+                      IsMaxFixed
+                      );
+  RdDWord.SpecificFlag = TypeSpecificFlags;
+  RdDWord.AddrSpaceGranularity = AddressGranularity;
+  RdDWord.AddrRangeMin = AddressMinimum;
+  RdDWord.AddrRangeMax = AddressMaximum;
+  RdDWord.AddrTranslationOffset = AddressTranslation;
+  RdDWord.AddrLen = RangeLength;
+
+  Status = AmlCreateDataNode (
+             EAmlNodeDataTypeResourceData,
+             (UINT8*)&RdDWord,
+             sizeof (EFI_ACPI_DWORD_ADDRESS_SPACE_DESCRIPTOR),
+             &RdNode
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  return LinkRdNode (RdNode, NameOpNode, NewRdNode);
+}
+
+/** Code generation for the "DWordIO ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.2 "DWord Address Space Descriptor".
+   - s19.6.34 "DWordIO".
+
+  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,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsaRanges            Available values are:
+                                     0-Reserved
+                                     1-NonISAOnly
+                                     2-ISAOnly
+                                     3-EntireRange
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.34 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.34 for more.
+                                    Not supported.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.34 for more.
+  @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
+AmlCodeGenRdDWordIo (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        UINT8                   IsaRanges,
+  IN        UINT32                  AddressGranularity,
+  IN        UINT32                  AddressMinimum,
+  IN        UINT32                  AddressMaximum,
+  IN        UINT32                  AddressTranslation,
+  IN        UINT32                  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 AmlCodeGenRdDWordSpace (
+           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 "DWordMemory ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.2 "DWord Address Space Descriptor".
+   - s19.6.35 "DWordMemory".
+
+  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,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  Cacheable            Available values are:
+                                    0-The memory is non-cacheable
+                                    1-The memory is cacheable
+                                    2-The memory is cacheable and supports
+                                      write combining
+                                    3-The memory is cacheable and prefetchable
+  @param [in]  IsReadWrite          ReadAndWrite parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.35 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.35 for more.
+                                    Not supported.
+  @param [in]  MemoryRangeType      Available values are:
+                                      0-AddressRangeMemory
+                                      1-AddressRangeReserved
+                                      2-AddressRangeACPI
+                                      3-AddressRangeNVS
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.35 for more.
+  @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
+AmlCodeGenRdDWordMemory (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   Cacheable,
+  IN        BOOLEAN                 IsReadWrite,
+  IN        UINT32                  AddressGranularity,
+  IN        UINT32                  AddressMinimum,
+  IN        UINT32                  AddressMaximum,
+  IN        UINT32                  AddressTranslation,
+  IN        UINT32                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        UINT8                   MemoryRangeType,
+  IN        BOOLEAN                 IsTypeStatic,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  return AmlCodeGenRdDWordSpace (
+           ACPI_ADDRESS_SPACE_TYPE_MEM,
+           IsResourceConsumer,
+           IsPosDecode,
+           IsMinFixed,
+           IsMaxFixed,
+           MemoryRangeSpecificFlags (
+             Cacheable,
+             IsReadWrite,
+             MemoryRangeType,
+             IsTypeStatic
+             ),
+           AddressGranularity,
+           AddressMinimum,
+           AddressMaximum,
+           AddressTranslation,
+           RangeLength,
+           ResourceSourceIndex,
+           ResourceSource,
+           NameOpNode,
+           NewRdNode
+           );
+}
+
+/** Code generation for the "WordSpace ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+   - s19.6.151 "WordSpace".
+
+  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]  ResourceType         See ACPI 6.4 spec, s6.4.3.5.3 for more.
+                                    Available values are:
+                                      0:        Memory range
+                                      1:        I/O range
+                                      2:        Bus number range
+                                      3-191:    Reserved
+                                      192-255:  Hardware Vendor Defined
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  TypeSpecificFlags    See ACPI 6.4 spec, s6.4.3.5.5
+                                    "Resource Type Specific Flags".
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.151 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.151 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.151 for more.
+                                    Not supported.
+  @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.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdWordSpace (
+  IN        UINT8                   ResourceType,
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   TypeSpecificFlags,
+  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
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  EFI_STATUS                                Status;
+  AML_DATA_NODE                           * RdNode;
+  EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR    Rdword;
+
+  // ResourceSource and ResourceSourceIndex are not supported.
+  if ((TypeSpecificFlags == MAX_UINT8)  ||
+      (ResourceSourceIndex != 0)        ||
+      (ResourceSource != NULL)          ||
+      ((NameOpNode == NULL) && (NewRdNode == NULL))) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = CheckAddressSpaceFields (
+             IsMinFixed,
+             IsMaxFixed,
+             AddressGranularity,
+             AddressMinimum,
+             AddressMaximum,
+             AddressTranslation,
+             RangeLength
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  // Header
+  Rdword.Header.Header.Bits.Name =
+    ACPI_LARGE_WORD_ADDRESS_SPACE_DESCRIPTOR_NAME;
+  Rdword.Header.Header.Bits.Type = ACPI_LARGE_ITEM_FLAG;
+  Rdword.Header.Length = sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR) -
+                               sizeof (ACPI_LARGE_RESOURCE_HEADER);
+
+  // Body
+  Rdword.ResType = ResourceType;
+  Rdword.GenFlag = AddressSpaceGeneralFlags (
+                     IsPosDecode,
+                     IsMinFixed,
+                     IsMaxFixed
+                     );
+  Rdword.SpecificFlag = TypeSpecificFlags;
+  Rdword.AddrSpaceGranularity = AddressGranularity;
+  Rdword.AddrRangeMin = AddressMinimum;
+  Rdword.AddrRangeMax = AddressMaximum;
+  Rdword.AddrTranslationOffset = AddressTranslation;
+  Rdword.AddrLen = RangeLength;
+
+  Status = AmlCreateDataNode (
+             EAmlNodeDataTypeResourceData,
+             (UINT8*)&Rdword,
+             sizeof (EFI_ACPI_WORD_ADDRESS_SPACE_DESCRIPTOR),
+             &RdNode
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  return LinkRdNode (RdNode, NameOpNode, NewRdNode);
+}
+
+/** Code generation for the "WordBusNumber ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+   - s19.6.149 "WordBusNumber".
+
+  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,
+                                    See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.149 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.149 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.149 for more.
+                                    Not supported.
+  @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
+AmlCodeGenRdWordBusNumber (
+  IN        BOOLEAN                 IsResourceConsumer,
+  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        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  // There is no Type Specific Flags for buses.
+  return AmlCodeGenRdWordSpace (
+           ACPI_ADDRESS_SPACE_TYPE_BUS,
+           IsResourceConsumer,
+           IsPosDecode,
+           IsMinFixed,
+           IsMaxFixed,
+           0,
+           AddressGranularity,
+           AddressMinimum,
+           AddressMaximum,
+           AddressTranslation,
+           RangeLength,
+           ResourceSourceIndex,
+           ResourceSource,
+           NameOpNode,
+           NewRdNode
+           );
+}
+
+/** Code generation for the "QWordSpace ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.111 "QWordSpace".
+
+  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]  ResourceType         See ACPI 6.4 spec, s6.4.3.5.1 for more.
+                                    Available values are:
+                                      0:        Memory range
+                                      1:        I/O range
+                                      2:        Bus number range
+                                      3-191:    Reserved
+                                      192-255:  Hardware Vendor Defined
+  @param [in]  IsResourceConsumer   ResourceUsage parameter,
+                                    See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  TypeSpecificFlags    See ACPI 6.4 spec, s6.4.3.5.5
+                                    "Resource Type Specific Flags".
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.111 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.111 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.111 for more.
+                                    Not supported.
+  @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.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdQWordSpace (
+  IN        UINT8                   ResourceType,
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   TypeSpecificFlags,
+  IN        UINT64                  AddressGranularity,
+  IN        UINT64                  AddressMinimum,
+  IN        UINT64                  AddressMaximum,
+  IN        UINT64                  AddressTranslation,
+  IN        UINT64                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  EFI_STATUS                                Status;
+  AML_DATA_NODE                           * RdNode;
+  EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR   RdQword;
+
+  // ResourceSource and ResourceSourceIndex are not supported.
+  if ((TypeSpecificFlags == MAX_UINT8)  ||
+      (ResourceSourceIndex != 0)        ||
+      (ResourceSource != NULL)          ||
+      ((NameOpNode == NULL) && (NewRdNode == NULL))) {
+    ASSERT (0);
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = CheckAddressSpaceFields (
+             IsMinFixed,
+             IsMaxFixed,
+             AddressGranularity,
+             AddressMinimum,
+             AddressMaximum,
+             AddressTranslation,
+             RangeLength
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  // Header
+  RdQword.Header.Header.Bits.Name =
+    ACPI_LARGE_QWORD_ADDRESS_SPACE_DESCRIPTOR_NAME;
+  RdQword.Header.Header.Bits.Type = ACPI_LARGE_ITEM_FLAG;
+  RdQword.Header.Length = sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) -
+                               sizeof (ACPI_LARGE_RESOURCE_HEADER);
+
+  // Body
+  RdQword.ResType = ResourceType;
+  RdQword.GenFlag = AddressSpaceGeneralFlags (
+                      IsPosDecode,
+                      IsMinFixed,
+                      IsMaxFixed
+                      );
+  RdQword.SpecificFlag = TypeSpecificFlags;
+  RdQword.AddrSpaceGranularity = AddressGranularity;
+  RdQword.AddrRangeMin = AddressMinimum;
+  RdQword.AddrRangeMax = AddressMaximum;
+  RdQword.AddrTranslationOffset = AddressTranslation;
+  RdQword.AddrLen = RangeLength;
+
+  Status = AmlCreateDataNode (
+             EAmlNodeDataTypeResourceData,
+             (UINT8*)&RdQword,
+             sizeof (EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR),
+             &RdNode
+             );
+  if (EFI_ERROR (Status)) {
+    ASSERT (0);
+    return Status;
+  }
+
+  return LinkRdNode (RdNode, NameOpNode, NewRdNode);
+}
+
+/** Code generation for the "QWordMemory ()" ASL function.
+
+  The Resource Data effectively created is an Extended Interrupt Resource
+  Data. Cf ACPI 6.4:
+   - s6.4.3.5.1 "QWord Address Space Descriptor".
+   - s19.6.110 "QWordMemory".
+
+  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,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsPosDecode          Decode parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsMinFixed           See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsMaxFixed           See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  Cacheable            Available values are:
+                                    0-The memory is non-cacheable
+                                    1-The memory is cacheable
+                                    2-The memory is cacheable and supports
+                                      write combining
+                                    3-The memory is cacheable and prefetchable
+  @param [in]  IsReadWrite          ReadAndWrite parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressGranularity   See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressMinimum       See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressMaximum       See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  AddressTranslation   See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  RangeLength          See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  ResourceSourceIndex  See ACPI 6.4 spec, s19.6.110 for more.
+                                    Not supported.
+  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.110 for more.
+                                    Not supported.
+  @param [in]  MemoryRangeType      Available values are:
+                                      0-AddressRangeMemory
+                                      1-AddressRangeReserved
+                                      2-AddressRangeACPI
+                                      3-AddressRangeNVS
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @param [in]  IsTypeStatic         TranslationType parameter,
+                                    See ACPI 6.4 spec, s19.6.110 for more.
+  @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
+AmlCodeGenRdQWordMemory (
+  IN        BOOLEAN                 IsResourceConsumer,
+  IN        BOOLEAN                 IsPosDecode,
+  IN        BOOLEAN                 IsMinFixed,
+  IN        BOOLEAN                 IsMaxFixed,
+  IN        UINT8                   Cacheable,
+  IN        BOOLEAN                 IsReadWrite,
+  IN        UINT64                  AddressGranularity,
+  IN        UINT64                  AddressMinimum,
+  IN        UINT64                  AddressMaximum,
+  IN        UINT64                  AddressTranslation,
+  IN        UINT64                  RangeLength,
+  IN        UINT8                   ResourceSourceIndex,
+  IN  CONST CHAR8                   *ResourceSource,
+  IN        UINT8                   MemoryRangeType,
+  IN        BOOLEAN                 IsTypeStatic,
+  IN        AML_OBJECT_NODE_HANDLE  NameOpNode, OPTIONAL
+  OUT       AML_DATA_NODE_HANDLE    *NewRdNode  OPTIONAL
+  )
+{
+  return AmlCodeGenRdQWordSpace (
+           ACPI_ADDRESS_SPACE_TYPE_MEM,
+           IsResourceConsumer,
+           IsPosDecode,
+           IsMinFixed,
+           IsMaxFixed,
+           MemoryRangeSpecificFlags (
+             Cacheable,
+             IsReadWrite,
+             MemoryRangeType,
+             IsTypeStatic
+             ),
+           AddressGranularity,
+           AddressMinimum,
+           AddressMaximum,
+           AddressTranslation,
+           RangeLength,
+           ResourceSourceIndex,
+           ResourceSource,
+           NameOpNode,
+           NewRdNode
+           );
+}
+
 /** Code generation for the "Interrupt ()" ASL function.
 
   The Resource Data effectively created is an Extended Interrupt Resource
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76959): https://edk2.groups.io/g/devel/message/76959
Mute This Topic: https://groups.io/mt/83735871/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list