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.sha...@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/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to