From a1fe1d6dd87986175207c62992ef956d518b8163 Mon Sep 17 00:00:00 2001 From: lgao4 Date: Mon, 7 Mar 2011 02:23:00 +0000 Subject: ECP package BootScriptSaveOnS3SaveStateThunk driver needs to support framework 32bit dispatch code. It must be loaded into <4G memory. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11349 6f19259b-4bc3-4df7-8a09-765794883524 --- .../BootScriptSaveOnS3SaveStateThunk/ScriptSave.c | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c index 9a4119b318..7248e2e860 100644 --- a/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c +++ b/EdkCompatibilityPkg/Compatibility/BootScriptSaveOnS3SaveStateThunk/ScriptSave.c @@ -797,11 +797,12 @@ InitializeScriptSaveOnS3SaveState ( { UINT8 *Buffer; UINTN BufferSize; - VOID *FfsBuffer; PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; BOOT_SCRIPT_THUNK_DATA *BootScriptThunkData; EFI_STATUS Status; VOID *DevicePath; + EFI_PHYSICAL_ADDRESS MemoryAddress; + UINTN PageNumber; // // Test if the gEfiCallerIdGuid of this image is already installed. if not, the entry @@ -839,15 +840,19 @@ InitializeScriptSaveOnS3SaveState ( if (EFI_ERROR (Status)) { return Status; } - Status = gBS->AllocatePool ( - EfiACPIMemoryNVS, - BufferSize + ImageContext.SectionAlignment, - &FfsBuffer - ); + + MemoryAddress = SIZE_4GB - 1; + PageNumber = EFI_SIZE_TO_PAGES (BufferSize + ImageContext.SectionAlignment); + Status = gBS->AllocatePages ( + AllocateMaxAddress, + EfiACPIMemoryNVS, + PageNumber, + &MemoryAddress + ); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES; } - ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer; + ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)MemoryAddress; // // Align buffer on section boundry // @@ -858,7 +863,7 @@ InitializeScriptSaveOnS3SaveState ( // Status = PeCoffLoaderLoadImage (&ImageContext); if (EFI_ERROR (Status)) { - gBS->FreePool (FfsBuffer); + gBS->FreePages (MemoryAddress, PageNumber); return Status; } @@ -869,7 +874,7 @@ InitializeScriptSaveOnS3SaveState ( if (EFI_ERROR (Status)) { PeCoffLoaderUnloadImage (&ImageContext); - gBS->FreePool (FfsBuffer); + gBS->FreePages (MemoryAddress, PageNumber); return Status; } // @@ -878,7 +883,7 @@ InitializeScriptSaveOnS3SaveState ( InvalidateInstructionCacheRange ((VOID *)(UINTN)ImageContext.ImageAddress, (UINTN)ImageContext.ImageSize); Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)(ImageContext.EntryPoint)) ((EFI_HANDLE)(UINTN)(ImageContext.ImageAddress), SystemTable); if (EFI_ERROR (Status)) { - gBS->FreePool (FfsBuffer); + gBS->FreePages (MemoryAddress, PageNumber); return Status; } // -- cgit v1.2.3