From: "Himanshu Sharma" <Himanshu.Sharma@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Pierre Gondois <Pierre.Gondois@arm.com>,
Himanshu Sharma <Himanshu.Sharma@arm.com>
Subject: [edk2-devel] [edk2][PATCH V1 2/2] DynamicTablesPkg/SsdtSerialPortFixupLib: Add Interrupt node for SPIs only
Date: Wed, 6 Dec 2023 15:41:46 +0530 [thread overview]
Message-ID: <20231206101146.1309296-3-Himanshu.Sharma@arm.com> (raw)
In-Reply-To: <20231206101146.1309296-1-Himanshu.Sharma@arm.com>
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.
Signed-off-by: Himanshu Sharma <Himanshu.Sharma@arm.com>
---
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf | 3 +-
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c | 38 ++++++++++++--------
DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl | 29 ++++++++-------
3 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
index 965167bdc4e1..2d16a22aeb41 100644
--- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
+++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
@@ -1,7 +1,7 @@
## @file
# SSDT Serial Port fixup Library
#
-# Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.<BR>
+# Copyright (c) 2020 - 2021, 2023, Arm Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
@@ -23,6 +23,7 @@
MdeModulePkg/MdeModulePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
DynamicTablesPkg/DynamicTablesPkg.dec
+ ArmPkg/ArmPkg.dec
[LibraryClasses]
AcpiHelperLib
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.c
index a65c1fe7e30d..fb77136aa844 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 - 2021, 2023, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -9,10 +9,12 @@
- 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.
**/
#include <IndustryStandard/DebugPort2Table.h>
#include <Library/AcpiLib.h>
+#include <Library/ArmGicArchLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
@@ -270,7 +272,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 +304,27 @@ 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;
+ // Generate an interrupt node if the interrupt for the serial-port is a valid SPI.
+ // SPI ranges from Table 2-1 in Arm Generic Interrupt Controller Architecture Specification.
+ if (((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))) {
+ Status = AmlCodeGenRdInterrupt (
+ 1, // Resource Consumer
+ 0, // Level Triggered
+ 0, // Active High
+ 0, // Exclusive
+ (UINT32 *)&SerialPortInfo->Interrupt,
+ 1,
+ NameOpCrsNode,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
}
-
- if (InterruptRdNode == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Update the interrupt number.
- return AmlUpdateRdInterrupt (InterruptRdNode, SerialPortInfo->Interrupt);
+ return EFI_SUCCESS;
}
/** Fixup the Serial Port device name.
diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTemplate.asl
index fcae2160ac3d..46f800b0cdad 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 - 2020, 2023, 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)
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112118): https://edk2.groups.io/g/devel/message/112118
Mute This Topic: https://groups.io/mt/103010241/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-12-06 10:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 10:11 [edk2-devel] [edk2][PATCH V1 0/2] Update handling of interrupt node for SSDT Serial Port Fixup Library Himanshu Sharma
2023-12-06 10:11 ` [edk2-devel] [edk2][PATCH V1 1/2] ArmPkg/ArmGicArchLib: Add macros for SPI and extended SPI ranges Himanshu Sharma
2023-12-14 9:47 ` Sami Mujawar
2023-12-06 10:11 ` Himanshu Sharma [this message]
2023-12-06 10:25 ` [edk2-devel] [edk2][PATCH V1 2/2] DynamicTablesPkg/SsdtSerialPortFixupLib: Add Interrupt node for SPIs only Himanshu Sharma
2023-12-14 9:47 ` 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=20231206101146.1309296-3-Himanshu.Sharma@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