2 Public include file for the HOB Library
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Returns the pointer to the HOB list.
21 This function returns the pointer to first HOB in the list.
23 @return The pointer to the HOB list.
33 Returns the next instance of a HOB type from the starting HOB.
35 This function searches the first instance of a HOB type from the starting HOB pointer.
36 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
37 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
38 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
39 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
40 If HobStart is NULL, then ASSERT().
42 @param Type The HOB type to return.
43 @param HobStart The starting HOB pointer to search from.
45 @return The next instance of a HOB type from the starting HOB.
52 IN CONST VOID
*HobStart
56 Returns the first instance of a HOB type among the whole HOB list.
58 This function searches the first instance of a HOB type among the whole HOB list.
59 If there does not exist such HOB type in the HOB list, it will return NULL.
61 @param Type The HOB type to return.
63 @return The next instance of a HOB type from the starting HOB.
73 This function searches the first instance of a HOB from the starting HOB pointer.
74 Such HOB should satisfy two conditions:
75 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
76 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
77 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
78 to extract the data section and its size info respectively.
79 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
80 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
81 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
82 If Guid is NULL, then ASSERT().
83 If HobStart is NULL, then ASSERT().
85 @param Guid The GUID to match with in the HOB list.
86 @param HobStart A pointer to a Guid.
88 @return The next instance of the matched GUID HOB from the starting HOB.
94 IN CONST EFI_GUID
*Guid
,
95 IN CONST VOID
*HobStart
99 This function searches the first instance of a HOB among the whole HOB list.
100 Such HOB should satisfy two conditions:
101 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
102 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
103 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
104 to extract the data section and its size info respectively.
105 If Guid is NULL, then ASSERT().
107 @param Guid The GUID to match with in the HOB list.
109 @return The first instance of the matched GUID HOB among the whole HOB list.
115 IN CONST EFI_GUID
*Guid
119 Get the Boot Mode from the HOB list.
121 This function returns the system boot mode information from the
122 PHIT HOB in HOB list.
126 @return The Boot Mode.
136 Builds a HOB for a loaded PE32 module.
138 This function builds a HOB for a loaded PE32 module.
139 It can only be invoked during PEI phase;
140 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
141 If ModuleName is NULL, then ASSERT().
142 If there is no additional space for HOB creation, then ASSERT().
144 @param ModuleName The GUID File Name of the module.
145 @param MemoryAllocationModule The 64 bit physical address of the module.
146 @param ModuleLength The length of the module in bytes.
147 @param EntryPoint The 64 bit physical address of the module entry point.
153 IN CONST EFI_GUID
*ModuleName
,
154 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
155 IN UINT64 ModuleLength
,
156 IN EFI_PHYSICAL_ADDRESS EntryPoint
160 Builds a HOB that describes a chunk of system memory.
162 This function builds a HOB that describes a chunk of system memory.
163 It can only be invoked during PEI phase;
164 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
165 If there is no additional space for HOB creation, then ASSERT().
167 @param ResourceType The type of resource described by this HOB.
168 @param ResourceAttribute The resource attributes of the memory described by this HOB.
169 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
170 @param NumberOfBytes The length of the memory described by this HOB in bytes.
175 BuildResourceDescriptorHob (
176 IN EFI_RESOURCE_TYPE ResourceType
,
177 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
178 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
179 IN UINT64 NumberOfBytes
183 Builds a GUID HOB with a certain data length.
185 This function builds a customized HOB tagged with a GUID for identification
186 and returns the start address of GUID HOB data so that caller can fill the customized data.
187 The HOB Header and Name field is already stripped.
188 It can only be invoked during PEI phase;
189 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
190 If Guid is NULL, then ASSERT().
191 If there is no additional space for HOB creation, then ASSERT().
192 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
194 @param Guid The GUID to tag the customized HOB.
195 @param DataLength The size of the data payload for the GUID HOB.
197 @return The start address of GUID HOB data.
203 IN CONST EFI_GUID
*Guid
,
208 Copies a data buffer to a newly-built HOB.
210 This function builds a customized HOB tagged with a GUID for identification,
211 copies the input data to the HOB data field and returns the start address of the GUID HOB data.
212 The HOB Header and Name field is already stripped.
213 It can only be invoked during PEI phase;
214 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
215 If Guid is NULL, then ASSERT().
216 If Data is NULL and DataLength > 0, then ASSERT().
217 If there is no additional space for HOB creation, then ASSERT().
218 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
220 @param Guid The GUID to tag the customized HOB.
221 @param Data The data to be copied into the data field of the GUID HOB.
222 @param DataLength The size of the data payload for the GUID HOB.
224 @return The start address of GUID HOB data.
230 IN CONST EFI_GUID
*Guid
,
236 Builds a Firmware Volume HOB.
238 This function builds a Firmware Volume HOB.
239 It can only be invoked during PEI phase;
240 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
241 If there is no additional space for HOB creation, then ASSERT().
243 @param BaseAddress The base address of the Firmware Volume.
244 @param Length The size of the Firmware Volume in bytes.
250 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
255 Builds a EFI_HOB_TYPE_FV2 HOB.
257 This function builds a EFI_HOB_TYPE_FV2 HOB.
258 It can only be invoked during PEI phase;
259 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
260 If there is no additional space for HOB creation, then ASSERT().
262 @param BaseAddress The base address of the Firmware Volume.
263 @param Length The size of the Firmware Volume in bytes.
264 @param FvName The name of the Firmware Volume.
265 @param FileName The name of the file.
271 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
273 IN CONST EFI_GUID
*FvName
,
274 IN CONST EFI_GUID
*FileName
278 Builds a Capsule Volume HOB.
280 This function builds a Capsule Volume HOB.
281 It can only be invoked during PEI phase;
282 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
283 If there is no additional space for HOB creation, then ASSERT().
285 @param BaseAddress The base address of the Capsule Volume.
286 @param Length The size of the Capsule Volume in bytes.
292 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
297 Builds a HOB for the CPU.
299 This function builds a HOB for the CPU.
300 It can only be invoked during PEI phase;
301 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
302 If there is no additional space for HOB creation, then ASSERT().
304 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
305 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
311 IN UINT8 SizeOfMemorySpace
,
312 IN UINT8 SizeOfIoSpace
316 Builds a HOB for the Stack.
318 This function builds a HOB for the stack.
319 It can only be invoked during PEI phase;
320 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().
323 @param BaseAddress The 64 bit physical address of the Stack.
324 @param Length The length of the stack in bytes.
330 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
335 Builds a HOB for the BSP store.
337 This function builds a HOB for BSP store.
338 It can only be invoked during PEI phase;
339 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
340 If there is no additional space for HOB creation, then ASSERT().
342 @param BaseAddress The 64 bit physical address of the BSP.
343 @param Length The length of the BSP store in bytes.
344 @param MemoryType Type of memory allocated by this HOB.
350 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
352 IN EFI_MEMORY_TYPE MemoryType
356 Builds a HOB for the memory allocation.
358 This function builds a HOB for the memory allocation.
359 It can only be invoked during PEI phase;
360 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
361 If there is no additional space for HOB creation, then ASSERT().
363 @param BaseAddress The 64 bit physical address of the memory.
364 @param Length The length of the memory allocation in bytes.
365 @param MemoryType Type of memory allocated by this HOB.
370 BuildMemoryAllocationHob (
371 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
373 IN EFI_MEMORY_TYPE MemoryType
377 /// Get a HOB's type from HOB header
379 #define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
382 /// Get a HOB's length from HOB header
384 #define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
387 /// Get the pointer to next HOB in HOB List
389 #define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
392 /// Judge if the HOB is the end of HOB List
394 #define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == (UINT16)EFI_HOB_TYPE_END_OF_HOB_LIST)
397 /// Get the pointer to data field of GUID HOB
399 #define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
402 /// Get the data size of GUID HOB
404 #define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))