1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
/** @file
This library will parse the Slim Bootloader to get required information.
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiDxe.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/IoLib.h>
#include <Library/HobLib.h>
#include <Library/BlParseLib.h>
#include <IndustryStandard/Acpi.h>
#include <UniversalPayload/PciRootBridges.h>
/**
This function retrieves the parameter base address from boot loader.
This function will get bootloader specific parameter address for UEFI payload.
e.g. HobList pointer for Slim Bootloader, and coreboot table header for Coreboot.
@retval NULL Failed to find the GUID HOB.
@retval others GUIDed HOB data pointer.
**/
VOID *
EFIAPI
GetParameterBase (
VOID
)
{
EFI_HOB_HANDOFF_INFO_TABLE *HandoffTable;
HandoffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)(UINTN) GET_BOOTLOADER_PARAMETER ();
if ((HandoffTable->Header.HobType == EFI_HOB_TYPE_HANDOFF) &&
(HandoffTable->Header.HobLength == sizeof (EFI_HOB_HANDOFF_INFO_TABLE)) &&
(HandoffTable->Header.Reserved == 0)) {
return (VOID *)HandoffTable;
}
return NULL;
}
/**
This function retrieves a GUIDed HOB data from Slim Bootloader.
This function will search SBL HOB list to find the first GUIDed HOB that
its GUID matches Guid.
@param[in] Guid A pointer to HOB GUID to search.
@retval NULL Failed to find the GUID HOB.
@retval others GUIDed HOB data pointer.
**/
VOID *
GetGuidHobDataFromSbl (
IN EFI_GUID *Guid
)
{
UINT8 *GuidHob;
CONST VOID *HobList;
HobList = GetParameterBase ();
ASSERT (HobList != NULL);
GuidHob = GetNextGuidHob (Guid, HobList);
if (GuidHob != NULL) {
return GET_GUID_HOB_DATA (GuidHob);
}
return NULL;
}
/**
Acquire the memory map information.
@param MemInfoCallback The callback routine
@param Params Pointer to the callback routine parameter
@retval RETURN_SUCCESS Successfully find out the memory information.
@retval RETURN_NOT_FOUND Failed to find the memory information.
**/
RETURN_STATUS
EFIAPI
ParseMemoryInfo (
IN BL_MEM_INFO_CALLBACK MemInfoCallback,
IN VOID *Params
)
{
MEMORY_MAP_INFO *MemoryMapInfo;
UINTN Idx;
MemoryMapInfo = (MEMORY_MAP_INFO *) GetGuidHobDataFromSbl (&gLoaderMemoryMapInfoGuid);
if (MemoryMapInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}
for (Idx = 0; Idx < MemoryMapInfo->Count; Idx++) {
MemInfoCallback (&MemoryMapInfo->Entry[Idx], Params);
}
return RETURN_SUCCESS;
}
/**
Acquire SMBIOS table from slim bootloader.
@param SmbiosTable Pointer to the SMBIOS table info.
@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
**/
RETURN_STATUS
EFIAPI
ParseSmbiosTable (
OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
)
{
UNIVERSAL_PAYLOAD_SMBIOS_TABLE *TableInfo;
TableInfo = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadSmbiosTableGuid);
if (TableInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}
SmbiosTable->SmBiosEntryPoint = TableInfo->SmBiosEntryPoint;
return RETURN_SUCCESS;
}
/**
Acquire ACPI table from slim bootloader.
@param AcpiTableHob Pointer to the ACPI table info.
@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
**/
RETURN_STATUS
EFIAPI
ParseAcpiTableInfo (
OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
)
{
UNIVERSAL_PAYLOAD_ACPI_TABLE *TableInfo;
TableInfo = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadAcpiTableGuid);
if (TableInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}
AcpiTableHob->Rsdp = TableInfo->Rsdp;
return RETURN_SUCCESS;
}
/**
Find the serial port information
@param[out] SerialPortInfo Pointer to serial port info structure
@retval RETURN_SUCCESS Successfully find the serial port information.
@retval RETURN_NOT_FOUND Failed to find the serial port information .
**/
RETURN_STATUS
EFIAPI
ParseSerialInfo (
OUT SERIAL_PORT_INFO *SerialPortInfo
)
{
SERIAL_PORT_INFO *BlSerialInfo;
BlSerialInfo = (SERIAL_PORT_INFO *) GetGuidHobDataFromSbl (&gUefiSerialPortInfoGuid);
if (BlSerialInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}
CopyMem (SerialPortInfo, BlSerialInfo, sizeof (SERIAL_PORT_INFO));
return RETURN_SUCCESS;
}
/**
Find the video frame buffer information
@param GfxInfo Pointer to the EFI_PEI_GRAPHICS_INFO_HOB structure
@retval RETURN_SUCCESS Successfully find the video frame buffer information.
@retval RETURN_NOT_FOUND Failed to find the video frame buffer information .
**/
RETURN_STATUS
EFIAPI
ParseGfxInfo (
OUT EFI_PEI_GRAPHICS_INFO_HOB *GfxInfo
)
{
EFI_PEI_GRAPHICS_INFO_HOB *BlGfxInfo;
BlGfxInfo = (EFI_PEI_GRAPHICS_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsInfoHobGuid);
if (BlGfxInfo == NULL) {
return RETURN_NOT_FOUND;
}
CopyMem (GfxInfo, BlGfxInfo, sizeof (EFI_PEI_GRAPHICS_INFO_HOB));
return RETURN_SUCCESS;
}
/**
Find the video frame buffer device information
@param GfxDeviceInfo Pointer to the EFI_PEI_GRAPHICS_DEVICE_INFO_HOB structure
@retval RETURN_SUCCESS Successfully find the video frame buffer information.
@retval RETURN_NOT_FOUND Failed to find the video frame buffer information.
**/
RETURN_STATUS
EFIAPI
ParseGfxDeviceInfo (
OUT EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *GfxDeviceInfo
)
{
EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *BlGfxDeviceInfo;
BlGfxDeviceInfo = (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB *) GetGuidHobDataFromSbl (&gEfiGraphicsDeviceInfoHobGuid);
if (BlGfxDeviceInfo == NULL) {
return RETURN_NOT_FOUND;
}
CopyMem (GfxDeviceInfo, BlGfxDeviceInfo, sizeof (EFI_PEI_GRAPHICS_DEVICE_INFO_HOB));
return RETURN_SUCCESS;
}
/**
Parse and handle the misc info provided by bootloader
@retval RETURN_SUCCESS The misc information was parsed successfully.
@retval RETURN_NOT_FOUND Could not find required misc info.
@retval RETURN_OUT_OF_RESOURCES Insufficant memory space.
**/
RETURN_STATUS
EFIAPI
ParseMiscInfo (
VOID
)
{
RETURN_STATUS Status;
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *BlRootBridgesHob;
UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PldRootBridgesHob;
Status = RETURN_NOT_FOUND;
BlRootBridgesHob = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *) GetGuidHobDataFromSbl (
&gUniversalPayloadPciRootBridgeInfoGuid
);
if (BlRootBridgesHob != NULL) {
//
// Migrate bootloader root bridge info hob from bootloader to payload.
//
PldRootBridgesHob = BuildGuidHob (
&gUniversalPayloadPciRootBridgeInfoGuid,
BlRootBridgesHob->Header.Length
);
ASSERT (PldRootBridgesHob != NULL);
if (PldRootBridgesHob != NULL) {
CopyMem (PldRootBridgesHob, BlRootBridgesHob, BlRootBridgesHob->Header.Length);
DEBUG ((DEBUG_INFO, "Create PCI root bridge info guid hob\n"));
Status = RETURN_SUCCESS;
} else {
Status = RETURN_OUT_OF_RESOURCES;
}
}
return Status;
}
|