X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FVolInfo%2FVolInfo.c;h=428011ca046c5e1f7303fe5facb052e449be23ed;hb=HEAD;hp=2647cbb73a176c04b605f52ab661df272fa29438;hpb=a9b4ee43d31929fd616b06a301d2af6e0af7b647;p=mirror_edk2.git
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index 2647cbb73a..428011ca04 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1,14 +1,9 @@
/** @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.
+Copyright (c) 2022, Konstantin Aladyshev
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -49,6 +44,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
//
EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
+EFI_GUID gPeiAprioriFileNameGuid = { 0x1b45cc0a, 0x156a, 0x428a, { 0XAF, 0x62, 0x49, 0x86, 0x4d, 0xa0, 0xe6, 0xe6 }};
+EFI_GUID gAprioriGuid = { 0xFC510EE7, 0xFFDC, 0x11D4, { 0xBD, 0x41, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 }};
#define UTILITY_MAJOR_VERSION 1
#define UTILITY_MINOR_VERSION 0
@@ -57,15 +54,13 @@ EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid = EFI_CRC32_GUIDED_SECTIO
#define EFI_SECTION_ERROR EFIERR (100)
-#define MAX_BASENAME_LEN 60 // not good to hardcode, but let's be reasonable
-
//
// Structure to keep a list of guid-to-basenames
//
typedef struct _GUID_TO_BASENAME {
struct _GUID_TO_BASENAME *Next;
INT8 Guid[PRINTED_GUID_BUFFER_SIZE];
- INT8 BaseName[MAX_BASENAME_LEN];
+ INT8 BaseName[MAX_LINE_LEN];
} GUID_TO_BASENAME;
static GUID_TO_BASENAME *mGuidBaseNameList = NULL;
@@ -115,6 +110,12 @@ ReadHeader (
OUT BOOLEAN *ErasePolarity
);
+STATIC
+EFI_STATUS
+PrintAprioriFile (
+ EFI_FFS_FILE_HEADER *FileHeader
+ );
+
STATIC
EFI_STATUS
PrintFileInfo (
@@ -331,7 +332,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 +542,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 +601,7 @@ Returns:
//
// 0x02
//
- "EFI_SECTION_GUID_DEFINED",
+ "EFI_SECTION_GUID_DEFINED",
//
// 0x03
//
@@ -661,11 +665,11 @@ Returns:
//
// 0x12
//
- "EFI_SECTION_TE",
+ "EFI_SECTION_TE",
//
// 0x13
//
- "EFI_SECTION_DXE_DEPEX",
+ "EFI_SECTION_DXE_DEPEX",
//
// 0x14
//
@@ -681,11 +685,11 @@ Returns:
//
// 0x17
//
- "EFI_SECTION_FIRMWARE_VOLUME_IMAGE ",
+ "EFI_SECTION_FIRMWARE_VOLUME_IMAGE",
//
// 0x18
//
- "EFI_SECTION_FREEFORM_SUBTYPE_GUID ",
+ "EFI_SECTION_FREEFORM_SUBTYPE_GUID",
//
// 0x19
//
@@ -701,7 +705,7 @@ Returns:
//
// 0x1C
//
- "EFI_SECTION_SMM_DEPEX",
+ "EFI_SECTION_MM_DEPEX",
//
// 0x1C+
//
@@ -732,7 +736,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 +744,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 +758,7 @@ Returns:
UINTN Signature[2];
UINTN BytesRead;
UINT32 Size;
+ size_t ReadSize;
BytesRead = 0;
Size = 0;
@@ -767,7 +772,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 +899,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 +918,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 +1058,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 +1078,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;
}
@@ -1087,6 +1092,53 @@ Returns:
return EFI_SUCCESS;
}
+STATIC
+EFI_STATUS
+PrintAprioriFile (
+ EFI_FFS_FILE_HEADER *FileHeader
+ )
+/*++
+
+Routine Description:
+
+ Print GUIDs from the APRIORI file
+
+Arguments:
+
+ FileHeader - The file header
+
+Returns:
+
+ EFI_SUCCESS - The APRIORI file was parsed correctly
+ EFI_SECTION_ERROR - Problem with file parsing
+
+--*/
+{
+ UINT8 GuidBuffer[PRINTED_GUID_BUFFER_SIZE];
+ UINT32 HeaderSize;
+
+ HeaderSize = FvBufGetFfsHeaderSize (FileHeader);
+
+ if (FileHeader->Type != EFI_FV_FILETYPE_FREEFORM)
+ return EFI_SECTION_ERROR;
+
+ EFI_COMMON_SECTION_HEADER* SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) FileHeader + HeaderSize);
+ if (SectionHeader->Type != EFI_SECTION_RAW)
+ return EFI_SECTION_ERROR;
+
+ UINT32 SectionLength = GetSectionFileLength (SectionHeader);
+ EFI_GUID* FileName = (EFI_GUID *) ((UINT8 *) SectionHeader + sizeof (EFI_COMMON_SECTION_HEADER));
+ while (((UINT8 *) FileName) < ((UINT8 *) SectionHeader + SectionLength)) {
+ PrintGuidToBuffer (FileName, GuidBuffer, sizeof (GuidBuffer), TRUE);
+ printf ("%s ", GuidBuffer);
+ PrintGuidName (GuidBuffer);
+ printf ("\n");
+ FileName++;
+ }
+
+ return EFI_SUCCESS;
+}
+
STATIC
EFI_STATUS
PrintFileInfo (
@@ -1120,7 +1172,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 +1274,7 @@ Returns:
return EFI_ABORTED;
}
}
-#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
//
// Verify tail if present
//
@@ -1237,7 +1289,7 @@ Returns:
return EFI_ABORTED;
}
}
- #endif
+ #endif
break;
default:
@@ -1286,7 +1338,7 @@ Returns:
break;
case EFI_FV_FILETYPE_SMM:
- printf ("EFI_FV_FILETYPE_SMM\n");
+ printf ("EFI_FV_FILETYPE_MM\n");
break;
case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
@@ -1294,11 +1346,19 @@ Returns:
break;
case EFI_FV_FILETYPE_COMBINED_SMM_DXE:
- printf ("EFI_FV_FILETYPE_COMBINED_SMM_DXE\n");
+ printf ("EFI_FV_FILETYPE_COMBINED_MM_DXE\n");
break;
case EFI_FV_FILETYPE_SMM_CORE:
- printf ("EFI_FV_FILETYPE_SMM_CORE\n");
+ printf ("EFI_FV_FILETYPE_MM_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:
@@ -1335,6 +1395,25 @@ Returns:
break;
}
+ if (!CompareGuid (
+ &FileHeader->Name,
+ &gPeiAprioriFileNameGuid
+ ))
+ {
+ printf("\n");
+ printf("PEI APRIORI FILE:\n");
+ return PrintAprioriFile (FileHeader);
+ }
+ if (!CompareGuid (
+ &FileHeader->Name,
+ &gAprioriGuid
+ ))
+ {
+ printf("\n");
+ printf("DXE APRIORI FILE:\n");
+ return PrintAprioriFile (FileHeader);
+ }
+
return EFI_SUCCESS;
}
@@ -1562,7 +1641,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;
@@ -1590,10 +1669,13 @@ CombinePath (
)
{
UINT32 DefaultPathLen;
+ UINT64 Index;
+ CHAR8 QuotesStr[] = "\"";
+ strcpy(NewPath, QuotesStr);
DefaultPathLen = strlen(DefaultPath);
- strcpy(NewPath, DefaultPath);
- UINT64 Index = 0;
- for (; Index < DefaultPathLen; Index ++) {
+ strcat(NewPath, DefaultPath);
+ Index = 0;
+ for (; Index < DefaultPathLen + 1; Index ++) {
if (NewPath[Index] == '\\' || NewPath[Index] == '/') {
if (NewPath[Index + 1] != '\0') {
NewPath[Index] = '/';
@@ -1605,6 +1687,7 @@ CombinePath (
NewPath[Index + 1] = '\0';
}
strcat(NewPath, AppendPath);
+ strcat(NewPath, QuotesStr);
return EFI_SUCCESS;
}
@@ -1628,7 +1711,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.
@@ -1666,6 +1749,7 @@ Returns:
CHAR8 *ToolInputFileName;
CHAR8 *ToolOutputFileName;
CHAR8 *UIFileName;
+ CHAR8 *VersionString;
ParsedLength = 0;
ToolInputFileName = NULL;
@@ -1785,20 +1869,30 @@ Returns:
break;
case EFI_SECTION_FIRMWARE_VOLUME_IMAGE:
+ printf ("/------------ Firmware Volume section start ---------------\\\n");
Status = PrintFvInfo (Ptr + SectionHeaderLen, TRUE);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0003, "printing of FV section contents failed", NULL);
return EFI_SECTION_ERROR;
}
+ printf ("\\------------ Firmware Volume section end -----------------/\n");
break;
case EFI_SECTION_COMPATIBILITY16:
- case EFI_SECTION_FREEFORM_SUBTYPE_GUID:
//
// Section does not contain any further header information.
//
break;
+ case EFI_SECTION_FREEFORM_SUBTYPE_GUID:
+ printf (" Guid: ");
+ if (SectionHeaderLen == sizeof (EFI_COMMON_SECTION_HEADER))
+ PrintGuid (&((EFI_FREEFORM_SUBTYPE_GUID_SECTION *)Ptr)->SubTypeGuid);
+ else
+ PrintGuid (&((EFI_FREEFORM_SUBTYPE_GUID_SECTION2 *)Ptr)->SubTypeGuid);
+ printf ("\n");
+ break;
+
case EFI_SECTION_PEI_DEPEX:
case EFI_SECTION_DXE_DEPEX:
case EFI_SECTION_SMM_DEPEX:
@@ -1806,8 +1900,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:
@@ -1886,7 +1986,9 @@ Returns:
return EFI_SECTION_ERROR;
}
+ printf ("/------------ Encapsulation section start -----------------\\\n");
Status = ParseSection (UncompressedBuffer, UncompressedLength);
+ printf ("\\------------ Encapsulation section end -------------------/\n");
if (CompressionType == EFI_STANDARD_COMPRESSION) {
//
@@ -1980,11 +2082,18 @@ Returns:
);
free (ExtractionTool);
+ if (!CompareGuid (
+ EfiGuid,
+ &gEfiCrc32GuidedSectionExtractionProtocolGuid
+ )
+ ) {
+ DataOffset -= 4;
+ }
Status =
PutFileImage (
ToolInputFile,
- (CHAR8*) SectionBuffer + DataOffset,
- BufferLength - DataOffset
+ (CHAR8*)Ptr + DataOffset,
+ SectionLength - DataOffset
);
system (SystemCommand);
@@ -2005,6 +2114,7 @@ Returns:
return EFI_SECTION_ERROR;
}
+ printf ("/------------ Encapsulation section start -----------------\\\n");
Status = ParseSection (
ToolOutputBuffer,
ToolOutputLength
@@ -2013,6 +2123,7 @@ Returns:
Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", NULL);
return EFI_SECTION_ERROR;
}
+ printf ("\\------------ Encapsulation section end -------------------/\n");
//
// Check for CRC32 sections which we can handle internally if needed.
@@ -2025,14 +2136,16 @@ Returns:
//
// CRC32 guided section
//
+ printf ("/------------ Encapsulation section start -----------------\\\n");
Status = ParseSection (
- SectionBuffer + DataOffset,
- BufferLength - DataOffset
+ Ptr + DataOffset,
+ SectionLength - DataOffset
);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 0003, "parse of CRC32 GUIDED section failed", NULL);
return EFI_SECTION_ERROR;
}
+ printf ("\\------------ Encapsulation section end -------------------/\n");
} else {
//
// We don't know how to parse it now.
@@ -2377,8 +2490,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");
//