summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbdul Lateef Attar <AbdulLateef.Attar@amd.com>2024-08-07 10:27:36 +0000
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-30 01:46:19 +0000
commit6a7be5a8418ab6397375e32e399e9523db9d4293 (patch)
treea176d3be2d85eaa3f8ab3dfc2faef658e0ddee07
parentb6c4708c4d3470cfd9f465771a665510d3ad1a66 (diff)
downloadedk2-6a7be5a8418ab6397375e32e399e9523db9d4293.tar.gz
edk2-6a7be5a8418ab6397375e32e399e9523db9d4293.tar.bz2
edk2-6a7be5a8418ab6397375e32e399e9523db9d4293.zip
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>
-rw-r--r--DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h42
-rw-r--r--DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c83
2 files changed, 125 insertions, 0 deletions
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 7c130736b4..13ce97c3dd 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -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.
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 46243f981c..3db536dddf 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -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