From 2ce311322c72857f73138c45358e722607a1e80c Mon Sep 17 00:00:00 2001 From: ajfish Date: Wed, 26 Jul 2006 15:23:35 +0000 Subject: Removed cross references from PciCf8Lib and PciExpressLib class to PciLib class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added PeCoffLoaderGetMachineType to the PeCoffGetEntryPointLibrary Class. Document to be updated. Added the PeCoffLoaderImageReadFromMemory() and PeCoffLoaderRelocateImageForRuntime () to the PcCoffLib. Updated EfiImage.h and removed EFI_IMAGE_OPTIONAL_HEADER and EFI_IMAGE_NT_HEADERS as they were replaced with checking the MachineType. PeCoffLib – Added checks for MachineType so the PeCoff lib can load any PE32 or PE32+ image. The relocations are still limited to IA32, X64, IPF, and EBC. I also added a re-relocator function to remove PeLoader Code from Runtime Lib. Even though there is only one instance of the re-relocator I wanted to get all the PeCoff loader code together. Replaced DEBUG_CODE() macro with DEBUG_CODE_START() and DEBUG_CODE_END() so you can debug through the DEBUG_CODE() macros. Also removed PE/COFF code and replaced with library usage. I also updated the IO Instrinsic lib to use _ReadWriteBarrior() to help with sync problems git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1103 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Console/GraphicsConsole/Dxe/GraphicsConsole.c | 4 +- .../DebugSupport/Dxe/ipf/plDebugSupport.c | 5 +- .../Universal/Debugger/Debugport/Dxe/DebugPort.c | 8 +- EdkModulePkg/Universal/Disk/Partition/Dxe/Gpt.c | 4 +- EdkModulePkg/Universal/Ebc/Dxe/EbcExecute.c | 11 +- EdkModulePkg/Universal/Ebc/Dxe/EbcInt.c | 8 +- .../FaultTolerantWriteLite/Dxe/Ia32/Ia32FtwMisc.c | 14 +- .../Runtime/RuntimeDxe/Ia32/PeHotRelocateEx.c | 32 ---- .../Runtime/RuntimeDxe/Ipf/PeHotRelocateEx.c | 186 --------------------- .../Universal/Runtime/RuntimeDxe/PeHotRelocate.c | 163 ------------------ .../Universal/Runtime/RuntimeDxe/Runtime.c | 16 +- .../Universal/Runtime/RuntimeDxe/Runtime.h | 9 - .../Universal/Runtime/RuntimeDxe/Runtime.msa | 1 - .../Runtime/RuntimeDxe/x64/PeHotRelocateEx.c | 32 ---- 14 files changed, 42 insertions(+), 451 deletions(-) (limited to 'EdkModulePkg/Universal') diff --git a/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.c b/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.c index a475723dfd..d70c979b72 100644 --- a/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.c +++ b/EdkModulePkg/Universal/Console/GraphicsConsole/Dxe/GraphicsConsole.c @@ -423,9 +423,9 @@ GraphicsConsoleControllerDriverStart ( goto Error; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput, (CHAR16 *)L"Graphics Console Started\n\r"); - ); + DEBUG_CODE_END (); // // Install protocol interfaces for the Graphics Console device. diff --git a/EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.c b/EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.c index 6f2ded213e..b79390a95f 100644 --- a/EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.c +++ b/EdkModulePkg/Universal/DebugSupport/Dxe/ipf/plDebugSupport.c @@ -191,7 +191,7 @@ Returns: { static BOOLEAN InHandler = FALSE; - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); if (InHandler) { EfiDebugPrint (EFI_D_GENERIC, "ERROR: Re-entered debugger!\n" " ExceptionType == %X\n" @@ -205,7 +205,8 @@ Returns: Context.SystemContextIpf->CrIpsr, InHandler); } - ) + DEBUG_CODE_END (); + ASSERT (!InHandler); InHandler = TRUE; if (IvtEntryTable[ExceptionType].RegisteredCallback != NULL) { diff --git a/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.c b/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.c index a24bfd06d5..2152f75cf4 100644 --- a/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.c +++ b/EdkModulePkg/Universal/Debugger/Debugport/Dxe/DebugPort.c @@ -368,7 +368,7 @@ Returns: ); if (EFI_ERROR (Status)) { - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); UINTN BufferSize; BufferSize = 48; @@ -378,7 +378,7 @@ Returns: &BufferSize, "DebugPort driver failed to open child controller\n\n" ); - ); + DEBUG_CODE_END (); gBS->CloseProtocol ( ControllerHandle, @@ -389,7 +389,7 @@ Returns: return Status; } - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); UINTN BufferSize; BufferSize = 38; @@ -399,7 +399,7 @@ Returns: &BufferSize, "Hello World from the DebugPort driver\n\n" ); - ); + DEBUG_CODE_END (); return EFI_SUCCESS; } diff --git a/EdkModulePkg/Universal/Disk/Partition/Dxe/Gpt.c b/EdkModulePkg/Universal/Disk/Partition/Dxe/Gpt.c index 35ff1a8606..9077ac63c2 100644 --- a/EdkModulePkg/Universal/Disk/Partition/Dxe/Gpt.c +++ b/EdkModulePkg/Universal/Disk/Partition/Dxe/Gpt.c @@ -758,11 +758,11 @@ Returns: // // return status // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); if (OrgCrc != Crc) { DEBUG ((EFI_D_ERROR, "CheckCrc32: Crc check failed\n")); } - ); + DEBUG_CODE_END (); return (BOOLEAN) (OrgCrc == Crc); } diff --git a/EdkModulePkg/Universal/Ebc/Dxe/EbcExecute.c b/EdkModulePkg/Universal/Ebc/Dxe/EbcExecute.c index 9d375a5461..a672a794e0 100644 --- a/EdkModulePkg/Universal/Ebc/Dxe/EbcExecute.c +++ b/EdkModulePkg/Universal/Ebc/Dxe/EbcExecute.c @@ -685,9 +685,6 @@ Returns: EFI_STATUS Status; EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *EbcSimpleDebugger; - // - // end DEBUG_CODE - // EbcSimpleDebugger = NULL; Status = EFI_SUCCESS; StackCorrupted = 0; @@ -704,7 +701,7 @@ Returns: // // Try to get the debug support for EBC // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); Status = gBS->LocateProtocol ( &mEbcSimpleDebuggerProtocolGuid, NULL, @@ -713,7 +710,7 @@ Returns: if (EFI_ERROR (Status)) { EbcSimpleDebugger = NULL; } - ); + DEBUG_CODE_END (); // // Save the start IP for debug. For example, if we take an exception we @@ -731,11 +728,11 @@ Returns: // // If we've found a simple debugger protocol, call it // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); if (EbcSimpleDebugger != NULL) { EbcSimpleDebugger->Debugger (EbcSimpleDebugger, VmPtr); } - ); + DEBUG_CODE_END (); // // Verify the opcode is in range. Otherwise generate an exception. diff --git a/EdkModulePkg/Universal/Ebc/Dxe/EbcInt.c b/EdkModulePkg/Universal/Ebc/Dxe/EbcInt.c index 220c8fefac..7b15a1a84b 100644 --- a/EdkModulePkg/Universal/Ebc/Dxe/EbcInt.c +++ b/EdkModulePkg/Universal/Ebc/Dxe/EbcInt.c @@ -298,9 +298,9 @@ Returns: // // Produce a VM test interface protocol. Not required for execution. // - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); InitEbcVmTestProtocol (&ImageHandle); - ); + DEBUG_CODE_END (); return Status; } @@ -908,10 +908,10 @@ Returns: } EbcVmTestProtocol->Execute = (EBC_VM_TEST_EXECUTE) EbcExecuteInstructions; - DEBUG_CODE( + DEBUG_CODE_BEGIN (); EbcVmTestProtocol->Assemble = (EBC_VM_TEST_ASM) EbcVmTestUnsupported; EbcVmTestProtocol->Disassemble = (EBC_VM_TEST_DASM) EbcVmTestUnsupported; - ); + DEBUG_CODE_END (); // // Publish the protocol diff --git a/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/Ia32/Ia32FtwMisc.c b/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/Ia32/Ia32FtwMisc.c index 80258f4cc3..85fa60e348 100644 --- a/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/Ia32/Ia32FtwMisc.c +++ b/EdkModulePkg/Universal/FirmwareVolume/FaultTolerantWriteLite/Dxe/Ia32/Ia32FtwMisc.c @@ -173,21 +173,23 @@ Note: Status = PciRootBridgeIo->Pci.Write ( PciRootBridgeIo, EfiPciWidthUint32, - EFI_PCI_ADDRESS (LPC_BUS_NUMBER, - LPC_DEVICE_NUMBER, - LPC_IF, - GEN_STATUS), + EFI_PCI_ADDRESS ( + LPC_BUS_NUMBER, + LPC_DEVICE_NUMBER, + LPC_IF, + GEN_STATUS + ), 1, &GenStatus ); - DEBUG_CODE ( + DEBUG_CODE_BEGIN (); if (TopSwap) { DEBUG ((EFI_D_ERROR, "SAR: Set top swap\n")); } else { DEBUG ((EFI_D_ERROR, "SAR: Clear top swap\n")); } - ); + DEBUG_CODE_END (); return EFI_SUCCESS; } diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ia32/PeHotRelocateEx.c b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ia32/PeHotRelocateEx.c index 82d464aebe..7678c4d365 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ia32/PeHotRelocateEx.c +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ia32/PeHotRelocateEx.c @@ -24,38 +24,6 @@ Revision History #include "Runtime.h" -EFI_STATUS -PeHotRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based platform specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - EFI_SUCCESS - ---*/ -{ - return EFI_SUCCESS; - -} // // Cache Flush Routine. diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ipf/PeHotRelocateEx.c b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ipf/PeHotRelocateEx.c index ffc0aaf4a4..97bdae0aa0 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ipf/PeHotRelocateEx.c +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Ipf/PeHotRelocateEx.c @@ -23,192 +23,6 @@ Revision History --*/ #include "Runtime.h" -#include "PeHotRelocateEx.h" - -EFI_STATUS -PeHotRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an IPF specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - None - ---*/ -{ - UINT64 *F64; - UINT64 FixupVal; - - switch ((*Reloc) >> 12) { - case EFI_IMAGE_REL_BASED_DIR64: - F64 = (UINT64 *) Fixup; - *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); - if (*(UINT64 *) (*FixupData) == *F64) { - *F64 = *F64 + (UINT64) Adjust; - } - - *FixupData = *FixupData + sizeof (UINT64); - break; - - case EFI_IMAGE_REL_BASED_IA64_IMM64: - F64 = (UINT64 *) Fixup; - *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT64)); - if (*(UINT64 *) (*FixupData) == *F64) { - // - // Align it to bundle address before fixing up the - // 64-bit immediate value of the movl instruction. - // - // - Fixup = (CHAR8 *) ((UINT64) Fixup & (UINT64)~(15)); - FixupVal = (UINT64) 0; - - // - // Extract the lower 32 bits of IMM64 from bundle - // - EXT_IMM64 ( - FixupVal, - (UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X, - IMM64_IMM7B_SIZE_X, - IMM64_IMM7B_INST_WORD_POS_X, - IMM64_IMM7B_VAL_POS_X - ); - - EXT_IMM64 ( - FixupVal, - (UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X, - IMM64_IMM9D_SIZE_X, - IMM64_IMM9D_INST_WORD_POS_X, - IMM64_IMM9D_VAL_POS_X - ); - - EXT_IMM64 ( - FixupVal, - (UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X, - IMM64_IMM5C_SIZE_X, - IMM64_IMM5C_INST_WORD_POS_X, - IMM64_IMM5C_VAL_POS_X - ); - - EXT_IMM64 ( - FixupVal, - (UINT32 *) Fixup + IMM64_IC_INST_WORD_X, - IMM64_IC_SIZE_X, - IMM64_IC_INST_WORD_POS_X, - IMM64_IC_VAL_POS_X - ); - - EXT_IMM64 ( - FixupVal, - (UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X, - IMM64_IMM41a_SIZE_X, - IMM64_IMM41a_INST_WORD_POS_X, - IMM64_IMM41a_VAL_POS_X - ); - - // - // Update 64-bit address - // - FixupVal += Adjust; - - // - // Insert IMM64 into bundle - // - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM7B_INST_WORD_X), - IMM64_IMM7B_SIZE_X, - IMM64_IMM7B_INST_WORD_POS_X, - IMM64_IMM7B_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM9D_INST_WORD_X), - IMM64_IMM9D_SIZE_X, - IMM64_IMM9D_INST_WORD_POS_X, - IMM64_IMM9D_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM5C_INST_WORD_X), - IMM64_IMM5C_SIZE_X, - IMM64_IMM5C_INST_WORD_POS_X, - IMM64_IMM5C_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IC_INST_WORD_X), - IMM64_IC_SIZE_X, - IMM64_IC_INST_WORD_POS_X, - IMM64_IC_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM41a_INST_WORD_X), - IMM64_IMM41a_SIZE_X, - IMM64_IMM41a_INST_WORD_POS_X, - IMM64_IMM41a_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM41b_INST_WORD_X), - IMM64_IMM41b_SIZE_X, - IMM64_IMM41b_INST_WORD_POS_X, - IMM64_IMM41b_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_IMM41c_INST_WORD_X), - IMM64_IMM41c_SIZE_X, - IMM64_IMM41c_INST_WORD_POS_X, - IMM64_IMM41c_VAL_POS_X - ); - - INS_IMM64 ( - FixupVal, - ((UINT32 *) Fixup + IMM64_SIGN_INST_WORD_X), - IMM64_SIGN_SIZE_X, - IMM64_SIGN_INST_WORD_POS_X, - IMM64_SIGN_VAL_POS_X - ); - - *(UINT64 *) (*FixupData) = *F64; - } - - *FixupData = *FixupData + sizeof (UINT64); - break; - - default: - DEBUG ((EFI_D_ERROR, "PeHotRelocateEx:unknown fixed type\n")); - return EFI_UNSUPPORTED; - } - - return EFI_SUCCESS; -} - // // Cache Flush Routine. diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/PeHotRelocate.c b/EdkModulePkg/Universal/Runtime/RuntimeDxe/PeHotRelocate.c index 4c2aeff78e..fd980a7b6a 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/PeHotRelocate.c +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/PeHotRelocate.c @@ -51,166 +51,3 @@ Returns: return (CHAR8 *) ((UINTN) Image->ImageBase + Address); } -VOID -RelocatePeImageForRuntime ( - RUNTIME_IMAGE_RELOCATION_DATA *Image - ) -{ - CHAR8 *OldBase; - CHAR8 *NewBase; - EFI_IMAGE_DOS_HEADER *DosHdr; - EFI_IMAGE_NT_HEADERS *PeHdr; - UINT32 NumberOfRvaAndSizes; - EFI_IMAGE_DATA_DIRECTORY *DataDirectory; - EFI_IMAGE_DATA_DIRECTORY *RelocDir; - EFI_IMAGE_BASE_RELOCATION *RelocBase; - EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd; - UINT16 *Reloc; - UINT16 *RelocEnd; - CHAR8 *Fixup; - CHAR8 *FixupBase; - UINT16 *F16; - UINT32 *F32; - CHAR8 *FixupData; - UINTN Adjust; - EFI_STATUS Status; - - OldBase = (CHAR8 *) ((UINTN) Image->ImageBase); - NewBase = (CHAR8 *) ((UINTN) Image->ImageBase); - - Status = RuntimeDriverConvertPointer (0, (VOID **) &NewBase); - ASSERT_EFI_ERROR (Status); - - Adjust = (UINTN) NewBase - (UINTN) OldBase; - - // - // Find the image's relocate dir info - // - DosHdr = (EFI_IMAGE_DOS_HEADER *) OldBase; - if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) { - // - // Valid DOS header so get address of PE header - // - PeHdr = (EFI_IMAGE_NT_HEADERS *) (((CHAR8 *) DosHdr) + DosHdr->e_lfanew); - } else { - // - // No Dos header so assume image starts with PE header. - // - PeHdr = (EFI_IMAGE_NT_HEADERS *) OldBase; - } - - if (PeHdr->Signature != EFI_IMAGE_NT_SIGNATURE) { - // - // Not a valid PE image so Exit - // - return ; - } - // - // Get some data from the PE type dependent data - // - NumberOfRvaAndSizes = PeHdr->OptionalHeader.NumberOfRvaAndSizes; - DataDirectory = &PeHdr->OptionalHeader.DataDirectory[0]; - - // - // Find the relocation block - // - // Per the PE/COFF spec, you can't assume that a given data directory - // is present in the image. You have to check the NumberOfRvaAndSizes in - // the optional header to verify a desired directory entry is there. - // - if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { - RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC; - RelocBase = RuntimePeImageAddress (Image, RelocDir->VirtualAddress); - RelocBaseEnd = RuntimePeImageAddress (Image, RelocDir->VirtualAddress + RelocDir->Size); - } else { - // - // Cannot find relocations, cannot continue - // - ASSERT (FALSE); - return ; - } - - ASSERT (RelocBase != NULL && RelocBaseEnd != NULL); - - // - // Run the whole relocation block. And re-fixup data that has not been - // modified. The FixupData is used to see if the image has been modified - // since it was relocated. This is so data sections that have been updated - // by code will not be fixed up, since that would set them back to - // defaults. - // - FixupData = Image->RelocationData; - while (RelocBase < RelocBaseEnd) { - - Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION)); - RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock); - FixupBase = (CHAR8 *) ((UINTN) Image->ImageBase) + RelocBase->VirtualAddress; - - // - // Run this relocation record - // - while (Reloc < RelocEnd) { - - Fixup = FixupBase + (*Reloc & 0xFFF); - switch ((*Reloc) >> 12) { - - case EFI_IMAGE_REL_BASED_ABSOLUTE: - break; - - case EFI_IMAGE_REL_BASED_HIGH: - F16 = (UINT16 *) Fixup; - if (*(UINT16 *) FixupData == *F16) { - *F16 = (UINT16) ((*F16 << 16) + ((UINT16) Adjust & 0xffff)); - } - - FixupData = FixupData + sizeof (UINT16); - break; - - case EFI_IMAGE_REL_BASED_LOW: - F16 = (UINT16 *) Fixup; - if (*(UINT16 *) FixupData == *F16) { - *F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff)); - } - - FixupData = FixupData + sizeof (UINT16); - break; - - case EFI_IMAGE_REL_BASED_HIGHLOW: - F32 = (UINT32 *) Fixup; - FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32)); - if (*(UINT32 *) FixupData == *F32) { - *F32 = *F32 + (UINT32) Adjust; - } - - FixupData = FixupData + sizeof (UINT32); - break; - - case EFI_IMAGE_REL_BASED_HIGHADJ: - // - // Not implemented, but not used in EFI 1.0 - // - ASSERT (FALSE); - break; - - default: - // - // Only Itanium requires ConvertPeImage_Ex - // - Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust); - if (EFI_ERROR (Status)) { - return ; - } - } - // - // Next relocation record - // - Reloc += 1; - } - // - // next reloc block - // - RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd; - } - - FlushCpuCache (Image->ImageBase, (UINT64) Image->ImageSize); -} diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.c b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.c index d2428ea1b6..f3899bc8e1 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.c +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.c @@ -352,6 +352,7 @@ RuntimeDriverSetVirtualAddressMap ( IN EFI_MEMORY_DESCRIPTOR *VirtualMap ) { + EFI_STATUS Status; RUNTIME_NOTIFY_EVENT_DATA *RuntimeEvent; RUNTIME_IMAGE_RELOCATION_DATA *RuntimeImage; LIST_ENTRY *Link; @@ -359,6 +360,7 @@ RuntimeDriverSetVirtualAddressMap ( UINTN Index1; EFI_DRIVER_OS_HANDOFF_HEADER *DriverOsHandoffHeader; EFI_DRIVER_OS_HANDOFF *DriverOsHandoff; + EFI_PHYSICAL_ADDRESS VirtImageBase; #if (EFI_SPECIFICATION_VERSION >= 0x00020000) EFI_CAPSULE_TABLE *CapsuleTable; #endif @@ -454,7 +456,19 @@ RuntimeDriverSetVirtualAddressMap ( for (Link = mRelocationList.ForwardLink; Link != &mRelocationList; Link = Link->ForwardLink) { RuntimeImage = _CR (Link, RUNTIME_IMAGE_RELOCATION_DATA, Link); if (RuntimeImage->Valid) { - RelocatePeImageForRuntime (RuntimeImage); + + VirtImageBase = RuntimeImage->ImageBase; + Status = RuntimeDriverConvertPointer (0, (VOID **) &VirtImageBase); + ASSERT_EFI_ERROR (Status); + + PeCoffLoaderRelocateImageForRuntime ( + RuntimeImage->ImageBase, + VirtImageBase, + RuntimeImage->ImageSize, + RuntimeImage->RelocationData + ); + + FlushCpuCache (RuntimeImage->ImageBase, (UINT64)RuntimeImage->ImageSize); } } // diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.h b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.h index 3803a9dadd..5b582c76ba 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.h +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.h @@ -53,15 +53,6 @@ RelocatePeImageForRuntime ( ) ; -EFI_STATUS -PeHotRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -; - EFI_STATUS EFIAPI RuntimeDriverCalculateCrc32 ( diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.msa b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.msa index c1373e1ea4..5773156f58 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.msa +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/Runtime.msa @@ -60,7 +60,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.--> Runtime.dxs - PeHotRelocate.c Runtime.c Runtime.h Crc32.c diff --git a/EdkModulePkg/Universal/Runtime/RuntimeDxe/x64/PeHotRelocateEx.c b/EdkModulePkg/Universal/Runtime/RuntimeDxe/x64/PeHotRelocateEx.c index 82d464aebe..7678c4d365 100644 --- a/EdkModulePkg/Universal/Runtime/RuntimeDxe/x64/PeHotRelocateEx.c +++ b/EdkModulePkg/Universal/Runtime/RuntimeDxe/x64/PeHotRelocateEx.c @@ -24,38 +24,6 @@ Revision History #include "Runtime.h" -EFI_STATUS -PeHotRelocateImageEx ( - IN UINT16 *Reloc, - IN OUT CHAR8 *Fixup, - IN OUT CHAR8 **FixupData, - IN UINT64 Adjust - ) -/*++ - -Routine Description: - - Performs an Itanium-based platform specific relocation fixup - -Arguments: - - Reloc - Pointer to the relocation record - - Fixup - Pointer to the address to fix up - - FixupData - Pointer to a buffer to log the fixups - - Adjust - The offset to adjust the fixup - -Returns: - - EFI_SUCCESS - ---*/ -{ - return EFI_SUCCESS; - -} // // Cache Flush Routine. -- cgit v1.2.3