X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FVolInfo%2FVolInfo.c;h=ed56587058f74319dad55778fe61ef796cf05981;hb=fca5de51e1fd2f3c5ddbf5974d785f0f6b2f6c38;hp=eff5f9ebfc436faf417b6cedd6b0293be2237dcc;hpb=8994d2f95cc77a09a37e87ad6e4e4858615c3b9e;p=mirror_edk2.git
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index eff5f9ebfc..ed56587058 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1,14 +1,8 @@
/** @file
The tool dumps the contents of a firmware volume
-Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.
-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
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -331,7 +325,10 @@ Returns:
if (OpenSslEnv == NULL) {
OpenSslPath = OpenSslCommand;
} else {
- OpenSslPath = malloc(strlen(OpenSslEnv)+strlen(OpenSslCommand)+1);
+ //
+ // We add quotes to the Openssl Path in case it has space characters
+ //
+ OpenSslPath = malloc(2+strlen(OpenSslEnv)+strlen(OpenSslCommand)+1);
if (OpenSslPath == NULL) {
Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
return GetUtilityStatus ();
@@ -538,16 +535,16 @@ GetOccupiedSize (
Routine Description:
- This function returns the next larger size that meets the alignment
+ This function returns the next larger size that meets the alignment
requirement specified.
Arguments:
ActualSize The size.
Alignment The desired alignment.
-
+
Returns:
-
+
EFI_SUCCESS Function completed successfully.
EFI_ABORTED The function encountered an error.
@@ -597,7 +594,7 @@ Returns:
//
// 0x02
//
- "EFI_SECTION_GUID_DEFINED",
+ "EFI_SECTION_GUID_DEFINED",
//
// 0x03
//
@@ -661,11 +658,11 @@ Returns:
//
// 0x12
//
- "EFI_SECTION_TE",
+ "EFI_SECTION_TE",
//
// 0x13
//
- "EFI_SECTION_DXE_DEPEX",
+ "EFI_SECTION_DXE_DEPEX",
//
// 0x14
//
@@ -732,7 +729,7 @@ ReadHeader (
Routine Description:
- This function determines the size of the FV and the erase polarity. The
+ This function determines the size of the FV and the erase polarity. The
erase polarity is the FALSE value for file state.
Arguments:
@@ -740,9 +737,9 @@ Arguments:
InputFile The file that contains the FV image.
FvSize The size of the FV.
ErasePolarity The FV erase polarity.
-
+
Returns:
-
+
EFI_SUCCESS Function completed successfully.
EFI_INVALID_PARAMETER A required parameter was NULL or is out of range.
EFI_ABORTED The function encountered an error.
@@ -754,6 +751,7 @@ Returns:
UINTN Signature[2];
UINTN BytesRead;
UINT32 Size;
+ size_t ReadSize;
BytesRead = 0;
Size = 0;
@@ -767,7 +765,10 @@ Returns:
//
// Read the header
//
- fread (&VolumeHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);
+ ReadSize = fread (&VolumeHeader, sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);
+ if (ReadSize != 1) {
+ return EFI_ABORTED;
+ }
BytesRead = sizeof (EFI_FIRMWARE_VOLUME_HEADER) - sizeof (EFI_FV_BLOCK_MAP_ENTRY);
Signature[0] = VolumeHeader.Signature;
Signature[1] = 0;
@@ -891,7 +892,7 @@ Returns:
if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_64K) {
printf (" EFI_FVB2_ALIGNMENT_64K\n");
}
-
+
#else
if (VolumeHeader.Attributes & EFI_FVB2_READ_LOCK_CAP) {
@@ -910,140 +911,134 @@ Returns:
printf (" EFI_FVB2_WRITE_LOCK_STATUS\n");
}
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1) {
+ switch (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT) {
+ case EFI_FVB2_ALIGNMENT_1:
printf (" EFI_FVB2_ALIGNMENT_1\n");
- }
-
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_2) {
- printf (" EFI_FVB2_ALIGNMENT_2\n");
- }
-
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_4) {
- printf (" EFI_FVB2_ALIGNMENT_4\n");
- }
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_8) {
- printf (" EFI_FVB2_ALIGNMENT_8\n");
- }
+ case EFI_FVB2_ALIGNMENT_2:
+ printf (" EFI_FVB2_ALIGNMENT_2\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_16) {
- printf (" EFI_FVB2_ALIGNMENT_16\n");
- }
+ case EFI_FVB2_ALIGNMENT_4:
+ printf (" EFI_FVB2_ALIGNMENT_4\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_32) {
- printf (" EFI_FVB2_ALIGNMENT_32\n");
- }
+ case EFI_FVB2_ALIGNMENT_8:
+ printf (" EFI_FVB2_ALIGNMENT_8\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_64) {
- printf (" EFI_FVB2_ALIGNMENT_64\n");
- }
+ case EFI_FVB2_ALIGNMENT_16:
+ printf (" EFI_FVB2_ALIGNMENT_16\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_128) {
- printf (" EFI_FVB2_ALIGNMENT_128\n");
- }
+ case EFI_FVB2_ALIGNMENT_32:
+ printf (" EFI_FVB2_ALIGNMENT_32\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_256) {
- printf (" EFI_FVB2_ALIGNMENT_256\n");
- }
+ case EFI_FVB2_ALIGNMENT_64:
+ printf (" EFI_FVB2_ALIGNMENT_64\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_512) {
- printf (" EFI_FVB2_ALIGNMENT_512\n");
- }
+ case EFI_FVB2_ALIGNMENT_128:
+ printf (" EFI_FVB2_ALIGNMENT_128\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1K) {
- printf (" EFI_FVB2_ALIGNMENT_1K\n");
- }
+ case EFI_FVB2_ALIGNMENT_256:
+ printf (" EFI_FVB2_ALIGNMENT_256\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_2K) {
- printf (" EFI_FVB2_ALIGNMENT_2K\n");
- }
+ case EFI_FVB2_ALIGNMENT_512:
+ printf (" EFI_FVB2_ALIGNMENT_512\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_4K) {
- printf (" EFI_FVB2_ALIGNMENT_4K\n");
- }
+ case EFI_FVB2_ALIGNMENT_1K:
+ printf (" EFI_FVB2_ALIGNMENT_1K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_8K) {
- printf (" EFI_FVB2_ALIGNMENT_8K\n");
- }
+ case EFI_FVB2_ALIGNMENT_2K:
+ printf (" EFI_FVB2_ALIGNMENT_2K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_16K) {
- printf (" EFI_FVB2_ALIGNMENT_16K\n");
- }
+ case EFI_FVB2_ALIGNMENT_4K:
+ printf (" EFI_FVB2_ALIGNMENT_4K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_32K) {
- printf (" EFI_FVB2_ALIGNMENT_32K\n");
- }
+ case EFI_FVB2_ALIGNMENT_8K:
+ printf (" EFI_FVB2_ALIGNMENT_8K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_64K) {
- printf (" EFI_FVB2_ALIGNMENT_64K\n");
- }
+ case EFI_FVB2_ALIGNMENT_16K:
+ printf (" EFI_FVB2_ALIGNMENT_16K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_128K) {
- printf (" EFI_FVB2_ALIGNMENT_128K\n");
- }
+ case EFI_FVB2_ALIGNMENT_32K:
+ printf (" EFI_FVB2_ALIGNMENT_32K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_256K) {
- printf (" EFI_FVB2_ALIGNMENT_256K\n");
- }
+ case EFI_FVB2_ALIGNMENT_64K:
+ printf (" EFI_FVB2_ALIGNMENT_64K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_512K) {
- printf (" EFI_FVB2_ALIGNMENT_512K\n");
- }
+ case EFI_FVB2_ALIGNMENT_128K:
+ printf (" EFI_FVB2_ALIGNMENT_128K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1M) {
- printf (" EFI_FVB2_ALIGNMENT_1M\n");
- }
+ case EFI_FVB2_ALIGNMENT_256K:
+ printf (" EFI_FVB2_ALIGNMENT_256K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_2M) {
- printf (" EFI_FVB2_ALIGNMENT_2M\n");
- }
+ case EFI_FVB2_ALIGNMENT_512K:
+ printf (" EFI_FVB2_ALIGNMENT_512K\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_4M) {
- printf (" EFI_FVB2_ALIGNMENT_4M\n");
- }
+ case EFI_FVB2_ALIGNMENT_1M:
+ printf (" EFI_FVB2_ALIGNMENT_1M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_8M) {
- printf (" EFI_FVB2_ALIGNMENT_8M\n");
- }
+ case EFI_FVB2_ALIGNMENT_2M:
+ printf (" EFI_FVB2_ALIGNMENT_2M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_16M) {
- printf (" EFI_FVB2_ALIGNMENT_16M\n");
- }
+ case EFI_FVB2_ALIGNMENT_4M:
+ printf (" EFI_FVB2_ALIGNMENT_4M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_32M) {
- printf (" EFI_FVB2_ALIGNMENT_32M\n");
- }
+ case EFI_FVB2_ALIGNMENT_8M:
+ printf (" EFI_FVB2_ALIGNMENT_8M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_64M) {
- printf (" EFI_FVB2_ALIGNMENT_64M\n");
- }
+ case EFI_FVB2_ALIGNMENT_16M:
+ printf (" EFI_FVB2_ALIGNMENT_16M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_128M) {
- printf (" EFI_FVB2_ALIGNMENT_128M\n");
- }
+ case EFI_FVB2_ALIGNMENT_32M:
+ printf (" EFI_FVB2_ALIGNMENT_32M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_64M) {
- printf (" EFI_FVB2_ALIGNMENT_64M\n");
- }
+ case EFI_FVB2_ALIGNMENT_64M:
+ printf (" EFI_FVB2_ALIGNMENT_64M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_128M) {
- printf (" EFI_FVB2_ALIGNMENT_128M\n");
- }
+ case EFI_FVB2_ALIGNMENT_128M:
+ printf (" EFI_FVB2_ALIGNMENT_128M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_256M) {
- printf (" EFI_FVB2_ALIGNMENT_256M\n");
- }
+ case EFI_FVB2_ALIGNMENT_256M:
+ printf (" EFI_FVB2_ALIGNMENT_256M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_512M) {
- printf (" EFI_FVB2_ALIGNMENT_512M\n");
- }
+ case EFI_FVB2_ALIGNMENT_512M:
+ printf (" EFI_FVB2_ALIGNMENT_512M\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_1G) {
- printf (" EFI_FVB2_ALIGNMENT_1G\n");
- }
+ case EFI_FVB2_ALIGNMENT_1G:
+ printf (" EFI_FVB2_ALIGNMENT_1G\n");
+ break;
- if (VolumeHeader.Attributes & EFI_FVB2_ALIGNMENT_2G) {
- printf (" EFI_FVB2_ALIGNMENT_2G\n");
+ case EFI_FVB2_ALIGNMENT_2G:
+ printf (" EFI_FVB2_ALIGNMENT_2G\n");
+ break;
}
#endif
@@ -1056,7 +1051,10 @@ Returns:
printf ("Revision: 0x%04X\n", VolumeHeader.Revision);
do {
- fread (&BlockMap, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);
+ ReadSize = fread (&BlockMap, sizeof (EFI_FV_BLOCK_MAP_ENTRY), 1, InputFile);
+ if (ReadSize != 1) {
+ return EFI_ABORTED;
+ }
BytesRead += sizeof (EFI_FV_BLOCK_MAP_ENTRY);
if (BlockMap.NumBlocks != 0) {
@@ -1073,7 +1071,7 @@ Returns:
}
if (VolumeHeader.FvLength != Size) {
- printf ("ERROR: Volume Size not consistant with Block Maps!\n");
+ printf ("ERROR: Volume Size not consistent with Block Maps!\n");
return EFI_ABORTED;
}
@@ -1120,7 +1118,7 @@ Returns:
EFI_STATUS Status;
UINT8 GuidBuffer[PRINTED_GUID_BUFFER_SIZE];
UINT32 HeaderSize;
-#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
UINT16 *Tail;
#endif
//
@@ -1222,7 +1220,7 @@ Returns:
return EFI_ABORTED;
}
}
-#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
//
// Verify tail if present
//
@@ -1237,7 +1235,7 @@ Returns:
return EFI_ABORTED;
}
}
- #endif
+ #endif
break;
default:
@@ -1301,6 +1299,14 @@ Returns:
printf ("EFI_FV_FILETYPE_SMM_CORE\n");
break;
+ case EFI_FV_FILETYPE_MM_STANDALONE:
+ printf ("EFI_FV_FILETYPE_MM_STANDALONE\n");
+ break;
+
+ case EFI_FV_FILETYPE_MM_CORE_STANDALONE:
+ printf ("EFI_FV_FILETYPE_MM_CORE_STANDALONE\n");
+ break;
+
case EFI_FV_FILETYPE_FFS_PAD:
printf ("EFI_FV_FILETYPE_FFS_PAD\n");
break;
@@ -1562,7 +1568,7 @@ Returns:
//
// Update Image Base Address
//
- if ((ImgHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) && (ImgHdr->Pe32.FileHeader.Machine != IMAGE_FILE_MACHINE_IA64)) {
+ if (ImgHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
ImgHdr->Pe32.OptionalHeader.ImageBase = (UINT32) NewPe32BaseAddress;
} else if (ImgHdr->Pe32Plus.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress;
@@ -1591,11 +1597,12 @@ CombinePath (
{
UINT32 DefaultPathLen;
UINT64 Index;
-
+ CHAR8 QuotesStr[] = "\"";
+ strcpy(NewPath, QuotesStr);
DefaultPathLen = strlen(DefaultPath);
- strcpy(NewPath, DefaultPath);
+ strcat(NewPath, DefaultPath);
Index = 0;
- for (; Index < DefaultPathLen; Index ++) {
+ for (; Index < DefaultPathLen + 1; Index ++) {
if (NewPath[Index] == '\\' || NewPath[Index] == '/') {
if (NewPath[Index + 1] != '\0') {
NewPath[Index] = '/';
@@ -1607,6 +1614,7 @@ CombinePath (
NewPath[Index + 1] = '\0';
}
strcat(NewPath, AppendPath);
+ strcat(NewPath, QuotesStr);
return EFI_SUCCESS;
}
@@ -1630,7 +1638,7 @@ Returns:
EFI_SECTION_ERROR - Problem with section parsing.
(a) compression errors
- (b) unrecognized section
+ (b) unrecognized section
EFI_UNSUPPORTED - Do not know how to parse the section.
EFI_SUCCESS - Section successfully parsed.
EFI_OUT_OF_RESOURCES - Memory allocation failed.
@@ -1668,6 +1676,7 @@ Returns:
CHAR8 *ToolInputFileName;
CHAR8 *ToolOutputFileName;
CHAR8 *UIFileName;
+ CHAR8 *VersionString;
ParsedLength = 0;
ToolInputFileName = NULL;
@@ -1808,8 +1817,14 @@ Returns:
break;
case EFI_SECTION_VERSION:
- printf (" Build Number: 0x%02X\n", *(UINT16 *)(Ptr + SectionHeaderLen));
- printf (" Version Strg: %s\n", (char*) (Ptr + SectionHeaderLen + sizeof (UINT16)));
+ printf (" Build Number: 0x%04X\n", *(UINT16 *)(Ptr + SectionHeaderLen));
+ VersionString = (CHAR8 *) malloc (UnicodeStrLen (((EFI_VERSION_SECTION *) Ptr)->VersionString) + 1);
+ if (VersionString == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Unicode2AsciiString (((EFI_VERSION_SECTION *) Ptr)->VersionString, VersionString);
+ printf (" Version String: %s\n", VersionString);
break;
case EFI_SECTION_COMPRESSION:
@@ -2379,8 +2394,8 @@ Returns:
//
// Copyright declaration
- //
- fprintf (stdout, "Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.\n\n");
+ //
+ fprintf (stdout, "Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.\n\n");
fprintf (stdout, " Display Tiano Firmware Volume FFS image information\n\n");
//