3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
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.
16 #include <Guid/MemoryTypeInformation.h>
19 // Have to use build system to set the original value in case we are running
20 // from FLASH and globals don't work. So if you do a GetHobList() and gHobList
21 // and gHobList is NULL the PCD default values are used.
23 VOID
*gHobList
= NULL
;
28 // May want to put this into a library so you only need the PCD setings if you are using the feature?
30 BuildMemoryTypeInformationHob (
34 EFI_MEMORY_TYPE_INFORMATION Info
[10];
36 Info
[0].Type
= EfiACPIReclaimMemory
;
37 Info
[0].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiACPIReclaimMemory
);
38 Info
[1].Type
= EfiACPIMemoryNVS
;
39 Info
[1].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiACPIMemoryNVS
);
40 Info
[2].Type
= EfiReservedMemoryType
;
41 Info
[2].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiReservedMemoryType
);
42 Info
[3].Type
= EfiRuntimeServicesData
;
43 Info
[3].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiRuntimeServicesData
);
44 Info
[4].Type
= EfiRuntimeServicesCode
;
45 Info
[4].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiRuntimeServicesCode
);
46 Info
[5].Type
= EfiBootServicesCode
;
47 Info
[5].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiBootServicesCode
);
48 Info
[6].Type
= EfiBootServicesData
;
49 Info
[6].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiBootServicesData
);
50 Info
[7].Type
= EfiLoaderCode
;
51 Info
[7].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiLoaderCode
);
52 Info
[8].Type
= EfiLoaderData
;
53 Info
[8].NumberOfPages
= PcdGet32 (PcdMemoryTypeEfiLoaderData
);
55 // Terminator for the list
56 Info
[9].Type
= EfiMaxMemoryType
;
57 Info
[9].NumberOfPages
= 0;
60 BuildGuidDataHob (&gEfiMemoryTypeInformationGuid
, &Info
, sizeof (Info
));
70 IN UINTN MemoryLength
,
75 EFI_HOB_HANDOFF_INFO_TABLE
*Hob
;
76 EFI_HOB_GENERIC_HEADER
*HobEnd
;
77 EFI_RESOURCE_ATTRIBUTE_TYPE Attributes
;
81 HobEnd
= (EFI_HOB_GENERIC_HEADER
*)(Hob
+1);
83 Hob
->Header
.HobType
= EFI_HOB_TYPE_HANDOFF
;
84 Hob
->Header
.HobLength
= sizeof(EFI_HOB_HANDOFF_INFO_TABLE
);
85 Hob
->Header
.Reserved
= 0;
87 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
88 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
91 Hob
->Version
= EFI_HOB_HANDOFF_TABLE_VERSION
;
92 Hob
->BootMode
= BOOT_WITH_FULL_CONFIGURATION
;
94 Hob
->EfiMemoryTop
= (UINTN
)MemoryBegin
+ MemoryLength
;
95 Hob
->EfiMemoryBottom
= (UINTN
)MemoryBegin
;
96 Hob
->EfiFreeMemoryTop
= (UINTN
)StackBase
;
97 Hob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)(HobEnd
+1);
98 Hob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)HobEnd
;
102 BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize
), PcdGet8 (PcdPrePiCpuIoSize
));
105 EFI_RESOURCE_ATTRIBUTE_PRESENT
|
106 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
107 EFI_RESOURCE_ATTRIBUTE_TESTED
|
108 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE
|
109 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE
|
110 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE
|
111 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
114 BuildResourceDescriptorHob (EFI_RESOURCE_SYSTEM_MEMORY
, Attributes
, (UINTN
)MemoryBegin
, MemoryLength
);
117 BuildStackHob ((UINTN
)StackBase
, Hob
->EfiMemoryTop
- (UINTN
)StackBase
);
119 if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob
)) {
120 // Optional feature that helps prevent EFI memory map fragmentation.
121 BuildMemoryTypeInformationHob ();
130 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
131 IN UINT64 NumberOfBytes
,
132 IN EFI_RESOURCE_ATTRIBUTE_TYPE
*ResourceAttribute
136 EFI_RESOURCE_ATTRIBUTE_TYPE Resource
;
138 BuildFvHob (PhysicalStart
, NumberOfBytes
);
140 if (ResourceAttribute
== NULL
) {
141 Resource
= (EFI_RESOURCE_ATTRIBUTE_PRESENT
|
142 EFI_RESOURCE_ATTRIBUTE_INITIALIZED
|
143 EFI_RESOURCE_ATTRIBUTE_TESTED
|
144 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
);
146 Resource
= *ResourceAttribute
;
149 BuildResourceDescriptorHob (EFI_RESOURCE_FIRMWARE_DEVICE
, Resource
, PhysicalStart
, NumberOfBytes
);
157 Returns the pointer to the HOB list.
159 This function returns the pointer to first HOB in the list.
161 @return The pointer to the HOB list.
170 if (gHobList
== NULL
) {
171 return (VOID
*)(UINTN
)PcdGet32 (PcdPrePiHobBase
);
180 Updates the pointer to the HOB list.
182 @param HobList Hob list pointer to store
194 // If this code is running from ROM this could fail
196 return (gHobList
== HobList
) ? EFI_SUCCESS
: EFI_UNSUPPORTED
;
207 EFI_HOB_HANDOFF_INFO_TABLE
*HandOffHob
;
208 EFI_HOB_GENERIC_HEADER
*HobEnd
;
209 EFI_PHYSICAL_ADDRESS FreeMemory
;
212 HandOffHob
= GetHobList ();
214 HobLength
= (UINT16
)((HobLength
+ 0x7) & (~0x7));
216 FreeMemory
= HandOffHob
->EfiFreeMemoryTop
- HandOffHob
->EfiFreeMemoryBottom
;
218 if (FreeMemory
< HobLength
) {
222 Hob
= (VOID
*) (UINTN
) HandOffHob
->EfiEndOfHobList
;
223 ((EFI_HOB_GENERIC_HEADER
*) Hob
)->HobType
= HobType
;
224 ((EFI_HOB_GENERIC_HEADER
*) Hob
)->HobLength
= HobLength
;
225 ((EFI_HOB_GENERIC_HEADER
*) Hob
)->Reserved
= 0;
227 HobEnd
= (EFI_HOB_GENERIC_HEADER
*) ((UINTN
)Hob
+ HobLength
);
228 HandOffHob
->EfiEndOfHobList
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
230 HobEnd
->HobType
= EFI_HOB_TYPE_END_OF_HOB_LIST
;
231 HobEnd
->HobLength
= sizeof(EFI_HOB_GENERIC_HEADER
);
232 HobEnd
->Reserved
= 0;
234 HandOffHob
->EfiFreeMemoryBottom
= (EFI_PHYSICAL_ADDRESS
) (UINTN
) HobEnd
;
241 Returns the next instance of a HOB type from the starting HOB.
243 This function searches the first instance of a HOB type from the starting HOB pointer.
244 If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
245 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
246 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
247 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
248 If HobStart is NULL, then ASSERT().
250 @param Type The HOB type to return.
251 @param HobStart The starting HOB pointer to search from.
253 @return The next instance of a HOB type from the starting HOB.
260 IN CONST VOID
*HobStart
263 EFI_PEI_HOB_POINTERS Hob
;
265 ASSERT (HobStart
!= NULL
);
267 Hob
.Raw
= (UINT8
*) HobStart
;
269 // Parse the HOB list until end of list or matching type is found.
271 while (!END_OF_HOB_LIST (Hob
)) {
272 if (Hob
.Header
->HobType
== Type
) {
275 Hob
.Raw
= GET_NEXT_HOB (Hob
);
283 Returns the first instance of a HOB type among the whole HOB list.
285 This function searches the first instance of a HOB type among the whole HOB list.
286 If there does not exist such HOB type in the HOB list, it will return NULL.
288 @param Type The HOB type to return.
290 @return The next instance of a HOB type from the starting HOB.
301 HobList
= GetHobList ();
302 return GetNextHob (Type
, HobList
);
307 This function searches the first instance of a HOB from the starting HOB pointer.
308 Such HOB should satisfy two conditions:
309 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
310 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
311 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
312 to extract the data section and its size info respectively.
313 In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
314 unconditionally: it returns HobStart back if HobStart itself meets the requirement;
315 caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
316 If Guid is NULL, then ASSERT().
317 If HobStart is NULL, then ASSERT().
319 @param Guid The GUID to match with in the HOB list.
320 @param HobStart A pointer to a Guid.
322 @return The next instance of the matched GUID HOB from the starting HOB.
328 IN CONST EFI_GUID
*Guid
,
329 IN CONST VOID
*HobStart
331 EFI_PEI_HOB_POINTERS GuidHob
;
333 GuidHob
.Raw
= (UINT8
*) HobStart
;
334 while ((GuidHob
.Raw
= GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION
, GuidHob
.Raw
)) != NULL
) {
335 if (CompareGuid (Guid
, &GuidHob
.Guid
->Name
)) {
338 GuidHob
.Raw
= GET_NEXT_HOB (GuidHob
);
345 This function searches the first instance of a HOB among the whole HOB list.
346 Such HOB should satisfy two conditions:
347 its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
348 If there does not exist such HOB from the starting HOB pointer, it will return NULL.
349 Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
350 to extract the data section and its size info respectively.
351 If Guid is NULL, then ASSERT().
353 @param Guid The GUID to match with in the HOB list.
355 @return The first instance of the matched GUID HOB among the whole HOB list.
361 IN CONST EFI_GUID
*Guid
366 HobList
= GetHobList ();
367 return GetNextGuidHob (Guid
, HobList
);
372 Get the Boot Mode from the HOB list.
374 This function returns the system boot mode information from the
375 PHIT HOB in HOB list.
379 @return The Boot Mode.
388 EFI_PEI_HOB_POINTERS Hob
;
390 Hob
.Raw
= GetHobList ();
391 return Hob
.HandoffInformationTable
->BootMode
;
396 Get the Boot Mode from the HOB list.
398 This function returns the system boot mode information from the
399 PHIT HOB in HOB list.
403 @return The Boot Mode.
409 IN EFI_BOOT_MODE BootMode
412 EFI_PEI_HOB_POINTERS Hob
;
414 Hob
.Raw
= GetHobList ();
415 Hob
.HandoffInformationTable
->BootMode
= BootMode
;
420 Builds a HOB for a loaded PE32 module.
422 This function builds a HOB for a loaded PE32 module.
423 It can only be invoked during PEI phase;
424 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
425 If ModuleName is NULL, then ASSERT().
426 If there is no additional space for HOB creation, then ASSERT().
428 @param ModuleName The GUID File Name of the module.
429 @param MemoryAllocationModule The 64 bit physical address of the module.
430 @param ModuleLength The length of the module in bytes.
431 @param EntryPoint The 64 bit physical address of the module entry point.
437 IN CONST EFI_GUID
*ModuleName
,
438 IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule
,
439 IN UINT64 ModuleLength
,
440 IN EFI_PHYSICAL_ADDRESS EntryPoint
443 EFI_HOB_MEMORY_ALLOCATION_MODULE
*Hob
;
445 ASSERT (((MemoryAllocationModule
& (EFI_PAGE_SIZE
- 1)) == 0) &&
446 ((ModuleLength
& (EFI_PAGE_SIZE
- 1)) == 0));
448 Hob
= CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE
));
450 CopyGuid (&(Hob
->MemoryAllocationHeader
.Name
), &gEfiHobMemoryAllocModuleGuid
);
451 Hob
->MemoryAllocationHeader
.MemoryBaseAddress
= MemoryAllocationModule
;
452 Hob
->MemoryAllocationHeader
.MemoryLength
= ModuleLength
;
453 Hob
->MemoryAllocationHeader
.MemoryType
= EfiBootServicesCode
;
456 // Zero the reserved space to match HOB spec
458 ZeroMem (Hob
->MemoryAllocationHeader
.Reserved
, sizeof (Hob
->MemoryAllocationHeader
.Reserved
));
460 CopyGuid (&Hob
->ModuleName
, ModuleName
);
461 Hob
->EntryPoint
= EntryPoint
;
466 Builds a HOB that describes a chunk of system memory.
468 This function builds a HOB that describes a chunk of system memory.
469 If there is no additional space for HOB creation, then ASSERT().
471 @param ResourceType The type of resource described by this HOB.
472 @param ResourceAttribute The resource attributes of the memory described by this HOB.
473 @param PhysicalStart The 64 bit physical address of memory described by this HOB.
474 @param NumberOfBytes The length of the memory described by this HOB in bytes.
479 BuildResourceDescriptorHob (
480 IN EFI_RESOURCE_TYPE ResourceType
,
481 IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
,
482 IN EFI_PHYSICAL_ADDRESS PhysicalStart
,
483 IN UINT64 NumberOfBytes
486 EFI_HOB_RESOURCE_DESCRIPTOR
*Hob
;
488 Hob
= CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR
));
490 Hob
->ResourceType
= ResourceType
;
491 Hob
->ResourceAttribute
= ResourceAttribute
;
492 Hob
->PhysicalStart
= PhysicalStart
;
493 Hob
->ResourceLength
= NumberOfBytes
;
498 Builds a GUID HOB with a certain data length.
500 This function builds a customized HOB tagged with a GUID for identification
501 and returns the start address of GUID HOB data so that caller can fill the customized data.
502 The HOB Header and Name field is already stripped.
503 It can only be invoked during PEI phase;
504 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
505 If Guid is NULL, then ASSERT().
506 If there is no additional space for HOB creation, then ASSERT().
507 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
509 @param Guid The GUID to tag the customized HOB.
510 @param DataLength The size of the data payload for the GUID HOB.
512 @return The start address of GUID HOB data.
518 IN CONST EFI_GUID
*Guid
,
522 EFI_HOB_GUID_TYPE
*Hob
;
525 // Make sure that data length is not too long.
527 ASSERT (DataLength
<= (0xffff - sizeof (EFI_HOB_GUID_TYPE
)));
529 Hob
= CreateHob (EFI_HOB_TYPE_GUID_EXTENSION
, (UINT16
) (sizeof (EFI_HOB_GUID_TYPE
) + DataLength
));
530 CopyGuid (&Hob
->Name
, Guid
);
536 Copies a data buffer to a newly-built HOB.
538 This function builds a customized HOB tagged with a GUID for identification,
539 copies the input data to the HOB data field and returns the start address of the GUID HOB data.
540 The HOB Header and Name field is already stripped.
541 It can only be invoked during PEI phase;
542 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
543 If Guid is NULL, then ASSERT().
544 If Data is NULL and DataLength > 0, then ASSERT().
545 If there is no additional space for HOB creation, then ASSERT().
546 If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
548 @param Guid The GUID to tag the customized HOB.
549 @param Data The data to be copied into the data field of the GUID HOB.
550 @param DataLength The size of the data payload for the GUID HOB.
552 @return The start address of GUID HOB data.
558 IN CONST EFI_GUID
*Guid
,
565 ASSERT (Data
!= NULL
|| DataLength
== 0);
567 HobData
= BuildGuidHob (Guid
, DataLength
);
569 return CopyMem (HobData
, Data
, DataLength
);
574 Builds a Firmware Volume HOB.
576 This function builds a Firmware Volume HOB.
577 It can only be invoked during PEI phase;
578 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().
581 @param BaseAddress The base address of the Firmware Volume.
582 @param Length The size of the Firmware Volume in bytes.
588 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
592 EFI_HOB_FIRMWARE_VOLUME
*Hob
;
594 Hob
= CreateHob (EFI_HOB_TYPE_FV
, sizeof (EFI_HOB_FIRMWARE_VOLUME
));
596 Hob
->BaseAddress
= BaseAddress
;
597 Hob
->Length
= Length
;
602 Builds a EFI_HOB_TYPE_FV2 HOB.
604 This function builds a EFI_HOB_TYPE_FV2 HOB.
605 It can only be invoked during PEI phase;
606 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
607 If there is no additional space for HOB creation, then ASSERT().
609 @param BaseAddress The base address of the Firmware Volume.
610 @param Length The size of the Firmware Volume in bytes.
611 @param FvName The name of the Firmware Volume.
612 @param FileName The name of the file.
618 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
620 IN CONST EFI_GUID
*FvName
,
621 IN CONST EFI_GUID
*FileName
624 EFI_HOB_FIRMWARE_VOLUME2
*Hob
;
626 Hob
= CreateHob (EFI_HOB_TYPE_FV2
, sizeof (EFI_HOB_FIRMWARE_VOLUME2
));
628 Hob
->BaseAddress
= BaseAddress
;
629 Hob
->Length
= Length
;
630 CopyGuid (&Hob
->FvName
, FvName
);
631 CopyGuid (&Hob
->FileName
, FileName
);
637 Builds a Capsule Volume HOB.
639 This function builds a Capsule Volume HOB.
640 It can only be invoked during PEI phase;
641 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
642 If there is no additional space for HOB creation, then ASSERT().
644 @param BaseAddress The base address of the Capsule Volume.
645 @param Length The size of the Capsule Volume in bytes.
651 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
660 Builds a HOB for the CPU.
662 This function builds a HOB for the CPU.
663 It can only be invoked during PEI phase;
664 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
665 If there is no additional space for HOB creation, then ASSERT().
667 @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
668 @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
674 IN UINT8 SizeOfMemorySpace
,
675 IN UINT8 SizeOfIoSpace
680 Hob
= CreateHob (EFI_HOB_TYPE_CPU
, sizeof (EFI_HOB_CPU
));
682 Hob
->SizeOfMemorySpace
= SizeOfMemorySpace
;
683 Hob
->SizeOfIoSpace
= SizeOfIoSpace
;
686 // Zero the reserved space to match HOB spec
688 ZeroMem (Hob
->Reserved
, sizeof (Hob
->Reserved
));
693 Builds a HOB for the Stack.
695 This function builds a HOB for the stack.
696 It can only be invoked during PEI phase;
697 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
698 If there is no additional space for HOB creation, then ASSERT().
700 @param BaseAddress The 64 bit physical address of the Stack.
701 @param Length The length of the stack in bytes.
707 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
711 EFI_HOB_MEMORY_ALLOCATION_STACK
*Hob
;
713 ASSERT (((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
714 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0));
716 Hob
= CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK
));
718 CopyGuid (&(Hob
->AllocDescriptor
.Name
), &gEfiHobMemoryAllocStackGuid
);
719 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
720 Hob
->AllocDescriptor
.MemoryLength
= Length
;
721 Hob
->AllocDescriptor
.MemoryType
= EfiBootServicesData
;
724 // Zero the reserved space to match HOB spec
726 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));
731 Update the Stack Hob if the stack has been moved
733 @param BaseAddress The 64 bit physical address of the Stack.
734 @param Length The length of the stack in bytes.
739 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
743 EFI_PEI_HOB_POINTERS Hob
;
745 Hob
.Raw
= GetHobList ();
746 while ((Hob
.Raw
= GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, Hob
.Raw
)) != NULL
) {
747 if (CompareGuid (&gEfiHobMemoryAllocStackGuid
, &(Hob
.MemoryAllocationStack
->AllocDescriptor
.Name
))) {
749 // Build a new memory allocation HOB with old stack info with EfiConventionalMemory type
750 // to be reclaimed by DXE core.
752 BuildMemoryAllocationHob (
753 Hob
.MemoryAllocationStack
->AllocDescriptor
.MemoryBaseAddress
,
754 Hob
.MemoryAllocationStack
->AllocDescriptor
.MemoryLength
,
755 EfiConventionalMemory
758 // Update the BSP Stack Hob to reflect the new stack info.
760 Hob
.MemoryAllocationStack
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
761 Hob
.MemoryAllocationStack
->AllocDescriptor
.MemoryLength
= Length
;
764 Hob
.Raw
= GET_NEXT_HOB (Hob
);
771 Builds a HOB for the memory allocation.
773 This function builds a HOB for the memory allocation.
774 It can only be invoked during PEI phase;
775 for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
776 If there is no additional space for HOB creation, then ASSERT().
778 @param BaseAddress The 64 bit physical address of the memory.
779 @param Length The length of the memory allocation in bytes.
780 @param MemoryType Type of memory allocated by this HOB.
785 BuildMemoryAllocationHob (
786 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
788 IN EFI_MEMORY_TYPE MemoryType
791 EFI_HOB_MEMORY_ALLOCATION
*Hob
;
793 ASSERT (((BaseAddress
& (EFI_PAGE_SIZE
- 1)) == 0) &&
794 ((Length
& (EFI_PAGE_SIZE
- 1)) == 0));
796 Hob
= CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION
, sizeof (EFI_HOB_MEMORY_ALLOCATION
));
798 ZeroMem (&(Hob
->AllocDescriptor
.Name
), sizeof (EFI_GUID
));
799 Hob
->AllocDescriptor
.MemoryBaseAddress
= BaseAddress
;
800 Hob
->AllocDescriptor
.MemoryLength
= Length
;
801 Hob
->AllocDescriptor
.MemoryType
= MemoryType
;
803 // Zero the reserved space to match HOB spec
805 ZeroMem (Hob
->AllocDescriptor
.Reserved
, sizeof (Hob
->AllocDescriptor
.Reserved
));