diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java index f9340758b3..ae47ec7ff4 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java @@ -34,10 +34,6 @@ public class GenFvImageTask extends Task implements EfiDefine{ /// The name of input inf file /// private String infFile=""; - /// - /// The target architecture. - /// - private String arch=""; /** execute @@ -56,25 +52,8 @@ public class GenFvImageTask extends Task implements EfiDefine{ path = path + File.separatorChar; } - // FIXME arch should be passed via schema attributes. - arch=System.getenv("ARCH"); - if (arch == null) { - arch = ""; - } - // FIXME end + command = path + "GenFvImage"; - if (arch.equalsIgnoreCase("IA32")){ - command = path + "GenFvImage_Ia32"; - } - else if (arch.equalsIgnoreCase("X64")){ - command = path + "GenFvImage_X64"; - } - else if (arch.equalsIgnoreCase("IPF")){ - command = path + "GenFvImage_Ipf"; - } - else { - command = path + "GenFvImage"; - } String argument = infFile; try { @@ -138,24 +117,4 @@ public class GenFvImageTask extends Task implements EfiDefine{ this.infFile = "-I " + infFile; } - /** - getArch - - This function is to get class member of arch. - @return The target architecture. - **/ - public String getArch() { - return arch; - } - - /** - setArch - - This function is to set class member of arch. - - @param arch The target architecture. - **/ - public void setArch(String arch) { - this.arch = arch; - } } diff --git a/Tools/Source/TianoTools/GenFvImage/GenFvImageLib.c b/Tools/Source/TianoTools/GenFvImage/GenFvImageLib.c index c4515001d8..6cc5a0d56f 100644 --- a/Tools/Source/TianoTools/GenFvImage/GenFvImageLib.c +++ b/Tools/Source/TianoTools/GenFvImage/GenFvImageLib.c @@ -1306,168 +1306,6 @@ Returns: return EFI_SUCCESS; } -EFI_STATUS -RebaseFfsFile ( - IN OUT EFI_FFS_FILE_HEADER *FfsFile, - IN EFI_PHYSICAL_ADDRESS BaseAddress - ) -/*++ - -Routine Description: - - This function determines if a file is XIP and should be rebased. It will - rebase any PE32 sections found in the file using the base address. - -Arguments: - - FfsFile A pointer to Ffs file image. - BaseAddress The base address to use for rebasing the file image. - -Returns: - - EFI_SUCCESS The image was properly rebased. - EFI_INVALID_PARAMETER An input parameter is invalid. - EFI_ABORTED An error occurred while rebasing the input file image. - EFI_OUT_OF_RESOURCES Could not allocate a required resource. - ---*/ -{ - EFI_STATUS Status; - PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; - UINTN MemoryImagePointer; - UINTN MemoryImagePointerAligned; - - EFI_PHYSICAL_ADDRESS ImageAddress; - UINT64 ImageSize; - EFI_PHYSICAL_ADDRESS EntryPoint; - - UINT32 Pe32FileSize; - UINT32 NewPe32BaseAddress; - - UINTN Index; - EFI_FILE_SECTION_POINTER CurrentPe32Section; - UINT8 FileGuidString[80]; - - // - // Verify input parameters - // - if (FfsFile == NULL) { - return EFI_INVALID_PARAMETER; - } - // - // Convert the GUID to a string so we can at least report which file - // if we find an error. - // - PrintGuidToBuffer (&FfsFile->Name, FileGuidString, sizeof (FileGuidString), TRUE); - - // - // Do some nominal checks on the file, then check for XIP. - // - Status = VerifyFfsFile (FfsFile); - if (EFI_ERROR (Status)) { - Error (NULL, 0, 0, "invalid FFS file", FileGuidString); - return EFI_INVALID_PARAMETER; - } - - if (FfsFile->Type != EFI_FV_FILETYPE_SECURITY_CORE && - FfsFile->Type != EFI_FV_FILETYPE_PEI_CORE && - FfsFile->Type != EFI_FV_FILETYPE_PEIM - ) { - // - // File is not XIP, so don't rebase - // - return EFI_SUCCESS; - } - // - // Rebase each PE32 section - // - for (Index = 1;; Index++) { - Status = GetSectionByType (FfsFile, EFI_SECTION_PE32, Index, &CurrentPe32Section); - if (EFI_ERROR (Status)) { - break; - } - // - // Calculate the PE32 base address, the FFS file base plus the offset of the PE32 section - // - NewPe32BaseAddress = ((UINT32) BaseAddress) + ((UINTN) CurrentPe32Section.Pe32Section - (UINTN) FfsFile); - - // - // Initialize context - // - memset (&ImageContext, 0, sizeof (ImageContext)); - ImageContext.Handle = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION)); - ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead; - - Status = PeCoffLoaderGetImageInfo (&ImageContext); - - if (EFI_ERROR (Status)) { - Error (NULL, 0, 0, "GetImageInfo() failed", FileGuidString); - return Status; - } - // - // Allocate a buffer for the image to be loaded into. - // - Pe32FileSize = GetLength (CurrentPe32Section.Pe32Section->CommonHeader.Size); - MemoryImagePointer = (UINTN) (malloc (Pe32FileSize + 0x1000)); - MemoryImagePointerAligned = (MemoryImagePointer + 0x0FFF) & (-1 << 12); - if (MemoryImagePointerAligned == 0) { - Error (NULL, 0, 0, "memory allocation failure", NULL); - return EFI_OUT_OF_RESOURCES; - } - - // - // bugbug - // - ImageContext.ImageAddress = MemoryImagePointerAligned; - Status = PeCoffLoaderLoadImage (&ImageContext); - if (EFI_ERROR (Status)) { - Error (NULL, 0, 0, "LoadImage() failure", FileGuidString); - free ((VOID *) MemoryImagePointer); - return Status; - } - - Status = PeCoffLoaderRelocateImage (&ImageContext); - if (EFI_ERROR (Status)) { - Error (NULL, 0, 0, "RelocateImage() failure", FileGuidString); - free ((VOID *) MemoryImagePointer); - return Status; - } - - ImageAddress = ImageContext.ImageAddress; - ImageSize = ImageContext.ImageSize; - EntryPoint = ImageContext.EntryPoint; - - if (ImageSize > Pe32FileSize) { - Error ( - NULL, - 0, - 0, - "rebased PE32 is larger than original PE32 image", - "0x%X > 0x%X on file %s", - ImageSize, - Pe32FileSize, - FileGuidString - ); - free ((VOID *) MemoryImagePointer); - return EFI_ABORTED; - } - - memcpy (CurrentPe32Section.Pe32Section, (VOID *) MemoryImagePointerAligned, Pe32FileSize); - - free ((VOID *) MemoryImagePointer); - } - // - // the above for loop will always exit with EFI_NOT_FOUND if it completes - // normally. If Index == 1 at exit, then no PE32 sections were found. If it - // exits with any other error code, then something broke... - // - if (Status != EFI_NOT_FOUND) { - Error (NULL, 0, 0, "failed to parse PE32 section", FileGuidString); - return Status; - } - - return EFI_SUCCESS; -} EFI_STATUS AddSymFile ( diff --git a/Tools/Source/TianoTools/GenFvImage/build.xml b/Tools/Source/TianoTools/GenFvImage/build.xml index d29a2eca97..c57ec2968e 100644 --- a/Tools/Source/TianoTools/GenFvImage/build.xml +++ b/Tools/Source/TianoTools/GenFvImage/build.xml @@ -24,9 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - - + @@ -34,9 +32,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - - + @@ -109,10 +105,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - + - @@ -134,95 +130,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -232,9 +140,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - - - +