4 Copyright (c) 2006, Intel Corporation<BR>
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.
20 Returns the pointer to the HOB list.
24 The pointer to the HOB list.
36 Status
= PeiCoreGetHobList (&HobList
);
37 ASSERT_EFI_ERROR (Status
);
38 ASSERT (HobList
!= NULL
);
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.
47 @param Type The HOB type to return.
48 @param HobStart The starting HOB pointer to search from.
50 @return The next instance of a HOB type from the starting HOB.
57 IN CONST VOID
*HobStart
60 EFI_PEI_HOB_POINTERS Hob
;
62 ASSERT (HobStart
!= NULL
);
64 Hob
.Raw
= (UINT8
*) HobStart
;
66 // Parse the HOB list, stop if end of list or matching type found.
68 while (!END_OF_HOB_LIST (Hob
)) {
69 if (Hob
.Header
->HobType
== Type
) {
72 Hob
.Raw
= GET_NEXT_HOB (Hob
);
78 This function searches the first instance of a HOB type among the whole HOB list.
79 If there does not exist such HOB type in the HOB list, it will return NULL.
81 @param Type The HOB type to return.
83 @return The next instance of a HOB type from the starting HOB.
94 HobList
= GetHobList ();
95 return GetNextHob (Type
, HobList
);
99 This function searches the first instance of a HOB from the starting HOB pointer.
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.
104 @param Guid The GUID to match with in the HOB list.
105 @param HobStart A pointer to a Guid.
107 @return The next instance of the matched GUID HOB from the starting HOB.
113 IN CONST EFI_GUID
*Guid
,
114 IN CONST VOID
*HobStart
117 EFI_PEI_HOB_POINTERS GuidHob
;
119 GuidHob
.Raw
= (UINT8
*) HobStart
;
120 while ((GuidHob
.Raw
= GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION
, GuidHob
.Raw
)) != NULL
) {
121 if (CompareGuid (Guid
, &GuidHob
.Guid
->Name
)) {
124 GuidHob
.Raw
= GET_NEXT_HOB (GuidHob
);
130 This function searches the first instance of a HOB among the whole HOB list.
131 Such HOB should satisfy two conditions:
132 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
133 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
135 @param Guid The GUID to match with in the HOB list.
137 @return The first instance of the matched GUID HOB among the whole HOB list.
143 IN CONST EFI_GUID
*Guid
148 HobList
= GetHobList ();
149 return GetNextGuidHob (Guid
, HobList
);
153 Add a new HOB to the HOB List.
155 @param Type Type of the new HOB.
156 @param Length Length of the new HOB to allocate.
158 @return The address of new HOB.
162 InternalPeiCreateHob (
170 Status
= PeiCoreCreateHob (Type
, Length
, &Hob
);
172 // Assume the process of HOB building is always successful.
174 ASSERT_EFI_ERROR (Status
);
179 This function builds a HOB for a loaded PE32 module.
181 @param ModuleName The GUID File Name of the module.
182 @param MemoryAllocationModule The 64 bit physical address of the module.
183 @param ModuleLength The length of the module in bytes.
184 @param EntryPoint The 64 bit physical address of the module\92s entry point.
190 IN CONST EFI_GUID
*ModuleName
,
191 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
192 IN UINT64 ModuleLength
,
193 IN EFI_PHYSICAL_ADDRESS EntryPoint
196 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
198 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
));
200 CopyGuid (&(Hob
->MemoryAllocationHeader
.Name
), &gEfiHobMemoryAllocModuleGuid
);
201 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
202 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
203 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
205 CopyGuid (&Hob
->ModuleName
, ModuleName
);
206 Hob
->EntryPoint
= EntryPoint
;
210 Builds a HOB that describes a chunk of system memory.
212 @param ResourceType The type of resource described by this HOB.
213 @param ResourceAttribute The resource attributes of the memory described by this HOB.
214 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
215 @param NumberOfBytes The length of the memory described by this HOB in bytes.
220 BuildResourceDescriptorHob (
221 IN EFI_RESOURCE_TYPE ResourceType
,
222 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
223 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
224 IN UINT64 NumberOfBytes
227 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
229 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
231 Hob
->ResourceType
= ResourceType
;
232 Hob
->ResourceAttribute
= ResourceAttribute
;
233 Hob
->PhysicalStart
= PhysicalStart
;
234 Hob
->ResourceLength
= NumberOfBytes
;
238 This function builds a customized HOB tagged with a GUID for identification
239 and returns the start address of GUID HOB data so that caller can fill the customized data.
241 @param Guid The GUID to tag the customized HOB.
242 @param DataLength The size of the data payload for the GUID HOB.
244 @return The start address of GUID HOB data.
250 IN CONST EFI_GUID
*Guid
,
254 EFI_HOB_GUID_TYPE
*Hob
;
257 // Make sure that data length is not too long.
259 ASSERT (DataLength
<= (0xffff - sizeof (EFI_HOB_GUID_TYPE
)));
261 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION
, (UINT16
) (sizeof (EFI_HOB_GUID_TYPE
) + DataLength
));
262 CopyGuid (&Hob
->Name
, Guid
);
267 This function builds a customized HOB tagged with a GUID for identification,
268 copies the input data to the HOB data field, and returns the start address of GUID HOB data.
270 @param Guid The GUID to tag the customized HOB.
271 @param Data The data to be copied into the data field of the GUID HOB.
272 @param DataLength The size of the data payload for the GUID HOB.
274 @return The start address of GUID HOB data.
280 IN CONST EFI_GUID
*Guid
,
287 HobData
= BuildGuidHob (Guid
, DataLength
);
289 return CopyMem (HobData
, Data
, DataLength
);
293 Builds a Firmware Volume HOB.
295 @param BaseAddress The base address of the Firmware Volume.
296 @param Length The size of the Firmware Volume in bytes.
302 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
306 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
308 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV
, sizeof (EFI_HOB_FIRMWARE_VOLUME
));
310 Hob
->BaseAddress
= BaseAddress
;
311 Hob
->Length
= Length
;
315 Builds a Capsule Volume HOB.
317 @param BaseAddress The base address of the Capsule Volume.
318 @param Length The size of the Capsule Volume in bytes.
324 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
328 EFI_HOB_CAPSULE_VOLUME
*Hob
;
330 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_CV
, sizeof (EFI_HOB_CAPSULE_VOLUME
));
332 Hob
->BaseAddress
= BaseAddress
;
333 Hob
->Length
= Length
;
337 Builds a HOB for the CPU.
339 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
340 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
346 IN UINT8 SizeOfMemorySpace
,
347 IN UINT8 SizeOfIoSpace
352 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_CPU
, sizeof (EFI_HOB_CPU
));
354 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
355 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
359 Builds a HOB for the Stack.
361 @param BaseAddress The 64 bit physical address of the Stack.
362 @param Length The length of the stack in bytes.
368 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
372 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
374 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
));
376 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocStackGuid
);
377 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
378 Hob
->AllocDescriptor
.MemoryLength
= Length
;
379 Hob
->AllocDescriptor
.MemoryType
= EfiConventionalMemory
;
383 Builds a HOB for the BSP store.
385 @param BaseAddress The 64 bit physical address of the BSP.
386 @param Length The length of the BSP store in bytes.
387 @param MemoryType Type of memory allocated by this HOB.
393 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
395 IN EFI_MEMORY_TYPE MemoryType
398 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
*Hob
;
400 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
));
402 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocBspStoreGuid
);
403 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
404 Hob
->AllocDescriptor
.MemoryLength
= Length
;
405 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
409 Builds a HOB for the memory allocation.
411 @param BaseAddress The 64 bit physical address of the memory.
412 @param Length The length of the memory allocation in bytes.
413 @param MemoryType Type of memory allocated by this HOB.
418 BuildMemoryAllocationHob (
419 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
421 IN EFI_MEMORY_TYPE MemoryType
424 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
426 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION
));
428 ZeroMem (&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
));
429 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
430 Hob
->AllocDescriptor
.MemoryLength
= Length
;
431 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;