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>
This commit is contained in:
Himanshu Sharma
2024-01-04 13:32:57 +05:30
committed by mergify[bot]
parent 855f528199
commit 1ae5bee967
4 changed files with 69 additions and 30 deletions

View File

@ -1,6 +1,6 @@
/** @file /** @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 SPDX-License-Identifier: BSD-2-Clause-Patent
@ -317,7 +317,10 @@ typedef struct CmArmSerialPortInfo {
/// The physical base address for the serial port /// The physical base address for the serial port
UINT64 BaseAddress; UINT64 BaseAddress;
/// The serial port interrupt /** The serial port interrupt.
0 indicates that the serial port does not
have an interrupt wired.
*/
UINT32 Interrupt; UINT32 Interrupt;
/// The serial port baud rate /// The serial port baud rate

View File

@ -1,7 +1,7 @@
/** @file /** @file
SSDT Serial Port Fixup Library. 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 SPDX-License-Identifier: BSD-2-Clause-Patent
@ -9,6 +9,9 @@
- Arm Server Base Boot Requirements (SBBR), s4.2.1.8 "SPCR". - Arm Server Base Boot Requirements (SBBR), s4.2.1.8 "SPCR".
- Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015. - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.
- ACPI for Arm Components 1.0 - 2020 - 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> #include <IndustryStandard/DebugPort2Table.h>
@ -27,6 +30,10 @@
#include <Library/AmlLib/AmlLib.h> #include <Library/AmlLib/AmlLib.h>
#include <Protocol/ConfigurationManagerProtocol.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. /** C array containing the compiled AML template.
This symbol is defined in the auto generated C file This symbol is defined in the auto generated C file
containing the AML bytecode array. containing the AML bytecode array.
@ -100,6 +107,26 @@ ValidateSerialPortInfo (
return EFI_INVALID_PARAMETER; 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, "UART Configuration:\n"));
DEBUG (( DEBUG ((
DEBUG_INFO, DEBUG_INFO,
@ -270,7 +297,6 @@ FixupCrs (
EFI_STATUS Status; EFI_STATUS Status;
AML_OBJECT_NODE_HANDLE NameOpCrsNode; AML_OBJECT_NODE_HANDLE NameOpCrsNode;
AML_DATA_NODE_HANDLE QWordRdNode; AML_DATA_NODE_HANDLE QWordRdNode;
AML_DATA_NODE_HANDLE InterruptRdNode;
// Get the "_CRS" object defined by the "Name ()" statement. // Get the "_CRS" object defined by the "Name ()" statement.
Status = AmlFindNode ( Status = AmlFindNode (
@ -303,22 +329,24 @@ FixupCrs (
return Status; return Status;
} }
// Get the Interrupt node. // Generate an interrupt node as the second Resource Data element in the
// It is the second Resource Data element in the NameOpCrsNode's // NameOpCrsNode, if the interrupt for the serial-port is a valid SPI from
// variable list of arguments. // Table 2-1 in Arm Generic Interrupt Controller Architecture Specification.
Status = AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode); Status = AmlCodeGenRdInterrupt (
if (EFI_ERROR (Status)) { TRUE, // Resource Consumer
FALSE, // Level Triggered
FALSE, // Active High
FALSE, // Exclusive
(UINT32 *)&SerialPortInfo->Interrupt,
1,
NameOpCrsNode,
NULL
);
ASSERT_EFI_ERROR (Status);
return Status; return Status;
} }
if (InterruptRdNode == NULL) {
return EFI_INVALID_PARAMETER;
}
// Update the interrupt number.
return AmlUpdateRdInterrupt (InterruptRdNode, SerialPortInfo->Interrupt);
}
/** Fixup the Serial Port device name. /** Fixup the Serial Port device name.
@param [in] RootNodeHandle Pointer to the root of an AML tree. @param [in] RootNodeHandle Pointer to the root of an AML tree.

View File

@ -18,12 +18,15 @@
SsdtSerialPortFixupLib.c SsdtSerialPortFixupLib.c
SsdtSerialPortTemplate.asl SsdtSerialPortTemplate.asl
[Packages] [Packages.common]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec EmbeddedPkg/EmbeddedPkg.dec
DynamicTablesPkg/DynamicTablesPkg.dec DynamicTablesPkg/DynamicTablesPkg.dec
[Packages.ARM, Packages.AARCH64]
ArmPkg/ArmPkg.dec
[LibraryClasses] [LibraryClasses]
AcpiHelperLib AcpiHelperLib
AmlLib AmlLib

View File

@ -1,7 +1,7 @@
/** @file /** @file
SSDT Serial Template 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 SPDX-License-Identifier: BSD-2-Clause-Patent
@ -10,6 +10,7 @@
@par Glossary: @par Glossary:
- {template} - Data fixed up using AML Fixup APIs. - {template} - Data fixed up using AML Fixup APIs.
- {codegen} - Data generated using AML Codegen APIs.
**/ **/
DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIAL", 1) { DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIAL", 1) {
@ -43,17 +44,21 @@ DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIAL", 1)
, // MemoryRangeType , // MemoryRangeType
// TranslationType // TranslationType
) // QWordMemory ) // QWordMemory
Interrupt (
ResourceConsumer, // ResourceUsage // The Interrupt information is generated using AmlCodegen.
Level, // EdgeLevel //
ActiveHigh, // ActiveLevel // Interrupt ( // {codegen}
Exclusive, // Shared // ResourceConsumer, // ResourceUsage
, // ResourceSourceIndex // Level, // EdgeLevel
, // ResourceSource // ActiveHigh, // ActiveLevel
// DescriptorName // Exclusive, // Shared
) { // , // ResourceSourceIndex
0xA5 // {template} // , // ResourceSource
} // Interrupt // // DescriptorName
// ) {
// <IRQ> // <spi>
// } // Interrupt
}) // Name }) // Name
} // Device } // Device
} // Scope (_SB) } // Scope (_SB)