]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Enhance peirebase tool to get base address from the corresponding fv.inf file, which...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Nov 2006 09:29:14 +0000 (09:29 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Nov 2006 09:29:14 +0000 (09:29 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1986 6f19259b-4bc3-4df7-8a09-765794883524

Tools/CCode/Source/GenFvImage/GenFvImageExe.c
Tools/CCode/Source/PeiRebase/PeiRebaseExe.c
Tools/Conf/BuildMacro.xml
Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java

index ce56299f1f5a1ddea9499d3a698a769537529780..f5a5179559dba5af32c71448ad335559c2e3aedb 100644 (file)
@@ -215,6 +215,11 @@ Returns:
             &SymFileName\r
             );\r
 \r
+  //\r
+  // free InfFileImage memory\r
+  //\r
+  free (InfFileImage);\r
+\r
   if (EFI_ERROR (Status)) {\r
     switch (Status) {\r
 \r
index 27c646e486fab1b86699270498f41ec2e0fe001b..d27083aceb5acbc0072705cc79539f82bb5f959c 100644 (file)
@@ -100,6 +100,10 @@ Returns:
   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
@@ -129,6 +133,9 @@ Returns:
   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
@@ -194,6 +201,52 @@ Returns:
       }\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
@@ -212,7 +265,7 @@ Returns:
       break;\r
     }\r
   }\r
-\r
+  \r
   //\r
   // Create the Map file if we need it\r
   //\r
@@ -486,15 +539,18 @@ Returns:
 --*/\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
index 45c7ddc32bea2b3c3542f83d0a44e10b6231a840..29edaaf540f0c608ae91fe05e627ec78b7f462a0 100644 (file)
@@ -1379,7 +1379,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     <element name="EXTRA.ARG" optional="yes"/>\r
 \r
     <sequential>\r
-      <mkdir dir="${MODULE_DIR}/@{FILEPATH}" /> \r
       <copy file="${MODULE_DIR}/@{FILEPATH}/@{FILENAME}.@{FILEEXT}" \r
             tofile="${DEST_DIR_OUTPUT}/@{FILEPATH}/@{FILENAME}.bin"/>\r
     </sequential>\r
index 1f8a4d1f3c899286a0b07d4b3496173994c91ec4..07154921d22564404f9104418ea0242a3e96bad8 100644 (file)
@@ -50,7 +50,11 @@ public class PeiReBaseTask extends Task implements EfiDefine {
     //\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
@@ -99,7 +103,7 @@ public class PeiReBaseTask extends Task implements EfiDefine {
         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
@@ -234,6 +238,24 @@ public class PeiReBaseTask extends Task implements EfiDefine {
         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