summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-29 06:16:53 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-29 06:16:53 +0000
commita709adfaf0bebbaf3d989f56b500e3985687d0e3 (patch)
tree47d6f44e4afffe70535e492f8585f433efcbf24d /BaseTools/Source
parent4661d5df04ce804e454509922fd54f45332553da (diff)
downloadedk2-a709adfaf0bebbaf3d989f56b500e3985687d0e3.tar.gz
edk2-a709adfaf0bebbaf3d989f56b500e3985687d0e3.tar.bz2
edk2-a709adfaf0bebbaf3d989f56b500e3985687d0e3.zip
Sync tool code to BuildTools project r1783.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9623 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source')
-rw-r--r--BaseTools/Source/C/Common/BasePeCoff.c52
-rw-r--r--BaseTools/Source/C/Common/FvLib.c3
-rw-r--r--BaseTools/Source/C/Common/ParseInf.c4
-rw-r--r--BaseTools/Source/C/Common/PeCoffLib.h10
-rw-r--r--BaseTools/Source/C/Common/SimpleFileParsing.c12
-rw-r--r--BaseTools/Source/C/Common/StringFuncs.c8
-rw-r--r--BaseTools/Source/C/EfiRom/EfiRom.h16
-rw-r--r--BaseTools/Source/C/GenFv/GenFv.c4
-rw-r--r--BaseTools/Source/C/GenFv/GenFvInternalLib.c2
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c590
-rw-r--r--BaseTools/Source/C/GenSec/GenSec.c2
-rw-r--r--BaseTools/Source/C/GenVtf/GenVtf.c16
-rw-r--r--BaseTools/Source/C/GenVtf/GenVtf.h16
-rw-r--r--BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h12
-rw-r--r--BaseTools/Source/C/Include/IndustryStandard/PeImage.h12
-rw-r--r--BaseTools/Source/C/Include/X64/ProcessorBind.h2
-rw-r--r--BaseTools/Source/C/Makefiles/app.makefile2
-rw-r--r--BaseTools/Source/C/Makefiles/header.makefile12
-rw-r--r--BaseTools/Source/C/Split/Split.c4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp2
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h178
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g184
-rw-r--r--BaseTools/Source/C/VolInfo/VolInfo.c4
-rw-r--r--BaseTools/Source/Python/AutoGen/AutoGen.py17
-rw-r--r--BaseTools/Source/Python/Common/Misc.py10
-rw-r--r--BaseTools/Source/Python/GenFds/Fv.py6
-rw-r--r--BaseTools/Source/Python/Workspace/WorkspaceDatabase.py5
-rw-r--r--BaseTools/Source/Python/build/build.py4
-rw-r--r--BaseTools/Source/Python/sitecustomize.py9
29 files changed, 890 insertions, 308 deletions
diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c
index 0166c22460..5ffb5d4503 100644
--- a/BaseTools/Source/C/Common/BasePeCoff.c
+++ b/BaseTools/Source/C/Common/BasePeCoff.c
@@ -1173,6 +1173,9 @@ Returns:
ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
break;
+ case CODEVIEW_SIGNATURE_MTOC:
+ ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);
+
default:
break;
}
@@ -1377,6 +1380,8 @@ PeCoffLoaderGetPdbPointer (
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
case CODEVIEW_SIGNATURE_RSDS:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
+ case CODEVIEW_SIGNATURE_MTOC:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
default:
break;
}
@@ -1386,3 +1391,50 @@ PeCoffLoaderGetPdbPointer (
return NULL;
}
+
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint,
+ OUT VOID **BaseOfImage
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ //
+ // Calculate the entry point relative to the start of the image.
+ // AddressOfEntryPoint is common for PE32 & PE32+
+ //
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ *BaseOfImage = (VOID *)(UINTN)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));
+ *EntryPoint = (VOID *)((UINTN)*BaseOfImage + (Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) + sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);
+ return RETURN_SUCCESS;
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ *EntryPoint = (VOID *)(UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint;
+ if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ *BaseOfImage = (VOID *)(UINTN)Hdr.Pe32->OptionalHeader.ImageBase;
+ } else {
+ *BaseOfImage = (VOID *)(UINTN)Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ }
+ *EntryPoint = (VOID *)(UINTN)((UINTN)*EntryPoint + (UINTN)*BaseOfImage);
+ return RETURN_SUCCESS;
+ }
+
+ return RETURN_UNSUPPORTED;
+}
diff --git a/BaseTools/Source/C/Common/FvLib.c b/BaseTools/Source/C/Common/FvLib.c
index dc50e877e6..a6f17e17a8 100644
--- a/BaseTools/Source/C/Common/FvLib.c
+++ b/BaseTools/Source/C/Common/FvLib.c
@@ -110,6 +110,7 @@ Returns:
}
*FvHeader = mFvHeader;
+ *FvLength = mFvLength;
return EFI_SUCCESS;
}
@@ -200,7 +201,7 @@ Returns:
//
// Get next file, compensate for 8 byte alignment if necessary.
//
- *NextFile = (EFI_FFS_FILE_HEADER *) (((UINTN) CurrentFile + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3));
+ *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);
//
// Verify file is in this FV.
diff --git a/BaseTools/Source/C/Common/ParseInf.c b/BaseTools/Source/C/Common/ParseInf.c
index b39c5bde40..cd10da9b2d 100644
--- a/BaseTools/Source/C/Common/ParseInf.c
+++ b/BaseTools/Source/C/Common/ParseInf.c
@@ -506,7 +506,7 @@ Returns:
// Verify string is a hex number
//
for (Index = 2; Index < strlen (AsciiString); Index++) {
- if (isxdigit (AsciiString[Index]) == 0) {
+ if (isxdigit ((int)AsciiString[Index]) == 0) {
return EFI_ABORTED;
}
}
@@ -536,7 +536,7 @@ Returns:
// Verify string is a number
//
for (Index = 0; Index < strlen (AsciiString); Index++) {
- if (isdigit (AsciiString[Index]) == 0) {
+ if (isdigit ((int)AsciiString[Index]) == 0) {
return EFI_ABORTED;
}
}
diff --git a/BaseTools/Source/C/Common/PeCoffLib.h b/BaseTools/Source/C/Common/PeCoffLib.h
index fc2e4cafc9..077a66c5d7 100644
--- a/BaseTools/Source/C/Common/PeCoffLib.h
+++ b/BaseTools/Source/C/Common/PeCoffLib.h
@@ -134,4 +134,14 @@ PeCoffLoaderGetPdbPointer (
IN VOID *Pe32Data
)
;
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint,
+ OUT VOID **BaseOfImage
+ )
+;
+
#endif
diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.c b/BaseTools/Source/C/Common/SimpleFileParsing.c
index 5a7111c8eb..68cdc630c1 100644
--- a/BaseTools/Source/C/Common/SimpleFileParsing.c
+++ b/BaseTools/Source/C/Common/SimpleFileParsing.c
@@ -328,7 +328,7 @@ Notes:
}
if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {
- if (isalnum (mGlobals.SourceFile.FileBufferPtr[Len])) {
+ if (isalnum ((int)mGlobals.SourceFile.FileBufferPtr[Len])) {
return FALSE;
}
@@ -543,26 +543,26 @@ Returns:
return FALSE;
}
- if (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {
+ if (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
//
// Check for hex value
//
if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {
- if (!isxdigit (mGlobals.SourceFile.FileBufferPtr[2])) {
+ if (!isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[2])) {
return FALSE;
}
mGlobals.SourceFile.FileBufferPtr += 2;
sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", &Val);
*Value = (UINT32) Val;
- while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {
+ while (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
mGlobals.SourceFile.FileBufferPtr++;
}
return TRUE;
} else {
*Value = atoi (mGlobals.SourceFile.FileBufferPtr);
- while (isdigit (mGlobals.SourceFile.FileBufferPtr[0])) {
+ while (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
mGlobals.SourceFile.FileBufferPtr++;
}
@@ -1239,7 +1239,7 @@ GetHexChars (
UINT32 Len;
Len = 0;
while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {
- if (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) {
+ if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
*Buffer = mGlobals.SourceFile.FileBufferPtr[0];
Buffer++;
Len++;
diff --git a/BaseTools/Source/C/Common/StringFuncs.c b/BaseTools/Source/C/Common/StringFuncs.c
index b0ad2d165e..f65ba96661 100644
--- a/BaseTools/Source/C/Common/StringFuncs.c
+++ b/BaseTools/Source/C/Common/StringFuncs.c
@@ -87,7 +87,7 @@ Returns:
//
// Remove leading whitespace
//
- for (Pos = String; isspace (*Pos); Pos++) {
+ for (Pos = String; isspace ((int)*Pos); Pos++) {
}
if (Pos != String) {
memmove (String, Pos, strlen (Pos) + 1);
@@ -114,7 +114,7 @@ Returns:
// Remove trailing whitespace
//
for (Pos = String + strlen (String);
- ((Pos - 1) >= String) && (isspace (*(Pos - 1)));
+ ((Pos - 1) >= String) && (isspace ((int)*(Pos - 1)));
Pos--
) {
}
@@ -160,12 +160,12 @@ Returns:
Output = NewStringList ();
for (Pos = String, Item = 0; Pos < EndOfString; Item++) {
- while (isspace (*Pos)) {
+ while (isspace ((int)*Pos)) {
Pos++;
}
for (EndOfSubString=Pos;
- (*EndOfSubString != '\0') && !isspace (*EndOfSubString);
+ (*EndOfSubString != '\0') && !isspace ((int)*EndOfSubString);
EndOfSubString++
) {
}
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h b/BaseTools/Source/C/EfiRom/EfiRom.h
index 2689c2293c..65c77c4034 100644
--- a/BaseTools/Source/C/EfiRom/EfiRom.h
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -1,13 +1,13 @@
/** @file
-Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved
-This software and associated documentation (if any) is furnished
-under a license and may only be used or copied in accordance
-with the terms of the license. Except as permitted by such
-license, no part of this software or documentation may be
-reproduced, stored in a retrieval system, or transmitted in any
-form or by any means without the express written consent of
-Intel Corporation.
+Copyright (c) 1999-2008 Intel Corporation. All rights reserved
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the BSD License which accompanies this
+distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c
index f2ff2d29cd..135c9ed23f 100644
--- a/BaseTools/Source/C/GenFv/GenFv.c
+++ b/BaseTools/Source/C/GenFv/GenFv.c
@@ -134,11 +134,11 @@ Returns:
fprintf (stdout, " -m logfile, --map logfile\n\
Logfile is the output fv map file name. if it is not\n\
given, the FvName.map will be the default map file name\n");
- fprintf (stdout, " -g Guid, --guid GuidValue\n\
+ fprintf (stdout, " -g Guid, --guid Guid\n\
GuidValue is one specific capsule guid value\n\
or fv file system guid value.\n\
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n");
- fprintf (stdout, " --FvNameGuid GuidValue is the Fv Name Guid value.\n\
+ fprintf (stdout, " --FvNameGuid Guid Guid is used to specify Fv Name.\n\
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");
diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index 6b5d6bda2a..d17a2ff1a8 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -2975,7 +2975,7 @@ Returns:
return EFI_OUT_OF_RESOURCES;
}
memset ((VOID *) MemoryImagePointer, 0, (UINTN) ImageContext.ImageSize + ImageContext.SectionAlignment);
- ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~(ImageContext.SectionAlignment - 1));
+ ImageContext.ImageAddress = ((UINTN) MemoryImagePointer + ImageContext.SectionAlignment - 1) & (~((INT64)ImageContext.SectionAlignment - 1));
Status = PeCoffLoaderLoadImage (&ImageContext);
if (EFI_ERROR (Status)) {
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index e72f052869..aabd143b6a 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -77,6 +77,7 @@ Abstract:
#define FW_MERGE_IMAGE 8
#define FW_RELOC_STRIPEED_IMAGE 9
#define FW_HII_PACKAGE_LIST_RCIMAGE 10
+#define FW_HII_PACKAGE_LIST_BINIMAGE 11
#define DUMP_TE_HEADER 0x11
@@ -198,10 +199,10 @@ Returns:
fprintf (stdout, " -o FileName, --outputfile FileName\n\
File will be created to store the ouput content.\n");
fprintf (stdout, " -e EFI_FILETYPE, --efiImage EFI_FILETYPE\n\
- Create Efi Image. EFI_FILETYPE is one of BASE, SEC,\n\
+ Create Efi Image. EFI_FILETYPE is one of BASE,SMM_CORE,\n\
PEI_CORE, PEIM, DXE_CORE, DXE_DRIVER, UEFI_APPLICATION,\n\
- DXE_SAL_DRIVER, UEFI_DRIVER, DXE_RUNTIME_DRIVER, \n\
- DXE_SMM_DRIVER, SECURITY_CORE, COMBINED_PEIM_DRIVER, \n\
+ SEC, DXE_SAL_DRIVER, UEFI_DRIVER, DXE_RUNTIME_DRIVER,\n\
+ DXE_SMM_DRIVER, SECURITY_CORE, COMBINED_PEIM_DRIVER,\n\
PIC_PEIM, RELOCATABLE_PEIM, BS_DRIVER, RT_DRIVER,\n\
APPLICATION, SAL_RT_DRIVER to support all module types\n\
It can only be used together with --keepexceptiontable,\n\
@@ -235,7 +236,7 @@ Returns:
except for -o, -r option. It is a action option.\n\
If it is combined with other action options, the later\n\
input action option will override the previous one.\n");;
- fprintf (stdout, " -l, --stripped Relocation info stripped from the input PE or TE image.\n\
+ fprintf (stdout, " -l, --stripped Strip off the relocation info from PE or TE image.\n\
It can't be combined with other action options\n\
except for -o, -r option. It is a action option.\n\
If it is combined with other action options, the later\n\
@@ -272,7 +273,7 @@ Returns:
If more input files are specified,\n\
the last input file will be as the output file.\n");
fprintf (stdout, " -g HiiPackageListGuid, --hiiguid HiiPackageListGuid\n\
- HiiListPackageGuidGuid is from the module guid.\n\
+ Guid is used to specify hii package list guid.\n\
Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n\
If not specified, the first Form FormSet guid is used.\n");
fprintf (stdout, " --hiipackage Combine all input binary hii pacakges into \n\
@@ -281,6 +282,12 @@ Returns:
except for -o option. It is a action option.\n\
If it is combined with other action options, the later\n\
input action option will override the previous one.\n");
+ fprintf (stdout, " --hiibinpackage Combine all input binary hii pacakges into \n\
+ a single package list as the binary resource section.\n\
+ It can't be combined with other action options\n\
+ except for -o option. It is a action option.\n\
+ If it is combined with other action options, the later\n\
+ input action option will override the previous one.\n");
fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");
fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n");
fprintf (stdout, " -d, --debug level Enable debug messages, at input debug level.\n");
@@ -501,12 +508,6 @@ UINT32 DataOffset;
UINT32 HiiRsrcOffset;
UINT32 RelocOffset;
-//
-// HiiBinData
-//
-UINT8* HiiBinData = NULL;
-UINT32 HiiBinSize = 0;
-
EFI_IMAGE_BASE_RELOCATION *CoffBaseRel;
UINT16 *CoffEntryRel;
@@ -628,122 +629,60 @@ CreateSectionHeader(
}
VOID
-GetBinaryHiiData (
- CHAR8 *RcString,
- UINT32 Size,
+SetHiiResourceHeader (
+ UINT8 *HiiBinData,
UINT32 OffsetToFile
)
{
- unsigned Data16;
- UINT32 HiiBinOffset;
UINT32 Index;
EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
- Index = 0;
- while (Index < Size && *RcString != '\0' && *RcString != '{') {
- RcString ++;
- Index ++;
- }
-
- if (*RcString == '\0' || Index == Size) {
- return;
- }
-
- //
- // Skip '{' character
- // Skip space and ',' character
- //
- RcString ++;
- Index ++;
- while (Index < Size && *RcString != '\0' && (isspace (*RcString) || *RcString == ',')){
- RcString ++;
- Index ++;
- }
-
- //
- // '}' end character
- //
- if (*RcString == '}' || Index == Size) {
- return;
- }
-
- HiiBinOffset = 0;
- HiiBinSize = 0x1000;
- HiiBinData = (UINT8 *) malloc (HiiBinSize);
- if (HiiBinData == NULL) {
- return;
- }
- memset (HiiBinData, 0, HiiBinSize);
//
// Fill Resource section entry
//
- ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiBinData + HiiBinOffset);
- HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
- ResourceDirectory->NumberOfNamedEntries = 1;
-
- ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (HiiBinData + HiiBinOffset);
- HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
- ResourceDirectoryEntry->u1.s.NameIsString = 1;
- ResourceDirectoryEntry->u1.s.NameOffset = HiiBinOffset;
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiBinData);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index ++) {
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiBinData + ResourceDirectoryEntry->u1.s.NameOffset);
- ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiBinData + HiiBinOffset);
- ResourceDirectoryString->Length = 3;
- ResourceDirectoryString->String[0] =L'H';
- ResourceDirectoryString->String[1] =L'I';
- ResourceDirectoryString->String[2] =L'I';
- HiiBinOffset = HiiBinOffset + sizeof (ResourceDirectoryString->Length) + ResourceDirectoryString->Length * sizeof (ResourceDirectoryString->String[0]);
+ if (ResourceDirectoryString->Length == 3 &&
+ ResourceDirectoryString->String[0] == L'H' &&
+ ResourceDirectoryString->String[1] == L'I' &&
+ ResourceDirectoryString->String[2] == L'I') {
+ //
+ // Resource Type "HII" found
+ //
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Name
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiBinData + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
- ResourceDirectoryEntry->u2.OffsetToData = HiiBinOffset;
- ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (HiiBinData + HiiBinOffset);
- HiiBinOffset += sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
- ResourceDataEntry->OffsetToData = OffsetToFile + HiiBinOffset;
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Language
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiBinData + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ }
+ }
- while (sscanf (RcString, "0x%X", &Data16) != EOF) {
- //
- // Convert the string data to the binary data.
- //
- *(UINT16 *)(HiiBinData + HiiBinOffset) = (UINT16) Data16;
- HiiBinOffset += 2;
- //
- // Jump to the next data.
- //
- RcString = RcString + 2 + 4;
- Index = Index + 2 + 4;
- //
- // Skip space and ',' character
- //
- while (Index < Size && *RcString != '\0' && (isspace (*RcString) || *RcString == ',')){
- RcString ++;
- Index ++;
- }
- //
- // '}' end character
- //
- if (*RcString == '}'|| Index == Size) {
- break;
- }
- //
- // Check BinBuffer size
- //
- if (HiiBinOffset >= HiiBinSize) {
- HiiBinSize += 0x1000;
- HiiBinData = (UINT8 *) realloc (HiiBinData, HiiBinSize);
- //
- // Memory allocation is failure.
- //
- if (HiiBinData == NULL) {
- HiiBinSize = 0;
- break;
+ //
+ // Now it ought to be resource Data and update its OffsetToData value
+ //
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (HiiBinData + ResourceDirectoryEntry->u2.OffsetToData);
+ ResourceDataEntry->OffsetToData = ResourceDataEntry->OffsetToData + OffsetToFile;
+ break;
+ }
}
}
- }
-
- if (HiiBinData != NULL) {
- HiiBinSize = HiiBinOffset;
- ResourceDataEntry->Size = HiiBinSize + OffsetToFile - ResourceDataEntry->OffsetToData;
+ ResourceDirectoryEntry++;
}
return;
@@ -867,10 +806,11 @@ ScanSections(
Error (NULL, 0, 3000, "Invalid", "Unsupported section alignment.");
}
}
- GetBinaryHiiData ((CHAR8*)Ehdr + shdr->sh_offset, shdr->sh_size, HiiRsrcOffset);
- if (HiiBinSize != 0) {
- CoffOffset += HiiBinSize;
+ if (shdr->sh_size != 0) {
+ CoffSectionsOffset[i] = CoffOffset;
+ CoffOffset += shdr->sh_size;
CoffOffset = CoffAlign(CoffOffset);
+ SetHiiResourceHeader ((UINT8*) Ehdr + shdr->sh_offset, HiiRsrcOffset);
}
break;
}
@@ -972,13 +912,8 @@ ScanSections(
EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
| EFI_IMAGE_SCN_MEM_READ);
- NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = HiiBinSize;
+ NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = RelocOffset - HiiRsrcOffset;
NtHdr->Pe32.OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = HiiRsrcOffset;
-
- memcpy(CoffFile + HiiRsrcOffset, HiiBinData, HiiBinSize);
- free (HiiBinData);
- HiiBinData = NULL;
- HiiBinSize = 0;
} else {
// Don't make a section of size 0.
NtHdr->Pe32.FileHeader.NumberOfSections--;
@@ -1398,6 +1333,7 @@ ConvertElf (
//
WriteSections(IsTextShdr);
WriteSections(IsDataShdr);
+ WriteSections(IsHiiRsrcShdr);
VerboseMsg ("Write and relocate sections.");
//
@@ -1430,6 +1366,279 @@ ConvertElf (
}
}
+
+EFI_IMAGE_OPTIONAL_HEADER_UNION *
+GetPeCoffHeader (
+ void *Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr;
+
+ //
+ // Read the dos & pe hdrs of the image
+ //
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Data;
+ if (DosHdr->e_magic != EFI_IMAGE_DOS_SIGNATURE) {
+ // NO DOS header, check for PE/COFF header
+ PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(Data);
+ if (PeHdr->Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {
+ return NULL;
+ }
+ } else {
+
+ PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)(((UINT8 *)Data) + DosHdr->e_lfanew);
+ if (PeHdr->Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {
+ return NULL;
+ }
+ }
+
+ return PeHdr;
+}
+
+void
+PeCoffConvertImageToXip (
+ UINT8 **FileBuffer,
+ UINT32 *FileLength
+ )
+{
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *NewPeHdr;
+ EFI_IMAGE_SECTION_HEADER *SectionHeader;
+ UINTN TotalNecessaryFileSize;
+ UINTN SectionSize;
+ UINT8 *XipFile;
+ UINT32 XipLength;
+ UINTN Index;
+ UINTN FirstSectionOffset;
+ BOOLEAN ConversionNeeded;
+
+ PeHdr = GetPeCoffHeader ((void *) *FileBuffer);
+ if (PeHdr == NULL) {
+ return;
+ }
+
+ if (PeHdr->Pe32.OptionalHeader.SectionAlignment != PeHdr->Pe32.OptionalHeader.FileAlignment) {
+ //
+ // The only reason to expand zero fill sections is to make them compatible with XIP images.
+ // If SectionAlignment is not equal to FileAlginment then it is not an XIP type image.
+ //
+ return;
+ }
+
+ //
+ // Calculate size of XIP file, and determine if the conversion is needed.
+ //
+ ConversionNeeded = FALSE;
+ XipLength = 0;
+ FirstSectionOffset = *FileLength;
+ TotalNecessaryFileSize = 0;
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
+ for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
+ SectionSize = MAX (SectionHeader->Misc.VirtualSize, SectionHeader->SizeOfRawData);
+ TotalNecessaryFileSize += SectionSize;
+ if (SectionSize > 0) {
+ FirstSectionOffset = MIN (FirstSectionOffset, SectionHeader->VirtualAddress);
+ XipLength = MAX (XipLength, SectionHeader->VirtualAddress + SectionSize);
+ if (SectionHeader->VirtualAddress != SectionHeader->PointerToRawData) {
+ ConversionNeeded = TRUE;
+ }
+ }
+ if (SectionHeader->Misc.VirtualSize > SectionHeader->SizeOfRawData) {
+ ConversionNeeded = TRUE;
+ }
+ }
+
+ if (FirstSectionOffset < PeHdr->Pe32.OptionalHeader.SizeOfHeaders) {
+ //
+ // If one of the sections should be loaded to an offset overlapping with
+ // the executable header, then it cannot be made into an XIP image.
+ //
+ VerboseMsg ("PE/COFF conversion to XIP is impossible due to overlap");
+ VerboseMsg ("of section data with the executable header.");
+ return;
+ }
+
+ if (FirstSectionOffset == *FileLength) {
+ //
+ // If we never found a section with a non-zero size, then we
+ // skip the conversion.
+ //
+ return;
+ }
+
+ TotalNecessaryFileSize += FirstSectionOffset;
+
+ if (!ConversionNeeded) {
+ return;
+ }
+
+ if (XipLength > (2 * TotalNecessaryFileSize)) {
+ VerboseMsg ("PE/COFF conversion to XIP appears to be larger than necessary.");
+ VerboseMsg ("The image linking process may have left unused memory ranges.");
+ }
+
+ if (PeHdr->Pe32.FileHeader.PointerToSymbolTable != 0) {
+ //
+ // This field is obsolete and should be zero
+ //
+ PeHdr->Pe32.FileHeader.PointerToSymbolTable = 0;
+ }
+
+ //
+ // Allocate the extra space that we need to grow the image
+ //
+ XipFile = malloc (XipLength);
+ memset (XipFile, 0, XipLength);
+
+ //
+ // Copy the file headers
+ //
+ memcpy (XipFile, *FileBuffer, PeHdr->Pe32.OptionalHeader.SizeOfHeaders);
+
+ NewPeHdr = GetPeCoffHeader ((void *)XipFile);
+ if (NewPeHdr == NULL) {
+ free (XipFile);
+ return;
+ }
+
+ //
+ // Copy the section data over to the appropriate XIP offsets
+ //
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(NewPeHdr->Pe32.OptionalHeader) + NewPeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
+ for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
+ if (SectionHeader->SizeOfRawData > 0) {
+ memcpy (
+ XipFile + SectionHeader->VirtualAddress,
+ *FileBuffer + SectionHeader->PointerToRawData,
+ SectionHeader->SizeOfRawData
+ );
+ }
+ SectionHeader->SizeOfRawData = SectionHeader->Misc.VirtualSize;
+ SectionHeader->PointerToRawData = SectionHeader->VirtualAddress;
+ }
+
+ free (*FileBuffer);
+ *FileLength = XipLength;
+ *FileBuffer = XipFile;
+}
+
+UINT8 *
+CreateHiiResouceSectionHeader (
+ UINT32 *pSectionHeaderSize,
+ UINT32 HiiDataSize
+ )
+/*++
+
+Routine Description:
+
+ Create COFF resource section header
+
+Arguments:
+
+ pSectionHeaderSize - Pointer to section header size.
+ HiiDataSize - Size of the total HII data in section.
+
+Returns:
+ The created section header buffer.
+
+--*/
+{
+ UINT32 HiiSectionHeaderSize;
+ UINT32 HiiSectionOffset;
+ UINT8 *HiiSectionHeader;
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *TypeResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *NameResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *LanguageResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+
+ //
+ // Calculate the total size for the resource header (include Type, Name and Language)
+ // then allocate memory for the resource header.
+ //
+ HiiSectionHeaderSize = 3 * (sizeof (EFI_IMAGE_RESOURCE_DIRECTORY) + sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY))
+ + 3 * (sizeof (UINT16) + 3 * sizeof (CHAR16))
+ + sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
+ HiiSectionHeader = malloc (HiiSectionHeaderSize);
+ memset (HiiSectionHeader, 0, HiiSectionHeaderSize);
+
+ HiiSectionOffset = 0;
+ //
+ // Create Type entry
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
+ ResourceDirectory->NumberOfNamedEntries = 1;
+ TypeResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
+ TypeResourceDirectoryEntry->u1.s.NameIsString = 1;
+ TypeResourceDirectoryEntry->u2.s.DataIsDirectory = 1;
+ TypeResourceDirectoryEntry->u2.s.OffsetToDirectory = HiiSectionOffset;
+ //
+ // Create Name entry
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
+ ResourceDirectory->NumberOfNamedEntries = 1;
+ NameResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
+ NameResourceDirectoryEntry->u1.s.NameIsString = 1;
+ NameResourceDirectoryEntry->u2.s.DataIsDirectory = 1;
+ NameResourceDirectoryEntry->u2.s.OffsetToDirectory = HiiSectionOffset;
+ //
+ // Create Language entry
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY);
+ ResourceDirectory->NumberOfNamedEntries = 1;
+ LanguageResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY);
+ LanguageResourceDirectoryEntry->u1.s.NameIsString = 1;
+ //
+ // Create string entry for Type
+ //
+ TypeResourceDirectoryEntry->u1.s.NameOffset = HiiSectionOffset;
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiSectionHeader + HiiSectionOffset);
+ ResourceDirectoryString->Length = 3;
+ ResourceDirectoryString->String[0] = L'H';
+ ResourceDirectoryString->String[1] = L'I';
+ ResourceDirectoryString->String[2] = L'I';
+ HiiSectionOffset = HiiSectionOffset + sizeof (ResourceDirectoryString->Length) + ResourceDirectoryString->Length * sizeof (ResourceDirectoryString->String[0]);
+ //
+ // Create string entry for Name
+ //
+ NameResourceDirectoryEntry->u1.s.NameOffset = HiiSectionOffset;
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiSectionHeader + HiiSectionOffset);
+ ResourceDirectoryString->Length = 3;
+ ResourceDirectoryString->String[0] = L'E';
+ ResourceDirectoryString->String[1] = L'F';
+ ResourceDirectoryString->String[2] = L'I';
+ HiiSectionOffset = HiiSectionOffset + sizeof (ResourceDirectoryString->Length) + ResourceDirectoryString->Length * sizeof (ResourceDirectoryString->String[0]);
+ //
+ // Create string entry for Language
+ //
+ LanguageResourceDirectoryEntry->u1.s.NameOffset = HiiSectionOffset;
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (HiiSectionHeader + HiiSectionOffset);
+ ResourceDirectoryString->Length = 3;
+ ResourceDirectoryString->String[0] = L'B';
+ ResourceDirectoryString->String[1] = L'I';
+ ResourceDirectoryString->String[2] = L'N';
+ HiiSectionOffset = HiiSectionOffset + sizeof (ResourceDirectoryString->Length) + ResourceDirectoryString->Length * sizeof (ResourceDirectoryString->String[0]);
+ //
+ // Create Leaf data
+ //
+ LanguageResourceDirectoryEntry->u2.OffsetToData = HiiSectionOffset;
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (HiiSectionHeader + HiiSectionOffset);
+ HiiSectionOffset += sizeof (EFI_IMAGE_RESOURCE_DATA_ENTRY);
+ ResourceDataEntry->OffsetToData = HiiSectionOffset;
+ ResourceDataEntry->Size = HiiDataSize;
+
+ *pSectionHeaderSize = HiiSectionHeaderSize;
+ return HiiSectionHeader;
+}
+
int
main (
int argc,
@@ -1501,6 +1710,8 @@ Returns:
EFI_IFR_FORM_SET IfrFormSet;
UINT8 NumberOfFormPacakge;
EFI_HII_PACKAGE_HEADER EndPackage;
+ UINT32 HiiSectionHeaderSize;
+ UINT8 *HiiSectionHeader;
SetUtilityName (UTILITY_NAME);
@@ -1539,6 +1750,8 @@ Returns:
EndPackage.Length = sizeof (EFI_HII_PACKAGE_HEADER);
EndPackage.Type = EFI_HII_PACKAGE_END;
memset (&HiiPackageListGuid, 0, sizeof (HiiPackageListGuid));
+ HiiSectionHeaderSize = 0;
+ HiiSectionHeader = NULL;
if (argc == 1) {
Error (NULL, 0, 1001, "Missing options", "No input options.");
@@ -1748,6 +1961,13 @@ Returns:
continue;
}
+ if (stricmp (argv[0], "--hiibinpackage") == 0) {
+ OutImageType = FW_HII_PACKAGE_LIST_BINIMAGE;
+ argc --;
+ argv ++;
+ continue;
+ }
+
if (argv[0][0] == '-') {
Error (NULL, 0, 1000, "Unknown option", argv[0]);
goto Finish;
@@ -1819,6 +2039,11 @@ Returns:
goto Finish;
}
+ if ((OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) && ReplaceFlag) {
+ Error (NULL, 0, 1002, "Conflicting option", "-r replace option cannot be used with --hiibinpackage merge files option.");
+ goto Finish;
+ }
+
//
// Input image file
//
@@ -1862,6 +2087,9 @@ Returns:
case FW_HII_PACKAGE_LIST_RCIMAGE:
VerboseMsg ("Combine the input multi hii bin packages to one text pacakge list RC file.");
break;
+ case FW_HII_PACKAGE_LIST_BINIMAGE:
+ VerboseMsg ("Combine the input multi hii bin packages to one binary pacakge list file.");
+ break;
default:
break;
}
@@ -1903,9 +2131,9 @@ Returns:
}
//
- // Combine multi binary HII package files to a single text package list RC file.
+ // Combine multi binary HII package files.
//
- if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) {
+ if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE || OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
//
// Get hii package list lenght
//
@@ -1970,37 +2198,64 @@ Returns:
HiiPackageDataPointer = HiiPackageDataPointer + FileLength;
}
memcpy (HiiPackageDataPointer, &EndPackage, sizeof (EndPackage));
+
//
- // write the hii package into the text package list rc file.
+ // write the hii package into the binary package list file with the resource section header
//
- for (Index = 0; gHiiPackageRCFileHeader[Index] != NULL; Index++) {
- fprintf (fpOut, "%s\n", gHiiPackageRCFileHeader[Index]);
+ if (OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
+ //
+ // Create the resource section header
+ //
+ HiiSectionHeader = CreateHiiResouceSectionHeader (&HiiSectionHeaderSize, HiiPackageListHeader.PackageLength);
+ //
+ // Wrtie section header and HiiData into File.
+ //
+ fwrite (HiiSectionHeader, 1, HiiSectionHeaderSize, fpOut);
+ fwrite (HiiPackageListBuffer, 1, HiiPackageListHeader.PackageLength, fpOut);
+ //
+ // Free allocated resources.
+ //
+ free (HiiSectionHeader);
+ free (HiiPackageListBuffer);
+ //
+ // Done successfully
+ //
+ goto Finish;
}
- fprintf (fpOut, "\n%d %s\n{", HII_RESOURCE_SECTION_INDEX, HII_RESOURCE_SECTION_NAME);
- HiiPackageDataPointer = HiiPackageListBuffer;
- for (Index = 0; Index + 2 < HiiPackageListHeader.PackageLength; Index += 2) {
+ //
+ // write the hii package into the text package list rc file.
+ //
+ if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) {
+ for (Index = 0; gHiiPackageRCFileHeader[Index] != NULL; Index++) {
+ fprintf (fpOut, "%s\n", gHiiPackageRCFileHeader[Index]);
+ }
+ fprintf (fpOut, "\n%d %s\n{", HII_RESOURCE_SECTION_INDEX, HII_RESOURCE_SECTION_NAME);
+
+ HiiPackageDataPointer = HiiPackageListBuffer;
+ for (Index = 0; Index + 2 < HiiPackageListHeader.PackageLength; Index += 2) {
+ if (Index % 16 == 0) {
+ fprintf (fpOut, "\n ");
+ }
+ fprintf (fpOut, " 0x%04X,", *(UINT16 *) HiiPackageDataPointer);
+ HiiPackageDataPointer += 2;
+ }
+
if (Index % 16 == 0) {
fprintf (fpOut, "\n ");
}
- fprintf (fpOut, " 0x%04X,", *(UINT16 *) HiiPackageDataPointer);
- HiiPackageDataPointer += 2;
- }
-
- if (Index % 16 == 0) {
- fprintf (fpOut, "\n ");
- }
- if ((Index + 2) == HiiPackageListHeader.PackageLength) {
- fprintf (fpOut, " 0x%04X\n}\n", *(UINT16 *) HiiPackageDataPointer);
- }
- if ((Index + 1) == HiiPackageListHeader.PackageLength) {
- fprintf (fpOut, " 0x%04X\n}\n", *(UINT8 *) HiiPackageDataPointer);
+ if ((Index + 2) == HiiPackageListHeader.PackageLength) {
+ fprintf (fpOut, " 0x%04X\n}\n", *(UINT16 *) HiiPackageDataPointer);
+ }
+ if ((Index + 1) == HiiPackageListHeader.PackageLength) {
+ fprintf (fpOut, " 0x%04X\n}\n", *(UINT8 *) HiiPackageDataPointer);
+ }
+ free (HiiPackageListBuffer);
+ //
+ // Done successfully
+ //
+ goto Finish;
}
- free (HiiPackageListBuffer);
- //
- // Done successfully
- //
- goto Finish;
}
//
@@ -2271,7 +2526,6 @@ Returns:
stricmp (ModuleType, "DXE_DRIVER") == 0 ||
stricmp (ModuleType, "DXE_SMM_DRIVER") == 0 ||
stricmp (ModuleType, "UEFI_DRIVER") == 0 ||
- stricmp (ModuleType, "SMM_DRIVER") == 0 ||
stricmp (ModuleType, "SMM_CORE") == 0) {
Type = EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;
VerboseMsg ("Efi Image subsystem type is efi boot service driver.");
@@ -2305,6 +2559,12 @@ Returns:
VerboseMsg ("Convert the input ELF Image to Pe Image");
ConvertElf(&FileBuffer, &FileLength);
}
+
+ //
+ // Make sure File Offsets and Virtual Offsets are the same in the image so it is XIP
+ // XIP == eXecute In Place
+ //
+ PeCoffConvertImageToXip (&FileBuffer, &FileLength);
//
// Remove reloc section from PE or TE image
@@ -2771,7 +3031,37 @@ Returns:
TEImageHeader.DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress = Optional64->SizeOfImage - sizeof (EFI_IMAGE_BASE_RELOCATION);
}
}
-
+
+ //
+ // Fill HII section data
+ //
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
+ for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index++) {
+ if (stricmp ((char *)SectionHeader[Index].Name, ".hii") == 0) {
+ //
+ // Update resource section header offset
+ //
+ SetHiiResourceHeader ((UINT8*) FileBuffer + SectionHeader[Index].PointerToRawData, SectionHeader[Index].VirtualAddress);
+ //
+ // Update resource section name
+ //
+ strcpy((char *) SectionHeader[Index].Name, ".rsrc");
+ //
+ // Update resource data directory.
+ //
+ if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ Optional32 = (EFI_IMAGE_OPTIONAL_HEADER32 *)&PeHdr->Pe32.OptionalHeader;
+ Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = SectionHeader[Index].VirtualAddress;
+ Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = SectionHeader[Index].Misc.VirtualSize;
+ } else if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ Optional64 = (EFI_IMAGE_OPTIONAL_HEADER64 *)&PeHdr->Pe32.OptionalHeader;
+ Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = SectionHeader[Index].VirtualAddress;
+ Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE].Size = SectionHeader[Index].Misc.VirtualSize;
+ }
+ break;
+ }
+ }
+
//
// Zero ExceptionTable Xdata
//
@@ -3311,7 +3601,7 @@ Returns:
//
// strip space
//
- for (cptr = Line; *cptr && isspace(*cptr); cptr++) {
+ for (cptr = Line; *cptr && isspace((int)*cptr); cptr++) {
}
// Skip Blank Lines and Comment Lines
@@ -3326,14 +3616,14 @@ Returns:
// DD XXXXXXXXX
// DD XXXXXXXXX
//
- if ((tolower(cptr[0]) == 'd') && (tolower(cptr[1]) == 'd') && isspace (cptr[2])) {
+ if ((tolower((int)cptr[0]) == 'd') && (tolower((int)cptr[1]) == 'd') && isspace ((int)cptr[2])) {
//
// Skip blanks and look for a hex digit
//
cptr += 3;
- for (; *cptr && isspace(*cptr); cptr++) {
+ for (; *cptr && isspace((int)*cptr); cptr++) {
}
- if (isxdigit (*cptr)) {
+ if (isxdigit ((int)*cptr)) {
if (sscanf (cptr, "%X", &ScannedData) != 1) {
return STATUS_ERROR;
}
diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
index 32b8cfd5a0..9a1d0ca48a 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -938,7 +938,7 @@ Returns:
// Verify string is a integrator number
//
for (Index = 0; Index < strlen (argv[1]); Index++) {
- if ((argv[1][Index] != '-') && (isdigit (argv[1][Index]) == 0)) {
+ if ((argv[1][Index] != '-') && (isdigit ((int)argv[1][Index]) == 0)) {
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
goto Finish;
}
diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c
index 890cfd98fd..2e417bf563 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.c
+++ b/BaseTools/Source/C/GenVtf/GenVtf.c
@@ -1,13 +1,13 @@
/**
-Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved
-This software and associated documentation (if any) is furnished
-under a license and may only be used or copied in accordance
-with the terms of the license. Except as permitted by such
-license, no part of this software or documentation may be
-reproduced, stored in a retrieval system, or transmitted in any
-form or by any means without the express written consent of
-Intel Corporation.
+Copyright (c) 1999-2008 Intel Corporation. All rights reserved
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the BSD License which accompanies this
+distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
diff --git a/BaseTools/Source/C/GenVtf/GenVtf.h b/BaseTools/Source/C/GenVtf/GenVtf.h
index 012ebb672a..a1d9f936fe 100644
--- a/BaseTools/Source/C/GenVtf/GenVtf.h
+++ b/BaseTools/Source/C/GenVtf/GenVtf.h
@@ -1,13 +1,13 @@
/** @file
-Copyright (c) 1999 - 2008 Intel Corporation. All rights reserved
-This software and associated documentation (if any) is furnished
-under a license and may only be used or copied in accordance
-with the terms of the license. Except as permitted by such
-license, no part of this software or documentation may be
-reproduced, stored in a retrieval system, or transmitted in any
-form or by any means without the express written consent of
-Intel Corporation.
+Copyright (c) 1999-2008 Intel Corporation. All rights reserved
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the BSD License which accompanies this
+distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
diff --git a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
index 5e926ac08d..e76ffd317c 100644
--- a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
+++ b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h
@@ -674,6 +674,7 @@ typedef union {
#define EFI_IFR_DEFAULTSTORE_OP 0x5C
#define EFI_IFR_CATENATE_OP 0x5E
#define EFI_IFR_GUID_OP 0x5F
+#define EFI_IFR_SECURITY_OP 0x60
typedef struct _EFI_IFR_OP_HEADER {
@@ -1276,6 +1277,17 @@ typedef struct _EFI_IFR_SPAN {
UINT8 Flags;
} EFI_IFR_SPAN;
+typedef struct _EFI_IFR_SECURITY {
+ ///
+ /// Standard opcode header, where Header.Op = EFI_IFR_SECURITY_OP.
+ ///
+ EFI_IFR_OP_HEADER Header;
+ ///
+ /// Security permission level.
+ ///
+ EFI_GUID Permissions;
+} EFI_IFR_SECURITY;
+
//
// Keyboard Package
//
diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
index 57cbc2366b..69cca91c31 100644
--- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
+++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
@@ -638,6 +638,18 @@ typedef struct {
//
} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
+///
+/// Debug Data Structure defined by Apple Mach-O to Coff utility
+///
+#define CODEVIEW_SIGNATURE_MTOC EFI_SIGNATURE_32('M', 'T', 'O', 'C')
+typedef struct {
+ UINT32 Signature; ///< "MTOC"
+ EFI_GUID MachOUuid;
+ //
+ // Filename of .DLL (Mach-O with debug info) goes here
+ //
+} EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY;
+
//
// .pdata entries for X64
//
diff --git a/BaseTools/Source/C/Include/X64/ProcessorBind.h b/BaseTools/Source/C/Include/X64/ProcessorBind.h
index 5b2ad46637..5d79d89d13 100644
--- a/BaseTools/Source/C/Include/X64/ProcessorBind.h
+++ b/BaseTools/Source/C/Include/X64/ProcessorBind.h
@@ -27,7 +27,9 @@
//
// Make sure we are useing the correct packing rules per EFI specification
//
+#ifndef __GNUC__
#pragma pack()
+#endif
#if _MSC_EXTENSIONS
diff --git a/BaseTools/Source/C/Makefiles/app.makefile b/BaseTools/Source/C/Makefiles/app.makefile
index 7555556baa..2f95003646 100644
--- a/BaseTools/Source/C/Makefiles/app.makefile
+++ b/BaseTools/Source/C/Makefiles/app.makefile
@@ -8,6 +8,6 @@ APPLICATION = $(MAKEROOT)/bin/$(APPNAME)
all: $(MAKEROOT)/bin $(APPLICATION)
$(APPLICATION): $(OBJECTS)
- $(LINKER) -o $(APPLICATION) $(OBJECTS) -L$(MAKEROOT)/libs $(LIBS)
+ $(LINKER) -o $(APPLICATION) $(LFLAGS) $(OBJECTS) -L$(MAKEROOT)/libs $(LIBS)
include $(MAKEROOT)/Makefiles/footer.makefile
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile
index a4dc2255e7..5f69e7b04e 100644
--- a/BaseTools/Source/C/Makefiles/header.makefile
+++ b/BaseTools/Source/C/Makefiles/header.makefile
@@ -26,7 +26,19 @@ endif
INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE)
CPPFLAGS = $(INCLUDE)
CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g
+LFLAGS =
+#
+# Snow Leopard is a 32-bit and 64-bit environment. uname -m returns -i386, but gcc defaults
+# to x86_64. So make sure tools match uname -m
+#
+uname_s = $(shell uname -s)
+ifeq ($(uname_s),Darwin)
+ CFLAGS += -arch i386
+ CPPFLAGS += -arch i386
+ LFLAGS += -arch i386
+endif
+
.PHONY: all
.PHONY: install
.PHONY: clean
diff --git a/BaseTools/Source/C/Split/Split.c b/BaseTools/Source/C/Split/Split.c
index 22e1a2be49..d5fe738a2c 100644
--- a/BaseTools/Source/C/Split/Split.c
+++ b/BaseTools/Source/C/Split/Split.c
@@ -124,14 +124,14 @@ GetSplitValue (
}
}
- lastCHAR = (CHAR8)toupper(SplitValueString[len - 1]);
+ lastCHAR = (CHAR8)toupper((int)SplitValueString[len - 1]);
if (lastCHAR != 'K' && lastCHAR != 'M' && lastCHAR != 'G') {
return STATUS_ERROR;
}
for (;index < len - 1; ++index) {
- if (!isdigit(SplitValueString[index])) {
+ if (!isdigit((int)SplitValueString[index])) {
return EFI_ABORTED;
}
}
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
index 87da95af71..ffa898bdbe 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp
@@ -1301,6 +1301,7 @@ static struct {
{ 0, 0}, // 0x5D
{ sizeof (EFI_IFR_CATENATE), 0 }, // EFI_IFR_CATENATE_OP
{ sizeof (EFI_IFR_GUID), 0 }, // EFI_IFR_GUID_OP
+ { sizeof (EFI_IFR_SECURITY), 0 }, // EFI_IFR_SECURITY_OP - 0x60
};
#ifdef CIFROBJ_DEUBG
@@ -1323,6 +1324,7 @@ static struct {
"EFI_IFR_STRING_REF1","EFI_IFR_STRING_REF2", "EFI_IFR_CONDITIONAL", "EFI_IFR_QUESTION_REF3", "EFI_IFR_ZERO", "EFI_IFR_ONE",
"EFI_IFR_ONES", "EFI_IFR_UNDEFINED", "EFI_IFR_LENGTH", "EFI_IFR_DUP", "EFI_IFR_THIS", "EFI_IFR_SPAN",
"EFI_IFR_VALUE", "EFI_IFR_DEFAULT", "EFI_IFR_DEFAULTSTORE", "EFI_IFR_INVALID", "EFI_IFR_CATENATE", "EFI_IFR_GUID",
+ "EFI_IFR_SECURITY",
};
VOID
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 324078a148..0b84896cc9 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -398,49 +398,159 @@ public:
}
};
-static CIfrQuestionHeader *gCurrentQuestion = NULL;
-static CIfrObj *gCurrentIfrOpcode = NULL;
-
/*
* The definition of CIfrMinMaxStepData
*/
class CIfrMinMaxStepData {
private:
MINMAXSTEP_DATA *mMinMaxStepData;
+ BOOLEAN ValueIsSet;
+ BOOLEAN IsNumeric;
public:
- CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr) : mMinMaxStepData (DataAddr) {
+ CIfrMinMaxStepData (MINMAXSTEP_DATA *DataAddr, BOOLEAN NumericOpcode=FALSE) : mMinMaxStepData (DataAddr) {
mMinMaxStepData->u64.MinValue = 0;
mMinMaxStepData->u64.MaxValue = 0;
mMinMaxStepData->u64.Step = 0;
+ ValueIsSet = FALSE;
+ IsNumeric = NumericOpcode;
}
VOID SetMinMaxStepData (IN UINT64 MinValue, IN UINT64 MaxValue, IN UINT64 Step) {
- mMinMaxStepData->u64.MinValue = MinValue;
- mMinMaxStepData->u64.MaxValue = MaxValue;
- mMinMaxStepData->u64.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u64.MinValue) {
+ mMinMaxStepData->u64.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u64.MaxValue) {
+ mMinMaxStepData->u64.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u64.Step = Step;
}
VOID SetMinMaxStepData (IN UINT32 MinValue, IN UINT32 MaxValue, IN UINT32 Step) {
- mMinMaxStepData->u32.MinValue = MinValue;
- mMinMaxStepData->u32.MaxValue = MaxValue;
- mMinMaxStepData->u32.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u32.MinValue) {
+ mMinMaxStepData->u32.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u32.MaxValue) {
+ mMinMaxStepData->u32.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u32.Step = Step;
}
VOID SetMinMaxStepData (IN UINT16 MinValue, IN UINT16 MaxValue, IN UINT16 Step) {
- mMinMaxStepData->u16.MinValue = MinValue;
- mMinMaxStepData->u16.MaxValue = MaxValue;
- mMinMaxStepData->u16.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u16.MinValue) {
+ mMinMaxStepData->u16.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u16.MaxValue) {
+ mMinMaxStepData->u16.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u16.Step = Step;
}
VOID SetMinMaxStepData (IN UINT8 MinValue, IN UINT8 MaxValue, IN UINT8 Step) {
- mMinMaxStepData->u8.MinValue = MinValue;
- mMinMaxStepData->u8.MaxValue = MaxValue;
- mMinMaxStepData->u8.Step = Step;
+ if (!ValueIsSet) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ ValueIsSet = TRUE;
+ } else {
+ if (MinValue < mMinMaxStepData->u8.MinValue) {
+ mMinMaxStepData->u8.MinValue = MinValue;
+ }
+ if (MaxValue > mMinMaxStepData->u8.MaxValue) {
+ mMinMaxStepData->u8.MaxValue = MaxValue;
+ }
+ }
+ mMinMaxStepData->u8.Step = Step;
+ }
+
+ UINT64 GetMinData (UINT8 VarType) {
+ UINT64 MinValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MinValue = mMinMaxStepData->u64.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MinValue = (UINT64) mMinMaxStepData->u32.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MinValue = (UINT64) mMinMaxStepData->u16.MinValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MinValue = (UINT64) mMinMaxStepData->u8.MinValue;
+ break;
+ default:
+ break;
+ }
+ return MinValue;
+ }
+
+ UINT64 GetMaxData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.MaxValue;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.MaxValue;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
+ }
+
+ UINT64 GetStepData (UINT8 VarType) {
+ UINT64 MaxValue = 0;
+ switch (VarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ MaxValue = mMinMaxStepData->u64.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ MaxValue = (UINT64) mMinMaxStepData->u32.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ MaxValue = (UINT64) mMinMaxStepData->u16.Step;
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ MaxValue = (UINT64) mMinMaxStepData->u8.Step;
+ break;
+ default:
+ break;
+ }
+ return MaxValue;
}
+ BOOLEAN IsNumericOpcode () {
+ return IsNumeric;
+ }
};
+static CIfrQuestionHeader *gCurrentQuestion = NULL;
+static CIfrMinMaxStepData *gCurrentMinMaxData = NULL;
+
/*
* The definition of all of the UEFI IFR Objects
*/
@@ -979,15 +1089,15 @@ public:
CIfrNumeric () : CIfrObj (EFI_IFR_NUMERIC_OP, (CHAR8 **)&mNumeric),
CIfrOpHeader (EFI_IFR_NUMERIC_OP, &mNumeric->Header),
CIfrQuestionHeader (&mNumeric->Question),
- CIfrMinMaxStepData (&mNumeric->data) {
+ CIfrMinMaxStepData (&mNumeric->data, TRUE) {
mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC;
- gCurrentQuestion = this;
- gCurrentIfrOpcode = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrNumeric () {
- gCurrentQuestion = NULL;
- gCurrentIfrOpcode = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -1017,13 +1127,13 @@ public:
CIfrQuestionHeader (&mOneOf->Question),
CIfrMinMaxStepData (&mOneOf->data) {
mOneOf->Flags = 0;
- gCurrentQuestion = this;
- gCurrentIfrOpcode = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrOneOf () {
- gCurrentQuestion = NULL;
- gCurrentIfrOpcode = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -1772,6 +1882,24 @@ public:
}
};
+class CIfrSecurity : public CIfrObj, public CIfrOpHeader {
+private:
+ EFI_IFR_SECURITY *mSecurity;
+
+public:
+ CIfrSecurity (
+ IN UINT32 LineNo
+ ) : CIfrObj (EFI_IFR_SECURITY_OP, (CHAR8 **)&mSecurity),
+ CIfrOpHeader (EFI_IFR_SECURITY_OP, &mSecurity->Header) {
+ SetLineNo (LineNo);
+ memset (&mSecurity->Permissions, 0, sizeof (EFI_GUID));
+ }
+
+ VOID SetPermissions (IN EFI_GUID *Permissions) {
+ memcpy (&mSecurity->Permissions, Permissions, sizeof (EFI_GUID));
+ }
+};
+
class CIfrUint8 : public CIfrObj, public CIfrOpHeader {
private:
EFI_IFR_UINT8 *mUint8;
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index ea529a5e15..09ec6919ec 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -1,5 +1,5 @@
/*++
-Copyright (c) 2004 - 2008, Intel Corporation
+Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -547,7 +547,8 @@ vfrFormSetList :
vfrStatementVarStoreEfi |
vfrStatementVarStoreNameValue |
vfrStatementDefaultStore |
- vfrStatementDisableIfFormSet
+ vfrStatementDisableIfFormSet |
+ vfrStatementSuppressIfFormSet
)*
;
@@ -720,6 +721,21 @@ vfrStatementDisableIfFormSet :
";"
;
+vfrStatementSuppressIfFormSet :
+ << CIfrSuppressIf SIObj;>>
+ L:SuppressIf <<
+ if (mCompatibleMode) {
+ _PCATCH (VFR_RETURN_UNSUPPORTED, L);
+ }
+ SIObj.SetLineNo(L->getLine());
+ >>
+ { FLAGS "=" flagsField ( "\|" flagsField )* "," }
+ vfrStatementExpression[0] ";"
+ vfrFormSetList
+ E: EndIf
+ ";" << CRT_END_OP (E); >>
+ ;
+
//*****************************************************************************
//
// the syntax of question header and statement header
@@ -1089,66 +1105,10 @@ vfrStatementDefault :
(
vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
| "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," <<
-
- if (gCurrentIfrOpcode != NULL && gCurrentIfrOpcode->GetObjBinAddr() != NULL) {
- EFI_IFR_OP_HEADER *TempOpCode;
- TempOpCode = (EFI_IFR_OP_HEADER *) gCurrentIfrOpcode->GetObjBinAddr();
- switch (TempOpCode->OpCode) {
- case EFI_IFR_NUMERIC_OP:
- EFI_IFR_NUMERIC *TempNumricCode;
- TempNumricCode = (EFI_IFR_NUMERIC *) TempOpCode;
- switch (_GET_CURRQEST_DATATYPE()) {
- case EFI_IFR_TYPE_NUM_SIZE_64:
- if (Val.u64 < TempNumricCode->data.u64.MinValue || Val.u64 > TempNumricCode->data.u64.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32:
- if (Val.u32 < TempNumricCode->data.u32.MinValue || Val.u32 > TempNumricCode->data.u32.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16:
- if (Val.u16 < TempNumricCode->data.u16.MinValue || Val.u16 > TempNumricCode->data.u16.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8:
- if (Val.u8 < TempNumricCode->data.u8.MinValue || Val.u8 > TempNumricCode->data.u8.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
- }
- break;
- }
- break;
- case EFI_IFR_ONE_OF_OP:
- EFI_IFR_ONE_OF *TempOneOfCode;
- TempOneOfCode = (EFI_IFR_ONE_OF *) TempOpCode;
- if (TempOneOfCode->data.u64.MinValue != 0 || TempOneOfCode->data.u64.MaxValue != 0 || TempOneOfCode->data.u64.Step != 0) {
- //OneOf MinMaxStep Data is set, Val value will be checked for MinMaxStep.
- switch (_GET_CURRQEST_DATATYPE()) {
- case EFI_IFR_TYPE_NUM_SIZE_64:
- if (Val.u64 < TempOneOfCode->data.u64.MinValue || Val.u64 > TempOneOfCode->data.u64.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_32:
- if (Val.u32 < TempOneOfCode->data.u32.MinValue || Val.u32 > TempOneOfCode->data.u32.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_16:
- if (Val.u16 < TempOneOfCode->data.u16.MinValue || Val.u16 > TempOneOfCode->data.u16.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue.");
- }
- break;
- case EFI_IFR_TYPE_NUM_SIZE_8:
- if (Val.u8 < TempOneOfCode->data.u8.MinValue || Val.u8 > TempOneOfCode->data.u8.MaxValue) {
- _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue.");
- }
- break;
- }
- }
- break;
+ if (gCurrentMinMaxData != NULL && gCurrentMinMaxData->IsNumericOpcode()) {
+ //check default value is valid for Numeric Opcode
+ if (Val.u64 < gCurrentMinMaxData->GetMinData(_GET_CURRQEST_DATATYPE()) || Val.u64 > gCurrentMinMaxData->GetMaxData(_GET_CURRQEST_DATATYPE())) {
+ _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue.");
}
}
DObj.SetType (_GET_CURRQEST_DATATYPE());
@@ -1711,7 +1671,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
>>
Minimum "=" I:Number ","
<<
- switch (_GET_CURRQEST_DATATYPE ()) {
+ switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 : MinU8 = _STOU64(I->getText()); break;
case EFI_IFR_TYPE_NUM_SIZE_32 : MinU4 = _STOU32(I->getText()); break;
case EFI_IFR_TYPE_NUM_SIZE_16 : MinU2 = _STOU16(I->getText()); break;
@@ -1720,7 +1680,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
>>
Maximum "=" A:Number ","
<<
- switch (_GET_CURRQEST_DATATYPE ()) {
+ switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 :
MaxU8 = _STOU64(A->getText());
if (MaxU8 < MinU8) {
@@ -1750,7 +1710,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
{
STEP "=" S:Number ","
<<
- switch (_GET_CURRQEST_DATATYPE ()) {
+ switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 : StepU8 = _STOU64(S->getText()); break;
case EFI_IFR_TYPE_NUM_SIZE_32 : StepU4 = _STOU32(S->getText()); break;
case EFI_IFR_TYPE_NUM_SIZE_16 : StepU2 = _STOU16(S->getText()); break;
@@ -1759,7 +1719,7 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] :
>>
}
<<
- switch (_GET_CURRQEST_DATATYPE ()) {
+ switch (_GET_CURRQEST_DATATYPE()) {
case EFI_IFR_TYPE_NUM_SIZE_64 : $MMSDObj.SetMinMaxStepData (MinU8, MaxU8, StepU8); break;
case EFI_IFR_TYPE_NUM_SIZE_32 : $MMSDObj.SetMinMaxStepData (MinU4, MaxU4, StepU4); break;
case EFI_IFR_TYPE_NUM_SIZE_16 : $MMSDObj.SetMinMaxStepData (MinU2, MaxU2, StepU2); break;
@@ -1793,18 +1753,38 @@ vfrStatementNumeric :
vfrNumericFlags [CIfrNumeric & NObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
>>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum); >>
+ <<
+ //check data type flag
+ VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for name/value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
+ }
+ _PCATCH(NObj.SetFlags (HFlags, LFlags), LineNum);
+ >>
;
numericFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
N:Number << _PCATCH(_STOU8(N->getText()) == 0 ? VFR_RETURN_SUCCESS : VFR_RETURN_UNSUPPORTED, N->getLine()); >>
- | "DISPLAY_INT_DEC" << $LFlags |= 0x00; >>
- | "DISPLAY_UINT_DEC" << $LFlags |= 0x10; >>
- | "DISPLAY_UINT_HEX" << $LFlags |= 0x20; >>
+ | "NUMERIC_SIZE_1" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_1; >>
+ | "NUMERIC_SIZE_2" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_2; >>
+ | "NUMERIC_SIZE_4" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_4; >>
+ | "NUMERIC_SIZE_8" << $LFlags = ($LFlags & ~EFI_IFR_NUMERIC_SIZE) | EFI_IFR_NUMERIC_SIZE_8; >>
+ | "DISPLAY_INT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_INT_DEC; >>
+ | "DISPLAY_UINT_DEC" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_DEC; >>
+ | "DISPLAY_UINT_HEX" << $LFlags = ($LFlags & ~EFI_IFR_DISPLAY) | EFI_IFR_DISPLAY_UINT_HEX; >>
| questionheaderFlagsField[HFlags]
;
@@ -1832,11 +1812,27 @@ vfrStatementOneOf :
vfrOneofFlagsField [CIfrOneOf & OObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = _GET_CURRQEST_DATATYPE() & EFI_IFR_NUMERIC_SIZE;
UINT8 HFlags = 0;
+ EFI_VFR_VARSTORE_TYPE VarStoreType = EFI_VFR_VARSTORE_INVALID;
>>
numericFlagsField[HFlags, LFlags] ( "\|" numericFlagsField[HFlags, LFlags] )*
- << _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum); >>
+ <<
+ //check data type flag
+ VarStoreType = mCVfrDataStorage.GetVarStoreType (_GET_CURRQEST_VARTINFO().mVarStoreId);
+ if (VarStoreType == EFI_VFR_VARSTORE_BUFFER || VarStoreType == EFI_VFR_VARSTORE_EFI) {
+ if (_GET_CURRQEST_DATATYPE() != (LFlags & EFI_IFR_NUMERIC_SIZE)) {
+ _PCATCH(VFR_RETURN_INVALID_PARAMETER, LineNum, "Numeric Flag is not same to Numeric VarData type");
+ }
+ } else {
+ // update data type for Name/Value store
+ UINT32 DataTypeSize;
+ _GET_CURRQEST_VARTINFO().mVarType = LFlags & EFI_IFR_NUMERIC_SIZE;
+ gCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
+ }
+ _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
+ >>
;
vfrStatementStringType :
@@ -2080,10 +2076,9 @@ vfrStatementStatListOld :
vfrStatementDisableIfStat :
<<
CIfrDisableIf DIObj;
- mConstantOnlyInExpression = TRUE;
>>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";" << mConstantOnlyInExpression = FALSE; >>
+ vfrStatementExpression[0] ";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
@@ -2227,10 +2222,9 @@ vfrStatementNoSubmitIf :
vfrStatementDisableIfQuest :
<<
CIfrDisableIf DIObj;
- mConstantOnlyInExpression = TRUE;
>>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";" << mConstantOnlyInExpression = FALSE; >>
+ vfrStatementExpression[0] ";"
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -2277,7 +2271,31 @@ vfrStatementOneOfOption :
>>
L:Option << OOOObj.SetLineNo(L->getLine()); >>
Text "=" "STRING_TOKEN" "\(" S:Number "\)" "," << OOOObj.SetOption (_STOSID(S->getText())); >>
- Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] "," << OOOObj.SetType (_GET_CURRQEST_DATATYPE()); OOOObj.SetValue (Val); >>
+ Value "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] >[Val] ","
+ <<
+ if (gCurrentMinMaxData != NULL) {
+ //set min/max value for oneof opcode
+ UINT64 Step = gCurrentMinMaxData->GetStepData(_GET_CURRQEST_DATATYPE());
+ switch (_GET_CURRQEST_DATATYPE()) {
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u64, Val.u64, Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u32, Val.u32, (UINT32) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u16, Val.u16, (UINT16) Step);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ gCurrentMinMaxData->SetMinMaxStepData(Val.u8, Val.u8, (UINT8) Step);
+ break;
+ default:
+ break;
+ }
+ }
+ OOOObj.SetType (_GET_CURRQEST_DATATYPE());
+ OOOObj.SetValue (Val);
+ >>
F:FLAGS "=" vfrOneOfOptionFlags[OOOObj, F->getLine()]
<<
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
@@ -2460,6 +2478,7 @@ vfrStatementInvalidSaveRestoreDefaults :
#token RuleRef("ruleref") "ruleref"
#token StringRef("stringref") "stringref"
#token PushThis("pushthis") "pushthis"
+#token Security("security") "security"
#token True("TRUE") "TRUE"
#token False("FALSE") "FALSE"
#token One("ONE") "ONE"
@@ -2685,6 +2704,7 @@ vfrExpressionBuildInFunction [UINT32 & RootLevel, UINT32 & ExpOpCount] :
| rulerefExp[$RootLevel, $ExpOpCount]
| stringref1Exp[$RootLevel, $ExpOpCount]
| pushthisExp[$RootLevel, $ExpOpCount]
+ | securityExp[$RootLevel, $ExpOpCount]
;
dupExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
@@ -2978,6 +2998,14 @@ pushthisExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
L:PushThis << { CIfrThis TObj(L->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L->getLine()); $ExpOpCount++; } >>
;
+securityExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
+ <<
+ EFI_GUID Guid;
+ >>
+ L:Security
+ "\(" guidDefinition[Guid] "\)" << { CIfrSecurity SObj(L->getLine()); _SAVE_OPHDR_COND (SObj, ($ExpOpCount == 0), L->getLine()); SObj.SetPermissions (&Guid); } $ExpOpCount++; >>
+ ;
+
vfrExpressionConstant[UINT32 & RootLevel, UINT32 & ExpOpCount] :
L1:True << CIfrTrue TObj(L1->getLine()); _SAVE_OPHDR_COND (TObj, ($ExpOpCount == 0), L1->getLine()); $ExpOpCount++; >>
| L2:False << CIfrFalse FObj(L2->getLine()); _SAVE_OPHDR_COND (FObj, ($ExpOpCount == 0), L2->getLine()); $ExpOpCount++; >>
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index ff61c9bd63..fc3dd113ac 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -203,7 +203,7 @@ Returns:
//
// Hex or decimal?
//
- if ((argv[1][0] == '0') && (tolower (argv[1][1]) == 'x')) {
+ if ((argv[1][0] == '0') && (tolower ((int)argv[1][1]) == 'x')) {
if (sscanf (argv[1], "%x", &Offset) != 1) {
Error (NULL, 0, 1003, "Invalid option value", "Offset = %s", argv[1]);
return GetUtilityStatus ();
@@ -216,7 +216,7 @@ Returns:
//
// See if they said something like "64K"
//
- if (tolower (argv[1][strlen (argv[1]) - 1]) == 'k') {
+ if (tolower ((int)argv[1][strlen (argv[1]) - 1]) == 'k') {
Offset *= 1024;
}
}
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9594ef0cae..ba026a9b26 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -1094,7 +1094,12 @@ class PlatformAutoGen(AutoGen):
# for overridding library instances with module specific setting
PlatformModule = self.Platform.Modules[str(Module)]
- # add forced library instance
+ # add forced library instances (specified under LibraryClasses sections)
+ for LibraryClass in self.Platform.LibraryClasses.GetKeys():
+ if LibraryClass.startswith("NULL"):
+ Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass]
+
+ # add forced library instances (specified in module overrides)
for LibraryClass in PlatformModule.LibraryClasses:
if LibraryClass.startswith("NULL"):
Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]
@@ -1170,7 +1175,7 @@ class PlatformAutoGen(AutoGen):
M = LibraryInstance[LibraryClassName]
LibraryList.append(M)
if ConsumedByList[M] == []:
- Q.insert(0, M)
+ Q.append(M)
#
# start the DAG algorithm
@@ -1939,7 +1944,7 @@ class ModuleAutoGen(AutoGen):
if Source != File:
CreateDirectory(Source.Dir)
- if File.IsBinary and File == Source:
+ if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:
RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]
elif FileType in self.BuildRules:
RuleObject = self.BuildRules[FileType]
@@ -2053,11 +2058,11 @@ class ModuleAutoGen(AutoGen):
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)
if UniStringBinBuffer != None and UniStringBinBuffer.getvalue() != "":
AutoFile = PathClass(gAutoGenStringFormFileName % {"module_name":self.Name}, self.OutputDir)
- self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue()
+ self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue()
AutoFile.IsBinary = True
self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)
- if UniStringBinBuffer != None:
- UniStringBinBuffer.close()
+ if UniStringBinBuffer != None:
+ UniStringBinBuffer.close()
return self._AutoGenFileList
## Return the list of library modules explicitly or implicityly used by this module
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 76dfbb665e..2883169f3c 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -1125,6 +1125,16 @@ class tdict:
for Key in self.data:
self.data[Key].SetSingleMode()
+ def GetKeys(self, KeyIndex=0):
+ assert KeyIndex >= 0
+ if KeyIndex == 0:
+ return set(self.data.keys())
+ else:
+ keys = set()
+ for Key in self.data:
+ keys |= self.data[Key].GetKeys(KeyIndex - 1)
+ return keys
+
## Boolean chain list
#
class Blist(UserList):
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index a9ff26e597..6190bceba8 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -278,9 +278,13 @@ class FV (FvClassObject):
#
if TotalSize > 0:
FvExtHeaderFileName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName + '.ext')
- FvExtHeaderFile = open (FvExtHeaderFileName,'wb')
+ FvExtHeaderFile = StringIO.StringIO()
FvExtHeaderFile.write(Buffer)
+ Changed = SaveFileOnChange(FvExtHeaderFileName, FvExtHeaderFile.getvalue(), True)
FvExtHeaderFile.close()
+ if Changed:
+ if os.path.exists (self.InfFileName):
+ os.remove (self.InfFileName)
self.FvInfFile.writelines("EFI_FV_EXT_HEADER_FILE_NAME = " + \
FvExtHeaderFileName + \
T_CHAR_LF)
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
index 2f2e8126c8..11b649658e 100644
--- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
+++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
@@ -444,6 +444,10 @@ class DscBuildData(PlatformBuildClassObject):
Macros.update(self._Macros)
for Record in RecordList:
LibraryClass, LibraryInstance, Dummy, Arch, ModuleType, Dummy, LineNo = Record
+ if LibraryClass == '' or LibraryClass == 'NULL':
+ self._NullLibraryNumber += 1
+ LibraryClass = 'NULL%d' % self._NullLibraryNumber
+ EdkLogger.verbose("Found forced library for arch=%s\n\t%s [%s]" % (Arch, LibraryInstance, LibraryClass))
LibraryClassSet.add(LibraryClass)
LibraryInstance = PathClass(NormPath(LibraryInstance, Macros), GlobalData.gWorkspace, Arch=self._Arch)
# check the file validation
@@ -1111,6 +1115,7 @@ class InfBuildData(ModuleBuildClassObject):
"BS_DRIVER" : "DXE_DRIVER",
"RT_DRIVER" : "DXE_RUNTIME_DRIVER",
"SAL_RT_DRIVER" : "DXE_SAL_DRIVER",
+ "DXE_SMM_DRIVER" : "DXE_SMM_DRIVER",
# "SMM_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "DXE_SMM_DRIVER",
# "BS_DRIVER" : "UEFI_DRIVER",
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index 5f470de926..624d941b0f 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -1265,9 +1265,9 @@ def MyOptionParser():
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
- Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Put build report in specified file.")
+ Parser.add_option("-y", "--report-file", action="store", dest="ReportFile", help="Create/overwrite the report to the specified filename.")
Parser.add_option("-Y", "--report-type", action="append", type="choice", choices=['ALL','PCD',], dest="ReportType",
- help="Flags that control the type of build report to generate. Must be one of [ALL, PCD]. To specify more flags, please repeat this option.")
+ help="Flags that control the type of build report to generate. Must be one of: [ALL, PCD]. To specify more than one flag, repeat this option on the command line.")
(Opt, Args)=Parser.parse_args()
return (Opt, Args)
diff --git a/BaseTools/Source/Python/sitecustomize.py b/BaseTools/Source/Python/sitecustomize.py
new file mode 100644
index 0000000000..fa5cd40705
--- /dev/null
+++ b/BaseTools/Source/Python/sitecustomize.py
@@ -0,0 +1,9 @@
+import sys
+import locale
+
+if sys.platform == "darwin":
+ DefaultLocal = locale.getdefaultlocale()[1]
+ if DefaultLocal is None:
+ DefaultLocal = 'UTF8'
+ sys.setdefaultencoding(DefaultLocal)
+