From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com []) by mx.groups.io with SMTP id smtpd.web11.28837.1605490291376568640 for ; Sun, 15 Nov 2020 17:31:34 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: heng.luo@intel.com) IronPort-SDR: 7phTkbonfJRAZTJIPyVyVNUBbeIZvO62jFYfIdLU7OKwzbTOkPdP0g8YeeLGKf9JoBNrRtMqZ8 2sHHqH/K5zig== X-IronPort-AV: E=McAfee;i="6000,8403,9806"; a="168112933" X-IronPort-AV: E=Sophos;i="5.77,481,1596524400"; d="scan'208";a="168112933" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2020 17:31:34 -0800 IronPort-SDR: 4/f6bwBFq/QHf+D6u74Qx2ISYUhKIoCuGTpNdrRGcIRV+3yw7hMYroVxRfWRY5eOOC8qedoPSB SS6tEgOITLTg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,481,1596524400"; d="scan'208";a="358295673" Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.154]) by fmsmga004.fm.intel.com with ESMTP; 15 Nov 2020 17:31:32 -0800 From: "Heng Luo" To: devel@edk2.groups.io Cc: Eric Dong , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [Patch V7 3/3] MinPlatformPkg: Add SerialPortTerminalLib to suport Serial Terminal feature Date: Mon, 16 Nov 2020 09:31:23 +0800 Message-Id: <20201116013124.1983-3-heng.luo@intel.com> X-Mailer: git-send-email 2.24.0.windows.2 In-Reply-To: <20201116013124.1983-1-heng.luo@intel.com> References: <20201116013124.1983-1-heng.luo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3014 1. Add SerialPortTerminalLib to MinPlatformPkg/Library. 2. Add SerialPortTerminalLib to BdsDxe driver, to add the serial device to ConIn and ConOut variables 3. Include SerialDxe and TerminalDxe to CoreDxeInclude.dsc and CoreUefiBootInclude.fdf. Cc: Eric Dong Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Heng Luo --- Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc = | 15 +++++++++++++-- Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf = | 8 +++++++- Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerm= inalLib.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++ Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerm= inalLib.h | 34 ++++++++++++++++++++++++++++++++++ Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerm= inalLib.inf | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 196 insertions(+), 3 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc b= /Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc index f0e578f8cc..1038a29c5c 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc +++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreDxeInclude.dsc @@ -1,7 +1,7 @@ ## @file=0D # Platform description.=0D #=0D -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -46,7 +46,18 @@ =0D MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf=0D =0D - MdeModulePkg/Universal/BdsDxe/BdsDxe.inf=0D + MdeModulePkg/Universal/BdsDxe/BdsDxe.inf {=0D + =0D +!if gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable =3D=3D TRUE=0D + NULL|MinPlatformPkg/Library/SerialPortTerminalLib/SerialPortTerminal= Lib.inf=0D +!endif=0D + }=0D +=0D +!if gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable =3D=3D TRUE=0D + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D + MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D +!endif=0D +=0D MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf= =0D MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {=0D =0D diff --git a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.= fdf b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf index 7859c0b1a5..ef4576eedf 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf +++ b/Platform/Intel/MinPlatformPkg/Include/Fdf/CoreUefiBootInclude.fdf @@ -1,7 +1,7 @@ ## @file=0D # FDF file of Platform.=0D #=0D -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -26,6 +26,12 @@ INF MdeModulePkg/Universal/Variable/RuntimeDxe/Variable= RuntimeDxe.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRun= timeDxe.inf=0D =0D INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf=0D +=0D +!if gMinPlatformPkgTokenSpaceGuid.PcdSerialTerminalEnable =3D=3D TRUE=0D +INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D +INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf=0D +!endif=0D +=0D INF MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.= inf=0D INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf=0D INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf=0D diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.c b/Platform/Intel/MinPlatformPkg/Library/SerialPortTer= minalLib/SerialPortTerminalLib.c new file mode 100644 index 0000000000..66e8ee018b --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.c @@ -0,0 +1,102 @@ +/** @file=0D + Main file for NULL named library for Serial Port Terminal Redirection li= brary.=0D +=0D + Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include "SerialPortTerminalLib.h"=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED SERIAL_DEVICE_PATH mSerialDevicePath =3D {=0D + {=0D + {=0D + HARDWARE_DEVICE_PATH,=0D + HW_VENDOR_DP,=0D + {=0D + (UINT8) sizeof (VENDOR_DEVICE_PATH),=0D + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)=0D + }=0D + },=0D + EDKII_SERIAL_PORT_LIB_VENDOR_GUID=0D + },=0D + {=0D + {=0D + MESSAGING_DEVICE_PATH,=0D + MSG_UART_DP,=0D + {=0D + (UINT8) sizeof (UART_DEVICE_PATH),=0D + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)=0D + }=0D + },=0D + 0, // Reserved=0D + 0, // BaudRate=0D + 0, // DataBits=0D + 0, // Parity=0D + 0 // StopBits=0D + },=0D + {=0D + {=0D + MESSAGING_DEVICE_PATH,=0D + MSG_VENDOR_DP,=0D + {=0D + (UINT8) (sizeof (VENDOR_DEVICE_PATH)),=0D + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),=0D + }=0D + },=0D + DEVICE_PATH_MESSAGING_PC_ANSI=0D + },=0D + gEndEntire=0D +};=0D +=0D +/**=0D + Updates the ConOut, ConIn, ErrOut variables with the serial terminal dev= ice path=0D + @param none=0D + @retval none=0D +**/=0D +VOID=0D +AddSerialTerminal (=0D + VOID=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "[AddSerialPortTerminal]\n"));=0D +=0D + //=0D + // Append Serial Terminal into "ConIn"=0D + //=0D + EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL *= ) &mSerialDevicePath, NULL);=0D + EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL *)= &mSerialDevicePath, NULL);=0D + EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL *= ) &mSerialDevicePath, NULL);=0D +}=0D +=0D +=0D +/**=0D + Constructor for the Serial Port Device controller library.=0D +=0D + @param ImageHandle the image handle of the process=0D + @param SystemTable the EFI System Table pointer=0D +=0D + @retval EFI_SUCCESS the shell command handlers were installed suc= essfully=0D + @retval EFI_UNSUPPORTED the shell level required was not found.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SerialPortTerminalLibConstructor (=0D + IN EFI_HANDLE ImageHandle,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + mSerialDevicePath.Uart.BaudRate =3D PcdGet64(PcdUartDefaultBaudRate);=0D + mSerialDevicePath.Uart.DataBits =3D PcdGet8(PcdUartDefaultDataBits);=0D + mSerialDevicePath.Uart.Parity =3D PcdGet8(PcdUartDefaultParity);=0D + mSerialDevicePath.Uart.StopBits =3D PcdGet8(PcdUartDefaultStopBits);=0D + DEBUG ((DEBUG_INFO, "[SerialPortTerminalLibConstructor] [%d, %d, %d, %d]= \n",=0D + mSerialDevicePath.Uart.BaudRate,=0D + mSerialDevicePath.Uart.DataBits,=0D + mSerialDevicePath.Uart.Parity,=0D + mSerialDevicePath.Uart.StopBits));=0D +=0D + AddSerialTerminal();=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.h b/Platform/Intel/MinPlatformPkg/Library/SerialPortTer= minalLib/SerialPortTerminalLib.h new file mode 100644 index 0000000000..bfa73cca7d --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.h @@ -0,0 +1,34 @@ +/** @file=0D + Header file for NULL named library for for Serial Port Terminal Redirect= ion library.=0D +=0D + Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef _SERIAL_PORT_TERMINAL_LIB_H_=0D +#define _SERIAL_PORT_TERMINAL_LIB_H_=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +//=0D +// Below is the platform console device path=0D +//=0D +typedef struct {=0D + VENDOR_DEVICE_PATH Guid;=0D + UART_DEVICE_PATH Uart;=0D + VENDOR_DEVICE_PATH TerminalType;=0D + EFI_DEVICE_PATH_PROTOCOL End;=0D +} SERIAL_DEVICE_PATH;=0D +=0D +#define gEndEntire \=0D + { \=0D + END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PAT= H_LENGTH, 0 } \=0D + }=0D +=0D +#endif=0D diff --git a/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/Se= rialPortTerminalLib.inf b/Platform/Intel/MinPlatformPkg/Library/SerialPortT= erminalLib/SerialPortTerminalLib.inf new file mode 100644 index 0000000000..2d95fe79f2 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Library/SerialPortTerminalLib/SerialPor= tTerminalLib.inf @@ -0,0 +1,40 @@ +## @file=0D +# Component information file for Serial Port Terminal Redirection Library= =0D +#=0D +# INTEL CONFIDENTIAL=0D +# Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +[Defines]=0D + INF_VERSION =3D 0x00010006=0D + BASE_NAME =3D SerialPortTerminalLib=0D + FILE_GUID =3D E12BFA46-95F2-4ADC-9774-7E38DE78741E= =0D + MODULE_TYPE =3D UEFI_DRIVER=0D + VERSION_STRING =3D 1.2=0D + LIBRARY_CLASS =3D NULL|UEFI_DRIVER DXE_DRIVER DXE_RUNTI= ME_DRIVER=0D + CONSTRUCTOR =3D SerialPortTerminalLibConstructor=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + BoardModulePkg/BoardModulePkg.dec=0D + MinPlatformPkg/MinPlatformPkg.dec=0D +=0D +[Sources]=0D + SerialPortTerminalLib.c=0D + SerialPortTerminalLib.h=0D +=0D +[LibraryClasses]=0D + DevicePathLib=0D + DebugLib=0D + UefiDriverEntryPoint=0D + UefiBootManagerLib=0D + UefiLib=0D +=0D +[Pcd]=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits=0D --=20 2.24.0.windows.2