From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.4705.1662532076879836693 for ; Tue, 06 Sep 2022 23:27:57 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ELcTg0lS; spf=permerror, err=too many SPF records (domain: intel.com, ip: 192.55.52.43, 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=1662532077; x=1694068077; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OdjrzfUDHe3YqCrpdgmJ+DOwho/AQyfBmkHgQCNqndc=; b=ELcTg0lSBy47biwaqkiLvaHRpZ8N7sotvzbsF7HPzL57KQRXAXU8QWFE APTAycdhaANFSCIIx/LUHyqyL1y2gZyygXfH0SZNN+o78cmSZf+dHu0Dh b+fdtTXa67rPyrr2uCSM+1jkcxh7hLeY9XATWJNS3lYQh9LwTR3B/6ArG cypp/8QHqQ8ZnOwwOU1x9fLztcdaDAxoLXhEdiDBjjiezEnvAdvjph3aV m8ERVJY14ynRSpwYKp+XROKXH1r0y3IYJknW9P9y/zujuYb4u0rGu2tPJ 2nJetoCqaCoeFtP6jpdeNoAuCx8Xai9Hf1fQwQHOJIrbHo7zpoBPKPG/u A==; X-IronPort-AV: E=McAfee;i="6500,9779,10462"; a="383088399" X-IronPort-AV: E=Sophos;i="5.93,295,1654585200"; d="scan'208";a="383088399" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 23:27:50 -0700 X-IronPort-AV: E=Sophos;i="5.93,295,1654585200"; d="scan'208";a="682687465" Received: from nldesimo-desk1.amr.corp.intel.com ([10.24.80.62]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2022 23:27:49 -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 V2 4/5] MinPlatformPkg: Add PcdDefaultTerminalType support to SerialPortTerminalLib Date: Tue, 6 Sep 2022 23:27:34 -0700 Message-Id: <20220907062735.5734-5-nathaniel.l.desimone@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20220907062735.5734-1-nathaniel.l.desimone@intel.com> References: <20220907062735.5734-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