ArmPkg/BdsLib: Allocate memory with AnyPage type if it failed with the one initially requested

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12170 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
oliviermartin 2011-08-18 21:11:27 +00:00
parent 656416bc2e
commit bd54c237f3
1 changed files with 20 additions and 4 deletions

View File

@ -452,6 +452,10 @@ BdsFileSystemLoadImage (
FreePool(FileInfo);
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
// Try to allocate in any pages if failed to allocate memory at the defined location
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
}
if (!EFI_ERROR(Status)) {
Status = File->Read (File, &Size, (VOID*)(UINTN)(*Image));
}
@ -493,6 +497,10 @@ BdsMemoryMapLoadImage (
}
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
// Try to allocate in any pages if failed to allocate memory at the defined location
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
}
if (!EFI_ERROR(Status)) {
CopyMem ((VOID*)(UINTN)(*Image), (CONST VOID*)(UINTN)MemMapPathDevicePath->StartingAddress, Size);
@ -571,6 +579,10 @@ BdsFirmwareVolumeLoadImage (
#else
// We must copy the buffer into a page allocations. Otherwise, the caller could call gBS->FreePages() on the pool allocation
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
// Try to allocate in any pages if failed to allocate memory at the defined location
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
}
if (!EFI_ERROR(Status)) {
CopyMem ((VOID*)(UINTN)(*Image), ImageBuffer, *ImageSize);
FreePool (ImageBuffer);
@ -589,6 +601,10 @@ BdsFirmwareVolumeLoadImage (
);
if (!EFI_ERROR(Status)) {
Status = gBS->AllocatePages (Type, EfiBootServicesCode, EFI_SIZE_TO_PAGES(*ImageSize), Image);
// Try to allocate in any pages if failed to allocate memory at the defined location
if ((Status == EFI_OUT_OF_RESOURCES) && (Type != AllocateAnyPages)) {
Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesCode, EFI_SIZE_TO_PAGES(Size), Image);
}
if (!EFI_ERROR(Status)) {
Status = FwVol->ReadFile (
FwVol,