From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id EE0857803E3 for ; Thu, 4 Jan 2024 08:03:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=s1bz2T8a7LCVLKrHN1Vd47cnC3QFfjz7Ci1NyCNVwVc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1704355391; v=1; b=TIhUCzJJ3vaprZeIjJZ2RqHAFcOGM3tiGAgTYBZ4tf0iniIE7V124HVNvKgGjj7QOgPBSy9M z2Yrn6mynKkRrXFxFkzpSigZC6E2zKQVscAziWeqP4UQg6YgNbqIMWFWad4bHibFB+ndtG0SgQn 3M97qE1LtTmS4ij3a6SnU7ek= X-Received: by 127.0.0.2 with SMTP id trMXYY7687511xtGKOR4MW0X; Thu, 04 Jan 2024 00:03:11 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.49727.1704355390997786488 for ; Thu, 04 Jan 2024 00:03:11 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3CDEEC15; Thu, 4 Jan 2024 00:03:56 -0800 (PST) X-Received: from usa.arm.com (a076756.arm.com [10.162.16.85]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8B6B03F7A6; Thu, 4 Jan 2024 00:03:08 -0800 (PST) From: "Himanshu Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Pierre Gondois , Himanshu Sharma Subject: [edk2-devel] [edk2][PATCH V2 2/2] DynamicTablesPkg/SsdtSerialPortFixupLib: Add Interrupt node for SPIs only Date: Thu, 4 Jan 2024 13:32:57 +0530 Message-Id: <20240104080257.319631-3-Himanshu.Sharma@arm.com> In-Reply-To: <20240104080257.319631-1-Himanshu.Sharma@arm.com> References: <20240104080257.319631-1-Himanshu.Sharma@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,Himanshu.Sharma@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kMnDYLnP68DitqJU6JJThu9rx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=TIhUCzJJ; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 --- DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixup= Lib.inf | 3 +- DynamicTablesPkg/Include/ArmNameSpaceObjects.h = | 6 ++- DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixup= Lib.c | 49 ++++++++++++++------ DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortTempl= ate.asl | 29 +++++++----- 4 files changed, 58 insertions(+), 29 deletions(-) diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.inf b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLi= b/SsdtSerialPortFixupLib.inf index 965167bdc4e1..5e2615c961ad 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.inf +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.inf @@ -1,7 +1,7 @@ ## @file=0D # SSDT Serial Port fixup Library=0D #=0D -# Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
=0D +# Copyright (c) 2020 - 2021, 2024, Arm Limited. All rights reserved.
= =0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D ##=0D @@ -19,6 +19,7 @@ SsdtSerialPortTemplate.asl=0D =0D [Packages]=0D + ArmPkg/ArmPkg.dec=0D MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D EmbeddedPkg/EmbeddedPkg.dec=0D diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTables= Pkg/Include/ArmNameSpaceObjects.h index 8c00bdac20bb..e9df0ec94808 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -1,6 +1,6 @@ /** @file=0D =0D - Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
=0D + Copyright (c) 2017 - 2024, Arm Limited. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -311,7 +311,9 @@ typedef struct CmArmSerialPortInfo { /// The physical base address for the serial port=0D UINT64 BaseAddress;=0D =0D - /// The serial port interrupt=0D + /** The serial port interrupt=0D + to be speciifed 0 if the serial port does not have an interrupt wire= d.=0D + */=0D UINT32 Interrupt;=0D =0D /// The serial port baud rate=0D diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortFixupLib.c b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/= SsdtSerialPortFixupLib.c index a65c1fe7e30d..d0b1f61fdf85 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= FixupLib.c @@ -1,7 +1,7 @@ /** @file=0D SSDT Serial Port Fixup Library.=0D =0D - Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
=0D + Copyright (c) 2019 - 2021, 2024, Arm Limited. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -9,10 +9,14 @@ - Arm Server Base Boot Requirements (SBBR), s4.2.1.8 "SPCR".=0D - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.= =0D - ACPI for Arm Components 1.0 - 2020=0D + - Arm Generic Interrupt Controller Architecture Specification,=0D + Issue H, January 2022.=0D + (https://developer.arm.com/documentation/ihi0069/)=0D **/=0D =0D #include =0D #include =0D +#include =0D #include =0D #include =0D #include =0D @@ -270,7 +274,6 @@ FixupCrs ( EFI_STATUS Status;=0D AML_OBJECT_NODE_HANDLE NameOpCrsNode;=0D AML_DATA_NODE_HANDLE QWordRdNode;=0D - AML_DATA_NODE_HANDLE InterruptRdNode;=0D =0D // Get the "_CRS" object defined by the "Name ()" statement.=0D Status =3D AmlFindNode (=0D @@ -303,20 +306,38 @@ FixupCrs ( return Status;=0D }=0D =0D - // Get the Interrupt node.=0D - // It is the second Resource Data element in the NameOpCrsNode's=0D - // variable list of arguments.=0D - Status =3D AmlNameOpGetNextRdNode (QWordRdNode, &InterruptRdNode);=0D - if (EFI_ERROR (Status)) {=0D - return Status;=0D + // Generate an interrupt node as the second Resource Data element in the= =0D + // NameOpCrsNode, if the interrupt for the serial-port is a valid SPI fr= om=0D + // Table 2-1 in Arm Generic Interrupt Controller Architecture Specificat= ion.=0D + if (((SerialPortInfo->Interrupt >=3D ARM_GIC_ARCH_SPI_MIN) &&=0D + (SerialPortInfo->Interrupt <=3D ARM_GIC_ARCH_SPI_MAX)) ||=0D + ((SerialPortInfo->Interrupt >=3D ARM_GIC_ARCH_EXT_SPI_MIN) &&=0D + (SerialPortInfo->Interrupt <=3D ARM_GIC_ARCH_EXT_SPI_MAX)))=0D + {=0D + Status =3D AmlCodeGenRdInterrupt (=0D + TRUE, // Resource Consumer=0D + FALSE, // Level Triggered=0D + FALSE, // Active High=0D + FALSE, // Exclusive=0D + (UINT32 *)&SerialPortInfo->Interrupt,=0D + 1,=0D + NameOpCrsNode,=0D + NULL=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + } else if (SerialPortInfo->Interrupt !=3D 0) {=0D + // If an interrupt is not wired to the serial port, the=0D + // Configuration Manager specifies the interrupt as 0.=0D + // Any other value must be treated as an error.=0D + DEBUG ((=0D + DEBUG_ERROR,=0D + "ERROR: SSDT-SERIAL-PORT-FIXUP: Invalid interrupt ID for Serial Port= \n"=0D + ));=0D + ASSERT (0);=0D + Status =3D EFI_INVALID_PARAMETER;=0D }=0D =0D - if (InterruptRdNode =3D=3D NULL) {=0D - return EFI_INVALID_PARAMETER;=0D - }=0D -=0D - // Update the interrupt number.=0D - return AmlUpdateRdInterrupt (InterruptRdNode, SerialPortInfo->Interrupt)= ;=0D + return Status;=0D }=0D =0D /** Fixup the Serial Port device name.=0D diff --git a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSer= ialPortTemplate.asl b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLi= b/SsdtSerialPortTemplate.asl index fcae2160ac3d..22e6c04e020c 100644 --- a/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= Template.asl +++ b/DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPort= Template.asl @@ -1,7 +1,7 @@ /** @file=0D SSDT Serial Template=0D =0D - Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
=0D + Copyright (c) 2019 - 2020, 2024, Arm Limited. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -10,6 +10,7 @@ =0D @par Glossary:=0D - {template} - Data fixed up using AML Fixup APIs.=0D + - {codegen} - Data generated using AML Codegen APIs.=0D **/=0D =0D DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", 2, "ARMLTD", "SERIA= L", 1) {=0D @@ -43,17 +44,21 @@ DefinitionBlock ("SsdtSerialPortTemplate.aml", "SSDT", = 2, "ARMLTD", "SERIAL", 1) , // MemoryRangeType=0D // TranslationType=0D ) // QWordMemory=0D - Interrupt (=0D - ResourceConsumer, // ResourceUsage=0D - Level, // EdgeLevel=0D - ActiveHigh, // ActiveLevel=0D - Exclusive, // Shared=0D - , // ResourceSourceIndex=0D - , // ResourceSource=0D - // DescriptorName=0D - ) {=0D - 0xA5 // {template}=0D - } // Interrupt=0D +=0D + // The Interrupt information is generated using AmlCodegen.=0D + //=0D + // Interrupt ( // {codegen}=0D + // ResourceConsumer, // ResourceUsage=0D + // Level, // EdgeLevel=0D + // ActiveHigh, // ActiveLevel=0D + // Exclusive, // Shared=0D + // , // ResourceSourceIndex=0D + // , // ResourceSource=0D + // // DescriptorName=0D + // ) {=0D + // // =0D + // } // Interrupt=0D +=0D }) // Name=0D } // Device=0D } // Scope (_SB)=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113142): https://edk2.groups.io/g/devel/message/113142 Mute This Topic: https://groups.io/mt/103518973/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-