]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFv/GenFv.c
Sync BaseTools Branch (version r2321) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / C / GenFv / GenFv.c
index f2ff2d29cd00ce503342653e976c16f1dfcfb43c..8f452c7374f6765a58daabc10316312937d3b2ea 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,6 @@ Abstract:
 //\r
 #define UTILITY_MAJOR_VERSION 0\r
 #define UTILITY_MINOR_VERSION 1\r
-#define GENFV_UPDATE_TIME           " updated on 2008/11/21"\r
 \r
 EFI_GUID  mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;\r
 \r
@@ -65,7 +64,7 @@ Returns:
 \r
 --*/\r
 {\r
-  fprintf (stdout, "%s Version %d.%d %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, GENFV_UPDATE_TIME);\r
+  fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);\r
 }\r
 \r
 STATIC\r
@@ -97,7 +96,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,19 +125,16 @@ 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
-  fprintf (stdout, "  -g Guid, --guid GuidValue\n\\r
+  fprintf (stdout, "  -g Guid, --guid Guid\n\\r
                         GuidValue is one specific capsule guid value\n\\r
                         or fv file system guid value.\n\\r
                         Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");\r
-  fprintf (stdout, "  --FvNameGuid          GuidValue is the Fv Name Guid value.\n\\r
+  fprintf (stdout, "  --FvNameGuid Guid     Guid is used to specify Fv Name.\n\\r
                         Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");\r
   fprintf (stdout, "  --capflag CapFlag     Capsule Reset Flag can be PersistAcrossReset,\n\\r
                         or PopulateSystemTable or InitiateReset or not set\n");\r
@@ -194,10 +190,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 +539,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 +621,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