]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFv/GenFv.c
Sync EDKII BaseTools to BaseTools project r1971
[mirror_edk2.git] / BaseTools / Source / C / GenFv / GenFv.c
index 135c9ed23f8e3335b0518739a6c92ef3b7450cfc..2cb8771b31b5f9762f3bacb43d4639dc40dc8904 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 \r
-Copyright (c) 2007 - 2009, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -40,7 +40,7 @@ Abstract:
 //\r
 #define UTILITY_MAJOR_VERSION 0\r
 #define UTILITY_MINOR_VERSION 1\r
-#define GENFV_UPDATE_TIME           " updated on 2008/11/21"\r
+#define GENFV_UPDATE_TIME           " updated on 2010/2/1"\r
 \r
 EFI_GUID  mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
 \r
@@ -97,7 +97,7 @@ Returns:
   //\r
   // Copyright declaration\r
   // \r
-  fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");\r
+  fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");\r
 \r
   //\r
   // Details Option\r
@@ -126,11 +126,8 @@ Returns:
                         run in Flash. It supports DEC or HEX digital format.\n\\r
                         If it is set to zero, no rebase action will be taken\n");\r
   fprintf (stdout, "  -a AddressFile, --addrfile AddressFile\n\\r
-                        AddressFile is one file used to record boot driver base\n\\r
-                        address and runtime driver base address. And this tool\n\\r
-                        will update these two addresses after it relocates all\n\\r
-                        boot drivers and runtime drivers in this fv iamge to\n\\r
-                        the preferred loaded memory address.\n");\r
+                        AddressFile is one file used to record the child\n\\r
+                        FV base address when current FV base address is set.\n");\r
   fprintf (stdout, "  -m logfile, --map logfile\n\\r
                         Logfile is the output fv map file name. if it is not\n\\r
                         given, the FvName.map will be the default map file name\n"); \r
@@ -194,10 +191,8 @@ Returns:
   CHAR8                 *InfFileImage;\r
   UINT32                InfFileSize;\r
   CHAR8                 *OutFileName;\r
-  CHAR8                 ValueString[_MAX_PATH];\r
   BOOLEAN               CapsuleFlag;\r
   BOOLEAN               DumpCapsule;\r
-  MEMORY_FILE           AddrMemoryFile;\r
   FILE                  *FpFile;\r
   EFI_CAPSULE_HEADER    *CapsuleHeader;\r
   UINT64                LogLevel, TempNumber;\r
@@ -545,62 +540,6 @@ Returns:
     VerboseMsg ("the output file name is %s", OutFileName);\r
   }\r
   \r
-  //\r
-  // Read boot and runtime address from address file\r
-  //\r
-  if (AddrFileName != NULL) {\r
-    VerboseMsg ("the input address file name is %s", AddrFileName);\r
-    Status = GetFileImage (AddrFileName, &InfFileImage, &InfFileSize);\r
-    if (EFI_ERROR (Status)) {\r
-      return STATUS_ERROR;\r
-    }\r
-\r
-    AddrMemoryFile.FileImage           = InfFileImage;\r
-    AddrMemoryFile.CurrentFilePointer  = InfFileImage;\r
-    AddrMemoryFile.Eof                 = InfFileImage + InfFileSize;\r
-\r
-    //\r
-    // Read the boot driver base address for this FV image\r
-    //\r
-    Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Get the base address\r
-      //\r
-      Status = AsciiStringToUint64 (ValueString, FALSE, &TempNumber);\r
-      if (EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 2000, "Invalid parameter", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
-        return STATUS_ERROR;\r
-      }\r
-      mFvDataInfo.BootBaseAddress = TempNumber;\r
-      DebugMsg (NULL, 0, 9, "Boot driver base address", "%s = %s", EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
-    }\r
-  \r
-    //\r
-    // Read the FV runtime driver base address\r
-    //\r
-    Status = FindToken (&AddrMemoryFile, OPTIONS_SECTION_STRING, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, 0, ValueString);\r
-    if (Status == EFI_SUCCESS) {\r
-      //\r
-      // Get the base address\r
-      //\r
-      Status = AsciiStringToUint64 (ValueString, FALSE, &TempNumber);\r
-      if (EFI_ERROR (Status)) {\r
-        Error (NULL, 0, 2000, "Invalid parameter", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
-        return STATUS_ERROR;\r
-      }\r
-      mFvDataInfo.RuntimeBaseAddress = TempNumber;\r
-      DebugMsg (NULL, 0, 9, "Runtime driver base address", "%s = %s", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, ValueString);\r
-    }\r
-    \r
-    //\r
-    // free the allocated memory space for addr file.\r
-    //\r
-    free (InfFileImage);\r
-    InfFileImage = NULL;\r
-    InfFileSize  = 0;\r
-  }\r
-\r
   //\r
   // Read the INF file image\r
   //\r
@@ -683,32 +622,22 @@ Returns:
   //\r
   //  update boot driver address and runtime driver address in address file\r
   //\r
-  if (Status == EFI_SUCCESS && AddrFileName != NULL) {\r
+  if (Status == EFI_SUCCESS && AddrFileName != NULL && mFvBaseAddressNumber > 0) {\r
     FpFile = fopen (AddrFileName, "w");\r
     if (FpFile == NULL) {\r
       Error (NULL, 0, 0001, "Error opening file", AddrFileName);\r
       return STATUS_ERROR;\r
     }\r
-    fprintf (FpFile, OPTIONS_SECTION_STRING);\r
+    fprintf (FpFile, FV_BASE_ADDRESS_STRING);\r
     fprintf (FpFile, "\n");\r
-    if (mFvDataInfo.BootBaseAddress != 0) {\r
-      fprintf (FpFile, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING);\r
-      fprintf (\r
-        FpFile,\r
-        " = 0x%llx\n",\r
-        (unsigned long long)mFvDataInfo.BootBaseAddress\r
-        );\r
-      DebugMsg (NULL, 0, 9, "Updated boot driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.BootBaseAddress);\r
-    }\r
-    if (mFvDataInfo.RuntimeBaseAddress != 0) {\r
-      fprintf (FpFile, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING);\r
+    for (Index = 0; Index < mFvBaseAddressNumber; Index ++) {\r
       fprintf (\r
         FpFile,\r
-        " = 0x%llx\n",\r
-        (unsigned long long)mFvDataInfo.RuntimeBaseAddress\r
+        "0x%llx\n",\r
+        (unsigned long long)mFvBaseAddress[Index]\r
         );\r
-      DebugMsg (NULL, 0, 9, "Updated runtime driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.RuntimeBaseAddress);\r
     }\r
+    fflush (FpFile);\r
     fclose (FpFile);\r
   }\r
   \r