From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) by mx.groups.io with SMTP id smtpd.web11.17657.1653556618084048729 for ; Thu, 26 May 2022 02:16:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@starlabs-systems.20210112.gappssmtp.com header.s=20210112 header.b=VoeTEEi7; spf=pass (domain: starlabs.systems, ip: 209.85.128.174, mailfrom: sean@starlabs.systems) Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-300beab2b76so8688147b3.13 for ; Thu, 26 May 2022 02:16:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=starlabs-systems.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9zwyjfwlAzRonb4NusWVyNSK8jCnnYRO/tkLwpxV/u8=; b=VoeTEEi7wlhJPHokPv/kzDSHFps93r6szjWsA+uKWBdt/h8ZAfjsRTeKSM8bvEF7qJ Nccvrk8gsNbYb5b1a8mMk5ztEFYYS5xGgOqx0lQ01nb2mipQ1KtuXuqhCwXZhds1lxfA CfuMTscSX6uEDV5LRKkrVz56XANGXYjkvSchIkgqScCG/vfv/w9v7d1nDdBW8ExLQD56 mXEKp2rIgIUbnviX+J+gktmJO0IEnNN+rGEJTx3ZrXdxUs+Ca91dzRnfPqQtAxGhQjwh dkopF+3DAQqIYKOh/hL2B3LspUP0qk4aASt1PES3XRPI4R5lf60P5tgk20uFy9W4E1Zq TaTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9zwyjfwlAzRonb4NusWVyNSK8jCnnYRO/tkLwpxV/u8=; b=ybKd5G+YcT3cFwKJPB40jrDsvb/kRDWb7AXQvr5uXwKqWdKgru/twVdPjvZoGf/oBL DxwNT8Wqwd+pKuABkbNQVwE+kQsk6Ku9N/jh/Dla//CVSs7i554Lci7ChsmeloUrj8PQ DtxQGZtz1o0ia5IivFS6Au+Avoinyh6Comjh7yHYTzSK59+lrxkC+0ilKANdVtS6vPl0 dLQFuhFKIjbvg38Ujah06e5shBLOkAtCh8dKfkdGPjRp8wEkXBeLeHaGdgspMWD0Rx4/ ROBFA7LNliPS+h3Dz8e+7Ktlkiadnk0NcH9kPu9h5LNil3Y35yrI3euAks9Ej/PsSyPA rKtw== X-Gm-Message-State: AOAM532WWzz0J6qbQQUxxo2XdJ3JnhJZT3dK0hDmUsQ9VfFT5LTIKSew bZSa/26LpCLNGBfmjC0AsRg228jPUktrwa1rwVKB X-Google-Smtp-Source: ABdhPJzz+QbAMW5wN3D9E0N0N8it8Bh3luzStP6mqxGBARG4xObW8HzgER19FSjNksH+cb59Tk4BOTxWaM6/WhCbo1o= X-Received: by 2002:a81:a04a:0:b0:2ff:2252:82ab with SMTP id x71-20020a81a04a000000b002ff225282abmr39408259ywg.190.1653556616963; Thu, 26 May 2022 02:16:56 -0700 (PDT) MIME-Version: 1.0 References: <20220522184708.1015315-1-benjamin.doron00@gmail.com> In-Reply-To: <20220522184708.1015315-1-benjamin.doron00@gmail.com> From: "Sean Rhodes" Date: Thu, 26 May 2022 10:16:44 +0100 Message-ID: Subject: Re: [PATCH v2] UefiPayloadPkg: Add support for logging to CBMEM console To: Benjamin Doron Cc: devel@edk2.groups.io, Guo Dong , Ray Ni , Maurice Ma , Benjamin You Content-Type: multipart/alternative; boundary="000000000000c53d0305dfe6a65f" --000000000000c53d0305dfe6a65f Content-Type: text/plain; charset="UTF-8" Reviewed-by: Sean Rhodes On Sun, 22 May 2022 at 19:47, Benjamin Doron wrote: > Writes TianoCore debug logs into the CBMEM console ringbuffer, from > where the user can retrieve them with the `cbmem` userspace utility. > > The intention is to aid in debugging non-fatal issues even in release > builds, or simply make TianoCore's logs available to those interested. > Consequently, MDEPKG_NDEBUG must be masked. As an in-memory debug > logging library, ASSERTs must be non-fatal to be seen, so they neither > dead-loop nor create a breakpoint. It is assumed that ASSERT() neither > enforces fatal conditions nor security integrity, as release builds do > not call DebugAssert() from the ASSERT macro. > > More detailed debug logs are produced with the DEBUG_CODE macro, but > this guards other debug-related code throughout the codebase. To avoid > changing behaviour on release builds, this is only set for debug builds. > > Tested on QEMU, dumping the appropriate memory region in the UEFI shell > shows the TianoCore log. An improved revision of the debug library used > in several coreboot-related EDK2 forks, including MrChromebox's. > Previous revisions also tested on an Acer Aspire VN7-572G laptop. > > Cc: Guo Dong > Cc: Ray Ni > Cc: Maurice Ma > Cc: Benjamin You > Cc: Sean Rhodes > Signed-off-by: Benjamin Doron > --- > UefiPayloadPkg/Include/Coreboot.h | 12 + > UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c | 258 > ++++++++++++++++++++ > UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf | 30 +++ > UefiPayloadPkg/UefiPayloadPkg.dsc | 25 +- > 4 files changed, 320 insertions(+), 5 deletions(-) > > diff --git a/UefiPayloadPkg/Include/Coreboot.h > b/UefiPayloadPkg/Include/Coreboot.h > index a3e1109fe84e..4c9cf965519b 100644 > --- a/UefiPayloadPkg/Include/Coreboot.h > +++ b/UefiPayloadPkg/Include/Coreboot.h > @@ -199,6 +199,12 @@ struct cb_forward { > UINT64 forward; > }; > > +struct cb_cbmem_ref { > + UINT32 tag; > + UINT32 size; > + UINT64 cbmem_addr; > +}; > + > #define CB_TAG_FRAMEBUFFER 0x0012 > struct cb_framebuffer { > UINT32 tag; > @@ -229,6 +235,12 @@ struct cb_vdat { > > #define CB_TAG_TIMESTAMPS 0x0016 > #define CB_TAG_CBMEM_CONSOLE 0x0017 > +struct cbmem_console { > + UINT32 size; > + UINT32 cursor; > + UINT8 body[0]; > +} __attribute__((packed)); > + > #define CB_TAG_MRC_CACHE 0x0018 > struct cb_cbmem_tab { > UINT32 tag; > diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c > b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c > new file mode 100644 > index 000000000000..f7c06b0f41e9 > --- /dev/null > +++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c > @@ -0,0 +1,258 @@ > +/** @file > + CBMEM console SerialPortLib instance > + > + Copyright (c) 2022, Baruch Binyamin Doron > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > + > +#include > +#include > +#include > + > +// Upper nibble contains flags > +#define CBMC_CURSOR_MASK ((1 << 28) - 1) > +#define CBMC_OVERFLOW (1 << 31) > + > +STATIC struct cbmem_console *gCbConsole = NULL; > + > +/** > + Find coreboot record with given Tag. > + NOTE: This coreboot-specific function definition is absent > + from the common BlParseLib header. > + > + @param Tag The tag id to be found > + > + @retval NULL The Tag is not found. > + @retval Others The pointer to the record found. > + > +**/ > +VOID * > +FindCbTag ( > + IN UINT32 Tag > + ); > + > +/** > + Initialize the serial device hardware. > + > + If no initialization is required, then return RETURN_SUCCESS. > + If the serial device was successfully initialized, then return > RETURN_SUCCESS. > + If the serial device could not be initialized, then return > RETURN_DEVICE_ERROR. > + > + @retval RETURN_SUCCESS The serial device was initialized. > + @retval RETURN_DEVICE_ERROR The serial device could not be > initialized. > + > +**/ > +RETURN_STATUS > +EFIAPI > +SerialPortInitialize ( > + VOID > + ) > +{ > + struct cb_cbmem_ref *cbref = FindCbTag(CB_TAG_CBMEM_CONSOLE); > + if (!cbref) { > + return RETURN_DEVICE_ERROR; > + } > + > + gCbConsole = (VOID *)(UINTN)cbref->cbmem_addr; // Support PEI and DXE > + if (gCbConsole == NULL) { > + return RETURN_DEVICE_ERROR; > + } > + > + return RETURN_SUCCESS; > +} > + > +/** > + Write data from buffer to serial device. > + > + Writes NumberOfBytes data bytes from Buffer to the serial device. > + The number of bytes actually written to the serial device is returned. > + If the return value is less than NumberOfBytes, then the write > operation failed. > + If Buffer is NULL, then ASSERT(). > + If NumberOfBytes is zero, then return 0. > + > + @param Buffer Pointer to the data buffer to be written. > + @param NumberOfBytes Number of bytes to written to the serial > device. > + > + @retval 0 NumberOfBytes is 0. > + @retval >0 The number of bytes written to the serial > device. > + If this value is less than NumberOfBytes, then > the write operation failed. > + > +**/ > +UINTN > +EFIAPI > +SerialPortWrite ( > + IN UINT8 *Buffer, > + IN UINTN NumberOfBytes > + ) > +{ > + UINT32 cursor; > + UINT32 flags; > + > + if (Buffer == NULL || NumberOfBytes == 0) { > + return 0; > + } > + > + if (!gCbConsole) { > + return 0; > + } > + > + cursor = gCbConsole->cursor & CBMC_CURSOR_MASK; > + flags = gCbConsole->cursor & ~CBMC_CURSOR_MASK; > + if (cursor >= gCbConsole->size) { > + // Already overflowed; bail out. TODO: Is this unnecessarily cautious? > + // - Supports old coreboot version with legacy overflow mechanism. > + return 0; > + } > + > + if (cursor + NumberOfBytes > gCbConsole->size) { > + // Will overflow, zero cursor and set flag. > + cursor = 0; > + flags |= CBMC_OVERFLOW; > + } > + > + // Longest debug messages supported by a DebugLib seems to be > CHAR16[0x100] == 512. > + // So, no chance that one message could overflow even the smallest > buffer. > + CopyMem (&gCbConsole->body[cursor], Buffer, NumberOfBytes); > + cursor += NumberOfBytes; > + > + if (cursor == gCbConsole->size) { > + // Next message will overflow, zero cursor. > + // - But not overflowed yet. Do not set flag. > + cursor = 0; > + } > + > + gCbConsole->cursor = flags | cursor; > + > + return NumberOfBytes; > +} > + > +/** > + Read data from serial device and save the datas in buffer. > + > + Reads NumberOfBytes data bytes from a serial device into the buffer > + specified by Buffer. The number of bytes actually read is returned. > + If Buffer is NULL, then ASSERT(). > + If NumberOfBytes is zero, then return 0. > + > + @param Buffer Pointer to the data buffer to store the data > read from the serial device. > + @param NumberOfBytes Number of bytes which will be read. > + > + @retval 0 Read data failed, no data is to be read. > + @retval >0 Actual number of bytes read from serial device. > + > +**/ > +UINTN > +EFIAPI > +SerialPortRead ( > + OUT UINT8 *Buffer, > + IN UINTN NumberOfBytes > +) > +{ > + return 0; > +} > + > +/** > + Polls a serial device to see if there is any data waiting to be read. > + > + @retval TRUE Data is waiting to be read from the serial > device. > + @retval FALSE There is no data waiting to be read from the > serial device. > + > +**/ > +BOOLEAN > +EFIAPI > +SerialPortPoll ( > + VOID > + ) > +{ > + return FALSE; > +} > + > +/** > + Sets the control bits on a serial device. > + > + @param Control Sets the bits of Control that are > settable. > + > + @retval RETURN_SUCCESS The new control bits were set on the > serial device. > + @retval RETURN_UNSUPPORTED The serial device does not support this > operation. > + @retval RETURN_DEVICE_ERROR The serial device is not functioning > correctly. > + > +**/ > +RETURN_STATUS > +EFIAPI > +SerialPortSetControl ( > + IN UINT32 Control > + ) > +{ > + return RETURN_UNSUPPORTED; > +} > + > +/** > + Retrieve the status of the control bits on a serial device. > + > + @param Control A pointer to return the current control > signals from the serial device. > + > + @retval RETURN_SUCCESS The control bits were read from the > serial device. > + @retval RETURN_UNSUPPORTED The serial device does not support this > operation. > + @retval RETURN_DEVICE_ERROR The serial device is not functioning > correctly. > + > +**/ > +RETURN_STATUS > +EFIAPI > +SerialPortGetControl ( > + OUT UINT32 *Control > + ) > +{ > + return RETURN_UNSUPPORTED; > +} > + > +/** > + Sets the baud rate, receive FIFO depth, transmit/receive time out, > parity, > + data bits, and stop bits on a serial device. > + > + @param BaudRate The requested baud rate. A BaudRate value of > 0 will use the > + device's default interface speed. > + On output, the value actually set. > + @param ReceiveFifoDepth The requested depth of the FIFO on the > receive side of the > + serial interface. A ReceiveFifoDepth value of > 0 will use > + the device's default FIFO depth. > + On output, the value actually set. > + @param Timeout The requested time out for a single character > in microseconds. > + This timeout applies to both the transmit and > receive side of the > + interface. A Timeout value of 0 will use the > device's default time > + out value. > + On output, the value actually set. > + @param Parity The type of parity to use on this serial > device. A Parity value of > + DefaultParity will use the device's default > parity value. > + On output, the value actually set. > + @param DataBits The number of data bits to use on the serial > device. A DataBits > + value of 0 will use the device's default data > bit setting. > + On output, the value actually set. > + @param StopBits The number of stop bits to use on this serial > device. A StopBits > + value of DefaultStopBits will use the > device's default number of > + stop bits. > + On output, the value actually set. > + > + @retval RETURN_SUCCESS The new attributes were set on the > serial device. > + @retval RETURN_UNSUPPORTED The serial device does not support > this operation. > + @retval RETURN_INVALID_PARAMETER One or more of the attributes has an > unsupported value. > + @retval RETURN_DEVICE_ERROR The serial device is not functioning > correctly. > + > +**/ > +RETURN_STATUS > +EFIAPI > +SerialPortSetAttributes ( > + IN OUT UINT64 *BaudRate, > + IN OUT UINT32 *ReceiveFifoDepth, > + IN OUT UINT32 *Timeout, > + IN OUT EFI_PARITY_TYPE *Parity, > + IN OUT UINT8 *DataBits, > + IN OUT EFI_STOP_BITS_TYPE *StopBits > + ) > +{ > + return RETURN_UNSUPPORTED; > +} > + > diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf > b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf > new file mode 100644 > index 000000000000..3df6a0c736a5 > --- /dev/null > +++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf > @@ -0,0 +1,30 @@ > +## @file > +# Component description file for CbSerialPortLib library. > +# > +# Copyright (c) 2022, Baruch Binyamin Doron > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION = 0x00010005 > + BASE_NAME = CbSerialPortLib > + FILE_GUID = 0DB3EF12-1426-4086-B012-113184C4CE11 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + # Recall that debug logging can be unsafe to core. Route over RSC. > + LIBRARY_CLASS = SerialPortLib > + CONSTRUCTOR = SerialPortInitialize > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + UefiPayloadPkg/UefiPayloadPkg.dec > + > +[LibraryClasses] > + BaseMemoryLib > + BlParseLib > + > +[Sources] > + CbSerialPortLib.c > + > diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc > b/UefiPayloadPkg/UefiPayloadPkg.dsc > index 4d9bbc80c866..0e4248767756 100644 > --- a/UefiPayloadPkg/UefiPayloadPkg.dsc > +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc > @@ -37,6 +37,7 @@ > DEFINE ABOVE_4G_MEMORY = TRUE > DEFINE BOOT_MANAGER_ESCAPE = FALSE > DEFINE SD_MMC_TIMEOUT = 1000000 > + DEFINE USE_CBMEM_FOR_CONSOLE = FALSE > # > # SBL: UEFI payload for Slim Bootloader > # COREBOOT: UEFI payload for coreboot > @@ -121,10 +122,11 @@ > > [BuildOptions] > *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES > - GCC:*_UNIXGCC_*_CC_FLAGS = -DMDEPKG_NDEBUG > +!if $(USE_CBMEM_FOR_CONSOLE) == FALSE > GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG > INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG > MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG > +!endif > > [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] > GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 > @@ -231,8 +233,13 @@ > TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf > !endif > ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf > +!if $(USE_CBMEM_FOR_CONSOLE) == TRUE > + SerialPortLib|UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf > + > PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf > +!else > > SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf > > PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf > +!endif > > PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf > IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf > > @@ -422,10 +429,18 @@ > gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, > 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, > 0x23, 0x31 } > gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7 > gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F > -!if $(SOURCE_DEBUG_ENABLE) > - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 > +!if $(USE_CBMEM_FOR_CONSOLE) == FALSE > + !if $(SOURCE_DEBUG_ENABLE) > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17 > + !else > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F > + !endif > !else > - gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F > + !if $(TARGET) == DEBUG > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x07 > + !else > + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x03 > + !endif > !endif > > gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|$(MAX_SIZE_NON_POPULATE_CAPSULE) > # > @@ -471,7 +486,7 @@ > gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode > gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress > gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize > -!if $(TARGET) == DEBUG > +!if ($(TARGET) == DEBUG || $(USE_CBMEM_FOR_CONSOLE) == TRUE) > gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE > !else > gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE > -- > 2.36.1 > > --000000000000c53d0305dfe6a65f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Sean Rhodes <sean@starlabs.systems>


On = Sun, 22 May 2022 at 19:47, Benjamin Doron <benjamin.doron00@gmail.com> wrote:
Writes TianoCore debug logs into= the CBMEM console ringbuffer, from
where the user can retrieve them with the `cbmem` userspace utility.

The intention is to aid in debugging non-fatal issues even in release
builds, or simply make TianoCore's logs available to those interested.<= br> Consequently, MDEPKG_NDEBUG must be masked. As an in-memory debug
logging library, ASSERTs must be non-fatal to be seen, so they neither
dead-loop nor create a breakpoint. It is assumed that ASSERT() neither
enforces fatal conditions nor security integrity, as release builds do
not call DebugAssert() from the ASSERT macro.

More detailed debug logs are produced with the DEBUG_CODE macro, but
this guards other debug-related code throughout the codebase. To avoid
changing behaviour on release builds, this is only set for debug builds.
Tested on QEMU, dumping the appropriate memory region in the UEFI shell
shows the TianoCore log. An improved revision of the debug library used
in several coreboot-related EDK2 forks, including MrChromebox's.
Previous revisions also tested on an Acer Aspire VN7-572G laptop.

Cc: Guo Dong <gu= o.dong@intel.com>
Cc: Ray Ni <ray.ni= @intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Benjamin Doron <benjamin.doron00@gmail.com>
---
=C2=A0UefiPayloadPkg/Include/Coreboot.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 12 +
=C2=A0UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c=C2=A0 =C2=A0= | 258 ++++++++++++++++++++
=C2=A0UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf |=C2=A0 30= +++
=C2=A0UefiPayloadPkg/UefiPayloadPkg.dsc=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 25 +-
=C2=A04 files changed, 320 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/Include/Coreboot.h b/UefiPayloadPkg/Include/Cor= eboot.h
index a3e1109fe84e..4c9cf965519b 100644
--- a/UefiPayloadPkg/Include/Coreboot.h
+++ b/UefiPayloadPkg/Include/Coreboot.h
@@ -199,6 +199,12 @@ struct cb_forward {
=C2=A0 =C2=A0UINT64=C2=A0 =C2=A0 forward;
=C2=A0};

+struct cb_cbmem_ref {
+=C2=A0 UINT32 tag;
+=C2=A0 UINT32 size;
+=C2=A0 UINT64 cbmem_addr;
+};
+
=C2=A0#define CB_TAG_FRAMEBUFFER=C2=A0 0x0012
=C2=A0struct cb_framebuffer {
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 tag;
@@ -229,6 +235,12 @@ struct cb_vdat {

=C2=A0#define CB_TAG_TIMESTAMPS=C2=A0 =C2=A0 =C2=A00x0016
=C2=A0#define CB_TAG_CBMEM_CONSOLE=C2=A0 0x0017
+struct cbmem_console {
+=C2=A0 UINT32 size;
+=C2=A0 UINT32 cursor;
+=C2=A0 UINT8=C2=A0 body[0];
+} __attribute__((packed));
+
=C2=A0#define CB_TAG_MRC_CACHE=C2=A0 =C2=A0 =C2=A0 0x0018
=C2=A0struct cb_cbmem_tab {
=C2=A0 =C2=A0UINT32=C2=A0 =C2=A0 tag;
diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c b/Uef= iPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c
new file mode 100644
index 000000000000..f7c06b0f41e9
--- /dev/null
+++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c
@@ -0,0 +1,258 @@
+/** @file
+=C2=A0 CBMEM console SerialPortLib instance
+
+=C2=A0 Copyright (c) 2022, Baruch Binyamin Doron
+=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Coreboot.h>
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/BlParseLib.h>
+#include <Library/SerialPortLib.h>
+
+// Upper nibble contains flags
+#define CBMC_CURSOR_MASK ((1 << 28) - 1)
+#define CBMC_OVERFLOW (1 << 31)
+
+STATIC struct cbmem_console=C2=A0 *gCbConsole =3D NULL;
+
+/**
+=C2=A0 Find coreboot record with given Tag.
+=C2=A0 NOTE: This coreboot-specific function definition is absent
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from the common BlParseLib header.
+
+=C2=A0 @param=C2=A0 Tag=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 The tag id to be found
+
+=C2=A0 @retval NULL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The Ta= g is not found.
+=C2=A0 @retval Others=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The pointer= to the record found.
+
+**/
+VOID *
+FindCbTag (
+=C2=A0 IN=C2=A0 UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Tag
+=C2=A0 );
+
+/**
+=C2=A0 Initialize the serial device hardware.
+
+=C2=A0 If no initialization is required, then return RETURN_SUCCESS.
+=C2=A0 If the serial device was successfully initialized, then return RETU= RN_SUCCESS.
+=C2=A0 If the serial device could not be initialized, then return RETURN_D= EVICE_ERROR.
+
+=C2=A0 @retval RETURN_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 The serial device= was initialized.
+=C2=A0 @retval RETURN_DEVICE_ERROR=C2=A0 =C2=A0The serial device could not= be initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortInitialize (
+=C2=A0 VOID
+=C2=A0 )
+{
+=C2=A0 struct cb_cbmem_ref *cbref =3D FindCbTag(CB_TAG_CBMEM_CONSOLE);
+=C2=A0 if (!cbref) {
+=C2=A0 =C2=A0 return RETURN_DEVICE_ERROR;
+=C2=A0 }
+
+=C2=A0 gCbConsole =3D (VOID *)(UINTN)cbref->cbmem_addr;=C2=A0 // Suppor= t PEI and DXE
+=C2=A0 if (gCbConsole =3D=3D NULL) {
+=C2=A0 =C2=A0 return RETURN_DEVICE_ERROR;
+=C2=A0 }
+
+=C2=A0 return RETURN_SUCCESS;
+}
+
+/**
+=C2=A0 Write data from buffer to serial device.
+
+=C2=A0 Writes NumberOfBytes data bytes from Buffer to the serial device. +=C2=A0 The number of bytes actually written to the serial device is return= ed.
+=C2=A0 If the return value is less than NumberOfBytes, then the write oper= ation failed.
+=C2=A0 If Buffer is NULL, then ASSERT().
+=C2=A0 If NumberOfBytes is zero, then return 0.
+
+=C2=A0 @param=C2=A0 Buffer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Pointer= to the data buffer to be written.
+=C2=A0 @param=C2=A0 NumberOfBytes=C2=A0 =C2=A0 Number of bytes to written = to the serial device.
+
+=C2=A0 @retval 0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Nu= mberOfBytes is 0.
+=C2=A0 @retval >0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0The number of bytes written to the serial device.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0If this value is less than NumberOfBytes, then the = write operation failed.
+
+**/
+UINTN
+EFIAPI
+SerialPortWrite (
+=C2=A0 IN UINT8=C2=A0 =C2=A0 =C2=A0*Buffer,
+=C2=A0 IN UINTN=C2=A0 =C2=A0 =C2=A0NumberOfBytes
+=C2=A0 )
+{
+=C2=A0 UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cursor;
+=C2=A0 UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 flags;
+
+=C2=A0 if (Buffer =3D=3D NULL || NumberOfBytes =3D=3D 0) {
+=C2=A0 =C2=A0 return 0;
+=C2=A0 }
+
+=C2=A0 if (!gCbConsole) {
+=C2=A0 =C2=A0 return 0;
+=C2=A0 }
+
+=C2=A0 cursor =3D gCbConsole->cursor & CBMC_CURSOR_MASK;
+=C2=A0 flags =3D gCbConsole->cursor & ~CBMC_CURSOR_MASK;
+=C2=A0 if (cursor >=3D gCbConsole->size) {
+=C2=A0 =C2=A0 // Already overflowed; bail out. TODO: Is this unnecessarily= cautious?
+=C2=A0 =C2=A0 // - Supports old coreboot version with legacy overflow mech= anism.
+=C2=A0 =C2=A0 return 0;
+=C2=A0 }
+
+=C2=A0 if (cursor + NumberOfBytes > gCbConsole->size) {
+=C2=A0 =C2=A0 // Will overflow, zero cursor and set flag.
+=C2=A0 =C2=A0 cursor =3D 0;
+=C2=A0 =C2=A0 flags |=3D CBMC_OVERFLOW;
+=C2=A0 }
+
+=C2=A0 // Longest debug messages supported by a DebugLib seems to be CHAR1= 6[0x100] =3D=3D 512.
+=C2=A0 // So, no chance that one message could overflow even the smallest = buffer.
+=C2=A0 CopyMem (&gCbConsole->body[cursor], Buffer, NumberOfBytes);<= br> +=C2=A0 cursor +=3D NumberOfBytes;
+
+=C2=A0 if (cursor =3D=3D gCbConsole->size) {
+=C2=A0 =C2=A0 // Next message will overflow, zero cursor.
+=C2=A0 =C2=A0 // - But not overflowed yet. Do not set flag.
+=C2=A0 =C2=A0 cursor =3D 0;
+=C2=A0 }
+
+=C2=A0 gCbConsole->cursor =3D flags | cursor;
+
+=C2=A0 return NumberOfBytes;
+}
+
+/**
+=C2=A0 Read data from serial device and save the datas in buffer.
+
+=C2=A0 Reads NumberOfBytes data bytes from a serial device into the buffer=
+=C2=A0 specified by Buffer. The number of bytes actually read is returned.=
+=C2=A0 If Buffer is NULL, then ASSERT().
+=C2=A0 If NumberOfBytes is zero, then return 0.
+
+=C2=A0 @param=C2=A0 Buffer=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Pointer= to the data buffer to store the data read from the serial device.
+=C2=A0 @param=C2=A0 NumberOfBytes=C2=A0 =C2=A0 Number of bytes which will = be read.
+
+=C2=A0 @retval 0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Re= ad data failed, no data is to be read.
+=C2=A0 @retval >0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Actual number of bytes read from serial device.
+
+**/
+UINTN
+EFIAPI
+SerialPortRead (
+=C2=A0 OUT UINT8=C2=A0 =C2=A0 =C2=A0*Buffer,
+=C2=A0 IN=C2=A0 UINTN=C2=A0 =C2=A0 =C2=A0NumberOfBytes
+)
+{
+=C2=A0 return 0;
+}
+
+/**
+=C2=A0 Polls a serial device to see if there is any data waiting to be rea= d.
+
+=C2=A0 @retval TRUE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Data is= waiting to be read from the serial device.
+=C2=A0 @retval FALSE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 There is no = data waiting to be read from the serial device.
+
+**/
+BOOLEAN
+EFIAPI
+SerialPortPoll (
+=C2=A0 VOID
+=C2=A0 )
+{
+=C2=A0 return FALSE;
+}
+
+/**
+=C2=A0 Sets the control bits on a serial device.
+
+=C2=A0 @param Control=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 Sets the bits of Control that are settable.
+
+=C2=A0 @retval RETURN_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 The new control b= its were set on the serial device.
+=C2=A0 @retval RETURN_UNSUPPORTED=C2=A0 =C2=A0 The serial device does not = support this operation.
+=C2=A0 @retval RETURN_DEVICE_ERROR=C2=A0 =C2=A0The serial device is not fu= nctioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetControl (
+=C2=A0 IN UINT32 Control
+=C2=A0 )
+{
+=C2=A0 return RETURN_UNSUPPORTED;
+}
+
+/**
+=C2=A0 Retrieve the status of the control bits on a serial device.
+
+=C2=A0 @param Control=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 A pointer to return the current control signals from the serial device.=
+
+=C2=A0 @retval RETURN_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 The control bits = were read from the serial device.
+=C2=A0 @retval RETURN_UNSUPPORTED=C2=A0 =C2=A0 The serial device does not = support this operation.
+=C2=A0 @retval RETURN_DEVICE_ERROR=C2=A0 =C2=A0The serial device is not fu= nctioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortGetControl (
+=C2=A0 OUT UINT32 *Control
+=C2=A0 )
+{
+=C2=A0 return RETURN_UNSUPPORTED;
+}
+
+/**
+=C2=A0 Sets the baud rate, receive FIFO depth, transmit/receive time out, = parity,
+=C2=A0 data bits, and stop bits on a serial device.
+
+=C2=A0 @param BaudRate=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The request= ed baud rate. A BaudRate value of 0 will use the
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 device's default interface speed.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+=C2=A0 @param ReceiveFifoDepth=C2=A0 =C2=A0The requested depth of the FIFO= on the receive side of the
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 serial interface. A ReceiveFifoDepth value of 0 wi= ll use
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 the device's default FIFO depth.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+=C2=A0 @param Timeout=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The request= ed time out for a single character in microseconds.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 This timeout applies to both the transmit and rece= ive side of the
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 interface. A Timeout value of 0 will use the devic= e's default time
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 out value.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+=C2=A0 @param Parity=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The ty= pe of parity to use on this serial device. A Parity value of
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 DefaultParity will use the device's default pa= rity value.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+=C2=A0 @param DataBits=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The number = of data bits to use on the serial device. A DataBits
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 value of 0 will use the device's default data = bit setting.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+=C2=A0 @param StopBits=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0The number = of stop bits to use on this serial device. A StopBits
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 value of DefaultStopBits will use the device's= default number of
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 stop bits.
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 On output, the value actually set.
+
+=C2=A0 @retval RETURN_SUCCESS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 The= new attributes were set on the serial device.
+=C2=A0 @retval RETURN_UNSUPPORTED=C2=A0 =C2=A0 =C2=A0 =C2=A0 The serial de= vice does not support this operation.
+=C2=A0 @retval RETURN_INVALID_PARAMETER=C2=A0 One or more of the attribute= s has an unsupported value.
+=C2=A0 @retval RETURN_DEVICE_ERROR=C2=A0 =C2=A0 =C2=A0 =C2=A0The serial de= vice is not functioning correctly.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortSetAttributes (
+=C2=A0 IN OUT UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*BaudR= ate,
+=C2=A0 IN OUT UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*Recei= veFifoDepth,
+=C2=A0 IN OUT UINT32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*Timeo= ut,
+=C2=A0 IN OUT EFI_PARITY_TYPE=C2=A0 =C2=A0 *Parity,
+=C2=A0 IN OUT UINT8=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *DataB= its,
+=C2=A0 IN OUT EFI_STOP_BITS_TYPE *StopBits
+=C2=A0 )
+{
+=C2=A0 return RETURN_UNSUPPORTED;
+}
+
diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf b/U= efiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf
new file mode 100644
index 000000000000..3df6a0c736a5
--- /dev/null
+++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf
@@ -0,0 +1,30 @@
+## @file
+#=C2=A0 Component description file for CbSerialPortLib library.
+#
+#=C2=A0 Copyright (c) 2022, Baruch Binyamin Doron
+#=C2=A0 SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+=C2=A0 INF_VERSION=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D 0x00010005
+=C2=A0 BASE_NAME=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =3D CbSerialPortLib
+=C2=A0 FILE_GUID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =3D 0DB3EF12-1426-4086-B012-113184C4CE11
+=C2=A0 MODULE_TYPE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D BASE
+=C2=A0 VERSION_STRING=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0=3D 1.0
+=C2=A0 # Recall that debug logging can be unsafe to core. Route over RSC.<= br> +=C2=A0 LIBRARY_CLASS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =3D SerialPortLib
+=C2=A0 CONSTRUCTOR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =3D SerialPortInitialize
+
+[Packages]
+=C2=A0 MdePkg/MdePkg.dec
+=C2=A0 MdeModulePkg/MdeModulePkg.dec
+=C2=A0 UefiPayloadPkg/UefiPayloadPkg.dec
+
+[LibraryClasses]
+=C2=A0 BaseMemoryLib
+=C2=A0 BlParseLib
+
+[Sources]
+=C2=A0 CbSerialPortLib.c
+
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc
index 4d9bbc80c866..0e4248767756 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -37,6 +37,7 @@
=C2=A0 =C2=A0DEFINE ABOVE_4G_MEMORY=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =3D TRUE
=C2=A0 =C2=A0DEFINE BOOT_MANAGER_ESCAPE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =3D FALSE
=C2=A0 =C2=A0DEFINE SD_MMC_TIMEOUT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0=3D 1000000
+=C2=A0 DEFINE USE_CBMEM_FOR_CONSOLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D FALSE =C2=A0 =C2=A0#
=C2=A0 =C2=A0# SBL:=C2=A0 =C2=A0 =C2=A0 UEFI payload for Slim Bootloader =C2=A0 =C2=A0# COREBOOT: UEFI payload for coreboot
@@ -121,10 +122,11 @@

=C2=A0[BuildOptions]
=C2=A0 =C2=A0*_*_*_CC_FLAGS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0=3D -D DISABLE_NEW_DEPRECATED_INTERFACES
-=C2=A0 GCC:*_UNIXGCC_*_CC_FLAGS=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D -DMDEPKG_NDE= BUG
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D FALSE
=C2=A0 =C2=A0GCC:RELEASE_*_*_CC_FLAGS=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D -DMDEPK= G_NDEBUG
=C2=A0 =C2=A0INTEL:RELEASE_*_*_CC_FLAGS=C2=A0 =C2=A0 =C2=A0=3D /D MDEPKG_ND= EBUG
=C2=A0 =C2=A0MSFT:RELEASE_*_*_CC_FLAGS=C2=A0 =C2=A0 =C2=A0 =3D /D MDEPKG_ND= EBUG
+!endif

=C2=A0[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
=C2=A0 =C2=A0GCC:*_*_*_DLINK_FLAGS=C2=A0 =C2=A0 =C2=A0 =3D -z common-page-s= ize=3D0x1000
@@ -231,8 +233,13 @@
=C2=A0 =C2=A0TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf<= br> =C2=A0!endif
=C2=A0 =C2=A0ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSyst= emLib.inf
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D TRUE
+=C2=A0 SerialPortLib|UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLi= b.inf
+=C2=A0 PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePl= atformHookLibNull.inf
+!else
=C2=A0 =C2=A0SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/Base= SerialPortLib16550.inf
=C2=A0 =C2=A0PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/Platfor= mHookLib.inf
+!endif
=C2=A0 =C2=A0PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootMana= gerLib/PlatformBootManagerLib.inf
=C2=A0 =C2=A0IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.i= nf

@@ -422,10 +429,18 @@
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, = 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x6= 6, 0x23, 0x31 }
=C2=A0 =C2=A0gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7 =C2=A0 =C2=A0gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F -!if $(SOURCE_DEBUG_ENABLE)
-=C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D FALSE
+=C2=A0 !if $(SOURCE_DEBUG_ENABLE)
+=C2=A0 =C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17
+=C2=A0 !else
+=C2=A0 =C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+=C2=A0 !endif
=C2=A0!else
-=C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F
+=C2=A0 !if $(TARGET) =3D=3D DEBUG
+=C2=A0 =C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x07
+=C2=A0 !else
+=C2=A0 =C2=A0 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x03
+=C2=A0 !endif
=C2=A0!endif
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|$(= MAX_SIZE_NON_POPULATE_CAPSULE)
=C2=A0 =C2=A0#
@@ -471,7 +486,7 @@
=C2=A0 =C2=A0gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode
=C2=A0 =C2=A0gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress
=C2=A0 =C2=A0gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize
-!if $(TARGET) =3D=3D DEBUG
+!if ($(TARGET) =3D=3D DEBUG || $(USE_CBMEM_FOR_CONSOLE) =3D=3D TRUE)
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE
=C2=A0!else
=C2=A0 =C2=A0gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE --
2.36.1

--000000000000c53d0305dfe6a65f--