DynamicTablesPkg: AML code generation for IO resouce descriptor.

Add helper functions to generate AML resource data
for I/O resource descriptor.

Cc: Pierre Gondois <pierre.gondois@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
This commit is contained in:
Abdul Lateef Attar 2024-08-07 10:27:36 +00:00 committed by mergify[bot]
parent b6c4708c4d
commit 6a7be5a841
2 changed files with 125 additions and 0 deletions

View File

@ -1028,6 +1028,48 @@ AmlCodeGenRdInterrupt (
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** Code generation for the "IO ()" ASL function.
The Resource Data effectively created is a IO Resource
Data. Cf ACPI 6.5:
- s19.6.65 IO (IO Resource Descriptor Macro)
- s6.4.2.5 I/O Port Descriptor
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
@param [in] IsDecoder16 Decoder parameter.
TRUE if 16-bit decoder.
FALSE if 10-bit decoder.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] Alignment Alignment.
@param [in] RangeLength Range length.
@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.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdIo (
IN BOOLEAN IsDecoder16,
IN UINT16 AddressMinimum,
IN UINT16 AddressMaximum,
IN UINT8 Alignment,
IN UINT8 RangeLength,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
);
/** AML code generation for DefinitionBlock.
Create a Root Node handle.

View File

@ -1475,6 +1475,89 @@ AmlCodeGenRdRegister (
return LinkRdNode (RdNode, NameOpNode, NewRdNode);
}
/** Code generation for the "IO ()" ASL function.
The Resource Data effectively created is a IO Resource
Data. Cf ACPI 6.5:
- s19.6.65 IO (IO Resource Descriptor Macro)
- s6.4.2.5 I/O Port Descriptor
The created resource data node can be:
- appended to the list of resource data elements of the NameOpNode.
In such case NameOpNode must be defined by a the "Name ()" ASL statement
and initially contain a "ResourceTemplate ()".
- returned through the NewRdNode parameter.
@param [in] IsDecoder16 Decoder parameter.
TRUE if 16-bit decoder.
FALSE if 10-bit decoder.
@param [in] AddressMinimum Minimum address.
@param [in] AddressMaximum Maximum address.
@param [in] Alignment Alignment.
@param [in] RangeLength Range length.
@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.
**/
EFI_STATUS
EFIAPI
AmlCodeGenRdIo (
IN BOOLEAN IsDecoder16,
IN UINT16 AddressMinimum,
IN UINT16 AddressMaximum,
IN UINT8 Alignment,
IN UINT8 RangeLength,
IN AML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL
)
{
EFI_STATUS Status;
EFI_ACPI_IO_PORT_DESCRIPTOR IoDesc;
AML_DATA_NODE *IoNode;
if (AddressMinimum > AddressMaximum) {
return EFI_INVALID_PARAMETER;
}
if (Alignment != 0) {
/// check the alignment
if ((AddressMinimum % Alignment) != 0) {
return EFI_INVALID_PARAMETER;
}
if ((AddressMaximum % Alignment) != 0) {
return EFI_INVALID_PARAMETER;
}
}
IoDesc.Header.Byte = ACPI_IO_PORT_DESCRIPTOR;
IoDesc.Information = IsDecoder16 ? BIT0 : 0;
IoDesc.BaseAddressMin = AddressMinimum;
IoDesc.BaseAddressMax = AddressMaximum;
IoDesc.Alignment = Alignment;
IoDesc.Length = RangeLength;
Status = AmlCreateDataNode (
EAmlNodeDataTypeResourceData,
(UINT8 *)&IoDesc,
sizeof (IoDesc),
&IoNode
);
if (EFI_ERROR (Status)) {
ASSERT (0);
return Status;
}
return LinkRdNode (IoNode, NameOpNode, NewRdNode);
}
/** Code generation for the EndTag resource data.
The EndTag resource data is automatically generated by the ASL compiler