EFI_FFS_FILE_HEADER *CurrentFile;\r
BOOLEAN ErasePolarity;\r
EFI_PHYSICAL_ADDRESS CurrentFileBaseAddress;\r
+ CHAR8 InfFileName[_MAX_PATH];\r
+ CHAR8 *InfFileImage;\r
+ UINTN InfFileSize;\r
+ MEMORY_FILE InfMemoryFile;\r
\r
ErasePolarity = FALSE;\r
//\r
OutputFile = NULL;\r
MapFile = NULL;\r
FvImage = NULL;\r
+ InfFileImage = NULL;\r
+ InfFileSize = 0;\r
+ strcpy (InfFileName, "");\r
\r
//\r
// Parse the command line arguments\r
}\r
break;\r
\r
+ case 'F':\r
+ case 'f':\r
+ if (!BaseAddressSet) {\r
+ strcpy (InfFileName, argv[Index + 1]);\r
+ //\r
+ // Read the INF file image\r
+ //\r
+ Status = GetFileImage (InfFileName, &InfFileImage, &InfFileSize);\r
+ if (EFI_ERROR (Status)) {\r
+ PrintUsage ();\r
+ Error (NULL, 0, 0, argv[Index + 1], "-f FvInfFile can't be opened.");\r
+ return STATUS_ERROR;\r
+ }\r
+ //\r
+ // Initialize file structures\r
+ //\r
+ InfMemoryFile.FileImage = InfFileImage;\r
+ InfMemoryFile.CurrentFilePointer = InfFileImage;\r
+ InfMemoryFile.Eof = InfFileImage + InfFileSize;\r
+ //\r
+ // Read BaseAddress from fv.inf file.\r
+ //\r
+ FindToken (&InfMemoryFile, "[options]", "EFI_BASE_ADDRESS", 0, InfFileName);\r
+ //\r
+ // free Inf File Image\r
+ //\r
+ free (InfFileImage);\r
+ \r
+ //\r
+ // Convert string to UINT64 base address.\r
+ //\r
+ Status = AsciiStringToUint64 (InfFileName, FALSE, &BaseAddress);\r
+ if (EFI_ERROR (Status)) {\r
+ PrintUsage ();\r
+ Error (NULL, 0, 0, argv[Index + 1], "can't find the base address in the specified fv.inf file.");\r
+ return STATUS_ERROR;\r
+ }\r
+\r
+ BaseAddressSet = TRUE;\r
+ } else {\r
+ PrintUsage ();\r
+ Error (NULL, 0, 0, argv[Index + 1], "BaseAddress has been got once from fv.inf or the specified base address.");\r
+ return STATUS_ERROR;\r
+ }\r
+ break;\r
+\r
case 'M':\r
case 'm':\r
if (strlen (MapFileName) == 0) {\r
break;\r
}\r
}\r
-\r
+ \r
//\r
// Create the Map file if we need it\r
//\r
--*/\r
{\r
printf (\r
- "Usage: %s -I InputFileName -O OutputFileName -B BaseAddress [-M MapFile]\n",\r
+ "Usage: %s -I InputFileName -O OutputFileName [-B BaseAddress] -F FvInfFileName -M MapFile\n",\r
UTILITY_NAME\r
);\r
printf (" Where:\n");\r
- printf (" InputFileName is the name of the EFI FV file to rebase.\n");\r
+ printf (" InputFileName is the name of the EFI FV file to rebase.\n");\r
printf (" OutputFileName is the desired output file name.\n");\r
- printf (" BaseAddress is the FV base address to rebase agains.\n");\r
- printf (" MapFileName is an optional map file of the relocations\n");\r
- printf (" Argument pair may be in any order.\n\n");\r
+ printf (" BaseAddress is the FV base address to rebase agains.\n");\r
+ printf (" FvInfFileName is the fv.inf to be used to generate this fv image.\n");\r
+ printf (" BaseAddress can also be got from the fv.inf file.\n");\r
+ printf (" Choose only one method to input BaseAddress.\n");\r
+ printf (" MapFileName is an optional map file of the relocations\n");\r
+ printf (" Argument pair may be in any order.\n\n");\r
}\r
\r
EFI_STATUS\r
//\r
private ToolArg baseAddr = new ToolArg();\r
//\r
+ // Fv.inf file\r
// \r
+ private FileArg fvinfFile = new FileArg();\r
+ //\r
+ // map file\r
// \r
private FileArg mapFile = new FileArg();\r
//\r
if (mapFile.getValue().length() == 0) {\r
mapFile.setArg(" -M ", outputFile.getValue() + ".map");\r
}\r
- argument = "" + inputFile + outputFile + baseAddr + mapFile;\r
+ argument = "" + inputFile + outputFile + baseAddr + fvinfFile + mapFile;\r
\r
//\r
// return value of fwimage execution\r
this.arch = arch;\r
}\r
\r
+ /**\r
+ Get the value of fv.inf file\r
+\r
+ @return String The fv.inf file path\r
+ **/\r
+ public String getFvInfFile() {\r
+ return fvinfFile.getValue();\r
+ }\r
+\r
+ /**\r
+ Set "-F FvinfFile" argument\r
+\r
+ @param fvinfFile The path of fv.inf file\r
+ **/\r
+ public void setFvInfFile(String fvinfFile) {\r
+ this.fvinfFile.setArg(" -F ", fvinfFile);\r
+ }\r
+\r
/**\r
Get the value of map file\r
\r