summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
authorHimanshu Sharma <Himanshu.Sharma@arm.com>2024-01-04 13:32:57 +0530
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-03-04 09:58:10 +0000
commit1ae5bee967bffcd6dbbabca913ea3c65d8f09c76 (patch)
tree71c956a0ca7142f88c63f673d0f82e9cc04551c6 /DynamicTablesPkg
parent855f52819950673642ca1add72c8eb0fc3499ce9 (diff)
downloadedk2-1ae5bee967bffcd6dbbabca913ea3c65d8f09c76.tar.gz
edk2-1ae5bee967bffcd6dbbabca913ea3c65d8f09c76.tar.bz2
edk2-1ae5bee967bffcd6dbbabca913ea3c65d8f09c76.zip
DynamicTablesPkg/SsdtSerialPortFixupLib: Add Interrupt node for SPIs only
Add interrupt node to the AML description of the serial-port only if the IRQ ID from the Configuration Manager is a valid SPI (shared processor interrupt) or an extended SPI. So, for DBG2 UART ports where interrupt is not mandatory, adding of an interrupt node in the AML description using Serial Port Fixup Library can be ignored if the UART is not defined with a valid SPI, like in N1SDP. This update generates the interrupt node for the valid SPI range using the AML Codegen API instead of updating it using the AML Fixup API. Cc: Sami Mujawar <Sami.Mujawar@arm.com> Cc: Pierre Gondois <pierre.gondois@arm.com> Signed-off-by: Himanshu Sharma <Himanshu.Sharma@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Include/ArmNameSpaceObjects.h7
-rw-r--r--DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c58
-rw-r--r--DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf5
-rw-r--r--DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl29
4 files changed, 69 insertions, 30 deletions
diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 3805c58247..4a419a8fcd 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2017 - 2024, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -317,7 +317,10 @@ typedef struct CmArmSerialPortInfo {
/// The physical base address for the serial port
UINT64 BaseAddress;
- /// The serial port interrupt
+ /** The serial port interrupt.
+ 0 indicates that the serial port does not
+ have an interrupt wired.
+ */
UINT32 Interrupt;
/// The serial port baud rate
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index a65c1fe7e3..b1a628e419 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
@@ -1,7 +1,7 @@
/** @file
SSDT Serial Port Fixup Library.
- Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,6 +9,9 @@
- Arm Server Base Boot Requirements (SBBR), s4.2.1.8 "SPCR".
- Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
- ACPI for Arm Components 1.0 - 2020
+ - Arm Generic Interrupt Controller Architecture Specification,
+ Issue H, January 2022.
+ (https://developer.arm.com/documentation/ihi0069/)
**/
#include <IndustryStandard/DebugPort2Table.h>
@@ -27,6 +30,10 @@
#include <Library/AmlLib/AmlLib.h>
#include <Protocol/ConfigurationManagerProtocol.h>
+#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+ #include <Library/ArmGicArchLib.h>
+#endif
+
/** C array containing the compiled AML template.
This symbol is defined in the auto generated C file
containing the AML bytecode array.
@@ -100,6 +107,26 @@ ValidateSerialPortInfo (
return EFI_INVALID_PARAMETER;
}
+ #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+ // If an interrupt is not wired to the serial port, the Configuration
+ // Manager specifies the interrupt as 0.
+ // Any other value must be within the SPI or extended SPI range.
+ if ((SerialPortInfo->Interrupt != 0) &&
+ !(((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_SPI_MIN) &&
+ (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_SPI_MAX)) ||
+ ((SerialPortInfo->Interrupt >= ARM_GIC_ARCH_EXT_SPI_MIN) &&
+ (SerialPortInfo->Interrupt <= ARM_GIC_ARCH_EXT_SPI_MAX))))
+ {
+ DEBUG ((
+ DEBUG_ERROR,
+ "ERROR: Invalid UART port interrupt ID. Interrupt = %lu\n",
+ SerialPortInfo->Interrupt
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ #endif
+
DEBUG ((DEBUG_INFO, "UART Configuration:\n"));
DEBUG ((
DEBUG_INFO,
@@ -270,7 +297,6 @@ FixupCrs (
EFI_STATUS Status;
AML_OBJECT_NODE_HANDLE NameOpCrsNode;
AML_DATA_NODE_HANDLE QWordRdNode;
- AML_DATA_NODE_HANDLE InterruptRdNode;
// Get the "_CRS" object defined by the "Name ()" statement.
Status = AmlFindNode (
@@ -303,20 +329,22 @@ FixupCrs (
return Status;
}
- // Get the Interrupt node.
- // It is the second Resource Data element in the NameOpCrsNode's
- // variable list of arguments.
- Status = AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (InterruptRdNode == NULL) {
- return EFI_INVALID_PARAMETER;
- }
+ // Generate an interrupt node as the second Resource Data element in the
+ // NameOpCrsNode, if the interrupt for the serial-port is a valid SPI from
+ // Table 2-1 in Arm Generic Interrupt Controller Architecture Specification.
+ Status = AmlCodeGenRdInterrupt (
+ TRUE, // Resource Consumer
+ FALSE, // Level Triggered
+ FALSE, // Active High
+ FALSE, // Exclusive
+ (UINT32 *)&SerialPortInfo->Interrupt,
+ 1,
+ NameOpCrsNode,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
- // Update the interrupt number.
- return AmlUpdateRdInterrupt (InterruptRdNode, SerialPortInfo->Interrupt);
+ return Status;
}
/** Fixup the Serial Port device name.
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 965167bdc4..1fae71068a 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -18,12 +18,15 @@
SsdtSerialPortFixupLib.c
SsdtSerialPortTemplate.asl
-[Packages]
+[Packages.common]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
DynamicTablesPkg/DynamicTablesPkg.dec
+[Packages.ARM, Packages.AARCH64]
+ ArmPkg/ArmPkg.dec
+
[LibraryClasses]
AcpiHelperLib
AmlLib
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
index fcae2160ac..ef0ab9a9b1 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
@@ -1,7 +1,7 @@
/** @file
SSDT Serial Template
- Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2019 - 2024, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -10,6 +10,7 @@
@par Glossary:
- {template} - Data fixed up using AML Fixup APIs.
+ - {codegen} - Data generated using AML Codegen APIs.
**/
DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIAL", 1) {
@@ -43,17 +44,21 @@ DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIAL", 1)
, // MemoryRangeType
// TranslationType
) // QWordMemory
- Interrupt (
- ResourceConsumer, // ResourceUsage
- Level, // EdgeLevel
- ActiveHigh, // ActiveLevel
- Exclusive, // Shared
- , // ResourceSourceIndex
- , // ResourceSource
- // DescriptorName
- ) {
- 0xA5 // {template}
- } // Interrupt
+
+ // The Interrupt information is generated using AmlCodegen.
+ //
+ // Interrupt ( // {codegen}
+ // ResourceConsumer, // ResourceUsage
+ // Level, // EdgeLevel
+ // ActiveHigh, // ActiveLevel
+ // Exclusive, // Shared
+ // , // ResourceSourceIndex
+ // , // ResourceSource
+ // // DescriptorName
+ // ) {
+ // <IRQ> // <spi>
+ // } // Interrupt
+
}) // Name
} // Device
} // Scope (_SB)