summaryrefslogtreecommitdiffstats
path: root/ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2023-10-08 17:39:10 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-10-26 18:55:43 +0000
commitba5d955e2505e963eaf91f7ba7d7d5db534372ad (patch)
tree32964b54515e13edb92608522cd6592e1d199080 /ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c
parentb7e6d979732f1cf127ffd8ef4e366cf37e43fa37 (diff)
downloadedk2-ba5d955e2505e963eaf91f7ba7d7d5db534372ad.tar.gz
edk2-ba5d955e2505e963eaf91f7ba7d7d5db534372ad.tar.bz2
edk2-ba5d955e2505e963eaf91f7ba7d7d5db534372ad.zip
ArmVirtPkg: introduce DebugLibFdtPL011Uart RAM instance
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 <ardb+tianocore@kernel.org> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Leif Lindholm <quic_llindhol@quicinc.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20231008153912.175941-8-lersek@redhat.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4577 [lersek@redhat.com: add TianoCore BZ reference]
Diffstat (limited to 'ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c')
-rw-r--r--ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c b/ArmVirtPkg/Library/DebugLibFdtPL011Uart/RamNonRuntime.c
new file mode 100644
index 0000000000..715d3400dd
--- /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 <Base.h>
+
+/**
+ Empty library instance constructor, only for ensuring the connectivity of the
+ constructor dependency graph.
+**/
+RETURN_STATUS
+EFIAPI
+DebugLibFdtPL011UartRamConstructor (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}