mirror of https://github.com/acidanthera/audk.git
Enhance peirebase tool to get base address from the corresponding fv.inf file, which don't need one base address parameter for this tool any longer. We can reduce base address duplicated definition in fv.inf and fpd file.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1986 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
e5d3db39cb
commit
4c50c88544
|
@ -215,6 +215,11 @@ Returns:
|
|||
&SymFileName
|
||||
);
|
||||
|
||||
//
|
||||
// free InfFileImage memory
|
||||
//
|
||||
free (InfFileImage);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
switch (Status) {
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1379,7 +1379,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
<element name="EXTRA.ARG" optional="yes"/>
|
||||
|
||||
<sequential>
|
||||
<mkdir dir="${MODULE_DIR}/@{FILEPATH}" />
|
||||
<copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}"
|
||||
tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>
|
||||
</sequential>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue