2 This library will parse the Slim Bootloader to get required information.
4 Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/BaseMemoryLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/PcdLib.h>
14 #include <Library/IoLib.h>
15 #include <Library/HobLib.h>
16 #include <Library/BlParseLib.h>
17 #include <IndustryStandard/Acpi.h>
18 #include <UniversalPayload/PciRootBridges.h>
21 This function retrieves the parameter base address from boot loader.
23 This function will get bootloader specific parameter address for UEFI payload.
24 e.g. HobList pointer for Slim Bootloader, and coreboot table header for Coreboot.
26 @retval NULL Failed to find the GUID HOB.
27 @retval others GUIDed HOB data pointer.
36 EFI_HOB_HANDOFF_INFO_TABLE
*HandoffTable
;
38 HandoffTable
= (EFI_HOB_HANDOFF_INFO_TABLE
*)(UINTN
)GET_BOOTLOADER_PARAMETER ();
39 if ((HandoffTable
->Header
.HobType
== EFI_HOB_TYPE_HANDOFF
) &&
40 (HandoffTable
->Header
.HobLength
== sizeof (EFI_HOB_HANDOFF_INFO_TABLE
)) &&
41 (HandoffTable
->Header
.Reserved
== 0))
43 return (VOID
*)HandoffTable
;
50 This function retrieves a GUIDed HOB data from Slim Bootloader.
52 This function will search SBL HOB list to find the first GUIDed HOB that
53 its GUID matches Guid.
55 @param[in] Guid A pointer to HOB GUID to search.
57 @retval NULL Failed to find the GUID HOB.
58 @retval others GUIDed HOB data pointer.
62 GetGuidHobDataFromSbl (
69 HobList
= GetParameterBase ();
70 ASSERT (HobList
!= NULL
);
71 GuidHob
= GetNextGuidHob (Guid
, HobList
);
72 if (GuidHob
!= NULL
) {
73 return GET_GUID_HOB_DATA (GuidHob
);
80 Acquire the memory map information.
82 @param MemInfoCallback The callback routine
83 @param Params Pointer to the callback routine parameter
85 @retval RETURN_SUCCESS Successfully find out the memory information.
86 @retval RETURN_NOT_FOUND Failed to find the memory information.
92 IN BL_MEM_INFO_CALLBACK MemInfoCallback
,
96 MEMORY_MAP_INFO
*MemoryMapInfo
;
99 MemoryMapInfo
= (MEMORY_MAP_INFO
*)GetGuidHobDataFromSbl (&gLoaderMemoryMapInfoGuid
);
100 if (MemoryMapInfo
== NULL
) {
102 return RETURN_NOT_FOUND
;
105 for (Idx
= 0; Idx
< MemoryMapInfo
->Count
; Idx
++) {
106 MemInfoCallback (&MemoryMapInfo
->Entry
[Idx
], Params
);
109 return RETURN_SUCCESS
;
113 Acquire SMBIOS table from slim bootloader.
115 @param SmbiosTable Pointer to the SMBIOS table info.
117 @retval RETURN_SUCCESS Successfully find out the tables.
118 @retval RETURN_NOT_FOUND Failed to find the tables.
124 OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE
*SmbiosTable
127 UNIVERSAL_PAYLOAD_SMBIOS_TABLE
*TableInfo
;
129 TableInfo
= (UNIVERSAL_PAYLOAD_SMBIOS_TABLE
*)GetGuidHobDataFromSbl (&gUniversalPayloadSmbiosTableGuid
);
130 if (TableInfo
== NULL
) {
132 return RETURN_NOT_FOUND
;
135 SmbiosTable
->SmBiosEntryPoint
= TableInfo
->SmBiosEntryPoint
;
137 return RETURN_SUCCESS
;
141 Acquire ACPI table from slim bootloader.
143 @param AcpiTableHob Pointer to the ACPI table info.
145 @retval RETURN_SUCCESS Successfully find out the tables.
146 @retval RETURN_NOT_FOUND Failed to find the tables.
152 OUT UNIVERSAL_PAYLOAD_ACPI_TABLE
*AcpiTableHob
155 UNIVERSAL_PAYLOAD_ACPI_TABLE
*TableInfo
;
157 TableInfo
= (UNIVERSAL_PAYLOAD_ACPI_TABLE
*)GetGuidHobDataFromSbl (&gUniversalPayloadAcpiTableGuid
);
158 if (TableInfo
== NULL
) {
160 return RETURN_NOT_FOUND
;
163 AcpiTableHob
->Rsdp
= TableInfo
->Rsdp
;
165 return RETURN_SUCCESS
;
169 Find the serial port information
171 @param[out] SerialPortInfo Pointer to serial port info structure
173 @retval RETURN_SUCCESS Successfully find the serial port information.
174 @retval RETURN_NOT_FOUND Failed to find the serial port information .
180 OUT SERIAL_PORT_INFO
*SerialPortInfo
183 SERIAL_PORT_INFO
*BlSerialInfo
;
185 BlSerialInfo
= (SERIAL_PORT_INFO
*)GetGuidHobDataFromSbl (&gUefiSerialPortInfoGuid
);
186 if (BlSerialInfo
== NULL
) {
188 return RETURN_NOT_FOUND
;
191 CopyMem (SerialPortInfo
, BlSerialInfo
, sizeof (SERIAL_PORT_INFO
));
193 return RETURN_SUCCESS
;
197 Find the video frame buffer information
199 @param GfxInfo Pointer to the EFI_PEI_GRAPHICS_INFO_HOB structure
201 @retval RETURN_SUCCESS Successfully find the video frame buffer information.
202 @retval RETURN_NOT_FOUND Failed to find the video frame buffer information .
208 OUT EFI_PEI_GRAPHICS_INFO_HOB
*GfxInfo
211 EFI_PEI_GRAPHICS_INFO_HOB
*BlGfxInfo
;
213 BlGfxInfo
= (EFI_PEI_GRAPHICS_INFO_HOB
*)GetGuidHobDataFromSbl (&gEfiGraphicsInfoHobGuid
);
214 if (BlGfxInfo
== NULL
) {
215 return RETURN_NOT_FOUND
;
218 CopyMem (GfxInfo
, BlGfxInfo
, sizeof (EFI_PEI_GRAPHICS_INFO_HOB
));
220 return RETURN_SUCCESS
;
224 Find the video frame buffer device information
226 @param GfxDeviceInfo Pointer to the EFI_PEI_GRAPHICS_DEVICE_INFO_HOB structure
228 @retval RETURN_SUCCESS Successfully find the video frame buffer information.
229 @retval RETURN_NOT_FOUND Failed to find the video frame buffer information.
235 OUT EFI_PEI_GRAPHICS_DEVICE_INFO_HOB
*GfxDeviceInfo
238 EFI_PEI_GRAPHICS_DEVICE_INFO_HOB
*BlGfxDeviceInfo
;
240 BlGfxDeviceInfo
= (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB
*)GetGuidHobDataFromSbl (&gEfiGraphicsDeviceInfoHobGuid
);
241 if (BlGfxDeviceInfo
== NULL
) {
242 return RETURN_NOT_FOUND
;
245 CopyMem (GfxDeviceInfo
, BlGfxDeviceInfo
, sizeof (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB
));
247 return RETURN_SUCCESS
;
251 Parse and handle the misc info provided by bootloader
253 @retval RETURN_SUCCESS The misc information was parsed successfully.
254 @retval RETURN_NOT_FOUND Could not find required misc info.
255 @retval RETURN_OUT_OF_RESOURCES Insufficant memory space.
264 RETURN_STATUS Status
;
265 UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES
*BlRootBridgesHob
;
266 UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES
*PldRootBridgesHob
;
268 Status
= RETURN_NOT_FOUND
;
269 BlRootBridgesHob
= (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES
*)GetGuidHobDataFromSbl (
270 &gUniversalPayloadPciRootBridgeInfoGuid
272 if (BlRootBridgesHob
!= NULL
) {
274 // Migrate bootloader root bridge info hob from bootloader to payload.
276 PldRootBridgesHob
= BuildGuidHob (
277 &gUniversalPayloadPciRootBridgeInfoGuid
,
278 BlRootBridgesHob
->Header
.Length
280 ASSERT (PldRootBridgesHob
!= NULL
);
281 if (PldRootBridgesHob
!= NULL
) {
282 CopyMem (PldRootBridgesHob
, BlRootBridgesHob
, BlRootBridgesHob
->Header
.Length
);
283 DEBUG ((DEBUG_INFO
, "Create PCI root bridge info guid hob\n"));
284 Status
= RETURN_SUCCESS
;
286 Status
= RETURN_OUT_OF_RESOURCES
;