From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web12.1316.1662685633362162071 for ; Thu, 08 Sep 2022 18:07:13 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=OMC93QhJ; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: nathaniel.l.desimone@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662685633; x=1694221633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OdjrzfUDHe3YqCrpdgmJ+DOwho/AQyfBmkHgQCNqndc=; b=OMC93QhJorjEuPBVp7VvO+rO18lZiturpTmIAzGH59oRFCz/PELGRDQi 43mZzLf0S4Z+88+lLVqDYy0/ZOjY093n8VqYjcHP10ZrAuUhnbooKfYGB M/UH1awVMMkw5FM8IJCBHrXaW3dLOX6s0GAAwwlzEocid6p4lH/VkEu1w 9PGGwgxhfdsLeve2tj2tzW4QkOpfjJUTPHk1sHwuObPBbUDQ4YmPkx5I4 A9UZCHVfozDY/OJcE4q2GIAXAtq9oFn2/DueZ+eA5NfwXVwDKB7IUxHbB IBMbR+RYSGFBYhKIDpD00YVs8GACLMvUnFNHS1oTXpk2RchkIT0FtlJfk Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10464"; a="323568634" X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="323568634" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:13 -0700 X-IronPort-AV: E=Sophos;i="5.93,300,1654585200"; d="scan'208";a="676950481" Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2022 18:07:12 -0700 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Sai Chaganty , Isaac Oram , Eric Dong , Liming Gao , Benjamin Doron , Michael Kubacki , Jeremy Soller Subject: [edk2-platforms] [PATCH V3 5/6] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Date: Thu, 8 Sep 2022 18:07:03 -0700 Message-Id: <20220909010704.7186-6-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> References: <20220909010704.7186-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit - 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 Cc: Sai Chaganty Cc: Isaac Oram Cc: Eric Dong Cc: Liming Gao Cc: Benjamin Doron Cc: Michael Kubacki Cc: Jeremy Soller Signed-off-by: Nate DeSimone --- .../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.
+ 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.
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.
+ 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.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -12,8 +17,10 @@ #include #include #include +#include #include #include +#include #include // 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.
# @@ -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