2 Instance of HOB Library using PEI Services.
4 HOB Library implementation that uses PEI Services to retrieve the HOB List.
5 This library instance uses EFI_HOB_TYPE_CV defined in Intel framework HOB specification v0.9
6 to implement HobLib BuildCvHob() API.
8 Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <FrameworkPei.h>
21 #include <Guid/MemoryAllocationHob.h>
23 #include <Library/HobLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/PeiServicesLib.h>
26 #include <Library/BaseMemoryLib.h>
29 Returns the pointer to the HOB list.
31 This function returns the pointer to first HOB in the list.
32 For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
33 to the HOB list. For the DXE phase, the HOB list pointer can be retrieved through
34 the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
35 Since the System Configuration Table does not exist that the time the DXE Core is
36 launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
37 to manage the pointer to the HOB list.
39 If the pointer to the HOB list is NULL, then ASSERT().
41 @return The pointer to the HOB list.
53 Status
= PeiServicesGetHobList (&HobList
);
54 ASSERT_EFI_ERROR (Status
);
55 ASSERT (HobList
!= NULL
);
61 Returns the next instance of a HOB type from the starting HOB.
63 This function searches the first instance of a HOB type from the starting HOB pointer.
64 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
65 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
66 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
67 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
69 If HobStart is NULL, then ASSERT().
71 @param Type The HOB type to return.
72 @param HobStart The starting HOB pointer to search from.
74 @return The next instance of a HOB type from the starting HOB.
81 IN CONST VOID
*HobStart
84 EFI_PEI_HOB_POINTERS Hob
;
86 ASSERT (HobStart
!= NULL
);
88 Hob
.Raw
= (UINT8
*) HobStart
;
90 // Parse the HOB list until end of list or matching type is found.
92 while (!END_OF_HOB_LIST (Hob
)) {
93 if (Hob
.Header
->HobType
== Type
) {
96 Hob
.Raw
= GET_NEXT_HOB (Hob
);
102 Returns the first instance of a HOB type among the whole HOB list.
104 This function searches the first instance of a HOB type among the whole HOB list.
105 If there does not exist such HOB type in the HOB list, it will return NULL.
107 If the pointer to the HOB list is NULL, then ASSERT().
109 @param Type The HOB type to return.
111 @return The next instance of a HOB type from the starting HOB.
122 HobList
= GetHobList ();
123 return GetNextHob (Type
, HobList
);
127 Returns the next instance of the matched GUID HOB from the starting HOB.
129 This function searches the first instance of a HOB from the starting HOB pointer.
130 Such HOB should satisfy two conditions:
131 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
132 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
133 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
134 to extract the data section and its size info respectively.
135 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
136 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
137 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
139 If Guid is NULL, then ASSERT().
140 If HobStart is NULL, then ASSERT().
142 @param Guid The GUID to match with in the HOB list.
143 @param HobStart A pointer to a Guid.
145 @return The next instance of the matched GUID HOB from the starting HOB.
151 IN CONST EFI_GUID
*Guid
,
152 IN CONST VOID
*HobStart
155 EFI_PEI_HOB_POINTERS GuidHob
;
157 GuidHob
.Raw
= (UINT8
*) HobStart
;
158 while ((GuidHob
.Raw
= GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION
, GuidHob
.Raw
)) != NULL
) {
159 if (CompareGuid (Guid
, &GuidHob
.Guid
->Name
)) {
162 GuidHob
.Raw
= GET_NEXT_HOB (GuidHob
);
168 Returns the first instance of the matched GUID HOB among the whole HOB list.
170 This function searches the first instance of a HOB among the whole HOB list.
171 Such HOB should satisfy two conditions:
172 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
173 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
174 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
175 to extract the data section and its size info respectively.
177 If the pointer to the HOB list is NULL, then ASSERT().
178 If Guid is NULL, then ASSERT().
180 @param Guid The GUID to match with in the HOB list.
182 @return The first instance of the matched GUID HOB among the whole HOB list.
188 IN CONST EFI_GUID
*Guid
193 HobList
= GetHobList ();
194 return GetNextGuidHob (Guid
, HobList
);
198 Get the system boot mode from the HOB list.
200 This function returns the system boot mode information from the
201 PHIT HOB in HOB list.
203 If the pointer to the HOB list is NULL, then ASSERT().
207 @return The Boot Mode.
217 EFI_BOOT_MODE BootMode
;
219 Status
= PeiServicesGetBootMode (&BootMode
);
220 ASSERT_EFI_ERROR (Status
);
226 Adds a new HOB to the HOB List.
228 This internal function enables PEIMs to create various types of HOBs.
230 @param Type Type of the new HOB.
231 @param Length Length of the new HOB to allocate.
233 @retval NULL The HOB could not be allocated.
234 @retval others The address of new HOB.
239 InternalPeiCreateHob (
247 Status
= PeiServicesCreateHob (Type
, Length
, &Hob
);
248 if (EFI_ERROR (Status
)) {
252 // Assume the process of HOB building is always successful.
254 ASSERT (Hob
!= NULL
);
259 Builds a HOB for a loaded PE32 module.
261 This function builds a HOB for a loaded PE32 module.
262 It can only be invoked during PEI phase;
263 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
265 If ModuleName is NULL, then ASSERT().
266 If there is no additional space for HOB creation, then ASSERT().
268 @param ModuleName The GUID File Name of the module.
269 @param MemoryAllocationModule The 64 bit physical address of the module.
270 @param ModuleLength The length of the module in bytes.
271 @param EntryPoint The 64 bit physical address of the module entry point.
277 IN CONST EFI_GUID
*ModuleName
,
278 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
279 IN UINT64 ModuleLength
,
280 IN EFI_PHYSICAL_ADDRESS EntryPoint
283 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
285 ASSERT (((MemoryAllocationModule
& (EFI_PAGE_SIZE
- 1)) == 0) &&
286 ((ModuleLength
& (EFI_PAGE_SIZE
- 1)) == 0));
288 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
) sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
));
293 CopyGuid (&(Hob
->MemoryAllocationHeader
.Name
), &gEfiHobMemoryAllocModuleGuid
);
294 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
295 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
296 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
299 // Zero the reserved space to match HOB spec
301 ZeroMem (Hob
->MemoryAllocationHeader
.Reserved
, sizeof (Hob
->MemoryAllocationHeader
.Reserved
));
303 CopyGuid (&Hob
->ModuleName
, ModuleName
);
304 Hob
->EntryPoint
= EntryPoint
;
308 Builds a HOB that describes a chunk of system memory with Owner GUID.
310 This function builds a HOB that describes a chunk of system memory.
311 It can only be invoked during PEI phase;
312 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
314 If there is no additional space for HOB creation, then ASSERT().
316 @param ResourceType The type of resource described by this HOB.
317 @param ResourceAttribute The resource attributes of the memory described by this HOB.
318 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
319 @param NumberOfBytes The length of the memory described by this HOB in bytes.
320 @param OwnerGUID GUID for the owner of this resource.
325 BuildResourceDescriptorWithOwnerHob (
326 IN EFI_RESOURCE_TYPE ResourceType
,
327 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
328 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
329 IN UINT64 NumberOfBytes
,
330 IN EFI_GUID
*OwnerGUID
333 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
335 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, (UINT16
) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
340 Hob
->ResourceType
= ResourceType
;
341 Hob
->ResourceAttribute
= ResourceAttribute
;
342 Hob
->PhysicalStart
= PhysicalStart
;
343 Hob
->ResourceLength
= NumberOfBytes
;
345 CopyGuid (&Hob
->Owner
, OwnerGUID
);
349 Builds a HOB that describes a chunk of system memory.
351 This function builds a HOB that describes a chunk of system memory.
352 It can only be invoked during PEI phase;
353 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 ResourceType The type of resource described by this HOB.
358 @param ResourceAttribute The resource attributes of the memory described by this HOB.
359 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
360 @param NumberOfBytes The length of the memory described by this HOB in bytes.
365 BuildResourceDescriptorHob (
366 IN EFI_RESOURCE_TYPE ResourceType
,
367 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
368 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
369 IN UINT64 NumberOfBytes
372 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
374 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, (UINT16
) sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
379 Hob
->ResourceType
= ResourceType
;
380 Hob
->ResourceAttribute
= ResourceAttribute
;
381 Hob
->PhysicalStart
= PhysicalStart
;
382 Hob
->ResourceLength
= NumberOfBytes
;
383 ZeroMem (&(Hob
->Owner
), sizeof (EFI_GUID
));
387 Builds a customized HOB tagged with a GUID for identification and returns
388 the start address of GUID HOB data.
390 This function builds a customized HOB tagged with a GUID for identification
391 and returns the start address of GUID HOB data so that caller can fill the customized data.
392 The HOB Header and Name field is already stripped.
393 It can only be invoked during PEI phase;
394 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
396 If Guid is NULL, then ASSERT().
397 If there is no additional space for HOB creation, then ASSERT().
398 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
400 @param Guid The GUID to tag the customized HOB.
401 @param DataLength The size of the data payload for the GUID HOB.
403 @retval NULL The GUID HOB could not be allocated.
404 @retval others The start address of GUID HOB data.
410 IN CONST EFI_GUID
*Guid
,
414 EFI_HOB_GUID_TYPE
*Hob
;
417 // Make sure Guid is valid
419 ASSERT (Guid
!= NULL
);
422 // Make sure that data length is not too long.
424 ASSERT (DataLength
<= (0xffff - sizeof (EFI_HOB_GUID_TYPE
)));
426 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION
, (UINT16
) (sizeof (EFI_HOB_GUID_TYPE
) + DataLength
));
430 CopyGuid (&Hob
->Name
, Guid
);
435 Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
436 data field, and returns the start address of the GUID HOB data.
438 This function builds a customized HOB tagged with a GUID for identification and copies the input
439 data to the HOB data field and returns the start address of the GUID HOB data. It can only be
440 invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
441 The HOB Header and Name field is already stripped.
442 It can only be invoked during PEI phase;
443 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
445 If Guid is NULL, then ASSERT().
446 If Data is NULL and DataLength > 0, then ASSERT().
447 If there is no additional space for HOB creation, then ASSERT().
448 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
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) {
516 if ((UINTN
)BaseAddress
% FvAlignment
!= 0) {
518 // FvImage buffer is not at its required alignment.
522 "Unaligned FvImage found at 0x%lx:0x%lx, the required alignment is 0x%x\n",
535 Builds a Firmware Volume HOB.
537 This function builds a Firmware Volume HOB.
538 It can only be invoked during PEI phase;
539 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
541 If there is no additional space for HOB creation, then ASSERT().
542 If the FvImage buffer is not at its required alignment, then ASSERT().
544 @param BaseAddress The base address of the Firmware Volume.
545 @param Length The size of the Firmware Volume in bytes.
551 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
555 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
557 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
562 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV
, (UINT16
) sizeof (EFI_HOB_FIRMWARE_VOLUME
));
567 Hob
->BaseAddress
= BaseAddress
;
568 Hob
->Length
= Length
;
572 Builds a EFI_HOB_TYPE_FV2 HOB.
574 This function builds a EFI_HOB_TYPE_FV2 HOB.
575 It can only be invoked during PEI phase;
576 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
578 If there is no additional space for HOB creation, then ASSERT().
579 If the FvImage buffer is not at its required alignment, then ASSERT().
581 @param BaseAddress The base address of the Firmware Volume.
582 @param Length The size of the Firmware Volume in bytes.
583 @param FvName The name of the Firmware Volume.
584 @param FileName The name of the file.
590 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
592 IN CONST EFI_GUID
*FvName
,
593 IN CONST EFI_GUID
*FileName
596 EFI_HOB_FIRMWARE_VOLUME2
*Hob
;
598 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
603 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV2
, (UINT16
) sizeof (EFI_HOB_FIRMWARE_VOLUME2
));
608 Hob
->BaseAddress
= BaseAddress
;
609 Hob
->Length
= Length
;
610 CopyGuid (&Hob
->FvName
, FvName
);
611 CopyGuid (&Hob
->FileName
, FileName
);
615 Builds a EFI_HOB_TYPE_FV3 HOB.
617 This function builds a EFI_HOB_TYPE_FV3 HOB.
618 It can only be invoked during PEI phase;
619 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
621 If there is no additional space for HOB creation, then ASSERT().
622 If the FvImage buffer is not at its required alignment, then ASSERT().
624 @param BaseAddress The base address of the Firmware Volume.
625 @param Length The size of the Firmware Volume in bytes.
626 @param AuthenticationStatus The authentication status.
627 @param ExtractedFv TRUE if the FV was extracted as a file within
628 another firmware volume. FALSE otherwise.
629 @param FvName The name of the Firmware Volume.
630 Valid only if IsExtractedFv is TRUE.
631 @param FileName The name of the file.
632 Valid only if IsExtractedFv is TRUE.
638 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
640 IN UINT32 AuthenticationStatus
,
641 IN BOOLEAN ExtractedFv
,
642 IN CONST EFI_GUID
*FvName
, OPTIONAL
643 IN CONST EFI_GUID
*FileName OPTIONAL
646 EFI_HOB_FIRMWARE_VOLUME3
*Hob
;
648 if (!InternalCheckFvAlignment (BaseAddress
, Length
)) {
653 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_FV3
, (UINT16
) sizeof (EFI_HOB_FIRMWARE_VOLUME3
));
658 Hob
->BaseAddress
= BaseAddress
;
659 Hob
->Length
= Length
;
660 Hob
->AuthenticationStatus
= AuthenticationStatus
;
661 Hob
->ExtractedFv
= ExtractedFv
;
663 CopyGuid (&Hob
->FvName
, FvName
);
664 CopyGuid (&Hob
->FileName
, FileName
);
669 Builds a Capsule Volume HOB.
671 This function builds a Capsule Volume HOB.
672 It can only be invoked during PEI phase;
673 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
675 If the platform does not support Capsule Volume HOBs, then ASSERT().
676 If there is no additional space for HOB creation, then ASSERT().
678 @param BaseAddress The base address of the Capsule Volume.
679 @param Length The size of the Capsule Volume in bytes.
685 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
689 EFI_HOB_CAPSULE_VOLUME
*Hob
;
691 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_CV
, (UINT16
) sizeof (EFI_HOB_CAPSULE_VOLUME
));
696 Hob
->BaseAddress
= BaseAddress
;
697 Hob
->Length
= Length
;
701 Builds a HOB for the CPU.
703 This function builds a HOB for the CPU.
704 It can only be invoked during PEI phase;
705 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
707 If there is no additional space for HOB creation, then ASSERT().
709 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
710 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
716 IN UINT8 SizeOfMemorySpace
,
717 IN UINT8 SizeOfIoSpace
722 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_CPU
, (UINT16
) sizeof (EFI_HOB_CPU
));
727 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
728 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
731 // Zero the reserved space to match HOB spec
733 ZeroMem (Hob
->Reserved
, sizeof (Hob
->Reserved
));
737 Builds a HOB for the Stack.
739 This function builds a HOB for the stack.
740 It can only be invoked during PEI phase;
741 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
743 If there is no additional space for HOB creation, then ASSERT().
745 @param BaseAddress The 64 bit physical address of the Stack.
746 @param Length The length of the stack in bytes.
752 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
756 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
758 ASSERT (((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
759 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0));
761 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
) sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
));
766 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocStackGuid
);
767 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
768 Hob
->AllocDescriptor
.MemoryLength
= Length
;
769 Hob
->AllocDescriptor
.MemoryType
= EfiBootServicesData
;
772 // Zero the reserved space to match HOB spec
774 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));
778 Builds a HOB for the BSP store.
780 This function builds a HOB for BSP store.
781 It can only be invoked during PEI phase;
782 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
784 If there is no additional space for HOB creation, then ASSERT().
786 @param BaseAddress The 64 bit physical address of the BSP.
787 @param Length The length of the BSP store in bytes.
788 @param MemoryType Type of memory allocated by this HOB.
794 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
796 IN EFI_MEMORY_TYPE MemoryType
799 EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
*Hob
;
801 ASSERT (((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
802 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0));
804 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
) sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE
));
809 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocBspStoreGuid
);
810 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
811 Hob
->AllocDescriptor
.MemoryLength
= Length
;
812 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
815 // Zero the reserved space to match HOB spec
817 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));
821 Builds a HOB for the memory allocation.
823 This function builds a HOB for the memory allocation.
824 It can only be invoked during PEI phase;
825 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
827 If there is no additional space for HOB creation, then ASSERT().
829 @param BaseAddress The 64 bit physical address of the memory.
830 @param Length The length of the memory allocation in bytes.
831 @param MemoryType Type of memory allocated by this HOB.
836 BuildMemoryAllocationHob (
837 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
839 IN EFI_MEMORY_TYPE MemoryType
842 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
844 ASSERT (((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
845 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0));
847 Hob
= InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, (UINT16
) sizeof (EFI_HOB_MEMORY_ALLOCATION
));
852 ZeroMem (&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
));
853 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
854 Hob
->AllocDescriptor
.MemoryLength
= Length
;
855 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
857 // Zero the reserved space to match HOB spec
859 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));