Hi Himanshu,

Thank you for this patch.

Please see my feedback marked inline as [SAMI].

Regards,

Sami Mujawar

On 06/12/2023 10:11 am, Himanshu Sharma wrote:
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
[SAMI] I understand that this section was not ordered alphabetically, but can you add the above line at the begining of this section, please?

 

 [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.

[SAMI] Please limit line length to 80 chars. Also it may be useful to include the link to the spec.

e.g.

     - Arm Generic Interrupt Controller Architecture Specification,

      Issue H, January 2022.

      (https://developer.arm.com/documentation/ihi0069/)

[/SAMI]


 **/

 

 #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.

[SAMI] Can you modify the above comment to say 'Generate an interrupt node as the second Resource Data element in the NameOpCrsNode, if the interrupt ...'.

Also, limit the line length to 80 characters.

[/SAMI]


+  // 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
[SAMI] Use BOOLEAN types TRUE/FALSE instead of 1/0.

+              (UINT32 *)&SerialPortInfo->Interrupt,

+              1,

+              NameOpCrsNode,

+              NULL

+    );
[SAMI] Run uncrustify and patch check script before submitting the patches.

+    if (EFI_ERROR (Status)) {

+      return Status;

+    }
[SAMI] Replace this 'if block' with ASSERT_EFI_ERROR (Status) and return 'Status' at the end of the function.

   }

[SAMI] I think you should document at https://github.com/tianocore/edk2/blob/master/DynamicTablesPkg/Include/ArmNameSpaceObjects.h#L314

that if the Serial port does not have an interrupt wired, then zero must be specified for the CM_ARM_SERIAL_PORT_INFO.Interrupt field.

Then there should be an additional check here as shown below:

       else if (SerialPortInfo->Interrupt !=0) {

// if an Interrupt is not wired to the Serial port the Configuration Manager

// specifies the Interrupt as 0. Any other value must be treated as an error.

DEBUG ((DEBUG_ERROR, "Invalid interrupt ID for Serial Port\n"));

Status = EFI_INVALID_PARAMETER;

}

[/SAMI]


-

-  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)

_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#112516) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_