From 7191dd3c5990416cf473ce36b3fb84ecb2f7b950 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 19 May 2020 14:23:51 +0200 Subject: [PATCH] ArmPkg/PlatformBootManagerLib: reject 'default' parity and stop bit count In the ArmPkg version of PlatformBootManagerLib, we construct a serial device path based on the default settings for baud rate, parity and the number of stop bits, to ensure that a serial console is available even on the very first boot. This assumes that PcdUartDefaultParity or PcdUartDefaultStopBits are not set to '0', meaning 'the default', as there is no default for these when constructing a device path. So add a couple of STATIC_ASSERT()s to make sure that we catch this condition, since it otherwise ignores the bogus device path silently, which is rather tedious to debug,. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm Reviewed-by: Sami Mujawar Reviewed-by: Laszlo Ersek --- ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index f713605c02..3411219fbf 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -585,6 +585,10 @@ PlatformBootManagerBeforeConsole ( // STATIC_ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4, "PcdDefaultTerminalType must be TTYTERM"); + STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultParity) != 0, + "PcdUartDefaultParity must be set to an actual value, not 'default'"); + STATIC_ASSERT (FixedPcdGet8 (PcdUartDefaultStopBits) != 0, + "PcdUartDefaultStopBits must be set to an actual value, not 'default'"); CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);