public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Pierre.Gondois@arm.com, devel@edk2.groups.io,
	Alexei Fedorov <Alexei.Fedorov@arm.com>
Cc: Akanksha Jain <akanksha.jain2@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>, nd <nd@arm.com>
Subject: Re: [PATCH v1 1/7] DynamicTablesPkg: AML Code generation for memory ranges
Date: Wed, 6 Oct 2021 16:14:20 +0100	[thread overview]
Message-ID: <64fb105e-4c1a-2a60-3097-e976ce8dfd26@arm.com> (raw)
In-Reply-To: <20210623115834.907-2-Pierre.Gondois@arm.com>

Hi Pierre,

Please find my feedback marked inline as [SAMI].

Regards,

Sami Mujawar


On 23/06/2021 12:58 PM, Pierre.Gondois@arm.com wrote:
> From: Pierre Gondois <Pierre.Gondois@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@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
[SAMI] I think the text above needs updating. Same comment for other 
functions in this patch.
> +  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.
[SAMI] Add brief description about the parameter in addition to the 
specification reference.
> +  @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.
[SAMI] I think it would be good to mention that this parameter is unused 
and is provided here for compatibility with the ACPI DWordIo() resource 
descriptor macro.
> +  @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.
[SAMI] Construct type specific flags for Memory ranges? Same for other 
functions in this patch.
> +
> +  @param [in]  Cacheable            Available values are:
[SAMI] Maybe the description should say Possible 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.
[SAMI] I think this should be changed to 'Returns a type specific flag 
value'.
> +          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.
[SAMI] I think you should mentions 'Not supported, must be 0.'
> +  @param [in]  ResourceSource       See ACPI 6.4 spec, s19.6.36 for more.
> +                                    Not supported.
[SAMI] I think you should mentions 'Not supported, must be NULL.'
> +  @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


  reply	other threads:[~2021-10-06 15:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 11:58 [PATCH v1 0/7] Create a SSDT PCIe generator PierreGondois
2021-06-23 11:58 ` [PATCH v1 1/7] DynamicTablesPkg: AML Code generation for memory ranges PierreGondois
2021-10-06 15:14   ` Sami Mujawar [this message]
2021-06-23 11:58 ` [PATCH v1 2/7] DynamicTablesPkg: AML Code generation to create a named Package() PierreGondois
2021-10-06 15:15   ` Sami Mujawar
2021-06-23 11:58 ` [PATCH v1 3/7] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() PierreGondois
2021-10-06 15:16   ` Sami Mujawar
2021-06-23 11:58 ` [PATCH v1 4/7] DynamicTablesPkg: AML Code generation to add _PRT entries PierreGondois
2021-10-06 15:17   ` Sami Mujawar
2021-06-23 11:58 ` [PATCH v1 5/7] DynamicTablesPkg: Add AmlAttachNode() PierreGondois
2021-10-06 15:17   ` Sami Mujawar
2021-06-23 11:58 ` [PATCH v1 6/7] DynamicTablesPkg: Add Pci related objects PierreGondois
2021-10-06 15:18   ` Sami Mujawar
2021-06-23 11:58 ` [PATCH v1 7/7] DynamicTablesPkg: SSDT Pci express generator PierreGondois
2021-10-07 11:11   ` Sami Mujawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64fb105e-4c1a-2a60-3097-e976ce8dfd26@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox