The BaseSerialPort16550 library invokes the
PlatformHookSerialPortInitialize() implemented as
part of the PlatformHook library, to perform platform
specific initialization required to enable use of the
16550 device. The BaseSerialPort16550 library uses
the PcdSerialRegisterBase to obtain the base address
of the UART for MMIO operations.
Some VMMs like Kvmtool provide the base address of
the console serial port in the platform device tree.
This patch introduces two instances of the Platform
Hook library:
1. EarlyFdt16550SerialPortHookLib - parses the
platform device tree to extract the base
address of the 16550 UART and update the PCD
PcdSerialRegisterBase.
2. Fdt16550SerialPortHookLib - reads the GUID
Hob gEarly16550UartBaseAddressGuid (that caches
the base address of the 16550 UART discovered
during early stages) and updates the PCD
PcdSerialRegisterBase.
Note:
a. The PCD PcdSerialRegisterBase is configured
as PatchableInModule.
b. A separate patch introduces a PlatformPeiLib
that trampolines the 16550 UART base address
from the Pcd PcdSerialRegisterBase to the
GUID Hob gEarly16550UartBaseAddressGuid.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Ard Biesheuvel <Ard.Biesheuvel@arm.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
/** @file
|
|
Platform Hook Library instance for 16550 Uart.
|
|
|
|
Copyright (c) 2020, ARM Ltd. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#include <Base.h>
|
|
#include <Uefi.h>
|
|
|
|
#include <Pi/PiBootMode.h>
|
|
#include <Pi/PiHob.h>
|
|
|
|
#include <Guid/Early16550UartBaseAddress.h>
|
|
#include <Guid/Fdt.h>
|
|
#include <Guid/FdtHob.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/HobLib.h>
|
|
#include <Library/PcdLib.h>
|
|
#include <Library/PlatformHookLib.h>
|
|
|
|
/** Platform hook to retrieve the 16550 UART base address from the GUID Hob
|
|
that caches the UART base address from early boot stage and store it in
|
|
PcdSerialRegisterBase.
|
|
|
|
@retval RETURN_SUCCESS Success.
|
|
@retval RETURN_NOT_FOUND Serial Port information not found.
|
|
|
|
**/
|
|
RETURN_STATUS
|
|
EFIAPI
|
|
PlatformHookSerialPortInitialize (
|
|
VOID
|
|
)
|
|
{
|
|
VOID *Hob;
|
|
UINT64 *UartBase;
|
|
|
|
if (PcdGet64 (PcdSerialRegisterBase) != 0) {
|
|
return RETURN_SUCCESS;
|
|
}
|
|
|
|
Hob = GetFirstGuidHob (&gEarly16550UartBaseAddressGuid);
|
|
if ((Hob == NULL) || (GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (*UartBase))) {
|
|
return RETURN_NOT_FOUND;
|
|
}
|
|
|
|
UartBase = GET_GUID_HOB_DATA (Hob);
|
|
if ((UINTN)*UartBase == 0) {
|
|
return RETURN_NOT_FOUND;
|
|
}
|
|
|
|
return (RETURN_STATUS)PcdSet64S (PcdSerialRegisterBase, (UINTN)*UartBase);
|
|
}
|