Files

47 lines
1.4 KiB
INI
Raw Permalink Normal View History

Platform/RaspberryPi: introduce DebugDualSerialPortLib On DEBUG builds that use the serial port directly for debug output, every module reinitializes the UART hardware, through the DebugLib constructor calling SerialPortInitialize. This is unnecessary, but usually harmless. However, in cases where this requires information that is non-trivial to obtain (e.g., the rate of the clock source feeding the baud clock), it results in a special kind of dependency hell that can only be fully appreciated by seasoned EDK2 connoisseurs [0]. As a first step towards solving this mess, implement a special version of the Raspberry Pi dual serial port library that only implements the SerialPortInitialize() and SerialPortWrite() library functions, and make the former an empty stub. This makes it only suitable for use by modules that inherit a dependency on SerialPortLib via DebugLib, and requires us to ensure that the baud clock is programmed correctly by the SEC phase. Use this version of the library to satisfy all SerialPortLib dependencies except the ones in PrePi and in SerialDxe. These will retain the full version, which is the only one that still consumes PcdSerialClockRate. [0] There are two distinct problems making this mess almost unsolvable: - SerialPortInitialize() is called directly in various places instead of relying on constructor ordering, so adding a constructor to a SerialPortLib implementation does not help, - Constructor ordering resolution in the EDK2 tooling fails to take transitive dependencies into account if an intermediate library has no constructor it self. For instance, if LibA depends on LibB, which depends on LibC, the constructors of LibA and LibC could be called in any order if LibB does not have a constructor itself (and fixing this breaks all the platforms in the tree) Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com> Reviewed-by: Pete Batard <pete@akeo.ie> Tested-by: Pete Batard <pete@akeo.ie>
2020-05-05 14:39:21 +02:00
## @file
#
# SerialPortLib instance for both PL011 and 16550 UART that satisfies
# only the dependencies of DebugLib.
#
# Copyright (c) 2020, Pete Batard <pete@akeo.ie>
# Copyright (c) 2012 - 2020, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 1.27
BASE_NAME = DebugDualSerialPortLib
FILE_GUID = 323bae1b-c2fc-4929-a2fe-9e9174f8ce0f
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = SerialPortLib
[Packages]
ArmPlatformPkg/ArmPlatformPkg.dec
MdeModulePkg/MdeModulePkg.dec
MdePkg/MdePkg.dec
Silicon/Broadcom/Bcm283x/Bcm283x.dec
[LibraryClasses]
IoLib
PcdLib
PL011UartLib
[Sources]
DebugDualSerialPortLib.c
DualSerialPortLib.h
DualSerialPortLibCommon.c
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHardwareFlowControl ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialDetectCable ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## CONSUMES
[FixedPcd]
gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress ## CONSUMES