From nobody Mon Feb 9 20:11:18 2026 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 --- 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-