2 Provide Hob Library functions for Pei phase.
4 Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Guid/MemoryAllocationHob.h>
13 #include <Library/HobLib.h>
14 #include <Library/DebugLib.h>
15 #include <Library/PeiServicesLib.h>
16 #include <Library/BaseMemoryLib.h>
19 Returns the pointer to the HOB list.
21 This function returns the pointer to first HOB in the list.
22 For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
23 to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
24 the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
25 Since the System Configuration Table does not exist that the time the DXE Core is
26 launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
27 to manage the pointer to the HOB list.
29 If the pointer to the HOB list is NULL, then ASSERT().
31 @return The pointer to the HOB list.
43 Status
= PeiServicesGetHobList (&HobList
);
44 ASSERT_EFI_ERROR (Status
);
45 ASSERT (HobList
!= NULL
);
51 Returns the next instance of a HOB type from the starting HOB.
53 This function searches the first instance of a HOB type from the starting HOB pointer.
54 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
55 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
56 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
57 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
59 If HobStart is NULL, then ASSERT().
61 @param Type The HOB type to return.
62 @param HobStart The starting HOB pointer to search from.
64 @return The next instance of a HOB type from the starting HOB.
71 IN CONST VOID
*HobStart
74 EFI_PEI_HOB_POINTERS Hob
;
76 ASSERT (HobStart
!= NULL
);
78 Hob
.Raw
= (UINT8
*)HobStart
;
80 // Parse the HOB list until end of list or matching type is found.
82 while (!END_OF_HOB_LIST (Hob
)) {
83 if (Hob
.Header
->HobType
== Type
) {
87 Hob
.Raw
= GET_NEXT_HOB (Hob
);
94 Returns the first instance of a HOB type among the whole HOB list.
96 This function searches the first instance of a HOB type among the whole HOB list.
97 If there does not exist such HOB type in the HOB list, it will return NULL.
99 If the pointer to the HOB list is NULL, then ASSERT().
101 @param Type The HOB type to return.
103 @return The next instance of a HOB type from the starting HOB.
114 HobList
= GetHobList ();
115 return GetNextHob (Type
, HobList
);
119 Returns the next instance of the matched GUID HOB from the starting HOB.
121 This function searches the first instance of a HOB from the starting HOB pointer.
122 Such HOB should satisfy two conditions:
123 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
124 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
125 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
126 to extract the data section and its size information, respectively.
127 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
128 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
129 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
131 If Guid is NULL, then ASSERT().
132 If HobStart is NULL, then ASSERT().
134 @param Guid The GUID to match with in the HOB list.
135 @param HobStart A pointer to a Guid.
137 @return The next instance of the matched GUID HOB from the starting HOB.
143 IN CONST EFI_GUID
*Guid
,
144 IN CONST VOID
*HobStart
147 EFI_PEI_HOB_POINTERS GuidHob
;
149 GuidHob
.Raw
= (UINT8
*)HobStart
;
150 while ((GuidHob
.Raw
= GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION
, GuidHob
.Raw
)) != NULL
) {
151 if (CompareGuid (Guid
, &GuidHob
.Guid
->Name
)) {
155 GuidHob
.Raw
= GET_NEXT_HOB (GuidHob
);
162 Returns the first instance of the matched GUID HOB among the whole HOB list.
164 This function searches the first instance of a HOB among the whole HOB list.
165 Such HOB should satisfy two conditions:
166 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
167 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
168 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
169 to extract the data section and its size information, respectively.
171 If the pointer to the HOB list is NULL, then ASSERT().
172 If Guid is NULL, then ASSERT().
174 @param Guid The GUID to match with in the HOB list.
176 @return The first instance of the matched GUID HOB among the whole HOB list.
182 IN CONST EFI_GUID
*Guid
187 HobList
= GetHobList ();
188 return GetNextGuidHob (Guid
, HobList
);
192 Get the system boot mode from the HOB list.
194 This function returns the system boot mode information from the
195 PHIT HOB in HOB list.
197 If the pointer to the HOB list is NULL, then ASSERT().
201 @return The Boot Mode.
211 EFI_BOOT_MODE BootMode
;
213 Status
= PeiServicesGetBootMode (&BootMode
);
214 ASSERT_EFI_ERROR (Status
);
220 Adds a new HOB to the HOB List.
222 This internal function enables PEIMs to create various types of HOBs.
224 @param Type Type of the new HOB.
225 @param Length Length of the new HOB to allocate.
227 @retval NULL The HOB could not be allocated.
228 @retval others The address of new HOB.
233 InternalPeiCreateHob (
241 Status
= PeiServicesCreateHob (Type
, Length
, &Hob
);
242 if (EFI_ERROR (Status
)) {
247 // Assume the process of HOB building is always successful.
249 ASSERT (Hob
!= NULL
);
254 Builds a HOB for a loaded PE32 module.
256 This function builds a HOB for a loaded PE32 module.
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.
260 If ModuleName is NULL, then ASSERT().
261 If there is no additional space for HOB creation, then ASSERT().
263 @param ModuleName The GUID File Name of the module.
264 @param MemoryAllocationModule The 64 bit physical address of the module.
265 @param ModuleLength The length of the module in bytes.
266 @param EntryPoint The 64 bit physical address of the module entry point.
272 IN CONST EFI_GUID
*ModuleName
,
273 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
274 IN UINT64 ModuleLength
,
275 IN EFI_PHYSICAL_ADDRESS EntryPoint
278 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
281 ((MemoryAllocationModule
& (EFI_PAGE_SIZE
- 1)) == 0) &&
282 ((ModuleLength
& (EFI_PAGE_SIZE
- 1)) == 0)
285 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
)sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
));
290 CopyGuid (&(Hob
->MemoryAllocationHeader
.Name
), &gEfiHobMemoryAllocModuleGuid
);
291 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
292 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
293 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
296 // Zero the reserved space to match HOB spec
298 ZeroMem (Hob
->MemoryAllocationHeader
.Reserved
, sizeof (Hob
->MemoryAllocationHeader
.Reserved
));
300 CopyGuid (&Hob
->ModuleName
, ModuleName
);
301 Hob
->EntryPoint
= EntryPoint
;
305 Builds a HOB that describes a chunk of system memory with Owner GUID.
307 This function builds a HOB that describes a chunk of system memory.
308 It can only be invoked during PEI phase;
309 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
311 If there is no additional space for HOB creation, then ASSERT().
313 @param ResourceType The type of resource described by this HOB.
314 @param ResourceAttribute The resource attributes of the memory described by this HOB.
315 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
316 @param NumberOfBytes The length of the memory described by this HOB in bytes.
317 @param OwnerGUID GUID for the owner of this resource.
322 BuildResourceDescriptorWithOwnerHob (
323 IN EFI_RESOURCE_TYPE ResourceType
,
324 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
325 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
326 IN UINT64 NumberOfBytes
,
327 IN EFI_GUID
*OwnerGUID
330 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
332 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, (UINT16
)sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
337 Hob
->ResourceType
= ResourceType
;
338 Hob
->ResourceAttribute
= ResourceAttribute
;
339 Hob
->PhysicalStart
= PhysicalStart
;
340 Hob
->ResourceLength
= NumberOfBytes
;
342 CopyGuid (&Hob
->Owner
, OwnerGUID
);
346 Builds a HOB that describes a chunk of system memory.
348 This function builds a HOB that describes a chunk of system memory.
349 It can only be invoked during PEI phase;
350 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
352 If there is no additional space for HOB creation, then ASSERT().
354 @param ResourceType The type of resource described by this HOB.
355 @param ResourceAttribute The resource attributes of the memory described by this HOB.
356 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
357 @param NumberOfBytes The length of the memory described by this HOB in bytes.
362 BuildResourceDescriptorHob (
363 IN EFI_RESOURCE_TYPE ResourceType
,
364 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
365 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
366 IN UINT64 NumberOfBytes
369 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
371 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, (UINT16
)sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
376 Hob
->ResourceType
= ResourceType
;
377 Hob
->ResourceAttribute
= ResourceAttribute
;
378 Hob
->PhysicalStart
= PhysicalStart
;
379 Hob
->ResourceLength
= NumberOfBytes
;
380 ZeroMem (&(Hob
->Owner
), sizeof (EFI_GUID
));
384 Builds a customized HOB tagged with a GUID for identification and returns
385 the start address of GUID HOB data.
387 This function builds a customized HOB tagged with a GUID for identification
388 and returns the start address of GUID HOB data so that caller can fill the customized data.
389 The HOB Header and Name field is already stripped.
390 It can only be invoked during PEI phase;
391 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
393 If Guid is NULL, then ASSERT().
394 If there is no additional space for HOB creation, then ASSERT().
395 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
396 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
398 @param Guid The GUID to tag the customized HOB.
399 @param DataLength The size of the data payload for the GUID HOB.
401 @retval NULL The GUID HOB could not be allocated.
402 @retval others The start address of GUID HOB data.
408 IN CONST EFI_GUID
*Guid
,
412 EFI_HOB_GUID_TYPE
*Hob
;
415 // Make sure Guid is valid
417 ASSERT (Guid
!= NULL
);
420 // Make sure that data length is not too long.
422 ASSERT (DataLength
<= (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE
)));
424 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION
, (UINT16
)(sizeof (EFI_HOB_GUID_TYPE
) + DataLength
));
429 CopyGuid (&Hob
->Name
, Guid
);
434 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
435 data field, and returns the start address of the GUID HOB data.
437 This function builds a customized HOB tagged with a GUID for identification and copies the input
438 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
439 invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
440 The HOB Header and Name field is already stripped.
441 It can only be invoked during PEI phase;
442 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
444 If Guid is NULL, then ASSERT().
445 If Data is NULL and DataLength > 0, then ASSERT().
446 If there is no additional space for HOB creation, then ASSERT().
447 If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
448 HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
450 @param Guid The GUID to tag the customized HOB.
451 @param Data The data to be copied into the data field of the GUID HOB.
452 @param DataLength The size of the data payload for the GUID HOB.
454 @retval NULL The GUID HOB could not be allocated.
455 @retval others The start address of GUID HOB data.
461 IN CONST EFI_GUID
*Guid
,
468 ASSERT (Data
!= NULL
|| DataLength
== 0);
470 HobData
= BuildGuidHob (Guid
, DataLength
);
471 if (HobData
== NULL
) {
475 return CopyMem (HobData
, Data
, DataLength
);
481 @param BaseAddress The base address of the Firmware Volume.
482 @param Length The size of the Firmware Volume in bytes.
484 @retval TRUE FvImage buffer is at its required alignment.
485 @retval FALSE FvImage buffer is not at its required alignment.
489 InternalCheckFvAlignment (
490 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
494 EFI_FIRMWARE_VOLUME_HEADER
*FwVolHeader
;
498 FwVolHeader
= (EFI_FIRMWARE_VOLUME_HEADER
*)(UINTN
)BaseAddress
;
501 // If EFI_FVB2_WEAK_ALIGNMENT is set in the volume header then the first byte of the volume
502 // can be aligned on any power-of-two boundary. A weakly aligned volume can not be moved from
503 // its initial linked location and maintain its alignment.
505 if ((FwVolHeader
->Attributes
& EFI_FVB2_WEAK_ALIGNMENT
) != EFI_FVB2_WEAK_ALIGNMENT
) {
507 // Get FvHeader alignment
509 FvAlignment
= 1 << ((FwVolHeader
->Attributes
& EFI_FVB2_ALIGNMENT
) >> 16);
511 // FvAlignment must be greater than or equal to 8 bytes of the minimum FFS alignment value.
513 if (FvAlignment
< 8) {
517 if ((UINTN
)BaseAddress
% FvAlignment
!= 0) {
519 // FvImage buffer is not at its required alignment.
523 "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n",
536 Builds a Firmware Volume HOB.
538 This function builds a Firmware Volume HOB.
539 It can only be invoked during PEI phase;
540 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
542 If there is no additional space for HOB creation, then ASSERT().
543 If the FvImage buffer is not at its required alignment, then ASSERT().
545 @param BaseAddress The base address of the Firmware Volume.
546 @param Length The size of the Firmware Volume in bytes.
552 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
556 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
558 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
563 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV
, (UINT16
)sizeof (EFI_HOB_FIRMWARE_VOLUME
));
568 Hob
->BaseAddress
= BaseAddress
;
569 Hob
->Length
= Length
;
573 Builds a EFI_HOB_TYPE_FV2 HOB.
575 This function builds a EFI_HOB_TYPE_FV2 HOB.
576 It can only be invoked during PEI phase;
577 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
579 If there is no additional space for HOB creation, then ASSERT().
580 If the FvImage buffer is not at its required alignment, then ASSERT().
582 @param BaseAddress The base address of the Firmware Volume.
583 @param Length The size of the Firmware Volume in bytes.
584 @param FvName The name of the Firmware Volume.
585 @param FileName The name of the file.
591 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
593 IN CONST EFI_GUID
*FvName
,
594 IN CONST EFI_GUID
*FileName
597 EFI_HOB_FIRMWARE_VOLUME2
*Hob
;
599 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
604 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV2
, (UINT16
)sizeof (EFI_HOB_FIRMWARE_VOLUME2
));
609 Hob
->BaseAddress
= BaseAddress
;
610 Hob
->Length
= Length
;
611 CopyGuid (&Hob
->FvName
, FvName
);
612 CopyGuid (&Hob
->FileName
, FileName
);
616 Builds a EFI_HOB_TYPE_FV3 HOB.
618 This function builds a EFI_HOB_TYPE_FV3 HOB.
619 It can only be invoked during PEI phase;
620 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
622 If there is no additional space for HOB creation, then ASSERT().
623 If the FvImage buffer is not at its required alignment, then ASSERT().
625 @param BaseAddress The base address of the Firmware Volume.
626 @param Length The size of the Firmware Volume in bytes.
627 @param AuthenticationStatus The authentication status.
628 @param ExtractedFv TRUE if the FV was extracted as a file within
629 another firmware volume. FALSE otherwise.
630 @param FvName The name of the Firmware Volume.
631 Valid only if IsExtractedFv is TRUE.
632 @param FileName The name of the file.
633 Valid only if IsExtractedFv is TRUE.
639 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
641 IN UINT32 AuthenticationStatus
,
642 IN BOOLEAN ExtractedFv
,
643 IN CONST EFI_GUID
*FvName OPTIONAL
,
644 IN CONST EFI_GUID
*FileName OPTIONAL
647 EFI_HOB_FIRMWARE_VOLUME3
*Hob
;
649 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
654 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV3
, (UINT16
)sizeof (EFI_HOB_FIRMWARE_VOLUME3
));
659 Hob
->BaseAddress
= BaseAddress
;
660 Hob
->Length
= Length
;
661 Hob
->AuthenticationStatus
= AuthenticationStatus
;
662 Hob
->ExtractedFv
= ExtractedFv
;
664 CopyGuid (&Hob
->FvName
, FvName
);
665 CopyGuid (&Hob
->FileName
, FileName
);
670 Builds a Capsule Volume HOB.
672 This function builds a Capsule Volume HOB.
673 It can only be invoked during PEI phase;
674 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
676 If the platform does not support Capsule Volume HOBs, then ASSERT().
677 If there is no additional space for HOB creation, then ASSERT().
679 @param BaseAddress The base address of the Capsule Volume.
680 @param Length The size of the Capsule Volume in bytes.
686 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
690 EFI_HOB_UEFI_CAPSULE
*Hob
;
692 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_UEFI_CAPSULE
, (UINT16
)sizeof (EFI_HOB_UEFI_CAPSULE
));
697 Hob
->BaseAddress
= BaseAddress
;
698 Hob
->Length
= Length
;
702 Builds a HOB for the CPU.
704 This function builds a HOB for the CPU.
705 It can only be invoked during PEI phase;
706 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
708 If there is no additional space for HOB creation, then ASSERT().
710 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
711 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
717 IN UINT8 SizeOfMemorySpace
,
718 IN UINT8 SizeOfIoSpace
723 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_CPU
, (UINT16
)sizeof (EFI_HOB_CPU
));
728 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
729 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
732 // Zero the reserved space to match HOB spec
734 ZeroMem (Hob
->Reserved
, sizeof (Hob
->Reserved
));
738 Builds a HOB for the Stack.
740 This function builds a HOB for the stack.
741 It can only be invoked during PEI phase;
742 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
744 If there is no additional space for HOB creation, then ASSERT().
746 @param BaseAddress The 64 bit physical address of the Stack.
747 @param Length The length of the stack in bytes.
753 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
757 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
760 ((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
761 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0)
764 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
)sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
));
769 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocStackGuid
);
770 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
771 Hob
->AllocDescriptor
.MemoryLength
= Length
;
772 Hob
->AllocDescriptor
.MemoryType
= EfiBootServicesData
;
775 // Zero the reserved space to match HOB spec
777 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));
781 Builds a HOB for the BSP store.
783 This function builds a HOB for BSP store.
784 It can only be invoked during PEI phase;
785 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
787 If there is no additional space for HOB creation, then ASSERT().
789 @param BaseAddress The 64 bit physical address of the BSP.
790 @param Length The length of the BSP store in bytes.
791 @param MemoryType The type of memory allocated by this HOB.
797 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
799 IN EFI_MEMORY_TYPE MemoryType
802 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
*Hob
;
805 ((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
806 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0)
809 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
)sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
));
814 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocBspStoreGuid
);
815 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
816 Hob
->AllocDescriptor
.MemoryLength
= Length
;
817 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
820 // Zero the reserved space to match HOB spec
822 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));
826 Builds a HOB for the memory allocation.
828 This function builds a HOB for the memory allocation.
829 It can only be invoked during PEI phase;
830 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
832 If there is no additional space for HOB creation, then ASSERT().
834 @param BaseAddress The 64 bit physical address of the memory.
835 @param Length The length of the memory allocation in bytes.
836 @param MemoryType The type of memory allocated by this HOB.
841 BuildMemoryAllocationHob (
842 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
844 IN EFI_MEMORY_TYPE MemoryType
847 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
850 ((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
851 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0)
854 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
)sizeof (EFI_HOB_MEMORY_ALLOCATION
));
859 ZeroMem (&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
));
860 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
861 Hob
->AllocDescriptor
.MemoryLength
= Length
;
862 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
864 // Zero the reserved space to match HOB spec
866 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));