summaryrefslogtreecommitdiff
path: root/BaseTools/Source
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2013-11-18 07:41:21 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-18 07:41:21 +0000
commite8a47801a1dfdb148b1bfcd5bdc8ebc3bf51f92d (patch)
tree04e3ec271347360a5e9da898f1dccbce3d94681f /BaseTools/Source
parentfddbbc661eeff8e9f94942fa2d47fb637404a040 (diff)
downloadedk2-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')
-rw-r--r--BaseTools/Source/C/Common/FvLib.c131
-rw-r--r--BaseTools/Source/C/Common/FvLib.h26
-rw-r--r--BaseTools/Source/C/GenFfs/GenFfs.c65
-rw-r--r--BaseTools/Source/C/GenFv/GenFv.c23
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.c236
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.h6
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c20
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c19
-rw-r--r--BaseTools/Source/C/GenSec/GenSec.c244
-rw-r--r--BaseTools/Source/C/Include/Common/BuildVersion.h2
-rw-r--r--BaseTools/Source/C/Include/Common/PiFirmwareFile.h78
-rw-r--r--BaseTools/Source/C/Include/Common/PiFirmwareVolume.h3
-rw-r--r--BaseTools/Source/C/Include/Guid/PiFirmwareFileSystem.h8
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g34
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp33
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.h2
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py377
-rw-r--r--BaseTools/Source/Python/AutoGen/GenC.py907
-rw-r--r--BaseTools/Source/Python/AutoGen/GenPcdDb.py1566
-rw-r--r--BaseTools/Source/Python/BPDG/GenVpd.py14
-rw-r--r--BaseTools/Source/Python/Common/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Common/DataType.py1
-rw-r--r--BaseTools/Source/Python/Common/GlobalData.py19
-rw-r--r--BaseTools/Source/Python/Common/Misc.py81
-rw-r--r--BaseTools/Source/Python/Common/VpdInfoFile.py25
-rw-r--r--BaseTools/Source/Python/CommonDataClass/DataClass.py1
-rw-r--r--BaseTools/Source/Python/CommonDataClass/FdfClass.py4
-rw-r--r--BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py1
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py160
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py126
-rw-r--r--BaseTools/Source/Python/GenFds/Section.py2
-rw-r--r--BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py57
-rw-r--r--BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py14
-rw-r--r--BaseTools/Source/Python/UPT/BuildVersion.py2
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileCommentParser.py28
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileParser.py26
-rw-r--r--BaseTools/Source/Python/Workspace/MetaFileTable.py4
-rw-r--r--BaseTools/Source/Python/Workspace/WorkspaceDatabase.py320
-rw-r--r--BaseTools/Source/Python/build/build.py2
39 files changed, 3425 insertions, 1244 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 *);
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 6711880f60..71d0d757d8 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1,7 +1,7 @@
## @file
# Generate AutoGen.h, AutoGen.c and *.depex files
#
-# Copyright (c) 2007 - 2011, 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
@@ -34,9 +34,12 @@ import Common.GlobalData as GlobalData
from GenFds.FdfParser import *
from CommonDataClass.CommonClass import SkuInfoClass
from Workspace.BuildClassObject import *
+from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile
import Common.VpdInfoFile as VpdInfoFile
+from GenPcdDb import CreatePcdDatabaseCode
+from Workspace.MetaFileCommentParser import UsageList
-## Regular expression for splitting Dependency Expression stirng into tokens
+## Regular expression for splitting Dependency Expression string into tokens
gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")
## Mapping Makefile type
@@ -59,13 +62,7 @@ gAutoGenDepexFileName = "%(module_name)s.depex"
#
# Template string to generic AsBuilt INF
#
-gAsBuiltInfHeaderString = TemplateString("""## @file
-# ${module_name}
-#
-# DO NOT EDIT
-# FILE auto-generated Binary INF
-#
-##
+gAsBuiltInfHeaderString = TemplateString("""${header_comments}
[Defines]
INF_VERSION = 0x00010016
@@ -73,6 +70,7 @@ gAsBuiltInfHeaderString = TemplateString("""## @file
FILE_GUID = ${module_guid}
MODULE_TYPE = ${module_module_type}
VERSION_STRING = ${module_version_string}${BEGIN}
+ PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}
UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}
@@ -82,8 +80,21 @@ gAsBuiltInfHeaderString = TemplateString("""## @file
[Binaries.${module_arch}]${BEGIN}
${binary_item}${END}
-[PcdEx]${BEGIN}
- ${pcd_item}${END}
+[PatchPcd.${module_arch}]${BEGIN}
+ ${patchablepcd_item}
+${END}
+[Protocols.${module_arch}]${BEGIN}
+ ${protocol_item}
+${END}
+[Ppis.${module_arch}]${BEGIN}
+ ${ppi_item}
+${END}
+[Guids.${module_arch}]${BEGIN}
+ ${guid_item}
+${END}
+[PcdEx.${module_arch}]${BEGIN}
+ ${pcd_item}
+${END}
## @AsBuilt${BEGIN}
## ${flags_item}${END}
@@ -228,15 +239,6 @@ class WorkspaceAutoGen(AutoGen):
ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"
% (self.BuildTarget, " ".join(self.Platform.BuildTargets)))
- # Validate SKU ID
- if not self.SkuId:
- self.SkuId = 'DEFAULT'
-
- if self.SkuId not in self.Platform.SkuIds:
- EdkLogger.error("build", PARAMETER_INVALID,
- ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"
- % (self.SkuId, " ".join(self.Platform.SkuIds.keys())))
-
# parse FDF file to get PCDs in it, if any
if not self.FdfFile:
self.FdfFile = self.Platform.FlashDefinition
@@ -867,7 +869,7 @@ class PlatformAutoGen(AutoGen):
for PcdFromModule in M.ModulePcdList+M.LibraryPcdList:
# make sure that the "VOID*" kind of datum has MaxDatumSize set
- if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize == None:
+ if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']:
NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))
if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:
@@ -938,31 +940,19 @@ class PlatformAutoGen(AutoGen):
# Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.
#
for PcdKey in PlatformPcds:
- Pcd = self.Platform.Pcds[PcdKey]
- if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:
- Pcd = VpdPcdDict[PcdKey]
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
- Sku.VpdOffset = Sku.VpdOffset.strip()
- #
- # Fix the optional data of VPD PCD.
- #
- if (Pcd.DatumType.strip() != "VOID*"):
- if Sku.DefaultValue == '':
- Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize
- Pcd.MaxDatumSize = None
- else:
- EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",
- File=self.MetaFile,
- ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"
- % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path))
-
- VpdFile.Add(Pcd, Sku.VpdOffset)
- # if the offset of a VPD is *, then it need to be fixed up by third party tool.
- if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
- NeedProcessVpdMapFile = True
- if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':
- EdkLogger.error("Build", FILE_NOT_FOUND, \
- "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
+ Pcd = self.Platform.Pcds[PcdKey]
+ if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \
+ PcdKey in VpdPcdDict:
+ Pcd = VpdPcdDict[PcdKey]
+ for (SkuName,Sku) in Pcd.SkuInfoList.items():
+ Sku.VpdOffset = Sku.VpdOffset.strip()
+ VpdFile.Add(Pcd, Sku.VpdOffset)
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
+ NeedProcessVpdMapFile = True
+ if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':
+ EdkLogger.error("Build", FILE_NOT_FOUND, \
+ "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
#
@@ -983,32 +973,46 @@ class PlatformAutoGen(AutoGen):
# Not found, it should be signature
if not FoundFlag :
# just pick the a value to determine whether is unicode string type
- Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
- Sku.VpdOffset = Sku.VpdOffset.strip()
-
- # Need to iterate DEC pcd information to get the value & datumtype
- for eachDec in self.PackageList:
- for DecPcd in eachDec.Pcds:
- DecPcdEntry = eachDec.Pcds[DecPcd]
- if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
- (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):
- # Print warning message to let the developer make a determine.
- EdkLogger.warn("build", "Unreferenced vpd pcd used!",
- File=self.MetaFile, \
- ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \
- %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))
-
- DscPcdEntry.DatumType = DecPcdEntry.DatumType
- DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue
- # Only fix the value while no value provided in DSC file.
- if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
- DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
-
+ for (SkuName,Sku) in DscPcdEntry.SkuInfoList.items():
+ Sku.VpdOffset = Sku.VpdOffset.strip()
+
+ # Need to iterate DEC pcd information to get the value & datumtype
+ for eachDec in self.PackageList:
+ for DecPcd in eachDec.Pcds:
+ DecPcdEntry = eachDec.Pcds[DecPcd]
+ if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \
+ (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):
+ # Print warning message to let the developer make a determine.
+ EdkLogger.warn("build", "Unreferenced vpd pcd used!",
+ File=self.MetaFile, \
+ ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \
+ %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))
+
+ DscPcdEntry.DatumType = DecPcdEntry.DatumType
+ DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue
+ DscPcdEntry.TokenValue = DecPcdEntry.TokenValue
+ DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]
+ # Only fix the value while no value provided in DSC file.
+ if (Sku.DefaultValue == "" or Sku.DefaultValue==None):
+ DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue
+
+ if DscPcdEntry not in self._DynamicPcdList:
+ self._DynamicPcdList.append(DscPcdEntry)
+# Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
+ Sku.VpdOffset = Sku.VpdOffset.strip()
+ PcdValue = Sku.DefaultValue
+ VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
+ if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
+ NeedProcessVpdMapFile = True
+ if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"):
+ UnicodePcdArray.append(DscPcdEntry)
+ elif len(Sku.VariableName) > 0:
+ HiiPcdArray.append(DscPcdEntry)
+ else:
+ OtherPcdArray.append(DscPcdEntry)
+
+ # if the offset of a VPD is *, then it need to be fixed up by third party tool.
- VpdFile.Add(DscPcdEntry, Sku.VpdOffset)
- # if the offset of a VPD is *, then it need to be fixed up by third party tool.
- if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":
- NeedProcessVpdMapFile = True
if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \
@@ -1055,9 +1059,11 @@ class PlatformAutoGen(AutoGen):
# Fixup "*" offset
for Pcd in self._DynamicPcdList:
# just pick the a value to determine whether is unicode string type
- Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]
- if Sku.VpdOffset == "*":
- Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0].strip()
+ i = 0
+ for (SkuName,Sku) in Pcd.SkuInfoList.items():
+ if Sku.VpdOffset == "*":
+ Sku.VpdOffset = VpdFile.GetOffset(Pcd)[i].strip()
+ i += 1
else:
EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)
@@ -1605,13 +1611,13 @@ class PlatformAutoGen(AutoGen):
% (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))
Value = ToPcd.DefaultValue
if Value in [None, '']:
- ToPcd.MaxDatumSize = 1
+ ToPcd.MaxDatumSize = '1'
elif Value[0] == 'L':
- ToPcd.MaxDatumSize = str(len(Value) * 2)
+ ToPcd.MaxDatumSize = str((len(Value) - 2) * 2)
elif Value[0] == '{':
ToPcd.MaxDatumSize = str(len(Value.split(',')))
else:
- ToPcd.MaxDatumSize = str(len(Value))
+ ToPcd.MaxDatumSize = str(len(Value) - 1)
# apply default SKU for dynamic PCDS if specified one is not available
if (ToPcd.Type in PCD_DYNAMIC_TYPE_LIST or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_LIST) \
@@ -2004,9 +2010,14 @@ class ModuleAutoGen(AutoGen):
self._DerivedPackageList = None
self._ModulePcdList = None
self._LibraryPcdList = None
+ self._PcdComments = sdict()
self._GuidList = None
+ self._GuidsUsedByPcd = None
+ self._GuidComments = sdict()
self._ProtocolList = None
+ self._ProtocolComments = sdict()
self._PpiList = None
+ self._PpiComments = sdict()
self._DepexList = None
self._DepexExpressionList = None
self._BuildOption = None
@@ -2107,6 +2118,10 @@ class ModuleAutoGen(AutoGen):
self._LibraryFlag = False
return self._LibraryFlag
+ ## Check if the module is binary module or not
+ def _IsBinaryModule(self):
+ return self.Module.IsBinaryModule
+
## Return the directory to store intermediate files of the module
def _GetBuildDir(self):
if self._BuildDir == None:
@@ -2563,6 +2578,12 @@ class ModuleAutoGen(AutoGen):
self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module)
return self._DependentLibraryList
+ @staticmethod
+ def UpdateComments(Recver, Src):
+ for Key in Src:
+ if Key not in Recver:
+ Recver[Key] = []
+ Recver[Key].extend(Src[Key])
## Get the list of PCDs from current module
#
# @retval list The list of PCD
@@ -2571,6 +2592,7 @@ class ModuleAutoGen(AutoGen):
if self._ModulePcdList == None:
# apply PCD settings from platform
self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)
+ self.UpdateComments(self._PcdComments, self.Module.PcdComments)
return self._ModulePcdList
## Get the list of PCDs from dependent libraries
@@ -2583,6 +2605,7 @@ class ModuleAutoGen(AutoGen):
if not self.IsLibrary:
# get PCDs from dependent libraries
for Library in self.DependentLibraryList:
+ self.UpdateComments(self._PcdComments, Library.PcdComments)
for Key in Library.Pcds:
# skip duplicated PCDs
if Key in self.Module.Pcds or Key in Pcds:
@@ -2603,8 +2626,17 @@ class ModuleAutoGen(AutoGen):
self._GuidList = self.Module.Guids
for Library in self.DependentLibraryList:
self._GuidList.update(Library.Guids)
+ self.UpdateComments(self._GuidComments, Library.GuidComments)
+ self.UpdateComments(self._GuidComments, self.Module.GuidComments)
return self._GuidList
+ def GetGuidsUsedByPcd(self):
+ if self._GuidsUsedByPcd == None:
+ self._GuidsUsedByPcd = sdict()
+ self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())
+ for Library in self.DependentLibraryList:
+ self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())
+ return self._GuidsUsedByPcd
## Get the protocol value mapping
#
# @retval dict The mapping between protocol cname and its value
@@ -2614,6 +2646,8 @@ class ModuleAutoGen(AutoGen):
self._ProtocolList = self.Module.Protocols
for Library in self.DependentLibraryList:
self._ProtocolList.update(Library.Protocols)
+ self.UpdateComments(self._ProtocolComments, Library.ProtocolComments)
+ self.UpdateComments(self._ProtocolComments, self.Module.ProtocolComments)
return self._ProtocolList
## Get the PPI value mapping
@@ -2625,6 +2659,8 @@ class ModuleAutoGen(AutoGen):
self._PpiList = self.Module.Ppis
for Library in self.DependentLibraryList:
self._PpiList.update(Library.Ppis)
+ self.UpdateComments(self._PpiComments, Library.PpiComments)
+ self.UpdateComments(self._PpiComments, self.Module.PpiComments)
return self._PpiList
## Get the list of include search path
@@ -2681,38 +2717,74 @@ class ModuleAutoGen(AutoGen):
### TODO: How to handles mixed source and binary modules
- # Find all DynamicEx PCDs used by this module and dependent libraries
+ # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries
# Also find all packages that the DynamicEx PCDs depend on
Pcds = []
+ PatchablePcds = {}
Packages = []
+ PcdCheckList = []
+ PcdTokenSpaceList = []
for Pcd in self.ModulePcdList + self.LibraryPcdList:
- if Pcd.Type in GenC.gDynamicExPcd:
- if Pcd not in Pcds:
- Pcds += [Pcd]
- for Package in self.DerivedPackageList:
- if Package not in Packages:
- if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:
- Packages += [Package]
- elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:
- Packages += [Package]
+ if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
+ PatchablePcds[Pcd.TokenCName] = Pcd
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'PatchableInModule'))
+ elif Pcd.Type in GenC.gDynamicExPcd:
+ if Pcd not in Pcds:
+ Pcds += [Pcd]
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx'))
+ PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic'))
+ PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)
+ GuidList = sdict()
+ GuidList.update(self.GuidList)
+ for TokenSpace in self.GetGuidsUsedByPcd():
+ # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list
+ # The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs
+ if TokenSpace not in PcdTokenSpaceList and TokenSpace in GuidList:
+ GuidList.pop(TokenSpace)
+ CheckList = (GuidList, self.PpiList, self.ProtocolList, PcdCheckList)
+ for Package in self.DerivedPackageList:
+ if Package in Packages:
+ continue
+ BeChecked = (Package.Guids, Package.Ppis, Package.Protocols, Package.Pcds)
+ Found = False
+ for Index in range(len(BeChecked)):
+ for Item in CheckList[Index]:
+ if Item in BeChecked[Index]:
+ Packages += [Package]
+ Found = True
+ break
+ if Found: break
ModuleType = self.ModuleType
if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:
- ModuleType = 'DXE_DRIVER'
+ ModuleType = 'DXE_DRIVER'
+
+ DriverType = ''
+ if self.PcdIsDriver != '':
+ DriverType = self.PcdIsDriver
AsBuiltInfDict = {
'module_name' : self.Name,
'module_guid' : self.Guid,
'module_module_type' : ModuleType,
'module_version_string' : self.Version,
+ 'pcd_is_driver_string' : [],
'module_uefi_specification_version' : [],
'module_pi_specification_version' : [],
'module_arch' : self.Arch,
'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],
'binary_item' : [],
+ 'patchablepcd_item' : [],
'pcd_item' : [],
- 'flags_item' : []
+ 'protocol_item' : [],
+ 'ppi_item' : [],
+ 'guid_item' : [],
+ 'flags_item' : [],
+ 'libraryclasses_item' : []
}
+ AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion
+ if DriverType:
+ AsBuiltInfDict['pcd_is_driver_string'] += [DriverType]
if 'UEFI_SPECIFICATION_VERSION' in self.Specification:
AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]
@@ -2744,9 +2816,125 @@ class ModuleAutoGen(AutoGen):
if self.ModuleType in ['DXE_SMM_DRIVER']:
AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']
+ for Root, Dirs, Files in os.walk(OutputDir):
+ for File in Files:
+ if File.lower().endswith('.pdb'):
+ AsBuiltInfDict['binary_item'] += ['DISPOSABLE|' + File]
+ HeaderComments = self.Module.HeaderComments
+ StartPos = 0
+ for Index in range(len(HeaderComments)):
+ if HeaderComments[Index].find('@BinaryHeader') != -1:
+ HeaderComments[Index] = HeaderComments[Index].replace('@BinaryHeader', '@file')
+ StartPos = Index
+ break
+ AsBuiltInfDict['header_comments'] = '\n'.join(HeaderComments[StartPos:]).replace(':#', '://')
+ GenList = [
+ (self.ProtocolList, self._ProtocolComments, 'protocol_item'),
+ (self.PpiList, self._PpiComments, 'ppi_item'),
+ (GuidList, self._GuidComments, 'guid_item')
+ ]
+ for Item in GenList:
+ for CName in Item[0]:
+ Comments = ''
+ if CName in Item[1]:
+ Comments = '\n '.join(Item[1][CName])
+ Entry = CName
+ if Comments:
+ Entry = Comments + '\n ' + CName
+ AsBuiltInfDict[Item[2]].append(Entry)
+ PatchList = parsePcdInfoFromMapFile(
+ os.path.join(self.OutputDir, self.Name + '.map'),
+ os.path.join(self.OutputDir, self.Name + '.efi')
+ )
+ if PatchList:
+ for PatchPcd in PatchList:
+ if PatchPcd[0] not in PatchablePcds:
+ continue
+ Pcd = PatchablePcds[PatchPcd[0]]
+ PcdValue = ''
+ if Pcd.DatumType != 'VOID*':
+ HexFormat = '0x%02x'
+ if Pcd.DatumType == 'UINT16':
+ HexFormat = '0x%04x'
+ elif Pcd.DatumType == 'UINT32':
+ HexFormat = '0x%08x'
+ elif Pcd.DatumType == 'UINT64':
+ HexFormat = '0x%016x'
+ PcdValue = HexFormat % int(Pcd.DefaultValue, 0)
+ else:
+ if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ )
+ ArraySize = int(Pcd.MaxDatumSize, 0)
+ PcdValue = Pcd.DefaultValue
+ if PcdValue[0] != '{':
+ Unicode = False
+ if PcdValue[0] == 'L':
+ Unicode = True
+ PcdValue = PcdValue.lstrip('L')
+ PcdValue = eval(PcdValue)
+ NewValue = '{'
+ for Index in range(0, len(PcdValue)):
+ if Unicode:
+ CharVal = ord(PcdValue[Index])
+ NewValue = NewValue + '0x%02x' % (CharVal & 0x00FF) + ', ' \
+ + '0x%02x' % (CharVal >> 8) + ', '
+ else:
+ NewValue = NewValue + '0x%02x' % (ord(PcdValue[Index]) % 0x100) + ', '
+ Padding = '0x00, '
+ if Unicode:
+ Padding = Padding * 2
+ ArraySize = ArraySize / 2
+ if ArraySize < (len(PcdValue) + 1):
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ )
+ if ArraySize > len(PcdValue) + 1:
+ NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1)
+ PcdValue = NewValue + Padding.strip().rstrip(',') + '}'
+ elif len(PcdValue.split(',')) <= ArraySize:
+ PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(',')))
+ PcdValue += '}'
+ else:
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ )
+ PcdItem = '%s.%s|%s|0x%X' % \
+ (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, PcdValue, PatchPcd[1])
+ PcdComments = ''
+ if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:
+ PcdComments = '\n '.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])
+ if PcdComments:
+ PcdItem = PcdComments + '\n ' + PcdItem
+ AsBuiltInfDict['patchablepcd_item'].append(PcdItem)
for Pcd in Pcds:
- AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]
-
+ PcdComments = ''
+ PcdCommentList = []
+ HiiInfo = ''
+ if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:
+ for SkuName in Pcd.SkuInfoList:
+ SkuInfo = Pcd.SkuInfoList[SkuName]
+ HiiInfo = '## %s|%s|%s' % (SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInfo.VariableOffset)
+ break
+ if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:
+ PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]
+ if HiiInfo:
+ UsageIndex = -1
+ for Index, Comment in enumerate(PcdCommentList):
+ for Usage in UsageList:
+ if Comment.find(Usage) != -1:
+ UsageIndex = Index
+ break
+ if UsageIndex != -1:
+ PcdCommentList[UsageIndex] = PcdCommentList[UsageIndex] + ' ' + HiiInfo
+ else:
+ PcdCommentList.append('## ' + HiiInfo)
+ PcdComments = '\n '.join(PcdCommentList)
+ PcdEntry = Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName
+ if PcdComments:
+ PcdEntry = PcdComments + '\n ' + PcdEntry
+ AsBuiltInfDict['pcd_item'] += [PcdEntry]
for Item in self.BuildOption:
if 'FLAGS' in self.BuildOption[Item]:
AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]
@@ -2793,6 +2981,11 @@ class ModuleAutoGen(AutoGen):
if self.IsCodeFileCreated:
return
+ # Need to generate PcdDatabase even PcdDriver is binarymodule
+ if self.IsBinaryModule and self.PcdIsDriver != '':
+ CreatePcdDatabaseCode(self, TemplateString(), TemplateString())
+ return
+
if not self.IsLibrary and CreateLibraryCodeFile:
for LibraryAutoGen in self.LibraryAutoGenList:
LibraryAutoGen.CreateCodeFile()
@@ -2875,7 +3068,7 @@ class ModuleAutoGen(AutoGen):
Specification = property(_GetSpecification)
IsLibrary = property(_IsLibrary)
-
+ IsBinaryModule = property(_IsBinaryModule)
BuildDir = property(_GetBuildDir)
OutputDir = property(_GetOutputDir)
DebugDir = property(_GetDebugDir)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 2eb920417e..63ba2b241e 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1,7 +1,7 @@
## @file
# Routines for generating AutoGen.h and AutoGen.c
#
-# Copyright (c) 2007 - 2012, 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
@@ -22,6 +22,7 @@ from Common.DataType import *
from Common.Misc import *
from Common.String import StringToArray
from StrGather import *
+from GenPcdDb import CreatePcdDatabaseCode
## PCD type string
gItemTypeStringDatabase = {
@@ -49,252 +50,6 @@ gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64
gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'}
gDatumSizeStringDatabaseLib = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'}
-## Mapping between PCD driver type and EFI phase
-gPcdPhaseMap = {
- "PEI_PCD_DRIVER" : "PEI",
- "DXE_PCD_DRIVER" : "DXE"
-}
-
-gPcdDatabaseCommonAutoGenH = """
-//
-// The following definition will be generated by build tool
-//
-
-//
-// Common definitions
-//
-typedef UINT8 SKU_ID;
-
-#define PCD_TYPE_SHIFT 28
-
-#define PCD_TYPE_DATA (0x0U << PCD_TYPE_SHIFT)
-#define PCD_TYPE_HII (0x8U << PCD_TYPE_SHIFT)
-#define PCD_TYPE_VPD (0x4U << PCD_TYPE_SHIFT)
-#define PCD_TYPE_SKU_ENABLED (0x2U << PCD_TYPE_SHIFT)
-#define PCD_TYPE_STRING (0x1U << PCD_TYPE_SHIFT)
-
-#define PCD_TYPE_ALL_SET (PCD_TYPE_DATA | PCD_TYPE_HII | PCD_TYPE_VPD | PCD_TYPE_SKU_ENABLED | PCD_TYPE_STRING)
-
-#define PCD_DATUM_TYPE_SHIFT 24
-
-#define PCD_DATUM_TYPE_POINTER (0x0U << PCD_DATUM_TYPE_SHIFT)
-#define PCD_DATUM_TYPE_UINT8 (0x1U << PCD_DATUM_TYPE_SHIFT)
-#define PCD_DATUM_TYPE_UINT16 (0x2U << PCD_DATUM_TYPE_SHIFT)
-#define PCD_DATUM_TYPE_UINT32 (0x4U << PCD_DATUM_TYPE_SHIFT)
-#define PCD_DATUM_TYPE_UINT64 (0x8U << PCD_DATUM_TYPE_SHIFT)
-
-#define PCD_DATUM_TYPE_ALL_SET (PCD_DATUM_TYPE_POINTER | \\
- PCD_DATUM_TYPE_UINT8 | \\
- PCD_DATUM_TYPE_UINT16 | \\
- PCD_DATUM_TYPE_UINT32 | \\
- PCD_DATUM_TYPE_UINT64)
-
-#define PCD_DATABASE_OFFSET_MASK (~(PCD_TYPE_ALL_SET | PCD_DATUM_TYPE_ALL_SET))
-
-typedef struct {
- UINT32 ExTokenNumber;
- UINT16 LocalTokenNumber; // PCD Number of this particular platform build
- UINT16 ExGuidIndex; // Index of GuidTable
-} DYNAMICEX_MAPPING;
-
-typedef struct {
- UINT32 SkuDataStartOffset; //We have to use offsetof MACRO as we don't know padding done by compiler
- UINT32 SkuIdTableOffset; //Offset from the PCD_DB
-} SKU_HEAD;
-
-typedef struct {
- UINT32 StringIndex; // Offset in String Table in units of UINT32.
- UINT32 DefaultValueOffset; // Offset of the Default Value
- UINT16 GuidTableIndex; // Offset in Guid Table in units of GUID.
- UINT16 Offset; // Offset in Variable
-} VARIABLE_HEAD;
-
-typedef struct {
- UINT32 Offset;
-} VPD_HEAD;
-
-typedef UINT32 STRING_HEAD;
-
-typedef UINT16 SIZE_INFO;
-
-#define offsetof(s,m) (UINT32) (UINTN) &(((s *)0)->m)
-
-"""
-
-gPcdDatabaseEpilogueAutoGenH = """
-typedef struct {
- PEI_PCD_DATABASE PeiDb;
- DXE_PCD_DATABASE DxeDb;
-} PCD_DATABASE;
-
-#define PCD_TOTAL_TOKEN_NUMBER (PEI_LOCAL_TOKEN_NUMBER + DXE_LOCAL_TOKEN_NUMBER)
-
-"""
-
-gPcdDatabaseAutoGenH = TemplateString("""
-#define ${PHASE}_GUID_TABLE_SIZE ${GUID_TABLE_SIZE}
-#define ${PHASE}_STRING_TABLE_SIZE ${STRING_TABLE_SIZE}
-#define ${PHASE}_SKUID_TABLE_SIZE ${SKUID_TABLE_SIZE}
-#define ${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE ${LOCAL_TOKEN_NUMBER_TABLE_SIZE}
-#define ${PHASE}_LOCAL_TOKEN_NUMBER ${LOCAL_TOKEN_NUMBER}
-#define ${PHASE}_EXMAPPING_TABLE_SIZE ${EXMAPPING_TABLE_SIZE}
-#define ${PHASE}_EX_TOKEN_NUMBER ${EX_TOKEN_NUMBER}
-#define ${PHASE}_SIZE_TABLE_SIZE ${SIZE_TABLE_SIZE}
-#define ${PHASE}_GUID_TABLE_EMPTY ${GUID_TABLE_EMPTY}
-#define ${PHASE}_STRING_TABLE_EMPTY ${STRING_TABLE_EMPTY}
-#define ${PHASE}_SKUID_TABLE_EMPTY ${SKUID_TABLE_EMPTY}
-#define ${PHASE}_DATABASE_EMPTY ${DATABASE_EMPTY}
-#define ${PHASE}_EXMAP_TABLE_EMPTY ${EXMAP_TABLE_EMPTY}
-
-typedef struct {
-${BEGIN} UINT64 ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}];
-${END}
-${BEGIN} UINT64 ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64};
-${END}
-${BEGIN} UINT32 ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}];
-${END}
-${BEGIN} UINT32 ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32};
-${END}
-${BEGIN} VPD_HEAD ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}];
-${END}
- DYNAMICEX_MAPPING ExMapTable[${PHASE}_EXMAPPING_TABLE_SIZE];
- UINT32 LocalTokenNumberTable[${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
- GUID GuidTable[${PHASE}_GUID_TABLE_SIZE];
-${BEGIN} STRING_HEAD ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}];
-${END}
-${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}];
-${END}
-${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
-${END}
- SIZE_INFO SizeTable[${PHASE}_SIZE_TABLE_SIZE];
-${BEGIN} UINT16 ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}];
-${END}
-${BEGIN} UINT16 ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16};
-${END}
-${BEGIN} UINT8 ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}];
-${END}
-${BEGIN} UINT8 ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8};
-${END}
-${BEGIN} BOOLEAN ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}];
-${END}
-${BEGIN} BOOLEAN ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN};
-${END}
- UINT8 SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
-${SYSTEM_SKU_ID}
-} ${PHASE}_PCD_DATABASE_INIT;
-
-typedef struct {
-${PCD_DATABASE_UNINIT_EMPTY}
-${BEGIN} UINT64 ${UNINIT_CNAME_DECL_UINT64}_${UNINIT_GUID_DECL_UINT64}[${UNINIT_NUMSKUS_DECL_UINT64}];
-${END}
-${BEGIN} UINT32 ${UNINIT_CNAME_DECL_UINT32}_${UNINIT_GUID_DECL_UINT32}[${UNINIT_NUMSKUS_DECL_UINT32}];
-${END}
-${BEGIN} UINT16 ${UNINIT_CNAME_DECL_UINT16}_${UNINIT_GUID_DECL_UINT16}[${UNINIT_NUMSKUS_DECL_UINT16}];
-${END}
-${BEGIN} UINT8 ${UNINIT_CNAME_DECL_UINT8}_${UNINIT_GUID_DECL_UINT8}[${UNINIT_NUMSKUS_DECL_UINT8}];
-${END}
-${BEGIN} BOOLEAN ${UNINIT_CNAME_DECL_BOOLEAN}_${UNINIT_GUID_DECL_BOOLEAN}[${UNINIT_NUMSKUS_DECL_BOOLEAN}];
-${END}
-} ${PHASE}_PCD_DATABASE_UNINIT;
-
-#define PCD_${PHASE}_SERVICE_DRIVER_VERSION 2
-
-typedef struct {
- ${PHASE}_PCD_DATABASE_INIT Init;
- ${PHASE}_PCD_DATABASE_UNINIT Uninit;
-} ${PHASE}_PCD_DATABASE;
-
-#define ${PHASE}_NEX_TOKEN_NUMBER (${PHASE}_LOCAL_TOKEN_NUMBER - ${PHASE}_EX_TOKEN_NUMBER)
-""")
-
-gEmptyPcdDatabaseAutoGenC = TemplateString("""
-${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
- /* ExMapTable */
- {
- {0, 0, 0}
- },
- /* LocalTokenNumberTable */
- {
- 0
- },
- /* GuidTable */
- {
- {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
- },
- /* StringTable */
- { 0 },
- /* SizeTable */
- {
- 0, 0
- },
- /* SkuIdTable */
- { 0 },
- ${SYSTEM_SKU_ID_VALUE}
-};
-""")
-
-gPcdDatabaseAutoGenC = TemplateString("""
-${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
-${BEGIN} { ${INIT_VALUE_UINT64} }, /* ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}] */
-${END}
-${BEGIN} ${VARDEF_VALUE_UINT64}, /* ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64} */
-${END}
-${BEGIN} { ${INIT_VALUE_UINT32} }, /* ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}] */
-${END}
-${BEGIN} ${VARDEF_VALUE_UINT32}, /* ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32} */
-${END}
- /* VPD */
-${BEGIN} { ${VPD_HEAD_VALUE} }, /* ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}] */
-${END}
- /* ExMapTable */
- {
-${BEGIN} { ${EXMAPPING_TABLE_EXTOKEN}, ${EXMAPPING_TABLE_LOCAL_TOKEN}, ${EXMAPPING_TABLE_GUID_INDEX} },
-${END}
- },
- /* LocalTokenNumberTable */
- {
-${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE},
-${END}
- },
- /* GuidTable */
- {
-${BEGIN} ${GUID_STRUCTURE},
-${END}
- },
-${BEGIN} { ${STRING_HEAD_VALUE} }, /* ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}] */
-${END}
-${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */
- {
- ${VARIABLE_HEAD_VALUE}
- },
-${END}
- /* StringTable */
-${BEGIN} ${STRING_TABLE_VALUE}, /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
-${END}
- /* SizeTable */
- {
-${BEGIN} ${SIZE_TABLE_MAXIMUM_LENGTH}, ${SIZE_TABLE_CURRENT_LENGTH}, /* ${SIZE_TABLE_CNAME}_${SIZE_TABLE_GUID} */
-${END}
- },
-${BEGIN} { ${INIT_VALUE_UINT16} }, /* ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}] */
-${END}
-${BEGIN} ${VARDEF_VALUE_UINT16}, /* ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16} */
-${END}
-${BEGIN} { ${INIT_VALUE_UINT8} }, /* ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}] */
-${END}
-${BEGIN} ${VARDEF_VALUE_UINT8}, /* ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8} */
-${END}
-${BEGIN} { ${INIT_VALUE_BOOLEAN} }, /* ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}] */
-${END}
-${BEGIN} ${VARDEF_VALUE_BOOLEAN}, /* ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN} */
-${END}
- /* SkuIdTable */
- { ${BEGIN}${SKUID_VALUE}, ${END} },
- ${SYSTEM_SKU_ID_VALUE}
-};
-""")
-
-
## AutoGen File Header Templates
gAutoGenHeaderString = TemplateString("""\
/**
@@ -907,6 +662,76 @@ gModuleTypeHeaderFile = {
"USER_DEFINED" : [gBasicHeaderFile]
}
+## Autogen internal worker macro to define DynamicEx PCD name includes both the TokenSpaceGuidName
+# the TokenName and Guid comparison to avoid define name collisions.
+#
+# @param Info The ModuleAutoGen object
+# @param AutoGenH The TemplateString object for header file
+#
+#
+def DynExPcdTokenNumberMapping(Info, AutoGenH):
+ ExTokenCNameList = []
+ PcdExList = []
+ if Info.IsLibrary:
+ PcdList = Info.LibraryPcdList
+ else:
+ PcdList = Info.ModulePcdList
+ for Pcd in PcdList:
+ if Pcd.Type in gDynamicExPcd:
+ ExTokenCNameList.append(Pcd.TokenCName)
+ PcdExList.append(Pcd)
+ if len(ExTokenCNameList) == 0:
+ return
+ AutoGenH.Append('\n#define COMPAREGUID(Guid1, Guid2) (BOOLEAN)(*(CONST UINT64*)Guid1 == *(CONST UINT64*)Guid2 && *((CONST UINT64*)Guid1 + 1) == *((CONST UINT64*)Guid2 + 1))\n')
+ # AutoGen for each PCD listed in a [PcdEx] section of a Module/Lib INF file.
+ # Auto generate a macro for each TokenName that takes a Guid pointer as a parameter.
+ # Use the Guid pointer to see if it matches any of the token space GUIDs.
+ TokenCNameList = []
+ for TokenCName in ExTokenCNameList:
+ if TokenCName in TokenCNameList:
+ continue
+ Index = 0
+ Count = ExTokenCNameList.count(TokenCName)
+ for Pcd in PcdExList:
+ if Pcd.TokenCName == TokenCName:
+ Index = Index + 1
+ if Index == 1:
+ AutoGenH.Append('\n#define __PCD_%s_ADDR_CMP(GuidPtr) (' % (Pcd.TokenCName))
+ AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:'
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
+ else:
+ AutoGenH.Append('\\\n (GuidPtr == &%s) ? _PCD_TOKEN_%s_%s:'
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
+ if Index == Count:
+ AutoGenH.Append('0 \\\n )\n')
+ TokenCNameList.append(TokenCName)
+
+ TokenCNameList = []
+ for TokenCName in ExTokenCNameList:
+ if TokenCName in TokenCNameList:
+ continue
+ Index = 0
+ Count = ExTokenCNameList.count(TokenCName)
+ for Pcd in PcdExList:
+ if Pcd.Type in gDynamicExPcd and Pcd.TokenCName == TokenCName:
+ Index = Index + 1
+ if Index == 1:
+ AutoGenH.Append('\n#define __PCD_%s_VAL_CMP(GuidPtr) (' % (Pcd.TokenCName))
+ AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:'
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
+ else:
+ AutoGenH.Append('\\\n COMPAREGUID (GuidPtr, &%s) ? _PCD_TOKEN_%s_%s:'
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
+ if Index == Count:
+ AutoGenH.Append('0 \\\n )\n')
+ # Autogen internal worker macro to compare GUIDs. Guid1 is a pointer to a GUID.
+ # Guid2 is a C name for a GUID. Compare pointers first because optimizing compiler
+ # can do this at build time on CONST GUID pointers and optimize away call to COMPAREGUID().
+ # COMPAREGUID() will only be used if the Guid passed in is local to the module.
+ AutoGenH.Append('#define _PCD_TOKEN_EX_%s(GuidPtr) __PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(GuidPtr) \n'
+ % (Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName))
+ TokenCNameList.append(TokenCName)
+
## Create code for module PCDs
#
# @param Info The ModuleAutoGen object
@@ -923,13 +748,29 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
PcdTokenName = '_PCD_TOKEN_' + Pcd.TokenCName
if Pcd.Type in gDynamicExPcd:
TokenNumber = int(Pcd.TokenValue, 0)
+ # Add TokenSpaceGuidValue value to PcdTokenName to discriminate the DynamicEx PCDs with
+ # different Guids but same TokenCName
+ PcdExTokenName = '_PCD_TOKEN_' + Pcd.TokenSpaceGuidCName + '_' + Pcd.TokenCName
+ AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber))
else:
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
- EdkLogger.error("build", AUTOGEN_ERROR,
- "No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
- ExtraData="[%s]" % str(Info))
- TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
- AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber))
+ # If one of the Source built modules listed in the DSC is not listed in FDF modules,
+ # and the INF lists a PCD can only use the PcdsDynamic access method (it is only
+ # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will
+ # report warning message notify the PI that they are attempting to build a module
+ # that must be included in a flash image in order to be functional. These Dynamic PCD
+ # will not be added into the Database unless it is used by other modules that are
+ # included in the FDF file.
+ # In this case, just assign an invalid token number to make it pass build.
+ if Pcd.Type in PCD_DYNAMIC_TYPE_LIST:
+ TokenNumber = 0
+ else:
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ "No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+ ExtraData="[%s]" % str(Info))
+ else:
+ TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
+ AutoGenH.Append('\n#define %s %dU\n' % (PcdTokenName, TokenNumber))
EdkLogger.debug(EdkLogger.DEBUG_3, "Creating code for " + Pcd.TokenCName + "." + Pcd.TokenSpaceGuidCName)
if Pcd.Type not in gItemTypeStringDatabase:
@@ -946,12 +787,33 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + Pcd.TokenCName
SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + Pcd.TokenCName
+ PcdExCNameList = []
if Pcd.Type in gDynamicExPcd:
- AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
- if Pcd.DatumType == 'VOID*':
- AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ if Info.IsLibrary:
+ PcdList = Info.LibraryPcdList
else:
- AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ PcdList = Info.ModulePcdList
+ for PcdModule in PcdList:
+ if PcdModule.Type in gDynamicExPcd:
+ PcdExCNameList.append(PcdModule.TokenCName)
+ # Be compatible with the current code which using PcdToken and PcdGet/Set for DynamicEx Pcd.
+ # If only PcdToken and PcdGet/Set used in all Pcds with different CName, it should succeed to build.
+ # If PcdToken and PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.
+ if PcdExCNameList.count(Pcd.TokenCName) > 1:
+ AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n')
+ AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))
+ AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ if Pcd.DatumType == 'VOID*':
+ AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
+ AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ if Pcd.DatumType == 'VOID*':
+ AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
elif Pcd.Type in gDynamicPcd:
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
if Pcd.DatumType == 'VOID*':
@@ -1117,16 +979,30 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
PcdTokenNumber = Info.PlatformInfo.PcdTokenNumber
TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
TokenCName = Pcd.TokenCName
- TokenSpaceGuidValue = Pcd.TokenSpaceGuidValue #Info.GuidList[TokenSpaceGuidCName]
- if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
- EdkLogger.error("build", AUTOGEN_ERROR,
- "No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
- ExtraData="[%s]" % str(Info))
- TokenNumber = PcdTokenNumber[TokenCName, TokenSpaceGuidCName]
-
- # If PCD is DynamicEx, then use TokenNumber declared in DEC file
+ PcdTokenName = '_PCD_TOKEN_' + TokenCName
+ #
+ # Write PCDs
+ #
if Pcd.Type in gDynamicExPcd:
TokenNumber = int(Pcd.TokenValue, 0)
+ else:
+ if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:
+ # If one of the Source built modules listed in the DSC is not listed in FDF modules,
+ # and the INF lists a PCD can only use the PcdsDynamic access method (it is only
+ # listed in the DEC file that declares the PCD as PcdsDynamic), then build tool will
+ # report warning message notify the PI that they are attempting to build a module
+ # that must be included in a flash image in order to be functional. These Dynamic PCD
+ # will not be added into the Database unless it is used by other modules that are
+ # included in the FDF file.
+ # In this case, just assign an invalid token number to make it pass build.
+ if Pcd.Type in PCD_DYNAMIC_TYPE_LIST:
+ TokenNumber = 0
+ else:
+ EdkLogger.error("build", AUTOGEN_ERROR,
+ "No generated token number for %s.%s\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+ ExtraData="[%s]" % str(Info))
+ else:
+ TokenNumber = PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName]
if Pcd.Type not in gItemTypeStringDatabase:
EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1148,23 +1024,40 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
if Pcd.DatumType == 'VOID*':
Type = '(VOID *)'
Array = '[]'
-
- AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber))
-
PcdItemType = Pcd.Type
- #if PcdItemType in gDynamicPcd:
- # PcdItemType = TAB_PCDS_FIXED_AT_BUILD
- # if (TokenCName, TokenSpaceGuidCName) in Info.PlatformInfo.Platform.Pcds:
- # PcdItemType = Info.PlatformInfo.Platform.Pcds[TokenCName, TokenSpaceGuidCName].Type
+ PcdExCNameList = []
if PcdItemType in gDynamicExPcd:
- PcdTokenName = '_PCD_TOKEN_' + TokenCName
- AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
- if DatumType == 'VOID*':
- AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName,DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
+ PcdExTokenName = '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + Pcd.TokenCName
+ AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumber))
+
+ if Info.IsLibrary:
+ PcdList = Info.LibraryPcdList
+ else:
+ PcdList = Info.ModulePcdList
+ for PcdModule in PcdList:
+ if PcdModule.Type in gDynamicExPcd:
+ PcdExCNameList.append(PcdModule.TokenCName)
+ # Be compatible with the current code which using PcdGet/Set for DynamicEx Pcd.
+ # If only PcdGet/Set used in all Pcds with different CName, it should succeed to build.
+ # If PcdGet/Set used in the Pcds with different Guids but same CName, it should failed to build.
+ if PcdExCNameList.count(Pcd.TokenCName) > 1:
+ AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGet/Set are not allowed in the case that more than one DynamicEx Pcds are different Guids but same CName.\n')
+ AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName))
+ AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ if Pcd.DatumType == 'VOID*':
+ AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('// #define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
else:
- AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, TokenSpaceGuidCName, PcdTokenName))
+ AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName))
+ AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ if Pcd.DatumType == 'VOID*':
+ AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s, (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName))
+ else:
+ AutoGenH.Append('#define _PCD_TOKEN_%s %dU\n' % (TokenCName, TokenNumber))
if PcdItemType in gDynamicPcd:
- PcdTokenName = '_PCD_TOKEN_' + TokenCName
AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName))
if DatumType == 'VOID*':
AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName))
@@ -1172,468 +1065,15 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
AutoGenH.Append('#define %s(Value) LibPcdSet%s(%s, (Value))\n' % (SetModeName, DatumSizeLib, PcdTokenName))
if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE:
PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName
- AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array) )
+ AutoGenH.Append('extern volatile %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array) )
AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName))
AutoGenH.Append('#define %s(Value) (%s = (Value))\n' % (SetModeName, PcdVariableName))
if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG:
AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array))
- #AutoGenH.Append('#define _PCD_VALUE_%s _gPcd_FixedAtBuild_%s\n' %(TokenCName, TokenCName))
AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName))
AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName)
-## Create code for PCD database in DXE or PEI phase
-#
-# @param Platform The platform object
-# @retval tuple Two TemplateString objects for C code and header file,
-# respectively
-#
-def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
- AutoGenC = TemplateString()
- AutoGenH = TemplateString()
-
- Dict = {
- 'PHASE' : Phase,
- 'GUID_TABLE_SIZE' : '1U',
- 'STRING_TABLE_SIZE' : '1U',
- 'SKUID_TABLE_SIZE' : '1U',
- 'LOCAL_TOKEN_NUMBER_TABLE_SIZE' : '1U',
- 'LOCAL_TOKEN_NUMBER' : '0U',
- 'EXMAPPING_TABLE_SIZE' : '1U',
- 'EX_TOKEN_NUMBER' : '0U',
- 'SIZE_TABLE_SIZE' : '2U',
- 'GUID_TABLE_EMPTY' : 'TRUE',
- 'STRING_TABLE_EMPTY' : 'TRUE',
- 'SKUID_TABLE_EMPTY' : 'TRUE',
- 'DATABASE_EMPTY' : 'TRUE',
- 'EXMAP_TABLE_EMPTY' : 'TRUE',
- 'PCD_DATABASE_UNINIT_EMPTY' : ' UINT8 dummy; /* PCD_DATABASE_UNINIT is emptry */',
- 'SYSTEM_SKU_ID' : ' SKU_ID SystemSkuId;',
- 'SYSTEM_SKU_ID_VALUE' : '0U'
- }
-
- for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]:
- Dict['VARDEF_CNAME_' + DatumType] = []
- Dict['VARDEF_GUID_' + DatumType] = []
- Dict['VARDEF_SKUID_' + DatumType] = []
- Dict['VARDEF_VALUE_' + DatumType] = []
- for Init in ['INIT','UNINIT']:
- Dict[Init+'_CNAME_DECL_' + DatumType] = []
- Dict[Init+'_GUID_DECL_' + DatumType] = []
- Dict[Init+'_NUMSKUS_DECL_' + DatumType] = []
- Dict[Init+'_VALUE_' + DatumType] = []
-
- for Type in ['STRING_HEAD','VPD_HEAD','VARIABLE_HEAD']:
- Dict[Type + '_CNAME_DECL'] = []
- Dict[Type + '_GUID_DECL'] = []
- Dict[Type + '_NUMSKUS_DECL'] = []
- Dict[Type + '_VALUE'] = []
-
- Dict['STRING_TABLE_INDEX'] = []
- Dict['STRING_TABLE_LENGTH'] = []
- Dict['STRING_TABLE_CNAME'] = []
- Dict['STRING_TABLE_GUID'] = []
- Dict['STRING_TABLE_VALUE'] = []
-
- Dict['SIZE_TABLE_CNAME'] = []
- Dict['SIZE_TABLE_GUID'] = []
- Dict['SIZE_TABLE_CURRENT_LENGTH'] = []
- Dict['SIZE_TABLE_MAXIMUM_LENGTH'] = []
-
- Dict['EXMAPPING_TABLE_EXTOKEN'] = []
- Dict['EXMAPPING_TABLE_LOCAL_TOKEN'] = []
- Dict['EXMAPPING_TABLE_GUID_INDEX'] = []
-
- Dict['GUID_STRUCTURE'] = []
-
- Dict['SKUID_VALUE'] = []
- Dict['VARDEF_HEADER'] = []
- if Phase == 'DXE':
- Dict['SYSTEM_SKU_ID'] = ''
- Dict['SYSTEM_SKU_ID_VALUE'] = ''
-
- StringTableIndex = 0
- StringTableSize = 0
- NumberOfLocalTokens = 0
- NumberOfPeiLocalTokens = 0
- NumberOfDxeLocalTokens = 0
- NumberOfExTokens = 0
- NumberOfSizeItems = 0
- GuidList = []
-
- for Pcd in Platform.DynamicPcdList:
- CName = Pcd.TokenCName
- TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
-
- EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
- if Pcd.DatumType not in gDatumSizeStringDatabase:
- EdkLogger.error("build", AUTOGEN_ERROR,
- "Unknown datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
- ExtraData="[%s]" % str(Platform))
-
- if Pcd.Phase == 'PEI':
- NumberOfPeiLocalTokens += 1
- if Pcd.Phase == 'DXE':
- NumberOfDxeLocalTokens += 1
- if Pcd.Phase != Phase:
- continue
-
- #
- # TODO: need GetGuidValue() definition
- #
- TokenSpaceGuidStructure = Pcd.TokenSpaceGuidValue
- TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure)
- if Pcd.Type in gDynamicExPcd:
- if TokenSpaceGuid not in GuidList:
- GuidList += [TokenSpaceGuid]
- Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure)
- NumberOfExTokens += 1
- ValueList = []
- StringHeadOffsetList = []
- VpdHeadOffsetList = []
- VariableHeadValueList = []
- Pcd.InitString = 'UNINIT'
-
- if Pcd.DatumType == 'VOID*':
- if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:
- Pcd.TokenTypeList = ['PCD_TYPE_STRING']
- else:
- Pcd.TokenTypeList = []
- elif Pcd.DatumType == 'BOOLEAN':
- Pcd.TokenTypeList = ['PCD_DATUM_TYPE_UINT8']
- else:
- Pcd.TokenTypeList = ['PCD_DATUM_TYPE_' + Pcd.DatumType]
-
- if len(Pcd.SkuInfoList) > 1:
- Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED']
-
- for SkuName in Pcd.SkuInfoList:
- Sku = Pcd.SkuInfoList[SkuName]
- SkuId = Sku.SkuId
- if SkuId == None or SkuId == '':
- continue
-
- if (SkuId + 'U') not in Dict['SKUID_VALUE']:
- Dict['SKUID_VALUE'].append(SkuId + 'U')
-
- SkuIdIndex = Dict['SKUID_VALUE'].index(SkuId + 'U')
- if len(Sku.VariableName) > 0:
- Pcd.TokenTypeList += ['PCD_TYPE_HII']
- Pcd.InitString = 'INIT'
- VariableNameStructure = StringToArray(Sku.VariableName)
- if VariableNameStructure not in Dict['STRING_TABLE_VALUE']:
- Dict['STRING_TABLE_CNAME'].append(CName)
- Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
- if StringTableIndex == 0:
- Dict['STRING_TABLE_INDEX'].append('')
- else:
- Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
-
- Dict['STRING_TABLE_LENGTH'].append((len(Sku.VariableName) - 3 + 1) * 2)
- Dict['STRING_TABLE_VALUE'].append(VariableNameStructure)
- StringTableIndex += 1
- StringTableSize += (len(Sku.VariableName) - 3 + 1) * 2
-
- VariableHeadStringIndex = 0
- for Index in range(Dict['STRING_TABLE_VALUE'].index(VariableNameStructure)):
- VariableHeadStringIndex += Dict['STRING_TABLE_LENGTH'][Index]
-
- VariableGuidStructure = Sku.VariableGuidValue
- VariableGuid = GuidStructureStringToGuidValueName(VariableGuidStructure)
- if VariableGuid not in GuidList:
- GuidList += [VariableGuid]
- Dict['GUID_STRUCTURE'].append(VariableGuidStructure)
- VariableHeadGuidIndex = GuidList.index(VariableGuid)
-
- if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
- VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s), %dU, %sU' %
- (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid,
- VariableHeadGuidIndex, Sku.VariableOffset))
- else:
- VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' %
- (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, SkuIdIndex,
- VariableHeadGuidIndex, Sku.VariableOffset))
- Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName)
- Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid)
- Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex)
- if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
- Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex))
- else:
- #
- # ULL (for UINT64) or U(other integer type) should be append to avoid
- # warning under linux building environment.
- #
- if Pcd.DatumType == "UINT64":
- Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL")
- elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
- Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")
- elif Pcd.DatumType == "BOOLEAN":
- if Sku.HiiDefaultValue in ["1", "0"]:
- Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")
- else:
- Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
-
- elif Sku.VpdOffset != '':
- Pcd.TokenTypeList += ['PCD_TYPE_VPD']
- Pcd.InitString = 'INIT'
- VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U')
- continue
-
- if Pcd.DatumType == 'VOID*':
- Pcd.TokenTypeList += ['PCD_TYPE_STRING']
- Pcd.InitString = 'INIT'
- if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '':
- Sku.DefaultValue = Sku.HiiDefaultValue
- if Sku.DefaultValue != '':
- NumberOfSizeItems += 1
- Dict['STRING_TABLE_CNAME'].append(CName)
- Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
-
- if StringTableIndex == 0:
- Dict['STRING_TABLE_INDEX'].append('')
- else:
- Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
- if Sku.DefaultValue[0] == 'L':
- Size = (len(Sku.DefaultValue) - 3 + 1) * 2
- Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
- elif Sku.DefaultValue[0] == '"':
- Size = len(Sku.DefaultValue) - 2 + 1
- Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
- elif Sku.DefaultValue[0] == '{':
- Size = len(Sku.DefaultValue.replace(',',' ').split())
- Dict['STRING_TABLE_VALUE'].append(Sku.DefaultValue)
-
- StringHeadOffsetList.append(str(StringTableSize) + 'U')
- Dict['SIZE_TABLE_CNAME'].append(CName)
- Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
- Dict['SIZE_TABLE_CURRENT_LENGTH'].append(str(Size) + 'U')
- Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')
- if Pcd.MaxDatumSize != '':
- MaxDatumSize = int(Pcd.MaxDatumSize, 0)
- if MaxDatumSize < Size:
- EdkLogger.error("build", AUTOGEN_ERROR,
- "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
- ExtraData="[%s]" % str(Platform))
- Size = MaxDatumSize
- Dict['STRING_TABLE_LENGTH'].append(Size)
- StringTableIndex += 1
- StringTableSize += (Size)
- else:
- if "PCD_TYPE_HII" not in Pcd.TokenTypeList:
- Pcd.TokenTypeList += ['PCD_TYPE_DATA']
- if Sku.DefaultValue == 'TRUE':
- Pcd.InitString = 'INIT'
- else:
- try:
- if int(Sku.DefaultValue, 0) != 0:
- Pcd.InitString = 'INIT'
- except:
- pass
-
- #
- # For UNIT64 type PCD's value, ULL should be append to avoid
- # warning under linux building environment.
- #
- if Pcd.DatumType == "UINT64":
- ValueList.append(Sku.DefaultValue + "ULL")
- elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
- ValueList.append(Sku.DefaultValue + "U")
- elif Pcd.DatumType == "BOOLEAN":
- if Sku.DefaultValue in ["1", "0"]:
- ValueList.append(Sku.DefaultValue + "U")
- else:
- ValueList.append(Sku.DefaultValue)
-
- Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
-
-
- if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
- Dict['VARIABLE_HEAD_CNAME_DECL'].append(CName)
- Dict['VARIABLE_HEAD_GUID_DECL'].append(TokenSpaceGuid)
- Dict['VARIABLE_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
- Dict['VARIABLE_HEAD_VALUE'].append('{ %s }\n' % ' },\n { '.join(VariableHeadValueList))
- Dict['VARDEF_HEADER'].append('_Variable_Header')
- else:
- Dict['VARDEF_HEADER'].append('')
- if 'PCD_TYPE_VPD' in Pcd.TokenTypeList:
- Dict['VPD_HEAD_CNAME_DECL'].append(CName)
- Dict['VPD_HEAD_GUID_DECL'].append(TokenSpaceGuid)
- Dict['VPD_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
- Dict['VPD_HEAD_VALUE'].append('{ %s }' % ' }, { '.join(VpdHeadOffsetList))
- if 'PCD_TYPE_STRING' in Pcd.TokenTypeList:
- Dict['STRING_HEAD_CNAME_DECL'].append(CName)
- Dict['STRING_HEAD_GUID_DECL'].append(TokenSpaceGuid)
- Dict['STRING_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
- Dict['STRING_HEAD_VALUE'].append(', '.join(StringHeadOffsetList))
- if 'PCD_TYPE_DATA' in Pcd.TokenTypeList:
- Dict[Pcd.InitString+'_CNAME_DECL_'+Pcd.DatumType].append(CName)
- Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType].append(TokenSpaceGuid)
- Dict[Pcd.InitString+'_NUMSKUS_DECL_'+Pcd.DatumType].append(len(Pcd.SkuInfoList))
- if Pcd.InitString == 'UNINIT':
- Dict['PCD_DATABASE_UNINIT_EMPTY'] = ''
- else:
- Dict[Pcd.InitString+'_VALUE_'+Pcd.DatumType].append(', '.join(ValueList))
-
- if Phase == 'PEI':
- NumberOfLocalTokens = NumberOfPeiLocalTokens
- if Phase == 'DXE':
- NumberOfLocalTokens = NumberOfDxeLocalTokens
-
- Dict['TOKEN_INIT'] = ['' for x in range(NumberOfLocalTokens)]
- Dict['TOKEN_CNAME'] = ['' for x in range(NumberOfLocalTokens)]
- Dict['TOKEN_GUID'] = ['' for x in range(NumberOfLocalTokens)]
- Dict['TOKEN_TYPE'] = ['' for x in range(NumberOfLocalTokens)]
-
- for Pcd in Platform.DynamicPcdList:
- CName = Pcd.TokenCName
- TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
- if Pcd.Phase != Phase:
- continue
-
- TokenSpaceGuid = GuidStructureStringToGuidValueName(Pcd.TokenSpaceGuidValue) #(Platform.PackageList, TokenSpaceGuidCName))
- GeneratedTokenNumber = Platform.PcdTokenNumber[CName, TokenSpaceGuidCName] - 1
- if Phase == 'DXE':
- GeneratedTokenNumber -= NumberOfPeiLocalTokens
-
- EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
- EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
- EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))
-
- Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Init'
- if Pcd.InitString == 'UNINIT':
- Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Uninit'
- Dict['TOKEN_CNAME'][GeneratedTokenNumber] = CName
- Dict['TOKEN_GUID'][GeneratedTokenNumber] = TokenSpaceGuid
- Dict['TOKEN_TYPE'][GeneratedTokenNumber] = ' | '.join(Pcd.TokenTypeList)
-
- Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
- #
- # Update VARDEF_HEADER
- #
- if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
- Dict['VARDEF_HEADER'][GeneratedTokenNumber] = '_Variable_Header'
- else:
- Dict['VARDEF_HEADER'][GeneratedTokenNumber] = ''
-
-
- if Pcd.Type in gDynamicExPcd:
- Dict['EXMAPPING_TABLE_EXTOKEN'].append(str(Pcd.TokenValue) + 'U')
- if Phase == 'DXE':
- GeneratedTokenNumber += NumberOfPeiLocalTokens
- #
- # Per, PCD architecture specification, PCD Token Number is 1 based and 0 is defined as invalid token number.
- # For each EX type PCD, a PCD Token Number is assigned. When the
- # PCD Driver/PEIM map EX_GUID and EX_TOKEN_NUMBER to the PCD Token Number,
- # the non-EX Protocol/PPI interface can be called to get/set the value. This assumption is made by
- # Pcd Driver/PEIM in MdeModulePkg.
- # Therefore, 1 is added to GeneratedTokenNumber to generate a PCD Token Number before being inserted
- # to the EXMAPPING_TABLE.
- #
- Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(str(GeneratedTokenNumber + 1) + 'U')
- Dict['EXMAPPING_TABLE_GUID_INDEX'].append(str(GuidList.index(TokenSpaceGuid)) + 'U')
-
- if GuidList != []:
- Dict['GUID_TABLE_EMPTY'] = 'FALSE'
- Dict['GUID_TABLE_SIZE'] = str(len(GuidList)) + 'U'
- else:
- Dict['GUID_STRUCTURE'] = [GuidStringToGuidStructureString('00000000-0000-0000-0000-000000000000')]
-
- if StringTableIndex == 0:
- Dict['STRING_TABLE_INDEX'].append('')
- Dict['STRING_TABLE_LENGTH'].append(1)
- Dict['STRING_TABLE_CNAME'].append('')
- Dict['STRING_TABLE_GUID'].append('')
- Dict['STRING_TABLE_VALUE'].append('{ 0 }')
- else:
- Dict['STRING_TABLE_EMPTY'] = 'FALSE'
- Dict['STRING_TABLE_SIZE'] = str(StringTableSize) + 'U'
-
- if Dict['SIZE_TABLE_CNAME'] == []:
- Dict['SIZE_TABLE_CNAME'].append('')
- Dict['SIZE_TABLE_GUID'].append('')
- Dict['SIZE_TABLE_CURRENT_LENGTH'].append('0U')
- Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append('0U')
-
- if NumberOfLocalTokens != 0:
- Dict['DATABASE_EMPTY'] = 'FALSE'
- Dict['LOCAL_TOKEN_NUMBER_TABLE_SIZE'] = NumberOfLocalTokens
- Dict['LOCAL_TOKEN_NUMBER'] = NumberOfLocalTokens
-
- if NumberOfExTokens != 0:
- Dict['EXMAP_TABLE_EMPTY'] = 'FALSE'
- Dict['EXMAPPING_TABLE_SIZE'] = str(NumberOfExTokens) + 'U'
- Dict['EX_TOKEN_NUMBER'] = str(NumberOfExTokens) + 'U'
- else:
- Dict['EXMAPPING_TABLE_EXTOKEN'].append('0U')
- Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append('0U')
- Dict['EXMAPPING_TABLE_GUID_INDEX'].append('0U')
-
- if NumberOfSizeItems != 0:
- Dict['SIZE_TABLE_SIZE'] = str(NumberOfSizeItems * 2) + 'U'
-
- AutoGenH.Append(gPcdDatabaseAutoGenH.Replace(Dict))
- if NumberOfLocalTokens == 0:
- AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict))
- else:
- #
- # Update Size Table to the right order, it should be same with LocalTokenNumberTable
- #
- SizeCNameTempList = []
- SizeGuidTempList = []
- SizeCurLenTempList = []
- SizeMaxLenTempList = []
- ReOrderFlag = True
-
- if len(Dict['SIZE_TABLE_CNAME']) == 1:
- if not (Dict['SIZE_TABLE_CNAME'][0] and Dict['SIZE_TABLE_GUID'][0]):
- ReOrderFlag = False
-
- if ReOrderFlag:
- for Count in range(len(Dict['TOKEN_CNAME'])):
- for Count1 in range(len(Dict['SIZE_TABLE_CNAME'])):
- if Dict['TOKEN_CNAME'][Count] == Dict['SIZE_TABLE_CNAME'][Count1] and \
- Dict['TOKEN_GUID'][Count] == Dict['SIZE_TABLE_GUID'][Count1]:
- SizeCNameTempList.append(Dict['SIZE_TABLE_CNAME'][Count1])
- SizeGuidTempList.append(Dict['SIZE_TABLE_GUID'][Count1])
- SizeCurLenTempList.append(Dict['SIZE_TABLE_CURRENT_LENGTH'][Count1])
- SizeMaxLenTempList.append(Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count1])
-
- for Count in range(len(Dict['SIZE_TABLE_CNAME'])):
- Dict['SIZE_TABLE_CNAME'][Count] = SizeCNameTempList[Count]
- Dict['SIZE_TABLE_GUID'][Count] = SizeGuidTempList[Count]
- Dict['SIZE_TABLE_CURRENT_LENGTH'][Count] = SizeCurLenTempList[Count]
- Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count] = SizeMaxLenTempList[Count]
-
- AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict))
-
- return AutoGenH, AutoGenC
-
-## Create code for PCD database
-#
-# @param Info The ModuleAutoGen object
-# @param AutoGenC The TemplateString object for C code
-# @param AutoGenH The TemplateString object for header file
-#
-def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
- if Info.PcdIsDriver == "":
- return
- if Info.PcdIsDriver not in gPcdPhaseMap:
- EdkLogger.error("build", AUTOGEN_ERROR, "Not supported PcdIsDriver type:%s" % Info.PcdIsDriver,
- ExtraData="[%s]" % str(Info))
-
- AutoGenH.Append(gPcdDatabaseCommonAutoGenH)
- AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI')
- AutoGenH.Append(AdditionalAutoGenH.String)
-
- Phase = gPcdPhaseMap[Info.PcdIsDriver]
- if Phase == 'PEI':
- AutoGenC.Append(AdditionalAutoGenC.String)
-
- if Phase == 'DXE':
- AdditionalAutoGenH, AdditionalAutoGenC = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase)
- AutoGenH.Append(AdditionalAutoGenH.String)
- AutoGenC.Append(AdditionalAutoGenC.String)
- AutoGenH.Append(gPcdDatabaseEpilogueAutoGenH)
## Create code for library constructor
#
@@ -1920,7 +1360,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
# Collect Token Space GUIDs used by DynamicEc PCDs
TokenSpaceList = []
for Pcd in Info.ModulePcdList:
- if Pcd.Type in gDynamicExPcd and Pcd.TokenSpaceGuidCName not in TokenSpaceList:
+ if Pcd.Type in gDynamicExPcd and Pcd.TokenSpaceGuidCName not in TokenSpaceList:
TokenSpaceList += [Pcd.TokenSpaceGuidCName]
# Add extern declarations to AutoGen.h if one or more Token Space GUIDs were found
@@ -1938,13 +1378,14 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH):
AutoGenH.Append("\n// PCD definitions\n")
for Pcd in Info.ModulePcdList:
CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd)
+ DynExPcdTokenNumberMapping (Info, AutoGenH)
else:
if Info.ModulePcdList:
AutoGenH.Append("\n// Definition of PCDs used in this module\n")
AutoGenC.Append("\n// Definition of PCDs used in this module\n")
for Pcd in Info.ModulePcdList:
CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd)
-
+ DynExPcdTokenNumberMapping (Info, AutoGenH)
if Info.LibraryPcdList:
AutoGenH.Append("\n// Definition of PCDs used in libraries is in AutoGen.c\n")
AutoGenC.Append("\n// Definition of PCDs used in libraries\n")
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
new file mode 100644
index 0000000000..08719fa733
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -0,0 +1,1566 @@
+## @file
+# Routines for generating Pcd Database
+#
+# Copyright (c) 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
+# 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.
+#
+from StringIO import StringIO
+from Common.Misc import *
+from Common.String import StringToArray
+from struct import pack
+
+DATABASE_VERSION = 4
+
+gPcdDatabaseAutoGenC = TemplateString("""
+//
+// External PCD database debug information
+//
+#if 0
+${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
+${BEGIN} { ${INIT_VALUE_UINT64} }, /* ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}] */
+${END}
+${BEGIN} ${VARDEF_VALUE_UINT64}, /* ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64} */
+${END}
+${BEGIN} { ${INIT_VALUE_UINT32} }, /* ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}] */
+${END}
+${BEGIN} ${VARDEF_VALUE_UINT32}, /* ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32} */
+${END}
+ /* VPD */
+${BEGIN} { ${VPD_HEAD_VALUE} }, /* ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}] */
+${END}
+ /* ExMapTable */
+ {
+${BEGIN} { ${EXMAPPING_TABLE_EXTOKEN}, ${EXMAPPING_TABLE_LOCAL_TOKEN}, ${EXMAPPING_TABLE_GUID_INDEX} },
+${END}
+ },
+ /* LocalTokenNumberTable */
+ {
+${BEGIN} offsetof(${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE},
+${END}
+ },
+ /* GuidTable */
+ {
+${BEGIN} ${GUID_STRUCTURE},
+${END}
+ },
+${BEGIN} { ${STRING_HEAD_VALUE} }, /* ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}] */
+${END}
+${BEGIN} /* ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}] */
+ {
+ ${VARIABLE_HEAD_VALUE}
+ },
+${END}
+/* SkuHead */
+ {
+ ${BEGIN} offsetof (${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.${TOKEN_CNAME}_${TOKEN_GUID}${VARDEF_HEADER}) | ${TOKEN_TYPE}, /* */
+ offsetof (${PHASE}_PCD_DATABASE, ${TOKEN_INIT}.SkuHead) /* */
+ ${END}
+ },
+ /* StringTable */
+${BEGIN} ${STRING_TABLE_VALUE}, /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
+${END}
+ /* SizeTable */
+ {
+${BEGIN} ${SIZE_TABLE_MAXIMUM_LENGTH}, ${SIZE_TABLE_CURRENT_LENGTH}, /* ${SIZE_TABLE_CNAME}_${SIZE_TABLE_GUID} */
+${END}
+ },
+${BEGIN} { ${INIT_VALUE_UINT16} }, /* ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}] */
+${END}
+${BEGIN} ${VARDEF_VALUE_UINT16}, /* ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16} */
+${END}
+${BEGIN} { ${INIT_VALUE_UINT8} }, /* ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}] */
+${END}
+${BEGIN} ${VARDEF_VALUE_UINT8}, /* ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8} */
+${END}
+${BEGIN} { ${INIT_VALUE_BOOLEAN} }, /* ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}] */
+${END}
+${BEGIN} ${VARDEF_VALUE_BOOLEAN}, /* ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN} */
+${END}
+ /* SkuIdTable */
+ { ${BEGIN}${SKUID_VALUE}, ${END} },
+ ${SYSTEM_SKU_ID_VALUE}
+};
+#endif
+""")
+
+## Mapping between PCD driver type and EFI phase
+gPcdPhaseMap = {
+ "PEI_PCD_DRIVER" : "PEI",
+ "DXE_PCD_DRIVER" : "DXE"
+}
+
+gPcdDatabaseAutoGenH = TemplateString("""
+#define PCD_${PHASE}_SERVICE_DRIVER_VERSION ${SERVICE_DRIVER_VERSION}
+
+//
+// External PCD database debug information
+//
+#if 0
+#define ${PHASE}_GUID_TABLE_SIZE ${GUID_TABLE_SIZE}
+#define ${PHASE}_STRING_TABLE_SIZE ${STRING_TABLE_SIZE}
+#define ${PHASE}_SKUID_TABLE_SIZE ${SKUID_TABLE_SIZE}
+#define ${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE ${LOCAL_TOKEN_NUMBER_TABLE_SIZE}
+#define ${PHASE}_LOCAL_TOKEN_NUMBER ${LOCAL_TOKEN_NUMBER}
+#define ${PHASE}_EXMAPPING_TABLE_SIZE ${EXMAPPING_TABLE_SIZE}
+#define ${PHASE}_EX_TOKEN_NUMBER ${EX_TOKEN_NUMBER}
+#define ${PHASE}_SIZE_TABLE_SIZE ${SIZE_TABLE_SIZE}
+#define ${PHASE}_SKU_HEAD_SIZE ${SKU_HEAD_SIZE}
+#define ${PHASE}_GUID_TABLE_EMPTY ${GUID_TABLE_EMPTY}
+#define ${PHASE}_STRING_TABLE_EMPTY ${STRING_TABLE_EMPTY}
+#define ${PHASE}_SKUID_TABLE_EMPTY ${SKUID_TABLE_EMPTY}
+#define ${PHASE}_DATABASE_EMPTY ${DATABASE_EMPTY}
+#define ${PHASE}_EXMAP_TABLE_EMPTY ${EXMAP_TABLE_EMPTY}
+
+typedef struct {
+${BEGIN} UINT64 ${INIT_CNAME_DECL_UINT64}_${INIT_GUID_DECL_UINT64}[${INIT_NUMSKUS_DECL_UINT64}];
+${END}
+${BEGIN} UINT64 ${VARDEF_CNAME_UINT64}_${VARDEF_GUID_UINT64}_VariableDefault_${VARDEF_SKUID_UINT64};
+${END}
+${BEGIN} UINT32 ${INIT_CNAME_DECL_UINT32}_${INIT_GUID_DECL_UINT32}[${INIT_NUMSKUS_DECL_UINT32}];
+${END}
+${BEGIN} UINT32 ${VARDEF_CNAME_UINT32}_${VARDEF_GUID_UINT32}_VariableDefault_${VARDEF_SKUID_UINT32};
+${END}
+${BEGIN} VPD_HEAD ${VPD_HEAD_CNAME_DECL}_${VPD_HEAD_GUID_DECL}[${VPD_HEAD_NUMSKUS_DECL}];
+${END}
+ DYNAMICEX_MAPPING ExMapTable[${PHASE}_EXMAPPING_TABLE_SIZE];
+ UINT32 LocalTokenNumberTable[${PHASE}_LOCAL_TOKEN_NUMBER_TABLE_SIZE];
+ GUID GuidTable[${PHASE}_GUID_TABLE_SIZE];
+${BEGIN} STRING_HEAD ${STRING_HEAD_CNAME_DECL}_${STRING_HEAD_GUID_DECL}[${STRING_HEAD_NUMSKUS_DECL}];
+${END}
+${BEGIN} VARIABLE_HEAD ${VARIABLE_HEAD_CNAME_DECL}_${VARIABLE_HEAD_GUID_DECL}_Variable_Header[${VARIABLE_HEAD_NUMSKUS_DECL}];
+${END}
+${BEGIN} SKU_HEAD SkuHead[${PHASE}_SKU_HEAD_SIZE];
+${END}
+${BEGIN} UINT8 StringTable${STRING_TABLE_INDEX}[${STRING_TABLE_LENGTH}]; /* ${STRING_TABLE_CNAME}_${STRING_TABLE_GUID} */
+${END}
+ SIZE_INFO SizeTable[${PHASE}_SIZE_TABLE_SIZE];
+${BEGIN} UINT16 ${INIT_CNAME_DECL_UINT16}_${INIT_GUID_DECL_UINT16}[${INIT_NUMSKUS_DECL_UINT16}];
+${END}
+${BEGIN} UINT16 ${VARDEF_CNAME_UINT16}_${VARDEF_GUID_UINT16}_VariableDefault_${VARDEF_SKUID_UINT16};
+${END}
+${BEGIN} UINT8 ${INIT_CNAME_DECL_UINT8}_${INIT_GUID_DECL_UINT8}[${INIT_NUMSKUS_DECL_UINT8}];
+${END}
+${BEGIN} UINT8 ${VARDEF_CNAME_UINT8}_${VARDEF_GUID_UINT8}_VariableDefault_${VARDEF_SKUID_UINT8};
+${END}
+${BEGIN} BOOLEAN ${INIT_CNAME_DECL_BOOLEAN}_${INIT_GUID_DECL_BOOLEAN}[${INIT_NUMSKUS_DECL_BOOLEAN}];
+${END}
+${BEGIN} BOOLEAN ${VARDEF_CNAME_BOOLEAN}_${VARDEF_GUID_BOOLEAN}_VariableDefault_${VARDEF_SKUID_BOOLEAN};
+${END}
+ UINT8 SkuIdTable[${PHASE}_SKUID_TABLE_SIZE];
+${SYSTEM_SKU_ID}
+} ${PHASE}_PCD_DATABASE_INIT;
+
+typedef struct {
+${PCD_DATABASE_UNINIT_EMPTY}
+${BEGIN} UINT64 ${UNINIT_CNAME_DECL_UINT64}_${UNINIT_GUID_DECL_UINT64}[${UNINIT_NUMSKUS_DECL_UINT64}];
+${END}
+${BEGIN} UINT32 ${UNINIT_CNAME_DECL_UINT32}_${UNINIT_GUID_DECL_UINT32}[${UNINIT_NUMSKUS_DECL_UINT32}];
+${END}
+${BEGIN} UINT16 ${UNINIT_CNAME_DECL_UINT16}_${UNINIT_GUID_DECL_UINT16}[${UNINIT_NUMSKUS_DECL_UINT16}];
+${END}
+${BEGIN} UINT8 ${UNINIT_CNAME_DECL_UINT8}_${UNINIT_GUID_DECL_UINT8}[${UNINIT_NUMSKUS_DECL_UINT8}];
+${END}
+${BEGIN} BOOLEAN ${UNINIT_CNAME_DECL_BOOLEAN}_${UNINIT_GUID_DECL_BOOLEAN}[${UNINIT_NUMSKUS_DECL_BOOLEAN}];
+${END}
+} ${PHASE}_PCD_DATABASE_UNINIT;
+
+typedef struct {
+ //GUID Signature; // PcdDataBaseGuid
+ //UINT32 Length;
+ //UINT32 UninitDataBaseSize;// Total size for PCD those default value with 0.
+ //TABLE_OFFSET LocalTokenNumberTableOffset;
+ //TABLE_OFFSET ExMapTableOffset;
+ //TABLE_OFFSET GuidTableOffset;
+ //TABLE_OFFSET StringTableOffset;
+ //TABLE_OFFSET SizeTableOffset;
+ //TABLE_OFFSET SkuIdTableOffset;
+ //UINT16 LocalTokenCount; // LOCAL_TOKEN_NUMBER for all
+ //UINT16 ExTokenCount; // EX_TOKEN_NUMBER for DynamicEx
+ //UINT16 GuidTableCount; // The Number of Guid in GuidTable
+ //SKU_ID SystemSkuId; // Current SkuId value.
+ //UINT8 Pad;
+ ${PHASE}_PCD_DATABASE_INIT Init;
+ ${PHASE}_PCD_DATABASE_UNINIT Uninit;
+} ${PHASE}_PCD_DATABASE;
+
+#define ${PHASE}_NEX_TOKEN_NUMBER (${PHASE}_LOCAL_TOKEN_NUMBER - ${PHASE}_EX_TOKEN_NUMBER)
+#endif
+""")
+
+
+gEmptyPcdDatabaseAutoGenC = TemplateString("""
+//
+// External PCD database debug information
+//
+#if 0
+${PHASE}_PCD_DATABASE_INIT g${PHASE}PcdDbInit = {
+ /* ExMapTable */
+ {
+ {0, 0, 0}
+ },
+ /* LocalTokenNumberTable */
+ {
+ 0
+ },
+ /* GuidTable */
+ {
+ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}
+ },
+ /* StringTable */
+ { 0 },
+ /* SkuHead */
+ {
+ 0, 0
+ },
+ /* SizeTable */
+ {
+ 0, 0
+ },
+ /* SkuIdTable */
+ { 0 },
+ ${SYSTEM_SKU_ID_VALUE}
+};
+#endif
+""")
+
+## PackGuid
+#
+# Pack the GUID value in C structure format into data array
+#
+# @param GuidStructureValue: The GUID value in C structure format
+#
+# @retval Buffer: a data array contains the Guid
+#
+def PackGuid(GuidStructureValue):
+ GuidString = GuidStructureStringToGuidString(GuidStructureValue)
+ Guid = GuidString.split('-')
+ Buffer = pack('=LHHBBBBBBBB',
+ int(Guid[0], 16),
+ int(Guid[1], 16),
+ int(Guid[2], 16),
+ int(Guid[3][-4:-2], 16),
+ int(Guid[3][-2:], 16),
+ int(Guid[4][-12:-10], 16),
+ int(Guid[4][-10:-8], 16),
+ int(Guid[4][-8:-6], 16),
+ int(Guid[4][-6:-4], 16),
+ int(Guid[4][-4:-2], 16),
+ int(Guid[4][-2:], 16)
+ )
+ return Buffer
+
+def toHex(s):
+ lst = []
+ for ch in s:
+ hv = hex(ord(ch)).replace('0x', ' ')
+ if len(hv) == 1:
+ hv = '0'+hv
+ lst.append(hv)
+ if lst:
+ return reduce(lambda x,y:x+y, lst)
+ else:
+ return 'empty'
+## DbItemList
+#
+# The class holds the Pcd database items. ItemSize if not zero should match the item datum type in the C structure.
+# When the structure is changed, remember to check the ItemSize and the related PackStr in PackData()
+# RawDataList is the RawData that may need some kind of calculation or transformation,
+# the DataList corresponds to the data that need to be written to database. If DataList is not present, then RawDataList
+# will be written to the database.
+#
+class DbItemList:
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ self.ItemSize = ItemSize
+ self.DataList = DataList
+ self.RawDataList = RawDataList
+ self.ListSize = 0
+
+ def GetInterOffset(self, Index):
+ Offset = 0
+ if self.ItemSize == 0:
+ #
+ # Variable length, need to calculate one by one
+ #
+ assert(Index < len(self.RawDataList))
+ for ItemIndex in xrange(Index):
+ Offset += len(self.RawDataList[ItemIndex])
+ else:
+ for Datas in self.RawDataList:
+ Offset = self.ItemSize * Index
+
+ return Offset
+
+ def GetListSize(self):
+ if self.ListSize:
+ return self.ListSize
+ if len(self.RawDataList) == 0:
+ self.ListSize = 0
+ return self.ListSize
+ if self.ItemSize == 0:
+ self.ListSize = self.GetInterOffset(len(self.RawDataList) - 1) + len(self.RawDataList[len(self.RawDataList)-1])
+ else:
+ self.ListSize = self.ItemSize * len(self.RawDataList)
+ return self.ListSize
+
+ def PackData(self):
+ if self.ItemSize == 8:
+ PackStr = "=Q"
+ elif self.ItemSize == 4:
+ PackStr = "=L"
+ elif self.ItemSize == 2:
+ PackStr = "=H"
+ elif self.ItemSize == 1:
+ PackStr = "=B"
+ elif self.ItemSize == 0:
+ PackStr = "=B"
+ elif self.ItemSize == 16:
+ # pack Guid
+ PackStr = ''
+ else:
+ # should not reach here
+ assert(False)
+
+ Buffer = ''
+ for Datas in self.RawDataList:
+ if type(Datas) in (list, tuple):
+ for Data in Datas:
+ if PackStr:
+ Buffer += pack(PackStr, GetIntegerValue(Data))
+ else:
+ Buffer += PackGuid(Data)
+ else:
+ if PackStr:
+ Buffer += pack(PackStr, GetIntegerValue(Datas))
+ else:
+ Buffer += PackGuid(Datas)
+
+ return Buffer
+
+## DbExMapTblItemList
+#
+# The class holds the ExMap table
+#
+class DbExMapTblItemList (DbItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def PackData(self):
+ Buffer = ''
+ PackStr = "=LHH"
+ for Datas in self.RawDataList:
+ Buffer += pack(PackStr,
+ GetIntegerValue(Datas[0]),
+ GetIntegerValue(Datas[1]),
+ GetIntegerValue(Datas[2]))
+ return Buffer
+
+## DbComItemList
+#
+# The DbComItemList is a special kind of DbItemList in case that the size of the List can not be computed by the
+# ItemSize multiply the ItemCount.
+#
+class DbComItemList (DbItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def GetInterOffset(self, Index):
+ Offset = 0
+ if self.ItemSize == 0:
+ #
+ # Variable length, need to calculte one by one
+ # The only variable table is stringtable, it is not Composite item, should not reach here
+ #
+ assert(False)
+ else:
+ assert(Index < len(self.RawDataList))
+ for ItemIndex in xrange(Index):
+ Offset += len(self.RawDataList[ItemIndex]) * self.ItemSize
+
+ return Offset
+
+ def GetListSize(self):
+ if self.ListSize:
+ return self.ListSize
+ if self.ItemSize == 0:
+ assert(False)
+ else:
+ if len(self.RawDataList) == 0:
+ self.ListSize = 0
+ else:
+ self.ListSize = self.GetInterOffset(len(self.RawDataList) - 1) + len(self.RawDataList[len(self.RawDataList)-1]) * self.ItemSize
+
+ return self.ListSize
+
+ def PackData(self):
+ if self.ItemSize == 8:
+ PackStr = "=Q"
+ elif self.ItemSize == 4:
+ PackStr = "=L"
+ elif self.ItemSize == 2:
+ PackStr = "=H"
+ elif self.ItemSize == 1:
+ PackStr = "=B"
+ elif self.ItemSize == 0:
+ PackStr = "=B"
+ else:
+ assert(False)
+
+ Buffer = ''
+ for DataList in self.RawDataList:
+ for Data in DataList:
+ if type(Data) in (list, tuple):
+ for SingleData in Data:
+ Buffer += pack(PackStr, GetIntegerValue(SingleData))
+ else:
+ Buffer += pack(PackStr, GetIntegerValue(Data))
+
+ return Buffer
+
+## DbVariableTableItemList
+#
+# The class holds the Variable header value table
+#
+class DbVariableTableItemList (DbComItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbComItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def PackData(self):
+ PackStr = "=LLHH"
+ Buffer = ''
+ for DataList in self.RawDataList:
+ for Data in DataList:
+ Buffer += pack(PackStr,
+ GetIntegerValue(Data[0]),
+ GetIntegerValue(Data[1]),
+ GetIntegerValue(Data[2]),
+ GetIntegerValue(Data[3]))
+ return Buffer
+
+class DbStringHeadTableItemList(DbItemList):
+ def __init__(self,ItemSize,DataList=None,RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+
+ def GetInterOffset(self, Index):
+ Offset = 0
+ if self.ItemSize == 0:
+ #
+ # Variable length, need to calculate one by one
+ #
+ assert(Index < len(self.RawDataList))
+ for ItemIndex in xrange(Index):
+ Offset += len(self.RawDataList[ItemIndex])
+ else:
+ for innerIndex in range(Index):
+ if type(self.RawDataList[innerIndex]) in (list, tuple):
+ Offset += len(self.RawDataList[innerIndex]) * self.ItemSize
+ else:
+ Offset += self.ItemSize
+
+ return Offset
+
+ def GetListSize(self):
+ if self.ListSize:
+ return self.ListSize
+ if len(self.RawDataList) == 0:
+ self.ListSize = 0
+ return self.ListSize
+ if self.ItemSize == 0:
+ self.ListSize = self.GetInterOffset(len(self.RawDataList) - 1) + len(self.RawDataList[len(self.RawDataList)-1])
+ else:
+ for Datas in self.RawDataList:
+ if type(Datas) in (list, tuple):
+ self.ListSize += len(Datas) * self.ItemSize
+ else:
+ self.ListSize += self.ItemSize
+ return self.ListSize
+
+## DbSkuHeadTableItemList
+#
+# The class holds the Sku header value table
+#
+class DbSkuHeadTableItemList (DbItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def PackData(self):
+ PackStr = "=LL"
+ Buffer = ''
+ for Data in self.RawDataList:
+ Buffer += pack(PackStr,
+ GetIntegerValue(Data[0]),
+ GetIntegerValue(Data[1]))
+ return Buffer
+
+## DbSizeTableItemList
+#
+# The class holds the size table
+#
+class DbSizeTableItemList (DbItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ DbItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def PackData(self):
+ PackStr = "=HH"
+ Buffer = ''
+ for Data in self.RawDataList:
+ Buffer += pack(PackStr,
+ GetIntegerValue(Data[0]),
+ GetIntegerValue(Data[1]))
+ return Buffer
+
+## DbStringItemList
+#
+# The class holds the string table
+#
+class DbStringItemList (DbComItemList):
+ def __init__(self, ItemSize, DataList=None, RawDataList=None, LenList=None):
+ if DataList is None:
+ DataList = []
+ if RawDataList is None:
+ RawDataList = []
+ if LenList is None:
+ LenList = []
+
+ assert(len(RawDataList) == len(LenList))
+ DataList = []
+ # adjust DataList according to the LenList
+ for Index in xrange(len(RawDataList)):
+ Len = LenList[Index]
+ RawDatas = RawDataList[Index]
+ assert(Len >= len(RawDatas))
+ ActualDatas = []
+ for i in xrange(len(RawDatas)):
+ ActualDatas.append(RawDatas[i])
+ for i in xrange(len(RawDatas), Len):
+ ActualDatas.append(0)
+ DataList.append(ActualDatas)
+ self.LenList = LenList
+ DbComItemList.__init__(self, ItemSize, DataList, RawDataList)
+ def GetInterOffset(self, Index):
+ Offset = 0
+
+ assert(Index < len(self.LenList))
+ for ItemIndex in xrange(Index):
+ Offset += self.LenList[ItemIndex]
+
+ return Offset
+
+ def GetListSize(self):
+ if self.ListSize:
+ return self.ListSize
+
+ if len(self.LenList) == 0:
+ self.ListSize = 0
+ else:
+ self.ListSize = self.GetInterOffset(len(self.LenList) - 1) + self.LenList[len(self.LenList)-1]
+
+ return self.ListSize
+
+ def PackData(self):
+ self.RawDataList = self.DataList
+ return DbComItemList.PackData(self)
+
+
+
+## Find the index in two list where the item matches the key separately
+#
+# @param Key1 The key used to search the List1
+# @param List1 The list that Key1 will be searched
+# @param Key2 The key used to search the List2
+# @param List2 The list that Key2 will be searched
+#
+# @retval Index The position inside the list where list1[Index] == Key1 and list2[Index] == Key2
+#
+def GetMatchedIndex(Key1, List1, Key2, List2):
+ StartPos = 0
+ while StartPos < len(List1):
+ Index = List1.index(Key1, StartPos)
+ if List2[Index] == Key2:
+ return Index
+ else:
+ StartPos = Index + 1
+
+ return -1
+
+
+## Get the integer value from string like "14U" or integer like 2
+#
+# @param Input The object that may be either a integer value or a string
+#
+# @retval Value The integer value that the input represents
+#
+def GetIntegerValue(Input):
+ if type(Input) in (int, long):
+ return Input
+ String = Input
+ if String.endswith("U"):
+ String = String[:-1]
+ if String.endswith("ULL"):
+ String = String[:-3]
+ if String.endswith("LL"):
+ String = String[:-2]
+
+ if String.startswith("0x") or String.startswith("0X"):
+ return int(String, 16)
+ elif String == '':
+ return 0
+ else:
+ return int(String)
+
+
+## convert StringArray like {0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x00, 0x34, 0x00, 0x00, 0x00}
+# to List like [0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x00, 0x34, 0x00, 0x00, 0x00]
+#
+# @param StringArray A string array like {0x36, 0x00, 0x34, 0x00, 0x21, 0x00, 0x36, 0x00, 0x34, 0x00, 0x00, 0x00}
+#
+# @retval A list object of integer items
+#
+def StringArrayToList(StringArray):
+ StringArray = StringArray[1:-1]
+ StringArray = '[' + StringArray + ']'
+ return eval(StringArray)
+
+
+## Convert TokenType String like "PCD_DATUM_TYPE_UINT32 | PCD_TYPE_HII" to TokenType value
+#
+# @param TokenType A TokenType string like "PCD_DATUM_TYPE_UINT32 | PCD_TYPE_HII"
+#
+# @retval A integer representation of the TokenType
+#
+def GetTokenTypeValue(TokenType):
+ TokenTypeDict = {
+ "PCD_TYPE_SHIFT":28,
+ "PCD_TYPE_DATA":(0x0 << 28),
+ "PCD_TYPE_HII":(0x8 << 28),
+ "PCD_TYPE_VPD":(0x4 << 28),
+ "PCD_TYPE_SKU_ENABLED":(0x2 << 28),
+ "PCD_TYPE_STRING":(0x1 << 28),
+
+ "PCD_DATUM_TYPE_SHIFT":24,
+ "PCD_DATUM_TYPE_POINTER":(0x0 << 24),
+ "PCD_DATUM_TYPE_UINT8":(0x1 << 24),
+ "PCD_DATUM_TYPE_UINT16":(0x2 << 24),
+ "PCD_DATUM_TYPE_UINT32":(0x4 << 24),
+ "PCD_DATUM_TYPE_UINT64":(0x8 << 24),
+
+ "PCD_DATUM_TYPE_SHIFT2":20,
+ "PCD_DATUM_TYPE_UINT8_BOOLEAN":(0x1 << 20 | 0x1 << 24),
+ }
+ return eval(TokenType, TokenTypeDict)
+
+## construct the external Pcd database using data from Dict
+#
+# @param Dict A dictionary contains Pcd related tables
+#
+# @retval Buffer A byte stream of the Pcd database
+#
+def BuildExDataBase(Dict):
+ # init Db items
+ InitValueUint64 = Dict['INIT_DB_VALUE_UINT64']
+ DbInitValueUint64 = DbComItemList(8, RawDataList = InitValueUint64)
+ VardefValueUint64 = Dict['VARDEF_DB_VALUE_UINT64']
+ DbVardefValueUint64 = DbItemList(8, RawDataList = VardefValueUint64)
+ InitValueUint32 = Dict['INIT_DB_VALUE_UINT32']
+ DbInitValueUint32 = DbComItemList(4, RawDataList = InitValueUint32)
+ VardefValueUint32 = Dict['VARDEF_DB_VALUE_UINT32']
+ DbVardefValueUint32 = DbItemList(4, RawDataList = VardefValueUint32)
+ VpdHeadValue = Dict['VPD_DB_VALUE']
+ DbVpdHeadValue = DbComItemList(4, RawDataList = VpdHeadValue)
+ ExMapTable = zip(Dict['EXMAPPING_TABLE_EXTOKEN'], Dict['EXMAPPING_TABLE_LOCAL_TOKEN'], Dict['EXMAPPING_TABLE_GUID_INDEX'])
+ DbExMapTable = DbExMapTblItemList(8, RawDataList = ExMapTable)
+ LocalTokenNumberTable = Dict['LOCAL_TOKEN_NUMBER_DB_VALUE']
+ DbLocalTokenNumberTable = DbItemList(4, RawDataList = LocalTokenNumberTable)
+ GuidTable = Dict['GUID_STRUCTURE']
+ DbGuidTable = DbItemList(16, RawDataList = GuidTable)
+ StringHeadValue = Dict['STRING_DB_VALUE']
+ # DbItemList to DbStringHeadTableItemList
+ DbStringHeadValue = DbStringHeadTableItemList(4, RawDataList = StringHeadValue)
+ VariableTable = Dict['VARIABLE_DB_VALUE']
+ DbVariableTable = DbVariableTableItemList(12, RawDataList = VariableTable)
+ NumberOfSkuEnabledPcd = GetIntegerValue(Dict['SKU_HEAD_SIZE'])
+ Dict['SKUHEAD_TABLE_VALUE'] = [(0,0) for i in xrange(NumberOfSkuEnabledPcd)]
+ SkuTable = Dict['SKUHEAD_TABLE_VALUE'] # Generated later
+ DbSkuTable = DbSkuHeadTableItemList(8, RawDataList = SkuTable)
+ Dict['STRING_TABLE_DB_VALUE'] = [StringArrayToList(x) for x in Dict['STRING_TABLE_VALUE']]
+
+ StringTableValue = Dict['STRING_TABLE_DB_VALUE']
+ # when calcute the offset, should use StringTableLen instead of StringTableValue, as string maxium len may be different with actual len
+ StringTableLen = Dict['STRING_TABLE_LENGTH']
+ DbStringTableLen = DbStringItemList(0, RawDataList = StringTableValue, LenList = StringTableLen)
+
+
+ PcdTokenTable = Dict['PCD_TOKENSPACE']
+ PcdTokenLen = Dict['PCD_TOKENSPACE_LENGTH']
+ PcdTokenTableValue = [StringArrayToList(x) for x in Dict['PCD_TOKENSPACE']]
+ DbPcdTokenTable = DbStringItemList(0, RawDataList = PcdTokenTableValue, LenList = PcdTokenLen)
+
+ PcdCNameTable = Dict['PCD_CNAME']
+ PcdCNameLen = Dict['PCD_CNAME_LENGTH']
+ PcdCNameTableValue = [StringArrayToList(x) for x in Dict['PCD_CNAME']]
+ DbPcdCNameTable = DbStringItemList(0, RawDataList = PcdCNameTableValue, LenList = PcdCNameLen)
+
+ PcdNameOffsetTable = Dict['PCD_NAME_OFFSET']
+ DbPcdNameOffsetTable = DbItemList(4,RawDataList = PcdNameOffsetTable)
+
+ SizeTableValue = zip(Dict['SIZE_TABLE_MAXIMUM_LENGTH'], Dict['SIZE_TABLE_CURRENT_LENGTH'])
+ DbSizeTableValue = DbSizeTableItemList(4, RawDataList = SizeTableValue)
+ InitValueUint16 = Dict['INIT_DB_VALUE_UINT16']
+ DbInitValueUint16 = DbComItemList(2, RawDataList = InitValueUint16)
+ VardefValueUint16 = Dict['VARDEF_DB_VALUE_UINT16']
+ DbVardefValueUint16 = DbItemList(2, RawDataList = VardefValueUint16)
+ InitValueUint8 = Dict['INIT_DB_VALUE_UINT8']
+ DbInitValueUint8 = DbComItemList(1, RawDataList = InitValueUint8)
+ VardefValueUint8 = Dict['VARDEF_DB_VALUE_UINT8']
+ DbVardefValueUint8 = DbItemList(1, RawDataList = VardefValueUint8)
+ InitValueBoolean = Dict['INIT_DB_VALUE_BOOLEAN']
+ DbInitValueBoolean = DbComItemList(1, RawDataList = InitValueBoolean)
+ VardefValueBoolean = Dict['VARDEF_DB_VALUE_BOOLEAN']
+ DbVardefValueBoolean = DbItemList(1, RawDataList = VardefValueBoolean)
+ SkuidValue = Dict['SKUID_VALUE']
+ DbSkuidValue = DbItemList(1, RawDataList = SkuidValue)
+ SkuIndexValue = Dict['SKU_INDEX_VALUE']
+ DbSkuIndexValue = DbItemList(0,RawDataList = SkuIndexValue)
+
+ # Unit Db Items
+ UnInitValueUint64 = Dict['UNINIT_GUID_DECL_UINT64']
+ DbUnInitValueUint64 = DbItemList(8, RawDataList = UnInitValueUint64)
+ UnInitValueUint32 = Dict['UNINIT_GUID_DECL_UINT32']
+ DbUnInitValueUint32 = DbItemList(4, RawDataList = UnInitValueUint32)
+ UnInitValueUint16 = Dict['UNINIT_GUID_DECL_UINT16']
+ DbUnInitValueUint16 = DbItemList(2, RawDataList = UnInitValueUint16)
+ UnInitValueUint8 = Dict['UNINIT_GUID_DECL_UINT8']
+ DbUnInitValueUint8 = DbItemList(1, RawDataList = UnInitValueUint8)
+ UnInitValueBoolean = Dict['UNINIT_GUID_DECL_BOOLEAN']
+ DbUnInitValueBoolean = DbItemList(1, RawDataList = UnInitValueBoolean)
+
+ DbNameTotle = ["InitValueUint64", "VardefValueUint64", "InitValueUint32", "VardefValueUint32", "VpdHeadValue", "ExMapTable",
+ "LocalTokenNumberTable", "GuidTable", "StringHeadValue", "PcdNameOffsetTable","VariableTable","SkuTable", "StringTableLen", "PcdTokenTable", "PcdCNameTable",
+ "SizeTableValue", "InitValueUint16", "VardefValueUint16", "InitValueUint8", "VardefValueUint8", "InitValueBoolean",
+ "VardefValueBoolean", "SkuidValue", "SkuIndexValue","UnInitValueUint64", "UnInitValueUint32", "UnInitValueUint16", "UnInitValueUint8", "UnInitValueBoolean"]
+
+ DbTotal = [InitValueUint64, VardefValueUint64, InitValueUint32, VardefValueUint32, VpdHeadValue, ExMapTable,
+ LocalTokenNumberTable, GuidTable, StringHeadValue, PcdNameOffsetTable,VariableTable,SkuTable, StringTableLen, PcdTokenTable,PcdCNameTable,
+ SizeTableValue, InitValueUint16, VardefValueUint16,InitValueUint8, VardefValueUint8, InitValueBoolean,
+ VardefValueBoolean, SkuidValue, SkuIndexValue, UnInitValueUint64, UnInitValueUint32, UnInitValueUint16, UnInitValueUint8, UnInitValueBoolean]
+ DbItemTotal = [DbInitValueUint64, DbVardefValueUint64, DbInitValueUint32, DbVardefValueUint32, DbVpdHeadValue, DbExMapTable,
+ DbLocalTokenNumberTable, DbGuidTable, DbStringHeadValue, DbPcdNameOffsetTable,DbVariableTable,DbSkuTable, DbStringTableLen, DbPcdTokenTable, DbPcdCNameTable,
+ DbSizeTableValue, DbInitValueUint16, DbVardefValueUint16,DbInitValueUint8, DbVardefValueUint8, DbInitValueBoolean,
+ DbVardefValueBoolean, DbSkuidValue, DbSkuIndexValue, DbUnInitValueUint64, DbUnInitValueUint32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean]
+
+ # SkuidValue is the last table in the init table items
+ InitTableNum = DbTotal.index(SkuidValue) + 1 + 1 # +1 is for SkuIndexValue table
+ # The FixedHeader length of the PCD_DATABASE_INIT, from Signature to Pad
+ FixedHeaderLen = 64
+
+ # Get offset of SkuId table in the database
+ SkuIdTableOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is SkuidValue:
+ break
+ SkuIdTableOffset += DbItemTotal[DbIndex].GetListSize()
+
+
+ # Get offset of SkuValue table in the database
+ SkuTableOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is SkuTable:
+ break
+ SkuTableOffset += DbItemTotal[DbIndex].GetListSize()
+ PcdTokenTableDbOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is PcdTokenTable:
+ break
+ PcdTokenTableDbOffset += DbItemTotal[DbIndex].GetListSize()
+
+ PcdCNameTableDbOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is PcdCNameTable:
+ break
+ PcdCNameTableDbOffset += DbItemTotal[DbIndex].GetListSize()
+ # Fix up the LocalTokenNumberTable, SkuHeader table
+ SkuHeaderIndex = 0
+ if len(Dict['SKU_INDEX_VALUE']) > 0:
+ SkuIndexIndexTable = [(0) for i in xrange(len(Dict['SKU_INDEX_VALUE']))]
+ SkuIndexIndexTable[0] = 0 #Dict['SKU_INDEX_VALUE'][0][0]
+ for i in range(1,len(Dict['SKU_INDEX_VALUE'])):
+ SkuIndexIndexTable[i] = SkuIndexIndexTable[i-1]+Dict['SKU_INDEX_VALUE'][i-1][0]
+ for (LocalTokenNumberTableIndex, (Offset, Table)) in enumerate(LocalTokenNumberTable):
+ DbIndex = 0
+ DbOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is Table:
+ DbOffset += DbItemTotal[DbIndex].GetInterOffset(Offset)
+ break
+ DbOffset += DbItemTotal[DbIndex].GetListSize()
+ else:
+ assert(False)
+
+ TokenTypeValue = Dict['TOKEN_TYPE'][LocalTokenNumberTableIndex]
+ TokenTypeValue = GetTokenTypeValue(TokenTypeValue)
+ LocalTokenNumberTable[LocalTokenNumberTableIndex] = DbOffset|int(TokenTypeValue)
+ # if PCD_TYPE_SKU_ENABLED, then we need to fix up the SkuTable
+
+ SkuIndexTabalOffset = SkuIdTableOffset + Dict['SKUID_VALUE'][0]
+ if (TokenTypeValue & (0x2 << 28)):
+ SkuTable[SkuHeaderIndex] = (DbOffset|int(TokenTypeValue & ~(0x2<<28)), SkuIndexTabalOffset + SkuIndexIndexTable[SkuHeaderIndex])
+ LocalTokenNumberTable[LocalTokenNumberTableIndex] = (SkuTableOffset + SkuHeaderIndex * 8) | int(TokenTypeValue)
+ SkuHeaderIndex += 1
+
+
+ if SkuHeaderIndex == 0:
+ SkuHeaderIndex = 1
+ assert(SkuHeaderIndex == NumberOfSkuEnabledPcd)
+
+ # resolve variable table offset
+ for VariableEntries in VariableTable:
+ for VariableEntryPerSku in VariableEntries:
+ (VariableHeadGuidIndex, VariableHeadStringIndex, SKUVariableOffset, VariableOffset, VariableRefTable) = VariableEntryPerSku[:]
+ DbIndex = 0
+ DbOffset = FixedHeaderLen
+ for DbIndex in xrange(len(DbTotal)):
+ if DbTotal[DbIndex] is VariableRefTable:
+ DbOffset += DbItemTotal[DbIndex].GetInterOffset(VariableOffset)
+ break
+ DbOffset += DbItemTotal[DbIndex].GetListSize()
+ else:
+ assert(False)
+
+ if DbIndex >= InitTableNum:
+ assert(False)
+
+ VariableEntryPerSku[:] = (VariableHeadStringIndex, DbOffset, VariableHeadGuidIndex, SKUVariableOffset)
+
+ # calculate various table offset now
+ DbTotalLength = FixedHeaderLen
+ for DbIndex in xrange(len(DbItemTotal)):
+ if DbItemTotal[DbIndex] is DbLocalTokenNumberTable:
+ LocalTokenNumberTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbExMapTable:
+ ExMapTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbGuidTable:
+ GuidTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbStringTableLen:
+ StringTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbSizeTableValue:
+ SizeTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbSkuidValue:
+ SkuIdTableOffset = DbTotalLength
+ elif DbItemTotal[DbIndex] is DbPcdNameOffsetTable:
+ DbPcdNameOffset = DbTotalLength
+
+ DbTotalLength += DbItemTotal[DbIndex].GetListSize()
+ if not Dict['PCD_INFO_FLAG']:
+ DbPcdNameOffset = 0
+ LocalTokenCount = GetIntegerValue(Dict['LOCAL_TOKEN_NUMBER'])
+ ExTokenCount = GetIntegerValue(Dict['EX_TOKEN_NUMBER'])
+ GuidTableCount = GetIntegerValue(Dict['GUID_TABLE_SIZE'])
+ SystemSkuId = GetIntegerValue(Dict['SYSTEM_SKU_ID_VALUE'])
+ Pad = 0xDA
+
+ UninitDataBaseSize = 0
+ for Item in (DbUnInitValueUint64, DbUnInitValueUint32, DbUnInitValueUint16, DbUnInitValueUint8, DbUnInitValueBoolean):
+ UninitDataBaseSize += Item.GetListSize()
+
+ # Construct the database buffer
+ Guid = "{0x3c7d193c, 0x682c, 0x4c14, 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e}"
+ Guid = StringArrayToList(Guid)
+ Buffer = pack('=LHHBBBBBBBB',
+ Guid[0],
+ Guid[1],
+ Guid[2],
+ Guid[3],
+ Guid[4],
+ Guid[5],
+ Guid[6],
+ Guid[7],
+ Guid[8],
+ Guid[9],
+ Guid[10],
+ )
+
+ b = pack("=L", DATABASE_VERSION)
+ Buffer += b
+
+ b = pack('=L', DbTotalLength - UninitDataBaseSize)
+
+ Buffer += b
+ b = pack('=L', UninitDataBaseSize)
+
+ Buffer += b
+ b = pack('=L', LocalTokenNumberTableOffset)
+
+ Buffer += b
+ b = pack('=L', ExMapTableOffset)
+
+ Buffer += b
+ b = pack('=L', GuidTableOffset)
+
+ Buffer += b
+ b = pack('=L', StringTableOffset)
+
+ Buffer += b
+ b = pack('=L', SizeTableOffset)
+
+ Buffer += b
+ b = pack('=L', SkuIdTableOffset)
+
+ Buffer += b
+ b = pack('=L', DbPcdNameOffset)
+
+ Buffer += b
+ b = pack('=H', LocalTokenCount)
+
+ Buffer += b
+ b = pack('=H', ExTokenCount)
+
+ Buffer += b
+ b = pack('=H', GuidTableCount)
+
+ Buffer += b
+ b = pack('=B', SystemSkuId)
+
+ Buffer += b
+ b = pack('=B', Pad)
+
+ Buffer += b
+
+ Index = 0
+ for Item in DbItemTotal:
+ Index +=1
+ b = Item.PackData()
+ Buffer += b
+ if Index == InitTableNum:
+ break
+ return Buffer
+
+## Create code for PCD database
+#
+# @param Info The ModuleAutoGen object
+# @param AutoGenC The TemplateString object for C code
+# @param AutoGenH The TemplateString object for header file
+#
+def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
+ if Info.PcdIsDriver == "":
+ return
+ if Info.PcdIsDriver not in gPcdPhaseMap:
+ EdkLogger.error("build", AUTOGEN_ERROR, "Not supported PcdIsDriver type:%s" % Info.PcdIsDriver,
+ ExtraData="[%s]" % str(Info))
+
+ AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, 'PEI')
+ AutoGenH.Append(AdditionalAutoGenH.String)
+
+ Phase = gPcdPhaseMap[Info.PcdIsDriver]
+ if Phase == 'PEI':
+ AutoGenC.Append(AdditionalAutoGenC.String)
+
+ if Phase == 'DXE':
+ AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer = CreatePcdDatabasePhaseSpecificAutoGen (Info.PlatformInfo, Phase)
+ AutoGenH.Append(AdditionalAutoGenH.String)
+ AutoGenC.Append(AdditionalAutoGenC.String)
+
+ if Info.IsBinaryModule:
+ DbFileName = os.path.join(Info.PlatformInfo.BuildDir, "FV", Phase + "PcdDataBase.raw")
+ else:
+ DbFileName = os.path.join(Info.OutputDir, Phase + "PcdDataBase.raw")
+ DbFile = StringIO()
+ DbFile.write(PcdDbBuffer)
+ Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)
+
+
+def CArrayToArray(carray):
+ return "{%s, 0x00}" % ", ".join(["0x%02x" % ord(C) for C in carray])
+
+## Create PCD database in DXE or PEI phase
+#
+# @param Platform The platform object
+# @retval tuple Two TemplateString objects for C code and header file,
+# respectively
+#
+def CreatePcdDatabasePhaseSpecificAutoGen (Platform, Phase):
+ AutoGenC = TemplateString()
+ AutoGenH = TemplateString()
+
+ Dict = {
+ 'PHASE' : Phase,
+ 'SERVICE_DRIVER_VERSION' : DATABASE_VERSION,
+ 'GUID_TABLE_SIZE' : '1U',
+ 'STRING_TABLE_SIZE' : '1U',
+ 'SKUID_TABLE_SIZE' : '1U',
+ 'LOCAL_TOKEN_NUMBER_TABLE_SIZE' : '0U',
+ 'LOCAL_TOKEN_NUMBER' : '0U',
+ 'EXMAPPING_TABLE_SIZE' : '1U',
+ 'EX_TOKEN_NUMBER' : '0U',
+ 'SIZE_TABLE_SIZE' : '2U',
+ 'SKU_HEAD_SIZE' : '1U',
+ 'GUID_TABLE_EMPTY' : 'TRUE',
+ 'STRING_TABLE_EMPTY' : 'TRUE',
+ 'SKUID_TABLE_EMPTY' : 'TRUE',
+ 'DATABASE_EMPTY' : 'TRUE',
+ 'EXMAP_TABLE_EMPTY' : 'TRUE',
+ 'PCD_DATABASE_UNINIT_EMPTY' : ' UINT8 dummy; /* PCD_DATABASE_UNINIT is emptry */',
+ 'SYSTEM_SKU_ID' : ' SKU_ID SystemSkuId;',
+ 'SYSTEM_SKU_ID_VALUE' : '0U'
+ }
+
+
+ SkuObj = SkuClass(Platform.Platform.SkuName,Platform.Platform.SkuIds)
+ Dict['SYSTEM_SKU_ID_VALUE'] = Platform.Platform.SkuIds[SkuObj.SystemSkuId]
+
+ Dict['PCD_INFO_FLAG'] = Platform.Platform.PcdInfoFlag
+
+ for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]:
+ Dict['VARDEF_CNAME_' + DatumType] = []
+ Dict['VARDEF_GUID_' + DatumType] = []
+ Dict['VARDEF_SKUID_' + DatumType] = []
+ Dict['VARDEF_VALUE_' + DatumType] = []
+ Dict['VARDEF_DB_VALUE_' + DatumType] = []
+ for Init in ['INIT','UNINIT']:
+ Dict[Init+'_CNAME_DECL_' + DatumType] = []
+ Dict[Init+'_GUID_DECL_' + DatumType] = []
+ Dict[Init+'_NUMSKUS_DECL_' + DatumType] = []
+ Dict[Init+'_VALUE_' + DatumType] = []
+ Dict[Init+'_DB_VALUE_'+DatumType] = []
+
+ for Type in ['STRING_HEAD','VPD_HEAD','VARIABLE_HEAD']:
+ Dict[Type + '_CNAME_DECL'] = []
+ Dict[Type + '_GUID_DECL'] = []
+ Dict[Type + '_NUMSKUS_DECL'] = []
+ Dict[Type + '_VALUE'] = []
+
+ Dict['STRING_DB_VALUE'] = []
+ Dict['VPD_DB_VALUE'] = []
+ Dict['VARIABLE_DB_VALUE'] = []
+
+ Dict['STRING_TABLE_INDEX'] = []
+ Dict['STRING_TABLE_LENGTH'] = []
+ Dict['STRING_TABLE_CNAME'] = []
+ Dict['STRING_TABLE_GUID'] = []
+ Dict['STRING_TABLE_VALUE'] = []
+ Dict['STRING_TABLE_DB_VALUE'] = []
+
+ Dict['SIZE_TABLE_CNAME'] = []
+ Dict['SIZE_TABLE_GUID'] = []
+ Dict['SIZE_TABLE_CURRENT_LENGTH'] = []
+ Dict['SIZE_TABLE_MAXIMUM_LENGTH'] = []
+
+ Dict['EXMAPPING_TABLE_EXTOKEN'] = []
+ Dict['EXMAPPING_TABLE_LOCAL_TOKEN'] = []
+ Dict['EXMAPPING_TABLE_GUID_INDEX'] = []
+
+ Dict['GUID_STRUCTURE'] = []
+ Dict['SKUID_VALUE'] = [0] # init Dict length
+ Dict['VARDEF_HEADER'] = []
+
+ Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] = []
+ Dict['VARIABLE_DB_VALUE'] = []
+ Dict['SKUHEAD_TABLE_VALUE'] = []
+ Dict['SKU_INDEX_VALUE'] = []
+
+ Dict['PCD_TOKENSPACE'] = []
+ Dict['PCD_CNAME'] = []
+ Dict['PCD_TOKENSPACE_LENGTH'] = []
+ Dict['PCD_CNAME_LENGTH'] = []
+ Dict['PCD_TOKENSPACE_OFFSET'] = []
+ Dict['PCD_CNAME_OFFSET'] = []
+ Dict['PCD_TOKENSPACE_MAP'] = []
+ Dict['PCD_NAME_OFFSET'] = []
+
+ StringTableIndex = 0
+ StringTableSize = 0
+ NumberOfLocalTokens = 0
+ NumberOfPeiLocalTokens = 0
+ NumberOfDxeLocalTokens = 0
+ NumberOfExTokens = 0
+ NumberOfSizeItems = 0
+ NumberOfSkuEnabledPcd = 0
+ GuidList = []
+ i = 0
+ for Pcd in Platform.DynamicPcdList:
+ i += 1
+ CName = Pcd.TokenCName
+ TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
+
+ EdkLogger.debug(EdkLogger.DEBUG_3, "PCD: %s %s (%s : %s)" % (CName, TokenSpaceGuidCName, Pcd.Phase, Phase))
+
+ if Pcd.Phase == 'PEI':
+ NumberOfPeiLocalTokens += 1
+ if Pcd.Phase == 'DXE':
+ NumberOfDxeLocalTokens += 1
+ if Pcd.Phase != Phase:
+ continue
+
+ #
+ # TODO: need GetGuidValue() definition
+ #
+ TokenSpaceGuidStructure = Pcd.TokenSpaceGuidValue
+ TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure)
+ if Pcd.Type in gDynamicExPcd:
+ if TokenSpaceGuid not in GuidList:
+ GuidList += [TokenSpaceGuid]
+ Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure)
+ NumberOfExTokens += 1
+
+ ValueList = []
+ DbValueList = []
+ StringHeadOffsetList = []
+ StringDbOffsetList = []
+ VpdHeadOffsetList = []
+ VpdDbOffsetList = []
+ VariableHeadValueList = []
+ VariableDbValueList = []
+ Pcd.InitString = 'UNINIT'
+
+ if Pcd.DatumType == 'VOID*':
+ if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:
+ Pcd.TokenTypeList = ['PCD_TYPE_STRING']
+ else:
+ Pcd.TokenTypeList = []
+ elif Pcd.DatumType == 'BOOLEAN':
+ Pcd.TokenTypeList = ['PCD_DATUM_TYPE_UINT8_BOOLEAN']
+ else:
+ Pcd.TokenTypeList = ['PCD_DATUM_TYPE_' + Pcd.DatumType]
+
+ if len(Pcd.SkuInfoList) > 1:
+ Pcd.TokenTypeList += ['PCD_TYPE_SKU_ENABLED']
+ NumberOfSkuEnabledPcd += 1
+
+ SkuIndexTableTmp = []
+ SkuIndexTableTmp.append(0)
+ SkuIdIndex = 1
+ for SkuName in Pcd.SkuInfoList:
+ Sku = Pcd.SkuInfoList[SkuName]
+ SkuId = Sku.SkuId
+ if SkuId == None or SkuId == '':
+ continue
+
+ if (SkuId + 'U') not in Dict['SKUID_VALUE']:
+ Dict['SKUID_VALUE'].append(SkuId + 'U')
+
+ SkuIndexTableTmp.append(SkuId+'U')
+ SkuIdIndex += 1
+
+ if len(Sku.VariableName) > 0:
+ Pcd.TokenTypeList += ['PCD_TYPE_HII']
+ Pcd.InitString = 'INIT'
+ # store VariableName to stringTable and calculate the VariableHeadStringIndex
+ if Sku.VariableName.startswith('{'):
+ VariableNameStructure = CArrayToArray(Sku.VariableName)
+ else:
+ VariableNameStructure = StringToArray(Sku.VariableName)
+ if VariableNameStructure not in Dict['STRING_TABLE_VALUE']:
+ Dict['STRING_TABLE_CNAME'].append(CName)
+ Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
+ if StringTableIndex == 0:
+ Dict['STRING_TABLE_INDEX'].append('')
+ else:
+ Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
+
+ Dict['STRING_TABLE_LENGTH'].append((len(Sku.VariableName) - 3 + 1) * 2 )
+ Dict['STRING_TABLE_VALUE'].append(VariableNameStructure)
+ StringTableIndex += 1
+ StringTableSize += (len(Sku.VariableName) - 3 + 1) * 2
+ VariableHeadStringIndex = 0
+ for Index in range(Dict['STRING_TABLE_VALUE'].index(VariableNameStructure)):
+ VariableHeadStringIndex += Dict['STRING_TABLE_LENGTH'][Index]
+
+ # store VariableGuid to GuidTable and get the VariableHeadGuidIndex
+ VariableGuidStructure = Sku.VariableGuidValue
+ VariableGuid = GuidStructureStringToGuidValueName(VariableGuidStructure)
+
+ if VariableGuid not in GuidList:
+ GuidList += [VariableGuid]
+ Dict['GUID_STRUCTURE'].append(VariableGuidStructure)
+ VariableHeadGuidIndex = GuidList.index(VariableGuid)
+
+ if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
+ VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s), %dU, %sU' %
+ (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid,
+ VariableHeadGuidIndex, Sku.VariableOffset))
+ else:
+ VariableHeadValueList.append('%dU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s), %dU, %sU' %
+ (VariableHeadStringIndex, Phase, CName, TokenSpaceGuid, SkuIdIndex,
+ VariableHeadGuidIndex, Sku.VariableOffset))
+ Dict['VARDEF_CNAME_'+Pcd.DatumType].append(CName)
+ Dict['VARDEF_GUID_'+Pcd.DatumType].append(TokenSpaceGuid)
+ Dict['VARDEF_SKUID_'+Pcd.DatumType].append(SkuIdIndex)
+ if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
+ Dict['VARDEF_VALUE_' + Pcd.DatumType].append("%s_%s[%d]" % (Pcd.TokenCName, TokenSpaceGuid, SkuIdIndex))
+ else:
+ #
+ # ULL (for UINT64) or U(other integer type) should be append to avoid
+ # warning under linux building environment.
+ #
+ Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
+
+ if Pcd.DatumType == "UINT64":
+ Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL")
+ elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
+ Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")
+ elif Pcd.DatumType == "BOOLEAN":
+ if eval(Sku.HiiDefaultValue) in [1,0]:
+ Dict['VARDEF_VALUE_'+Pcd.DatumType].append(str(eval(Sku.HiiDefaultValue)) + "U")
+ else:
+ Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)
+
+ # construct the VariableHeader value
+ if "PCD_TYPE_STRING" in Pcd.TokenTypeList:
+ VariableHeadValueList.append('%dU, %dU, %sU, offsetof(%s_PCD_DATABASE, Init.%s_%s)' %
+ (VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
+ Phase, CName, TokenSpaceGuid))
+ # the Pcd default value will be filled later on
+ VariableOffset = len(Dict['STRING_DB_VALUE'])
+ VariableRefTable = Dict['STRING_DB_VALUE']
+ else:
+ VariableHeadValueList.append('%dU, %dU, %sU, offsetof(%s_PCD_DATABASE, Init.%s_%s_VariableDefault_%s)' %
+ (VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset,
+ Phase, CName, TokenSpaceGuid, SkuIdIndex))
+ # the Pcd default value was filled before
+ VariableOffset = len(Dict['VARDEF_DB_VALUE_' + Pcd.DatumType]) - 1
+ VariableRefTable = Dict['VARDEF_DB_VALUE_' + Pcd.DatumType]
+ VariableDbValueList.append([VariableHeadGuidIndex, VariableHeadStringIndex, Sku.VariableOffset, VariableOffset, VariableRefTable])
+
+ elif Sku.VpdOffset != '':
+ Pcd.TokenTypeList += ['PCD_TYPE_VPD']
+ Pcd.InitString = 'INIT'
+ VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U')
+ VpdDbOffsetList.append(Sku.VpdOffset)
+ # Also add the VOID* string of VPD PCD to SizeTable
+ if Pcd.DatumType == 'VOID*':
+ NumberOfSizeItems += 1
+ Dict['SIZE_TABLE_CNAME'].append(CName)
+ Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
+ # For VPD type of PCD, its current size is equal to its MAX size.
+ Dict['SIZE_TABLE_CURRENT_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')
+ Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')
+ continue
+
+ if Pcd.DatumType == 'VOID*':
+ Pcd.TokenTypeList += ['PCD_TYPE_STRING']
+ Pcd.InitString = 'INIT'
+ if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '':
+ Sku.DefaultValue = Sku.HiiDefaultValue
+ if Sku.DefaultValue != '':
+ NumberOfSizeItems += 1
+ Dict['STRING_TABLE_CNAME'].append(CName)
+ Dict['STRING_TABLE_GUID'].append(TokenSpaceGuid)
+
+ if StringTableIndex == 0:
+ Dict['STRING_TABLE_INDEX'].append('')
+ else:
+ Dict['STRING_TABLE_INDEX'].append('_%d' % StringTableIndex)
+ if Sku.DefaultValue[0] == 'L':
+ Size = (len(Sku.DefaultValue) - 3 + 1) * 2
+ Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
+ elif Sku.DefaultValue[0] == '"':
+ Size = len(Sku.DefaultValue) - 2 + 1
+ Dict['STRING_TABLE_VALUE'].append(StringToArray(Sku.DefaultValue))
+ elif Sku.DefaultValue[0] == '{':
+ Size = len(Sku.DefaultValue.replace(',',' ').split())
+ Dict['STRING_TABLE_VALUE'].append(Sku.DefaultValue)
+
+ StringHeadOffsetList.append(str(StringTableSize) + 'U')
+ StringDbOffsetList.append(StringTableSize)
+ Dict['SIZE_TABLE_CNAME'].append(CName)
+ Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)
+ Dict['SIZE_TABLE_CURRENT_LENGTH'].append(str(Size) + 'U')
+ Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')
+ if Pcd.MaxDatumSize != '':
+ MaxDatumSize = int(Pcd.MaxDatumSize, 0)
+ if MaxDatumSize < Size:
+ MaxDatumSize = Size
+ Size = MaxDatumSize
+ Dict['STRING_TABLE_LENGTH'].append(Size)
+ StringTableIndex += 1
+ StringTableSize += (Size)
+ else:
+ if "PCD_TYPE_HII" not in Pcd.TokenTypeList:
+ Pcd.TokenTypeList += ['PCD_TYPE_DATA']
+ if Sku.DefaultValue == 'TRUE':
+ Pcd.InitString = 'INIT'
+ else:
+ if int(Sku.DefaultValue, 0) != 0:
+ Pcd.InitString = 'INIT'
+ #
+ # For UNIT64 type PCD's value, ULL should be append to avoid
+ # warning under linux building environment.
+ #
+ if Pcd.DatumType == "UINT64":
+ ValueList.append(Sku.DefaultValue + "ULL")
+ elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):
+ ValueList.append(Sku.DefaultValue + "U")
+ elif Pcd.DatumType == "BOOLEAN":
+ if Sku.DefaultValue in ["1", "0"]:
+ ValueList.append(Sku.DefaultValue + "U")
+ else:
+ ValueList.append(Sku.DefaultValue)
+
+ DbValueList.append(Sku.DefaultValue)
+
+ Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
+
+ SkuIndexTableTmp[0] = len(SkuIndexTableTmp)
+ if len(Pcd.SkuInfoList) > 1:
+ Dict['SKU_INDEX_VALUE'].append(SkuIndexTableTmp)
+
+ if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
+ Dict['VARIABLE_HEAD_CNAME_DECL'].append(CName)
+ Dict['VARIABLE_HEAD_GUID_DECL'].append(TokenSpaceGuid)
+ Dict['VARIABLE_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
+ Dict['VARIABLE_HEAD_VALUE'].append('{ %s }\n' % ' },\n { '.join(VariableHeadValueList))
+ Dict['VARDEF_HEADER'].append('_Variable_Header')
+ Dict['VARIABLE_DB_VALUE'].append(VariableDbValueList)
+ else:
+ Dict['VARDEF_HEADER'].append('')
+ if 'PCD_TYPE_VPD' in Pcd.TokenTypeList:
+ Dict['VPD_HEAD_CNAME_DECL'].append(CName)
+ Dict['VPD_HEAD_GUID_DECL'].append(TokenSpaceGuid)
+ Dict['VPD_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
+ Dict['VPD_HEAD_VALUE'].append('{ %s }' % ' }, { '.join(VpdHeadOffsetList))
+ Dict['VPD_DB_VALUE'].append(VpdDbOffsetList)
+ if 'PCD_TYPE_STRING' in Pcd.TokenTypeList:
+ Dict['STRING_HEAD_CNAME_DECL'].append(CName)
+ Dict['STRING_HEAD_GUID_DECL'].append(TokenSpaceGuid)
+ Dict['STRING_HEAD_NUMSKUS_DECL'].append(len(Pcd.SkuInfoList))
+ Dict['STRING_HEAD_VALUE'].append(', '.join(StringHeadOffsetList))
+ Dict['STRING_DB_VALUE'].append(StringDbOffsetList)
+ if 'PCD_TYPE_DATA' in Pcd.TokenTypeList:
+ Dict[Pcd.InitString+'_CNAME_DECL_'+Pcd.DatumType].append(CName)
+ Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType].append(TokenSpaceGuid)
+ Dict[Pcd.InitString+'_NUMSKUS_DECL_'+Pcd.DatumType].append(len(Pcd.SkuInfoList))
+ if Pcd.InitString == 'UNINIT':
+ Dict['PCD_DATABASE_UNINIT_EMPTY'] = ''
+ else:
+ Dict[Pcd.InitString+'_VALUE_'+Pcd.DatumType].append(', '.join(ValueList))
+ Dict[Pcd.InitString+'_DB_VALUE_'+Pcd.DatumType].append(DbValueList)
+
+ if Phase == 'PEI':
+ NumberOfLocalTokens = NumberOfPeiLocalTokens
+ if Phase == 'DXE':
+ NumberOfLocalTokens = NumberOfDxeLocalTokens
+
+ Dict['TOKEN_INIT'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['TOKEN_CNAME'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['TOKEN_GUID'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['TOKEN_TYPE'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['PCD_CNAME'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['PCD_TOKENSPACE_MAP'] = ['' for x in range(NumberOfLocalTokens)]
+ Dict['PCD_CNAME_LENGTH'] = [0 for x in range(NumberOfLocalTokens)]
+ for Pcd in Platform.DynamicPcdList:
+ CName = Pcd.TokenCName
+ TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName
+ if Pcd.Phase != Phase:
+ continue
+
+ TokenSpaceGuid = GuidStructureStringToGuidValueName(Pcd.TokenSpaceGuidValue) #(Platform.PackageList, TokenSpaceGuidCName))
+ GeneratedTokenNumber = Platform.PcdTokenNumber[CName, TokenSpaceGuidCName] - 1
+ if Phase == 'DXE':
+ GeneratedTokenNumber -= NumberOfPeiLocalTokens
+
+ EdkLogger.debug(EdkLogger.DEBUG_1, "PCD = %s.%s" % (CName, TokenSpaceGuidCName))
+ EdkLogger.debug(EdkLogger.DEBUG_1, "phase = %s" % Phase)
+ EdkLogger.debug(EdkLogger.DEBUG_1, "GeneratedTokenNumber = %s" % str(GeneratedTokenNumber))
+
+ #
+ # following four Dict items hold the information for LocalTokenNumberTable
+ #
+ Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Init'
+ if Pcd.InitString == 'UNINIT':
+ Dict['TOKEN_INIT'][GeneratedTokenNumber] = 'Uninit'
+
+ Dict['TOKEN_CNAME'][GeneratedTokenNumber] = CName
+ Dict['TOKEN_GUID'][GeneratedTokenNumber] = TokenSpaceGuid
+ Dict['TOKEN_TYPE'][GeneratedTokenNumber] = ' | '.join(Pcd.TokenTypeList)
+
+ if Platform.Platform.PcdInfoFlag:
+ TokenSpaceGuidCNameArray = StringToArray('"' + TokenSpaceGuidCName + '"' )
+ if TokenSpaceGuidCNameArray not in Dict['PCD_TOKENSPACE']:
+ Dict['PCD_TOKENSPACE'].append(TokenSpaceGuidCNameArray)
+ Dict['PCD_TOKENSPACE_LENGTH'].append( len(TokenSpaceGuidCName) + 1 )
+ Dict['PCD_TOKENSPACE_MAP'][GeneratedTokenNumber] = Dict['PCD_TOKENSPACE'].index(TokenSpaceGuidCNameArray)
+ Dict['PCD_CNAME'][GeneratedTokenNumber] = StringToArray('"' + CName + '"' )
+
+ Dict['PCD_CNAME_LENGTH'][GeneratedTokenNumber] = len(CName) + 1
+
+
+ Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))
+
+ # search the Offset and Table, used by LocalTokenNumberTableOffset
+ if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
+ # Find index by CName, TokenSpaceGuid
+ Offset = GetMatchedIndex(CName, Dict['VARIABLE_HEAD_CNAME_DECL'], TokenSpaceGuid, Dict['VARIABLE_HEAD_GUID_DECL'])
+ assert(Offset != -1)
+ Table = Dict['VARIABLE_DB_VALUE']
+ if 'PCD_TYPE_VPD' in Pcd.TokenTypeList:
+ Offset = GetMatchedIndex(CName, Dict['VPD_HEAD_CNAME_DECL'], TokenSpaceGuid, Dict['VPD_HEAD_GUID_DECL'])
+ assert(Offset != -1)
+ Table = Dict['VPD_DB_VALUE']
+ if 'PCD_TYPE_STRING' in Pcd.TokenTypeList and 'PCD_TYPE_HII' not in Pcd.TokenTypeList:
+ # Find index by CName, TokenSpaceGuid
+ Offset = GetMatchedIndex(CName, Dict['STRING_HEAD_CNAME_DECL'], TokenSpaceGuid, Dict['STRING_HEAD_GUID_DECL'])
+ assert(Offset != -1)
+ Table = Dict['STRING_DB_VALUE']
+ if 'PCD_TYPE_DATA' in Pcd.TokenTypeList:
+ # need to store whether it is in init table or not
+ Offset = GetMatchedIndex(CName, Dict[Pcd.InitString+'_CNAME_DECL_'+Pcd.DatumType], TokenSpaceGuid, Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType])
+ assert(Offset != -1)
+ if Pcd.InitString == 'UNINIT':
+ Table = Dict[Pcd.InitString+'_GUID_DECL_'+Pcd.DatumType]
+ else:
+ Table = Dict[Pcd.InitString+'_DB_VALUE_'+Pcd.DatumType]
+ Dict['LOCAL_TOKEN_NUMBER_DB_VALUE'][GeneratedTokenNumber] = (Offset, Table)
+
+ #
+ # Update VARDEF_HEADER
+ #
+ if 'PCD_TYPE_HII' in Pcd.TokenTypeList:
+ Dict['VARDEF_HEADER'][GeneratedTokenNumber] = '_Variable_Header'
+ else:
+ Dict['VARDEF_HEADER'][GeneratedTokenNumber] = ''
+
+
+ if Pcd.Type in gDynamicExPcd:
+
+ if Phase == 'DXE':
+ GeneratedTokenNumber += NumberOfPeiLocalTokens
+ #
+ # Per, PCD architecture specification, PCD Token Number is 1 based and 0 is defined as invalid token number.
+ # For each EX type PCD, a PCD Token Number is assigned. When the
+ # PCD Driver/PEIM map EX_GUID and EX_TOKEN_NUMBER to the PCD Token Number,
+ # the non-EX Protocol/PPI interface can be called to get/set the value. This assumption is made by
+ # Pcd Driver/PEIM in MdeModulePkg.
+ # Therefore, 1 is added to GeneratedTokenNumber to generate a PCD Token Number before being inserted
+ # to the EXMAPPING_TABLE.
+ #
+
+
+ Dict['EXMAPPING_TABLE_EXTOKEN'].append(str(Pcd.TokenValue) + 'U')
+ Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append(str(GeneratedTokenNumber + 1) + 'U')
+ Dict['EXMAPPING_TABLE_GUID_INDEX'].append(str(GuidList.index(TokenSpaceGuid)) + 'U')
+
+ if Platform.Platform.PcdInfoFlag:
+ for index in range(len(Dict['PCD_TOKENSPACE_MAP'])):
+ TokenSpaceIndex = StringTableSize
+ for i in range(Dict['PCD_TOKENSPACE_MAP'][index]):
+ TokenSpaceIndex += Dict['PCD_TOKENSPACE_LENGTH'][i]
+ Dict['PCD_TOKENSPACE_OFFSET'].append(TokenSpaceIndex)
+ for index in range(len(Dict['PCD_TOKENSPACE'])):
+ StringTableSize += Dict['PCD_TOKENSPACE_LENGTH'][index]
+
+ for index in range(len(Dict['PCD_CNAME'])):
+ Dict['PCD_CNAME_OFFSET'].append(StringTableSize)
+ Dict['PCD_NAME_OFFSET'].append(Dict['PCD_TOKENSPACE_OFFSET'][index])
+ Dict['PCD_NAME_OFFSET'].append(StringTableSize)
+ StringTableSize += Dict['PCD_CNAME_LENGTH'][index]
+
+ if GuidList != []:
+ Dict['GUID_TABLE_EMPTY'] = 'FALSE'
+ Dict['GUID_TABLE_SIZE'] = str(len(GuidList)) + 'U'
+ else:
+ Dict['GUID_STRUCTURE'] = [GuidStringToGuidStructureString('00000000-0000-0000-0000-000000000000')]
+
+ if StringTableIndex == 0:
+ Dict['STRING_TABLE_INDEX'].append('')
+ Dict['STRING_TABLE_LENGTH'].append(1)
+ Dict['STRING_TABLE_CNAME'].append('')
+ Dict['STRING_TABLE_GUID'].append('')
+ Dict['STRING_TABLE_VALUE'].append('{ 0 }')
+ else:
+ Dict['STRING_TABLE_EMPTY'] = 'FALSE'
+ Dict['STRING_TABLE_SIZE'] = str(StringTableSize) + 'U'
+
+ if Dict['SIZE_TABLE_CNAME'] == []:
+ Dict['SIZE_TABLE_CNAME'].append('')
+ Dict['SIZE_TABLE_GUID'].append('')
+ Dict['SIZE_TABLE_CURRENT_LENGTH'].append('0U')
+ Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append('0U')
+
+ if NumberOfLocalTokens != 0:
+ Dict['DATABASE_EMPTY'] = 'FALSE'
+ Dict['LOCAL_TOKEN_NUMBER_TABLE_SIZE'] = NumberOfLocalTokens
+ Dict['LOCAL_TOKEN_NUMBER'] = NumberOfLocalTokens
+
+ if NumberOfExTokens != 0:
+ Dict['EXMAP_TABLE_EMPTY'] = 'FALSE'
+ Dict['EXMAPPING_TABLE_SIZE'] = str(NumberOfExTokens) + 'U'
+ Dict['EX_TOKEN_NUMBER'] = str(NumberOfExTokens) + 'U'
+ else:
+ Dict['EXMAPPING_TABLE_EXTOKEN'].append('0U')
+ Dict['EXMAPPING_TABLE_LOCAL_TOKEN'].append('0U')
+ Dict['EXMAPPING_TABLE_GUID_INDEX'].append('0U')
+
+ if NumberOfSizeItems != 0:
+ Dict['SIZE_TABLE_SIZE'] = str(NumberOfSizeItems * 2) + 'U'
+
+ if NumberOfSkuEnabledPcd != 0:
+ Dict['SKU_HEAD_SIZE'] = str(NumberOfSkuEnabledPcd) + 'U'
+
+ Dict['SKUID_VALUE'][0] = len(Dict['SKUID_VALUE'])
+
+ AutoGenH.Append(gPcdDatabaseAutoGenH.Replace(Dict))
+ if NumberOfLocalTokens == 0:
+ AutoGenC.Append(gEmptyPcdDatabaseAutoGenC.Replace(Dict))
+ else:
+ #
+ # Update Size Table to the right order, it should be same with LocalTokenNumberTable
+ #
+ SizeCNameTempList = []
+ SizeGuidTempList = []
+ SizeCurLenTempList = []
+ SizeMaxLenTempList = []
+ ReOrderFlag = True
+
+ if len(Dict['SIZE_TABLE_CNAME']) == 1:
+ if not (Dict['SIZE_TABLE_CNAME'][0] and Dict['SIZE_TABLE_GUID'][0]):
+ ReOrderFlag = False
+
+ if ReOrderFlag:
+ for Count in range(len(Dict['TOKEN_CNAME'])):
+ for Count1 in range(len(Dict['SIZE_TABLE_CNAME'])):
+ if Dict['TOKEN_CNAME'][Count] == Dict['SIZE_TABLE_CNAME'][Count1] and \
+ Dict['TOKEN_GUID'][Count] == Dict['SIZE_TABLE_GUID'][Count1]:
+ SizeCNameTempList.append(Dict['SIZE_TABLE_CNAME'][Count1])
+ SizeGuidTempList.append(Dict['SIZE_TABLE_GUID'][Count1])
+ SizeCurLenTempList.append(Dict['SIZE_TABLE_CURRENT_LENGTH'][Count1])
+ SizeMaxLenTempList.append(Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count1])
+
+ for Count in range(len(Dict['SIZE_TABLE_CNAME'])):
+ Dict['SIZE_TABLE_CNAME'][Count] = SizeCNameTempList[Count]
+ Dict['SIZE_TABLE_GUID'][Count] = SizeGuidTempList[Count]
+ Dict['SIZE_TABLE_CURRENT_LENGTH'][Count] = SizeCurLenTempList[Count]
+ Dict['SIZE_TABLE_MAXIMUM_LENGTH'][Count] = SizeMaxLenTempList[Count]
+
+ AutoGenC.Append(gPcdDatabaseAutoGenC.Replace(Dict))
+
+ Buffer = BuildExDataBase(Dict)
+ return AutoGenH, AutoGenC, Buffer
+
diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py
index cc4985062e..3564571787 100644
--- a/BaseTools/Source/Python/BPDG/GenVpd.py
+++ b/BaseTools/Source/Python/BPDG/GenVpd.py
@@ -34,9 +34,10 @@ _FORMAT_CHAR = {1: 'B',
# This class contain method to format and pack pcd's value.
#
class PcdEntry:
- def __init__(self, PcdCName, PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None,
+ def __init__(self, PcdCName, SkuId,PcdOffset, PcdSize, PcdValue, Lineno=None, FileName=None, PcdUnpackValue=None,
PcdBinOffset=None, PcdBinSize=None):
self.PcdCName = PcdCName.strip()
+ self.SkuId = SkuId.strip()
self.PcdOffset = PcdOffset.strip()
self.PcdSize = PcdSize.strip()
self.PcdValue = PcdValue.strip()
@@ -284,7 +285,7 @@ class PcdEntry:
"Invalid unicode character %s in unicode string %s(File: %s Line: %s)" % \
(Value, UnicodeString, self.FileName, self.Lineno))
- for Index in range(len(UnicodeString) * 2, Size):
+ for Index in xrange(len(UnicodeString) * 2, Size):
ReturnArray.append(0)
self.PcdValue = ReturnArray.tolist()
@@ -343,7 +344,7 @@ class GenVPD :
#
# Enhanced for support "|" character in the string.
#
- ValueList = ['', '', '', '']
+ ValueList = ['', '', '', '','']
ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
PtrValue = ValueRe.findall(line)
@@ -358,7 +359,7 @@ class GenVPD :
ValueList[0:len(TokenList)] = TokenList
if ValueUpdateFlag:
- ValueList[3] = PtrValue[0]
+ ValueList[4] = PtrValue[0]
self.FileLinesList[count] = ValueList
# Store the line number
self.FileLinesList[count].append(str(count+1))
@@ -393,9 +394,10 @@ class GenVPD :
count = 0
for line in self.FileLinesList:
if line != None :
- PCD = PcdEntry(line[0], line[1], line[2], line[3], line[4], self.InputFileName)
+ PCD = PcdEntry(line[0], line[1], line[2], line[3], line[4],line[5], self.InputFileName)
# Strip the space char
PCD.PcdCName = PCD.PcdCName.strip(' ')
+ PCD.SkuId = PCD.SkuId.strip(' ')
PCD.PcdOffset = PCD.PcdOffset.strip(' ')
PCD.PcdSize = PCD.PcdSize.strip(' ')
PCD.PcdValue = PCD.PcdValue.strip(' ')
@@ -639,7 +641,7 @@ class GenVPD :
for eachPcd in self.PcdFixedOffsetSizeList :
# write map file
try :
- fMapFile.write("%s | %s | %s | %s \n" % (eachPcd.PcdCName, eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))
+ fMapFile.write("%s | %s | %s | %s | %s \n" % (eachPcd.PcdCName, eachPcd.SkuId,eachPcd.PcdOffset, eachPcd.PcdSize,eachPcd.PcdUnpackValue))
except:
EdkLogger.error("BPDG", BuildToolError.FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %self.MapFileName,None)
diff --git a/BaseTools/Source/Python/Common/BuildVersion.py b/BaseTools/Source/Python/Common/BuildVersion.py
index 25546cdfe9..2a3b0aa681 100644
--- a/BaseTools/Source/Python/Common/BuildVersion.py
+++ b/BaseTools/Source/Python/Common/BuildVersion.py
@@ -13,4 +13,4 @@
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
-gBUILD_VERSION = "Build 2601"
+gBUILD_VERSION = "Build 2610"
diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index 3a82362100..dbe7215f40 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -397,6 +397,7 @@ TAB_DSC_DEFINES_OUTPUT_DIRECTORY = 'OUTPUT_DIRECTORY'
TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES = 'SUPPORTED_ARCHITECTURES'
TAB_DSC_DEFINES_BUILD_TARGETS = 'BUILD_TARGETS'
TAB_DSC_DEFINES_SKUID_IDENTIFIER = 'SKUID_IDENTIFIER'
+TAB_DSC_DEFINES_PCD_INFO_GENERATION = 'PCD_INFO_GENERATION'
TAB_DSC_DEFINES_FLASH_DEFINITION = 'FLASH_DEFINITION'
TAB_DSC_DEFINES_BUILD_NUMBER = 'BUILD_NUMBER'
TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME'
diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/Python/Common/GlobalData.py
index d566a57844..4fbe721823 100644
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -50,3 +50,22 @@ gWideStringPattern = re.compile('(\W|\A)L"')
#
gAutoGenPhase = False
+#
+# The Conf dir outside the workspace dir
+#
+gConfDirectory = ''
+
+#
+# The relative default database file path
+#
+gDatabasePath = ".cache/build.db"
+
+#
+# Build flag for binary build
+#
+gIgnoreSource = False
+
+#
+# FDF parser
+#
+gFdfParser = None
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index afdfb93ad6..960581581a 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -31,6 +31,7 @@ from Common import GlobalData as GlobalData
from DataType import *
from BuildToolError import *
from CommonDataClass.DataClass import *
+from Parsing import GetSplitValueList
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE)
@@ -1248,8 +1249,13 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
Size = Type = ''
if len(FieldList) > 1:
Type = FieldList[1]
+ else:
+ Type = DataType
if len(FieldList) > 2:
Size = FieldList[2]
+ else:
+ if Type == 'VOID*':
+ Size = str(len(Value))
if DataType == 'VOID*':
IsValid = (len(FieldList) <= 3)
else:
@@ -1322,25 +1328,13 @@ def AnalyzePcdData(Setting):
#
# @retval ValueList: A List contaian VariableName, VariableGuid, VariableOffset, DefaultValue.
#
-def AnalyzeHiiPcdData(Setting):
- ValueList = ['', '', '', '']
-
- ValueRe = re.compile(r'^\s*L?\".*\|.*\"')
- PtrValue = ValueRe.findall(Setting)
-
- ValueUpdateFlag = False
-
- if len(PtrValue) >= 1:
- Setting = re.sub(ValueRe, '', Setting)
- ValueUpdateFlag = True
+def AnalyzeHiiPcdData(Setting):
+ ValueList = ['', '', '', '']
- TokenList = Setting.split(TAB_VALUE_SPLIT)
+ TokenList = GetSplitValueList(Setting)
ValueList[0:len(TokenList)] = TokenList
-
- if ValueUpdateFlag:
- ValueList[0] = PtrValue[0]
-
- return ValueList
+
+ return ValueList
## AnalyzeVpdPcdData
#
@@ -1679,7 +1673,60 @@ class PeImageClass():
for index in range(len(ByteList) - 1, -1, -1):
Value = (Value << 8) | int(ByteList[index])
return Value
+
+
+class SkuClass():
+
+ DEFAULT = 0
+ SINGLE = 1
+ MULTIPLE =2
+
+ def __init__(self,SkuIdentifier='', SkuIds={}):
+
+ self.AvailableSkuIds = sdict()
+ self.SkuIdSet = []
+
+ if SkuIdentifier == '' or SkuIdentifier is None:
+ self.SkuIdSet = ['DEFAULT']
+ elif SkuIdentifier == 'ALL':
+ self.SkuIdSet = SkuIds.keys()
+ else:
+ r = SkuIdentifier.split('|')
+ self.SkuIdSet=[r[k].strip() for k in range(len(r))]
+ if len(self.SkuIdSet) == 2 and 'DEFAULT' in self.SkuIdSet and SkuIdentifier != 'ALL':
+ self.SkuIdSet.remove('DEFAULT')
+
+ for each in self.SkuIdSet:
+ if each in SkuIds:
+ self.AvailableSkuIds[each] = SkuIds[each]
+ else:
+ EdkLogger.error("build", PARAMETER_INVALID,
+ ExtraData="SKU-ID [%s] is not supported by the platform. [Valid SKU-ID: %s]"
+ % (each, " ".join(SkuIds.keys())))
+ def __SkuUsageType(self):
+
+ if len(self.SkuIdSet) == 1:
+ if self.SkuIdSet[0] == 'DEFAULT':
+ return SkuClass.DEFAULT
+ else:
+ return SkuClass.SINGLE
+ else:
+ return SkuClass.MULTIPLE
+
+ def __GetAvailableSkuIds(self):
+ return self.AvailableSkuIds
+
+ def __GetSystemSkuID(self):
+ if self.__SkuUsageType() == SkuClass.SINGLE:
+ return self.SkuIdSet[0]
+ else:
+ return 'DEFAULT'
+
+ SystemSkuId = property(__GetSystemSkuID)
+ AvailableSkuIdSet = property(__GetAvailableSkuIds)
+ SkuUsageType = property(__SkuUsageType)
+
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 207cc8735b..18f6f5663c 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -138,12 +138,14 @@ class VpdInfoFile:
Pcds = self._VpdArray.keys()
Pcds.sort()
for Pcd in Pcds:
+ i = 0
for Offset in self._VpdArray[Pcd]:
- PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue).strip()
+ PcdValue = str(Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[i]].DefaultValue).strip()
if PcdValue == "" :
PcdValue = Pcd.DefaultValue
- fd.write("%s.%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue))
+ fd.write("%s.%s|%s|%s|%s|%s \n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, str(Pcd.SkuInfoList.keys()[i]),str(Offset).strip(), str(Pcd.MaxDatumSize).strip(),PcdValue))
+ i += 1
except:
EdkLogger.error("VpdInfoFile",
BuildToolError.FILE_WRITE_FAILURE,
@@ -174,21 +176,22 @@ class VpdInfoFile:
# the line must follow output format defined in BPDG spec.
#
try:
- PcdName, Offset, Size, Value = Line.split("#")[0].split("|")
+ PcdName, SkuId,Offset, Size, Value = Line.split("#")[0].split("|")
+ PcdName, SkuId,Offset, Size, Value = PcdName.strip(), SkuId.strip(),Offset.strip(), Size.strip(), Value.strip()
TokenSpaceName, PcdTokenName = PcdName.split(".")
except:
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Fail to parse VPD information file %s" % FilePath)
Found = False
+
for VpdObject in self._VpdArray.keys():
- if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip():
- if self._VpdArray[VpdObject][0] == "*":
- if Offset == "*":
- EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
-
- self._VpdArray[VpdObject][0] = Offset
- Found = True
- break
+ for sku in VpdObject.SkuInfoList.keys():
+ if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObject.TokenCName == PcdTokenName.strip() and sku == SkuId:
+ if self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] == "*":
+ if Offset == "*":
+ EdkLogger.error("BPDG", BuildToolError.FORMAT_INVALID, "The offset of %s has not been fixed up by third-party BPDG tool." % PcdName)
+ self._VpdArray[VpdObject][VpdObject.SkuInfoList.keys().index(sku)] = Offset
+ Found = True
if not Found:
EdkLogger.error("BPDG", BuildToolError.PARSER_ERROR, "Can not find PCD defined in VPD guid file.")
diff --git a/BaseTools/Source/Python/CommonDataClass/DataClass.py b/BaseTools/Source/Python/CommonDataClass/DataClass.py
index 3d971c84cd..c69152b9b4 100644
--- a/BaseTools/Source/Python/CommonDataClass/DataClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/DataClass.py
@@ -77,6 +77,7 @@ MODEL_PCD_DYNAMIC_DEFAULT = 4009
MODEL_PCD_DYNAMIC_VPD = 4010
MODEL_PCD_DYNAMIC_HII = 4011
+MODEL_META_DATA_HEADER_COMMENT = 5000
MODEL_META_DATA_HEADER = 5001
MODEL_META_DATA_INCLUDE = 5002
MODEL_META_DATA_DEFINE = 5003
diff --git a/BaseTools/Source/Python/CommonDataClass/FdfClass.py b/BaseTools/Source/Python/CommonDataClass/FdfClass.py
index 996468d6aa..ce3df12058 100644
--- a/BaseTools/Source/Python/CommonDataClass/FdfClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/FdfClass.py
@@ -1,7 +1,7 @@
## @file
# classes represent data in FDF
#
-# 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
@@ -27,7 +27,7 @@ class FDClassObject:
self.BaseAddressPcd = None
self.Size = None
self.SizePcd = None
- self.ErasePolarity = '1'
+ self.ErasePolarity = None
# 3-tuple list (blockSize, numBlocks, pcd)
self.BlockSizeList = []
# DefineVarDict[var] = value
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
index d10265e973..98a899e76b 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
@@ -719,6 +719,7 @@ class DscParser(MetaFileParser):
"PLATFORM_GUID",
"PLATFORM_VERSION",
"SKUID_IDENTIFIER",
+ "PCD_INFO_GENERATION",
"SUPPORTED_ARCHITECTURES",
"BUILD_TARGETS",
"OUTPUT_DIRECTORY",
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index a468a5ec99..661e16ae40 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1,7 +1,7 @@
## @file
# parse FDF 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
@@ -1423,7 +1423,15 @@ class FdfParser:
if not Status:
raise Warning("FD name error", self.FileName, self.CurrentLineNumber)
- self.__GetTokenStatements(FdObj)
+ while self.__GetTokenStatements(FdObj):
+ pass
+ for Attr in ("BaseAddress", "Size", "ErasePolarity"):
+ if getattr(FdObj, Attr) == None:
+ self.__GetNextToken()
+ raise Warning("Keyword %s missing" % Attr, self.FileName, self.CurrentLineNumber)
+
+ if not FdObj.BlockSizeList:
+ FdObj.BlockSizeList.append((1, FdObj.Size, None))
self.__GetDefineStatements(FdObj)
@@ -1480,58 +1488,54 @@ class FdfParser:
# @param Obj for whom token statement is got
#
def __GetTokenStatements(self, Obj):
- if not self.__IsKeyword( "BaseAddress"):
- raise Warning("BaseAddress missing", self.FileName, self.CurrentLineNumber)
-
- if not self.__IsToken( "="):
- raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
-
- if not self.__GetNextHexNumber():
- raise Warning("expected Hex base address", self.FileName, self.CurrentLineNumber)
-
- Obj.BaseAddress = self.__Token
-
- if self.__IsToken( "|"):
- pcdPair = self.__GetNextPcdName()
- Obj.BaseAddressPcd = pcdPair
- self.Profile.PcdDict[pcdPair] = Obj.BaseAddress
- FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
-
- if not self.__IsKeyword( "Size"):
- raise Warning("Size missing", self.FileName, self.CurrentLineNumber)
-
- if not self.__IsToken( "="):
- raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
-
- if not self.__GetNextHexNumber():
- raise Warning("expected Hex size", self.FileName, self.CurrentLineNumber)
-
-
- Size = self.__Token
- if self.__IsToken( "|"):
- pcdPair = self.__GetNextPcdName()
- Obj.SizePcd = pcdPair
- self.Profile.PcdDict[pcdPair] = Size
- FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
- self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
- Obj.Size = long(Size, 0)
-
- if not self.__IsKeyword( "ErasePolarity"):
- raise Warning("ErasePolarity missing", self.FileName, self.CurrentLineNumber)
-
- if not self.__IsToken( "="):
- raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+ if self.__IsKeyword( "BaseAddress"):
+ if not self.__IsToken( "="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextHexNumber():
+ raise Warning("expected Hex base address", self.FileName, self.CurrentLineNumber)
+
+ Obj.BaseAddress = self.__Token
+
+ if self.__IsToken( "|"):
+ pcdPair = self.__GetNextPcdName()
+ Obj.BaseAddressPcd = pcdPair
+ self.Profile.PcdDict[pcdPair] = Obj.BaseAddress
+ FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
+ self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
+ return True
- if not self.__GetNextToken():
- raise Warning("expected Erase Polarity", self.FileName, self.CurrentLineNumber)
+ if self.__IsKeyword( "Size"):
+ if not self.__IsToken( "="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextHexNumber():
+ raise Warning("expected Hex size", self.FileName, self.CurrentLineNumber)
- if self.__Token != "1" and self.__Token != "0":
- raise Warning("expected 1 or 0 Erase Polarity", self.FileName, self.CurrentLineNumber)
+ Size = self.__Token
+ if self.__IsToken( "|"):
+ pcdPair = self.__GetNextPcdName()
+ Obj.SizePcd = pcdPair
+ self.Profile.PcdDict[pcdPair] = Size
+ FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
+ self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple
+ Obj.Size = long(Size, 0)
+ return True
- Obj.ErasePolarity = self.__Token
+ if self.__IsKeyword( "ErasePolarity"):
+ if not self.__IsToken( "="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextToken():
+ raise Warning("expected Erase Polarity", self.FileName, self.CurrentLineNumber)
+
+ if self.__Token != "1" and self.__Token != "0":
+ raise Warning("expected 1 or 0 Erase Polarity", self.FileName, self.CurrentLineNumber)
+
+ Obj.ErasePolarity = self.__Token
+ return True
- self.__GetBlockStatements(Obj)
+ return self.__GetBlockStatements(Obj)
## __GetAddressStatements() method
#
@@ -1572,18 +1576,14 @@ class FdfParser:
# @param Obj for whom block statement is got
#
def __GetBlockStatements(self, Obj):
-
- if not self.__GetBlockStatement(Obj):
- #set default block size is 1
- Obj.BlockSizeList.append((1, Obj.Size, None))
- return
-
+ IsBlock = False
while self.__GetBlockStatement(Obj):
- pass
+ IsBlock = True
- for Item in Obj.BlockSizeList:
+ Item = Obj.BlockSizeList[-1]
if Item[0] == None or Item[1] == None:
raise Warning("expected block statement", self.FileName, self.CurrentLineNumber)
+ return IsBlock
## __GetBlockStatement() method
#
@@ -2038,27 +2038,16 @@ class FdfParser:
self.__GetAddressStatements(FvObj)
- while self.__GetBlockStatement(FvObj):
- pass
-
- self.__GetSetStatements(FvObj)
-
- self.__GetFvBaseAddress(FvObj)
-
- self.__GetFvForceRebase(FvObj)
-
- self.__GetFvAlignment(FvObj)
-
- self.__GetFvAttributes(FvObj)
-
- self.__GetFvNameGuid(FvObj)
-
FvObj.FvExtEntryTypeValue = []
FvObj.FvExtEntryType = []
FvObj.FvExtEntryData = []
while True:
- isFvExtEntry = self.__GetFvExtEntryStatement(FvObj)
- if not isFvExtEntry:
+ self.__GetSetStatements(FvObj)
+
+ if not (self.__GetBlockStatement(FvObj) or self.__GetFvBaseAddress(FvObj) or
+ self.__GetFvForceRebase(FvObj) or self.__GetFvAlignment(FvObj) or
+ self.__GetFvAttributes(FvObj) or self.__GetFvNameGuid(FvObj) or
+ self.__GetFvExtEntryStatement(FvObj)):
break
self.__GetAprioriSection(FvObj, FvObj.DefineVarDict.copy())
@@ -2177,9 +2166,9 @@ class FdfParser:
"WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENABLED_CAP", \
"READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_CAP", \
"READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LOCK_STATUS", \
- "WRITE_POLICY_RELIABLE"):
+ "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"):
self.__UndoToken()
- return
+ return False
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -2189,7 +2178,7 @@ class FdfParser:
FvObj.FvAttributeDict[name] = self.__Token
- return
+ return True
## __GetFvNameGuid() method
#
@@ -2202,7 +2191,7 @@ class FdfParser:
def __GetFvNameGuid(self, FvObj):
if not self.__IsKeyword( "FvNameGuid"):
- return
+ return False
if not self.__IsToken( "="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -2212,7 +2201,7 @@ class FdfParser:
FvObj.FvNameGuid = self.__Token
- return
+ return True
def __GetFvExtEntryStatement(self, FvObj):
@@ -3058,7 +3047,7 @@ class FdfParser:
def __GetCapsuleTokens(self, Obj):
if not self.__GetNextToken():
return False
- while self.__Token in ("CAPSULE_GUID", "CAPSULE_HEADER_SIZE", "CAPSULE_FLAGS"):
+ while self.__Token in ("CAPSULE_GUID", "CAPSULE_HEADER_SIZE", "CAPSULE_FLAGS", "OEM_CAPSULE_FLAGS"):
Name = self.__Token.strip()
if not self.__IsToken("="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
@@ -3075,6 +3064,15 @@ class FdfParser:
if not self.__Token in ("PersistAcrossReset", "PopulateSystemTable", "InitiateReset"):
raise Warning("expected PersistAcrossReset, PopulateSystemTable, or InitiateReset", self.FileName, self.CurrentLineNumber)
Value += self.__Token.strip()
+ elif Name == 'OEM_CAPSULE_FLAGS':
+ Value = self.__Token.strip()
+ try:
+ Value = int(Value, 0)
+ except ValueError:
+ raise Warning("expected integer value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
+ if not 0x0000 <= Value <= 0xFFFF:
+ raise Warning("expected integer value between 0x0000 and 0xFFFF", self.FileName, self.CurrentLineNumber)
+ Value = self.__Token.strip()
else:
Value = self.__Token.strip()
Obj.TokensDict[Name] = Value
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 71acd2992c..3d16398c32 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -37,6 +37,7 @@ from GuidSection import GuidSection
from FvImageSection import FvImageSection
from Common.Misc import PeImageClass
from AutoGen.GenDepex import DependencyExpression
+from PatchPcdValue.PatchPcdValue import PatchBinaryFile
## generate FFS from INF
#
@@ -203,14 +204,80 @@ class FfsInfStatement(FfsInfStatementClassObject):
if Inf._Defs != None and len(Inf._Defs) > 0:
self.OptRomDefs.update(Inf._Defs)
-
+ self.PatchPcds = []
+ InfPcds = Inf.Pcds
+ Platform = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
+ FdfPcdDict = GenFdsGlobalVariable.FdfParser.Profile.PcdDict
+ DscModules = {}
+ for DscModule in Platform.Modules:
+ DscModules[str(DscModule).lower()] = Platform.Modules[DscModule]
+ for PcdKey in InfPcds:
+ Pcd = InfPcds[PcdKey]
+ if not hasattr(Pcd, 'Offset'):
+ continue
+ if Pcd.Type != 'PatchableInModule':
+ continue
+ PatchPcd = None
+ InfLowerPath = str(PathClassObj).lower()
+ if InfLowerPath in DscModules and PcdKey in DscModules[InfLowerPath].Pcds:
+ PatchPcd = DscModules[InfLowerPath].Pcds[PcdKey]
+ elif PcdKey in Platform.Pcds:
+ PatchPcd = Platform.Pcds[PcdKey]
+ DscOverride = False
+ if PatchPcd and Pcd.Type == PatchPcd.Type:
+ DefaultValue = PatchPcd.DefaultValue
+ DscOverride = True
+ FdfOverride = False
+ if PcdKey in FdfPcdDict:
+ DefaultValue = FdfPcdDict[PcdKey]
+ FdfOverride = True
+ if not DscOverride and not FdfOverride:
+ continue
+ if Pcd.DatumType == "VOID*":
+ if Pcd.DefaultValue == DefaultValue or DefaultValue in [None, '']:
+ continue
+ if DefaultValue[0] == 'L':
+ MaxDatumSize = str((len(DefaultValue) - 2) * 2)
+ elif DefaultValue[0] == '{':
+ MaxDatumSize = str(len(DefaultValue.split(',')))
+ else:
+ MaxDatumSize = str(len(DefaultValue) - 1)
+ if DscOverride:
+ Pcd.MaxDatumSize = PatchPcd.MaxDatumSize
+ if Pcd.MaxDatumSize in ['', None]:
+ Pcd.MaxDatumSize = str(len(Pcd.DefaultValue.split(',')))
+ else:
+ Base1 = Base2 = 10
+ if Pcd.DefaultValue.upper().startswith('0X'):
+ Base1 = 16
+ if DefaultValue.upper().startswith('0X'):
+ Base2 = 16
+ try:
+ PcdValueInImg = int(Pcd.DefaultValue, Base1)
+ PcdValueInDscOrFdf = int(DefaultValue, Base2)
+ if PcdValueInImg == PcdValueInDscOrFdf:
+ continue
+ except:
+ continue
+ if Pcd.DatumType == "VOID*":
+ if int(MaxDatumSize) > int(Pcd.MaxDatumSize):
+ EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \
+ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize)))
+ else:
+ if PcdValueInDscOrFdf > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType] \
+ or PcdValueInImg > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType]:
+ EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %s type PCD '%s.%s' doesn't match its data type." \
+ % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))
+ Pcd.DefaultValue = DefaultValue
+ self.PatchPcds.append(Pcd)
self.InfModule = Inf
-
- GenFdsGlobalVariable.VerboseLogger( "BaseName : %s" %self.BaseName)
- GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" %self.ModuleGuid)
- GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" %self.ModuleType)
- GenFdsGlobalVariable.VerboseLogger("VersionString : %s" %self.VersionString)
- GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" %self.InfFileName)
+ self.PcdIsDriver = Inf.PcdIsDriver
+ self.IsBinaryModule = Inf.IsBinaryModule
+ GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName)
+ GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" % self.ModuleGuid)
+ GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" % self.ModuleType)
+ GenFdsGlobalVariable.VerboseLogger("VersionString : %s" % self.VersionString)
+ GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" % self.InfFileName)
#
# Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\
@@ -224,6 +291,27 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.EfiOutputPath = self.__GetEFIOutPutPath__()
GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)
+## PatchEfiFile
+ #
+ # Patch EFI file with patch PCD
+ #
+ # @param EfiFile: EFI file needs to be patched.
+ # @retval: Full path of patched EFI file: self.OutputPath + EfiFile base name
+ # If passed in file does not end with efi, return as is
+ #
+ def PatchEfiFile(self, EfiFile):
+ if os.path.splitext(EfiFile)[1].lower() != '.efi':
+ return EfiFile
+ if not self.PatchPcds:
+ return EfiFile
+ Basename = os.path.basename(EfiFile)
+ Output = os.path.join(self.OutputPath, Basename)
+ CopyLongFilePath(EfiFile, Output)
+ for Pcd in self.PatchPcds:
+ RetVal, RetStr = PatchBinaryFile(Output, int(Pcd.Offset, 0), Pcd.DatumType, Pcd.DefaultValue, Pcd.MaxDatumSize)
+ if RetVal:
+ EdkLogger.error("GenFds", GENFDS_ERROR, RetStr, File=self.InfFileName)
+ return Output
## GenFfs() method
#
# Generate FFS
@@ -668,6 +756,30 @@ class FfsInfStatement(FfsInfStatementClassObject):
SectAlignments = []
Index = 1
HasGneratedFlag = False
+ if self.PcdIsDriver == 'PEI_PCD_DRIVER':
+ if self.IsBinaryModule:
+ PcdExDbFileName = os.path.join(GenFdsGlobalVariable.FvDir, "PEIPcdDataBase.raw")
+ else:
+ PcdExDbFileName = os.path.join(self.EfiOutputPath, "PEIPcdDataBase.raw")
+ PcdExDbSecName = os.path.join(self.OutputPath, "PEIPcdDataBaseSec.raw")
+ GenFdsGlobalVariable.GenerateSection(PcdExDbSecName,
+ [PcdExDbFileName],
+ "EFI_SECTION_RAW",
+ )
+ SectFiles.append(PcdExDbSecName)
+ SectAlignments.append(None)
+ elif self.PcdIsDriver == 'DXE_PCD_DRIVER':
+ if self.IsBinaryModule:
+ PcdExDbFileName = os.path.join(GenFdsGlobalVariable.FvDir, "DXEPcdDataBase.raw")
+ else:
+ PcdExDbFileName = os.path.join(self.EfiOutputPath, "DXEPcdDataBase.raw")
+ PcdExDbSecName = os.path.join(self.OutputPath, "DXEPcdDataBaseSec.raw")
+ GenFdsGlobalVariable.GenerateSection(PcdExDbSecName,
+ [PcdExDbFileName],
+ "EFI_SECTION_RAW",
+ )
+ SectFiles.append(PcdExDbSecName)
+ SectAlignments.append(None)
for Sect in Rule.SectionList:
SecIndex = '%d' %Index
SectList = []
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py
index 6f57ad5681..819bb51a78 100644
--- a/BaseTools/Source/Python/GenFds/Section.py
+++ b/BaseTools/Source/Python/GenFds/Section.py
@@ -131,7 +131,7 @@ class Section (SectionClassObject):
if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'):
if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
- FileList.append(File.Path)
+ FileList.append(FfsInf.PatchEfiFile(File.Path))
else:
GenFdsGlobalVariable.InfLogger ("\nBuild Target \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %(File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName))
else:
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index ca4440f9a2..6deb0f8471 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -5,7 +5,7 @@
# PCD Name Offset in binary
# ======== ================
#
-# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 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
@@ -54,39 +54,54 @@ def parsePcdInfoFromMapFile(mapfilepath, efifilepath):
if len(lines) == 0: return None
if lines[0].strip().find("Archive member included because of file (symbol)") != -1:
- return _parseForGCC(lines)
+ return _parseForGCC(lines, efifilepath)
return _parseGeneral(lines, efifilepath)
-
-def _parseForGCC(lines):
+
+def _parseForGCC(lines, efifilepath):
""" Parse map file generated by GCC linker """
- status = 0
- imageBase = -1
- lastSectionName = None
- pcds = []
+ status = 0
+ imageBase = -1
+ sections = []
+ bpcds = []
for line in lines:
line = line.strip()
# status machine transection
- if status == 0 and line == "Linker script and memory map":
+ if status == 0 and line == "Memory Configuration":
status = 1
continue
- elif status == 1 and line == 'START GROUP':
+ elif status == 1 and line == 'Linker script and memory map':
status = 2
continue
-
- # status handler:
- if status == 1:
- m = re.match('^[\da-fA-FxhH]+ +__image_base__ += +([\da-fA-FhxH]+)', line)
- if m != None:
- imageBase = int(m.groups(0)[0], 16)
+ elif status ==2 and line == 'START GROUP':
+ status = 3
+ continue
+
+ # status handler
if status == 2:
- m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)', line)
+ m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)
if m != None:
- lastSectionName = m.groups(0)[0]
+ sections.append(m.groups(0))
if status == 2:
- m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)", line)
+ m = re.match("^([\da-fA-Fx]+) +[_]+gPcd_BinaryPatch_([\w_\d]+)$", line)
if m != None:
- assert imageBase != -1, "Fail to get Binary PCD offsest for unknown image base address"
- pcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) - imageBase, lastSectionName))
+ bpcds.append((m.groups(0)[1], int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))
+
+ # get section information from efi file
+ efisecs = PeImageClass(efifilepath).SectionHeaderList
+ if efisecs == None or len(efisecs) == 0:
+ return None
+ #redirection
+ redirection = 0
+ for efisec in efisecs:
+ for section in sections:
+ if section[0].strip() == efisec[0].strip() and section[0].strip() == '.text':
+ redirection = int(section[1], 16) - efisec[1]
+ pcds = []
+ for pcd in bpcds:
+ for efisec in efisecs:
+ if pcd[1] >= efisec[1] and pcd[1] < efisec[1]+efisec[3]:
+ #assert efisec[0].strip() == pcd[3].strip() and efisec[1] + redirection == pcd[2], "There are some differences between map file and efi file"
+ pcds.append([pcd[0], efisec[2] + pcd[1] - efisec[1] - redirection, efisec[0]])
return pcds
def _parseGeneral(lines, efifilepath):
diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
index 3f6c575128..69c8244790 100644
--- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
+++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
@@ -72,7 +72,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
elif TypeName == 'VOID*':
if MaxSize == 0:
return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD."
- ValueLength = MaxSize
+ ValueLength = int(MaxSize)
else:
return PARAMETER_INVALID, "PCD type %s is not valid." %(CommandOptions.PcdTypeName)
#
@@ -97,6 +97,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
#
# Patch value into offset
#
+ SavedStr = ValueString
ValueString = ValueString.upper()
ValueNumber = 0
if TypeName == 'BOOLEAN':
@@ -109,9 +110,9 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
elif ValueString == 'FALSE':
ValueNumber = 0
elif ValueString.startswith('0X'):
- ValueNumber = int (Value, 16)
+ ValueNumber = int (ValueString, 16)
else:
- ValueNumber = int (Value)
+ ValueNumber = int (ValueString)
if ValueNumber != 0:
ValueNumber = 1
except:
@@ -138,12 +139,13 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
ByteList[ValueOffset + Index] = ValueNumber % 0x100
ValueNumber = ValueNumber / 0x100
elif TypeName == 'VOID*':
- if ValueString.startswith("L "):
+ ValueString = SavedStr
+ if ValueString.startswith('L"'):
#
# Patch Unicode String
#
Index = 0
- for ByteString in ValueString[2:]:
+ for ByteString in ValueString[2:-1]:
#
# Reserve zero as unicode tail
#
@@ -177,7 +179,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
# Patch ascii string
#
Index = 0
- for ByteString in ValueString:
+ for ByteString in ValueString[1:-1]:
#
# Reserve zero as string tail
#
diff --git a/BaseTools/Source/Python/UPT/BuildVersion.py b/BaseTools/Source/Python/UPT/BuildVersion.py
index fa6c26aa76..2858e32c0d 100644
--- a/BaseTools/Source/Python/UPT/BuildVersion.py
+++ b/BaseTools/Source/Python/UPT/BuildVersion.py
@@ -17,4 +17,4 @@
Build version information
'''
-gBUILD_VERSION = "Build 2601"
+gBUILD_VERSION = "Build 2610"
diff --git a/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py b/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py
new file mode 100644
index 0000000000..ee6f5ac2b8
--- /dev/null
+++ b/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py
@@ -0,0 +1,28 @@
+## @file
+# This file is used to check format of comments
+#
+# Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+from CommonDataClass.DataClass import (
+ MODEL_PCD_PATCHABLE_IN_MODULE,
+ MODEL_PCD_DYNAMIC_EX,
+ MODEL_PCD_DYNAMIC,
+ MODEL_EFI_GUID,
+ MODEL_EFI_PPI,
+ MODEL_EFI_PROTOCOL
+)
+from Common.BuildToolError import FORMAT_INVALID
+import Common.EdkLogger as EdkLogger
+
+UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES",
+ "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED",
+ "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES")
+
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index 34000b5e88..2419d270ac 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -287,7 +287,7 @@ class MetaFileParser(object):
if self._SectionName in self.DataType:
self._SectionType = self.DataType[self._SectionName]
# Check if the section name is valid
- if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 2:
+ if self._SectionName not in SECTIONS_HAVE_ITEM_AFTER_ARCH and len(ItemList) > 3:
EdkLogger.error("Parser", FORMAT_UNKNOWN_ERROR, "%s is not a valid section name" % Item,
self.MetaFile, self._LineIndex + 1, self._CurrentLine)
elif self._Version >= 0x00010005:
@@ -495,14 +495,18 @@ class InfParser(MetaFileParser):
# parse the file line by line
IsFindBlockComment = False
+ GetHeaderComment = False
+ Comments = []
for Index in range(0, len(Content)):
# skip empty, commented, block commented lines
- Line = CleanString(Content[Index], AllowCppStyleComment=True)
+ Line, Comment = CleanString2(Content[Index], AllowCppStyleComment=True)
NextLine = ''
if Index + 1 < len(Content):
- NextLine = CleanString(Content[Index + 1])
+ NextLine, NextComment = CleanString2(Content[Index + 1])
if Line == '':
+ if Comment:
+ Comments.append((Comment, Index + 1))
continue
if Line.find(DataType.TAB_COMMENT_EDK_START) > -1:
IsFindBlockComment = True
@@ -518,6 +522,12 @@ class InfParser(MetaFileParser):
# section header
if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END:
+ if not GetHeaderComment:
+ for Cmt, LNo in Comments:
+ self._Store(MODEL_META_DATA_HEADER_COMMENT, Cmt, '', '', 'COMMON',
+ 'COMMON', self._Owner[-1], LNo, -1, LNo, -1, 0)
+ GetHeaderComment = True
+ Comments = []
self._SectionHeaderParser()
# Check invalid sections
if self._Version < 0x00010005:
@@ -566,13 +576,16 @@ class InfParser(MetaFileParser):
self._SectionParser[self._SectionType](self)
if self._ValueList == None or self._ItemType == MODEL_META_DATA_DEFINE:
self._ItemType = -1
+ Comments = []
continue
+ if Comment:
+ Comments.append((Comment, Index + 1))
#
# Model, Value1, Value2, Value3, Arch, Platform, BelongsToItem=-1,
# LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, Enabled=-1
#
for Arch, Platform in self._Scope:
- self._Store(self._SectionType,
+ LastItem = self._Store(self._SectionType,
self._ValueList[0],
self._ValueList[1],
self._ValueList[2],
@@ -585,6 +598,10 @@ class InfParser(MetaFileParser):
- 1,
0
)
+ for Comment, LineNo in Comments:
+ self._Store(MODEL_META_DATA_COMMENT, Comment, '', '', Arch, Platform,
+ LastItem, LineNo, -1, LineNo, -1, 0)
+ Comments = []
if IsFindBlockComment:
EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments (starting with /*) are expected to end with */",
File=self.MetaFile)
@@ -770,6 +787,7 @@ class DscParser(MetaFileParser):
"PLATFORM_GUID",
"PLATFORM_VERSION",
"SKUID_IDENTIFIER",
+ "PCD_INFO_GENERATION",
"SUPPORTED_ARCHITECTURES",
"BUILD_TARGETS",
"OUTPUT_DIRECTORY",
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py
index 088a118de1..607225a0ef 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileTable.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py
@@ -134,7 +134,7 @@ class ModuleTable(MetaFileTable):
#
# @retval: A recordSet of all found records
#
- def Query(self, Model, Arch=None, Platform=None):
+ def Query(self, Model, Arch=None, Platform=None, BelongsToItem=None):
ConditionString = "Model=%s AND Enabled>=0" % Model
ValueString = "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
@@ -142,6 +142,8 @@ class ModuleTable(MetaFileTable):
ConditionString += " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
if Platform != None and Platform != 'COMMON':
ConditionString += " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform
+ if BelongsToItem != None:
+ ConditionString += " AND BelongsToItem=%s" % BelongsToItem
SqlCommand = "SELECT %s FROM %s WHERE %s" % (ValueString, self.Table, ConditionString)
return self.Exec(SqlCommand)
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 19c00ca78d..04e3d14dff 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -70,7 +70,7 @@ class DscBuildData(PlatformBuildClassObject):
#TAB_DSC_DEFINES_OUTPUT_DIRECTORY : "_OutputDirectory",
#TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES : "_SupArchList",
#TAB_DSC_DEFINES_BUILD_TARGETS : "_BuildTargets",
- #TAB_DSC_DEFINES_SKUID_IDENTIFIER : "_SkuName",
+ TAB_DSC_DEFINES_SKUID_IDENTIFIER : "_SkuName",
#TAB_DSC_DEFINES_FLASH_DEFINITION : "_FlashDefinition",
TAB_DSC_DEFINES_BUILD_NUMBER : "_BuildNumber",
TAB_DSC_DEFINES_MAKEFILE_NAME : "_MakefileName",
@@ -126,6 +126,8 @@ class DscBuildData(PlatformBuildClassObject):
self._SupArchList = None
self._BuildTargets = None
self._SkuName = None
+ self._SkuIdentifier = None
+ self._PcdInfoFlag = None
self._FlashDefinition = None
self._BuildNumber = None
self._MakefileName = None
@@ -181,10 +183,9 @@ class DscBuildData(PlatformBuildClassObject):
for Record in RecordList:
Name = Record[1]
# items defined _PROPERTY_ don't need additional processing
- if Name in self:
- self[Name] = Record[2]
+
# some special items in [Defines] section need special treatment
- elif Name == TAB_DSC_DEFINES_OUTPUT_DIRECTORY:
+ if Name == TAB_DSC_DEFINES_OUTPUT_DIRECTORY:
self._OutputDirectory = NormPath(Record[2], self._Macros)
if ' ' in self._OutputDirectory:
EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in OUTPUT_DIRECTORY",
@@ -203,6 +204,9 @@ class DscBuildData(PlatformBuildClassObject):
elif Name == TAB_DSC_DEFINES_SKUID_IDENTIFIER:
if self._SkuName == None:
self._SkuName = Record[2]
+ self._SkuIdentifier = Record[2]
+ elif Name == TAB_DSC_DEFINES_PCD_INFO_GENERATION:
+ self._PcdInfoFlag = Record[2]
elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
try:
self._LoadFixAddress = int (Record[2], 0)
@@ -247,6 +251,8 @@ class DscBuildData(PlatformBuildClassObject):
except:
EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile)
self._VpdToolGuid = Record[2]
+ elif Name in self:
+ self[Name] = Record[2]
# set _Header to non-None in order to avoid database re-querying
self._Header = 'DUMMY'
@@ -312,7 +318,20 @@ class DscBuildData(PlatformBuildClassObject):
if self._BuildTargets == None:
EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile)
return self._BuildTargets
-
+
+ def _GetPcdInfoFlag(self):
+ if self._PcdInfoFlag == None or self._PcdInfoFlag.upper() == 'FALSE':
+ return False
+ elif self._PcdInfoFlag.upper() == 'TRUE':
+ return True
+ else:
+ return False
+
+ def _GetSkuIdentifier(self):
+ if self._SkuIdentifier == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ return self._SkuIdentifier
## Retrieve SKUID_IDENTIFIER
def _GetSkuName(self):
if self._SkuName == None:
@@ -441,9 +460,11 @@ class DscBuildData(PlatformBuildClassObject):
if Record[1] in [None, '']:
EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',
File=self.MetaFile, Line=Record[-1])
- self._SkuIds[Record[1]] = Record[0]
+ self._SkuIds[Record[1].upper()] = Record[0]
if 'DEFAULT' not in self._SkuIds:
self._SkuIds['DEFAULT'] = '0'
+ if 'COMMON' not in self._SkuIds:
+ self._SkuIds['COMMON'] = '0'
return self._SkuIds
## Retrieve [Components] section information
@@ -701,19 +722,45 @@ class DscBuildData(PlatformBuildClassObject):
# tdict is a special dict kind of type, used for selecting correct
# PCD settings for certain ARCH
#
+
+ SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds)
+
PcdDict = tdict(True, 3)
PcdSet = set()
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
+ PcdValueDict = sdict()
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4))
- PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting
- # Remove redundant PCD candidates
- for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet:
- Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]
+ SkuName = SkuName.upper()
+ if SkuName in (SkuObj.SystemSkuId,'DEFAULT','COMMON'):
+ PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,Dummy4))
+ PcdDict[Arch, PcdCName, TokenSpaceGuid,SkuName] = Setting
+
+ #handle pcd value override
+ for PcdCName, TokenSpaceGuid, SkuName,Dummy4 in PcdSet:
+ Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid,SkuName]
if Setting == None:
continue
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
+ if (PcdCName, TokenSpaceGuid) in PcdValueDict:
+ PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] = (PcdValue,DatumType,MaxDatumSize)
+ else:
+ PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue,DatumType,MaxDatumSize)}
+
+ PcdsKeys = PcdValueDict.keys()
+ for PcdCName,TokenSpaceGuid in PcdsKeys:
+
+ PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid]
+ PcdValue = None
+ DatumType = None
+ MaxDatumSize = None
+ if 'COMMON' in PcdSetting:
+ PcdValue,DatumType,MaxDatumSize = PcdSetting['COMMON']
+ if 'DEFAULT' in PcdSetting:
+ PcdValue,DatumType,MaxDatumSize = PcdSetting['DEFAULT']
+ if SkuObj.SystemSkuId in PcdSetting:
+ PcdValue,DatumType,MaxDatumSize = PcdSetting[SkuObj.SystemSkuId]
+
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -735,6 +782,9 @@ class DscBuildData(PlatformBuildClassObject):
# @retval a dict object contains settings of given PCD type
#
def _GetDynamicPcd(self, Type):
+
+ SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds)
+
Pcds = sdict()
#
# tdict is a special dict kind of type, used for selecting correct
@@ -744,30 +794,68 @@ class DscBuildData(PlatformBuildClassObject):
PcdList = []
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
+ AvailableSkuIdSet = SkuObj.AvailableSkuIdSet.copy()
+
+ AvailableSkuIdSet.update({'DEFAULT':0,'COMMON':0})
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdList.append((PcdCName, TokenSpaceGuid, Dummy4))
+ SkuName = SkuName.upper()
+ if SkuName not in AvailableSkuIdSet:
+ continue
+
+ PcdList.append((PcdCName, TokenSpaceGuid, SkuName,Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid, Dummy4 in PcdList:
- Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
+ for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList:
+
+ Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
+ SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], '', '', '', '', '', PcdValue)
+ if (PcdCName,TokenSpaceGuid) in Pcds.keys():
+ pcdObject = Pcds[PcdCName,TokenSpaceGuid]
+ pcdObject.SkuInfoList[SkuName] = SkuInfo
+ else:
+ Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
+ PcdCName,
+ TokenSpaceGuid,
+ self._PCD_TYPE_STRING_[Type],
+ DatumType,
+ PcdValue,
+ '',
+ MaxDatumSize,
+ {SkuName : SkuInfo},
+ False,
+ None
+ )
+
+ for pcd in Pcds.values():
+ if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ pcdDecObject = self._DecPcds[pcd.TokenCName,pcd.TokenSpaceGuidCName]
+ valuefromDec = pcdDecObject.DefaultValue
+ SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)
+ pcd.SkuInfoList['DEFAULT'] = SkuInfo
+ elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
+ del(pcd.SkuInfoList['COMMON'])
+ elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ del(pcd.SkuInfoList['COMMON'])
+ if SkuObj.SkuUsageType == SkuObj.SINGLE:
+ if 'DEFAULT' in pcd.SkuInfoList.keys() and SkuObj.SystemSkuId not in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList[SkuObj.SystemSkuId] = pcd.SkuInfoList['DEFAULT']
+ del(pcd.SkuInfoList['DEFAULT'])
+
+ if SkuObj.SkuUsageType == SkuObj.MULTIPLE:
+ if pcd.DatumType == "VOID*":
+ MaxSize = int(pcd.MaxDatumSize,0)
+ for (skuname,skuobj) in pcd.SkuInfoList.items():
+ datalen = len(skuobj.DefaultValue)
+ if datalen>MaxSize:
+ MaxSize = datalen
+ pcd.MaxDatumSize = str(MaxSize)
+
- SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', '', PcdValue)
- Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
- PcdCName,
- TokenSpaceGuid,
- self._PCD_TYPE_STRING_[Type],
- DatumType,
- PcdValue,
- '',
- MaxDatumSize,
- {self.SkuName : SkuInfo},
- False,
- None
- )
return Pcds
## Retrieve dynamic HII PCD settings
@@ -777,6 +865,9 @@ class DscBuildData(PlatformBuildClassObject):
# @retval a dict object contains settings of given PCD type
#
def _GetDynamicHiiPcd(self, Type):
+
+ SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds)
+
Pcds = sdict()
#
# tdict is a special dict kind of type, used for selecting correct
@@ -786,17 +877,28 @@ class DscBuildData(PlatformBuildClassObject):
PcdSet = set()
RecordList = self._RawData[Type, self._Arch]
# Find out all possible PCD candidates for self._Arch
+ AvailableSkuIdSet = SkuObj.AvailableSkuIdSet.copy()
+
+ AvailableSkuIdSet.update({'DEFAULT':0,'COMMON':0})
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4))
+ SkuName = SkuName.upper()
+ if SkuName not in AvailableSkuIdSet:
+ continue
+ PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet:
- Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
+ for PcdCName, TokenSpaceGuid,SkuName, Dummy4 in PcdSet:
+
+ Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
VariableName, VariableGuid, VariableOffset, DefaultValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
- SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue)
- Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
+ SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue)
+ if (PcdCName,TokenSpaceGuid) in Pcds.keys():
+ pcdObject = Pcds[PcdCName,TokenSpaceGuid]
+ pcdObject.SkuInfoList[SkuName] = SkuInfo
+ else:
+ Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
self._PCD_TYPE_STRING_[Type],
@@ -804,10 +906,29 @@ class DscBuildData(PlatformBuildClassObject):
DefaultValue,
'',
'',
- {self.SkuName : SkuInfo},
+ {SkuName : SkuInfo},
False,
None
)
+
+
+ for pcd in Pcds.values():
+ SkuInfoObj = pcd.SkuInfoList.values()[0]
+ if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ pcdDecObject = self._DecPcds[pcd.TokenCName,pcd.TokenSpaceGuidCName]
+ valuefromDec = pcdDecObject.DefaultValue
+ SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec)
+ pcd.SkuInfoList['DEFAULT'] = SkuInfo
+ elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
+ del(pcd.SkuInfoList['COMMON'])
+ elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ del(pcd.SkuInfoList['COMMON'])
+
+ if SkuObj.SkuUsageType == SkuObj.SINGLE:
+ if 'DEFAULT' in pcd.SkuInfoList.keys() and SkuObj.SystemSkuId not in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList[SkuObj.SystemSkuId] = pcd.SkuInfoList['DEFAULT']
+ del(pcd.SkuInfoList['DEFAULT'])
return Pcds
## Retrieve dynamic VPD PCD settings
@@ -817,6 +938,9 @@ class DscBuildData(PlatformBuildClassObject):
# @retval a dict object contains settings of given PCD type
#
def _GetDynamicVpdPcd(self, Type):
+
+ SkuObj = SkuClass(self.SkuIdentifier,self.SkuIds)
+
Pcds = sdict()
#
# tdict is a special dict kind of type, used for selecting correct
@@ -826,12 +950,19 @@ class DscBuildData(PlatformBuildClassObject):
PcdList = []
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
+ AvailableSkuIdSet = SkuObj.AvailableSkuIdSet.copy()
+
+ AvailableSkuIdSet.update({'DEFAULT':0,'COMMON':0})
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdList.append((PcdCName, TokenSpaceGuid, Dummy4))
+ SkuName = SkuName.upper()
+ if SkuName not in AvailableSkuIdSet:
+ continue
+
+ PcdList.append((PcdCName, TokenSpaceGuid,SkuName, Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid, Dummy4 in PcdList:
- Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
+ for PcdCName, TokenSpaceGuid, SkuName,Dummy4 in PcdList:
+ Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
#
@@ -841,9 +972,12 @@ class DscBuildData(PlatformBuildClassObject):
# until the DEC parser has been called.
#
VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
-
- SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset, InitialValue)
- Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
+ SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName], '', '', '', '', VpdOffset, InitialValue)
+ if (PcdCName,TokenSpaceGuid) in Pcds.keys():
+ pcdObject = Pcds[PcdCName,TokenSpaceGuid]
+ pcdObject.SkuInfoList[SkuName] = SkuInfo
+ else:
+ Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
self._PCD_TYPE_STRING_[Type],
@@ -851,10 +985,35 @@ class DscBuildData(PlatformBuildClassObject):
'',
'',
MaxDatumSize,
- {self.SkuName : SkuInfo},
+ {SkuName : SkuInfo},
False,
None
)
+ for pcd in Pcds.values():
+ SkuInfoObj = pcd.SkuInfoList.values()[0]
+ if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():
+ pcdDecObject = self._DecPcds[pcd.TokenCName,pcd.TokenSpaceGuidCName]
+ valuefromDec = pcdDecObject.DefaultValue
+ SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '','',SkuInfoObj.VpdOffset, valuefromDec)
+ pcd.SkuInfoList['DEFAULT'] = SkuInfo
+ elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']
+ del(pcd.SkuInfoList['COMMON'])
+ elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():
+ del(pcd.SkuInfoList['COMMON'])
+ if SkuObj.SkuUsageType == SkuObj.SINGLE:
+ if 'DEFAULT' in pcd.SkuInfoList.keys() and SkuObj.SystemSkuId not in pcd.SkuInfoList.keys():
+ pcd.SkuInfoList[SkuObj.SystemSkuId] = pcd.SkuInfoList['DEFAULT']
+ del(pcd.SkuInfoList['DEFAULT'])
+
+ if SkuObj.SkuUsageType == SkuObj.MULTIPLE:
+ if pcd.MaxDatumSize.strip():
+ MaxSize = int(pcd.MaxDatumSize,0)
+ for (skuname,skuobj) in pcd.SkuInfoList.items():
+ datalen = len(skuobj.DefaultValue)
+ if datalen>MaxSize:
+ MaxSize = datalen
+ pcd.MaxDatumSize = str(MaxSize)
return Pcds
## Add external modules
@@ -896,6 +1055,8 @@ class DscBuildData(PlatformBuildClassObject):
SupArchList = property(_GetSupArch)
BuildTargets = property(_GetBuildTarget)
SkuName = property(_GetSkuName, _SetSkuName)
+ SkuIdentifier = property(_GetSkuIdentifier)
+ PcdInfoFlag = property(_GetPcdInfoFlag)
FlashDefinition = property(_GetFdfFile)
BuildNumber = property(_GetBuildNumber)
MakefileName = property(_GetMakefileName)
@@ -1358,6 +1519,7 @@ class InfBuildData(ModuleBuildClassObject):
## Set all internal used members of InfBuildData to None
def _Clear(self):
+ self._HeaderComments = None
self._Header_ = None
self._AutoGenVersion = None
self._BaseName = None
@@ -1384,11 +1546,16 @@ class InfBuildData(ModuleBuildClassObject):
self._LibraryClasses = None
self._Libraries = None
self._Protocols = None
+ self._ProtocolComments = None
self._Ppis = None
+ self._PpiComments = None
self._Guids = None
+ self._GuidsUsedByPcd = sdict()
+ self._GuidComments = None
self._Includes = None
self._Packages = None
self._Pcds = None
+ self._PcdComments = None
self._BuildOptions = None
self._Depex = None
self._DepexExpression = None
@@ -1438,6 +1605,13 @@ class InfBuildData(ModuleBuildClassObject):
return
self._Platform = Value
self._Clear()
+ def _GetHeaderComments(self):
+ if not self._HeaderComments:
+ self._HeaderComments = []
+ RecordList = self._RawData[MODEL_META_DATA_HEADER_COMMENT]
+ for Record in RecordList:
+ self._HeaderComments.append(Record[0])
+ return self._HeaderComments
## Retrieve all information in [Defines] section
#
@@ -1873,10 +2047,14 @@ class InfBuildData(ModuleBuildClassObject):
self._Libraries.append(LibraryName)
return self._Libraries
+ def _GetProtocolComments(self):
+ self._GetProtocols()
+ return self._ProtocolComments
## Retrieve protocols consumed/produced by this module
def _GetProtocols(self):
if self._Protocols == None:
self._Protocols = sdict()
+ self._ProtocolComments = sdict()
RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch, self._Platform]
for Record in RecordList:
CName = Record[0]
@@ -1887,12 +2065,21 @@ class InfBuildData(ModuleBuildClassObject):
"Value of Protocol [%s] is not found under [Protocols] section in" % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
self._Protocols[CName] = Value
+ CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
+ Comments = []
+ for CmtRec in CommentRecords:
+ Comments.append(CmtRec[0])
+ self._ProtocolComments[CName] = Comments
return self._Protocols
+ def _GetPpiComments(self):
+ self._GetPpis()
+ return self._PpiComments
## Retrieve PPIs consumed/produced by this module
def _GetPpis(self):
if self._Ppis == None:
self._Ppis = sdict()
+ self._PpiComments = sdict()
RecordList = self._RawData[MODEL_EFI_PPI, self._Arch, self._Platform]
for Record in RecordList:
CName = Record[0]
@@ -1903,12 +2090,21 @@ class InfBuildData(ModuleBuildClassObject):
"Value of PPI [%s] is not found under [Ppis] section in " % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
self._Ppis[CName] = Value
+ CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
+ Comments = []
+ for CmtRec in CommentRecords:
+ Comments.append(CmtRec[0])
+ self._PpiComments[CName] = Comments
return self._Ppis
+ def _GetGuidComments(self):
+ self._GetGuids()
+ return self._GuidComments
## Retrieve GUIDs consumed/produced by this module
def _GetGuids(self):
if self._Guids == None:
self._Guids = sdict()
+ self._GuidComments = sdict()
RecordList = self._RawData[MODEL_EFI_GUID, self._Arch, self._Platform]
for Record in RecordList:
CName = Record[0]
@@ -1919,6 +2115,11 @@ class InfBuildData(ModuleBuildClassObject):
"Value of Guid [%s] is not found under [Guids] section in" % CName,
ExtraData=PackageList, File=self.MetaFile, Line=Record[-1])
self._Guids[CName] = Value
+ CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Record[5]]
+ Comments = []
+ for CmtRec in CommentRecords:
+ Comments.append(CmtRec[0])
+ self._GuidComments[CName] = Comments
return self._Guids
## Retrieve include paths necessary for this module (for Edk.x style of modules)
@@ -1986,10 +2187,15 @@ class InfBuildData(ModuleBuildClassObject):
self._Packages.append(Package)
return self._Packages
+ ## Retrieve PCD comments
+ def _GetPcdComments(self):
+ self._GetPcds()
+ return self._PcdComments
## Retrieve PCDs used in this module
def _GetPcds(self):
if self._Pcds == None:
self._Pcds = sdict()
+ self._PcdComments = sdict()
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
@@ -2087,13 +2293,15 @@ class InfBuildData(ModuleBuildClassObject):
self._DepexExpression[Arch, ModuleType] = DepexExpression[Arch, ModuleType]
return self._DepexExpression
+ def GetGuidsUsedByPcd(self):
+ return self._GuidsUsedByPcd
## Retrieve PCD for given type
def _GetPcd(self, Type):
Pcds = sdict()
PcdDict = tdict(True, 4)
PcdList = []
RecordList = self._RawData[Type, self._Arch, self._Platform]
- for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Dummy1, LineNo in RecordList:
+ for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Id, LineNo in RecordList:
PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] = (Setting, LineNo)
PcdList.append((PcdCName, TokenSpaceGuid))
# get the guid value
@@ -2105,6 +2313,12 @@ class InfBuildData(ModuleBuildClassObject):
"Value of Guid [%s] is not found under [Guids] section in" % TokenSpaceGuid,
ExtraData=PackageList, File=self.MetaFile, Line=LineNo)
self.Guids[TokenSpaceGuid] = Value
+ self._GuidsUsedByPcd[TokenSpaceGuid] = Value
+ CommentRecords = self._RawData[MODEL_META_DATA_COMMENT, self._Arch, self._Platform, Id]
+ Comments = []
+ for CmtRec in CommentRecords:
+ Comments.append(CmtRec[0])
+ self._PcdComments[TokenSpaceGuid, PcdCName] = Comments
# resolve PCD type, value, datum info, etc. by getting its definition from package
for PcdCName, TokenSpaceGuid in PcdList:
@@ -2125,6 +2339,9 @@ class InfBuildData(ModuleBuildClassObject):
False,
self.Guids[TokenSpaceGuid]
)
+ if Type == MODEL_PCD_PATCHABLE_IN_MODULE and ValueList[1]:
+ # Patch PCD: TokenSpace.PcdCName|Value|Offset
+ Pcd.Offset = ValueList[1]
# get necessary info from package declaring this PCD
for Package in self.Packages:
@@ -2216,10 +2433,20 @@ class InfBuildData(ModuleBuildClassObject):
return Pcds
- _Macros = property(_GetMacros)
- Arch = property(_GetArch, _SetArch)
- Platform = property(_GetPlatform, _SetPlatform)
+ ## check whether current module is binary module
+ def _IsBinaryModule(self):
+ if self.Binaries and not self.Sources:
+ return True
+ elif GlobalData.gIgnoreSource:
+ return True
+ else:
+ return False
+
+ _Macros = property(_GetMacros)
+ Arch = property(_GetArch, _SetArch)
+ Platform = property(_GetPlatform, _SetPlatform)
+ HeaderComments = property(_GetHeaderComments)
AutoGenVersion = property(_GetInfVersion)
BaseName = property(_GetBaseName)
ModuleType = property(_GetModuleType)
@@ -2244,14 +2471,19 @@ class InfBuildData(ModuleBuildClassObject):
LibraryClasses = property(_GetLibraryClassUses)
Libraries = property(_GetLibraryNames)
Protocols = property(_GetProtocols)
+ ProtocolComments = property(_GetProtocolComments)
Ppis = property(_GetPpis)
+ PpiComments = property(_GetPpiComments)
Guids = property(_GetGuids)
+ GuidComments = property(_GetGuidComments)
Includes = property(_GetIncludes)
Packages = property(_GetPackages)
Pcds = property(_GetPcds)
+ PcdComments = property(_GetPcdComments)
BuildOptions = property(_GetBuildOptions)
Depex = property(_GetDepex)
DepexExpression = property(_GetDepexExpression)
+ IsBinaryModule = property(_IsBinaryModule)
## Database
#
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 24a6ed8168..fca36d1807 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1433,8 +1433,8 @@ class Build():
Ma.CreateAsBuiltInf()
if self.Target == "genmake":
continue
- self.Progress.Stop("done!")
pModules.append(Ma)
+ self.Progress.Stop("done!")
for Ma in pModules:
# Generate build task for the module