From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109391+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109391+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779563; cv=none; d=zohomail.com; s=zohoarc; b=IuPS/IESGt1HCzoO1VGSB/2rPPA7YeFyK4q6LUHoikM0yecdD6Ae3meIWO+u2/0lY4BrZzorNSKwLwAGSam5hIsuO05Kt7yWhKFsOEy3EnxRByDMqr4Pm3c4WytTucADx5E4h0KkeUrFlRqv0Iwn6eQXJJ2xcr+OjvkT8AdUfDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779563; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=eUgb8RpWdc6UgwLrBKo5OfQAWsS8hx4NSX868x8A458=; b=ejAF2hKDALmintJIa95ipzWKuwI2MswiCF9DPha11YGn1qw5Yj4fjsRaIPqnrMTkseLAhTO5cVnvo+H3bj9kuTcaoszucacN04sj4Uw+nafu4s7lk+B1zfJhy5COnYs5nyHgW/g0239damftda0Wztca2RsNQKR0forzDsKO2HQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109391+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779563286275.9195672081295; Sun, 8 Oct 2023 08:39:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=eUgb8RpWdc6UgwLrBKo5OfQAWsS8hx4NSX868x8A458=; 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:Content-Type; s=20140610; t=1696779562; v=1; b=NEv9a6yyb8S0RIj7HUa/LcT7MU7EQNTvtn1nmgdwZCXWx1L/bsmlUTzlrMI8D2ZfXjG647PZ DJIelhzdG4TY6FMdSl6TroBWvBuK2oeOqbFb8+MZ/VRp5v5NbtEHqsocXTdVN4IdnpSJrRmipBb 0Hx3K26lsJo1+SSkUJnxRbKs= X-Received: by 127.0.0.2 with SMTP id 55knYY1788612xcGocuNczvT; Sun, 08 Oct 2023 08:39:22 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.40261.1696779562218248116 for ; Sun, 08 Oct 2023 08:39:22 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-6hLtT2AwPOilZ28pzZyqhQ-1; Sun, 08 Oct 2023 11:39:17 -0400 X-MC-Unique: 6hLtT2AwPOilZ28pzZyqhQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5608585A5BF; Sun, 8 Oct 2023 15:39:17 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39CB849BB9A; Sun, 8 Oct 2023 15:39:16 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 1/9] ArmVirtPkg: introduce FdtSerialPortAddressLib Date: Sun, 8 Oct 2023 17:39:04 +0200 Message-Id: <20231008153912.175941-2-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Jsxe0BoIIYzr7eUChicso2wdx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779564886100004 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce a new library class + instance for: - collecting serial port base addresses from the device tree, - collecting the /chosen stdout-path serial port base address from the device tree. The logic is loosely based on the following functions: - SerialPortGetBaseAddress() [ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c] - PlatformPeim() [ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c] - GetSerialConsolePortAddress() [ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHook= Lib.c] which are going to be converted to clients of the new library later. Copyright notices from those other files are preserved. The new library fixes the following warts, found by reading the existent code: - Neither of the three functions check whether the "reg" property exists. (This may be implicitly checked when they compare the property size to 16.) - GetSerialConsolePortAddress() uses ScanMem8() for locating a colon (":") node path separator in "stdout-path", when AsciiStrStr() could work just as fine. While ScanMem8() is likely faster, "stdout-path" is presumably very short, and ScanMem8() introduces an extra lib class dependency (namely BaseMemoryLib). - If ScanMem8() fails to locate a colon in "stdout-path", then GetSerialConsolePortAddress() re-measures the length of the whole "stdout-path" property. This is conceptually (if not performance-wise) disturbing, because we know the whole size of the "stdout-path" property from the property lookup just before, so we only need to subtract the NUL-terminator for learning the length. - GetSerialConsolePortAddress() does not check if the first (or only) node path inside the "stdout-path" property is empty. (Not a big deal, the subsequent alias resolution should simply fail.) - GetSerialConsolePortAddress() does not verify if the node path retrieved (and potentially alias-resolved) from "stdout-path" can be located in the device tree; it assumes it. - Code is duplicated (of course) between SerialPortGetBaseAddress() and PlatformPeim(), but more surprisingly, all three functions embed the same code for verifying the "status" property of the serial port node, and for checking and reading its "reg" property. Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirtPkg.dec | = 1 + ArmVirtPkg/ArmVirt.dsc.inc | = 1 + ArmVirtPkg/Include/Library/FdtSerialPortAddressLib.h | = 83 +++++++ ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.inf | = 27 +++ ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.c | 2= 56 ++++++++++++++++++++ 5 files changed, 368 insertions(+) diff --git a/ArmVirtPkg/ArmVirtPkg.dec b/ArmVirtPkg/ArmVirtPkg.dec index 4645c91a8375..0f2d7873279f 100644 --- a/ArmVirtPkg/ArmVirtPkg.dec +++ b/ArmVirtPkg/ArmVirtPkg.dec @@ -27,6 +27,7 @@ [Includes.common] =20 [LibraryClasses] ArmVirtMemInfoLib|Include/Library/ArmVirtMemInfoLib.h + FdtSerialPortAddressLib|Include/Library/FdtSerialPortAddressLib.h =20 [Guids.common] gArmVirtTokenSpaceGuid =3D { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0= x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } } diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 3f7bac6bf33a..0d7115525497 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -121,6 +121,7 @@ [LibraryClasses.common] # ARM PL011 UART Driver PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPor= tLib.inf + FdtSerialPortAddressLib|ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSe= rialPortAddressLib.inf =20 PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCof= fExtraActionLib.inf #PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePe= CoffExtraActionLibNull.inf diff --git a/ArmVirtPkg/Include/Library/FdtSerialPortAddressLib.h b/ArmVirt= Pkg/Include/Library/FdtSerialPortAddressLib.h new file mode 100644 index 000000000000..3d4c911f58aa --- /dev/null +++ b/ArmVirtPkg/Include/Library/FdtSerialPortAddressLib.h @@ -0,0 +1,83 @@ +/** @file + Determine the base addresses of serial ports from the Device Tree. + + Copyright (C) Red Hat + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef FDT_SERIAL_PORT_ADDRESS_LIB_H_ +#define FDT_SERIAL_PORT_ADDRESS_LIB_H_ + +#include + +typedef struct { + UINTN NumberOfPorts; + UINT64 BaseAddress[2]; +} FDT_SERIAL_PORTS; + +/** + Collect the first ARRAY_SIZE (Ports->BaseAddress) serial ports into Port= s from + DeviceTree. + + @param[in] DeviceTree The flat device tree (FDT) to scan. + + @param[in] Compatible Look for Compatible in the "compatible" property = of the + scanned nodes. + + @param[out] Ports On successful return, Ports->NumberOfPorts contai= ns the + number of serial ports found; it is (a) positive = and + (b) at most ARRAY_SIZE (Ports->BaseAddress). If t= he FDT + had more serial ports, those are not reported. On + error, the contents of Ports are indeterminate. + + @retval RETURN_INVALID_PARAMETER DeviceTree does not point to a valid F= DT + header. + + @retval RETURN_NOT_FOUND No compatible and enabled serial port = has + been found. + + @retval RETURN_SUCCESS At least one compatible and enabled se= rial + port has been found; Ports has been fi= lled + in. +**/ +RETURN_STATUS +EFIAPI +FdtSerialGetPorts ( + IN CONST VOID *DeviceTree, + IN CONST CHAR8 *Compatible, + OUT FDT_SERIAL_PORTS *Ports + ); + +/** + Fetch the base address of the serial port identified in the "stdout-path" + property of the "/chosen" node in DeviceTree. + + @param[in] DeviceTree The flat device tree (FDT) to scan. + + @param[out] BaseAddress On success, the base address of the preferred s= erial + port (to be used as console). On error, BaseAdd= ress + is not modified. + + @retval RETURN_INVALID_PARAMETER DeviceTree does not point to a valid F= DT + header. + + @retval RETURN_NOT_FOUND No enabled console port has been found. + + @retval RETURN_PROTOCOL_ERROR The first (or only) node path in the + "stdout-path" property is an empty str= ing. + + @retval RETURN_PROTOCOL_ERROR The console port has been found in the= FDT, + but its base address is not correctly + represented. + + @retval RETURN_SUCCESS BaseAddress has been populated. +**/ +RETURN_STATUS +EFIAPI +FdtSerialGetConsolePort ( + IN CONST VOID *DeviceTree, + OUT UINT64 *BaseAddress + ); + +#endif diff --git a/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddres= sLib.inf b/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressL= ib.inf new file mode 100644 index 000000000000..ae6d0d374b80 --- /dev/null +++ b/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.inf @@ -0,0 +1,27 @@ +## @file +# Determine the base addresses of serial ports from the Device Tree. +# +# Copyright (C) Red Hat +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D FdtSerialPortAddressLib + FILE_GUID =3D AEBE813B-25EA-40E5-95C4-2B864FE1E951 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FdtSerialPortAddressLib + +[Sources] + FdtSerialPortAddressLib.c + +[Packages] + ArmVirtPkg/ArmVirtPkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + FdtLib diff --git a/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddres= sLib.c b/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib= .c new file mode 100644 index 000000000000..f6508e09898a --- /dev/null +++ b/ArmVirtPkg/Library/FdtSerialPortAddressLib/FdtSerialPortAddressLib.c @@ -0,0 +1,256 @@ +/** @file + Determine the base addresses of serial ports from the Device Tree. + + Copyright (C) Red Hat + Copyright (c) 2011 - 2023, Arm Ltd. All rights reserved.
+ Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+ Copyright (c) 2014 - 2020, Linaro Ltd. All rights reserved.
+ Copyright (c) 2015, Intel Corporation. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include + +/** + Read the "reg" property of Node in DeviceTree as a UINT64 base address. + + @param[in] DeviceTree The flat device tree (FDT) to scan. + + @param[in] Node The node to read the "reg" property of. + + @param[out] BaseAddress On success, the base address read out of Node's= "reg" + property. On error, not modified. + + @retval RETURN_DEVICE_ERROR Node has a "status" property with value + different from "okay". + + @retval RETURN_NOT_FOUND Node does not have a "reg" property. + + @retval RETURN_BAD_BUFFER_SIZE The size of Node's "reg" property is not= 16 + bytes. + + @retval RETURN_SUCCESS BaseAddress has been populated. +**/ +STATIC +RETURN_STATUS +GetBaseAddress ( + IN CONST VOID *DeviceTree, + IN INT32 Node, + OUT UINT64 *BaseAddress + ) +{ + CONST CHAR8 *NodeStatus; + CONST VOID *RegProp; + INT32 PropSize; + + NodeStatus =3D fdt_getprop (DeviceTree, Node, "status", NULL); + if ((NodeStatus !=3D NULL) && (AsciiStrCmp (NodeStatus, "okay") !=3D 0))= { + return RETURN_DEVICE_ERROR; + } + + RegProp =3D fdt_getprop (DeviceTree, Node, "reg", &PropSize); + if (RegProp =3D=3D NULL) { + return RETURN_NOT_FOUND; + } + + if (PropSize !=3D 16) { + return RETURN_BAD_BUFFER_SIZE; + } + + *BaseAddress =3D fdt64_to_cpu (ReadUnaligned64 (RegProp)); + return RETURN_SUCCESS; +} + +/** + Collect the first ARRAY_SIZE (Ports->BaseAddress) serial ports into Port= s from + DeviceTree. + + @param[in] DeviceTree The flat device tree (FDT) to scan. + + @param[in] Compatible Look for Compatible in the "compatible" property = of the + scanned nodes. + + @param[out] Ports On successful return, Ports->NumberOfPorts contai= ns the + number of serial ports found; it is (a) positive = and + (b) at most ARRAY_SIZE (Ports->BaseAddress). If t= he FDT + had more serial ports, those are not reported. On + error, the contents of Ports are indeterminate. + + @retval RETURN_INVALID_PARAMETER DeviceTree does not point to a valid F= DT + header. + + @retval RETURN_NOT_FOUND No compatible and enabled serial port = has + been found. + + @retval RETURN_SUCCESS At least one compatible and enabled se= rial + port has been found; Ports has been fi= lled + in. +**/ +RETURN_STATUS +EFIAPI +FdtSerialGetPorts ( + IN CONST VOID *DeviceTree, + IN CONST CHAR8 *Compatible, + OUT FDT_SERIAL_PORTS *Ports + ) +{ + INT32 Node; + + if (fdt_check_header (DeviceTree) !=3D 0) { + return RETURN_INVALID_PARAMETER; + } + + Ports->NumberOfPorts =3D 0; + Node =3D fdt_next_node (DeviceTree, 0, NULL); + while ((Node > 0) && + (Ports->NumberOfPorts < ARRAY_SIZE (Ports->BaseAddress))) + { + CONST CHAR8 *CompatProp; + INT32 PropSize; + + CompatProp =3D fdt_getprop (DeviceTree, Node, "compatible", &PropSize); + if (CompatProp !=3D NULL) { + CONST CHAR8 *CompatItem; + + CompatItem =3D CompatProp; + while ((CompatItem < CompatProp + PropSize) && + (AsciiStrCmp (CompatItem, Compatible) !=3D 0)) + { + CompatItem +=3D AsciiStrLen (CompatItem) + 1; + } + + if (CompatItem < CompatProp + PropSize) { + RETURN_STATUS Status; + UINT64 BaseAddress; + + Status =3D GetBaseAddress (DeviceTree, Node, &BaseAddress); + if (!RETURN_ERROR (Status)) { + Ports->BaseAddress[Ports->NumberOfPorts++] =3D BaseAddress; + } + } + } + + Node =3D fdt_next_node (DeviceTree, Node, NULL); + } + + return Ports->NumberOfPorts > 0 ? RETURN_SUCCESS : RETURN_NOT_FOUND; +} + +/** + Fetch the base address of the serial port identified in the "stdout-path" + property of the "/chosen" node in DeviceTree. + + @param[in] DeviceTree The flat device tree (FDT) to scan. + + @param[out] BaseAddress On success, the base address of the preferred s= erial + port (to be used as console). On error, BaseAdd= ress + is not modified. + + @retval RETURN_INVALID_PARAMETER DeviceTree does not point to a valid F= DT + header. + + @retval RETURN_NOT_FOUND No enabled console port has been found. + + @retval RETURN_PROTOCOL_ERROR The first (or only) node path in the + "stdout-path" property is an empty str= ing. + + @retval RETURN_PROTOCOL_ERROR The console port has been found in the= FDT, + but its base address is not correctly + represented. + + @retval RETURN_SUCCESS BaseAddress has been populated. +**/ +RETURN_STATUS +EFIAPI +FdtSerialGetConsolePort ( + IN CONST VOID *DeviceTree, + OUT UINT64 *BaseAddress + ) +{ + INT32 ChosenNode; + CONST CHAR8 *StdoutPathProp; + INT32 PropSize; + CONST CHAR8 *StdoutPathEnd; + UINTN StdoutPathLength; + INT32 ConsoleNode; + RETURN_STATUS Status; + + if (fdt_check_header (DeviceTree) !=3D 0) { + return RETURN_INVALID_PARAMETER; + } + + ChosenNode =3D fdt_path_offset (DeviceTree, "/chosen"); + if (ChosenNode < 0) { + return RETURN_NOT_FOUND; + } + + StdoutPathProp =3D fdt_getprop ( + DeviceTree, + ChosenNode, + "stdout-path", + &PropSize + ); + if (StdoutPathProp =3D=3D NULL) { + return RETURN_NOT_FOUND; + } + + // + // If StdoutPathProp contains a colon (":"), then the colon terminates t= he + // path we're interested in. + // + StdoutPathEnd =3D AsciiStrStr (StdoutPathProp, ":"); + if (StdoutPathEnd =3D=3D NULL) { + StdoutPathLength =3D PropSize - 1; + } else { + StdoutPathLength =3D StdoutPathEnd - StdoutPathProp; + } + + if (StdoutPathLength =3D=3D 0) { + return RETURN_PROTOCOL_ERROR; + } + + if (StdoutPathProp[0] =3D=3D '/') { + // + // StdoutPathProp starts with an absolute node path. + // + ConsoleNode =3D fdt_path_offset_namelen ( + DeviceTree, + StdoutPathProp, + (INT32)StdoutPathLength + ); + } else { + // + // StdoutPathProp starts with an alias. + // + CONST CHAR8 *ResolvedStdoutPath; + + ResolvedStdoutPath =3D fdt_get_alias_namelen ( + DeviceTree, + StdoutPathProp, + (INT32)StdoutPathLength + ); + if (ResolvedStdoutPath =3D=3D NULL) { + return RETURN_NOT_FOUND; + } + + ConsoleNode =3D fdt_path_offset (DeviceTree, ResolvedStdoutPath); + } + + if (ConsoleNode < 0) { + return RETURN_NOT_FOUND; + } + + Status =3D GetBaseAddress (DeviceTree, ConsoleNode, BaseAddress); + switch (Status) { + case RETURN_NOT_FOUND: + case RETURN_BAD_BUFFER_SIZE: + return RETURN_PROTOCOL_ERROR; + case RETURN_SUCCESS: + return RETURN_SUCCESS; + default: + return RETURN_NOT_FOUND; + } +} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109391): https://edk2.groups.io/g/devel/message/109391 Mute This Topic: https://groups.io/mt/101834875/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109400+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109400+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779574; cv=none; d=zohomail.com; s=zohoarc; b=hZvMe+b/3FkgBOifSkNOMGCTK1c449gaXGR8M5x5Twam4pv/c4qVMmVQ6lWGarIuJpsx8RPXuqF8ihTuT/0hmeb6MhhiDGw/HEypzYS7d0OQ80A/KoB4g9WKJ9Bbj7wYw4LQUr4Awvz7fWe81ixanMKlzl+VQt4jqSTBL2pm43g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779574; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=FVhxwGbuXQ/j6GdlYaCnJuy2iEShah+d6X0fpa7xIrY=; b=f+nRHAoUg4kAeUvKnox0rnmY2jZF6gHA82SCjJtbcV2+QibIstKmSQWyeh7XOWXR8sP+qtanEAE9J9x+EASlywiNRw/8C6avuHWn4N1I4FbDkCSoJq5tqLRE57s8fwk9R7U+OfQWzpS6dTfllCg9SAKbq2afv4Nts6u6P8k/4KA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109400+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779574500462.28963326165865; Sun, 8 Oct 2023 08:39:34 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=FVhxwGbuXQ/j6GdlYaCnJuy2iEShah+d6X0fpa7xIrY=; 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:Content-Type; s=20140610; t=1696779574; v=1; b=qeowPHgZJyd++QWlG0k4uDoQ7SddXuYJpPra2CIa6xIQFlDQxCt8KfaeI5LG2GxkD4vNjitJ tzOVV+9e6T9A0cXd/IJjl/yOYo2M14jth76THuy0/Qb2BlruoN7l6MDmI0asY/hxaC5T7LzJZLE wy7MpPUWtfw3tcfZnjRem2v8= X-Received: by 127.0.0.2 with SMTP id pycqYY1788612xe4qlKaupW3; Sun, 08 Oct 2023 08:39:34 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.40421.1696779573038207278 for ; Sun, 08 Oct 2023 08:39:33 -0700 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-sZOcZS3GMpaMIzgY7VPKiQ-1; Sun, 08 Oct 2023 11:39:19 -0400 X-MC-Unique: sZOcZS3GMpaMIzgY7VPKiQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC1553C176E1; Sun, 8 Oct 2023 15:39:18 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF69F492B05; Sun, 8 Oct 2023 15:39:17 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 2/9] ArmVirtPkg/Fdt16550SerialPortHookLib: rebase to FdtSerialPortAddressLib Date: Sun, 8 Oct 2023 17:39:05 +0200 Message-Id: <20231008153912.175941-3-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: y7Rc9MngkYvbdq4K2kyYbgaox1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779575117100023 Content-Type: text/plain; charset="utf-8"; x-default="true" This is only a refactoring; the patch is not supposed to cause any observable change. Build-tested only (with "ArmVirtKvmTool.dsc"). Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.inf | 3 +- ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLi= b.c | 88 +------------------- 2 files changed, 4 insertions(+), 87 deletions(-) diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.inf b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16= 550SerialPortHookLib.inf index 007a45eca2a6..22aba53d9b48 100644 --- a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.inf +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.inf @@ -22,12 +22,11 @@ [Sources] [LibraryClasses] BaseLib PcdLib - FdtLib + FdtSerialPortAddressLib HobLib =20 [Packages] ArmVirtPkg/ArmVirtPkg.dec - EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec MdePkg/MdePkg.dec =20 diff --git a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550Seri= alPortHookLib.c b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt1655= 0SerialPortHookLib.c index c1b81920214b..03d28b9282ea 100644 --- a/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.c +++ b/ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortH= ookLib.c @@ -17,90 +17,7 @@ #include #include #include -#include - -/** Get the UART base address of the console serial-port from the DT. - - This function fetches the node referenced in the "stdout-path" - property of the "chosen" node and returns the base address of - the console UART. - - @param [in] Fdt Pointer to a Flattened Device Tree (= Fdt). - @param [out] SerialConsoleAddress If success, contains the base address - of the console serial-port. - - @retval EFI_SUCCESS The function completed successfully. - @retval EFI_NOT_FOUND Console serial-port info not found in DT. - @retval EFI_INVALID_PARAMETER Invalid parameter. -**/ -STATIC -EFI_STATUS -EFIAPI -GetSerialConsolePortAddress ( - IN CONST VOID *Fdt, - OUT UINT64 *SerialConsoleAddress - ) -{ - CONST CHAR8 *Prop; - INT32 PropSize; - CONST CHAR8 *Path; - INT32 PathLen; - INT32 ChosenNode; - INT32 SerialConsoleNode; - INT32 Len; - CONST CHAR8 *NodeStatus; - CONST UINT64 *RegProperty; - - if ((Fdt =3D=3D NULL) || (fdt_check_header (Fdt) !=3D 0)) { - return EFI_INVALID_PARAMETER; - } - - // The "chosen" node resides at the root of the DT. Fetch it. - ChosenNode =3D fdt_path_offset (Fdt, "/chosen"); - if (ChosenNode < 0) { - return EFI_NOT_FOUND; - } - - Prop =3D fdt_getprop (Fdt, ChosenNode, "stdout-path", &PropSize); - if (PropSize < 0) { - return EFI_NOT_FOUND; - } - - // Determine the actual path length, as a colon terminates the path. - Path =3D ScanMem8 (Prop, PropSize, ':'); - if (Path =3D=3D NULL) { - PathLen =3D AsciiStrLen (Prop); - } else { - PathLen =3D Path - Prop; - } - - // Aliases cannot start with a '/', so it must be the actual path. - if (Prop[0] =3D=3D '/') { - SerialConsoleNode =3D fdt_path_offset_namelen (Fdt, Prop, PathLen); - } else { - // Lookup the alias, as this contains the actual path. - Path =3D fdt_get_alias_namelen (Fdt, Prop, PathLen); - if (Path =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - SerialConsoleNode =3D fdt_path_offset (Fdt, Path); - } - - NodeStatus =3D fdt_getprop (Fdt, SerialConsoleNode, "status", &Len); - if ((NodeStatus !=3D NULL) && (AsciiStrCmp (NodeStatus, "okay") !=3D 0))= { - return EFI_NOT_FOUND; - } - - RegProperty =3D fdt_getprop (Fdt, SerialConsoleNode, "reg", &Len); - if (Len !=3D 16) { - return EFI_INVALID_PARAMETER; - } - - *SerialConsoleAddress =3D fdt64_to_cpu (ReadUnaligned64 (RegProperty)); - - return EFI_SUCCESS; -} +#include =20 /** Platform hook to retrieve the 16550 UART base address from the platform Device tree and store it in PcdSerialRegisterBase. @@ -108,6 +25,7 @@ GetSerialConsolePortAddress ( @retval RETURN_SUCCESS Success. @retval RETURN_INVALID_PARAMETER A parameter was invalid. @retval RETURN_NOT_FOUND Serial port information not found. + @retval RETURN_PROTOCOL_ERROR Invalid information in the Device Tree. =20 **/ RETURN_STATUS @@ -129,7 +47,7 @@ PlatformHookSerialPortInitialize ( return RETURN_NOT_FOUND; } =20 - Status =3D GetSerialConsolePortAddress (DeviceTreeBase, &SerialConsoleAd= dress); + Status =3D FdtSerialGetConsolePort (DeviceTreeBase, &SerialConsoleAddres= s); if (RETURN_ERROR (Status)) { return Status; } -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109400): https://edk2.groups.io/g/devel/message/109400 Mute This Topic: https://groups.io/mt/101834887/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109392+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109392+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779563; cv=none; d=zohomail.com; s=zohoarc; b=cn/3oyMGheqxRFpYqandZ8fpeBAQuudgV7fhbobSDE/sbGPuCkPTticefMemFGE60KFNg/SJT6A6LfcbDjTfb0EqC6OMmKXeLA9+AfJixITieOYsP/q+1nC08w0I3AX0SlHldqC1/EgiAw8sSn88X58tbVp7xqzSH0rcAR3dzU8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779563; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=40m24cfXTFUY953f+W46bIgOYiFQ3xzuW4KSo/N2Xtk=; b=aBdPgDgigmj2D9wjdlzJqollyBXOWZC69xNco5AfQFgcjWkPQnr/FUVGHFwxGZSwm2hO3q21MrTqZNtaNiO15R74ud4coLahc7VluvxRiw5xCNQG8AJJ6kUCdIiLtZGosQrnJ5T38sZZl5aHgXzkenESPLWwrHA+HyUOnC0zd2E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109392+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779563882643.8779745193148; Sun, 8 Oct 2023 08:39:23 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=40m24cfXTFUY953f+W46bIgOYiFQ3xzuW4KSo/N2Xtk=; 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:Content-Type; s=20140610; t=1696779563; v=1; b=ohWCttfNcfz8ZHwtsNUGsvnqNE2jM0p7cBciCzwrAaJj0ML1uMEd222MdEA7NWZEQ0t2fGOi /aYPwDkiwwFRPXK0u6Y2RuPlbsqDhSosaF2HzJW3s/znWsUDOrUINIrFAVfTwawkPpdUmK8uMK+ wSFflInWrlFFQX9kHgffhDlw= X-Received: by 127.0.0.2 with SMTP id 1JrGYY1788612xFbCpZwP3kR; Sun, 08 Oct 2023 08:39:23 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.40410.1696779562815883106 for ; Sun, 08 Oct 2023 08:39:23 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-684-Qbe7osixP1-mMZWD4at1-A-1; Sun, 08 Oct 2023 11:39:20 -0400 X-MC-Unique: Qbe7osixP1-mMZWD4at1-A-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 245248039C1; Sun, 8 Oct 2023 15:39:20 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 275A2492B05; Sun, 8 Oct 2023 15:39:19 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 3/9] ArmVirtPkg: adjust whitespace in block scope declarations Date: Sun, 8 Oct 2023 17:39:06 +0200 Message-Id: <20231008153912.175941-4-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: XyrDc7gc6EA6fSv5OMFG8hgLx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779564845100003 Content-Type: text/plain; charset="utf-8"; x-default="true" I strongly dislike when *small* local variable declaration changes are muddled by whitespace changes. When that happens, a reviewer can choose from two suboptimal options: display the patch with "git show -b", which creates confusion in *other* parts of the patch, or display the patch with just "git show", which then produces an unjustifiedly large hunk for the sequence of declarations. For avoiding that in subsequent patches, adjust some whitespace in this patch in isolation. Functionally this is a no-op; "git show -b" produces empty output. Note that uncrustify is (of course) unhappy with this patch, but that's fine -- this patch is in the middle of a series, and by the end of the series (which is where uncrustify is run in CI) the whitespace is going to be tight. Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c | 18 ++++= +----- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 38 ++++= ++++++---------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib= .c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c index 9d71f369570f..5718b02977df 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c @@ -44,15 +44,15 @@ SerialPortInitialize ( VOID ) { - VOID *Hob; - RETURN_STATUS Status; - CONST UINT64 *UartBase; - UINTN SerialBaseAddress; - UINT64 BaudRate; - UINT32 ReceiveFifoDepth; - EFI_PARITY_TYPE Parity; - UINT8 DataBits; - EFI_STOP_BITS_TYPE StopBits; + VOID *Hob; + RETURN_STATUS Status; + CONST UINT64 *UartBase; + UINTN SerialBaseAddress; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; =20 if (mSerialBaseAddress !=3D 0) { return RETURN_SUCCESS; diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPk= g/Library/PlatformPeiLib/PlatformPeiLib.c index 8d9dcf504dc6..1b43d77dd120 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -37,25 +37,25 @@ PlatformPeim ( VOID ) { - VOID *Base; - VOID *NewBase; - UINTN FdtSize; - UINTN FdtPages; - UINT64 *FdtHobData; - UINT64 *UartHobData; - INT32 Node, Prev; - INT32 Parent, Depth; - CONST CHAR8 *Compatible; - CONST CHAR8 *CompItem; - CONST CHAR8 *NodeStatus; - INT32 Len; - INT32 RangesLen; - INT32 StatusLen; - CONST UINT64 *RegProp; - CONST UINT32 *RangesProp; - UINT64 UartBase; - UINT64 TpmBase; - EFI_STATUS Status; + VOID *Base; + VOID *NewBase; + UINTN FdtSize; + UINTN FdtPages; + UINT64 *FdtHobData; + UINT64 *UartHobData; + INT32 Node, Prev; + INT32 Parent, Depth; + CONST CHAR8 *Compatible; + CONST CHAR8 *CompItem; + CONST CHAR8 *NodeStatus; + INT32 Len; + INT32 RangesLen; + INT32 StatusLen; + CONST UINT64 *RegProp; + CONST UINT32 *RangesProp; + UINT64 UartBase; + UINT64 TpmBase; + EFI_STATUS Status; =20 Base =3D (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); ASSERT (Base !=3D NULL); -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109392): https://edk2.groups.io/g/devel/message/109392 Mute This Topic: https://groups.io/mt/101834876/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109396+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109396+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779571; cv=none; d=zohomail.com; s=zohoarc; b=DRvFghKjgHtg0lMsoma/9hTxcr9/liiDDg7iuNOwliBcKQcQmfo0oTbU+fjdp0vZt/H7nN2JlcxBXBZkrrdcI1zflXjoAi1w2Qi4Ido9KpLkpVkTtlgHbDp5wnXDefwSKgLp8imiXsTdUUMq+BDOVOtCnN1gphxwmVe1cvcfqF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779571; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=G+ZFQcp0g0sZ7B/5PoxGnRrUpVJioLuEzu1Q5L1i8Ew=; b=e15mq4mIKYujoddRGtN++mDLttAYvlxBv8VH9o4wHMdSIHdu0dPhE30nW3kFr9PgfCWEbwgjJEn4uGB/6pZvomvKkgZ4R+jdGXnKiucA9kENYORnnSHqDqOXqsoYALLt2Qv6sseRxo58CAE9CdyZuZFXdq222Uo7jk/nqQBnk64= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109396+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779571874376.4003454012343; Sun, 8 Oct 2023 08:39:31 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=G+ZFQcp0g0sZ7B/5PoxGnRrUpVJioLuEzu1Q5L1i8Ew=; 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:Content-Type; s=20140610; t=1696779571; v=1; b=kbCfCBYJP/2VIpNNvxR90H2o/g/xwgpx/r91ra1kcphtIBeBkuH95k/09kwUjRZNzFkRozGj VaEYVBdAy3DEAa+BLeNgYm9APl8YoqnA8AElL1wpfzTB+6h9Y8Ny3WOqCcIbcnaLI/MJL1BYEYf LBDwO1jlnHs0YY5wVDRVLe78= X-Received: by 127.0.0.2 with SMTP id LVaSYY1788612xJXoYKnzebC; Sun, 08 Oct 2023 08:39:31 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.40417.1696779570897692815 for ; Sun, 08 Oct 2023 08:39:31 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-5OYe7dgNNqWzFvfRJ_O8AQ-1; Sun, 08 Oct 2023 11:39:21 -0400 X-MC-Unique: 5OYe7dgNNqWzFvfRJ_O8AQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E4E3802C1A; Sun, 8 Oct 2023 15:39:21 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 631F4492B05; Sun, 8 Oct 2023 15:39:20 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 4/9] ArmVirtPkg: adhere to the serial port selected by /chosen "stdout-path" Date: Sun, 8 Oct 2023 17:39:07 +0200 Message-Id: <20231008153912.175941-5-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: I0JrZsx5QrNYPSqhSAb8tpBux1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779572999100012 Content-Type: text/plain; charset="utf-8"; x-default="true" Convert both EarlyFdtPL011SerialPortLib and PlatformPeiLib at the same time to clients of FdtSerialPortAddressLib (so that both "early" and "late" serial output continue going to a common serial port). If the device tree specifies just one serial port, this conversion makes no difference, but if there are multiple ports, the output is written to the port identified by /chosen "stdout-path". In this patch, DebugLib output is not separated yet from the UEFI console. Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf | = 3 +- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf | = 1 + ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c | = 90 +++++++------------- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | = 42 ++++----- 4 files changed, 56 insertions(+), 80 deletions(-) diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPo= rtLib.inf b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPor= tLib.inf index 32b2d337d412..f47692f06a95 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.i= nf +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.i= nf @@ -22,11 +22,10 @@ [Sources.common] [LibraryClasses] PL011UartLib PcdLib - FdtLib + FdtSerialPortAddressLib =20 [Packages] MdePkg/MdePkg.dec - EmbeddedPkg/EmbeddedPkg.dec ArmPlatformPkg/ArmPlatformPkg.dec ArmVirtPkg/ArmVirtPkg.dec =20 diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirt= Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf index 3f97ef080520..08a8f23bb449 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -34,6 +34,7 @@ [LibraryClasses] DebugLib HobLib FdtLib + FdtSerialPortAddressLib PcdLib PeiServicesLib =20 diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPo= rtLib.c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortL= ib.c index c34021243210..dc5459b4ce66 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include =20 RETURN_STATUS EFIAPI @@ -56,74 +56,48 @@ SerialPortGetBaseAddress ( UINT8 DataBits; EFI_STOP_BITS_TYPE StopBits; VOID *DeviceTreeBase; - INT32 Node, Prev; - INT32 Len; - CONST CHAR8 *Compatible; - CONST CHAR8 *NodeStatus; - CONST CHAR8 *CompatibleItem; - CONST UINT64 *RegProperty; - UINTN UartBase; + FDT_SERIAL_PORTS Ports; + UINT64 UartBase; RETURN_STATUS Status; =20 DeviceTreeBase =3D (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddr= ess); =20 - if ((DeviceTreeBase =3D=3D NULL) || (fdt_check_header (DeviceTreeBase) != =3D 0)) { + if (DeviceTreeBase =3D=3D NULL) { + return 0; + } + + Status =3D FdtSerialGetPorts (DeviceTreeBase, "arm,pl011", &Ports); + if (RETURN_ERROR (Status)) { return 0; } =20 // - // Enumerate all FDT nodes looking for a PL011 and capture its base addr= ess + // Default to the first port found, but (if there are multiple ports) al= low + // the "/chosen" node to override it. Note that if FdtSerialGetConsolePo= rt() + // fails, it does not modify UartBase. // - for (Prev =3D 0; ; Prev =3D Node) { - Node =3D fdt_next_node (DeviceTreeBase, Prev, NULL); - if (Node < 0) { - break; - } - - Compatible =3D fdt_getprop (DeviceTreeBase, Node, "compatible", &Len); - if (Compatible =3D=3D NULL) { - continue; - } - - // - // Iterate over the NULL-separated items in the compatible string - // - for (CompatibleItem =3D Compatible; CompatibleItem < Compatible + Len; - CompatibleItem +=3D 1 + AsciiStrLen (CompatibleItem)) - { - if (AsciiStrCmp (CompatibleItem, "arm,pl011") =3D=3D 0) { - NodeStatus =3D fdt_getprop (DeviceTreeBase, Node, "status", &Len); - if ((NodeStatus !=3D NULL) && (AsciiStrCmp (NodeStatus, "okay") != =3D 0)) { - continue; - } - - RegProperty =3D fdt_getprop (DeviceTreeBase, Node, "reg", &Len); - if (Len !=3D 16) { - return 0; - } - - UartBase =3D (UINTN)fdt64_to_cpu (ReadUnaligned64 (RegProperty)); + UartBase =3D Ports.BaseAddress[0]; + if (Ports.NumberOfPorts > 1) { + FdtSerialGetConsolePort (DeviceTreeBase, &UartBase); + } =20 - BaudRate =3D (UINTN)FixedPcdGet64 (PcdUartDefaultBaudRate); - ReceiveFifoDepth =3D 0; // Use the default value for Fifo depth - Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefault= Parity); - DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); - StopBits =3D (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefa= ultStopBits); + BaudRate =3D (UINTN)FixedPcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth =3D 0; // Use the default value for Fifo depth + Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity= ); + DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits =3D (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultSto= pBits); =20 - Status =3D PL011UartInitializePort ( - UartBase, - FixedPcdGet32 (PL011UartClkInHz), - &BaudRate, - &ReceiveFifoDepth, - &Parity, - &DataBits, - &StopBits - ); - if (!EFI_ERROR (Status)) { - return UartBase; - } - } - } + Status =3D PL011UartInitializePort ( + UartBase, + FixedPcdGet32 (PL011UartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + if (!RETURN_ERROR (Status)) { + return UartBase; } =20 return 0; diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPk= g/Library/PlatformPeiLib/PlatformPeiLib.c index 1b43d77dd120..d5dcc7cbfd52 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -14,6 +14,7 @@ #include #include #include +#include #include =20 #include @@ -43,17 +44,15 @@ PlatformPeim ( UINTN FdtPages; UINT64 *FdtHobData; UINT64 *UartHobData; + FDT_SERIAL_PORTS Ports; INT32 Node, Prev; INT32 Parent, Depth; CONST CHAR8 *Compatible; CONST CHAR8 *CompItem; - CONST CHAR8 *NodeStatus; INT32 Len; INT32 RangesLen; - INT32 StatusLen; CONST UINT64 *RegProp; CONST UINT32 *RangesProp; - UINT64 UartBase; UINT64 TpmBase; EFI_STATUS Status; =20 @@ -75,6 +74,24 @@ PlatformPeim ( ASSERT (UartHobData !=3D NULL); *UartHobData =3D 0; =20 + Status =3D FdtSerialGetPorts (Base, "arm,pl011", &Ports); + if (!EFI_ERROR (Status)) { + UINT64 UartBase; + + // + // Default to the first port found, but (if there are multiple ports) = allow + // the "/chosen" node to override it. Note that if FdtSerialGetConsole= Port() + // fails, it does not modify UartBase. + // + UartBase =3D Ports.BaseAddress[0]; + if (Ports.NumberOfPorts > 1) { + FdtSerialGetConsolePort (Base, &UartBase); + } + + DEBUG ((DEBUG_INFO, "%a: PL011 UART @ 0x%lx\n", __func__, UartBase)); + *UartHobData =3D UartBase; + } + TpmBase =3D 0; =20 // @@ -100,23 +117,8 @@ PlatformPeim ( for (CompItem =3D Compatible; CompItem !=3D NULL && CompItem < Compati= ble + Len; CompItem +=3D 1 + AsciiStrLen (CompItem)) { - if (AsciiStrCmp (CompItem, "arm,pl011") =3D=3D 0) { - NodeStatus =3D fdt_getprop (Base, Node, "status", &StatusLen); - if ((NodeStatus !=3D NULL) && (AsciiStrCmp (NodeStatus, "okay") != =3D 0)) { - continue; - } - - RegProp =3D fdt_getprop (Base, Node, "reg", &Len); - ASSERT (Len =3D=3D 16); - - UartBase =3D fdt64_to_cpu (ReadUnaligned64 (RegProp)); - - DEBUG ((DEBUG_INFO, "%a: PL011 UART @ 0x%lx\n", __func__, UartBase= )); - - *UartHobData =3D UartBase; - break; - } else if (FeaturePcdGet (PcdTpm2SupportEnabled) && - (AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") =3D=3D 0)) + if (FeaturePcdGet (PcdTpm2SupportEnabled) && + (AsciiStrCmp (CompItem, "tcg,tpm-tis-mmio") =3D=3D 0)) { RegProp =3D fdt_getprop (Base, Node, "reg", &Len); ASSERT (Len =3D=3D 8 || Len =3D=3D 16); -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109396): https://edk2.groups.io/g/devel/message/109396 Mute This Topic: https://groups.io/mt/101834882/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109393+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109393+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779568; cv=none; d=zohomail.com; s=zohoarc; b=WuAJ2Q17V47Tjv1krw4LYYFfIxfmzrfb1RzGr0A0RcWwbSmZRwFvJwGPmgSaUqKrGbSLSVEkmxKC0yf9jBnu9EuiFZ6/POar3vKXCuOO0FN2a3jSheIsgn4MaDlHpsD0siQHLJajSaTZKfuGA7SIoplDmMdyuzq5eveCRV9J5Do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779568; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=0xRivDgJOpU4SIAj+NHH0f7dU6f3DcFDTDGYscZqVTw=; b=kstuP3wUQAnPiHhoo/YIbds1onmw7UreoZb2D/V99ZkWUrEkUggBWYPgDNJPHq5nTGzk3DDqyoWl+Av0v9pXz/IG3revclD88yRtGoc7BEkduNoijZfIQKCOSWqMOEeJgKdOSJRwXWrl7rjPP6HTsK49VjnZmWZiql/+OybdEtU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109393+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16967795681692.143947057824903; Sun, 8 Oct 2023 08:39:28 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=0xRivDgJOpU4SIAj+NHH0f7dU6f3DcFDTDGYscZqVTw=; 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:Content-Type; s=20140610; t=1696779567; v=1; b=PvmZsRLT3z7r/xvaMjIlWOh/fAcBtfSQP185x2qoaX9ssKOyQEOkXSkhHCVkXwdEgA+33B4z 7EYFSSr4Y3zKDXK0w/6NTYVjIyl+FpUgwDwLYmLiRULA8lN9R9K/td2oad0r4bn3Vwjyr1CyK+9 VS89Tzosra4S69EFEs7JhoRU= X-Received: by 127.0.0.2 with SMTP id Ai4dYY1788612x8pEn5GHuF7; Sun, 08 Oct 2023 08:39:27 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.40414.1696779567283056321 for ; Sun, 08 Oct 2023 08:39:27 -0700 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-T5D1tFdUM6arNeji55HT3w-1; Sun, 08 Oct 2023 11:39:23 -0400 X-MC-Unique: T5D1tFdUM6arNeji55HT3w-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 98DE629AB435; Sun, 8 Oct 2023 15:39:22 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D669492B05; Sun, 8 Oct 2023 15:39:21 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 5/9] ArmVirtPkg: store separate console and debug PL011 addresses in GUID HOB Date: Sun, 8 Oct 2023 17:39:08 +0200 Message-Id: <20231008153912.175941-6-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ewKaIxhO34y7dDf5Vb1X9IW9x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779568883100001 Content-Type: text/plain; charset="utf-8"; x-default="true" PlatformPeiLib produces the EarlyPL011BaseAddress GUID HOB, and FdtPL011SerialPortLib consumes it. Extend the HOB such that it also carry the base address of the PL011 UART meant for DebugLib usage -- namely the first UART that is *not* designated by the /chosen node's "stdout-path" property. Implement this policy in PlatformPeiLib. Note that as far as the SerialPortLib+console UART is concerned, this patch makes no difference. That selection remains consistent with the pre-patch state, and therefore consistent with EarlyFdtPL011SerialPortLib. Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Include/Guid/EarlyPL011BaseAddress.h | 15 ++++- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf | 1 + ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c | 4 +- ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 58 ++++= +++++++++++----- 4 files changed, 61 insertions(+), 17 deletions(-) diff --git a/ArmVirtPkg/Include/Guid/EarlyPL011BaseAddress.h b/ArmVirtPkg/I= nclude/Guid/EarlyPL011BaseAddress.h index 492cbbcb1599..43b106f3ff04 100644 --- a/ArmVirtPkg/Include/Guid/EarlyPL011BaseAddress.h +++ b/ArmVirtPkg/Include/Guid/EarlyPL011BaseAddress.h @@ -1,6 +1,6 @@ /** @file - GUID for the HOB that caches the base address of the PL011 serial port, = for - when PCD access is not available. + GUID for the HOB that caches the base address(es) of the PL011 serial po= rt(s), + for when PCD access is not available. =20 Copyright (C) 2014, Red Hat, Inc. =20 @@ -18,4 +18,15 @@ =20 extern EFI_GUID gEarlyPL011BaseAddressGuid; =20 +typedef struct { + // + // for SerialPortLib and console IO + // + UINT64 ConsoleAddress; + // + // for DebugLib; may equal ConsoleAddress if there's only one PL011 UART + // + UINT64 DebugAddress; +} EARLY_PL011_BASE_ADDRESS; + #endif diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirt= Pkg/Library/PlatformPeiLib/PlatformPeiLib.inf index 08a8f23bb449..b867d8bb895e 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -31,6 +31,7 @@ [FeaturePcd] gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled =20 [LibraryClasses] + BaseMemoryLib DebugLib HobLib FdtLib diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib= .c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c index 5718b02977df..20e29e3f57f4 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.c @@ -46,7 +46,7 @@ SerialPortInitialize ( { VOID *Hob; RETURN_STATUS Status; - CONST UINT64 *UartBase; + CONST EARLY_PL011_BASE_ADDRESS *UartBase; UINTN SerialBaseAddress; UINT64 BaudRate; UINT32 ReceiveFifoDepth; @@ -70,7 +70,7 @@ SerialPortInitialize ( =20 UartBase =3D GET_GUID_HOB_DATA (Hob); =20 - SerialBaseAddress =3D (UINTN)*UartBase; + SerialBaseAddress =3D (UINTN)UartBase->ConsoleAddress; if (SerialBaseAddress =3D=3D 0) { Status =3D RETURN_NOT_FOUND; goto Failed; diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPk= g/Library/PlatformPeiLib/PlatformPeiLib.c index d5dcc7cbfd52..7ab4aa2d6bb9 100644 --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c @@ -9,6 +9,7 @@ =20 #include =20 +#include #include #include #include @@ -43,7 +44,7 @@ PlatformPeim ( UINTN FdtSize; UINTN FdtPages; UINT64 *FdtHobData; - UINT64 *UartHobData; + EARLY_PL011_BASE_ADDRESS *UartHobData; FDT_SERIAL_PORTS Ports; INT32 Node, Prev; INT32 Parent, Depth; @@ -72,24 +73,55 @@ PlatformPeim ( =20 UartHobData =3D BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartH= obData); ASSERT (UartHobData !=3D NULL); - *UartHobData =3D 0; + SetMem (UartHobData, sizeof *UartHobData, 0); =20 Status =3D FdtSerialGetPorts (Base, "arm,pl011", &Ports); if (!EFI_ERROR (Status)) { - UINT64 UartBase; + if (Ports.NumberOfPorts =3D=3D 1) { + // + // Just one UART; direct both SerialPortLib+console and DebugLib to = it. + // + UartHobData->ConsoleAddress =3D Ports.BaseAddress[0]; + UartHobData->DebugAddress =3D Ports.BaseAddress[0]; + } else { + UINT64 ConsoleAddress; =20 - // - // Default to the first port found, but (if there are multiple ports) = allow - // the "/chosen" node to override it. Note that if FdtSerialGetConsole= Port() - // fails, it does not modify UartBase. - // - UartBase =3D Ports.BaseAddress[0]; - if (Ports.NumberOfPorts > 1) { - FdtSerialGetConsolePort (Base, &UartBase); + Status =3D FdtSerialGetConsolePort (Base, &ConsoleAddress); + if (EFI_ERROR (Status)) { + // + // At least two UARTs; but failed to get the console preference. U= se the + // first UART for SerialPortLib+console, and the second one for + // DebugLib. + // + UartHobData->ConsoleAddress =3D Ports.BaseAddress[0]; + UartHobData->DebugAddress =3D Ports.BaseAddress[1]; + } else { + // + // At least two UARTs; and console preference available. Use the + // preferred UART for SerialPortLib+console, and *another* UART for + // DebugLib. + // + UartHobData->ConsoleAddress =3D ConsoleAddress; + if (ConsoleAddress =3D=3D Ports.BaseAddress[0]) { + UartHobData->DebugAddress =3D Ports.BaseAddress[1]; + } else { + UartHobData->DebugAddress =3D Ports.BaseAddress[0]; + } + } } =20 - DEBUG ((DEBUG_INFO, "%a: PL011 UART @ 0x%lx\n", __func__, UartBase)); - *UartHobData =3D UartBase; + DEBUG (( + DEBUG_INFO, + "%a: PL011 UART (console) @ 0x%lx\n", + __func__, + UartHobData->ConsoleAddress + )); + DEBUG (( + DEBUG_INFO, + "%a: PL011 UART (debug) @ 0x%lx\n", + __func__, + UartHobData->DebugAddress + )); } =20 TpmBase =3D 0; -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109393): https://edk2.groups.io/g/devel/message/109393 Mute This Topic: https://groups.io/mt/101834879/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109395+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109395+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779570; cv=none; d=zohomail.com; s=zohoarc; b=ciyDgHQSZHpqL+dH9q7RvKLAGWo9jXXRB4yBcLbAmTqmWi8sN+JZAHjMoAHFcjRjYdjgbNdj0zeWKVC8JHdmn1hDqXngI4QAvUx+dhBHnF01Tu1BSSq9xcrw8mwBPApl/+lSGHoNVc/aVsy7HvDSkh/SntNrFAcQ7C383ltyINs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779570; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=p3iwTIsW3mzyMvgTmQ6BQn8SII9/SPh1UdVBKZwMoF8=; b=LAmMzsHsy+5B9dpfU9kX5w8AydiM95P1h+vmu2uRbHB6SEFOHT9pMV0pPQy62qZ+jPREizSJc9gWgAMuprbLyjH0w9BexX5tFGPJHySPEjftDovgd+p/uTiHqXj7tGm+JFZuYgEn/aAmaMiLj5b7IoN8ARNDOVRAP55kdCWyjzA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109395+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779570766338.28300748833965; Sun, 8 Oct 2023 08:39:30 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=p3iwTIsW3mzyMvgTmQ6BQn8SII9/SPh1UdVBKZwMoF8=; 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:Content-Type; s=20140610; t=1696779570; v=1; b=CGCWKMlvm27rctpjMlzvGr0mGOnOR1bxWpt1JPgx167ecu21s83jJutqxGZCqnRrSSKnzXsR /XSAo1olUrk7EzpdP24l3Gzdbr4/V4sQi/ArU+OQNiHSjZxPz2y7CPBjVTY2OVG090JWRkC1uD9 5I+fTIFQdShUPQ4AU5zmL9P4= X-Received: by 127.0.0.2 with SMTP id KQbnYY1788612x3GygMcXDZ0; Sun, 08 Oct 2023 08:39:30 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.40415.1696779569793424349 for ; Sun, 08 Oct 2023 08:39:30 -0700 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-231-gRWNUvgqNayzVzVGQj37aA-1; Sun, 08 Oct 2023 11:39:25 -0400 X-MC-Unique: gRWNUvgqNayzVzVGQj37aA-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 69BD33806703; Sun, 8 Oct 2023 15:39:25 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7DF2492B05; Sun, 8 Oct 2023 15:39:22 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 6/9] ArmVirtPkg: introduce DebugLibFdtPL011Uart Flash instance Date: Sun, 8 Oct 2023 17:39:09 +0200 Message-Id: <20231008153912.175941-7-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: nQtA8e7ayqso9W0iJcj1JXHHx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779572990100011 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce three new DebugLib instances, forked from MdePkg/Library/BaseDebugLibSerialPort. All three instances rely on PL011UartLib rather than SerialPortLib so that they can customize the PL011 UART that the debug messages are written to. All three instances direct the debug output to the first such PL011 UART that *differs* from the one specified in the Device Tree's /chosen node's "stdout-path" property. From these, DebugLibFdtPL011UartFlash mirrors EarlyFdtPL011SerialPortLib: it parses the initial Device Tree, and initializes the UART -- a UART different from EarlyFdtPL011SerialPortLib's -- for every message written. Suitable for SEC, PEI_CORE, PEIM. (Note that OVMF uses a similar set of dedicated DebugLib instances (PlatformDebugLibIoPort) for logging to the (x86-only) isa-debugcon device from various firmware phases.) The contexts in which these DebugLib instances run are identical to those in which the corresponding SerialPortLib instances run. The particular original dependency chain is BaseDebugLibSerialPort (SEC, PEI_CORE, PEIM) EarlyFdtPL011SerialPortLib PcdDeviceTreeInitialBaseAddress FdtSerialPortAddressLib PL011UartLib and the new dependency chain is DebugLibFdtPL011UartFlash (SEC, PEI_CORE, PEIM) PcdDeviceTreeInitialBaseAddress FdtSerialPortAddressLib PL011UartLib Note that EarlyFdtPL011SerialPortLib remains in use (just not via BaseDebugLibSerialPort), namely for direct SerialPortLib calls from SEC, PEI_CORE, PEIM. See for example commit 56035d1c8b25 ("ArmPlatformPkg/PrePeiCore: Print the firmware version early in boot", 2022-10-25). The ArmVirtPkg DSC files will be switched to the new library instances in a separate patch. This patch is worth viewing with "git show --find-copies-harder". Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash.inf = | 54 ++++++++++ ArmVirtPkg/Library/DebugLibFdtPL011Uart/Write.h = | 39 +++++++ {MdePkg/Library/BaseDebugLibSerialPort =3D> ArmVirtPkg/Library/DebugLibFdt= PL011Uart}/DebugLib.c | 41 +++----- ArmVirtPkg/Library/DebugLibFdtPL011Uart/Flash.c = | 107 ++++++++++++++++++++ 4 files changed, 216 insertions(+), 25 deletions(-) diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFl= ash.inf b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash= .inf new file mode 100644 index 000000000000..7870ca2ae47f --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash.inf @@ -0,0 +1,54 @@ +## @file +# DebugLib instance that produces debug output directly via PL011UartLib. +# +# If there are at least two PL011 UARTs in the device tree, and the /chosen +# node's "stdout-path" property references one PL011 UART, then both raw +# SerialPortLib IO, and -- via SerialDxe -- UEFI console IO, will occur on= that +# UART; and this DebugLib instance will produce output on a *different* UA= RT. +# +# This instance is suitable for modules that may run from flash or RAM. +# +# Copyright (C) Red Hat +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D DebugLibFdtPL011UartFlash + FILE_GUID =3D 43A4C56B-D071-4CE0-A157-9D59E6161DEC + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DebugLib|SEC PEI_CORE PEIM + +[Sources] + DebugLib.c + Flash.c + Write.h + +[Packages] + ArmPlatformPkg/ArmPlatformPkg.dec + ArmVirtPkg/ArmVirtPkg.dec + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugPrintErrorLevelLib + FdtSerialPortAddressLib # Flash.c + PL011UartLib + PcdLib + PrintLib + +[Pcd] + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress # Flash.c + gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask + gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel + +[FixedPcd] + gArmPlatformTokenSpaceGuid.PL011UartClkInHz + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Write.h b/ArmVirtPkg/L= ibrary/DebugLibFdtPL011Uart/Write.h new file mode 100644 index 000000000000..2cf610676423 --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Write.h @@ -0,0 +1,39 @@ +/** @file + Declare DebugLibFdtPL011UartWrite(), for abstracting PL011 UART initiali= zation + differences between flash- vs. RAM-based modules. + + Copyright (C) Red Hat + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2012 - 2014, ARM Ltd. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef DEBUG_LIB_FDT_PL011_UART_WRITE_H_ +#define DEBUG_LIB_FDT_PL011_UART_WRITE_H_ + +/** + (Copied from SerialPortWrite() in "MdePkg/Include/Library/SerialPortLib.= h" at + commit c4547aefb3d0, with the Buffer non-nullity assertion removed:) + + Write data from buffer to serial device. + + Writes NumberOfBytes data bytes from Buffer to the serial device. + The number of bytes actually written to the serial device is returned. + If the return value is less than NumberOfBytes, then the write operation= failed. + If NumberOfBytes is zero, then return 0. + + @param Buffer Pointer to the data buffer to be written. + @param NumberOfBytes Number of bytes to written to the serial device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial devic= e. + If this value is less than NumberOfBytes, then = the write operation failed. +**/ +UINTN +DebugLibFdtPL011UartWrite ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ); + +#endif diff --git a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c b/ArmVirtPkg/= Library/DebugLibFdtPL011Uart/DebugLib.c similarity index 89% copy from MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c copy to ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLib.c index bd5686947712..0da84ba8d263 100644 --- a/MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLib.c @@ -1,15 +1,20 @@ /** @file - Base Debug library instance base on Serial Port library. - It uses PrintLib to send debug messages to serial port device. + Originally copied from "MdePkg/Library/BaseDebugLibSerialPort/DebugLib.c= " at + commit f36e1ec1f0a5, and customized for: =20 - NOTE: If the Serial Port library enables hardware flow control, then a c= all - to DebugPrint() or DebugAssert() may hang if writes to the serial port a= re - being blocked. This may occur if a key(s) are pressed in a terminal emu= lator - used to monitor the DEBUG() and ASSERT() messages. + - RAM vs. flash dependent PL011 UART initialization, =20 + - direct PL011 UART access, with the base address taken from the device = tree + such that the debug output be separate from the SerialPortLib / UEFI c= onsole + traffic. + + Both of these customizations are hidden behind DebugLibFdtPL011UartWrite= (), + which replaces SerialPortWrite(). + + Copyright (C) Red Hat Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent - **/ =20 #include @@ -18,9 +23,10 @@ #include #include #include -#include #include =20 +#include "Write.h" + // // Define the maximum debug and assert message length that this library su= pports // @@ -32,21 +38,6 @@ // VA_LIST mVaListNull; =20 -/** - The constructor function initialize the Serial Port Library - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -BaseDebugLibSerialPortConstructor ( - VOID - ) -{ - return SerialPortInitialize (); -} - /** Prints a debug message to the debug output device if the specified error= level is enabled. =20 @@ -128,7 +119,7 @@ DebugPrintMarker ( // // Send the print string to a Serial Port // - SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); + DebugLibFdtPL011UartWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); } =20 /** @@ -224,7 +215,7 @@ DebugAssert ( // // Send the print string to the Console Output device // - SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); + DebugLibFdtPL011UartWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); =20 // // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Flash.c b/ArmVirtPkg/L= ibrary/DebugLibFdtPL011Uart/Flash.c new file mode 100644 index 000000000000..a624e0860d10 --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Flash.c @@ -0,0 +1,107 @@ +/** @file + Define DebugLibFdtPL011UartWrite() for modules that may run from flash o= r RAM. + + Copyright (C) Red Hat + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include + +#include "Write.h" + +/** + (Copied from SerialPortWrite() in "MdePkg/Include/Library/SerialPortLib.= h" at + commit c4547aefb3d0, with the Buffer non-nullity assertion removed:) + + Write data from buffer to serial device. + + Writes NumberOfBytes data bytes from Buffer to the serial device. + The number of bytes actually written to the serial device is returned. + If the return value is less than NumberOfBytes, then the write operation= failed. + If NumberOfBytes is zero, then return 0. + + @param Buffer Pointer to the data buffer to be written. + @param NumberOfBytes Number of bytes to written to the serial device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial devic= e. + If this value is less than NumberOfBytes, then = the write operation failed. +**/ +UINTN +DebugLibFdtPL011UartWrite ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + CONST VOID *DeviceTree; + RETURN_STATUS Status; + FDT_SERIAL_PORTS Ports; + UINT64 DebugAddress; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + + DeviceTree =3D (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); + if (DeviceTree =3D=3D NULL) { + return 0; + } + + Status =3D FdtSerialGetPorts (DeviceTree, "arm,pl011", &Ports); + if (RETURN_ERROR (Status)) { + return 0; + } + + if (Ports.NumberOfPorts =3D=3D 1) { + // + // Just one UART; direct DebugLib to it. + // + DebugAddress =3D Ports.BaseAddress[0]; + } else { + UINT64 ConsoleAddress; + + Status =3D FdtSerialGetConsolePort (DeviceTree, &ConsoleAddress); + if (EFI_ERROR (Status)) { + // + // At least two UARTs; but failed to get the console preference. Use= the + // second UART for DebugLib. + // + DebugAddress =3D Ports.BaseAddress[1]; + } else { + // + // At least two UARTs; and console preference available. Use the fir= st + // such UART for DebugLib that *differs* from ConsoleAddress. + // + if (ConsoleAddress =3D=3D Ports.BaseAddress[0]) { + DebugAddress =3D Ports.BaseAddress[1]; + } else { + DebugAddress =3D Ports.BaseAddress[0]; + } + } + } + + BaudRate =3D (UINTN)FixedPcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth =3D 0; // Use the default value for Fifo depth + Parity =3D (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity= ); + DataBits =3D FixedPcdGet8 (PcdUartDefaultDataBits); + StopBits =3D (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultSto= pBits); + + Status =3D PL011UartInitializePort ( + (UINTN)DebugAddress, + FixedPcdGet32 (PL011UartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + if (RETURN_ERROR (Status)) { + return 0; + } + + return PL011UartWrite ((UINTN)DebugAddress, Buffer, NumberOfBytes); +} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109395): https://edk2.groups.io/g/devel/message/109395 Mute This Topic: https://groups.io/mt/101834881/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109399+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109399+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779574; cv=none; d=zohomail.com; s=zohoarc; b=QlcrM20wvG/qPqA2pK6V7XOy/M6CmH/trhHrj2dBBg7m6Hb/+mrrYGGv6oofbVyrzIkTnKWu4Rj8ChxTpGR+wbzj+KYnhSWRsiKQhw9mCzC3vExXKtgfrl/Aag0RROGf3YLaHG4l8GtTz+XeG0aGDLTd7HyIjdarNTDN4z25yaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779574; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=KvzY+jIv+EVauFwEfP0likQqM+oQ015lt1/DVKMKXIA=; b=Y6VUXGat8xJRA8aLAPjpePh8J6Qsrw7JJ/PJVQd1NStnGjw7lcVmVbRp5VGspdijsY6ijS63FcLH9uuWCWtO2dXJ62Gd8MIIx7uyYJN1vkY4UIptw61z7RF0dkbvueoNCR8sisJUyU33rStZjlsU6n2vc91Rvc3DA6mQuXoOzXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109399+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169677957409045.905216462924386; Sun, 8 Oct 2023 08:39:34 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=KvzY+jIv+EVauFwEfP0likQqM+oQ015lt1/DVKMKXIA=; 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:Content-Type; s=20140610; t=1696779573; v=1; b=gCQ/IcwlNWHXb8bdT3nWEq2DSbs3+51i5znsFvgYOHBvc1rU6lOQ/3NvLD2PtjCQ3Ed6mAwX 2zeZ1y2uFjMVZXgSW0FFMAZQc0Lm+c6f3Ea0mrynZ4DhQQ3Arbr7xrYDOpeMiZMwyL9S/FYH1xZ YPTdme1rKnZ5i9k4i0WVGhTw= X-Received: by 127.0.0.2 with SMTP id La1iYY1788612x0bGLBUPTTg; Sun, 08 Oct 2023 08:39:33 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.40267.1696779572635562343 for ; Sun, 08 Oct 2023 08:39:32 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-s-uNK0SsOQScedJgruvYBQ-1; Sun, 08 Oct 2023 11:39:27 -0400 X-MC-Unique: s-uNK0SsOQScedJgruvYBQ-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5400811E7B; Sun, 8 Oct 2023 15:39:26 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8C8649BB9A; Sun, 8 Oct 2023 15:39:25 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 7/9] ArmVirtPkg: introduce DebugLibFdtPL011Uart RAM instance Date: Sun, 8 Oct 2023 17:39:10 +0200 Message-Id: <20231008153912.175941-8-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: BA6BdBqucB3iSqpx6P7ReoEFx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779575142100024 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce three new DebugLib instances, forked from MdePkg/Library/BaseDebugLibSerialPort. All three instances rely on PL011UartLib rather than SerialPortLib so that they can customize the PL011 UART that the debug messages are written to. All three instances direct the debug output to the first such PL011 UART that *differs* from the one specified in the Device Tree's /chosen node's "stdout-path" property. From these, DebugLibFdtPL011UartRam mirrors FdtPL011SerialPortLib: it relies on the EarlyPL011BaseAddress GUID HOB, and initializes the UART -- a UART different from FdtPL011SerialPortLib's -- only once in the lifetime of the containing module. Suitable for module types that can only execute from RAM (i.e., all types different from SEC, PEI_CORE, PEIM), except DXE_RUNTIME_DRIVER. (Note that OVMF uses a similar set of dedicated DebugLib instances (PlatformDebugLibIoPort) for logging to the (x86-only) isa-debugcon device from various firmware phases.) The contexts in which these DebugLib instances run are identical to those in which the corresponding SerialPortLib instances run. The particular original dependency chain is BaseDebugLibSerialPort (not SEC, PEI_CORE, PEIM, DXE_RUNTIME_DRIVER) FdtPL011SerialPortLib gEarlyPL011BaseAddressGuid HobLib PL011UartLib and the new dependency chain is DebugLibFdtPL011UartRam (not SEC, PEI_CORE, PEIM, DXE_RUNTIME_DRIVER) gEarlyPL011BaseAddressGuid HobLib PL011UartLib Note that FdtPL011SerialPortLib remains in use (just not via BaseDebugLibSerialPort); for instance by MdeModulePkg/Universal/SerialDxe, which produces the SerialIo protocol, underlying the UEFI console. The ArmVirtPkg DSC files will be switched to the new library instances in a separate patch. This patch is worth viewing with "git show --find-copies-harder". Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/DebugLibFdtPL011Uart/{DebugLibFdtPL011UartFlash.inf =3D= > DebugLibFdtPL011UartRam.inf} | 20 ++-- ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.h = | 18 +++ ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.c = | 124 ++++++++++++++++++++ ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c = | 27 +++++ 4 files changed, 182 insertions(+), 7 deletions(-) diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFl= ash.inf b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.i= nf similarity index 67% copy from ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash= .inf copy to ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.inf index 7870ca2ae47f..a5f4c2d80a3c 100644 --- a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFlash.inf +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.inf @@ -6,7 +6,8 @@ # SerialPortLib IO, and -- via SerialDxe -- UEFI console IO, will occur on= that # UART; and this DebugLib instance will produce output on a *different* UA= RT. # -# This instance is suitable for modules that may run from flash or RAM. +# This instance is suitable for modules that can only run from RAM (except +# DXE_RUNTIME_DRIVER). # # Copyright (C) Red Hat # @@ -15,15 +16,18 @@ =20 [Defines] INF_VERSION =3D 1.27 - BASE_NAME =3D DebugLibFdtPL011UartFlash - FILE_GUID =3D 43A4C56B-D071-4CE0-A157-9D59E6161DEC + BASE_NAME =3D DebugLibFdtPL011UartRam + FILE_GUID =3D 0584DE55-9C4C-49C1-ADA0-F62C9C1F3600 MODULE_TYPE =3D BASE VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D DebugLib|SEC PEI_CORE PEIM + LIBRARY_CLASS =3D DebugLib|DXE_CORE SMM_CORE MM_CORE_STANDALONE DXE_DRI= VER DXE_SMM_DRIVER SMM_DRIVER MM_STANDALONE UEFI_DRIVER UEFI_APPLICATION + CONSTRUCTOR =3D DebugLibFdtPL011UartRamConstructor =20 [Sources] DebugLib.c - Flash.c + Ram.c + Ram.h + RamNonRuntime.c Write.h =20 [Packages] @@ -35,13 +39,12 @@ [LibraryClasses] BaseLib BaseMemoryLib DebugPrintErrorLevelLib - FdtSerialPortAddressLib # Flash.c + HobLib # Ram.c PL011UartLib PcdLib PrintLib =20 [Pcd] - gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress # Flash.c gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel @@ -52,3 +55,6 @@ [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits + +[Guids] + gEarlyPL011BaseAddressGuid # Ram.c diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.h b/ArmVirtPkg/Lib= rary/DebugLibFdtPL011Uart/Ram.h new file mode 100644 index 000000000000..8c1ef52b4dba --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.h @@ -0,0 +1,18 @@ +/** @file + Declare the variables that modules that can only run from RAM use for + remembering initialization status. + + Copyright (C) Red Hat + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef DEBUG_LIB_FDT_PL011_UART_RAM_H_ +#define DEBUG_LIB_FDT_PL011_UART_RAM_H_ + +#include + +extern UINTN mDebugLibFdtPL011UartAddress; +extern RETURN_STATUS mDebugLibFdtPL011UartPermanentStatus; + +#endif diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.c b/ArmVirtPkg/Lib= rary/DebugLibFdtPL011Uart/Ram.c new file mode 100644 index 000000000000..bc5be015bded --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Ram.c @@ -0,0 +1,124 @@ +/** @file + Define DebugLibFdtPL011UartWrite() for modules that can only run from RA= M. + + Copyright (C) Red Hat + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Ram.h" +#include "Write.h" + +UINTN mDebugLibFdtPL011UartAddress; +RETURN_STATUS mDebugLibFdtPL011UartPermanentStatus =3D RETURN_SUCCESS; + +/** + Statefully initialize both the library instance and the debug PL011 UART. +**/ +STATIC +RETURN_STATUS +Initialize ( + VOID + ) +{ + CONST VOID *Hob; + CONST EARLY_PL011_BASE_ADDRESS *UartBase; + RETURN_STATUS Status; + UINTN DebugAddress; + UINT64 BaudRate; + UINT32 ReceiveFifoDepth; + EFI_PARITY_TYPE Parity; + UINT8 DataBits; + EFI_STOP_BITS_TYPE StopBits; + + if (mDebugLibFdtPL011UartAddress !=3D 0) { + return RETURN_SUCCESS; + } + + if (RETURN_ERROR (mDebugLibFdtPL011UartPermanentStatus)) { + return mDebugLibFdtPL011UartPermanentStatus; + } + + Hob =3D GetFirstGuidHob (&gEarlyPL011BaseAddressGuid); + if ((Hob =3D=3D NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) !=3D sizeof *Uart= Base)) { + Status =3D RETURN_NOT_FOUND; + goto Failed; + } + + UartBase =3D GET_GUID_HOB_DATA (Hob); + + DebugAddress =3D (UINTN)UartBase->DebugAddress; + if (DebugAddress =3D=3D 0) { + Status =3D RETURN_NOT_FOUND; + goto Failed; + } + + BaudRate =3D (UINTN)PcdGet64 (PcdUartDefaultBaudRate); + ReceiveFifoDepth =3D 0; // Use the default value for Fifo depth + Parity =3D (EFI_PARITY_TYPE)PcdGet8 (PcdUartDefaultParity); + DataBits =3D PcdGet8 (PcdUartDefaultDataBits); + StopBits =3D (EFI_STOP_BITS_TYPE)PcdGet8 (PcdUartDefaultStopBits= ); + + Status =3D PL011UartInitializePort ( + DebugAddress, + FixedPcdGet32 (PL011UartClkInHz), + &BaudRate, + &ReceiveFifoDepth, + &Parity, + &DataBits, + &StopBits + ); + if (RETURN_ERROR (Status)) { + goto Failed; + } + + mDebugLibFdtPL011UartAddress =3D DebugAddress; + return RETURN_SUCCESS; + +Failed: + mDebugLibFdtPL011UartPermanentStatus =3D Status; + return Status; +} + +/** + (Copied from SerialPortWrite() in "MdePkg/Include/Library/SerialPortLib.= h" at + commit c4547aefb3d0, with the Buffer non-nullity assertion removed:) + + Write data from buffer to serial device. + + Writes NumberOfBytes data bytes from Buffer to the serial device. + The number of bytes actually written to the serial device is returned. + If the return value is less than NumberOfBytes, then the write operation= failed. + If NumberOfBytes is zero, then return 0. + + @param Buffer Pointer to the data buffer to be written. + @param NumberOfBytes Number of bytes to written to the serial device. + + @retval 0 NumberOfBytes is 0. + @retval >0 The number of bytes written to the serial devic= e. + If this value is less than NumberOfBytes, then = the write operation failed. +**/ +UINTN +DebugLibFdtPL011UartWrite ( + IN UINT8 *Buffer, + IN UINTN NumberOfBytes + ) +{ + RETURN_STATUS Status; + + Status =3D Initialize (); + if (RETURN_ERROR (Status)) { + return 0; + } + + return PL011UartWrite (mDebugLibFdtPL011UartAddress, Buffer, NumberOfByt= es); +} diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c b/ArmV= irtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c new file mode 100644 index 000000000000..715d3400ddd9 --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c @@ -0,0 +1,27 @@ +/** @file + Provide an empty lib instance constructor for modules that can only run = from + RAM but are not DXE_RUNTIME_DRIVER modules. + + This ensures that e.g. any HobLib constructor is ordered correctly. (The + DXE_CORE calls constructors late, but the DXE_CORE HobLib instance needs= no + construction anyway.) + + Copyright (C) Red Hat + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +/** + Empty library instance constructor, only for ensuring the connectivity o= f the + constructor dependency graph. +**/ +RETURN_STATUS +EFIAPI +DebugLibFdtPL011UartRamConstructor ( + VOID + ) +{ + return RETURN_SUCCESS; +} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109399): https://edk2.groups.io/g/devel/message/109399 Mute This Topic: https://groups.io/mt/101834885/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109398+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109398+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779573; cv=none; d=zohomail.com; s=zohoarc; b=Lt/pPeeKMQuUwrJae84SvEQBC1azQ3fM8+q3pDl/XADQfo4GNwlTCc+joa8qNJnxHitSAhFNXl9Tv9GZovLu/Ko+SVDEOYwVTt+XbgdFZgEQggmE1w7D609YrJ2ISowvx5VRVOGl0N5TmxIoAFFX0EQYFX0ZezK1MZXepRC2gtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779573; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=cRSK38z7eGSSQ9tesYKSLWIF0AEzBAq/1V/gRuZO5Nw=; b=Tslk9ejUKQoeGbQvzW7VbHtrNK4tZL4ns6GJg8oCHxmLoBBW9mBu3+H/ilaml7Ax70SG5okZgqwLMUc3Z0qVtpSwXZ5yNXfuwXZrdEtHfg9S041VpIu1ExkFCbRCotfcm/1V9lMIcXzcmwIgXXYfjGaz9YcEdHmk8oDQNnw+N6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109398+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779573712499.77724639449036; Sun, 8 Oct 2023 08:39:33 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=cRSK38z7eGSSQ9tesYKSLWIF0AEzBAq/1V/gRuZO5Nw=; 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:Content-Type; s=20140610; t=1696779573; v=1; b=hyxai0YTbLoYz0LlCd9fmP+34IKzE0cgALzB04VDWBzCPLnzj7+yyxVyVyE1eZ8R4qV+1H0m 5w5jgeaFGcZOwV1Sqz67lx5WH0ozuDPMQQAN2e/TfDji8odBqXexLp522c82QhRoW7igdecQnwz SREd2/WWnJKfQVh7L2LkwZcg= X-Received: by 127.0.0.2 with SMTP id si9KYY1788612xFANKHU6b0d; Sun, 08 Oct 2023 08:39:33 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.40419.1696779572300995419 for ; Sun, 08 Oct 2023 08:39:32 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-JjJWkAaQPO-JzUZD16WR6w-1; Sun, 08 Oct 2023 11:39:28 -0400 X-MC-Unique: JjJWkAaQPO-JzUZD16WR6w-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C7A0811E7D; Sun, 8 Oct 2023 15:39:28 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 105FB492B05; Sun, 8 Oct 2023 15:39:26 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 8/9] ArmVirtPkg: introduce DebugLibFdtPL011Uart DXE Runtime instance Date: Sun, 8 Oct 2023 17:39:11 +0200 Message-Id: <20231008153912.175941-9-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 2cBIC22i9MWNOgYLLu9fUGJWx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779575104100021 Content-Type: text/plain; charset="utf-8"; x-default="true" Introduce three new DebugLib instances, forked from MdePkg/Library/BaseDebugLibSerialPort. All three instances rely on PL011UartLib rather than SerialPortLib so that they can customize the PL011 UART that the debug messages are written to. All three instances direct the debug output to the first such PL011 UART that *differs* from the one specified in the Device Tree's /chosen node's "stdout-path" property. From these, DxeRuntimeDebugLibFdtPL011Uart is identical to DebugLibFdtPL011UartRam, with the addition that UART access is permanently disabled when the containing DXE_RUNTIME_DRIVER module is notified about exiting boot services. The contexts in which these DebugLib instances run are identical to those in which the corresponding SerialPortLib instances run. The particular original dependency chain is DxeRuntimeDebugLibSerialPort (DXE_RUNTIME_DRIVER) FdtPL011SerialPortLib gEarlyPL011BaseAddressGuid HobLib PL011UartLib and the new dependency chain is DxeRuntimeDebugLibFdtPL011Uart (DXE_RUNTIME_DRIVER) gEarlyPL011BaseAddressGuid HobLib PL011UartLib The ArmVirtPkg DSC files will be switched to the new library instances in a separate patch. This patch is worth viewing with "git show --find-copies-harder". Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/Library/DebugLibFdtPL011Uart/{DebugLibFdtPL011UartRam.inf =3D> = DxeRuntimeDebugLibFdtPL011Uart.inf} | 17 ++-- ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c = | 88 ++++++++++++++++++++ 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRa= m.inf b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011U= art.inf similarity index 71% copy from ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.i= nf copy to ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011U= art.inf index a5f4c2d80a3c..84e9dbae221b 100644 --- a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam.inf +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL011Uar= t.inf @@ -6,8 +6,8 @@ # SerialPortLib IO, and -- via SerialDxe -- UEFI console IO, will occur on= that # UART; and this DebugLib instance will produce output on a *different* UA= RT. # -# This instance is suitable for modules that can only run from RAM (except -# DXE_RUNTIME_DRIVER). +# This instance is suitable for DXE_RUNTIME_DRIVER modules. When exiting b= oot +# services, UART access is stopped. # # Copyright (C) Red Hat # @@ -16,18 +16,19 @@ =20 [Defines] INF_VERSION =3D 1.27 - BASE_NAME =3D DebugLibFdtPL011UartRam - FILE_GUID =3D 0584DE55-9C4C-49C1-ADA0-F62C9C1F3600 - MODULE_TYPE =3D BASE + BASE_NAME =3D DxeRuntimeDebugLibFdtPL011Uart + FILE_GUID =3D 8A6E0972-81B5-4FF4-BB24-A07748415947 + MODULE_TYPE =3D DXE_RUNTIME_DRIVER VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D DebugLib|DXE_CORE SMM_CORE MM_CORE_STANDALONE DXE_DRI= VER DXE_SMM_DRIVER SMM_DRIVER MM_STANDALONE UEFI_DRIVER UEFI_APPLICATION - CONSTRUCTOR =3D DebugLibFdtPL011UartRamConstructor + LIBRARY_CLASS =3D DebugLib|DXE_RUNTIME_DRIVER + CONSTRUCTOR =3D DxeRuntimeDebugLibFdtPL011UartConstructor + DESTRUCTOR =3D DxeRuntimeDebugLibFdtPL011UartDestructor =20 [Sources] DebugLib.c Ram.c Ram.h - RamNonRuntime.c + Runtime.c Write.h =20 [Packages] diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c b/ArmVirtPkg= /Library/DebugLibFdtPL011Uart/Runtime.c new file mode 100644 index 000000000000..de7144739c4c --- /dev/null +++ b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/Runtime.c @@ -0,0 +1,88 @@ +/** @file + Permanently disable the library instance in DXE_RUNTIME_DRIVER modules w= hen + exiting boot services. + + Copyright (C) Red Hat + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +#include "Ram.h" + +STATIC EFI_EVENT mExitBootServicesEvent; + +/** + Notification function that is triggered when the boot service + ExitBootServices() is called. + + @param[in] Event Event whose notification function is being invoked. = Here, + unused. + + @param[in] Context The pointer to the notification function's context, = which + is implementation-dependent. Here, unused. +**/ +STATIC +VOID +EFIAPI +ExitBootServicesNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + mDebugLibFdtPL011UartAddress =3D 0; + mDebugLibFdtPL011UartPermanentStatus =3D RETURN_ABORTED; +} + +/** + Library instance constructor, registering ExitBootServicesNotify(). + + @param[in] ImageHandle The firmware-allocated handle for the EFI image. + + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + + @return Error codes propagated from CreateEvent(); the + registration of ExitBootServicesNotify() failed. +**/ +EFI_STATUS +EFIAPI +DxeRuntimeDebugLibFdtPL011UartConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SystemTable->BootServices->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + ExitBootServicesNotify, + NULL /* NotifyContext */, + &mExitBootServicesEvent + ); +} + +/** + Library instance destructor, deregistering ExitBootServicesNotify(). + + @param[in] ImageHandle The firmware-allocated handle for the EFI image. + + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS Library instance tear-down complete. + + @return Error codes propagated from CloseEvent(); the + deregistration of ExitBootServicesNotify() failed. +**/ +EFI_STATUS +EFIAPI +DxeRuntimeDebugLibFdtPL011UartDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SystemTable->BootServices->CloseEvent (mExitBootServicesEvent); +} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109398): https://edk2.groups.io/g/devel/message/109398 Mute This Topic: https://groups.io/mt/101834884/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Wed May 15 11:55:16 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+109397+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109397+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696779573; cv=none; d=zohomail.com; s=zohoarc; b=Epx1LQ5ZFZ7d7iSAKnNUUEkG/egyWIGvVxYfSxHlxPw9/eTt2VxY2s+FCQZYEG6mDF9ZwG5sOWZUN7CTHpz7KK0HpC3fKiGoSoN+XjqcGQE/9gLOKNnnMKsbUwF7n1Bio5iVE+vAjN5U+esDM9ARjzUpMyZlSNtKOSFpuarP2iM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696779573; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=kXmdqYEB0RwcH3Pf2kluETpq4RpdrKJC5TuiM9Y9yTU=; b=MLNVMAUbAU58vw7qEOcH17/uL8oX//wrhh4LZe0nYv30LLHWP5+zGWHfr7zjIG8trfuYb7WBGlOGAhF9Eqlyt4pzzVeTIc/Ss6SYT7vea8rzrHhZ5FWfsfJWdoVCxmh9viEG4FZP7t7KgYyHPKi8pskY2yZT6JdXLEaEYLt1fRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+109397+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1696779573270783.8899897974197; Sun, 8 Oct 2023 08:39:33 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=kXmdqYEB0RwcH3Pf2kluETpq4RpdrKJC5TuiM9Y9yTU=; 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:Content-Type; s=20140610; t=1696779572; v=1; b=PQbglPI/nT9u36jmvfft//DQOsFUg/T5fgfd7VgQ0SWxVYV+P78BuEGJgkpdjweDaUiQPgOq CfIvLy5JYmcTgxAUuenMTvoK7CiOflSk3wPFG/k2GN3ctTVKjvsX27mOg+Di1cUD91gZ3jtUuQk SKQnvZaCI16bg9Di0TX3j344= X-Received: by 127.0.0.2 with SMTP id 3ZTDYY1788612xqyLmSgLdz8; Sun, 08 Oct 2023 08:39:32 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.40418.1696779572269008803 for ; Sun, 08 Oct 2023 08:39:32 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-679-s2gft7kgON6HJZKXSM5_Ow-1; Sun, 08 Oct 2023 11:39:29 -0400 X-MC-Unique: s2gft7kgON6HJZKXSM5_Ow-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 67E62101A529; Sun, 8 Oct 2023 15:39:29 +0000 (UTC) X-Received: from lacos-laptop-9.usersys.redhat.com (unknown [10.39.192.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B7F9492B05; Sun, 8 Oct 2023 15:39:28 +0000 (UTC) From: "Laszlo Ersek" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Julien Grall , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH 9/9] ArmVirtPkg: steer DebugLib output away from SerialPortLib+console traffic Date: Sun, 8 Oct 2023 17:39:12 +0200 Message-Id: <20231008153912.175941-10-lersek@redhat.com> In-Reply-To: <20231008153912.175941-1-lersek@redhat.com> References: <20231008153912.175941-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: N2S34KZvBNUd6nRe9eWQ755tx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1696779575108100022 Content-Type: text/plain; charset="utf-8"; x-default="true" For the RELEASE target, all ArmVirtPkg DSCs inherit BaseDebugLibNull from "ArmVirt.dsc.inc"; keep that. For NOOPT and DEBUG: - switch the lib class resolution pair (BaseDebugLibSerialPort + FdtPL011SerialPortLib) that is set as the default for all module types in "ArmVirt.dsc.inc" to DebugLibFdtPL011UartRam; - switch the lib class resolution pair (BaseDebugLibSerialPort + EarlyFdtPL011SerialPortLib) that is set as an override for SEC, PEI_CORE, PEIM modules in "ArmVirt.dsc.inc" to DebugLibFdtPL011UartFlash; - switch the lib class resolution pair (DxeRuntimeDebugLibSerialPort + FdtPL011SerialPortLib) that is set as an override for DXE_RUNTIME_DRIVER modules in "ArmVirt.dsc.inc" to DxeRuntimeDebugLibFdtPL011Uart; - mask all of the above DebugLib class resolution changes in "ArmVirtKvmTool.dsc", because "ArmVirtKvmTool.dsc" uses BaseSerialPortLib16550 rather than PL011 UARTs, - mask all of the above DebugLib class resolution changes in "ArmVirtXen.dsc" too, because "ArmVirtXen.dsc" uses XenConsoleSerialPortLib rather than PL011 UARTs. I regression-tested this change for "ArmVirtKvmTool.dsc" and "ArmVirtXen.dsc" by building them for both DEBUG and RELEASE, both before the patch and after, and comparing the edk2 build report files (focusing on lib class resolutions). There are no changes. Cc: Ard Biesheuvel Cc: Gerd Hoffmann Cc: Julien Grall Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- ArmVirtPkg/ArmVirt.dsc.inc | 13 +++++++++++-- ArmVirtPkg/ArmVirtKvmTool.dsc | 11 +++++++++++ ArmVirtPkg/ArmVirtXen.dsc | 11 +++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 0d7115525497..4ed86b979e1a 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -37,7 +37,7 @@ [LibraryClasses.common] !if $(TARGET) =3D=3D RELEASE DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf !else - DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf + DebugLib|ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartRam= .inf !endif DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseD= ebugPrintErrorLevelLib.inf =20 @@ -189,6 +189,9 @@ [LibraryClasses.common.SEC] PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointerLib.inf MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAlloc= ationLib.inf +!if $(TARGET) !=3D RELEASE + DebugLib|ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFla= sh.inf +!endif =20 [LibraryClasses.common.PEI_CORE] PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf @@ -204,6 +207,9 @@ [LibraryClasses.common.PEI_CORE] =20 PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointerLib.inf SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011Seri= alPortLib.inf +!if $(TARGET) !=3D RELEASE + DebugLib|ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFla= sh.inf +!endif =20 [LibraryClasses.common.PEIM] PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf @@ -219,6 +225,9 @@ [LibraryClasses.common.PEIM] =20 PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/Pei= ServicesTablePointerLib.inf SerialPortLib|ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011Seri= alPortLib.inf +!if $(TARGET) !=3D RELEASE + DebugLib|ArmVirtPkg/Library/DebugLibFdtPL011Uart/DebugLibFdtPL011UartFla= sh.inf +!endif =20 [LibraryClasses.common.DXE_CORE] HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf @@ -246,7 +255,7 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER] MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf !if $(TARGET) !=3D RELEASE - DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibS= erialPort.inf + DebugLib|ArmVirtPkg/Library/DebugLibFdtPL011Uart/DxeRuntimeDebugLibFdtPL= 011Uart.inf !endif VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ibRuntimeDxe.inf =20 diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc index 00b6c64d1c16..f50d53bf158e 100644 --- a/ArmVirtPkg/ArmVirtKvmTool.dsc +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc @@ -77,6 +77,9 @@ [LibraryClasses.common] PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/Fdt16550Ser= ialPortHookLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!endif =20 HwInfoParserLib|DynamicTablesPkg/Library/FdtHwInfoParserLib/FdtHwInfoPar= serLib.inf DynamicPlatRepoLib|DynamicTablesPkg/Library/Common/DynamicPlatRepoLib/Dy= namicPlatRepoLib.inf @@ -88,6 +91,14 @@ [LibraryClasses.common.SEC, LibraryClasses.common.PEI_CO= RE, LibraryClasses.commo PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf PlatformHookLib|ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt165= 50SerialPortHookLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!endif + +[LibraryClasses.common.DXE_RUNTIME_DRIVER] +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibS= erialPort.inf +!endif =20 [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc index f44c1857c961..f0d15b823b9f 100644 --- a/ArmVirtPkg/ArmVirtXen.dsc +++ b/ArmVirtPkg/ArmVirtXen.dsc @@ -29,6 +29,9 @@ [Defines] =20 [LibraryClasses] SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPo= rtLib.inf +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf +!endif RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib= .inf XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf =20 @@ -52,6 +55,11 @@ [LibraryClasses] TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLi= bNull/PeiDxeTpmPlatformHierarchyLib.inf =20 +[LibraryClasses.common.DXE_RUNTIME_DRIVER] +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibS= erialPort.inf +!endif + [LibraryClasses.common.UEFI_DRIVER] UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf =20 @@ -147,6 +155,9 @@ [Components.common] PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib= /PrePiHobListPointerLib.inf MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/Pre= PiMemoryAllocationLib.inf SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSeri= alPortLib.inf +!if $(TARGET) !=3D RELEASE + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPor= t.inf +!endif } =20 # -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109397): https://edk2.groups.io/g/devel/message/109397 Mute This Topic: https://groups.io/mt/101834883/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-