From nobody Sat May 18 04:13:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+81267+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81267+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632894556; cv=none; d=zohomail.com; s=zohoarc; b=iYkFY9O7x1sFId3c1b7ZGsDNH0tgWXVszBb3IgRvdQii/BKEBV3GTSDccmt1ahyrQkLj08D15DN2NPa26/4VfFekRWku3jLhok75VQyJHPLe9UVp30WZ3h4slD0P0EAM0bB+kuIcjK8SznoJbprNiwZFlO3LU2cD8byb5kGvry0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632894556; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=nhWQbZs61urdP7ahgz4jUsXeGQ2/EqpfdPvYhNbEhOI=; b=EeJigl00+GE9DrBBkl8Bx8qhm8HaHOVkEIruh4N0U8tp/lAykDv/wqfyIPt00Y0HhG9APyLqZdOYZ8LCheWhaKMtTbJqLJMnYSOosXn+KcdslKpStuI3ovemzlWRd9J8g2jGmWaZa+y43Z9+a1EaPy+r6p1paa6xzqMbvqyLygM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81267+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1632894556807692.3280311073846; Tue, 28 Sep 2021 22:49:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id sspIYY1788612xkF8HlRtBXm; Tue, 28 Sep 2021 22:49:16 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.5097.1632894555277313263 for ; Tue, 28 Sep 2021 22:49:15 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10121"; a="285880825" X-IronPort-AV: E=Sophos;i="5.85,331,1624345200"; d="scan'208";a="285880825" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 22:49:14 -0700 X-IronPort-AV: E=Sophos;i="5.85,331,1624345200"; d="scan'208";a="617279547" X-Received: from gdong1-mobl1.amr.corp.intel.com ([10.212.91.91]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 22:49:13 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You Subject: [edk2-devel] [`edk2-devel][PATCH] UefiPayloadPkg: Remove asm code and sharing libraries Date: Tue, 28 Sep 2021 22:49:03 -0700 Message-Id: <20210929054903.1188-1-guo.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,guo.dong@intel.com X-Gm-Message-State: CcNN8iSmJ05PT62YPB0oEVf9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632894556; bh=EuhciBRbKDYxUG+l1I/EQvN0ZjK+NsMeCXXfq7eIuhk=; h=Cc:Date:From:Reply-To:Subject:To; b=jJhMqQ/JJMHiA3t22U51llec/8uQTDlM1k/ZJ4XCYUIVVlmC0NEb32H3gUYynlTiav9 Iq2xF8/7Ji2o9iaAGVQyJt8qbcFfzBdyI/V+cO3R6fmxN+ohsobPRzLlt6ztSqwQCnfwL Vel7u7MFEUSthuVYFVr55chlR3khdZM4Ewo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632894558582100002 Content-Type: text/plain; charset="utf-8" From: Guo Dong Remove asm code used for payload entry. Use patchable PCD instead a fixed PCD PcdPayloadStackTop to avoid potential conflict. Based on the removal, use same HobLib regardless UNIVERSAL_PAYLOAD. Use same PlatformHookLib regardless UNIVERSAL_PAYLOAD. The original PlatformHookLib was removed and UniversalPayloadPlatformHookLib was rename to new PlatformHookLib. Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Signed-off-by: Guo Dong Reviewed-by: Ray Ni --- UefiPayloadPkg/Include/Library/BlParseLib.h = | 5 ++--- UefiPayloadPkg/Library/CbParseLib/CbParseLib.c = | 6 ++++-- UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf = | 4 ++-- UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c = | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------= ------------------------------------------ UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf = | 18 ++++++++++-------- UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf = | 4 ++-- UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c = | 95 --------------------------------------------------------------------= --------------------------- UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf= | 40 ---------------------------------------- UefiPayloadPkg/UefiPayloadEntry/Ia32/SecEntry.nasm = | 46 ---------------------------------------------- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c = | 30 +++++++++++++++++++++++------- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h = | 1 + UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf = | 5 ++--- UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf = | 1 - UefiPayloadPkg/UefiPayloadEntry/X64/SecEntry.nasm = | 47 ----------------------------------------------- UefiPayloadPkg/UefiPayloadPkg.dec = | 4 ++-- UefiPayloadPkg/UefiPayloadPkg.dsc = | 10 +--------- 16 files changed, 105 insertions(+), 321 deletions(-) diff --git a/UefiPayloadPkg/Include/Library/BlParseLib.h b/UefiPayloadPkg/I= nclude/Library/BlParseLib.h index 20a526d15c..1244190d4e 100644 --- a/UefiPayloadPkg/Include/Library/BlParseLib.h +++ b/UefiPayloadPkg/Include/Library/BlParseLib.h @@ -2,7 +2,7 @@ This library will parse the coreboot table in memory and extract those r= equired information. =20 - Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -16,8 +16,7 @@ #ifndef __BOOTLOADER_PARSE_LIB__ #define __BOOTLOADER_PARSE_LIB__ =20 -#define GET_BOOTLOADER_PARAMETER() (*(UINTN *)(UINTN)(PcdGet32(PcdPay= loadStackTop) - sizeof(UINT64))) -#define SET_BOOTLOADER_PARAMETER(Value) GET_BOOTLOADER_PARAMETER()=3DValue +#define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter) =20 typedef RETURN_STATUS \ (*BL_MEM_INFO_CALLBACK) (MEMROY_MAP_ENTRY *MemoryMapEntry, VOID *P= aram); diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c b/UefiPayloadPk= g/Library/CbParseLib/CbParseLib.c index 4e23cff50e..4f90687e40 100644 --- a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c +++ b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c @@ -2,7 +2,7 @@ This library will parse the coreboot table in memory and extract those r= equired information. =20 - Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -140,6 +140,7 @@ GetParameterBase ( UINT8 *TmpPtr; UINT8 *CbTablePtr; UINTN Idx; + EFI_STATUS Status; =20 // // coreboot could pass coreboot table to UEFI payload @@ -193,7 +194,8 @@ GetParameterBase ( return NULL; } =20 - SET_BOOTLOADER_PARAMETER ((UINT32)(UINTN)CbTablePtr); + PcdSet64S (PcdBootloaderParameter, (UINTN)CbTablePtr); + ASSERT_EFI_STATUS (Status); =20 return CbTablePtr; } diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf b/UefiPayload= Pkg/Library/CbParseLib/CbParseLib.inf index 52e3ad2054..cf81697703 100644 --- a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf +++ b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf @@ -1,7 +1,7 @@ ## @file # Coreboot Table Parse Library. # -# Copyright (c) 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -36,4 +36,4 @@ PcdLib =20 [Pcd] - gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop + gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter diff --git a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c b/Uef= iPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c index d8453e5957..004fcd8b7c 100644 --- a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c +++ b/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c @@ -1,29 +1,34 @@ /** @file Platform Hook Library instance for UART device. =20 - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include -#include -#include +#include +#include #include -#include #include +#include =20 -typedef struct { - UINT16 VendorId; ///< Vendor ID to match the PCI device. The = value 0xFFFF terminates the list of entries. - UINT16 DeviceId; ///< Device ID to match the PCI device - UINT32 ClockRate; ///< UART clock rate. Set to 0 for default c= lock rate of 1843200 Hz - UINT64 Offset; ///< The byte offset into to the BAR - UINT8 BarIndex; ///< Which BAR to get the UART base address - UINT8 RegisterStride; ///< UART register stride in bytes. Set to 0= for default register stride of 1 byte. - UINT16 ReceiveFifoDepth; ///< UART receive FIFO depth in bytes. Set to= 0 for a default FIFO depth of 16 bytes. - UINT16 TransmitFifoDepth; ///< UART transmit FIFO depth in bytes. Set t= o 0 for a default FIFO depth of 16 bytes. - UINT8 Reserved[2]; -} PCI_SERIAL_PARAMETER; + +/** Library Constructor + + @retval RETURN_SUCCESS Success. +**/ +EFI_STATUS +EFIAPI +PlatformHookSerialPortConstructor ( + VOID + ) +{ + // Nothing to do here. This constructor is added to + // enable the chain of constructor invocation for + // dependent libraries. + return RETURN_SUCCESS; +} =20 /** Performs platform specific initialization required for the CPU to access @@ -42,52 +47,49 @@ PlatformHookSerialPortInitialize ( VOID ) { - RETURN_STATUS Status; - UINT32 DeviceVendor; - PCI_SERIAL_PARAMETER *SerialParam; - SERIAL_PORT_INFO SerialPortInfo; - - Status =3D ParseSerialInfo (&SerialPortInfo); - if (RETURN_ERROR (Status)) { - return Status; - } + RETURN_STATUS Status; + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; + UINT8 *GuidHob; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; =20 - if (SerialPortInfo.Type =3D=3D PLD_SERIAL_TYPE_MEMORY_MAPPED) { - Status =3D PcdSetBoolS (PcdSerialUseMmio, TRUE); - } else { //IO - Status =3D PcdSetBoolS (PcdSerialUseMmio, FALSE); - } - if (RETURN_ERROR (Status)) { - return Status; - } - Status =3D PcdSet64S (PcdSerialRegisterBase, SerialPortInfo.BaseAddr); - if (RETURN_ERROR (Status)) { - return Status; + GuidHob =3D GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid); + if (GuidHob =3D=3D NULL) { + return EFI_NOT_FOUND; } =20 - Status =3D PcdSet32S (PcdSerialRegisterStride, SerialPortInfo.RegWidth); - if (RETURN_ERROR (Status)) { - return Status; + GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA= (GuidHob); + if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE = (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { + return EFI_NOT_FOUND; } =20 - Status =3D PcdSet32S (PcdSerialBaudRate, SerialPortInfo.Baud); - if (RETURN_ERROR (Status)) { - return Status; - } + if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_RE= VISION) { + SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB= _DATA (GuidHob); + if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UN= IVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) { + // + // Return if can't find the Serial Port Info Hob with enough length + // + return EFI_NOT_FOUND; + } =20 - Status =3D PcdSet32S (PcdSerialClockRate, SerialPortInfo.InputHertz); - if (RETURN_ERROR (Status)) { - return Status; - } + Status =3D PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterB= ase); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->Registe= rStride); + if (RETURN_ERROR (Status)) { + return Status; + } + Status =3D PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate); + if (RETURN_ERROR (Status)) { + return Status; + } =20 - if (SerialPortInfo.UartPciAddr >=3D 0x80000000) { - DeviceVendor =3D PciRead32 (SerialPortInfo.UartPciAddr & 0x0ffff000); - SerialParam =3D PcdGetPtr(PcdPciSerialParameters); - SerialParam->VendorId =3D (UINT16)DeviceVendor; - SerialParam->DeviceId =3D DeviceVendor >> 16; - SerialParam->ClockRate =3D SerialPortInfo.InputHertz; - SerialParam->RegisterStride =3D (UINT8)SerialPortInfo.RegWidth; + return RETURN_SUCCESS; } =20 - return RETURN_SUCCESS; + return EFI_NOT_FOUND; } diff --git a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf b/U= efiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf index 3eeb94d8fa..7ac6bfa1b1 100644 --- a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf +++ b/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf @@ -1,7 +1,7 @@ ## @file -# Platform Hook Library instance for UART device. +# Platform Hook Library instance for UART device for Universal Payload. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2021, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -10,29 +10,31 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D PlatformHookLib - FILE_GUID =3D 40A2CBC6-CFB8-447b-A90E-198E88FD345E + FILE_GUID =3D 807E05AB-9411-429F-97F0-FE425BF6B094 MODULE_TYPE =3D BASE VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D PlatformHookLib - CONSTRUCTOR =3D PlatformHookSerialPortInitialize + CONSTRUCTOR =3D PlatformHookSerialPortConstructor =20 [Sources] PlatformHookLib.c =20 [LibraryClasses] - BlParseLib PcdLib - PciLib + BaseLib + HobLib + DxeHobListLib =20 [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec UefiPayloadPkg/UefiPayloadPkg.dec =20 +[Guids] + gUniversalPayloadSerialPortInfoGuid + [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdPciSerialParameters ## PRODUCES diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPaylo= adPkg/Library/SblParseLib/SblParseLib.inf index 9ce2864f9f..665a5a8adc 100644 --- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf +++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf @@ -1,7 +1,7 @@ ## @file # Slim Bootloader parse library. # -# Copyright (c) 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -43,4 +43,4 @@ gEfiGraphicsDeviceInfoHobGuid =20 [Pcd] - gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop + gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.c b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.c deleted file mode 100644 index 004fcd8b7c..0000000000 --- a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi= b.c +++ /dev/null @@ -1,95 +0,0 @@ -/** @file - Platform Hook Library instance for UART device. - - Copyright (c) 2021, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include -#include -#include -#include -#include -#include - - -/** Library Constructor - - @retval RETURN_SUCCESS Success. -**/ -EFI_STATUS -EFIAPI -PlatformHookSerialPortConstructor ( - VOID - ) -{ - // Nothing to do here. This constructor is added to - // enable the chain of constructor invocation for - // dependent libraries. - return RETURN_SUCCESS; -} - -/** - Performs platform specific initialization required for the CPU to access - the hardware associated with a SerialPortLib instance. This function do= es - not initialize the serial port hardware itself. Instead, it initializes - hardware devices that are required for the CPU to access the serial port - hardware. This function may be called more than once. - - @retval RETURN_SUCCESS The platform specific initialization succee= ded. - @retval RETURN_DEVICE_ERROR The platform specific initialization could = not be completed. - -**/ -RETURN_STATUS -EFIAPI -PlatformHookSerialPortInitialize ( - VOID - ) -{ - RETURN_STATUS Status; - UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo; - UINT8 *GuidHob; - UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; - - GuidHob =3D GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid); - if (GuidHob =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - GenericHeader =3D (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA= (GuidHob); - if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE = (GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { - return EFI_NOT_FOUND; - } - - if (GenericHeader->Revision =3D=3D UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_RE= VISION) { - SerialPortInfo =3D (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB= _DATA (GuidHob); - if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UN= IVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) { - // - // Return if can't find the Serial Port Info Hob with enough length - // - return EFI_NOT_FOUND; - } - - Status =3D PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio); - if (RETURN_ERROR (Status)) { - return Status; - } - Status =3D PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterB= ase); - if (RETURN_ERROR (Status)) { - return Status; - } - Status =3D PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->Registe= rStride); - if (RETURN_ERROR (Status)) { - return Status; - } - Status =3D PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate); - if (RETURN_ERROR (Status)) { - return Status; - } - - return RETURN_SUCCESS; - } - - return EFI_NOT_FOUND; -} diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platfor= mHookLib.inf b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/Platf= ormHookLib.inf deleted file mode 100644 index 7ac6bfa1b1..0000000000 --- a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi= b.inf +++ /dev/null @@ -1,40 +0,0 @@ -## @file -# Platform Hook Library instance for UART device for Universal Payload. -# -# Copyright (c) 2021, Intel Corporation. All rights reserved.
-# -# SPDX-License-Identifier: BSD-2-Clause-Patent -# -## - -[Defines] - INF_VERSION =3D 0x00010005 - BASE_NAME =3D PlatformHookLib - FILE_GUID =3D 807E05AB-9411-429F-97F0-FE425BF6B094 - MODULE_TYPE =3D BASE - VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D PlatformHookLib - CONSTRUCTOR =3D PlatformHookSerialPortConstructor - -[Sources] - PlatformHookLib.c - -[LibraryClasses] - PcdLib - BaseLib - HobLib - DxeHobListLib - -[Packages] - MdePkg/MdePkg.dec - MdeModulePkg/MdeModulePkg.dec - UefiPayloadPkg/UefiPayloadPkg.dec - -[Guids] - gUniversalPayloadSerialPortInfoGuid - -[Pcd] - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate ## PRODUCES - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride ## PRODUCES diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/SecEntry.nasm b/UefiPaylo= adPkg/UefiPayloadEntry/Ia32/SecEntry.nasm deleted file mode 100644 index fa5ed159c6..0000000000 --- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/SecEntry.nasm +++ /dev/null @@ -1,46 +0,0 @@ -;-------------------------------------------------------------------------= ----- -;* -;* Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
-;* SPDX-License-Identifier: BSD-2-Clause-Patent - -;-------------------------------------------------------------------------= ----- - -#include - -SECTION .text - -extern ASM_PFX(PayloadEntry) -extern ASM_PFX(PcdGet32 (PcdPayloadStackTop)) - -; -; SecCore Entry Point -; -; Processor is in flat protected mode - -global ASM_PFX(_ModuleEntryPoint) -ASM_PFX(_ModuleEntryPoint): - - ; - ; Disable all the interrupts - ; - cli - - ; - ; Save the bootloader parameter base address - ; - mov eax, [esp + 4] - - mov esp, FixedPcdGet32 (PcdPayloadStackTop) - - ; - ; Push the bootloader parameter address onto new stack - ; - push 0 - push eax - - ; - ; Call into C code - ; - call ASM_PFX(PayloadEntry) - jmp $ - diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index a12d9961f1..f2ac3d2c69 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -385,7 +385,7 @@ BuildGenericHob ( **/ EFI_STATUS EFIAPI -PayloadEntry ( +_ModuleEntryPoint ( IN UINTN BootloaderParameter ) { @@ -395,13 +395,10 @@ PayloadEntry ( UINTN HobMemBase; UINTN HobMemTop; EFI_PEI_HOB_POINTERS Hob; + SERIAL_PORT_INFO SerialPortInfo; + UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *UniversalSerialPort; =20 - // Call constructor for all libraries - ProcessLibraryConstructorList (); - - DEBUG ((DEBUG_INFO, "GET_BOOTLOADER_PARAMETER() =3D 0x%lx\n", GET_BOOTLO= ADER_PARAMETER())); - DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof(UINTN))); - + PcdSet64S (PcdBootloaderParameter, BootloaderParameter); // Initialize floating point operating environment to be compliant with = UEFI spec. InitializeFloatingPointUnits (); =20 @@ -412,6 +409,25 @@ PayloadEntry ( =20 HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID *)HobMemBase, = (VOID *)HobMemTop); =20 + // + // Build serial port info + // + Status =3D ParseSerialInfo (&SerialPortInfo); + if (!EFI_ERROR (Status)) { + UniversalSerialPort =3D BuildGuidHob (&gUniversalPayloadSerialPortInfo= Guid, sizeof (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO)); + ASSERT (UniversalSerialPort !=3D NULL); + UniversalSerialPort->Header.Revision =3D UNIVERSAL_PAYLOAD_SERIAL_PORT= _INFO_REVISION; + UniversalSerialPort->Header.Length =3D sizeof (UNIVERSAL_PAYLOAD_SER= IAL_PORT_INFO); + UniversalSerialPort->UseMmio =3D (SerialPortInfo.Type =3D=3D 1= )?FALSE:TRUE; + UniversalSerialPort->RegisterBase =3D SerialPortInfo.BaseAddr; + UniversalSerialPort->BaudRate =3D SerialPortInfo.Baud; + UniversalSerialPort->RegisterStride =3D (UINT8)SerialPortInfo.RegWidt= h; + } + + // The library constructors might depend on serial port, so call it afte= r serial port hob + ProcessLibraryConstructorList (); + DEBUG ((DEBUG_INFO, "sizeof(UINTN) =3D 0x%x\n", sizeof(UINTN))); + // Build HOB based on information from Bootloader Status =3D BuildHobFromBl (); if (EFI_ERROR (Status)) { diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.h index 9922b56b39..de51c2fba9 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h @@ -35,6 +35,7 @@ #include #include #include +#include #include =20 #define LEGACY_8259_MASK_REGISTER_MASTER 0x21 diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPay= loadPkg/UefiPayloadEntry/UefiPayloadEntry.inf index 4c5170d9cc..96e4bb81f4 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf @@ -32,13 +32,11 @@ X64/VirtualMemory.c Ia32/DxeLoadFunc.c Ia32/IdtVectorAsm.nasm - Ia32/SecEntry.nasm =20 [Sources.X64] X64/VirtualMemory.h X64/VirtualMemory.c X64/DxeLoadFunc.c - X64/SecEntry.nasm =20 [Packages] MdePkg/MdePkg.dec @@ -67,6 +65,7 @@ gUefiAcpiBoardInfoGuid gUniversalPayloadSmbiosTableGuid gUniversalPayloadAcpiTableGuid + gUniversalPayloadSerialPortInfoGuid =20 [FeaturePcd.IA32] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONSUMES @@ -87,7 +86,7 @@ =20 gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize - gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop + gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize =20 gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/Ue= fiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf index e7e05b744a..928bd2e42b 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf @@ -92,7 +92,6 @@ =20 gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize - gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop gUefiPayloadPkgTokenSpaceGuid.PcdSystemMemoryUefiRegionSize =20 gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/SecEntry.nasm b/UefiPayloa= dPkg/UefiPayloadEntry/X64/SecEntry.nasm deleted file mode 100644 index 974cf77771..0000000000 --- a/UefiPayloadPkg/UefiPayloadEntry/X64/SecEntry.nasm +++ /dev/null @@ -1,47 +0,0 @@ -;-------------------------------------------------------------------------= ----- -;* -;* Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
-;* SPDX-License-Identifier: BSD-2-Clause-Patent - -;-------------------------------------------------------------------------= ----- - -#include - -DEFAULT REL -SECTION .text - -extern ASM_PFX(PayloadEntry) -extern ASM_PFX(PcdGet32 (PcdPayloadStackTop)) - -; -; SecCore Entry Point -; -; Processor is in flat protected mode - -global ASM_PFX(_ModuleEntryPoint) -ASM_PFX(_ModuleEntryPoint): - - ; - ; Disable all the interrupts - ; - cli - - - mov rsp, FixedPcdGet32 (PcdPayloadStackTop) - - ; - ; Push the bootloader parameter address onto new stack - ; - push rcx - mov rax, 0 - push rax ; shadow space - push rax - push rax - push rax - - ; - ; Call into C code - ; - call ASM_PFX(PayloadEntry) - jmp $ - diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayload= Pkg.dec index 8f0a7e3f95..e5e8db8863 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -60,8 +60,8 @@ gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemBase|0|UINT32|0x10000001 ## Provides the size of the payload binary in memory gUefiPayloadPkgTokenSpaceGuid.PcdPayloadFdMemSize|0|UINT32|0x10000002 -## Payload stack top -gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop|0x90000|UINT32|0x10000004 +## Save bootloader parameter +gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0|UINT64|0x10000004 =20 ## FFS filename to find the shell application. gUefiPayloadPkgTokenSpaceGuid.PcdShellFile|{ 0x83, 0xA5, 0x04, 0x7C, 0x3E,= 0x9E, 0x1c, 0x4f, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 }|VOID*|0= x10000005 diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index fb805dc772..57b04f10be 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -169,12 +169,7 @@ IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf - -!if $(UNIVERSAL_PAYLOAD) =3D=3D TRUE HobLib|UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf -!else - HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf -!endif =20 # # UEFI & PI @@ -217,11 +212,7 @@ TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort= Lib16550.inf -!if $(UNIVERSAL_PAYLOAD) =3D=3D TRUE - PlatformHookLib|UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/P= latformHookLib.inf -!else PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.i= nf -!endif PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/Pla= tformBootManagerLib.inf IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf =20 @@ -366,6 +357,7 @@ =20 gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|$(MAX_LOGICAL_= PROCESSORS) gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0 + gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter|0 =20 ##########################################################################= ###### # --=20 2.32.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#81267): https://edk2.groups.io/g/devel/message/81267 Mute This Topic: https://groups.io/mt/85942633/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-