From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 7763A78003C for ; Wed, 19 Jun 2024 22:06:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8VAp8+GHrfbAzq1DhuHDwGR1yd6TUzec0NIGF//rQbY=; 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:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1718834819; v=1; b=mXejXpsw40rdxcdwNYSXvmFUHevv0mTHB0Z98TUMzHhq1MFEo+MLvFVrj1i/jFOUYJRwwHNv 4as4QVdjBLlWa9277EKfQorJsNUTz0qzEMpvGFNjnTGtwr9M+TcpKN2CGvygq2ND2/W5h+3sHCL 53EIRBziotM2iezKGf77tbF+TptMW5XpzzpBlUiA32cdtdIA28Hp1PdpcN0LvAgtdhi+1kmMNLm ZuaBCdNrKHyrRXrNiW6PcaW4O5fin6u80nD/znX4y/OFMAhKSt/XyJlftfK62qRHBmnp09TYaf5 y46OH33IE7V6Vr4LxZ0quwYw5RL+RI1TEJA6RhbeLT1tQ== X-Received: by 127.0.0.2 with SMTP id LUgCYY7687511xO1i2awBnTg; Wed, 19 Jun 2024 15:06:57 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.33989.1718834817231727213 for ; Wed, 19 Jun 2024 15:06:57 -0700 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 9CF58DA7; Wed, 19 Jun 2024 15:07:21 -0700 (PDT) X-Received: from e126645.home (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 756C73F64C; Wed, 19 Jun 2024 15:06:54 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , AbdulLateef Attar , Girish Mahadevan , Jeff Brasen , Jeshua Smith , Leif Lindholm , Meenakshi Aggarwal , Sami Mujawar , Sunil V L , Yeo Reum Yun Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 04/15] DynamicTablesPkg: AcpiDbg2Lib: Prepare to support other archs Date: Thu, 20 Jun 2024 00:06:18 +0200 Message-Id: <20240619220629.1994362-5-pierre.gondois@arm.com> In-Reply-To: <20240619220629.1994362-1-pierre.gondois@arm.com> References: <20240619220629.1994362-1-pierre.gondois@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 Resent-Date: Wed, 19 Jun 2024 15:06:57 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: gJd9mHitMCS6aCdaGGErTR7lx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=mXejXpsw; 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 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Allow other architectures to reuse the AcpiDbg2Lib by extracting the Arm specific part of the table generation. Signed-off-by: Pierre Gondois --- .../Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf | 7 ++ .../Common/AcpiDbg2Lib/Arm/ArmDbg2Generator.c | 67 +++++++++++++++++++ .../AcpiDbg2Lib/Common/CommonDbg2Generator.c | 59 ++++++++++++++++ .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c | 24 +++++-- .../Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h | 56 ++++++++++++++++ 5 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/Ar= mDbg2Generator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common= /CommonDbg2Generator.c create mode 100644 DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Ge= nerator.h diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.i= nf b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf index 32dcd20c082b..1e0ce347c0fa 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/AcpiDbg2Lib.inf @@ -18,6 +18,13 @@ [Defines] =0D [Sources]=0D Dbg2Generator.c=0D + Dbg2Generator.h=0D +=0D +[Sources.ARM, Sources.AARCH64]=0D + Arm/ArmDbg2Generator.c=0D +=0D +[Sources.IA32, Sources.X86]=0D + Common/CommonDbg2Generator.c=0D =0D [Packages.ARM, Packages.AARCH64]=0D ArmPlatformPkg/ArmPlatformPkg.dec=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Ge= nerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Gen= erator.c new file mode 100644 index 000000000000..a063f49829e5 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Arm/ArmDbg2Generator= .c @@ -0,0 +1,67 @@ +/** @file=0D + Arm DBG2 Table Generator=0D +=0D + Copyright (c) 2024, Arm Limited. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.= =0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include "Dbg2Generator.h"=0D +=0D +/**=0D + Initialise the serial port to the specified settings.=0D + The serial port is re-configured only if the specified settings=0D + are different from the current settings.=0D + All unspecified settings will be set to the default values.=0D +=0D + @param SerialPortInfo CM_ARCH_COMMON_SERIAL_PORT_INFO object d= escribing=0D + the serial port.=0D + @param BaudRate The baud rate of the serial device. If t= he=0D + baud rate is not supported, the speed wi= ll be=0D + reduced to the nearest supported one and= the=0D + variable's value will be updated accordi= ngly.=0D + @param ReceiveFifoDepth The number of characters the device will= =0D + buffer on input. Value of 0 will use th= e=0D + device's default FIFO depth.=0D + @param Parity If applicable, this is the EFI_PARITY_TY= PE=0D + that is computed or checked as each char= acter=0D + is transmitted or received. If the devic= e=0D + does not support parity, the value is th= e=0D + default parity value.=0D + @param DataBits The number of data bits in each characte= r.=0D + @param StopBits If applicable, the EFI_STOP_BITS_TYPE nu= mber=0D + of stop bits per character.=0D + If the device does not support stop bits= , the=0D + value is the default stop bit value.=0D +=0D + @retval RETURN_SUCCESS All attributes were set correctly on t= he=0D + serial device.=0D + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an=0D + unsupported value.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +Dbg2InitializePort (=0D + IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo,=0D + IN OUT UINT64 *BaudRate,=0D + IN OUT UINT32 *ReceiveFifoDepth,=0D + IN OUT EFI_PARITY_TYPE *Parity,=0D + IN OUT UINT8 *DataBits,=0D + IN OUT EFI_STOP_BITS_TYPE *StopBits=0D + )=0D +{=0D + return PL011UartInitializePort (=0D + (UINTN)SerialPortInfo->BaseAddress,=0D + SerialPortInfo->Clock,=0D + BaudRate,=0D + ReceiveFifoDepth,=0D + Parity,=0D + DataBits,=0D + StopBits=0D + );=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/Common= Dbg2Generator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/C= ommonDbg2Generator.c new file mode 100644 index 000000000000..936f3ca46604 --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Common/CommonDbg2Gen= erator.c @@ -0,0 +1,59 @@ +/** @file=0D + Common DBG2 Table Generator=0D +=0D + Copyright (c) 2024, Arm Limited. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.= =0D +**/=0D +=0D +#include =0D +#include =0D +#include "Dbg2Generator.h"=0D +=0D +/**=0D + Initialise the serial port to the specified settings.=0D + The serial port is re-configured only if the specified settings=0D + are different from the current settings.=0D + All unspecified settings will be set to the default values.=0D +=0D + @param SerialPortInfo CM_ARCH_COMMON_SERIAL_PORT_INFO object d= escribing=0D + the serial port.=0D + @param BaudRate The baud rate of the serial device. If t= he=0D + baud rate is not supported, the speed wi= ll be=0D + reduced to the nearest supported one and= the=0D + variable's value will be updated accordi= ngly.=0D + @param ReceiveFifoDepth The number of characters the device will= =0D + buffer on input. Value of 0 will use th= e=0D + device's default FIFO depth.=0D + @param Parity If applicable, this is the EFI_PARITY_TY= PE=0D + that is computed or checked as each char= acter=0D + is transmitted or received. If the devic= e=0D + does not support parity, the value is th= e=0D + default parity value.=0D + @param DataBits The number of data bits in each characte= r.=0D + @param StopBits If applicable, the EFI_STOP_BITS_TYPE nu= mber=0D + of stop bits per character.=0D + If the device does not support stop bits= , the=0D + value is the default stop bit value.=0D +=0D + @retval RETURN_SUCCESS All attributes were set correctly on t= he=0D + serial device.=0D + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an=0D + unsupported value.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +Dbg2InitializePort (=0D + IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo,=0D + IN OUT UINT64 *BaudRate,=0D + IN OUT UINT32 *ReceiveFifoDepth,=0D + IN OUT EFI_PARITY_TYPE *Parity,=0D + IN OUT UINT8 *DataBits,=0D + IN OUT EFI_STOP_BITS_TYPE *StopBits=0D + )=0D +{=0D + // Nothing to do.=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator= .c b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c index fbf2ba37331d..6f49e6a27053 100644 --- a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.c @@ -14,7 +14,6 @@ #include =0D #include =0D #include =0D -#include =0D #include =0D #include =0D =0D @@ -26,9 +25,11 @@ #include =0D #include =0D =0D +#include "Dbg2Generator.h"=0D +=0D /** ARM standard DBG2 Table Generator=0D =0D - Constructs the DBG2 table for PL011 or SBSA UART peripherals.=0D + Constructs the DBG2 table for corresponding DBG2 peripheral.=0D =0D Requirements:=0D The following Configuration Manager Object(s) are required by=0D @@ -169,7 +170,7 @@ DBG2_TABLE AcpiDbg2 =3D { DBG2_DEBUG_PORT_DDI (=0D 0, // {Template}: Serial Port Subtype=0D 0, // {Template}: Serial Port Base Address=0D - PL011_UART_LENGTH,=0D + 0, // {Template}: Serial Port Base Address Size=0D NAMESPACE_STR_DBG_PORT0=0D )=0D }=0D @@ -186,7 +187,7 @@ GET_OBJECT_LIST ( CM_ARCH_COMMON_SERIAL_PORT_INFO=0D );=0D =0D -/** Initialize the PL011/SBSA UART with the parameters obtained from=0D +/** Initialize the DBG2 UART with the parameters obtained from=0D the Configuration Manager.=0D =0D @param [in] SerialPortInfo Pointer to the Serial Port Information.=0D @@ -218,9 +219,8 @@ SetupDebugUart ( StopBits =3D (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultSto= pBits);=0D =0D BaudRate =3D SerialPortInfo->BaudRate;=0D - Status =3D PL011UartInitializePort (=0D - (UINTN)SerialPortInfo->BaseAddress,=0D - SerialPortInfo->Clock,=0D + Status =3D Dbg2InitializePort (=0D + SerialPortInfo,=0D &BaudRate,=0D &ReceiveFifoDepth,=0D &Parity,=0D @@ -460,6 +460,9 @@ BuildDbg2TableEx ( (SerialPortInfo->PortSubtype =3D=3D=0D EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART))=0D {=0D + // Setup the PL011 length.=0D + AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].AddressSize =3D PL011_UART_LE= NGTH;=0D +=0D // Initialize the serial port=0D Status =3D SetupDebugUart (SerialPortInfo);=0D if (EFI_ERROR (Status)) {=0D @@ -470,6 +473,13 @@ BuildDbg2TableEx ( ));=0D goto error_handler;=0D }=0D + } else if ((SerialPortInfo->PortSubtype =3D=3D=0D + EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_16550_WITH_GAS))=0D + {=0D + AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].AddressSize =3D SIZE_4KB;=0D + } else {=0D + // Try to catch other serial ports, but don't return an error.=0D + ASSERT (0);=0D }=0D =0D TableList[0] =3D (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiDbg2;=0D diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator= .h b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h new file mode 100644 index 000000000000..5424be47b8ec --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiDbg2Lib/Dbg2Generator.h @@ -0,0 +1,56 @@ +/** @file=0D + DBG2 Table Generator=0D +=0D + Copyright (c) 2024, Arm Limited. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Reference(s):=0D + - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.= =0D +**/=0D +=0D +#ifndef DBG2_GENERATOR_H_=0D +#define DBG2_GENERATOR_H_=0D +=0D +/**=0D + Initialise the serial port to the specified settings.=0D + The serial port is re-configured only if the specified settings=0D + are different from the current settings.=0D + All unspecified settings will be set to the default values.=0D +=0D + @param SerialPortInfo CM_ARCH_COMMON_SERIAL_PORT_INFO object d= escribing=0D + the serial port.=0D + @param BaudRate The baud rate of the serial device. If t= he=0D + baud rate is not supported, the speed wi= ll be=0D + reduced to the nearest supported one and= the=0D + variable's value will be updated accordi= ngly.=0D + @param ReceiveFifoDepth The number of characters the device will= =0D + buffer on input. Value of 0 will use th= e=0D + device's default FIFO depth.=0D + @param Parity If applicable, this is the EFI_PARITY_TY= PE=0D + that is computed or checked as each char= acter=0D + is transmitted or received. If the devic= e=0D + does not support parity, the value is th= e=0D + default parity value.=0D + @param DataBits The number of data bits in each characte= r.=0D + @param StopBits If applicable, the EFI_STOP_BITS_TYPE nu= mber=0D + of stop bits per character.=0D + If the device does not support stop bits= , the=0D + value is the default stop bit value.=0D +=0D + @retval RETURN_SUCCESS All attributes were set correctly on t= he=0D + serial device.=0D + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an=0D + unsupported value.=0D +**/=0D +RETURN_STATUS=0D +EFIAPI=0D +Dbg2InitializePort (=0D + IN CONST CM_ARCH_COMMON_SERIAL_PORT_INFO *SerialPortInfo,=0D + IN OUT UINT64 *BaudRate,=0D + IN OUT UINT32 *ReceiveFifoDepth,=0D + IN OUT EFI_PARITY_TYPE *Parity,=0D + IN OUT UINT8 *DataBits,=0D + IN OUT EFI_STOP_BITS_TYPE *StopBits=0D + );=0D +=0D +#endif // DBG2_GENERATOR_H_=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119636): https://edk2.groups.io/g/devel/message/119636 Mute This Topic: https://groups.io/mt/106770155/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-