29#define PEI_ADDITIONAL_MEMORY_SIZE (16 * EFI_PAGE_SIZE)
52 while (!END_OF_HOB_LIST (Hob)) {
53 if ((Hob.Header->
HobType == EFI_HOB_TYPE_GUID_EXTENSION) &&
60 Hob.Raw = GET_NEXT_HOB (Hob);
63 if (MemoryData ==
NULL) {
68 for (Index = 0; MemoryData[Index].
Type != EfiMaxMemoryType; Index++) {
75 return TempPageNum * EFI_PAGE_SIZE;
93 return Size + PEI_ADDITIONAL_MEMORY_SIZE;
113 if (BootMode == BOOT_IN_RECOVERY_MODE) {
114 return PcdGet32 (PcdPeiRecoveryMinMemSize);
119 if (BootMode == BOOT_ON_FLASH_UPDATE) {
123 MinSize =
PcdGet32 (PcdPeiMinMemSize);
125 MinSize =
PcdGet32 (PcdPeiMinMemSize);
128 return MinSize + Size + PEI_ADDITIONAL_MEMORY_SIZE;
145 UINT64 LowMemorySize;
146 UINT64 FspMemorySize;
152 BOOLEAN FoundFspMemHob;
157 UINTN CapsuleBufferLength;
158 UINT64 RequiredMemSize;
169 FoundFspMemHob =
FALSE;
175 Hob.Raw = (UINT8 *)(
UINTN)FspHobList;
176 DEBUG ((DEBUG_INFO,
"FspHobList - 0x%x\n", FspHobList));
178 while ((Hob.Raw =
GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, Hob.Raw)) !=
NULL) {
179 DEBUG ((DEBUG_INFO,
"\nResourceType: 0x%x\n", Hob.ResourceDescriptor->
ResourceType));
180 if ((Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) ||
181 (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_MEMORY_RESERVED))
186 DEBUG ((DEBUG_INFO,
"Owner: %g\n\n", &Hob.ResourceDescriptor->
Owner));
189 if ( (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)
194 Hob.Raw = GET_NEXT_HOB (Hob);
198 if ( (Hob.ResourceDescriptor->
ResourceType == EFI_RESOURCE_MEMORY_RESERVED)
201 && (
CompareGuid (&Hob.ResourceDescriptor->
Owner, &gFspReservedMemoryResourceHobGuid)))
203 FoundFspMemHob =
TRUE;
206 DEBUG ((DEBUG_INFO,
"Find fsp mem hob, base 0x%x, len 0x%x\n", FspMemoryBase, FspMemorySize));
219 Hob.Raw = GET_NEXT_HOB (Hob);
222 if (!FoundFspMemHob) {
223 DEBUG ((DEBUG_INFO,
"Didn't find the fsp used memory information.\n"));
227 DEBUG ((DEBUG_INFO,
"LowMemorySize: 0x%x.\n", LowMemorySize));
228 DEBUG ((DEBUG_INFO,
"FspMemoryBase: 0x%x.\n", FspMemoryBase));
229 DEBUG ((DEBUG_INFO,
"FspMemorySize: 0x%x.\n", FspMemorySize));
231 if (BootMode == BOOT_ON_S3_RESUME) {
233 EFI_RESOURCE_SYSTEM_MEMORY,
235 EFI_RESOURCE_ATTRIBUTE_PRESENT |
236 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
238 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
239 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
240 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
241 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
251 DEBUG ((DEBUG_INFO,
"S3 memory %Xh - %Xh bytes\n", S3PeiMemBase, S3PeiMemSize));
264 DEBUG ((DEBUG_INFO,
"PEI memory size = %Xh bytes\n", PeiMemSize));
270 CapsuleBuffer =
NULL;
271 CapsuleBufferLength = 0;
272 if (BootMode == BOOT_ON_FLASH_UPDATE) {
274 &gEfiPeiCapsulePpiGuid,
285 CapsuleBuffer = (VOID *)(
UINTN)BASE_1MB;
286 CapsuleBufferLength = (
UINTN)(LowMemorySize - PeiMemSize);
290 Status = Capsule->Coalesce (PeiServices, &CapsuleBuffer, &CapsuleBufferLength);
295 DEBUG ((DEBUG_INFO,
"Required memory size = %Xh bytes\n", RequiredMemSize));
301 EFI_RESOURCE_SYSTEM_MEMORY,
303 EFI_RESOURCE_ATTRIBUTE_PRESENT |
304 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
305 EFI_RESOURCE_ATTRIBUTE_TESTED |
306 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
307 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
308 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
309 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
322 PeiMemBase = BASE_1MB + LowMemorySize - PeiMemSize;
325 PeiMemSize - RequiredMemSize
329 if (Capsule !=
NULL) {
330 Status = Capsule->CreateState (PeiServices, CapsuleBuffer, CapsuleBufferLength);
350 FspHob.Raw = FspHobList;
355 while (!END_OF_HOB_LIST (FspHob)) {
356 if (FspHob.Header->
HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
363 GET_GUID_HOB_DATA (FspHob),
364 GET_GUID_HOB_DATA_SIZE (FspHob)
369 FspHob.Raw = GET_NEXT_HOB (FspHob);
392 if (
PcdGet8 (PcdFspModeSelection) == 1) {
397 ASSERT (FspHobList !=
NULL);
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI BuildGuidDataHob(IN CONST EFI_GUID *Guid, IN VOID *Data, IN UINTN DataLength)
VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
VOID *EFIAPI GetNextHob(IN UINT16 Type, IN CONST VOID *HobStart)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPeiMemory(IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength)
UINT64 GetMemorySizeInMemoryTypeInformation(IN EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI PostFspsHobProcess(IN VOID *FspHobList)
EFI_STATUS EFIAPI PostFspmHobProcess(IN VOID *FspHobList)
VOID ProcessFspHobList(IN VOID *FspHobList)
UINT64 GetPeiMemSize(IN EFI_PEI_SERVICES **PeiServices, IN UINT32 BootMode)
UINT64 RetrieveRequiredMemorySize(IN EFI_PEI_SERVICES **PeiServices)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_PHYSICAL_ADDRESS PhysicalStart
EFI_RESOURCE_TYPE ResourceType
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute
UINT32 NumberOfPages
The pages of this type memory.
UINT32 Type
EFI memory type defined in UEFI specification.