3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include "EdkIIGlueDxe.h"
26 STATIC VOID
*mHobList
= NULL
;
29 The constructor function caches the pointer to HOB list.
31 The constructor function gets the start address of HOB list from system configuration table.
32 It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
34 @param ImageHandle The firmware allocated handle for the EFI image.
35 @param SystemTable A pointer to the EFI System Table.
37 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
43 IN EFI_HANDLE ImageHandle
,
44 IN EFI_SYSTEM_TABLE
*SystemTable
49 Status
= EfiGetSystemConfigurationTable (&gEfiHobListGuid
, &mHobList
);
50 ASSERT_EFI_ERROR (Status
);
51 ASSERT (mHobList
!= NULL
);
56 Returns the pointer to the HOB list.
58 This function returns the pointer to first HOB in the list.
60 @return The pointer to the HOB list.
73 Returns the next instance of a HOB type from the starting HOB.
75 This function searches the first instance of a HOB type from the starting HOB pointer.
76 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
77 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
78 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
79 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
80 If HobStart is NULL, then ASSERT().
82 @param Type The HOB type to return.
83 @param HobStart The starting HOB pointer to search from.
85 @return The next instance of a HOB type from the starting HOB.
92 IN CONST VOID
*HobStart
95 EFI_PEI_HOB_POINTERS Hob
;
97 ASSERT (HobStart
!= NULL
);
99 Hob
.Raw
= (UINT8
*) HobStart
;
101 // Parse the HOB list until end of list or matching type is found.
103 while (!END_OF_HOB_LIST (Hob
)) {
104 if (Hob
.Header
->HobType
== Type
) {
107 Hob
.Raw
= GET_NEXT_HOB (Hob
);
113 Returns the first instance of a HOB type among the whole HOB list.
115 This function searches the first instance of a HOB type among the whole HOB list.
116 If there does not exist such HOB type in the HOB list, it will return NULL.
118 @param Type The HOB type to return.
120 @return The next instance of a HOB type from the starting HOB.
131 HobList
= GetHobList ();
132 return GetNextHob (Type
, HobList
);
136 This function searches the first instance of a HOB from the starting HOB pointer.
137 Such HOB should satisfy two conditions:
138 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
139 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
140 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
141 to extract the data section and its size info respectively.
142 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
143 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
144 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
145 If Guid is NULL, then ASSERT().
146 If HobStart is NULL, then ASSERT().
148 @param Guid The GUID to match with in the HOB list.
149 @param HobStart A pointer to a Guid.
151 @return The next instance of the matched GUID HOB from the starting HOB.
157 IN CONST EFI_GUID
*Guid
,
158 IN CONST VOID
*HobStart
161 EFI_PEI_HOB_POINTERS GuidHob
;
163 GuidHob
.Raw
= (UINT8
*) HobStart
;
164 while ((GuidHob
.Raw
= GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION
, GuidHob
.Raw
)) != NULL
) {
165 if (CompareGuid (Guid
, &GuidHob
.Guid
->Name
)) {
168 GuidHob
.Raw
= GET_NEXT_HOB (GuidHob
);
174 This function searches the first instance of a HOB among the whole HOB list.
175 Such HOB should satisfy two conditions:
176 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
177 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
178 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
179 to extract the data section and its size info respectively.
180 If Guid is NULL, then ASSERT().
182 @param Guid The GUID to match with in the HOB list.
184 @return The first instance of the matched GUID HOB among the whole HOB list.
189 GlueGetFirstGuidHob (
190 IN CONST EFI_GUID
*Guid
195 HobList
= GetHobList ();
196 return GetNextGuidHob (Guid
, HobList
);
200 Get the Boot Mode from the HOB list.
202 This function returns the system boot mode information from the
203 PHIT HOB in HOB list.
207 @return The Boot Mode.
216 EFI_HOB_HANDOFF_INFO_TABLE
*HandOffHob
;
218 HandOffHob
= (EFI_HOB_HANDOFF_INFO_TABLE
*) GetHobList ();
220 return HandOffHob
->BootMode
;
224 Builds a HOB for a loaded PE32 module.
226 This function builds a HOB for a loaded PE32 module.
227 It can only be invoked during PEI phase;
228 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
229 If ModuleName is NULL, then ASSERT().
230 If there is no additional space for HOB creation, then ASSERT().
232 @param ModuleName The GUID File Name of the module.
233 @param MemoryAllocationModule The 64 bit physical address of the module.
234 @param ModuleLength The length of the module in bytes.
235 @param EntryPoint The 64 bit physical address of the module's entry point.
241 IN CONST EFI_GUID
*ModuleName
,
242 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
243 IN UINT64 ModuleLength
,
244 IN EFI_PHYSICAL_ADDRESS EntryPoint
248 // PEI HOB is read only for DXE phase
254 Builds a HOB that describes a chunk of system memory.
256 This function builds a HOB that describes a chunk of system memory.
257 It can only be invoked during PEI phase;
258 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
259 If there is no additional space for HOB creation, then ASSERT().
261 @param ResourceType The type of resource described by this HOB.
262 @param ResourceAttribute The resource attributes of the memory described by this HOB.
263 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
264 @param NumberOfBytes The length of the memory described by this HOB in bytes.
269 BuildResourceDescriptorHob (
270 IN EFI_RESOURCE_TYPE ResourceType
,
271 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
272 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
273 IN UINT64 NumberOfBytes
277 // PEI HOB is read only for DXE phase
283 Builds a GUID HOB with a certain data length.
285 This function builds a customized HOB tagged with a GUID for identification
286 and returns the start address of GUID HOB data so that caller can fill the customized data.
287 The HOB Header and Name field is already stripped.
288 It can only be invoked during PEI phase;
289 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
290 If Guid is NULL, then ASSERT().
291 If there is no additional space for HOB creation, then ASSERT().
292 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
294 @param Guid The GUID to tag the customized HOB.
295 @param DataLength The size of the data payload for the GUID HOB.
297 @return The start address of GUID HOB data.
303 IN CONST EFI_GUID
*Guid
,
308 // PEI HOB is read only for DXE phase
315 Copies a data buffer to a newly-built HOB.
317 This function builds a customized HOB tagged with a GUID for identification,
318 copies the input data to the HOB data field and returns the start address of the GUID HOB data.
319 The HOB Header and Name field is already stripped.
320 It can only be invoked during PEI phase;
321 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
322 If Guid is NULL, then ASSERT().
323 If Data is NULL and DataLength > 0, then ASSERT().
324 If there is no additional space for HOB creation, then ASSERT().
325 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
327 @param Guid The GUID to tag the customized HOB.
328 @param Data The data to be copied into the data field of the GUID HOB.
329 @param DataLength The size of the data payload for the GUID HOB.
331 @return The start address of GUID HOB data.
337 IN CONST EFI_GUID
*Guid
,
343 // PEI HOB is read only for DXE phase
350 Builds a Firmware Volume HOB.
352 This function builds a Firmware Volume HOB.
353 It can only be invoked during PEI phase;
354 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
355 If there is no additional space for HOB creation, then ASSERT().
357 @param BaseAddress The base address of the Firmware Volume.
358 @param Length The size of the Firmware Volume in bytes.
364 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
369 // PEI HOB is read only for DXE phase
375 Builds a Capsule Volume HOB.
377 This function builds a Capsule Volume HOB.
378 It can only be invoked during PEI phase;
379 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
380 If there is no additional space for HOB creation, then ASSERT().
382 @param BaseAddress The base address of the Capsule Volume.
383 @param Length The size of the Capsule Volume in bytes.
389 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
394 // PEI HOB is read only for DXE phase
400 Builds a HOB for the CPU.
402 This function builds a HOB for the CPU.
403 It can only be invoked during PEI phase;
404 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
405 If there is no additional space for HOB creation, then ASSERT().
407 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
408 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
414 IN UINT8 SizeOfMemorySpace
,
415 IN UINT8 SizeOfIoSpace
419 // PEI HOB is read only for DXE phase
425 Builds a HOB for the Stack.
427 This function builds a HOB for the stack.
428 It can only be invoked during PEI phase;
429 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
430 If there is no additional space for HOB creation, then ASSERT().
432 @param BaseAddress The 64 bit physical address of the Stack.
433 @param Length The length of the stack in bytes.
439 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
444 // PEI HOB is read only for DXE phase
450 Builds a HOB for the BSP store.
452 This function builds a HOB for BSP store.
453 It can only be invoked during PEI phase;
454 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
455 If there is no additional space for HOB creation, then ASSERT().
457 @param BaseAddress The 64 bit physical address of the BSP.
458 @param Length The length of the BSP store in bytes.
459 @param MemoryType Type of memory allocated by this HOB.
465 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
467 IN EFI_MEMORY_TYPE MemoryType
471 // PEI HOB is read only for DXE phase
477 Builds a HOB for the memory allocation.
479 This function builds a HOB for the memory allocation.
480 It can only be invoked during PEI phase;
481 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
482 If there is no additional space for HOB creation, then ASSERT().
484 @param BaseAddress The 64 bit physical address of the memory.
485 @param Length The length of the memory allocation in bytes.
486 @param MemoryType Type of memory allocated by this HOB.
491 GlueBuildMemoryAllocationHob (
492 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
494 IN EFI_MEMORY_TYPE MemoryType
498 // PEI HOB is read only for DXE phase