diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-20 09:29:14 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-11-20 09:29:14 +0000 |
commit | 4c50c885441c6406bb8a82f8b4e6106ce0706544 (patch) | |
tree | c12b62fddfc836c63f4ab26d46126fa4fc3f4efc /Tools/CCode/Source | |
parent | e5d3db39cb679f0b7f4e786e32df031b90c964f9 (diff) | |
download | edk2-platforms-4c50c885441c6406bb8a82f8b4e6106ce0706544.tar.xz |
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
Diffstat (limited to 'Tools/CCode/Source')
-rw-r--r-- | Tools/CCode/Source/GenFvImage/GenFvImageExe.c | 5 | ||||
-rw-r--r-- | Tools/CCode/Source/PeiRebase/PeiRebaseExe.c | 68 |
2 files changed, 67 insertions, 6 deletions
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
|