ArmVirtPkg: Add early FDT 16550 serial port probe library

Fdt16550SerialPortHookLib does not provide a constructor and
expects SerialPortLib to call PlatformHookSerialPortInitialize().

Add an early FDT 16550 serial port probe library that invokes the
platform serial hook from its constructor. This allows the FDT to be
parsed early, the 16550 serial port base address to be extracted, and
the serial port PCD to be populated. It is needed during early boot so
the serial port memory map can be set up using the populated serial
port PCD.

The probe library wraps the hook call in its constructor instead of
reusing PlatformHookSerialPortInitialize() directly. This avoids
duplicate global definitions in modules that already link against the
PlatformHookLib instance.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Sami Mujawar 2026-06-15 16:24:28 +01:00 committed by mergify[bot]
parent da1ccea67c
commit 2adf8dc56d
2 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,31 @@
/** @file
Early FDT 16550 serial port probe constructor.
Copyright (c) 2026, ARM Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>
#include <Library/PlatformHookLib.h>
/**
Early constructor to probe the FDT for the 16550 UART base address.
This constructor invokes the platform serial hook so early boot code can
populate PcdSerialRegisterBase before it is used.
@retval RETURN_SUCCESS The serial port base address was already
configured or was found and stored.
@retval RETURN_INVALID_PARAMETER A parameter was invalid.
@retval RETURN_NOT_FOUND Serial port information was not found.
@retval RETURN_PROTOCOL_ERROR Invalid serial port information was found
in the device tree.
**/
RETURN_STATUS
EFIAPI
EarlyFdt16550SerialPortProbeLibConstructor (
VOID
)
{
return PlatformHookSerialPortInitialize ();
}

View file

@ -0,0 +1,29 @@
## @file
# Early Platform Probe Library instance for 16550 Uart.
#
# Copyright (c) 2026, ARM Ltd. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x0001001B
BASE_NAME = EarlyFdt16550SerialPortProbeLib
MODULE_UNI_FILE = Fdt16550SerialPortHookLib.uni
FILE_GUID = 07a000d5-7de7-485f-ab59-a2ce4da5e488
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = NULL|SEC PEI_CORE PEIM
CONSTRUCTOR = EarlyFdt16550SerialPortProbeLibConstructor
[Sources]
EarlyFdt16550SerialPortProbeLib.c
[LibraryClasses]
PlatformHookLib
[Packages]
ArmVirtPkg/ArmVirtPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec