2 Provides services to create and parse HOBs. Only available for PEI
5 Copyright (c) 2006 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 Returns the pointer to the HOB list.
21 ASSERT() if the HOB list returned by GetHobList() is NULL.
23 This function returns the pointer to first HOB in the list.
25 @return The pointer to the HOB list.
35 Returns the next instance of a HOB type from the starting HOB.
37 This function searches the first instance of a HOB type from the starting HOB pointer.
38 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
39 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
40 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
41 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
42 If HobStart is NULL, then ASSERT().
44 @param Type The HOB type to return.
45 @param HobStart The starting HOB pointer to search from.
47 @return The next instance of a HOB type from the starting HOB.
54 IN CONST VOID
*HobStart
58 Returns the first instance of a HOB type among the whole HOB list.
60 This function searches the first instance of a HOB type among the whole HOB list.
61 If there does not exist such HOB type in the HOB list, it will return NULL.
63 @param Type The HOB type to return.
65 @return The next instance of a HOB type from the starting HOB.
75 This function searches the first instance of a HOB from the starting HOB pointer.
76 Such HOB should satisfy two conditions:
77 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
78 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
79 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
80 to extract the data section and its size info respectively.
81 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
82 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
83 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
84 If Guid is NULL, then ASSERT().
85 If HobStart is NULL, then ASSERT().
87 @param Guid The GUID to match with in the HOB list.
88 @param HobStart A pointer to a Guid.
90 @return The next instance of the matched GUID HOB from the starting HOB.
96 IN CONST EFI_GUID
*Guid
,
97 IN CONST VOID
*HobStart
101 This function searches the first instance of a HOB among the whole HOB list.
102 Such HOB should satisfy two conditions:
103 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
104 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
105 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
106 to extract the data section and its size info respectively.
107 If Guid is NULL, then ASSERT().
109 @param Guid The GUID to match with in the HOB list.
111 @return The first instance of the matched GUID HOB among the whole HOB list.
117 IN CONST EFI_GUID
*Guid
121 Get the Boot Mode from the HOB list.
123 This function returns the system boot mode information from the
124 PHIT HOB in HOB list.
128 @return The Boot Mode.
138 Builds a HOB for a loaded PE32 module.
140 This function builds a HOB for a loaded PE32 module.
141 It can only be invoked during PEI phase;
142 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
143 If ModuleName is NULL, then ASSERT().
144 If there is no additional space for HOB creation, then ASSERT().
146 @param ModuleName The GUID File Name of the module.
147 @param MemoryAllocationModule The 64 bit physical address of the module.
148 @param ModuleLength The length of the module in bytes.
149 @param EntryPoint The 64 bit physical address of the module entry point.
155 IN CONST EFI_GUID
*ModuleName
,
156 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
157 IN UINT64 ModuleLength
,
158 IN EFI_PHYSICAL_ADDRESS EntryPoint
162 Builds a HOB that describes a chunk of system memory.
164 This function builds a HOB that describes a chunk of system memory.
165 It can only be invoked during PEI phase;
166 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
167 If there is no additional space for HOB creation, then ASSERT().
169 @param ResourceType The type of resource described by this HOB.
170 @param ResourceAttribute The resource attributes of the memory described by this HOB.
171 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
172 @param NumberOfBytes The length of the memory described by this HOB in bytes.
177 BuildResourceDescriptorHob (
178 IN EFI_RESOURCE_TYPE ResourceType
,
179 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
180 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
181 IN UINT64 NumberOfBytes
185 Builds a GUID HOB with a certain data length.
187 This function builds a customized HOB tagged with a GUID for identification
188 and returns the start address of GUID HOB data so that caller can fill the customized data.
189 The HOB Header and Name field is already stripped.
190 It can only be invoked during PEI phase;
191 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
192 If Guid is NULL, then ASSERT().
193 If there is no additional space for HOB creation, then ASSERT().
194 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
196 @param Guid The GUID to tag the customized HOB.
197 @param DataLength The size of the data payload for the GUID HOB.
199 @return The start address of GUID HOB data.
205 IN CONST EFI_GUID
*Guid
,
210 Copies a data buffer to a newly-built HOB.
212 This function builds a customized HOB tagged with a GUID for identification,
213 copies the input data to the HOB data field and returns the start address of the GUID HOB data.
214 The HOB Header and Name field is already stripped.
215 It can only be invoked during PEI phase;
216 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
217 If Guid is NULL, then ASSERT().
218 If Data is NULL and DataLength > 0, then ASSERT().
219 If there is no additional space for HOB creation, then ASSERT().
220 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
222 @param Guid The GUID to tag the customized HOB.
223 @param Data The data to be copied into the data field of the GUID HOB.
224 @param DataLength The size of the data payload for the GUID HOB.
226 @return The start address of GUID HOB data.
232 IN CONST EFI_GUID
*Guid
,
238 Builds a Firmware Volume HOB.
240 This function builds a Firmware Volume HOB.
241 It can only be invoked during PEI phase;
242 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
243 If there is no additional space for HOB creation, then ASSERT().
245 @param BaseAddress The base address of the Firmware Volume.
246 @param Length The size of the Firmware Volume in bytes.
252 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
257 Builds a EFI_HOB_TYPE_FV2 HOB.
259 This function builds a EFI_HOB_TYPE_FV2 HOB.
260 It can only be invoked during PEI phase;
261 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
262 If there is no additional space for HOB creation, then ASSERT().
264 @param BaseAddress The base address of the Firmware Volume.
265 @param Length The size of the Firmware Volume in bytes.
266 @param FvName The name of the Firmware Volume.
267 @param FileName The name of the file.
273 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
275 IN CONST EFI_GUID
*FvName
,
276 IN CONST EFI_GUID
*FileName
280 Builds a Capsule Volume HOB.
282 This function builds a Capsule Volume HOB.
283 It can only be invoked during PEI phase;
284 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
285 If there is no additional space for HOB creation, then ASSERT().
287 @param BaseAddress The base address of the Capsule Volume.
288 @param Length The size of the Capsule Volume in bytes.
294 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
299 Builds a HOB for the CPU.
301 This function builds a HOB for the CPU.
302 It can only be invoked during PEI phase;
303 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
304 If there is no additional space for HOB creation, then ASSERT().
306 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
307 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
313 IN UINT8 SizeOfMemorySpace
,
314 IN UINT8 SizeOfIoSpace
318 Builds a HOB for the Stack.
320 This function builds a HOB for the stack.
321 It can only be invoked during PEI phase;
322 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
323 If there is no additional space for HOB creation, then ASSERT().
325 @param BaseAddress The 64 bit physical address of the Stack.
326 @param Length The length of the stack in bytes.
332 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
337 Builds a HOB for the BSP store.
339 This function builds a HOB for BSP store.
340 It can only be invoked during PEI phase;
341 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
342 If there is no additional space for HOB creation, then ASSERT().
344 @param BaseAddress The 64 bit physical address of the BSP.
345 @param Length The length of the BSP store in bytes.
346 @param MemoryType Type of memory allocated by this HOB.
352 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
354 IN EFI_MEMORY_TYPE MemoryType
358 Builds a HOB for the memory allocation.
360 This function builds a HOB for the memory allocation.
361 It can only be invoked during PEI phase;
362 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
363 If there is no additional space for HOB creation, then ASSERT().
365 @param BaseAddress The 64 bit physical address of the memory.
366 @param Length The length of the memory allocation in bytes.
367 @param MemoryType Type of memory allocated by this HOB.
372 BuildMemoryAllocationHob (
373 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
375 IN EFI_MEMORY_TYPE MemoryType
379 /// Get a HOB's type from HOB header
381 #define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
384 /// Get a HOB's length from HOB header
386 #define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
389 /// Get the pointer to next HOB in HOB List
391 #define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
394 /// Judge if the HOB is the end of HOB List
396 #define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)
399 /// Get the pointer to data field of GUID HOB
401 #define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
404 /// Get the data size of GUID HOB
406 #define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))