From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.10646.1589891051085895695 for ; Tue, 19 May 2020 05:24:11 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB55E30E; Tue, 19 May 2020 05:24:10 -0700 (PDT) Received: from e123331-lin.nice.arm.com (unknown [10.37.8.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE4E43F52E; Tue, 19 May 2020 05:24:08 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, graeme.gregory@linaro.org, tanmay.jagdale@linaro.org, lersek@redhat.com, sami.mujawar@arm.com, Ard Biesheuvel Subject: [PATCH v2 2/2] ArmPkg/PlatformBootManagerLib: reject 'default' parity and stop bit count Date: Tue, 19 May 2020 14:23:51 +0200 Message-Id: <20200519122351.18405-3-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200519122351.18405-1-ard.biesheuvel@arm.com> References: <20200519122351.18405-1-ard.biesheuvel@arm.com> 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 --- 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 f713605c02b2..3411219fbfdb 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); -- 2.17.1