From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Eric Dong <eric.dong@intel.com>,
Isaac Oram <isaac.w.oram@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Sai Chaganty <rangasai.v.chaganty@intel.com>,
Benjamin Doron <benjamin.doron00@gmail.com>,
Michael Kubacki <michael.kubacki@microsoft.com>,
Jeremy Soller <jeremy@system76.com>
Subject: [edk2-platforms] [PATCH V1 4/5] BoardModulePkg: Add BdsSerialPortTerminalLib
Date: Fri, 17 Jun 2022 21:05:49 -0700 [thread overview]
Message-ID: <20220618040550.8467-5-nathaniel.l.desimone@intel.com> (raw)
In-Reply-To: <20220618040550.8467-1-nathaniel.l.desimone@intel.com>
BdsSerialPortTerminalLib add a terminal device
to the Serial UART device created by
MdeModulePkg/Universal/SerialDxe to the UEFI
Console Variables (ConIn, ConOut, ErrOut). This
allows BIOS Setup, UEFI Shell, etc. to be used
on a headless system via a null modem and
terminal emulation software.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Benjamin Doron <benjamin.doron00@gmail.com>
Cc: Michael Kubacki <michael.kubacki@microsoft.com>
Cc: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
---
.../Intel/BoardModulePkg/BoardModulePkg.dsc | 3 +-
.../BdsSerialPortTerminalLib.c | 114 ++++++++++++++++++
.../BdsSerialPortTerminalLib.h | 53 ++++++++
.../BdsSerialPortTerminalLib.inf | 49 ++++++++
4 files changed, 218 insertions(+), 1 deletion(-)
create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h
create mode 100644 Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
index 9f00592a19..c93b536f0d 100644
--- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
+++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dsc
@@ -6,7 +6,7 @@
# INF files to generate AutoGen.c and AutoGen.h files
# for the build infrastructure.
#
-# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -91,3 +91,4 @@
BoardModulePkg/Library/PeiFirmwareBootMediaInfoLib/PeiFirmwareBootMediaInfoLib.inf
BoardModulePkg/Library/BdsPs2KbcLib/BdsPs2KbcLib.inf
+ BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
new file mode 100644
index 0000000000..178ca2b3ac
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.c
@@ -0,0 +1,114 @@
+/** @file
+ Main file for NULL named library that adds a Terminal Device connected
+ to SerialDxe to the UEFI Console Variables. This allows BIOS Setup, UEFI
+ Shell, etc. to be used on a headless system via a null modem and terminal
+ emulator.
+
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "BdsSerialPortTerminalLib.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID *mTerminalType[] = {
+ &gEfiPcAnsiGuid,
+ &gEfiVT100Guid,
+ &gEfiVT100PlusGuid,
+ &gEfiVTUTF8Guid,
+ &gEfiTtyTermGuid
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath = {
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ {
+ (UINT8) sizeof (VENDOR_DEVICE_PATH),
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ }
+ },
+ EDKII_SERIAL_PORT_LIB_VENDOR_GUID
+ },
+ {
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_UART_DP,
+ {
+ (UINT8) sizeof (UART_DEVICE_PATH),
+ (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
+ }
+ },
+ 0, // Reserved
+ 115200, // BaudRate
+ 8, // DataBits
+ 1, // Parity
+ 1 // StopBits
+ },
+ {
+ {
+ MESSAGING_DEVICE_PATH,
+ MSG_VENDOR_DP,
+ {
+ (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),
+ }
+ },
+ DEVICE_PATH_MESSAGING_PC_ANSI
+ },
+ gEndEntire
+};
+
+/**
+ Updates the ConOut, ConIn, ErrOut variables with the serial terminal device path
+ @param none
+ @retval none
+**/
+VOID
+AddSerialTerminal (
+ VOID
+ )
+{
+ DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n"));
+
+ //
+ // Update the Terminal Device Configuration Parameters
+ //
+ mSerialDevicePath.Uart.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
+ mSerialDevicePath.Uart.DataBits = PcdGet8 (PcdUartDefaultDataBits);
+ mSerialDevicePath.Uart.Parity = PcdGet8 (PcdUartDefaultParity);
+ mSerialDevicePath.Uart.StopBits = PcdGet8 (PcdUartDefaultStopBits);
+ CopyMem (
+ (VOID *) &(mSerialDevicePath.TerminalType.Guid),
+ (VOID *) mTerminalType[PcdGet8 (PcdDefaultTerminalType)],
+ sizeof (EFI_GUID)
+ );
+
+ //
+ // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut"
+ //
+ EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
+ EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
+}
+
+/**
+ Constructor for the Serial Port Terminal Device library.
+
+ @param ImageHandle The Image Handle of the process
+ @param SystemTable The EFI System Table pointer
+
+ @retval EFI_SUCCESS The Serial Port Terminal Device was installed successfully
+**/
+EFI_STATUS
+EFIAPI
+SerialPortTerminalLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ AddSerialTerminal ();
+
+ return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h
new file mode 100644
index 0000000000..39d6486712
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.h
@@ -0,0 +1,53 @@
+/** @file
+ Header file for NULL named library that adds a Terminal Device
+ connected to SerialDxe to the UEFI Console Variables. This allows BIOS Setup,
+ UEFI Shell, etc. to be used on a headless system via a null modem and terminal
+ emulator.
+
+ Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef BDS_SERIAL_PORT_TERMINAL_LIB_H_
+#define BDS_SERIAL_PORT_TERMINAL_LIB_H_
+
+#include <Uefi.h>
+#include <Guid/SerialPortLibVendor.h>
+#include <Library/UefiLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+#include <Library/UefiBootManagerLib.h>
+
+//
+// Below is the platform console device path
+//
+typedef struct {
+ VENDOR_DEVICE_PATH Guid;
+ UART_DEVICE_PATH Uart;
+ VENDOR_DEVICE_PATH TerminalType;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} SERIAL_DEVICE_PATH;
+
+#define gPciRootBridge \
+ { \
+ { \
+ ACPI_DEVICE_PATH, \
+ ACPI_DP, \
+ { \
+ (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
+ (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
+ }, \
+ }, \
+ EISA_PNP_ID (0x0A03), \
+ 0 \
+ }
+
+#define gEndEntire \
+ { \
+ END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
+ }
+
+#endif
diff --git a/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
new file mode 100644
index 0000000000..befaeee3e5
--- /dev/null
+++ b/Platform/Intel/BoardModulePkg/Library/BdsSerialPortTerminalLib/BdsSerialPortTerminalLib.inf
@@ -0,0 +1,49 @@
+## @file
+# Component information file for NULL named library that adds a Terminal Device
+# connected to SerialDxe to the UEFI Console Variables. This allows BIOS
+# Setup, UEFI Shell, etc. to be used on a headless system via a null modem and
+# terminal emulator.
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+[Defines]
+ INF_VERSION = 0x00010006
+ BASE_NAME = SerialPortTerminalLib
+ FILE_GUID = E12BFA46-95F2-4ADC-9774-7E38DE78741E
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.2
+ LIBRARY_CLASS = NULL|UEFI_DRIVER
+ CONSTRUCTOR = SerialPortTerminalLibConstructor
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[Sources]
+ BdsSerialPortTerminalLib.c
+ BdsSerialPortTerminalLib.h
+
+[LibraryClasses]
+ BaseMemoryLib
+ DevicePathLib
+ DebugLib
+ UefiDriverEntryPoint
+ UefiBootManagerLib
+ UefiLib
+
+[Guids]
+ gEfiPcAnsiGuid
+ gEfiVT100Guid
+ gEfiVT100PlusGuid
+ gEfiVTUTF8Guid
+ gEfiTtyTermGuid
+
+[Pcd]
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
+ gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+ gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType
--
2.27.0.windows.1
next prev parent reply other threads:[~2022-06-18 4:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-18 4:05 [edk2-platforms] [PATCH V1 0/5] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
2022-06-18 4:05 ` [edk2-platforms] [PATCH V1 1/5] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
2022-06-18 4:05 ` [edk2-platforms] [PATCH V1 2/5] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
2022-06-18 4:05 ` [edk2-platforms] [PATCH V1 3/5] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
2022-06-18 4:05 ` Nate DeSimone [this message]
2022-06-18 4:05 ` [edk2-platforms] [PATCH V1 5/5] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port Nate DeSimone
2022-06-19 20:06 ` [edk2-devel] " Benjamin Doron
2022-06-19 20:13 ` Benjamin Doron
[not found] ` <16F99B5C34E031D3.5445@groups.io>
2022-06-22 18:57 ` [edk2-devel] [edk2-platforms] [PATCH V1 4/5] BoardModulePkg: Add BdsSerialPortTerminalLib Nate DeSimone
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220618040550.8467-5-nathaniel.l.desimone@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox