[PATCH 1/1] UefiPayloadPkg: Add PCI root bridge info hob support for SBL


Ma, Maurice
 

Current UefiPayloadPkg can suport PCI root bridge info HOB
provided by bootloader. For UniversalPayload, bootloader can
directly provide this HOB for payload consumption. However,
for legacy UEFI payload, it is required to migrate the HOB
information from bootloader HOB space to UEFI payload HOB
space. This patch added the missing part for the bootloader
ParseLib in order to support both legacy and universal UEFI
payload.

This patch was tested on Slim Bootloader with latest UEFI
payload, and it worked as expected.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Maurice Ma <maurice.ma@intel.com>
---
UefiPayloadPkg/Include/Library/BlParseLib.h | 14 ++++++
.../Library/CbParseLib/CbParseLib.c | 16 +++++++
.../Library/SblParseLib/SblParseLib.c | 47 ++++++++++++++++++-
.../Library/SblParseLib/SblParseLib.inf | 1 +
.../UefiPayloadEntry/UefiPayloadEntry.c | 8 ++++
5 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/UefiPayloadPkg/Include/Library/BlParseLib.h b/UefiPayloadPkg/I=
nclude/Library/BlParseLib.h
index 1244190d4e87..49eac3124818 100644
--- a/UefiPayloadPkg/Include/Library/BlParseLib.h
+++ b/UefiPayloadPkg/Include/Library/BlParseLib.h
@@ -116,4 +116,18 @@ ParseGfxDeviceInfo (
OUT EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *GfxDeviceInfo=0D
);=0D
=0D
+/**=0D
+ Parse and handle the misc info provided by bootloader=0D
+=0D
+ @retval RETURN_SUCCESS The misc information was parsed success=
fully.=0D
+ @retval RETURN_NOT_FOUND Could not find required misc info.=0D
+ @retval RETURN_OUT_OF_RESOURCES Insufficant memory space.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+ParseMiscInfo (=0D
+ VOID=0D
+ );=0D
+=0D
#endif=0D
diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c b/UefiPayloadPk=
g/Library/CbParseLib/CbParseLib.c
index 4f90687e407e..f81aa0f301d8 100644
--- a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
+++ b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
@@ -560,3 +560,19 @@ ParseGfxDeviceInfo (
return RETURN_NOT_FOUND;=0D
}=0D
=0D
+/**=0D
+ Parse and handle the misc info provided by bootloader=0D
+=0D
+ @retval RETURN_SUCCESS The misc information was parsed success=
fully.=0D
+ @retval RETURN_NOT_FOUND Could not find required misc info.=0D
+ @retval RETURN_OUT_OF_RESOURCES Insufficant memory space.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+ParseMiscInfo (=0D
+ VOID=0D
+ )=0D
+{=0D
+ return RETURN_SUCCESS;=0D
+}=0D
diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c b/UefiPayload=
Pkg/Library/SblParseLib/SblParseLib.c
index 7214fd87d20c..ccdcbfc07db9 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
@@ -1,7 +1,7 @@
/** @file=0D
This library will parse the Slim Bootloader to get required information.=
=0D
=0D
- Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -15,7 +15,7 @@
#include <Library/HobLib.h>=0D
#include <Library/BlParseLib.h>=0D
#include <IndustryStandard/Acpi.h>=0D
-=0D
+#include <UniversalPayload/PciRootBridges.h>=0D
=0D
/**=0D
This function retrieves the parameter base address from boot loader.=0D
@@ -221,3 +221,46 @@ ParseGfxDeviceInfo (
return RETURN_SUCCESS;=0D
}=0D
=0D
+/**=0D
+ Parse and handle the misc info provided by bootloader=0D
+=0D
+ @retval RETURN_SUCCESS The misc information was parsed success=
fully.=0D
+ @retval RETURN_NOT_FOUND Could not find required misc info.=0D
+ @retval RETURN_OUT_OF_RESOURCES Insufficant memory space.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+ParseMiscInfo (=0D
+ VOID=0D
+ )=0D
+{=0D
+ RETURN_STATUS Status;=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *BlRootBridgesHob;=0D
+ UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PldRootBridgesHob;=0D
+=0D
+ Status =3D RETURN_NOT_FOUND;=0D
+ BlRootBridgesHob =3D (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GetGuidHobDa=
taFromSbl (=0D
+ &gUniversalPayloadPciRootBridgeInfoGuid=0D
+ );=0D
+ if (BlRootBridgesHob !=3D NULL) {=0D
+ //=0D
+ // Migrate bootloader root bridge info hob from bootloader to payload.=
=0D
+ //=0D
+ PldRootBridgesHob =3D BuildGuidHob (=0D
+ &gUniversalPayloadPciRootBridgeInfoG=
uid,=0D
+ BlRootBridgesHob->Header.Length=0D
+ );=0D
+ ASSERT (PldRootBridgesHob !=3D NULL);=0D
+ if (PldRootBridgesHob !=3D NULL) {=0D
+ CopyMem (PldRootBridgesHob, BlRootBridgesHob, BlRootBridgesHob->Head=
er.Length);=0D
+ DEBUG ((DEBUG_INFO, "Create PCI root bridge info guid hob\n"));=0D
+ Status =3D RETURN_SUCCESS;=0D
+ } else {=0D
+ Status =3D RETURN_OUT_OF_RESOURCES;=0D
+ }=0D
+ }=0D
+=0D
+ return Status;=0D
+}=0D
+=0D
diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPaylo=
adPkg/Library/SblParseLib/SblParseLib.inf
index 665a5a8adcef..535cca58a63c 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
@@ -41,6 +41,7 @@
gLoaderMemoryMapInfoGuid=0D
gEfiGraphicsInfoHobGuid=0D
gEfiGraphicsDeviceInfoHobGuid=0D
+ gUniversalPayloadPciRootBridgeInfoGuid=0D
=0D
[Pcd]=0D
gUefiPayloadPkgTokenSpaceGuid.PcdBootloaderParameter=0D
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo=
adPkg/UefiPayloadEntry/UefiPayloadEntry.c
index f2ac3d2c6925..5a1e5786687a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -321,6 +321,14 @@ BuildHobFromBl (
return Status;=0D
}=0D
=0D
+ //=0D
+ // Parse the misc info provided by bootloader=0D
+ //=0D
+ Status =3D ParseMiscInfo ();=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_WARN, "Error when parsing misc info, Status =3D %r\n", S=
tatus));=0D
+ }=0D
+=0D
//=0D
// Parse platform specific information.=0D
//=0D
--=20
2.29.2.windows.2

Join devel@edk2.groups.io to automatically receive all group messages.