2 Provides services to create and parse HOBs. Only available for PEI
5 The HOB Library supports the efficient creation and searching of HOBs
6 defined in the PI Specification.
7 A HOB is a Hand-Off Block, defined in the Framework architecture, that
8 allows the PEI phase to pass information to the DXE phase. HOBs are position
9 independent and can be relocated easily to different memory locations.
11 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
12 SPDX-License-Identifier: BSD-2-Clause-Patent
20 Returns the pointer to the HOB list.
22 This function returns the pointer to first HOB in the list.
23 For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
24 to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
25 the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
26 Since the System Configuration Table does not exist that the time the DXE Core is
27 launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
28 to manage the pointer to the HOB list.
30 If the pointer to the HOB list is NULL, then ASSERT().
32 @return The pointer to the HOB list.
42 Returns the next instance of a HOB type from the starting HOB.
44 This function searches the first instance of a HOB type from the starting HOB pointer.
45 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
46 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
47 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
48 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
50 If HobStart is NULL, then ASSERT().
52 @param Type The HOB type to return.
53 @param HobStart The starting HOB pointer to search from.
55 @return The next instance of a HOB type from the starting HOB.
62 IN CONST VOID
*HobStart
66 Returns the first instance of a HOB type among the whole HOB list.
68 This function searches the first instance of a HOB type among the whole HOB list.
69 If there does not exist such HOB type in the HOB list, it will return NULL.
71 If the pointer to the HOB list is NULL, then ASSERT().
73 @param Type The HOB type to return.
75 @return The next instance of a HOB type from the starting HOB.
85 Returns the next instance of the matched GUID HOB from the starting HOB.
87 This function searches the first instance of a HOB from the starting HOB pointer.
88 Such HOB should satisfy two conditions:
89 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
90 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
91 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
92 to extract the data section and its size info respectively.
93 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
94 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
95 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
97 If Guid is NULL, then ASSERT().
98 If HobStart is NULL, then ASSERT().
100 @param Guid The GUID to match with in the HOB list.
101 @param HobStart A pointer to a Guid.
103 @return The next instance of the matched GUID HOB from the starting HOB.
109 IN CONST EFI_GUID
*Guid
,
110 IN CONST VOID
*HobStart
114 Returns the first instance of the matched GUID HOB among the whole HOB list.
116 This function searches the first instance of a HOB among the whole HOB list.
117 Such HOB should satisfy two conditions:
118 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
119 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
120 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
121 to extract the data section and its size info respectively.
123 If the pointer to the HOB list is NULL, then ASSERT().
124 If Guid is NULL, then ASSERT().
126 @param Guid The GUID to match with in the HOB list.
128 @return The first instance of the matched GUID HOB among the whole HOB list.
134 IN CONST EFI_GUID
*Guid
138 Get the system boot mode from the HOB list.
140 This function returns the system boot mode information from the
141 PHIT HOB in HOB list.
143 If the pointer to the HOB list is NULL, then ASSERT().
147 @return The Boot Mode.
157 Builds a HOB for a loaded PE32 module.
159 This function builds a HOB for a loaded PE32 module.
160 It can only be invoked during PEI phase;
161 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
163 If ModuleName is NULL, then ASSERT().
164 If there is no additional space for HOB creation, then ASSERT().
166 @param ModuleName The GUID File Name of the module.
167 @param MemoryAllocationModule The 64 bit physical address of the module.
168 @param ModuleLength The length of the module in bytes.
169 @param EntryPoint The 64 bit physical address of the module entry point.
175 IN CONST EFI_GUID
*ModuleName
,
176 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
177 IN UINT64 ModuleLength
,
178 IN EFI_PHYSICAL_ADDRESS EntryPoint
182 Builds a HOB that describes a chunk of system memory with Owner GUID.
184 This function builds a HOB that describes a chunk of system memory.
185 It can only be invoked during PEI phase;
186 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
188 If there is no additional space for HOB creation, then ASSERT().
190 @param ResourceType The type of resource described by this HOB.
191 @param ResourceAttribute The resource attributes of the memory described by this HOB.
192 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
193 @param NumberOfBytes The length of the memory described by this HOB in bytes.
194 @param OwnerGUID GUID for the owner of this resource.
199 BuildResourceDescriptorWithOwnerHob (
200 IN EFI_RESOURCE_TYPE ResourceType
,
201 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
202 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
203 IN UINT64 NumberOfBytes
,
204 IN EFI_GUID
*OwnerGUID
208 Builds a HOB that describes a chunk of system memory.
210 This function builds a HOB that describes a chunk of system memory.
211 It can only be invoked during PEI phase;
212 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
214 If there is no additional space for HOB creation, then ASSERT().
216 @param ResourceType The type of resource described by this HOB.
217 @param ResourceAttribute The resource attributes of the memory described by this HOB.
218 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
219 @param NumberOfBytes The length of the memory described by this HOB in bytes.
224 BuildResourceDescriptorHob (
225 IN EFI_RESOURCE_TYPE ResourceType
,
226 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
227 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
228 IN UINT64 NumberOfBytes
232 Builds a customized HOB tagged with a GUID for identification and returns
233 the start address of GUID HOB data.
235 This function builds a customized HOB tagged with a GUID for identification
236 and returns the start address of GUID HOB data so that caller can fill the customized data.
237 The HOB Header and Name field is already stripped.
238 It can only be invoked during PEI phase;
239 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
241 If Guid is NULL, then ASSERT().
242 If there is no additional space for HOB creation, then ASSERT().
243 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
244 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
246 @param Guid The GUID to tag the customized HOB.
247 @param DataLength The size of the data payload for the GUID HOB.
249 @retval NULL The GUID HOB could not be allocated.
250 @retval others The start address of GUID HOB data.
256 IN CONST EFI_GUID
*Guid
,
261 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
262 data field, and returns the start address of the GUID HOB data.
264 This function builds a customized HOB tagged with a GUID for identification and copies the input
265 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
266 invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
267 The HOB Header and Name field is already stripped.
268 It can only be invoked during PEI phase;
269 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
271 If Guid is NULL, then ASSERT().
272 If Data is NULL and DataLength > 0, then ASSERT().
273 If there is no additional space for HOB creation, then ASSERT().
274 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
275 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
277 @param Guid The GUID to tag the customized HOB.
278 @param Data The data to be copied into the data field of the GUID HOB.
279 @param DataLength The size of the data payload for the GUID HOB.
281 @retval NULL The GUID HOB could not be allocated.
282 @retval others The start address of GUID HOB data.
288 IN CONST EFI_GUID
*Guid
,
294 Builds a Firmware Volume HOB.
296 This function builds a Firmware Volume HOB.
297 It can only be invoked during PEI phase;
298 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
300 If there is no additional space for HOB creation, then ASSERT().
301 If the FvImage buffer is not at its required alignment, then ASSERT().
303 @param BaseAddress The base address of the Firmware Volume.
304 @param Length The size of the Firmware Volume in bytes.
310 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
315 Builds a EFI_HOB_TYPE_FV2 HOB.
317 This function builds a EFI_HOB_TYPE_FV2 HOB.
318 It can only be invoked during PEI phase;
319 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
321 If there is no additional space for HOB creation, then ASSERT().
322 If the FvImage buffer is not at its required alignment, then ASSERT().
324 @param BaseAddress The base address of the Firmware Volume.
325 @param Length The size of the Firmware Volume in bytes.
326 @param FvName The name of the Firmware Volume.
327 @param FileName The name of the file.
333 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
335 IN CONST EFI_GUID
*FvName
,
336 IN CONST EFI_GUID
*FileName
340 Builds a EFI_HOB_TYPE_FV3 HOB.
342 This function builds a EFI_HOB_TYPE_FV3 HOB.
343 It can only be invoked during PEI phase;
344 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
346 If there is no additional space for HOB creation, then ASSERT().
347 If the FvImage buffer is not at its required alignment, then ASSERT().
349 @param BaseAddress The base address of the Firmware Volume.
350 @param Length The size of the Firmware Volume in bytes.
351 @param AuthenticationStatus The authentication status.
352 @param ExtractedFv TRUE if the FV was extracted as a file within
353 another firmware volume. FALSE otherwise.
354 @param FvName The name of the Firmware Volume.
355 Valid only if IsExtractedFv is TRUE.
356 @param FileName The name of the file.
357 Valid only if IsExtractedFv is TRUE.
363 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
365 IN UINT32 AuthenticationStatus
,
366 IN BOOLEAN ExtractedFv
,
367 IN CONST EFI_GUID
*FvName
, OPTIONAL
368 IN CONST EFI_GUID
*FileName OPTIONAL
372 Builds a Capsule Volume HOB.
374 This function builds a Capsule Volume HOB.
375 It can only be invoked during PEI phase;
376 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
378 If the platform does not support Capsule Volume HOBs, then ASSERT().
379 If there is no additional space for HOB creation, then ASSERT().
381 @param BaseAddress The base address of the Capsule Volume.
382 @param Length The size of the Capsule Volume in bytes.
388 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
393 Builds a HOB for the CPU.
395 This function builds a HOB for the CPU.
396 It can only be invoked during PEI phase;
397 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
399 If there is no additional space for HOB creation, then ASSERT().
401 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
402 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
408 IN UINT8 SizeOfMemorySpace
,
409 IN UINT8 SizeOfIoSpace
413 Builds a HOB for the Stack.
415 This function builds a HOB for the stack.
416 It can only be invoked during PEI phase;
417 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
419 If there is no additional space for HOB creation, then ASSERT().
421 @param BaseAddress The 64 bit physical address of the Stack.
422 @param Length The length of the stack in bytes.
428 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
433 Builds a HOB for the BSP store.
435 This function builds a HOB for BSP store.
436 It can only be invoked during PEI phase;
437 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
439 If there is no additional space for HOB creation, then ASSERT().
441 @param BaseAddress The 64 bit physical address of the BSP.
442 @param Length The length of the BSP store in bytes.
443 @param MemoryType Type of memory allocated by this HOB.
449 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
451 IN EFI_MEMORY_TYPE MemoryType
455 Builds a HOB for the memory allocation.
457 This function builds a HOB for the memory allocation.
458 It can only be invoked during PEI phase;
459 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
461 If there is no additional space for HOB creation, then ASSERT().
463 @param BaseAddress The 64 bit physical address of the memory.
464 @param Length The length of the memory allocation in bytes.
465 @param MemoryType Type of memory allocated by this HOB.
470 BuildMemoryAllocationHob (
471 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
473 IN EFI_MEMORY_TYPE MemoryType
477 Returns the type of a HOB.
479 This macro returns the HobType field from the HOB header for the
480 HOB specified by HobStart.
482 @param HobStart A pointer to a HOB.
487 #define GET_HOB_TYPE(HobStart) \
488 ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobType)
491 Returns the length, in bytes, of a HOB.
493 This macro returns the HobLength field from the HOB header for the
494 HOB specified by HobStart.
496 @param HobStart A pointer to a HOB.
501 #define GET_HOB_LENGTH(HobStart) \
502 ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobLength)
505 Returns a pointer to the next HOB in the HOB list.
507 This macro returns a pointer to HOB that follows the
508 HOB specified by HobStart in the HOB List.
510 @param HobStart A pointer to a HOB.
512 @return A pointer to the next HOB in the HOB list.
515 #define GET_NEXT_HOB(HobStart) \
516 (VOID *)(*(UINT8 **)&(HobStart) + GET_HOB_LENGTH (HobStart))
519 Determines if a HOB is the last HOB in the HOB list.
521 This macro determine if the HOB specified by HobStart is the
522 last HOB in the HOB list. If HobStart is last HOB in the HOB list,
523 then TRUE is returned. Otherwise, FALSE is returned.
525 @param HobStart A pointer to a HOB.
527 @retval TRUE The HOB specified by HobStart is the last HOB in the HOB list.
528 @retval FALSE The HOB specified by HobStart is not the last HOB in the HOB list.
531 #define END_OF_HOB_LIST(HobStart) (GET_HOB_TYPE (HobStart) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)
534 Returns a pointer to data buffer from a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
536 This macro returns a pointer to the data buffer in a HOB specified by HobStart.
537 HobStart is assumed to be a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
539 @param GuidHob A pointer to a HOB.
541 @return A pointer to the data buffer in a HOB.
544 #define GET_GUID_HOB_DATA(HobStart) \
545 (VOID *)(*(UINT8 **)&(HobStart) + sizeof (EFI_HOB_GUID_TYPE))
548 Returns the size of the data buffer from a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
550 This macro returns the size, in bytes, of the data buffer in a HOB specified by HobStart.
551 HobStart is assumed to be a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
553 @param GuidHob A pointer to a HOB.
555 @return The size of the data buffer.
557 #define GET_GUID_HOB_DATA_SIZE(HobStart) \
558 (UINT16)(GET_HOB_LENGTH (HobStart) - sizeof (EFI_HOB_GUID_TYPE))