diff options
author | Liming Gao <liming.gao@intel.com> | 2013-11-18 07:41:21 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2013-11-18 07:41:21 +0000 |
commit | e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d (patch) | |
tree | 04e3ec271347360a5e9da898f1dccbce3d94681f /BaseTools/Source/C | |
parent | fddbbc661eeff8e9f94942fa2d47fb637404a040 (diff) | |
download | edk2-platforms-e8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d.tar.xz |
Sync BaseTool trunk (version r2610) into EDKII BaseTools.
Signed-off-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14856 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C')
-rw-r--r-- | BaseTools/Source/C/Common/FvLib.c | 131 | ||||
-rw-r--r-- | BaseTools/Source/C/Common/FvLib.h | 26 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFfs/GenFfs.c | 65 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFv/GenFv.c | 23 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFv/GenFvInternalLib.c | 236 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFv/GenFvInternalLib.h | 6 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf32Convert.c | 20 | ||||
-rw-r--r-- | BaseTools/Source/C/GenFw/Elf64Convert.c | 19 | ||||
-rw-r--r-- | BaseTools/Source/C/GenSec/GenSec.c | 244 | ||||
-rw-r--r-- | BaseTools/Source/C/Include/Common/BuildVersion.h | 2 | ||||
-rw-r--r-- | BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 78 | ||||
-rw-r--r-- | BaseTools/Source/C/Include/Common/PiFirmwareVolume.h | 3 | ||||
-rw-r--r-- | BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h | 8 | ||||
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrSyntax.g | 34 | ||||
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 33 | ||||
-rw-r--r-- | BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 2 |
16 files changed, 715 insertions, 215 deletions
diff --git a/BaseTools/Source/C/Common/FvLib.c b/BaseTools/Source/C/Common/FvLib.c index 1b289d83cd..4758749dc3 100644 --- a/BaseTools/Source/C/Common/FvLib.c +++ b/BaseTools/Source/C/Common/FvLib.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -181,7 +181,7 @@ Returns: //
// Verify file is in this FV.
//
- if ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) {
+ if ((UINTN) CurrentFile + GetFfsFileLength(CurrentFile) > (UINTN) mFvHeader + mFvLength) {
*NextFile = NULL;
return EFI_SUCCESS;
}
@@ -194,20 +194,20 @@ Returns: // Verify current file is in range
//
if (((UINTN) CurrentFile < (UINTN) mFvHeader + mFvHeader->HeaderLength) ||
- ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength)
+ ((UINTN) CurrentFile + GetFfsFileLength(CurrentFile) > (UINTN) mFvHeader + mFvLength)
) {
return EFI_INVALID_PARAMETER;
}
//
// Get next file, compensate for 8 byte alignment if necessary.
//
- *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);
+ *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetFfsFileLength(CurrentFile) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);
//
// Verify file is in this FV.
//
- if (((UINTN) *NextFile + sizeof (EFI_FFS_FILE_HEADER) >= (UINTN) mFvHeader + mFvLength) ||
- ((UINTN) *NextFile + GetLength ((*NextFile)->Size) > (UINTN) mFvHeader + mFvLength)
+ if (((UINTN) *NextFile + GetFfsHeaderLength(*NextFile) >= (UINTN) mFvHeader + mFvLength) ||
+ ((UINTN) *NextFile + GetFfsFileLength (*NextFile) > (UINTN) mFvHeader + mFvLength)
) {
*NextFile = NULL;
return EFI_SUCCESS;
@@ -434,7 +434,11 @@ Returns: EFI_FILE_SECTION_POINTER InnerSection;
EFI_STATUS Status;
UINTN SectionSize;
+ UINT16 GuidSecAttr;
+ UINT16 GuidDataOffset;
+ GuidSecAttr = 0;
+ GuidDataOffset = 0;
CurrentSection = FirstSection;
while ((UINTN) CurrentSection.CommonHeader < (UINTN) SearchEnd) {
@@ -452,14 +456,21 @@ Returns: // special processing, go ahead to search the requesting
// section inside the GUID-defined section.
//
+ if (CurrentSection.CommonHeader->Type == EFI_SECTION_GUID_DEFINED) {
+ if (GetLength(CurrentSection.CommonHeader->Size) == 0xffffff) {
+ GuidSecAttr = CurrentSection.GuidDefinedSection2->Attributes;
+ GuidDataOffset = CurrentSection.GuidDefinedSection2->DataOffset;
+ } else {
+ GuidSecAttr = CurrentSection.GuidDefinedSection->Attributes;
+ GuidDataOffset = CurrentSection.GuidDefinedSection->DataOffset;
+ }
+ }
if (SectionType != EFI_SECTION_GUID_DEFINED &&
CurrentSection.CommonHeader->Type == EFI_SECTION_GUID_DEFINED &&
- !(CurrentSection.GuidDefinedSection->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED)) {
+ !(GuidSecAttr & EFI_GUIDED_SECTION_PROCESSING_REQUIRED)) {
InnerSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *)
- ((UINTN) CurrentSection.CommonHeader + CurrentSection.GuidDefinedSection->DataOffset);
- SectionSize = CurrentSection.CommonHeader->Size[0] +
- (CurrentSection.CommonHeader->Size[1] << 8) +
- (CurrentSection.CommonHeader->Size[2] << 16);
+ ((UINTN) CurrentSection.CommonHeader + GuidDataOffset);
+ SectionSize = GetSectionFileLength(CurrentSection.CommonHeader);
Status = SearchSectionByType (
InnerSection,
(UINT8 *) ((UINTN) CurrentSection.CommonHeader + SectionSize),
@@ -475,7 +486,7 @@ Returns: //
// Find next section (including compensating for alignment issues.
//
- CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2));
+ CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetSectionFileLength(CurrentSection.CommonHeader) + 0x03) & (-1 << 2));
}
return EFI_NOT_FOUND;
@@ -538,14 +549,14 @@ Returns: //
// Get the first section
//
- CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER));
+ CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + GetFfsHeaderLength(File));
//
// Depth-first manner to find section file.
//
Status = SearchSectionByType (
CurrentSection,
- (UINT8 *) ((UINTN) File + GetLength (File->Size)),
+ (UINT8 *) ((UINTN) File + GetFfsFileLength (File)),
SectionType,
&SectionCount,
Instance,
@@ -639,12 +650,14 @@ Returns: {
BOOLEAN ErasePolarity;
EFI_STATUS Status;
- EFI_FFS_FILE_HEADER BlankHeader;
+ EFI_FFS_FILE_HEADER2 BlankHeader;
UINT8 Checksum;
UINT32 FileLength;
UINT8 SavedChecksum;
UINT8 SavedState;
UINT8 FileGuidString[80];
+ UINT32 FfsHeaderSize;
+
//
// Verify library has been initialized.
//
@@ -665,16 +678,18 @@ Returns: if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
+
+ FfsHeaderSize = GetFfsHeaderLength(FfsHeader);
//
// Check if we have free space
//
if (ErasePolarity) {
- memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER));
+ memset (&BlankHeader, -1, FfsHeaderSize);
} else {
- memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER));
+ memset (&BlankHeader, 0, FfsHeaderSize);
}
- if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) {
+ if (memcmp (&BlankHeader, FfsHeader, FfsHeaderSize) == 0) {
return EFI_NOT_FOUND;
}
//
@@ -689,7 +704,7 @@ Returns: FfsHeader->State = 0;
SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File;
FfsHeader->IntegrityCheck.Checksum.File = 0;
- Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FfsHeaderSize);
FfsHeader->State = SavedState;
FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum;
if (Checksum != 0) {
@@ -703,8 +718,8 @@ Returns: //
// Verify file data checksum
//
- FileLength = GetLength (FfsHeader->Size);
- Checksum = CalculateSum8 ((UINT8 *) (FfsHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));
+ FileLength = GetFfsFileLength (FfsHeader);
+ Checksum = CalculateSum8 ((UINT8 *) ((UINT8 *)FfsHeader + FfsHeaderSize), FileLength - FfsHeaderSize);
Checksum = Checksum + FfsHeader->IntegrityCheck.Checksum.File;
if (Checksum != 0) {
Error (NULL, 0, 0006, "invalid FFS file checksum", "Ffs file with Guid %s", FileGuidString);
@@ -725,6 +740,80 @@ Returns: }
UINT32
+GetFfsHeaderLength(
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+{
+ if (FfsHeader == NULL) {
+ return 0;
+ }
+ if (FfsHeader->Attributes & FFS_ATTRIB_LARGE_FILE) {
+ return sizeof(EFI_FFS_FILE_HEADER2);
+ }
+ return sizeof(EFI_FFS_FILE_HEADER);
+}
+
+UINT32
+GetSectionHeaderLength(
+ IN EFI_COMMON_SECTION_HEADER *SectionHeader
+ )
+{
+ if (SectionHeader == NULL) {
+ return 0;
+ }
+ if (GetLength(SectionHeader->Size) == 0xffffff) {
+ return sizeof(EFI_COMMON_SECTION_HEADER2);
+ }
+ return sizeof(EFI_COMMON_SECTION_HEADER);
+}
+
+UINT32
+GetFfsFileLength (
+ EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+
+ Get FFS file length including FFS header.
+
+Arguments:
+
+ FfsHeader Pointer to EFI_FFS_FILE_HEADER.
+
+Returns:
+
+ UINT32 Length of FFS file header.
+
+--*/
+{
+ if (FfsHeader == NULL) {
+ return 0;
+ }
+ if (FfsHeader->Attributes & FFS_ATTRIB_LARGE_FILE) {
+ return ((EFI_FFS_FILE_HEADER2 *)FfsHeader)->ExtendedSize;
+ } else {
+ return GetLength(FfsHeader->Size);
+ }
+}
+
+UINT32
+GetSectionFileLength (
+ EFI_COMMON_SECTION_HEADER *SectionHeader
+ )
+{
+ UINT32 Length;
+ if (SectionHeader == NULL) {
+ return 0;
+ }
+ Length = GetLength(SectionHeader->Size);
+ if (Length == 0xffffff) {
+ Length = ((EFI_COMMON_SECTION_HEADER2 *)SectionHeader)->ExtendedSize;
+ }
+ return Length;
+}
+
+UINT32
GetLength (
UINT8 *ThreeByteLength
)
diff --git a/BaseTools/Source/C/Common/FvLib.h b/BaseTools/Source/C/Common/FvLib.h index 7815baae3f..567430a378 100644 --- a/BaseTools/Source/C/Common/FvLib.h +++ b/BaseTools/Source/C/Common/FvLib.h @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -90,6 +90,30 @@ VerifyFfsFile ( )
;
+UINT32
+GetFfsFileLength (
+ EFI_FFS_FILE_HEADER *FfsHeader
+ )
+;
+
+UINT32
+GetSectionFileLength (
+ EFI_COMMON_SECTION_HEADER *SectionHeader
+ )
+;
+
+UINT32
+GetFfsHeaderLength(
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+;
+
+UINT32
+GetSectionHeaderLength(
+ IN EFI_COMMON_SECTION_HEADER *SectionHeader
+ )
+;
+
/*++
Routine Description:
diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c index 24081ebfc4..6f4804e90a 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -1,6 +1,6 @@ /**
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -119,7 +119,7 @@ Returns: //
// Copyright declaration
//
- fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
+ fprintf (stdout, "Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
@@ -284,10 +284,11 @@ Returns: UINT32 Index;
FILE *InFile;
EFI_COMMON_SECTION_HEADER *SectHeader;
- EFI_COMMON_SECTION_HEADER TempSectHeader;
+ EFI_COMMON_SECTION_HEADER2 TempSectHeader;
EFI_TE_IMAGE_HEADER TeHeader;
UINT32 TeOffset;
EFI_GUID_DEFINED_SECTION GuidSectHeader;
+ EFI_GUID_DEFINED_SECTION2 GuidSectHeader2;
UINT32 HeaderSize;
Size = 0;
@@ -332,8 +333,12 @@ Returns: // Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section.
//
TeOffset = 0;
- HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
- fread (&TempSectHeader, 1, sizeof (TempSectHeader), InFile);
+ if (FileSize >= MAX_FFS_SIZE) {
+ HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER2);
+ } else {
+ HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
+ }
+ fread (&TempSectHeader, 1, HeaderSize, InFile);
if (TempSectHeader.Type == EFI_SECTION_TE) {
(*PESectionNum) ++;
fread (&TeHeader, 1, sizeof (TeHeader), InFile);
@@ -344,9 +349,16 @@ Returns: (*PESectionNum) ++;
} else if (TempSectHeader.Type == EFI_SECTION_GUID_DEFINED) {
fseek (InFile, 0, SEEK_SET);
- fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
- if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
- HeaderSize = GuidSectHeader.DataOffset;
+ if (FileSize >= MAX_SECTION_SIZE) {
+ fread (&GuidSectHeader2, 1, sizeof (GuidSectHeader2), InFile);
+ if ((GuidSectHeader2.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
+ HeaderSize = GuidSectHeader2.DataOffset;
+ }
+ } else {
+ fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
+ if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
+ HeaderSize = GuidSectHeader.DataOffset;
+ }
}
(*PESectionNum) ++;
} else if (TempSectHeader.Type == EFI_SECTION_COMPRESSION ||
@@ -378,6 +390,9 @@ Returns: Offset = Offset - Size - HeaderSize - TeOffset;
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {
+ //
+ // The maximal alignment is 64K, the raw section size must be less than 0xffffff
+ //
memset (FileBuffer + Size, 0, Offset);
SectHeader = (EFI_COMMON_SECTION_HEADER *) (FileBuffer + Size);
SectHeader->Type = EFI_SECTION_RAW;
@@ -453,11 +468,12 @@ Returns: UINT8 *FileBuffer;
UINT32 FileSize;
UINT32 MaxAlignment;
- EFI_FFS_FILE_HEADER FfsFileHeader;
+ EFI_FFS_FILE_HEADER2 FfsFileHeader;
FILE *FfsFile;
UINT32 Index;
UINT64 LogLevel;
UINT8 PeSectionNum;
+ UINT32 HeaderSize;
//
// Init local variables
@@ -816,7 +832,7 @@ Returns: //
// Create Ffs file header.
//
- memset (&FfsFileHeader, 0, sizeof (EFI_FFS_FILE_HEADER));
+ memset (&FfsFileHeader, 0, sizeof (EFI_FFS_FILE_HEADER2));
memcpy (&FfsFileHeader.Name, &FileGuid, sizeof (EFI_GUID));
FfsFileHeader.Type = FfsFiletype;
//
@@ -832,16 +848,27 @@ Returns: FfsAlign = Index;
}
VerboseMsg ("the alignment of the generated FFS file is %u", (unsigned) mFfsValidAlign [FfsAlign + 1]);
- FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));
//
// Now FileSize includes the EFI_FFS_FILE_HEADER
//
- FileSize += sizeof (EFI_FFS_FILE_HEADER);
+ if (FileSize + sizeof (EFI_FFS_FILE_HEADER) >= MAX_FFS_SIZE) {
+ HeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
+ FileSize += sizeof (EFI_FFS_FILE_HEADER2);
+ FfsFileHeader.ExtendedSize = FileSize;
+ memset(FfsFileHeader.Size, 0, sizeof (UINT8) * 3);
+ FfsAttrib |= FFS_ATTRIB_LARGE_FILE;
+ } else {
+ HeaderSize = sizeof (EFI_FFS_FILE_HEADER);
+ FileSize += sizeof (EFI_FFS_FILE_HEADER);
+ FfsFileHeader.Size[0] = (UINT8) (FileSize & 0xFF);
+ FfsFileHeader.Size[1] = (UINT8) ((FileSize & 0xFF00) >> 8);
+ FfsFileHeader.Size[2] = (UINT8) ((FileSize & 0xFF0000) >> 16);
+ }
VerboseMsg ("the size of the generated FFS file is %u bytes", (unsigned) FileSize);
- FfsFileHeader.Size[0] = (UINT8) (FileSize & 0xFF);
- FfsFileHeader.Size[1] = (UINT8) ((FileSize & 0xFF00) >> 8);
- FfsFileHeader.Size[2] = (UINT8) ((FileSize & 0xFF0000) >> 16);
+
+ FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3));
+
//
// Fill in checksums and state, these must be zero for checksumming
//
@@ -851,7 +878,7 @@ Returns: //
FfsFileHeader.IntegrityCheck.Checksum.Header = CalculateChecksum8 (
(UINT8 *) &FfsFileHeader,
- sizeof (EFI_FFS_FILE_HEADER)
+ HeaderSize
);
if (FfsFileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {
@@ -860,7 +887,7 @@ Returns: //
FfsFileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 (
FileBuffer,
- FileSize - sizeof (EFI_FFS_FILE_HEADER)
+ FileSize - HeaderSize
);
} else {
FfsFileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
@@ -880,11 +907,11 @@ Returns: //
// write header
//
- fwrite (&FfsFileHeader, 1, sizeof (FfsFileHeader), FfsFile);
+ fwrite (&FfsFileHeader, 1, HeaderSize, FfsFile);
//
// write data
//
- fwrite (FileBuffer, 1, FileSize - sizeof (EFI_FFS_FILE_HEADER), FfsFile);
+ fwrite (FileBuffer, 1, FileSize - HeaderSize, FfsFile);
fclose (FfsFile);
diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c index fa86d009da..8f837d2695 100644 --- a/BaseTools/Source/C/GenFv/GenFv.c +++ b/BaseTools/Source/C/GenFv/GenFv.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2013, 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
@@ -42,6 +42,7 @@ Abstract: #define UTILITY_MINOR_VERSION 1
EFI_GUID mEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;
+EFI_GUID mEfiFirmwareFileSystem3Guid = EFI_FIRMWARE_FILE_SYSTEM3_GUID;
STATIC
VOID
@@ -96,7 +97,7 @@ Returns: //
// Copyright declaration
//
- fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
+ fprintf (stdout, "Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
@@ -143,6 +144,8 @@ Returns: Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
fprintf (stdout, " --capflag CapFlag Capsule Reset Flag can be PersistAcrossReset,\n\
or PopulateSystemTable or InitiateReset or not set\n");
+ fprintf (stdout, " --capoemflag CapOEMFlag\n\
+ Capsule OEM Flag is an integer between 0x0000 and 0xffff\n");
fprintf (stdout, " --capheadsize HeadSize\n\
HeadSize is one HEX or DEC format value\n\
HeadSize is required by Capsule Image.\n");
@@ -439,6 +442,22 @@ Returns: continue;
}
+ if (stricmp (argv[0], "--capoemflag") == 0) {
+ if (argv[1] == NULL) {
+ Error (NULL, 0, 1003, "Invalid option value", "Capsule OEM flag can't be null");
+ }
+ Status = AsciiStringToUint64(argv[1], FALSE, &TempNumber);
+ if (EFI_ERROR (Status) || TempNumber > 0xffff) {
+ Error (NULL, 0, 1003, "Invalid option value", "Capsule OEM flag value must be integer value between 0x0000 and 0xffff");
+ return STATUS_ERROR;
+ }
+ mCapDataInfo.Flags |= TempNumber;
+ DebugMsg( NULL, 0, 9, "Capsule OEM Flags", argv[1]);
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
if (stricmp (argv[0], "--capguid") == 0) {
//
// Get the Capsule Guid
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index dd0e9ec3be..d0df4ac13d 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>
Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -159,6 +159,7 @@ UINT8 m64kRecoveryStartupApDataArray[SIZEOF_ST FV_INFO mFvDataInfo;
CAP_INFO mCapDataInfo;
+BOOLEAN mIsLargeFfs = FALSE;
EFI_PHYSICAL_ADDRESS mFvBaseAddress[0x10];
UINT32 mFvBaseAddressNumber = 0;
@@ -281,6 +282,19 @@ Returns: }
//
+ // Read weak alignment flag
+ //
+ Status = FindToken (InfFile, ATTRIBUTES_SECTION_STRING, EFI_FV_WEAK_ALIGNMENT_STRING, 0, Value);
+ if (Status == EFI_SUCCESS) {
+ if ((strcmp (Value, TRUE_STRING) == 0) || (strcmp (Value, ONE_STRING) == 0)) {
+ FvInfo->FvAttributes |= EFI_FVB2_WEAK_ALIGNMENT;
+ } else if ((strcmp (Value, FALSE_STRING) != 0) && (strcmp (Value, ZERO_STRING) != 0)) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Weak alignment value expected one of TRUE, FALSE, 1 or 0.");
+ return EFI_ABORTED;
+ }
+ }
+
+ //
// Read block maps
//
for (Index = 0; Index < MAX_NUMBER_OF_FV_BLOCKS; Index++) {
@@ -510,7 +524,8 @@ AddPadFile ( IN OUT MEMORY_FILE *FvImage,
IN UINT32 DataAlignment,
IN VOID *FvEnd,
- IN EFI_FIRMWARE_VOLUME_EXT_HEADER *ExtHeader
+ IN EFI_FIRMWARE_VOLUME_EXT_HEADER *ExtHeader,
+ IN UINT32 NextFfsSize
)
/*++
@@ -538,7 +553,10 @@ Returns: {
EFI_FFS_FILE_HEADER *PadFile;
UINTN PadFileSize;
+ UINT32 NextFfsHeaderSize;
+ UINT32 CurFfsHeaderSize;
+ CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
//
// Verify input parameters.
//
@@ -547,42 +565,44 @@ Returns: }
//
- // Check if a pad file is necessary
- //
- if ((ExtHeader == NULL) && (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER)) % DataAlignment == 0)) {
- return EFI_SUCCESS;
- }
-
- //
// Calculate the pad file size
//
- //
- // This is the earliest possible valid offset (current plus pad file header
- // plus the next file header)
- //
- PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2);
//
- // Add whatever it takes to get to the next aligned address
- //
- while ((PadFileSize % DataAlignment) != 0) {
- PadFileSize++;
- }
- //
- // Subtract the next file header size
- //
- PadFileSize -= sizeof (EFI_FFS_FILE_HEADER);
-
- //
- // Subtract the starting offset to get size
- //
- PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
-
- //
// Append extension header size
//
if (ExtHeader != NULL) {
- PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize;
+ PadFileSize = ExtHeader->ExtHeaderSize;
+ if (PadFileSize + sizeof (EFI_FFS_FILE_HEADER) >= MAX_FFS_SIZE) {
+ CurFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
+ }
+ PadFileSize += CurFfsHeaderSize;
+ } else {
+ NextFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER);
+ if (NextFfsSize >= MAX_FFS_SIZE) {
+ NextFfsHeaderSize = sizeof (EFI_FFS_FILE_HEADER2);
+ }
+ //
+ // Check if a pad file is necessary
+ //
+ if (((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + NextFfsHeaderSize) % DataAlignment == 0) {
+ return EFI_SUCCESS;
+ }
+ PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + sizeof (EFI_FFS_FILE_HEADER) + NextFfsHeaderSize;
+ //
+ // Add whatever it takes to get to the next aligned address
+ //
+ while ((PadFileSize % DataAlignment) != 0) {
+ PadFileSize++;
+ }
+ //
+ // Subtract the next file header size
+ //
+ PadFileSize -= NextFfsHeaderSize;
+ //
+ // Subtract the starting offset to get size
+ //
+ PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage;
}
//
@@ -606,9 +626,15 @@ Returns: //
// Write pad file size (calculated size minus next file header size)
//
- PadFile->Size[0] = (UINT8) (PadFileSize & 0xFF);
- PadFile->Size[1] = (UINT8) ((PadFileSize >> 8) & 0xFF);
- PadFile->Size[2] = (UINT8) ((PadFileSize >> 16) & 0xFF);
+ if (PadFileSize >= MAX_FFS_SIZE) {
+ memset(PadFile->Size, 0, sizeof(UINT8) * 3);
+ ((EFI_FFS_FILE_HEADER2 *)PadFile)->ExtendedSize = PadFileSize;
+ PadFile->Attributes |= FFS_ATTRIB_LARGE_FILE;
+ } else {
+ PadFile->Size[0] = (UINT8) (PadFileSize & 0xFF);
+ PadFile->Size[1] = (UINT8) ((PadFileSize >> 8) & 0xFF);
+ PadFile->Size[2] = (UINT8) ((PadFileSize >> 16) & 0xFF);
+ }
//
// Fill in checksums and state, they must be 0 for checksumming.
@@ -616,7 +642,7 @@ Returns: PadFile->IntegrityCheck.Checksum.Header = 0;
PadFile->IntegrityCheck.Checksum.File = 0;
PadFile->State = 0;
- PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
+ PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, CurFfsHeaderSize);
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;
@@ -634,8 +660,8 @@ Returns: //
// Copy Fv Extension Header and Set Fv Extension header offset
//
- memcpy (PadFile + 1, ExtHeader, ExtHeader->ExtHeaderSize);
- ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = (UINT16) ((UINTN) (PadFile + 1) - (UINTN) FvImage->FileImage);
+ memcpy ((UINT8 *)PadFile + CurFfsHeaderSize, ExtHeader, ExtHeader->ExtHeaderSize);
+ ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = (UINT16) ((UINTN) ((UINT8 *)PadFile + CurFfsHeaderSize) - (UINTN) FvImage->FileImage);
//
// Make next file start at QWord Boundry
//
@@ -1078,7 +1104,7 @@ Returns: //
// Sanity check. The file MUST align appropriately
//
- if (((UINTN) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER) - (UINTN) FvImage->FileImage) % (1 << CurrentFileAlignment)) {
+ if (((UINTN) *VtfFileImage + GetFfsHeaderLength((EFI_FFS_FILE_HEADER *)FileBuffer) - (UINTN) FvImage->FileImage) % (1 << CurrentFileAlignment)) {
Error (NULL, 0, 3000, "Invalid", "VTF file cannot be aligned on a %u-byte boundary.", (unsigned) (1 << CurrentFileAlignment));
free (FileBuffer);
return EFI_ABORTED;
@@ -1116,7 +1142,7 @@ Returns: //
// Add pad file if necessary
//
- Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL);
+ Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL, FileSize);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property.");
free (FileBuffer);
@@ -1190,6 +1216,7 @@ Returns: {
EFI_FFS_FILE_HEADER *PadFile;
UINTN FileSize;
+ UINT32 FfsHeaderSize;
//
// If there is no VTF or the VTF naturally follows the previous file without a
@@ -1219,9 +1246,18 @@ Returns: // FileSize includes the EFI_FFS_FILE_HEADER
//
FileSize = (UINTN) VtfFileImage - (UINTN) FvImage->CurrentFilePointer;
- PadFile->Size[0] = (UINT8) (FileSize & 0x000000FF);
- PadFile->Size[1] = (UINT8) ((FileSize & 0x0000FF00) >> 8);
- PadFile->Size[2] = (UINT8) ((FileSize & 0x00FF0000) >> 16);
+ if (FileSize >= MAX_FFS_SIZE) {
+ PadFile->Attributes |= FFS_ATTRIB_LARGE_FILE;
+ memset(PadFile->Size, 0, sizeof(UINT8) * 3);
+ ((EFI_FFS_FILE_HEADER2 *)PadFile)->ExtendedSize = FileSize;
+ FfsHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ mIsLargeFfs = TRUE;
+ } else {
+ PadFile->Size[0] = (UINT8) (FileSize & 0x000000FF);
+ PadFile->Size[1] = (UINT8) ((FileSize & 0x0000FF00) >> 8);
+ PadFile->Size[2] = (UINT8) ((FileSize & 0x00FF0000) >> 16);
+ FfsHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ }
//
// Fill in checksums and state, must be zero during checksum calculation.
@@ -1229,7 +1265,7 @@ Returns: PadFile->IntegrityCheck.Checksum.Header = 0;
PadFile->IntegrityCheck.Checksum.File = 0;
PadFile->State = 0;
- PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
+ PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, FfsHeaderSize);
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
PadFile->State = EFI_FILE_HEADER_CONSTRUCTION | EFI_FILE_HEADER_VALID | EFI_FILE_DATA_VALID;
@@ -1297,6 +1333,8 @@ Returns: UINT64 FitAddress;
FIT_TABLE *FitTablePtr;
BOOLEAN Vtf0Detected;
+ UINT32 FfsHeaderSize;
+ UINT32 SecHeaderSize;
//
// Verify input parameters
@@ -1359,8 +1397,9 @@ Returns: return EFI_ABORTED;
}
+ SecHeaderSize = GetSectionHeaderLength(Pe32Section.CommonHeader);
Status = GetPe32Info (
- (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),
+ (VOID *) ((UINTN) Pe32Section.Pe32Section + SecHeaderSize),
&EntryPoint,
&BaseOfCode,
&MachineType
@@ -1388,7 +1427,7 @@ Returns: // Physical address is FV base + offset of PE32 + offset of the entry point
//
SecCorePhysicalAddress = FvInfo->BaseAddress;
- SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;
+ SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + SecHeaderSize - (UINTN) FvImage->FileImage;
SecCorePhysicalAddress += EntryPoint;
DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%llX", (unsigned long long) SecCorePhysicalAddress);
@@ -1413,8 +1452,9 @@ Returns: return EFI_ABORTED;
}
+ SecHeaderSize = GetSectionHeaderLength(Pe32Section.CommonHeader);
Status = GetPe32Info (
- (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),
+ (VOID *) ((UINTN) Pe32Section.Pe32Section + SecHeaderSize),
&EntryPoint,
&BaseOfCode,
&MachineType
@@ -1428,7 +1468,7 @@ Returns: // Physical address is FV base + offset of PE32 + offset of the entry point
//
PeiCorePhysicalAddress = FvInfo->BaseAddress;
- PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;
+ PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + SecHeaderSize - (UINTN) FvImage->FileImage;
PeiCorePhysicalAddress += EntryPoint;
DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress);
@@ -1598,9 +1638,10 @@ Returns: VtfFile->IntegrityCheck.Checksum.File = 0;
VtfFile->State = 0;
if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+ FfsHeaderSize = GetFfsHeaderLength(VtfFile);
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *) (VtfFile + 1),
- GetLength (VtfFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
+ (UINT8 *) ((UINT8 *)VtfFile + FfsHeaderSize),
+ GetFfsFileLength (VtfFile) - FfsHeaderSize
);
} else {
VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
@@ -1720,7 +1761,7 @@ Returns: }
Status = GetPe32Info (
- (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),
+ (VOID *) ((UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader)),
&EntryPoint,
&BaseOfCode,
&MachineType
@@ -1734,7 +1775,7 @@ Returns: // Physical address is FV base + offset of PE32 + offset of the entry point
//
PeiCorePhysicalAddress = FvInfo->BaseAddress;
- PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;
+ PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader) - (UINTN) FvImage->FileImage;
PeiCorePhysicalAddress += EntryPoint;
DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress);
@@ -1768,7 +1809,7 @@ Returns: }
Status = GetPe32Info (
- (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),
+ (VOID *) ((UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader)),
&EntryPoint,
&BaseOfCode,
&MachineType
@@ -1789,7 +1830,7 @@ Returns: // Physical address is FV base + offset of PE32 + offset of the entry point
//
SecCorePhysicalAddress = FvInfo->BaseAddress;
- SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;
+ SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader) - (UINTN) FvImage->FileImage;
SecCorePhysicalAddress += EntryPoint;
DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%llX", (unsigned long long) SecCorePhysicalAddress);
@@ -1813,7 +1854,7 @@ Returns: }
Status = GetPe32Info (
- (VOID *) ((UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32)),
+ (VOID *) ((UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader)),
&EntryPoint,
&BaseOfCode,
&MachineType
@@ -1827,7 +1868,7 @@ Returns: // Physical address is FV base + offset of PE32 + offset of the entry point
//
PeiCorePhysicalAddress = FvInfo->BaseAddress;
- PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage;
+ PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + GetSectionHeaderLength(Pe32Section.CommonHeader) - (UINTN) FvImage->FileImage;
PeiCorePhysicalAddress += EntryPoint;
DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress);
}
@@ -2344,7 +2385,7 @@ Returns: //
// Add FV Extended Header contents to the FV as a PAD file
//
- AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader);
+ AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, FvExtHeader, 0);
//
// Fv Extension header change update Fv Header Check sum
@@ -2419,7 +2460,8 @@ Returns: //
// Update FV Alignment attribute to the largest alignment of all the FFS files in the FV
//
- if ((((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16)) < MaxFfsAlignment) {
+ if (((FvHeader->Attributes & EFI_FVB2_WEAK_ALIGNMENT) != EFI_FVB2_WEAK_ALIGNMENT) &&
+ (((FvHeader->Attributes & EFI_FVB2_ALIGNMENT) >> 16)) < MaxFfsAlignment) {
FvHeader->Attributes = ((MaxFfsAlignment << 16) | (FvHeader->Attributes & 0xFFFF));
//
// Update Checksum for FvHeader
@@ -2428,6 +2470,15 @@ Returns: FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
}
+ //
+ // If there are large FFS in FV, the file system GUID should set to system 3 GUID.
+ //
+ if (mIsLargeFfs && CompareGuid (&FvHeader->FileSystemGuid, &mEfiFirmwareFileSystem2Guid) == 0) {
+ memcpy (&FvHeader->FileSystemGuid, &mEfiFirmwareFileSystem3Guid, sizeof (EFI_GUID));
+ FvHeader->Checksum = 0;
+ FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
+ }
+
WriteFile:
//
// Write fv file
@@ -2564,6 +2615,7 @@ Returns: UINTN FfsFileSize;
UINTN FvExtendHeaderSize;
UINT32 FfsAlignment;
+ UINT32 FfsHeaderSize;
EFI_FFS_FILE_HEADER FfsHeader;
BOOLEAN VtfFileFlag;
UINTN VtfFileSize;
@@ -2605,7 +2657,12 @@ Returns: }
FvExtendHeaderSize = _filelength (fileno (fpin));
fclose (fpin);
- CurrentOffset += sizeof (EFI_FFS_FILE_HEADER) + FvExtendHeaderSize;
+ if (sizeof (EFI_FFS_FILE_HEADER) + FvExtendHeaderSize >= MAX_FFS_SIZE) {
+ CurrentOffset += sizeof (EFI_FFS_FILE_HEADER2) + FvExtendHeaderSize;
+ mIsLargeFfs = TRUE;
+ } else {
+ CurrentOffset += sizeof (EFI_FFS_FILE_HEADER) + FvExtendHeaderSize;
+ }
CurrentOffset = (CurrentOffset + 7) & (~7);
} else if (mFvDataInfo.FvNameGuidSet) {
CurrentOffset += sizeof (EFI_FFS_FILE_HEADER) + sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER);
@@ -2629,6 +2686,12 @@ Returns: // Get the file size
//
FfsFileSize = _filelength (fileno (fpin));
+ if (FfsFileSize >= MAX_FFS_SIZE) {
+ FfsHeaderSize = sizeof(EFI_FFS_FILE_HEADER2);
+ mIsLargeFfs = TRUE;
+ } else {
+ FfsHeaderSize = sizeof(EFI_FFS_FILE_HEADER);
+ }
//
// Read Ffs File header
//
@@ -2662,9 +2725,12 @@ Returns: //
// Add Pad file
//
- if (((CurrentOffset + sizeof (EFI_FFS_FILE_HEADER)) % FfsAlignment) != 0) {
- CurrentOffset = (CurrentOffset + sizeof (EFI_FFS_FILE_HEADER) * 2 + FfsAlignment - 1) & ~(FfsAlignment - 1);
- CurrentOffset -= sizeof (EFI_FFS_FILE_HEADER);
+ if (((CurrentOffset + FfsHeaderSize) % FfsAlignment) != 0) {
+ //
+ // Only EFI_FFS_FILE_HEADER is needed for a pad section.
+ //
+ CurrentOffset = (CurrentOffset + FfsHeaderSize + sizeof(EFI_FFS_FILE_HEADER) + FfsAlignment - 1) & ~(FfsAlignment - 1);
+ CurrentOffset -= FfsHeaderSize;
}
}
@@ -2792,7 +2858,7 @@ Returns: if (EFI_ERROR (Status)) {
break;
}
- SubFvImageHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) SubFvSection.FVImageSection + sizeof (EFI_FIRMWARE_VOLUME_IMAGE_SECTION));
+ SubFvImageHeader = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINT8 *) SubFvSection.FVImageSection + GetSectionHeaderLength(SubFvSection.FVImageSection));
//
// Rebase on Flash
//
@@ -2854,6 +2920,8 @@ Returns: UINT8 *PeFileBuffer;
UINT32 PeFileSize;
CHAR8 *PdbPointer;
+ UINT32 FfsHeaderSize;
+ UINT32 CurSecHdrSize;
Index = 0;
MemoryImagePointer = NULL;
@@ -2905,6 +2973,8 @@ Returns: default:
return EFI_SUCCESS;
}
+
+ FfsHeaderSize = GetFfsHeaderLength(FfsFile);
//
// Rebase each PE32 section
//
@@ -2922,12 +2992,13 @@ Returns: if (EFI_ERROR (Status)) {
break;
}
+ CurSecHdrSize = GetSectionHeaderLength(CurrentPe32Section.CommonHeader);
//
// Initialize context
//
memset (&ImageContext, 0, sizeof (ImageContext));
- ImageContext.Handle = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION));
+ ImageContext.Handle = (VOID *) ((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize);
ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead;
Status = PeCoffLoaderGetImageInfo (&ImageContext);
if (EFI_ERROR (Status)) {
@@ -2953,7 +3024,7 @@ Returns: //
// Get PeHeader pointer
//
- ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) + ImageContext.PeCoffHeaderOffset);
+ ImgHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize + ImageContext.PeCoffHeaderOffset);
//
// Calculate the PE32 base address, based on file type
@@ -3030,7 +3101,7 @@ Returns: ImageContext.RelocationsStripped = FALSE;
}
- NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;
+ NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize - (UINTN)FfsFile;
break;
case EFI_FV_FILETYPE_DRIVER:
@@ -3045,7 +3116,7 @@ Returns: Error (NULL, 0, 3000, "Invalid", "Section-Alignment and File-Alignment do not match : %s.", FileName);
return EFI_ABORTED;
}
- NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + sizeof (EFI_PE32_SECTION) - (UINTN)FfsFile;
+ NewPe32BaseAddress = XipBase + (UINTN) CurrentPe32Section.Pe32Section + CurSecHdrSize - (UINTN)FfsFile;
break;
default:
@@ -3104,7 +3175,7 @@ Returns: for (Index = 0; Index < ImgHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
CopyMem (
- (UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER) + SectionHeader->PointerToRawData,
+ (UINT8 *) CurrentPe32Section.Pe32Section + CurSecHdrSize + SectionHeader->PointerToRawData,
(VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress),
SectionHeader->SizeOfRawData
);
@@ -3140,8 +3211,8 @@ Returns: FfsFile->IntegrityCheck.Checksum.File = 0;
FfsFile->State = 0;
FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *) (FfsFile + 1),
- GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
+ (UINT8 *) ((UINT8 *)FfsFile + FfsHeaderSize),
+ GetFfsFileLength (FfsFile) - FfsHeaderSize
);
FfsFile->State = SavedState;
}
@@ -3185,12 +3256,14 @@ Returns: if (EFI_ERROR (Status)) {
break;
}
+
+ CurSecHdrSize = GetSectionHeaderLength(CurrentPe32Section.CommonHeader);
//
// Calculate the TE base address, the FFS file base plus the offset of the TE section less the size stripped off
// by GenTEImage
//
- TEImageHeader = (EFI_TE_IMAGE_HEADER *) ((UINT8 *) CurrentPe32Section.Pe32Section + sizeof (EFI_COMMON_SECTION_HEADER));
+ TEImageHeader = (EFI_TE_IMAGE_HEADER *) ((UINT8 *) CurrentPe32Section.Pe32Section + CurSecHdrSize);
//
// Initialize context, load image info.
@@ -3365,8 +3438,8 @@ Returns: FfsFile->IntegrityCheck.Checksum.File = 0;
FfsFile->State = 0;
FfsFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
- (UINT8 *)(FfsFile + 1),
- GetLength (FfsFile->Size) - sizeof (EFI_FFS_FILE_HEADER)
+ (UINT8 *)((UINT8 *)FfsFile + FfsHeaderSize),
+ GetFfsFileLength (FfsFile) - FfsHeaderSize
);
FfsFile->State = SavedState;
}
@@ -3436,12 +3509,12 @@ Returns: //
// Get Pad file size.
//
- FileLength = (*(UINT32 *)(PadFile->Size)) & 0x00FFFFFF;
+ FileLength = GetFfsFileLength(PadFile);
FileLength = (FileLength + EFI_FFS_FILE_HEADER_ALIGNMENT - 1) & ~(EFI_FFS_FILE_HEADER_ALIGNMENT - 1);
//
// FixPoint must be align on 0x1000 relative to FvImage Header
//
- FixPoint = (UINT8*) PadFile + sizeof (EFI_FFS_FILE_HEADER);
+ FixPoint = (UINT8*) PadFile + GetFfsHeaderLength(PadFile);
FixPoint = FixPoint + 0x1000 - (((UINTN) FixPoint - (UINTN) FvImage->FileImage) & 0xFFF);
//
// FixPoint be larger at the last place of one fv image.
@@ -3451,7 +3524,7 @@ Returns: }
FixPoint -= 0x1000;
- if ((UINTN) FixPoint < ((UINTN) PadFile + sizeof (EFI_FFS_FILE_HEADER))) {
+ if ((UINTN) FixPoint < ((UINTN) PadFile + GetFfsHeaderLength(PadFile))) {
//
// No alignment FixPoint in this Pad File.
//
@@ -3556,6 +3629,19 @@ Returns: DebugMsg (NULL, 0, 9, "Capsule Flag", Value);
}
+ Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_OEM_CAPSULE_FLAGS_STRING, 0, Value);
+ if (Status == EFI_SUCCESS) {
+ Status = AsciiStringToUint64 (Value, FALSE, &Value64);
+ if (EFI_ERROR (Status) || Value64 > 0xffff) {
+ Error (NULL, 0, 2000, "Invalid parameter",
+ "invalid Flag setting for %s. Must be integer value between 0x0000 and 0xffff.",
+ EFI_OEM_CAPSULE_FLAGS_STRING);
+ return EFI_ABORTED;
+ }
+ CapInfo->Flags |= Value64;
+ DebugMsg (NULL, 0, 9, "Capsule Extend Flag", Value);
+ }
+
//
// Read Capsule File name
//
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.h b/BaseTools/Source/C/GenFv/GenFvInternalLib.h index 40c23600ab..21993b5e7b 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.h +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.h @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -82,6 +82,7 @@ Abstract: #define EFI_CAPSULE_GUID_STRING "EFI_CAPSULE_GUID"
#define EFI_CAPSULE_HEADER_SIZE_STRING "EFI_CAPSULE_HEADER_SIZE"
#define EFI_CAPSULE_FLAGS_STRING "EFI_CAPSULE_FLAGS"
+#define EFI_OEM_CAPSULE_FLAGS_STRING "EFI_OEM_CAPSULE_FLAGS"
#define EFI_CAPSULE_VERSION_STRING "EFI_CAPSULE_VERSION"
#define EFI_FV_TOTAL_SIZE_STRING "EFI_FV_TOTAL_SIZE"
@@ -144,6 +145,8 @@ Abstract: #define EFI_FVB2_ALIGNMENT_1G_STRING "EFI_FVB2_ALIGNMENT_1G"
#define EFI_FVB2_ALIGNMENT_2G_STRING "EFI_FVB2_ALIGNMENT_2G"
+#define EFI_FV_WEAK_ALIGNMENT_STRING "EFI_WEAK_ALIGNMENT"
+
//
// File sections
//
@@ -259,6 +262,7 @@ typedef struct { extern FV_INFO mFvDataInfo;
extern CAP_INFO mCapDataInfo;
extern EFI_GUID mEfiFirmwareFileSystem2Guid;
+extern EFI_GUID mEfiFirmwareFileSystem3Guid;
extern UINT32 mFvTotalSize;
extern UINT32 mFvTakenSize;
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index ddb45acc86..58ac333888 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -1,6 +1,7 @@ /** @file Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR> +Portions copyright (c) 2013, ARM Ltd. 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 @@ -18,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <windows.h> #include <io.h> #endif +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -264,9 +266,12 @@ ScanSections32 ( EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; UINT32 CoffEntry; UINT32 SectionCount; + BOOLEAN FoundText; CoffEntry = 0; mCoffOffset = 0; + mTextOffset = 0; + FoundText = FALSE; // // Coff file start with a DOS header. @@ -291,7 +296,6 @@ ScanSections32 ( // First text sections. // mCoffOffset = CoffAlign(mCoffOffset); - mTextOffset = mCoffOffset; SectionCount = 0; for (i = 0; i < mEhdr->e_shnum; i++) { Elf_Shdr *shdr = GetShdrByIndex(i); @@ -315,12 +319,26 @@ ScanSections32 ( (mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) { CoffEntry = mCoffOffset + mEhdr->e_entry - shdr->sh_addr; } + + // + // Set mTextOffset with the offset of the first '.text' section + // + if (!FoundText) { + mTextOffset = mCoffOffset; + FoundText = TRUE; + } + mCoffSectionsOffset[i] = mCoffOffset; mCoffOffset += shdr->sh_size; SectionCount ++; } } + if (!FoundText) { + Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section."); + assert (FALSE); + } + if (mEhdr->e_machine != EM_ARM) { mCoffOffset = CoffAlign(mCoffOffset); } diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index 72d6cd16d7..713f8f7e47 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <windows.h> #include <io.h> #endif +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -258,9 +259,12 @@ ScanSections64 ( EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr; UINT32 CoffEntry; UINT32 SectionCount; + BOOLEAN FoundText; CoffEntry = 0; mCoffOffset = 0; + mTextOffset = 0; + FoundText = FALSE; // // Coff file start with a DOS header. @@ -286,7 +290,6 @@ ScanSections64 ( // First text sections. // mCoffOffset = CoffAlign(mCoffOffset); - mTextOffset = mCoffOffset; SectionCount = 0; for (i = 0; i < mEhdr->e_shnum; i++) { Elf_Shdr *shdr = GetShdrByIndex(i); @@ -310,12 +313,26 @@ ScanSections64 ( (mEhdr->e_entry < shdr->sh_addr + shdr->sh_size)) { CoffEntry = (UINT32) (mCoffOffset + mEhdr->e_entry - shdr->sh_addr); } + + // + // Set mTextOffset with the offset of the first '.text' section + // + if (!FoundText) { + mTextOffset = mCoffOffset; + FoundText = TRUE; + } + mCoffSectionsOffset[i] = mCoffOffset; mCoffOffset += (UINT32) shdr->sh_size; SectionCount ++; } } + if (!FoundText) { + Error (NULL, 0, 3000, "Invalid", "Did not find any '.text' section."); + assert (FALSE); + } + if (mEhdr->e_machine != EM_ARM) { mCoffOffset = CoffAlign(mCoffOffset); } diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index d6b22aee86..63e8e13e8f 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -1,6 +1,6 @@ /** @file
-Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2013, 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
@@ -42,8 +42,6 @@ Abstract: #define UTILITY_MAJOR_VERSION 0
#define UTILITY_MINOR_VERSION 1
-#define MAX_SECTION_SIZE 0x1000000
-
STATIC CHAR8 *mSectionTypeName[] = {
NULL, // 0x00 - reserved
"EFI_SECTION_COMPRESSION", // 0x01
@@ -94,6 +92,11 @@ typedef struct { UINT32 CRC32Checksum;
} CRC32_SECTION_HEADER;
+typedef struct {
+ EFI_GUID_DEFINED_SECTION2 GuidSectionHeader;
+ UINT32 CRC32Checksum;
+} CRC32_SECTION_HEADER2;
+
STATIC EFI_GUID mZeroGuid = {0x0, 0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
STATIC EFI_GUID mEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
@@ -150,7 +153,7 @@ Returns: //
// Copyright declaration
//
- fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
+ fprintf (stdout, "Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.\n\n");
//
// Details Option
@@ -184,7 +187,7 @@ Returns: fprintf (stdout, " -n String, --name String\n\
String is a NULL terminated string used in Ui section.\n");
fprintf (stdout, " -j Number, --buildnumber Number\n\
- Number is an integer value between 0000 and 9999\n\
+ Number is an integer value between 0 and 65535\n\
used in Ver section.\n");
fprintf (stdout, " --sectionalign SectionAlign\n\
SectionAlign points to section alignment, which support\n\
@@ -266,6 +269,7 @@ Returns: FILE *InFile;
UINT8 *Buffer;
UINT32 TotalLength;
+ UINT32 HeaderLength;
EFI_COMMON_SECTION_HEADER *CommonSect;
STATUS Status;
@@ -298,9 +302,14 @@ Returns: //
// Size must fit in 3 bytes
//
+ //if (TotalLength >= MAX_SECTION_SIZE) {
+ // Error (NULL, 0, 2000, "Invalid paramter", "%s file size (0x%X) exceeds section size limit(%uM).", InputFileName[0], (unsigned) TotalLength, MAX_SECTION_SIZE>>20);
+ // goto Done;
+ //}
+ HeaderLength = sizeof (EFI_COMMON_SECTION_HEADER);
if (TotalLength >= MAX_SECTION_SIZE) {
- Error (NULL, 0, 2000, "Invalid paramter", "%s file size (0x%X) exceeds section size limit(%uM).", InputFileName[0], (unsigned) TotalLength, MAX_SECTION_SIZE>>20);
- goto Done;
+ TotalLength = sizeof (EFI_COMMON_SECTION_HEADER2) + InputFileLength;
+ HeaderLength = sizeof (EFI_COMMON_SECTION_HEADER2);
}
VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength);
//
@@ -313,15 +322,20 @@ Returns: }
CommonSect = (EFI_COMMON_SECTION_HEADER *) Buffer;
CommonSect->Type = SectionType;
- CommonSect->Size[0] = (UINT8) (TotalLength & 0xff);
- CommonSect->Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
- CommonSect->Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
+ if (TotalLength < MAX_SECTION_SIZE) {
+ CommonSect->Size[0] = (UINT8) (TotalLength & 0xff);
+ CommonSect->Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
+ CommonSect->Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
+ } else {
+ memset(CommonSect->Size, 0xff, sizeof(UINT8) * 3);
+ ((EFI_COMMON_SECTION_HEADER2 *)CommonSect)->ExtendedSize = TotalLength;
+ }
//
// read data from the input file.
//
if (InputFileLength != 0) {
- if (fread (Buffer + sizeof (EFI_COMMON_SECTION_HEADER), (size_t) InputFileLength, 1, InFile) != 1) {
+ if (fread (Buffer + HeaderLength, (size_t) InputFileLength, 1, InFile) != 1) {
Error (NULL, 0, 0004, "Error reading file", InputFileName[0]);
goto Done;
}
@@ -421,10 +435,11 @@ Returns: UINT32 Index;
FILE *InFile;
EFI_COMMON_SECTION_HEADER *SectHeader;
- EFI_COMMON_SECTION_HEADER TempSectHeader;
+ EFI_COMMON_SECTION_HEADER2 TempSectHeader;
EFI_TE_IMAGE_HEADER TeHeader;
UINT32 TeOffset;
EFI_GUID_DEFINED_SECTION GuidSectHeader;
+ EFI_GUID_DEFINED_SECTION2 GuidSectHeader2;
UINT32 HeaderSize;
if (InputFileNum < 1) {
@@ -476,8 +491,16 @@ Returns: // Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section.
//
TeOffset = 0;
- HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
- fread (&TempSectHeader, 1, sizeof (TempSectHeader), InFile);
+ //
+ // The section might be EFI_COMMON_SECTION_HEADER2
+ // But only Type needs to be checked
+ //
+ if (FileSize >= MAX_SECTION_SIZE) {
+ HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER2);
+ } else {
+ HeaderSize = sizeof (EFI_COMMON_SECTION_HEADER);
+ }
+ fread (&TempSectHeader, 1, HeaderSize, InFile);
if (TempSectHeader.Type == EFI_SECTION_TE) {
fread (&TeHeader, 1, sizeof (TeHeader), InFile);
if (TeHeader.Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
@@ -485,9 +508,16 @@ Returns: }
} else if (TempSectHeader.Type == EFI_SECTION_GUID_DEFINED) {
fseek (InFile, 0, SEEK_SET);
- fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
- if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
- HeaderSize = GuidSectHeader.DataOffset;
+ if (FileSize >= MAX_SECTION_SIZE) {
+ fread (&GuidSectHeader2, 1, sizeof (GuidSectHeader2), InFile);
+ if ((GuidSectHeader2.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
+ HeaderSize = GuidSectHeader2.DataOffset;
+ }
+ } else {
+ fread (&GuidSectHeader, 1, sizeof (GuidSectHeader), InFile);
+ if ((GuidSectHeader.Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) == 0) {
+ HeaderSize = GuidSectHeader.DataOffset;
+ }
}
}
@@ -510,6 +540,9 @@ Returns: Offset = Offset - Size - HeaderSize - TeOffset;
if (FileBuffer != NULL && ((Size + Offset) < *BufferLength)) {
+ //
+ // The maximal alignment is 64K, the raw section size must be less than 0xffffff
+ //
memset (FileBuffer + Size, 0, Offset);
SectHeader = (EFI_COMMON_SECTION_HEADER *) (FileBuffer + Size);
SectHeader->Type = EFI_SECTION_RAW;
@@ -591,16 +624,19 @@ Returns: UINT32 TotalLength;
UINT32 InputLength;
UINT32 CompressedLength;
+ UINT32 HeaderLength;
UINT8 *FileBuffer;
UINT8 *OutputBuffer;
EFI_STATUS Status;
EFI_COMPRESSION_SECTION *CompressionSect;
+ EFI_COMPRESSION_SECTION2 *CompressionSect2;
COMPRESS_FUNCTION CompressFunction;
InputLength = 0;
FileBuffer = NULL;
OutputBuffer = NULL;
CompressedLength = 0;
+ TotalLength = 0;
//
// read all input file contents into a buffer
// first get the size of all file contents
@@ -646,15 +682,21 @@ Returns: switch (SectCompSubType) {
case EFI_NOT_COMPRESSED:
CompressedLength = InputLength;
+ HeaderLength = sizeof (EFI_COMPRESSION_SECTION);
+ if (CompressedLength + HeaderLength >= MAX_SECTION_SIZE) {
+ HeaderLength = sizeof (EFI_COMPRESSION_SECTION2);
+ }
+ TotalLength = CompressedLength + HeaderLength;
//
// Copy file buffer to the none compressed data.
//
- OutputBuffer = malloc (CompressedLength + sizeof (EFI_COMPRESSION_SECTION));
+ OutputBuffer = malloc (TotalLength);
if (OutputBuffer == NULL) {
free (FileBuffer);
return EFI_OUT_OF_RESOURCES;
}
- memcpy (OutputBuffer + sizeof (EFI_COMPRESSION_SECTION), FileBuffer, CompressedLength);
+ memcpy (OutputBuffer + HeaderLength, FileBuffer, CompressedLength);
+ free (FileBuffer);
FileBuffer = OutputBuffer;
break;
@@ -672,13 +714,18 @@ Returns: Status = CompressFunction (FileBuffer, InputLength, OutputBuffer, &CompressedLength);
if (Status == EFI_BUFFER_TOO_SMALL) {
- OutputBuffer = malloc (CompressedLength + sizeof (EFI_COMPRESSION_SECTION));
+ HeaderLength = sizeof (EFI_COMPRESSION_SECTION);
+ if (CompressedLength + HeaderLength >= MAX_SECTION_SIZE) {
+ HeaderLength = sizeof (EFI_COMPRESSION_SECTION2);
+ }
+ TotalLength = CompressedLength + HeaderLength;
+ OutputBuffer = malloc (TotalLength);
if (!OutputBuffer) {
free (FileBuffer);
return EFI_OUT_OF_RESOURCES;
}
- Status = CompressFunction (FileBuffer, InputLength, OutputBuffer + sizeof (EFI_COMPRESSION_SECTION), &CompressedLength);
+ Status = CompressFunction (FileBuffer, InputLength, OutputBuffer + HeaderLength, &CompressedLength);
}
free (FileBuffer);
@@ -695,30 +742,40 @@ Returns: DebugMsg (NULL, 0, 9, "comprss file size",
"the original section size is %d bytes and the compressed section size is %u bytes", (unsigned) InputLength, (unsigned) CompressedLength);
- TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION);
- if (TotalLength >= MAX_SECTION_SIZE) {
- Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20);
- if (FileBuffer != NULL) {
- free (FileBuffer);
- }
- if (OutputBuffer != NULL) {
- free (OutputBuffer);
- }
- return STATUS_ERROR;
- }
+
+ //if (TotalLength >= MAX_SECTION_SIZE) {
+ // Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20);
+ // if (FileBuffer != NULL) {
+ // free (FileBuffer);
+ // }
+ // if (OutputBuffer != NULL) {
+ // free (OutputBuffer);
+ // }
+ // return STATUS_ERROR;
+ //}
VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength);
//
// Add the section header for the compressed data
//
- CompressionSect = (EFI_COMPRESSION_SECTION *) FileBuffer;
-
- CompressionSect->CommonHeader.Type = EFI_SECTION_COMPRESSION;
- CompressionSect->CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
- CompressionSect->CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
- CompressionSect->CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
- CompressionSect->CompressionType = SectCompSubType;
- CompressionSect->UncompressedLength = InputLength;
+ if (TotalLength >= MAX_SECTION_SIZE) {
+ CompressionSect2 = (EFI_COMPRESSION_SECTION2 *)FileBuffer;
+
+ memset(CompressionSect2->CommonHeader.Size, 0xff, sizeof(UINT8) * 3);
+ CompressionSect2->CommonHeader.Type = EFI_SECTION_COMPRESSION;
+ CompressionSect2->CommonHeader.ExtendedSize = TotalLength;
+ CompressionSect2->CompressionType = SectCompSubType;
+ CompressionSect2->UncompressedLength = InputLength;
+ } else {
+ CompressionSect = (EFI_COMPRESSION_SECTION *) FileBuffer;
+
+ CompressionSect->CommonHeader.Type = EFI_SECTION_COMPRESSION;
+ CompressionSect->CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
+ CompressionSect->CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
+ CompressionSect->CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
+ CompressionSect->CompressionType = SectCompSubType;
+ CompressionSect->UncompressedLength = InputLength;
+ }
//
// Set OutFileBuffer
@@ -779,17 +836,14 @@ Returns: UINT32 Crc32Checksum;
EFI_STATUS Status;
CRC32_SECTION_HEADER *Crc32GuidSect;
+ CRC32_SECTION_HEADER2 *Crc32GuidSect2;
EFI_GUID_DEFINED_SECTION *VendorGuidSect;
+ EFI_GUID_DEFINED_SECTION2 *VendorGuidSect2;
InputLength = 0;
Offset = 0;
FileBuffer = NULL;
-
- if (CompareGuid (VendorGuid, &mZeroGuid) == 0) {
- Offset = sizeof (CRC32_SECTION_HEADER);
- } else {
- Offset = sizeof (EFI_GUID_DEFINED_SECTION);
- }
+ TotalLength = 0;
//
// read all input file contents into a buffer
@@ -804,6 +858,19 @@ Returns: );
if (Status == EFI_BUFFER_TOO_SMALL) {
+ if (CompareGuid (VendorGuid, &mZeroGuid) == 0) {
+ Offset = sizeof (CRC32_SECTION_HEADER);
+ if (InputLength + Offset >= MAX_SECTION_SIZE) {
+ Offset = sizeof (CRC32_SECTION_HEADER2);
+ }
+ } else {
+ Offset = sizeof (EFI_GUID_DEFINED_SECTION);
+ if (InputLength + Offset >= MAX_SECTION_SIZE) {
+ Offset = sizeof (EFI_GUID_DEFINED_SECTION2);
+ }
+ }
+ TotalLength = InputLength + Offset;
+
FileBuffer = (UINT8 *) malloc (InputLength + Offset);
if (FileBuffer == NULL) {
Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
@@ -843,42 +910,54 @@ Returns: //
Crc32Checksum = 0;
CalculateCrc32 (FileBuffer + Offset, InputLength, &Crc32Checksum);
-
- TotalLength = InputLength + sizeof (CRC32_SECTION_HEADER);
+
if (TotalLength >= MAX_SECTION_SIZE) {
- Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20);
- free (FileBuffer);
- return STATUS_ERROR;
+ Crc32GuidSect2 = (CRC32_SECTION_HEADER2 *) FileBuffer;
+ Crc32GuidSect2->GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
+ Crc32GuidSect2->GuidSectionHeader.CommonHeader.Size[0] = (UINT8) 0xff;
+ Crc32GuidSect2->GuidSectionHeader.CommonHeader.Size[1] = (UINT8) 0xff;
+ Crc32GuidSect2->GuidSectionHeader.CommonHeader.Size[2] = (UINT8) 0xff;
+ Crc32GuidSect2->GuidSectionHeader.CommonHeader.ExtendedSize = TotalLength;
+ memcpy (&(Crc32GuidSect2->GuidSectionHeader.SectionDefinitionGuid), &mEfiCrc32SectionGuid, sizeof (EFI_GUID));
+ Crc32GuidSect2->GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;
+ Crc32GuidSect2->GuidSectionHeader.DataOffset = sizeof (CRC32_SECTION_HEADER2);
+ Crc32GuidSect2->CRC32Checksum = Crc32Checksum;
+ DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", Crc32GuidSect2->GuidSectionHeader.DataOffset);
+ } else {
+ Crc32GuidSect = (CRC32_SECTION_HEADER *) FileBuffer;
+ Crc32GuidSect->GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
+ Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
+ Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
+ Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
+ memcpy (&(Crc32GuidSect->GuidSectionHeader.SectionDefinitionGuid), &mEfiCrc32SectionGuid, sizeof (EFI_GUID));
+ Crc32GuidSect->GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;
+ Crc32GuidSect->GuidSectionHeader.DataOffset = sizeof (CRC32_SECTION_HEADER);
+ Crc32GuidSect->CRC32Checksum = Crc32Checksum;
+ DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", Crc32GuidSect->GuidSectionHeader.DataOffset);
}
-
- Crc32GuidSect = (CRC32_SECTION_HEADER *) FileBuffer;
- Crc32GuidSect->GuidSectionHeader.CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
- Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
- Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
- Crc32GuidSect->GuidSectionHeader.CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
- memcpy (&(Crc32GuidSect->GuidSectionHeader.SectionDefinitionGuid), &mEfiCrc32SectionGuid, sizeof (EFI_GUID));
- Crc32GuidSect->GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID;
- Crc32GuidSect->GuidSectionHeader.DataOffset = sizeof (CRC32_SECTION_HEADER);
- Crc32GuidSect->CRC32Checksum = Crc32Checksum;
- DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", Crc32GuidSect->GuidSectionHeader.DataOffset);
-
} else {
- TotalLength = InputLength + sizeof (EFI_GUID_DEFINED_SECTION);
if (TotalLength >= MAX_SECTION_SIZE) {
- Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20);
- free (FileBuffer);
- return STATUS_ERROR;
+ VendorGuidSect2 = (EFI_GUID_DEFINED_SECTION2 *) FileBuffer;
+ VendorGuidSect2->CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
+ VendorGuidSect2->CommonHeader.Size[0] = (UINT8) 0xff;
+ VendorGuidSect2->CommonHeader.Size[1] = (UINT8) 0xff;
+ VendorGuidSect2->CommonHeader.Size[2] = (UINT8) 0xff;
+ VendorGuidSect2->CommonHeader.ExtendedSize = InputLength + sizeof (EFI_GUID_DEFINED_SECTION2);
+ memcpy (&(VendorGuidSect2->SectionDefinitionGuid), VendorGuid, sizeof (EFI_GUID));
+ VendorGuidSect2->Attributes = DataAttribute;
+ VendorGuidSect2->DataOffset = (UINT16) (sizeof (EFI_GUID_DEFINED_SECTION2) + DataHeaderSize);
+ DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", VendorGuidSect2->DataOffset);
+ } else {
+ VendorGuidSect = (EFI_GUID_DEFINED_SECTION *) FileBuffer;
+ VendorGuidSect->CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
+ VendorGuidSect->CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
+ VendorGuidSect->CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
+ VendorGuidSect->CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
+ memcpy (&(VendorGuidSect->SectionDefinitionGuid), VendorGuid, sizeof (EFI_GUID));
+ VendorGuidSect->Attributes = DataAttribute;
+ VendorGuidSect->DataOffset = (UINT16) (sizeof (EFI_GUID_DEFINED_SECTION) + DataHeaderSize);
+ DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", VendorGuidSect->DataOffset);
}
-
- VendorGuidSect = (EFI_GUID_DEFINED_SECTION *) FileBuffer;
- VendorGuidSect->CommonHeader.Type = EFI_SECTION_GUID_DEFINED;
- VendorGuidSect->CommonHeader.Size[0] = (UINT8) (TotalLength & 0xff);
- VendorGuidSect->CommonHeader.Size[1] = (UINT8) ((TotalLength & 0xff00) >> 8);
- VendorGuidSect->CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16);
- memcpy (&(VendorGuidSect->SectionDefinitionGuid), VendorGuid, sizeof (EFI_GUID));
- VendorGuidSect->Attributes = DataAttribute;
- VendorGuidSect->DataOffset = (UINT16) (sizeof (EFI_GUID_DEFINED_SECTION) + DataHeaderSize);
- DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", VendorGuidSect->DataOffset);
}
VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength);
@@ -935,6 +1014,7 @@ Returns: UINT64 LogLevel;
UINT32 *InputFileAlign;
UINT32 InputFileAlignNum;
+ EFI_COMMON_SECTION_HEADER *SectionHeader;
InputFileAlign = NULL;
InputFileAlignNum = 0;
@@ -1262,8 +1342,8 @@ Returns: SectType = EFI_SECTION_SMM_DEPEX;
} else if (stricmp (SectionName, mSectionTypeName[EFI_SECTION_VERSION]) == 0) {
SectType = EFI_SECTION_VERSION;
- if (VersionNumber < 0 || VersionNumber > 9999) {
- Error (NULL, 0, 1003, "Invalid option value", "%d is not in 0~9999", VersionNumber);
+ if (VersionNumber < 0 || VersionNumber > 65535) {
+ Error (NULL, 0, 1003, "Invalid option value", "%d is not in 0~65535", VersionNumber);
goto Finish;
}
VerboseMsg ("Version section number is %d", VersionNumber);
@@ -1463,7 +1543,11 @@ Returns: // Get output file length
//
if (SectType != EFI_SECTION_ALL) {
- InputLength = SECTION_SIZE (OutFileBuffer);
+ SectionHeader = (EFI_COMMON_SECTION_HEADER *)OutFileBuffer;
+ InputLength = *(UINT32 *)SectionHeader->Size & 0x00ffffff;
+ if (InputLength == 0xffffff) {
+ InputLength = ((EFI_COMMON_SECTION_HEADER2 *)SectionHeader)->ExtendedSize;
+ }
}
//
diff --git a/BaseTools/Source/C/Include/Common/BuildVersion.h b/BaseTools/Source/C/Include/Common/BuildVersion.h index f524cefc9b..b84bd05714 100644 --- a/BaseTools/Source/C/Include/Common/BuildVersion.h +++ b/BaseTools/Source/C/Include/Common/BuildVersion.h @@ -14,4 +14,4 @@ **/
-#define __BUILD_VERSION "Build 2601"
+#define __BUILD_VERSION "Build 2610"
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h index e66f40ca43..1790c3a1e8 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h @@ -1,7 +1,7 @@ /** @file
The firmware file related definitions in PI.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -64,6 +64,7 @@ typedef UINT8 EFI_FFS_FILE_STATE; //
// FFS File Attributes.
//
+#define FFS_ATTRIB_LARGE_FILE 0x01
#define FFS_ATTRIB_FIXED 0x04
#define FFS_ATTRIB_DATA_ALIGNMENT 0x38
#define FFS_ATTRIB_CHECKSUM 0x40
@@ -104,6 +105,17 @@ typedef struct { EFI_FFS_FILE_STATE State;
} EFI_FFS_FILE_HEADER;
+typedef struct {
+ EFI_GUID Name;
+ EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
+ EFI_FV_FILETYPE Type;
+ EFI_FFS_FILE_ATTRIBUTES Attributes;
+ UINT8 Size[3];
+ EFI_FFS_FILE_STATE State;
+ UINT32 ExtendedSize;
+} EFI_FFS_FILE_HEADER2;
+
+#define MAX_FFS_SIZE 0x1000000
typedef UINT8 EFI_SECTION_TYPE;
@@ -142,11 +154,20 @@ typedef struct { EFI_SECTION_TYPE Type;
} EFI_COMMON_SECTION_HEADER;
+typedef struct {
+ UINT8 Size[3];
+ EFI_SECTION_TYPE Type;
+ UINT32 ExtendedSize;
+} EFI_COMMON_SECTION_HEADER2;
+
+#define MAX_SECTION_SIZE 0x1000000
+
//
// Leaf section type that contains an
// IA-32 16-bit executable image.
//
typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;
//
// CompressionType of EFI_COMPRESSION_SECTION.
@@ -163,15 +184,23 @@ typedef struct { UINT8 CompressionType;
} EFI_COMPRESSION_SECTION;
+typedef struct {
+ EFI_COMMON_SECTION_HEADER2 CommonHeader;
+ UINT32 UncompressedLength;
+ UINT8 CompressionType;
+} EFI_COMPRESSION_SECTION2;
+
//
// Leaf section which could be used to determine the dispatch order of DXEs.
//
typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;
//
// Leaf section witch contains a PI FV.
//
typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;
//
// Leaf section which contains a single GUID.
@@ -181,6 +210,11 @@ typedef struct { EFI_GUID SubTypeGuid;
} EFI_FREEFORM_SUBTYPE_GUID_SECTION;
+typedef struct {
+ EFI_COMMON_SECTION_HEADER2 CommonHeader;
+ EFI_GUID SubTypeGuid;
+} EFI_FREEFORM_SUBTYPE_GUID_SECTION2;
+
//
// Attributes of EFI_GUID_DEFINED_SECTION
//
@@ -196,30 +230,42 @@ typedef struct { UINT16 Attributes;
} EFI_GUID_DEFINED_SECTION;
+typedef struct {
+ EFI_COMMON_SECTION_HEADER2 CommonHeader;
+ EFI_GUID SectionDefinitionGuid;
+ UINT16 DataOffset;
+ UINT16 Attributes;
+} EFI_GUID_DEFINED_SECTION2;
+
//
// Leaf section which contains PE32+ image.
//
typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;
//
// Leaf section which contains PIC image.
//
typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;
//
// Leaf section which used to determine the dispatch order of PEIMs.
//
typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;
//
// Leaf section which constains the position-independent-code image.
//
typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;
//
// Leaf section which contains an array of zero or more bytes.
//
typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
+typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;
//
// Leaf section which contains a unicode string that
@@ -234,6 +280,14 @@ typedef struct { CHAR16 FileNameString[1];
} EFI_USER_INTERFACE_SECTION;
+typedef struct {
+ EFI_COMMON_SECTION_HEADER2 CommonHeader;
+
+ //
+ // Array of unicode string.
+ //
+ CHAR16 FileNameString[1];
+} EFI_USER_INTERFACE_SECTION2;
//
// Leaf section which contains a numeric build number and
@@ -245,6 +299,11 @@ typedef struct { CHAR16 VersionString[1];
} EFI_VERSION_SECTION;
+typedef struct {
+ EFI_COMMON_SECTION_HEADER2 CommonHeader;
+ UINT16 BuildNumber;
+ CHAR16 VersionString[1];
+} EFI_VERSION_SECTION2;
#define SECTION_SIZE(SectionHeaderPtr) \
((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
@@ -266,6 +325,23 @@ typedef union { EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
EFI_RAW_SECTION *RawSection;
+ //
+ // For section whose size is equal or greater than 0x1000000
+ //
+ EFI_COMMON_SECTION_HEADER2 *CommonHeader2;
+ EFI_COMPRESSION_SECTION2 *CompressionSection2;
+ EFI_GUID_DEFINED_SECTION2 *GuidDefinedSection2;
+ EFI_PE32_SECTION2 *Pe32Section2;
+ EFI_PIC_SECTION2 *PicSection2;
+ EFI_TE_SECTION2 *TeSection2;
+ EFI_PEI_DEPEX_SECTION2 *PeimHeaderSection2;
+ EFI_DXE_DEPEX_SECTION2 *DependencySection2;
+ EFI_VERSION_SECTION2 *VersionSection2;
+ EFI_USER_INTERFACE_SECTION2 *UISection2;
+ EFI_COMPATIBILITY16_SECTION2 *Code16Section2;
+ EFI_FIRMWARE_VOLUME_IMAGE_SECTION2 *FVImageSection2;
+ EFI_FREEFORM_SUBTYPE_GUID_SECTION2 *FreeformSubtypeSection2;
+ EFI_RAW_SECTION2 *RawSection2;
} EFI_FILE_SECTION_POINTER;
#endif
diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h index 0c8e29e1ce..ea06eee695 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareVolume.h @@ -1,7 +1,7 @@ /** @file
The firmware volume related definitions in PI.
- Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -54,6 +54,7 @@ typedef UINT32 EFI_FVB_ATTRIBUTES_2; #define EFI_FVB2_WRITE_LOCK_CAP 0x00004000
#define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000
#define EFI_FVB2_ALIGNMENT 0x001F0000
+#define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
#define EFI_FVB2_ALIGNMENT_1 0x00000000
#define EFI_FVB2_ALIGNMENT_2 0x00010000
#define EFI_FVB2_ALIGNMENT_4 0x00020000
diff --git a/BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h b/BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h index a1c6b55f1d..3a4be34634 100644 --- a/BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h +++ b/BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h @@ -2,7 +2,7 @@ Guid used to define the Firmware File System. See PI spec volume 3 for more
details.
- Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2013, 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
@@ -30,12 +30,18 @@ 0x8c8ce578, 0x8a3d, 0x4f1c, {0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } \
}
+#define EFI_FIRMWARE_FILE_SYSTEM3_GUID \
+ { \
+ 0x5473c07a, 0x3dcb, 0x4dca, {0xbd, 0x6f, 0x1e, 0x96, 0x89, 0xe7, 0x34, 0x9a } \
+ }
+
#define EFI_FFS_VOLUME_TOP_FILE_GUID \
{ \
0x1BA0062E, 0xC779, 0x4582, {0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x09 } \
}
extern EFI_GUID gEfiFirmwareFileSystem2Guid;
+extern EFI_GUID gEfiFirmwareFileSystem3Guid;
extern EFI_GUID gEfiFirmwareVolumeTopFileGuid;
#endif
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 61b68f5fb7..6f15aaa452 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -136,6 +136,7 @@ VfrParserStart ( #token MapTitle("maptitle") "maptitle"
#token MapGuid("mapguid") "mapguid"
#token Subtitle("subtitle") "subtitle"
+#token EndSubtitle("endsubtitle") "endsubtitle"
#token Help("help") "help"
#token Text("text") "text"
#token Option("option") "option"
@@ -1018,12 +1019,29 @@ vfrStatementVarStoreNameValue : <<
EFI_GUID Guid;
CIfrVarStoreNameValue VSNVObj;
- EFI_VARSTORE_ID VarStoreId;
+ EFI_VARSTORE_ID VarStoreId = EFI_VARSTORE_ID_INVALID;
+ BOOLEAN Created = FALSE;
>>
L:NameValueVarStore << VSNVObj.SetLineNo(L->getLine()); >>
- SN:StringIdentifier "," << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText()), SN); >>
+ SN:StringIdentifier ","
+ {
+ VarId "=" ID:Number "," <<
+ _PCATCH(
+ (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
+ (INTN)TRUE,
+ ID,
+ "varid 0 is not allowed."
+ );
+ >>
+ }
(
- Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
+ Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," <<
+ if (!Created) {
+ _PCATCH(mCVfrDataStorage.DeclareNameVarStoreBegin (SN->getText(), VarStoreId), SN);
+ Created = TRUE;
+ }
+ _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN);
+ >>
)+
Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
<<
@@ -1628,8 +1646,14 @@ vfrStatementSubTitle : {
"," FLAGS "=" vfrSubtitleFlags[SObj]
}
- { vfrStatementStatTagList "," }
- E:";" << CRT_END_OP (E); >>
+ (
+ {vfrStatementStatTagList "," }
+ E:";" << CRT_END_OP (E); >>
+ |
+ { "," vfrStatementStatTagList}
+ { "," (vfrStatementStat | vfrStatementQuestions)*}
+ E: EndSubtitle ";" << CRT_END_OP (E); >>
+ )
;
vfrSubtitleFlags [CIfrSubtitle & SObj] :
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index 21a479db68..7c1383eb7a 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -1512,21 +1512,30 @@ CVfrDataStorage::MarkVarStoreIdUnused ( EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareNameVarStoreBegin (
- IN CHAR8 *StoreName
+ IN CHAR8 *StoreName,
+ IN EFI_VARSTORE_ID VarStoreId
)
{
SVfrVarStorageNode *pNode = NULL;
- EFI_VARSTORE_ID VarStoreId;
+ EFI_VARSTORE_ID TmpVarStoreId;
if (StoreName == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
- if (GetVarStoreId (StoreName, &VarStoreId) == VFR_RETURN_SUCCESS) {
+ if (GetVarStoreId (StoreName, &TmpVarStoreId) == VFR_RETURN_SUCCESS) {
return VFR_RETURN_REDEFINED;
}
+
+ if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
+ VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_NAME);
+ } else {
+ if (ChekVarStoreIdFree (VarStoreId) == FALSE) {
+ return VFR_RETURN_VARSTOREID_REDEFINED;
+ }
+ MarkVarStoreIdUsed (VarStoreId);
+ }
- VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_NAME);
if ((pNode = new SVfrVarStorageNode (StoreName, VarStoreId)) == NULL) {
return VFR_RETURN_UNDEFINED;
}
@@ -2619,6 +2628,14 @@ CVfrQuestionDB::RegisterNewDateQuestion ( CHAR8 Index;
if (BaseVarId == NULL && Name == NULL) {
+ if (QuestionId == EFI_QUESTION_ID_INVALID) {
+ QuestionId = GetFreeQuestionId ();
+ } else {
+ if (ChekQuestionIdFree (QuestionId) == FALSE) {
+ goto Err;
+ }
+ MarkQuestionIdUsed (QuestionId);
+ }
return;
}
@@ -2787,6 +2804,14 @@ CVfrQuestionDB::RegisterNewTimeQuestion ( CHAR8 Index;
if (BaseVarId == NULL && Name == NULL) {
+ if (QuestionId == EFI_QUESTION_ID_INVALID) {
+ QuestionId = GetFreeQuestionId ();
+ } else {
+ if (ChekQuestionIdFree (QuestionId) == FALSE) {
+ goto Err;
+ }
+ MarkQuestionIdUsed (QuestionId);
+ }
return;
}
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h index 2847a74a7b..c8f5333641 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h @@ -300,7 +300,7 @@ public: SVfrVarStorageNode * GetEfiVarStoreList () {
return mEfiVarStoreList;
}
- EFI_VFR_RETURN_CODE DeclareNameVarStoreBegin (CHAR8 *);
+ EFI_VFR_RETURN_CODE DeclareNameVarStoreBegin (CHAR8 *, EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE NameTableAddItem (EFI_STRING_ID);
EFI_VFR_RETURN_CODE DeclareNameVarStoreEnd (EFI_GUID *);
|