public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nate DeSimone" <nathaniel.l.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Chasel Chiu <chasel.chiu@intel.com>,
	Sai Chaganty <rangasai.v.chaganty@intel.com>,
	Isaac Oram <isaac.w.oram@intel.com>,
	Eric Dong <eric.dong@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Benjamin Doron <benjamin.doron00@gmail.com>,
	Michael Kubacki <michael.kubacki@microsoft.com>,
	Jeremy Soller <jeremy@system76.com>
Subject: [edk2-platforms] [PATCH V3 5/6] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib
Date: Thu,  8 Sep 2022 18:07:03 -0700	[thread overview]
Message-ID: <20220909010704.7186-6-nathaniel.l.desimone@intel.com> (raw)
In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com>

 - Sets the terminal type GUID for ConIn, ConOut, and ConErr to the terminal
   type indicated by PcdDefaultTerminalType.
 - Some improvements to the comments in SerialPortTerminalLib

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
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>
---
 .../SerialPortTerminalLib.c                   | 66 ++++++++++++++-----
 .../SerialPortTerminalLib.h                   | 11 +++-
 .../SerialPortTerminalLib.inf                 | 17 ++++-
 3 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
index 66e8ee018b..ca5e966cb5 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.c
@@ -1,13 +1,26 @@
 /** @file
-  Main file for NULL named library for Serial Port Terminal Redirection library.
+  Main file for NULL named library for the Serial Port Terminal Redirection library.
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  This library 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) 2020 - 2022, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include "SerialPortTerminalLib.h"
 
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID  *mTerminalType[] = {
+  &gEfiPcAnsiGuid,
+  &gEfiVT100Guid,
+  &gEfiVT100PlusGuid,
+  &gEfiVTUTF8Guid,
+  &gEfiTtyTermGuid
+};
+
 GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath = {
   {
     {
@@ -59,10 +72,36 @@ AddSerialTerminal (
   VOID
   )
 {
-  DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n"));
+  UINT8   DefaultTerminalType;
+
+  //
+  // 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);
+  DefaultTerminalType             = PcdGet8 (PcdDefaultTerminalType);
+  DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal] [%d, %d, %d, %d, %d]\n",
+      (int) mSerialDevicePath.Uart.BaudRate,
+      (int) mSerialDevicePath.Uart.DataBits,
+      (int) mSerialDevicePath.Uart.Parity,
+      (int) mSerialDevicePath.Uart.StopBits,
+      (int) DefaultTerminalType));
+
+  if (DefaultTerminalType >= 0 &&
+      DefaultTerminalType < (sizeof (mTerminalType) / sizeof (mTerminalType[0]))) {
+    CopyMem (
+      (VOID *) &(mSerialDevicePath.TerminalType.Guid),
+      (VOID *) mTerminalType[DefaultTerminalType],
+      sizeof (EFI_GUID)
+      );
+  } else {
+    DEBUG ((DEBUG_WARN, "PcdDefaultTerminalType has invalid value: %d\n", (int) DefaultTerminalType));
+  }
 
   //
-  // Append Serial Terminal into "ConIn"
+  // Append Serial Terminal into "ConIn", "ConOut", and "ErrOut"
   //
   EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
   EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *) &mSerialDevicePath, NULL);
@@ -71,13 +110,12 @@ AddSerialTerminal (
 
 
 /**
-  Constructor for the Serial Port Device controller library.
+  Constructor for the Serial Port Terminal Device library.
 
-  @param ImageHandle    the image handle of the process
-  @param SystemTable    the EFI System Table pointer
+  @param ImageHandle    The Image Handle of the process
+  @param SystemTable    The EFI System Table pointer
 
-  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
-  @retval EFI_UNSUPPORTED    the shell level required was not found.
+  @retval EFI_SUCCESS   The Serial Port Terminal Device was installed successfully
 **/
 EFI_STATUS
 EFIAPI
@@ -86,15 +124,7 @@ SerialPortTerminalLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  mSerialDevicePath.Uart.BaudRate = PcdGet64(PcdUartDefaultBaudRate);
-  mSerialDevicePath.Uart.DataBits = PcdGet8(PcdUartDefaultDataBits);
-  mSerialDevicePath.Uart.Parity   = PcdGet8(PcdUartDefaultParity);
-  mSerialDevicePath.Uart.StopBits = PcdGet8(PcdUartDefaultStopBits);
-  DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor] [%d, %d, %d, %d]\n",
-      mSerialDevicePath.Uart.BaudRate,
-      mSerialDevicePath.Uart.DataBits,
-      mSerialDevicePath.Uart.Parity,
-      mSerialDevicePath.Uart.StopBits));
+  DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor]\n"));
 
   AddSerialTerminal();
 
diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
index bfa73cca7d..33415721cd 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.h
@@ -1,7 +1,12 @@
 /** @file
-  Header file for NULL named library for for Serial Port Terminal Redirection library.
+  Header file for NULL named library for the Serial Port Terminal Redirection library.
 
-  Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+  This library 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) 2020 -2022, Intel Corporation. All rights reserved.<BR>
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -12,8 +17,10 @@
 #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>
 
 //
diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
index dc5bb91a8e..ac1a06b2a5 100644
--- a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminalLib.inf
@@ -1,5 +1,9 @@
 ## @file
-# Component information file for Serial Port Terminal Redirection Library
+# Component information file for the Serial Port Terminal Redirection library.
+#
+#  This library 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
 #
 # Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
 #
@@ -18,22 +22,29 @@
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
-  BoardModulePkg/BoardModulePkg.dec
-  MinPlatformPkg/MinPlatformPkg.dec
 
 [Sources]
   SerialPortTerminalLib.c
   SerialPortTerminalLib.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


  parent reply	other threads:[~2022-09-09  1:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  1:06 [edk2-platforms] [PATCH V3 0/6] KabylakeOpenBoardPkg: HDMI DDC I2C Bus Debugging Nate DeSimone
2022-09-09  1:06 ` [edk2-platforms] [PATCH V3 1/6] KabylakeOpenBoardPkg: Add HdmiDebugPchDetectionLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 2/6] KabylakeOpenBoardPkg: Add I2cHdmiDebugSerialPortLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 3/6] KabylakeOpenBoardPkg: Add HdmiDebugGpioInitLib Nate DeSimone
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 4/6] KabylakeOpenBoardPkg: Add SecBoardInitLib Nate DeSimone
2022-09-09  1:07 ` Nate DeSimone [this message]
2022-09-09  1:07 ` [edk2-platforms] [PATCH V3 6/6] KabylakeOpenBoardPkg/GalagoPro3: Enable HDMI DDC Debug Port 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=20220909010704.7186-6-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