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 memory locations.
11 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
12 This program and the accompanying materials
13 are licensed and made available under the terms and conditions of the BSD License
14 which accompanies this distribution. The full text of the license may be found at
15 http://opensource.org/licenses/bsd-license.php
17 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
18 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
26 Returns the pointer to the HOB list.
28 This function returns the pointer to first HOB in the list.
29 For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
30 to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
31 the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
32 Since the System Configuration Table does not exist that the time the DXE Core is
33 launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
34 to manage the pointer to the HOB list.
36 If the pointer to the HOB list is NULL, then ASSERT().
38 @return The pointer to the HOB list.
48 Returns the next instance of a HOB type from the starting HOB.
50 This function searches the first instance of a HOB type from the starting HOB pointer.
51 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
52 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
53 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
54 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
56 If HobStart is NULL, then ASSERT().
58 @param Type The HOB type to return.
59 @param HobStart The starting HOB pointer to search from.
61 @return The next instance of a HOB type from the starting HOB.
68 IN CONST VOID
*HobStart
72 Returns the first instance of a HOB type among the whole HOB list.
74 This function searches the first instance of a HOB type among the whole HOB list.
75 If there does not exist such HOB type in the HOB list, it will return NULL.
77 If the pointer to the HOB list is NULL, then ASSERT().
79 @param Type The HOB type to return.
81 @return The next instance of a HOB type from the starting HOB.
91 Returns the next instance of the matched GUID HOB from the starting HOB.
93 This function searches the first instance of a HOB from the starting HOB pointer.
94 Such HOB should satisfy two conditions:
95 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
96 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
97 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
98 to extract the data section and its size info respectively.
99 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
100 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
101 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
103 If Guid is NULL, then ASSERT().
104 If HobStart is NULL, then ASSERT().
106 @param Guid The GUID to match with in the HOB list.
107 @param HobStart A pointer to a Guid.
109 @return The next instance of the matched GUID HOB from the starting HOB.
115 IN CONST EFI_GUID
*Guid
,
116 IN CONST VOID
*HobStart
120 Returns the first instance of the matched GUID HOB among the whole HOB list.
122 This function searches the first instance of a HOB among the whole HOB list.
123 Such HOB should satisfy two conditions:
124 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
125 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
126 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
127 to extract the data section and its size info respectively.
129 If the pointer to the HOB list is NULL, then ASSERT().
130 If Guid is NULL, then ASSERT().
132 @param Guid The GUID to match with in the HOB list.
134 @return The first instance of the matched GUID HOB among the whole HOB list.
140 IN CONST EFI_GUID
*Guid
144 Get the system boot mode from the HOB list.
146 This function returns the system boot mode information from the
147 PHIT HOB in HOB list.
149 If the pointer to the HOB list is NULL, then ASSERT().
153 @return The Boot Mode.
163 Builds a HOB for a loaded PE32 module.
165 This function builds a HOB for a loaded PE32 module.
166 It can only be invoked during PEI phase;
167 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
169 If ModuleName is NULL, then ASSERT().
170 If there is no additional space for HOB creation, then ASSERT().
172 @param ModuleName The GUID File Name of the module.
173 @param MemoryAllocationModule The 64 bit physical address of the module.
174 @param ModuleLength The length of the module in bytes.
175 @param EntryPoint The 64 bit physical address of the module entry point.
181 IN CONST EFI_GUID
*ModuleName
,
182 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
183 IN UINT64 ModuleLength
,
184 IN EFI_PHYSICAL_ADDRESS EntryPoint
188 Builds a HOB that describes a chunk of system memory with Owner GUID.
190 This function builds a HOB that describes a chunk of system memory.
191 It can only be invoked during PEI phase;
192 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
194 If there is no additional space for HOB creation, then ASSERT().
196 @param ResourceType The type of resource described by this HOB.
197 @param ResourceAttribute The resource attributes of the memory described by this HOB.
198 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
199 @param NumberOfBytes The length of the memory described by this HOB in bytes.
200 @param OwnerGUID GUID for the owner of this resource.
205 BuildResourceDescriptorWithOwnerHob (
206 IN EFI_RESOURCE_TYPE ResourceType
,
207 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
208 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
209 IN UINT64 NumberOfBytes
,
210 IN EFI_GUID
*OwnerGUID
214 Builds a HOB that describes a chunk of system memory.
216 This function builds a HOB that describes a chunk of system memory.
217 It can only be invoked during PEI phase;
218 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
220 If there is no additional space for HOB creation, then ASSERT().
222 @param ResourceType The type of resource described by this HOB.
223 @param ResourceAttribute The resource attributes of the memory described by this HOB.
224 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
225 @param NumberOfBytes The length of the memory described by this HOB in bytes.
230 BuildResourceDescriptorHob (
231 IN EFI_RESOURCE_TYPE ResourceType
,
232 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
233 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
234 IN UINT64 NumberOfBytes
238 Builds a customized HOB tagged with a GUID for identification and returns
239 the start address of GUID HOB data.
241 This function builds a customized HOB tagged with a GUID for identification
242 and returns the start address of GUID HOB data so that caller can fill the customized data.
243 The HOB Header and Name field is already stripped.
244 It can only be invoked during PEI phase;
245 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
247 If Guid is NULL, then ASSERT().
248 If there is no additional space for HOB creation, then ASSERT().
249 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
250 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
252 @param Guid The GUID to tag the customized HOB.
253 @param DataLength The size of the data payload for the GUID HOB.
255 @retval NULL The GUID HOB could not be allocated.
256 @retval others The start address of GUID HOB data.
262 IN CONST EFI_GUID
*Guid
,
267 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
268 data field, and returns the start address of the GUID HOB data.
270 This function builds a customized HOB tagged with a GUID for identification and copies the input
271 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
272 invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
273 The HOB Header and Name field is already stripped.
274 It can only be invoked during PEI phase;
275 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
277 If Guid is NULL, then ASSERT().
278 If Data is NULL and DataLength > 0, then ASSERT().
279 If there is no additional space for HOB creation, then ASSERT().
280 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
281 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
283 @param Guid The GUID to tag the customized HOB.
284 @param Data The data to be copied into the data field of the GUID HOB.
285 @param DataLength The size of the data payload for the GUID HOB.
287 @retval NULL The GUID HOB could not be allocated.
288 @retval others The start address of GUID HOB data.
294 IN CONST EFI_GUID
*Guid
,
300 Builds a Firmware Volume HOB.
302 This function builds a Firmware Volume HOB.
303 It can only be invoked during PEI phase;
304 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
306 If there is no additional space for HOB creation, then ASSERT().
308 @param BaseAddress The base address of the Firmware Volume.
309 @param Length The size of the Firmware Volume in bytes.
315 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
320 Builds a EFI_HOB_TYPE_FV2 HOB.
322 This function builds a EFI_HOB_TYPE_FV2 HOB.
323 It can only be invoked during PEI phase;
324 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
326 If there is no additional space for HOB creation, then ASSERT().
328 @param BaseAddress The base address of the Firmware Volume.
329 @param Length The size of the Firmware Volume in bytes.
330 @param FvName The name of the Firmware Volume.
331 @param FileName The name of the file.
337 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
339 IN CONST EFI_GUID
*FvName
,
340 IN CONST EFI_GUID
*FileName
344 Builds a Capsule Volume HOB.
346 This function builds a Capsule Volume HOB.
347 It can only be invoked during PEI phase;
348 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
350 If the platform does not support Capsule Volume HOBs, then ASSERT().
351 If there is no additional space for HOB creation, then ASSERT().
353 @param BaseAddress The base address of the Capsule Volume.
354 @param Length The size of the Capsule Volume in bytes.
360 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
365 Builds a HOB for the CPU.
367 This function builds a HOB for the CPU.
368 It can only be invoked during PEI phase;
369 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
371 If there is no additional space for HOB creation, then ASSERT().
373 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
374 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
380 IN UINT8 SizeOfMemorySpace
,
381 IN UINT8 SizeOfIoSpace
385 Builds a HOB for the Stack.
387 This function builds a HOB for the stack.
388 It can only be invoked during PEI phase;
389 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
391 If there is no additional space for HOB creation, then ASSERT().
393 @param BaseAddress The 64 bit physical address of the Stack.
394 @param Length The length of the stack in bytes.
400 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
405 Builds a HOB for the BSP store.
407 This function builds a HOB for BSP store.
408 It can only be invoked during PEI phase;
409 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
411 If there is no additional space for HOB creation, then ASSERT().
413 @param BaseAddress The 64 bit physical address of the BSP.
414 @param Length The length of the BSP store in bytes.
415 @param MemoryType Type of memory allocated by this HOB.
421 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
423 IN EFI_MEMORY_TYPE MemoryType
427 Builds a HOB for the memory allocation.
429 This function builds a HOB for the memory allocation.
430 It can only be invoked during PEI phase;
431 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
433 If there is no additional space for HOB creation, then ASSERT().
435 @param BaseAddress The 64 bit physical address of the memory.
436 @param Length The length of the memory allocation in bytes.
437 @param MemoryType Type of memory allocated by this HOB.
442 BuildMemoryAllocationHob (
443 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
445 IN EFI_MEMORY_TYPE MemoryType
449 Returns the type of a HOB.
451 This macro returns the HobType field from the HOB header for the
452 HOB specified by HobStart.
454 @param HobStart A pointer to a HOB.
459 #define GET_HOB_TYPE(HobStart) \
460 ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobType)
463 Returns the length, in bytes, of a HOB.
465 This macro returns the HobLength field from the HOB header for the
466 HOB specified by HobStart.
468 @param HobStart A pointer to a HOB.
473 #define GET_HOB_LENGTH(HobStart) \
474 ((*(EFI_HOB_GENERIC_HEADER **)&(HobStart))->HobLength)
477 Returns a pointer to the next HOB in the HOB list.
479 This macro returns a pointer to HOB that follows the
480 HOB specified by HobStart in the HOB List.
482 @param HobStart A pointer to a HOB.
484 @return A pointer to the next HOB in the HOB list.
487 #define GET_NEXT_HOB(HobStart) \
488 (VOID *)(*(UINT8 **)&(HobStart) + GET_HOB_LENGTH (HobStart))
491 Determines if a HOB is the last HOB in the HOB list.
493 This macro determine if the HOB specified by HobStart is the
494 last HOB in the HOB list. If HobStart is last HOB in the HOB list,
495 then TRUE is returned. Otherwise, FALSE is returned.
497 @param HobStart A pointer to a HOB.
499 @retval TRUE The HOB specified by HobStart is the last HOB in the HOB list.
500 @retval FALSE The HOB specified by HobStart is not the last HOB in the HOB list.
503 #define END_OF_HOB_LIST(HobStart) (GET_HOB_TYPE (HobStart) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)
506 Returns a pointer to data buffer from a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
508 This macro returns a pointer to the data buffer in a HOB specified by HobStart.
509 HobStart is assumed to be a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
511 @param GuidHob A pointer to a HOB.
513 @return A pointer to the data buffer in a HOB.
516 #define GET_GUID_HOB_DATA(HobStart) \
517 (VOID *)(*(UINT8 **)&(HobStart) + sizeof (EFI_HOB_GUID_TYPE))
520 Returns the size of the data buffer from a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
522 This macro returns the size, in bytes, of the data buffer in a HOB specified by HobStart.
523 HobStart is assumed to be a HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
525 @param GuidHob A pointer to a HOB.
527 @return The size of the data buffer.
529 #define GET_GUID_HOB_DATA_SIZE(HobStart) \
530 (UINT16)(GET_HOB_LENGTH (HobStart) - sizeof (EFI_HOB_GUID_TYPE))