diff --git a/Tools/CCode/Source/GenFvImage/GenFvImageExe.c b/Tools/CCode/Source/GenFvImage/GenFvImageExe.c index ce56299f1f..f5a5179559 100644 --- a/Tools/CCode/Source/GenFvImage/GenFvImageExe.c +++ b/Tools/CCode/Source/GenFvImage/GenFvImageExe.c @@ -215,6 +215,11 @@ Returns: &SymFileName ); + // + // free InfFileImage memory + // + free (InfFileImage); + if (EFI_ERROR (Status)) { switch (Status) { diff --git a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c index 27c646e486..d27083aceb 100644 --- a/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c +++ b/Tools/CCode/Source/PeiRebase/PeiRebaseExe.c @@ -100,6 +100,10 @@ Returns: EFI_FFS_FILE_HEADER *CurrentFile; BOOLEAN ErasePolarity; EFI_PHYSICAL_ADDRESS CurrentFileBaseAddress; + CHAR8 InfFileName[_MAX_PATH]; + CHAR8 *InfFileImage; + UINTN InfFileSize; + MEMORY_FILE InfMemoryFile; ErasePolarity = FALSE; // @@ -129,6 +133,9 @@ Returns: OutputFile = NULL; MapFile = NULL; FvImage = NULL; + InfFileImage = NULL; + InfFileSize = 0; + strcpy (InfFileName, ""); // // Parse the command line arguments @@ -194,6 +201,52 @@ Returns: } break; + case 'F': + case 'f': + if (!BaseAddressSet) { + strcpy (InfFileName, argv[Index + 1]); + // + // Read the INF file image + // + Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize); + if (EFI_ERROR (Status)) { + PrintUsage (); + Error (NULL, 0, 0, argv[Index + 1], "-f FvInfFile can't be opened."); + return STATUS_ERROR; + } + // + // Initialize file structures + // + InfMemoryFile.FileImage = InfFileImage; + InfMemoryFile.CurrentFilePointer = InfFileImage; + InfMemoryFile.Eof = InfFileImage + InfFileSize; + // + // Read BaseAddress from fv.inf file. + // + FindToken (&InfMemoryFile, "[options]", "EFI_BASE_ADDRESS", 0, InfFileName); + // + // free Inf File Image + // + free (InfFileImage); + + // + // Convert string to UINT64 base address. + // + Status = AsciiStringToUint64 (InfFileName, FALSE, &BaseAddress); + if (EFI_ERROR (Status)) { + PrintUsage (); + Error (NULL, 0, 0, argv[Index + 1], "can't find the base address in the specified fv.inf file."); + return STATUS_ERROR; + } + + BaseAddressSet = TRUE; + } else { + PrintUsage (); + Error (NULL, 0, 0, argv[Index + 1], "BaseAddress has been got once from fv.inf or the specified base address."); + return STATUS_ERROR; + } + break; + case 'M': case 'm': if (strlen (MapFileName) == 0) { @@ -212,7 +265,7 @@ Returns: break; } } - + // // Create the Map file if we need it // @@ -486,15 +539,18 @@ Returns: --*/ { printf ( - "Usage: %s -I InputFileName -O OutputFileName -B BaseAddress [-M MapFile]\n", + "Usage: %s -I InputFileName -O OutputFileName [-B BaseAddress] -F FvInfFileName -M MapFile\n", UTILITY_NAME ); printf (" Where:\n"); - printf (" InputFileName is the name of the EFI FV file to rebase.\n"); + printf (" InputFileName is the name of the EFI FV file to rebase.\n"); printf (" OutputFileName is the desired output file name.\n"); - printf (" BaseAddress is the FV base address to rebase agains.\n"); - printf (" MapFileName is an optional map file of the relocations\n"); - printf (" Argument pair may be in any order.\n\n"); + printf (" BaseAddress is the FV base address to rebase agains.\n"); + printf (" FvInfFileName is the fv.inf to be used to generate this fv image.\n"); + printf (" BaseAddress can also be got from the fv.inf file.\n"); + printf (" Choose only one method to input BaseAddress.\n"); + printf (" MapFileName is an optional map file of the relocations\n"); + printf (" Argument pair may be in any order.\n\n"); } EFI_STATUS diff --git a/Tools/Conf/BuildMacro.xml b/Tools/Conf/BuildMacro.xml index 45c7ddc32b..29edaaf540 100644 --- a/Tools/Conf/BuildMacro.xml +++ b/Tools/Conf/BuildMacro.xml @@ -1379,7 +1379,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - diff --git a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java index 1f8a4d1f3c..07154921d2 100644 --- a/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java +++ b/Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java @@ -50,7 +50,11 @@ public class PeiReBaseTask extends Task implements EfiDefine { // private ToolArg baseAddr = new ToolArg(); // + // Fv.inf file // + private FileArg fvinfFile = new FileArg(); + // + // map file // private FileArg mapFile = new FileArg(); // @@ -99,7 +103,7 @@ public class PeiReBaseTask extends Task implements EfiDefine { if (mapFile.getValue().length() == 0) { mapFile.setArg(" -M ", outputFile.getValue() + ".map"); } - argument = "" + inputFile + outputFile + baseAddr + mapFile; + argument = "" + inputFile + outputFile + baseAddr + fvinfFile + mapFile; // // return value of fwimage execution @@ -234,6 +238,24 @@ public class PeiReBaseTask extends Task implements EfiDefine { this.arch = arch; } + /** + Get the value of fv.inf file + + @return String The fv.inf file path + **/ + public String getFvInfFile() { + return fvinfFile.getValue(); + } + + /** + Set "-F FvinfFile" argument + + @param fvinfFile The path of fv.inf file + **/ + public void setFvInfFile(String fvinfFile) { + this.fvinfFile.setArg(" -F ", fvinfFile); + } + /** Get the value of map file