{\r
UINT8 *Buffer;\r
UINTN BufferSize;\r
- VOID *FfsBuffer;\r
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
BOOT_SCRIPT_THUNK_DATA *BootScriptThunkData;\r
EFI_STATUS Status;\r
VOID *DevicePath;\r
+ EFI_PHYSICAL_ADDRESS MemoryAddress;\r
+ UINTN PageNumber;\r
\r
//\r
// Test if the gEfiCallerIdGuid of this image is already installed. if not, the entry\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
- Status = gBS->AllocatePool (\r
- EfiACPIMemoryNVS,\r
- BufferSize + ImageContext.SectionAlignment,\r
- &FfsBuffer\r
- );\r
+\r
+ MemoryAddress = SIZE_4GB - 1;\r
+ PageNumber = EFI_SIZE_TO_PAGES (BufferSize + ImageContext.SectionAlignment);\r
+ Status = gBS->AllocatePages (\r
+ AllocateMaxAddress,\r
+ EfiACPIMemoryNVS,\r
+ PageNumber,\r
+ &MemoryAddress\r
+ );\r
if (EFI_ERROR (Status)) {\r
return EFI_OUT_OF_RESOURCES;\r
}\r
- ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer;\r
+ ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)MemoryAddress;\r
//\r
// Align buffer on section boundry\r
//\r
//\r
Status = PeCoffLoaderLoadImage (&ImageContext);\r
if (EFI_ERROR (Status)) {\r
- gBS->FreePool (FfsBuffer);\r
+ gBS->FreePages (MemoryAddress, PageNumber);\r
return Status;\r
}\r
\r
\r
if (EFI_ERROR (Status)) {\r
PeCoffLoaderUnloadImage (&ImageContext);\r
- gBS->FreePool (FfsBuffer);\r
+ gBS->FreePages (MemoryAddress, PageNumber);\r
return Status;\r
}\r
//\r
InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize);\r
Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) ((EFI_HANDLE)(UINTN)(ImageContext.ImageAddress), SystemTable);\r
if (EFI_ERROR (Status)) {\r
- gBS->FreePool (FfsBuffer);\r
+ gBS->FreePages (MemoryAddress, PageNumber);\r
return Status;\r
}\r
//\r