diff options
author | Guo Dong <guo.dong@intel.com> | 2021-09-28 20:34:40 -0700 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-09-30 16:26:14 +0000 |
commit | 422e5d2f7f1abbecd9dd7baad54213251a8ed47f (patch) | |
tree | e2b97dae6156d26e6231b8907616e44730202952 /UefiPayloadPkg/Library | |
parent | 22737996771c8053189b8fe2839cf4a96272784a (diff) | |
download | edk2-422e5d2f7f1abbecd9dd7baad54213251a8ed47f.tar.gz edk2-422e5d2f7f1abbecd9dd7baad54213251a8ed47f.tar.bz2 edk2-422e5d2f7f1abbecd9dd7baad54213251a8ed47f.zip |
UefiPayloadPkg: Remove asm code and sharing libraries
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 <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Diffstat (limited to 'UefiPayloadPkg/Library')
7 files changed, 74 insertions, 203 deletions
diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c b/UefiPayloadPkg/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 required
information.
- Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -140,6 +140,7 @@ GetParameterBase ( UINT8 *TmpPtr;
UINT8 *CbTablePtr;
UINTN Idx;
+ EFI_STATUS Status;
//
// coreboot could pass coreboot table to UEFI payload
@@ -193,7 +194,8 @@ GetParameterBase ( return NULL;
}
- SET_BOOTLOADER_PARAMETER ((UINT32)(UINTN)CbTablePtr);
+ PcdSet64S (PcdBootloaderParameter, (UINTN)CbTablePtr);
+ ASSERT_EFI_STATUS (Status);
return CbTablePtr;
}
diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf b/UefiPayloadPkg/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.<BR>
+# Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -36,4 +36,4 @@ PcdLib
[Pcd]
- gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop
+ gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter
diff --git a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.c b/UefiPayloadPkg/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.
- Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Base.h>
-#include <Uefi/UefiBaseType.h>
-#include <Library/PciLib.h>
+#include <PiDxe.h>
+#include <UniversalPayload/SerialPortInfo.h>
#include <Library/PlatformHookLib.h>
-#include <Library/BlParseLib.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
-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 clock 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 to 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;
+}
/**
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 = ParseSerialInfo (&SerialPortInfo);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
+ RETURN_STATUS Status;
+ UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;
+ UINT8 *GuidHob;
+ UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
- if (SerialPortInfo.Type == PLD_SERIAL_TYPE_MEMORY_MAPPED) {
- Status = PcdSetBoolS (PcdSerialUseMmio, TRUE);
- } else { //IO
- Status = PcdSetBoolS (PcdSerialUseMmio, FALSE);
- }
- if (RETURN_ERROR (Status)) {
- return Status;
- }
- Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo.BaseAddr);
- if (RETURN_ERROR (Status)) {
- return Status;
+ GuidHob = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
+ if (GuidHob == NULL) {
+ return EFI_NOT_FOUND;
}
- Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo.RegWidth);
- if (RETURN_ERROR (Status)) {
- return Status;
+ GenericHeader = (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;
}
- Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo.Baud);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
+ if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
+ SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (GuidHob);
+ if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
+ //
+ // Return if can't find the Serial Port Info Hob with enough length
+ //
+ return EFI_NOT_FOUND;
+ }
- Status = PcdSet32S (PcdSerialClockRate, SerialPortInfo.InputHertz);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
+ Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
- if (SerialPortInfo.UartPciAddr >= 0x80000000) {
- DeviceVendor = PciRead32 (SerialPortInfo.UartPciAddr & 0x0ffff000);
- SerialParam = PcdGetPtr(PcdPciSerialParameters);
- SerialParam->VendorId = (UINT16)DeviceVendor;
- SerialParam->DeviceId = DeviceVendor >> 16;
- SerialParam->ClockRate = SerialPortInfo.InputHertz;
- SerialParam->RegisterStride = (UINT8)SerialPortInfo.RegWidth;
+ return RETURN_SUCCESS;
}
- return RETURN_SUCCESS;
+ return EFI_NOT_FOUND;
}
diff --git a/UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf b/UefiPayloadPkg/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.<BR>
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -10,29 +10,31 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = PlatformHookLib
- FILE_GUID = 40A2CBC6-CFB8-447b-A90E-198E88FD345E
+ FILE_GUID = 807E05AB-9411-429F-97F0-FE425BF6B094
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = PlatformHookLib
- CONSTRUCTOR = PlatformHookSerialPortInitialize
+ CONSTRUCTOR = PlatformHookSerialPortConstructor
[Sources]
PlatformHookLib.c
[LibraryClasses]
- BlParseLib
PcdLib
- PciLib
+ 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
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate ## PRODUCES
- gEfiMdeModulePkgTokenSpaceGuid.PcdPciSerialParameters ## PRODUCES
diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPayloadPkg/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.<BR>
+# Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
@@ -43,4 +43,4 @@ gEfiGraphicsDeviceInfoHobGuid
[Pcd]
- gUefiPayloadPkgTokenSpaceGuid.PcdPayloadStackTop
+ gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter
diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c deleted file mode 100644 index 004fcd8b7c..0000000000 --- a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c +++ /dev/null @@ -1,95 +0,0 @@ -/** @file
- Platform Hook Library instance for UART device.
-
- Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Base.h>
-#include <PiDxe.h>
-#include <UniversalPayload/SerialPortInfo.h>
-#include <Library/PlatformHookLib.h>
-#include <Library/PcdLib.h>
-#include <Library/HobLib.h>
-
-
-/** 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 does
- 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 succeeded.
- @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 = GetFirstGuidHob (&gUniversalPayloadSerialPortInfoGuid);
- if (GuidHob == NULL) {
- return EFI_NOT_FOUND;
- }
-
- GenericHeader = (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 == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
- SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA (GuidHob);
- if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
- //
- // Return if can't find the Serial Port Info Hob with enough length
- //
- return EFI_NOT_FOUND;
- }
-
- Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
- Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
- Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo->RegisterStride);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
- Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
- if (RETURN_ERROR (Status)) {
- return Status;
- }
-
- return RETURN_SUCCESS;
- }
-
- return EFI_NOT_FOUND;
-}
diff --git a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf deleted file mode 100644 index 7ac6bfa1b1..0000000000 --- a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.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.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PlatformHookLib
- FILE_GUID = 807E05AB-9411-429F-97F0-FE425BF6B094
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = PlatformHookLib
- CONSTRUCTOR = 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
|