]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/VolInfo/VolInfo.c
Sync BaseTool trunk (version r2423) into EDKII BaseTools. The change mainly includes:
[mirror_edk2.git] / BaseTools / Source / C / VolInfo / VolInfo.c
index 1df182e4d6ec7af207952a2a828abedb29b905c7..7d127e16915b453f1954a4106ea13bec41315a21 100644 (file)
@@ -1,7 +1,7 @@
 /** @file
 
-Copyright (c) 1999 - 2008, Intel Corporation
-All rights reserved. This program and the accompanying materials
+Copyright (c) 1999 - 2011, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
@@ -123,7 +123,8 @@ PrintFileInfo (
 static
 EFI_STATUS
 PrintFvInfo (
-  IN VOID                         *Fv
+  IN VOID                         *Fv,
+  IN BOOLEAN                      IsChildFv
   );
 
 static
@@ -164,17 +165,18 @@ Returns:
   EFI_FIRMWARE_VOLUME_HEADER  *FvImage;
   UINT32                      FvSize;
   EFI_STATUS                  Status;
-  UINT32                      Offset;
+  int                         Offset;
   BOOLEAN                     ErasePolarity;
 
   SetUtilityName (UTILITY_NAME);
   //
   // Print utility header
   //
-  printf ("%s Tiano Firmware Volume FFS image info.  Version %d.%d, %s\n",
+  printf ("%s Tiano Firmware Volume FFS image info.  Version %d.%d %s, %s\n",
     UTILITY_NAME,
     UTILITY_MAJOR_VERSION,
     UTILITY_MINOR_VERSION,
+    __BUILD_VERSION,
     __DATE__
     );
 
@@ -203,7 +205,7 @@ Returns:
       //
       // Hex or decimal?
       //
-      if ((argv[1][0] == '0') && (tolower (argv[1][1]) == 'x')) {
+      if ((argv[1][0] == '0') && (tolower ((int)argv[1][1]) == 'x')) {
         if (sscanf (argv[1], "%x", &Offset) != 1) {
           Error (NULL, 0, 1003, "Invalid option value", "Offset = %s", argv[1]);
           return GetUtilityStatus ();
@@ -216,7 +218,7 @@ Returns:
         //
         // See if they said something like "64K"
         //
-        if (tolower (argv[1][strlen (argv[1]) - 1]) == 'k') {
+        if (tolower ((int)argv[1][strlen (argv[1]) - 1]) == 'k') {
           Offset *= 1024;
         }
       }
@@ -291,7 +293,7 @@ Returns:
 
   LoadGuidedSectionToolsTxt (argv[0]);
 
-  PrintFvInfo (FvImage);
+  PrintFvInfo (FvImage, FALSE);
 
   //
   // Clean up
@@ -305,7 +307,8 @@ Returns:
 static
 EFI_STATUS
 PrintFvInfo (
-  IN VOID                         *Fv
+  IN VOID                         *Fv,
+  IN BOOLEAN                      IsChildFv
   )
 /*++
 
@@ -316,6 +319,7 @@ Routine Description:
 Arguments:
 
   Fv            - Firmware Volume to print information about
+  IsChildFv     - Flag specifies whether the input FV is a child FV.
 
 Returns:
 
@@ -375,7 +379,11 @@ Returns:
     }
   }
 
-  printf ("There are a total of %d files in this FV\n", (int) NumberOfFiles);
+  if (IsChildFv) {
+    printf ("There are a total of %d files in the child FV\n", (int) NumberOfFiles);
+  } else {
+    printf ("There are a total of %d files in this FV\n", (int) NumberOfFiles);
+  }
 
   return EFI_SUCCESS;
 }
@@ -437,122 +445,126 @@ Returns:
 {
   CHAR8 *SectionStr;
   CHAR8 *SectionTypeStringTable[] = {
-    "EFI_SECTION_ALL",
     //
     // 0X00
     //
-    "EFI_SECTION_COMPRESSION",
+    "EFI_SECTION_ALL",
     //
     // 0x01
     //
-    "EFI_SECTION_GUID_DEFINED",
+    "EFI_SECTION_COMPRESSION",
     //
     // 0x02
     //
-    "Unknown section type - Reserved 0x03",
+    "EFI_SECTION_GUID_DEFINED",    
     //
     // 0x03
     //
-    "Unknown section type - Reserved 0x04",
+    "Unknown section type - Reserved 0x03",
     //
     // 0x04
     //
-    "Unknown section type - Reserved 0x05",
+    "Unknown section type - Reserved 0x04",
     //
     // 0x05
     //
-    "Unknown section type - Reserved 0x06",
+    "Unknown section type - Reserved 0x05",
     //
     // 0x06
     //
-    "Unknown section type - Reserved 0x07",
+    "Unknown section type - Reserved 0x06",
     //
     // 0x07
     //
-    "Unknown section type - Reserved 0x08",
+    "Unknown section type - Reserved 0x07",
     //
     // 0x08
     //
-    "Unknown section type - Reserved 0x09",
+    "Unknown section type - Reserved 0x08",
     //
     // 0x09
     //
-    "Unknown section type - Reserved 0x0A",
+    "Unknown section type - Reserved 0x09",
     //
     // 0x0A
     //
-    "Unknown section type - Reserved 0x0B",
+    "Unknown section type - Reserved 0x0A",
     //
     // 0x0B
     //
-    "Unknown section type - Reserved 0x0C",
+    "Unknown section type - Reserved 0x0B",
     //
     // 0x0C
     //
-    "Unknown section type - Reserved 0x0D",
+    "Unknown section type - Reserved 0x0C",
     //
     // 0x0D
     //
-    "Unknown section type - Reserved 0x0E",
+    "Unknown section type - Reserved 0x0D",
     //
     // 0x0E
     //
-    "Unknown section type - Reserved 0x0F",
+    "Unknown section type - Reserved 0x0E",
     //
     // 0x0F
     //
-    "EFI_SECTION_PE32",
+    "Unknown section type - Reserved 0x0E",
     //
     // 0x10
     //
-    "EFI_SECTION_PIC",
+    "EFI_SECTION_PE32",
     //
     // 0x11
     //
-    "EFI_SECTION_TE",
+    "EFI_SECTION_PIC",
     //
     // 0x12
     //
-    "EFI_SECTION_DXE_DEPEX",
+    "EFI_SECTION_TE",    
     //
     // 0x13
     //
-    "EFI_SECTION_VERSION",
+    "EFI_SECTION_DXE_DEPEX", 
     //
     // 0x14
     //
-    "EFI_SECTION_USER_INTERFACE",
+    "EFI_SECTION_VERSION",
     //
     // 0x15
     //
-    "EFI_SECTION_COMPATIBILITY16",
+    "EFI_SECTION_USER_INTERFACE",
     //
     // 0x16
     //
-    "EFI_SECTION_FIRMWARE_VOLUME_IMAGE ",
+    "EFI_SECTION_COMPATIBILITY16",
     //
     // 0x17
     //
-    "EFI_SECTION_FREEFORM_SUBTYPE_GUID ",
+    "EFI_SECTION_FIRMWARE_VOLUME_IMAGE ",
     //
     // 0x18
     //
-    "EFI_SECTION_RAW",
+    "EFI_SECTION_FREEFORM_SUBTYPE_GUID ",
     //
     // 0x19
     //
-    "Unknown section type - 0x1A",
+    "EFI_SECTION_RAW",
     //
     // 0x1A
     //
-    "EFI_SECTION_PEI_DEPEX",
+    "Unknown section type - 0x1A",
     //
     // 0x1B
     //
-    "Unknown section type - Reserved - beyond last defined section"
+    "EFI_SECTION_PEI_DEPEX",
+    //
+    // 0x1C
+    //
+    "EFI_SECTION_SMM_DEPEX",
     //
     // 0x1C+
     //
+    "Unknown section type - Reserved - beyond last defined section"
   };
 
   if (Type > EFI_SECTION_LAST_SECTION_TYPE) {
@@ -622,8 +634,8 @@ Returns:
   //
   // Print FV header information
   //
-  printf ("Signature:        %s (%X)\n", (char *) Signature, VolumeHeader.Signature);
-  printf ("Attributes:       %X\n", VolumeHeader.Attributes);
+  printf ("Signature:        %s (%X)\n", (char *) Signature, (unsigned) VolumeHeader.Signature);
+  printf ("Attributes:       %X\n", (unsigned) VolumeHeader.Attributes);
 
   if (VolumeHeader.Attributes & EFI_FVB2_READ_DISABLED_CAP) {
     printf ("       EFI_FVB2_READ_DISABLED_CAP\n");
@@ -833,8 +845,8 @@ Returns:
     printf ("        EFI_FVB2_ALIGNMENT_256K\n");
   }
 
-  if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMNET_512K) {
-    printf ("        EFI_FVB2_ALIGNMNET_512K\n");
+  if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_512K) {
+    printf ("        EFI_FVB2_ALIGNMENT_512K\n");
   }
 
   if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1M) {
@@ -907,8 +919,8 @@ Returns:
     BytesRead += sizeof (EFI_FV_BLOCK_MAP_ENTRY);
 
     if (BlockMap.NumBlocks != 0) {
-      printf ("Number of Blocks:      0x%08X\n", BlockMap.NumBlocks);
-      printf ("Block Length:          0x%08X\n", BlockMap.Length);
+      printf ("Number of Blocks:      0x%08X\n", (unsigned) BlockMap.NumBlocks);
+      printf ("Block Length:          0x%08X\n", (unsigned) BlockMap.Length);
       Size += BlockMap.NumBlocks * BlockMap.Length;
     }
 
@@ -924,7 +936,7 @@ Returns:
     return EFI_ABORTED;
   }
 
-  printf ("Total Volume Size:     0x%08X\n", Size);
+  printf ("Total Volume Size:     0x%08X\n", (unsigned) Size);
 
   *FvSize = Size;
 
@@ -998,7 +1010,7 @@ Returns:
   //
   FileLength = GetLength (FileHeader->Size);
   printf ("File Offset:      0x%08X\n", (unsigned) ((UINTN) FileHeader - (UINTN) FvImage));
-  printf ("File Length:      0x%08X\n", FileLength);
+  printf ("File Length:      0x%08X\n", (unsigned) FileLength);
   printf ("File Attributes:  0x%02X\n", FileHeader->Attributes);
   printf ("File State:       0x%02X\n", FileHeader->State);
 
@@ -1055,15 +1067,15 @@ Returns:
       //
       // Calculate file checksum
       //
-      Checksum  = CalculateSum8 ((UINT8 *) FileHeader, FileLength);
-      Checksum  = (UINT8) (Checksum - FileHeader->State);
+      Checksum  = CalculateSum8 ((UINT8 *) (FileHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));
+      Checksum  = Checksum + FileHeader->IntegrityCheck.Checksum.File;
       if (Checksum != 0) {
         Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid file checksum", GuidBuffer);
         return EFI_ABORTED;
       }
     } else {
       if (FileHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
-        Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid header checksum -- not set to fixed value of 0x5A", GuidBuffer);
+        Error (NULL, 0, 0003, "error parsing FFS file", "FFS file with Guid %s has invalid header checksum -- not set to fixed value of 0xAA", GuidBuffer);
         return EFI_ABORTED;
       }
     }
@@ -1130,10 +1142,22 @@ Returns:
     printf ("EFI_FV_FILETYPE_APPLICATION\n");
     break;
 
+  case EFI_FV_FILETYPE_SMM:
+    printf ("EFI_FV_FILETYPE_SMM\n");
+    break;
+
   case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
     printf ("EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE\n");
     break;
 
+  case EFI_FV_FILETYPE_COMBINED_SMM_DXE:
+    printf ("EFI_FV_FILETYPE_COMBINED_SMM_DXE\n");
+    break;
+
+  case EFI_FV_FILETYPE_SMM_CORE:
+    printf ("EFI_FV_FILETYPE_SMM_CORE\n");
+    break;
+
   case EFI_FV_FILETYPE_FFS_PAD:
     printf ("EFI_FV_FILETYPE_FFS_PAD\n");
     break;
@@ -1242,7 +1266,7 @@ Returns:
 
     SectionName = SectionNameToStr (Type);
     printf ("------------------------------------------------------------\n");
-    printf ("  Type:  %s\n  Size:  0x%08X\n", SectionName, SectionLength);
+    printf ("  Type:  %s\n  Size:  0x%08X\n", SectionName, (unsigned) SectionLength);
     free (SectionName);
 
     switch (Type) {
@@ -1259,7 +1283,7 @@ Returns:
       break;
 
     case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
-      Status = PrintFvInfo (((EFI_FIRMWARE_VOLUME_IMAGE_SECTION*)Ptr) + 1);
+      Status = PrintFvInfo (((EFI_FIRMWARE_VOLUME_IMAGE_SECTION*)Ptr) + 1, TRUE);
       if (EFI_ERROR (Status)) {
         Error (NULL, 0, 0003, "printing of FV section contents failed", NULL);
         return EFI_SECTION_ERROR;
@@ -1273,8 +1297,9 @@ Returns:
       //
       break;
 
-    case EFI_SECTION_DXE_DEPEX:
     case EFI_SECTION_PEI_DEPEX:
+    case EFI_SECTION_DXE_DEPEX:
+    case EFI_SECTION_SMM_DEPEX:
       DumpDepexSection (Ptr, SectionLength);
       break;
 
@@ -1288,7 +1313,7 @@ Returns:
       CompressedLength    = SectionLength - sizeof (EFI_COMPRESSION_SECTION);
       UncompressedLength  = ((EFI_COMPRESSION_SECTION *) Ptr)->UncompressedLength;
       CompressionType     = ((EFI_COMPRESSION_SECTION *) Ptr)->CompressionType;
-      printf ("  Uncompressed Length:  0x%08X\n", UncompressedLength);
+      printf ("  Uncompressed Length:  0x%08X\n", (unsigned) UncompressedLength);
 
       if (CompressionType == EFI_NOT_COMPRESSED) {
         printf ("  Compression Type:  EFI_NOT_COMPRESSED\n");
@@ -1342,7 +1367,7 @@ Returns:
           return EFI_SECTION_ERROR;
         }
       } else {
-        Error (NULL, 0, 0003, "unrecognized compression type", "type 0x%X", (UINT32) CompressionType);
+        Error (NULL, 0, 0003, "unrecognized compression type", "type 0x%X", CompressionType);
         return EFI_SECTION_ERROR;
       }
 
@@ -1365,8 +1390,8 @@ Returns:
       printf ("  SectionDefinitionGuid:  ");
       PrintGuid (&((EFI_GUID_DEFINED_SECTION *) Ptr)->SectionDefinitionGuid);
       printf ("\n");
-      printf ("  DataOffset:             0x%04X\n", ((EFI_GUID_DEFINED_SECTION *) Ptr)->DataOffset);
-      printf ("  Attributes:             0x%04X\n", ((EFI_GUID_DEFINED_SECTION *) Ptr)->Attributes);
+      printf ("  DataOffset:             0x%04X\n", (unsigned) ((EFI_GUID_DEFINED_SECTION *) Ptr)->DataOffset);
+      printf ("  Attributes:             0x%04X\n", (unsigned) ((EFI_GUID_DEFINED_SECTION *) Ptr)->Attributes);
 
       ExtractionTool =
         LookupGuidedSectionToolPath (
@@ -1465,7 +1490,7 @@ Returns:
       //
       // Unknown section, return error
       //
-      Error (NULL, 0, 0003, "unrecognized section type found", "section type = 0x%X", (UINT32) Type);
+      Error (NULL, 0, 0003, "unrecognized section type found", "section type = 0x%X", Type);
       return EFI_SECTION_ERROR;
     }
 
@@ -1588,7 +1613,7 @@ Returns:
       break;
 
     default:
-      printf ("Unrecognized byte in depex: 0x%X\n", (UINT32) *Ptr);
+      printf ("Unrecognized byte in depex: 0x%X\n", *Ptr);
       return EFI_SUCCESS;
     }
   }
@@ -1732,11 +1757,14 @@ LoadGuidedSectionToolsTxt (
 {
   CHAR8* PeerFilename;
   CHAR8* Places[] = {
-    FirmwareVolumeFilename,
-    //mUtilityFilename,
+    NULL,
+    //NULL,
     };
   UINTN Index;
 
+  Places[0] = FirmwareVolumeFilename;
+  //Places[1] = mUtilityFilename;
+
   mParsedGuidedSectionTools = NULL;
 
   for (Index = 0; Index < (sizeof(Places)/sizeof(Places[0])); Index++) {
@@ -1781,7 +1809,7 @@ Returns:
   //
   // Copyright declaration
   // 
-  fprintf (stdout, "Copyright (c) 2007, Intel Corporation. All rights reserved.\n\n");
+  fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
 
   //
   // Details Option