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.web10.1380.1589821920922732852 for ; Mon, 18 May 2020 10:12:01 -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 3C763106F; Mon, 18 May 2020 10:12:00 -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 0BE2D3F305; Mon, 18 May 2020 10:11:58 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, graeme.gregory@linaro.org, tanmay.jagdale@linaro.org, Ard Biesheuvel Subject: [PATCH] ArmPkg/PlatformBootManagerLib: reject 'default' parity and stop bit count Date: Mon, 18 May 2020 19:11:48 +0200 Message-Id: <20200518171148.6113-1-ard.biesheuvel@arm.com> X-Mailer: git-send-email 2.17.1 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 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c index e6e788e0f107..a030d510aa62 100644 --- a/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c +++ b/ArmPkg/Library/PlatformBootManagerLib/PlatformBm.c @@ -583,6 +583,8 @@ PlatformBootManagerBeforeConsole ( // // Add the hardcoded serial console device path to ConIn, ConOut, ErrOut. // + ASSERT (FixedPcdGet8 (PcdUartDefaultParity) > 0); + ASSERT (FixedPcdGet8 (PcdUartDefaultStopBits) > 0); ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4); CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid); -- 2.17.1