summaryrefslogtreecommitdiff
path: root/BaseTools/Source/C
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-11 10:26:49 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2011-05-11 10:26:49 +0000
commitda92f27632d2c89fa8726948ac9b02461ca8b61e (patch)
tree5d81f058c42e5be0d57287a7ddd8e3e4325eda7a /BaseTools/Source/C
parente472e8d3cca67f5e058f26fb6edc214b01114a3c (diff)
downloadedk2-platforms-da92f27632d2c89fa8726948ac9b02461ca8b61e.tar.xz
Sync BaseTools Branch (version r2149) to EDKII main trunk.
BaseTool Branch: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/branches/Releases/BaseTools_r2100 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11640 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/C')
-rw-r--r--BaseTools/Source/C/Common/PeCoffLib.h31
-rw-r--r--BaseTools/Source/C/Common/PeCoffLoaderEx.c89
-rw-r--r--BaseTools/Source/C/GenFw/Elf32Convert.c82
-rw-r--r--BaseTools/Source/C/GenFw/Elf64Convert.c15
-rw-r--r--BaseTools/Source/C/GenFw/ElfConvert.c4
-rw-r--r--BaseTools/Source/C/GenFw/ElfConvert.h3
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.c108
-rw-r--r--BaseTools/Source/C/GenFw/GenFw.h22
-rw-r--r--BaseTools/Source/C/Include/IndustryStandard/PeImage.h2
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrCompiler.cpp4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrCompiler.h4
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrError.cpp3
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrError.h3
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrFormPkg.h21
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrSyntax.g204
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp109
-rw-r--r--BaseTools/Source/C/VfrCompile/VfrUtilityLib.h3
17 files changed, 550 insertions, 157 deletions
diff --git a/BaseTools/Source/C/Common/PeCoffLib.h b/BaseTools/Source/C/Common/PeCoffLib.h
index 31c6f0fca1..fe6b29251b 100644
--- a/BaseTools/Source/C/Common/PeCoffLib.h
+++ b/BaseTools/Source/C/Common/PeCoffLib.h
@@ -159,6 +159,7 @@ PeCoffLoaderGetEntryPoint (
**/
UINT16
+EFIAPI
ThumbMovtImmediateAddress (
IN UINT16 *Instruction
);
@@ -171,11 +172,41 @@ ThumbMovtImmediateAddress (
**/
VOID
+EFIAPI
ThumbMovtImmediatePatch (
IN OUT UINT16 *Instruction,
IN UINT16 Address
);
+/**
+ Pass in a pointer to an ARM MOVW/MOVT instruciton pair and
+ return the immediate data encoded in the two` instruction
+
+ @param Instructions Pointer to ARM MOVW/MOVT insturction pair
+
+ @return Immediate address encoded in the instructions
+
+**/
+UINT32
+EFIAPI
+ThumbMovwMovtImmediateAddress (
+ IN UINT16 *Instructions
+ );
+
+/**
+ Update an ARM MOVW/MOVT immediate instruction instruction pair.
+
+ @param Instructions Pointer to ARM MOVW/MOVT instruction pair
+ @param Address New addres to patch into the instructions
+**/
+VOID
+EFIAPI
+ThumbMovwMovtImmediatePatch (
+ IN OUT UINT16 *Instructions,
+ IN UINT32 Address
+ );
+
+
#endif
diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
index 5d827cefe4..2afd441845 100644
--- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
+++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
@@ -24,6 +24,8 @@ Revision History
#include <Common/UefiBaseTypes.h>
#include <IndustryStandard/PeImage.h>
#include "PeCoffLib.h"
+#include "CommonLib.h"
+
#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \
Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)
@@ -375,6 +377,55 @@ ThumbMovtImmediatePatch (
}
/**
+ Pass in a pointer to an ARM MOVW/MOVT instruciton pair and
+ return the immediate data encoded in the two` instruction
+
+ @param Instructions Pointer to ARM MOVW/MOVT insturction pair
+
+ @return Immediate address encoded in the instructions
+
+**/
+UINT32
+EFIAPI
+ThumbMovwMovtImmediateAddress (
+ IN UINT16 *Instructions
+ )
+{
+ UINT16 *Word;
+ UINT16 *Top;
+
+ Word = Instructions; // MOVW
+ Top = Word + 2; // MOVT
+
+ return (ThumbMovtImmediateAddress (Top) << 16) + ThumbMovtImmediateAddress (Word);
+}
+
+
+/**
+ Update an ARM MOVW/MOVT immediate instruction instruction pair.
+
+ @param Instructions Pointer to ARM MOVW/MOVT instruction pair
+ @param Address New addres to patch into the instructions
+**/
+VOID
+EFIAPI
+ThumbMovwMovtImmediatePatch (
+ IN OUT UINT16 *Instructions,
+ IN UINT32 Address
+ )
+{
+ UINT16 *Word;
+ UINT16 *Top;
+
+ Word = (UINT16 *)Instructions; // MOVW
+ Top = Word + 2; // MOVT
+
+ ThumbMovtImmediatePatch (Word, (UINT16)(Address & 0xffff));
+ ThumbMovtImmediatePatch (Top, (UINT16)(Address >> 16));
+}
+
+
+/**
Performs an ARM-based specific relocation fixup and is a no-op on other
instruction sets.
@@ -395,38 +446,26 @@ PeCoffLoaderRelocateArmImage (
)
{
UINT16 *Fixup16;
- UINT16 FixupVal;
- UINT16 *Addend;
+ UINT32 FixupVal;
- Fixup16 = (UINT16 *) Fixup;
+ Fixup16 = (UINT16 *) Fixup;
switch ((**Reloc) >> 12) {
- case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW:
- FixupVal = ThumbMovtImmediateAddress (Fixup16) + (UINT16)Adjust;
- ThumbMovtImmediatePatch (Fixup16, FixupVal);
-
- if (*FixupData != NULL) {
- *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT16));
- *(UINT16 *)*FixupData = *Fixup16;
- *FixupData = *FixupData + sizeof (UINT16);
- }
- break;
-
- case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT:
- // For MOVT you need to know the lower 16-bits do do the math
- // So this relocation entry is really two entries.
- *Reloc = *Reloc + 1;
- Addend = *Reloc;
- FixupVal = (UINT16)(((ThumbMovtImmediateAddress (Fixup16) << 16) + Adjust + *Addend) >> 16);
- ThumbMovtImmediatePatch (Fixup16, FixupVal);
-
+
+ case EFI_IMAGE_REL_BASED_ARM_MOV32T:
+ FixupVal = ThumbMovwMovtImmediateAddress (Fixup16) + (UINT32)Adjust;
+ ThumbMovwMovtImmediatePatch (Fixup16, FixupVal);
+
+
if (*FixupData != NULL) {
- *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT16));
- *(UINT16 *)*FixupData = *Fixup16;
- *FixupData = *FixupData + sizeof (UINT16);
+ *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
+ *(UINT64 *)(*FixupData) = *Fixup16;
+ CopyMem (*FixupData, Fixup16, sizeof (UINT64));
}
break;
+ case EFI_IMAGE_REL_BASED_ARM_MOV32A:
+ // break omitted - ARM instruction encoding not implemented
default:
return RETURN_UNSUPPORTED;
}
diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c
index 539fdf560a..42ae35bfef 100644
--- a/BaseTools/Source/C/GenFw/Elf32Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf32Convert.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2011, 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
@@ -263,6 +263,7 @@ ScanSections32 (
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
UINT32 CoffEntry;
+ UINT32 SectionCount;
CoffEntry = 0;
mCoffOffset = 0;
@@ -291,6 +292,7 @@ ScanSections32 (
//
mCoffOffset = CoffAlign(mCoffOffset);
mTextOffset = mCoffOffset;
+ SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
if (IsTextShdr(shdr)) {
@@ -315,6 +317,7 @@ ScanSections32 (
}
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += shdr->sh_size;
+ SectionCount ++;
}
}
@@ -322,10 +325,15 @@ ScanSections32 (
mCoffOffset = CoffAlign(mCoffOffset);
}
+ if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
+ Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 text section. Source level debug might not work correctly.", mInImageName);
+ }
+
//
// Then data sections.
//
mDataOffset = mCoffOffset;
+ SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
if (IsDataShdr(shdr)) {
@@ -344,10 +352,15 @@ ScanSections32 (
}
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += shdr->sh_size;
+ SectionCount ++;
}
}
mCoffOffset = CoffAlign(mCoffOffset);
+ if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
+ Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 data section. Source level debug might not work correctly.", mInImageName);
+ }
+
//
// The HII resource sections.
//
@@ -650,18 +663,18 @@ WriteSections32 (
case R_ARM_THM_ALU_PREL_11_0:
case R_ARM_THM_PC12:
case R_ARM_REL32_NOI:
- case R_ARM_ALU_PC_G0_NC:
- case R_ARM_ALU_PC_G0:
- case R_ARM_ALU_PC_G1_NC:
- case R_ARM_ALU_PC_G1:
- case R_ARM_ALU_PC_G2:
- case R_ARM_LDR_PC_G1:
- case R_ARM_LDR_PC_G2:
- case R_ARM_LDRS_PC_G0:
- case R_ARM_LDRS_PC_G1:
- case R_ARM_LDRS_PC_G2:
- case R_ARM_LDC_PC_G0:
- case R_ARM_LDC_PC_G1:
+ case R_ARM_ALU_PC_G0_NC:
+ case R_ARM_ALU_PC_G0:
+ case R_ARM_ALU_PC_G1_NC:
+ case R_ARM_ALU_PC_G1:
+ case R_ARM_ALU_PC_G2:
+ case R_ARM_LDR_PC_G1:
+ case R_ARM_LDR_PC_G2:
+ case R_ARM_LDRS_PC_G0:
+ case R_ARM_LDRS_PC_G1:
+ case R_ARM_LDRS_PC_G2:
+ case R_ARM_LDC_PC_G0:
+ case R_ARM_LDC_PC_G1:
case R_ARM_LDC_PC_G2:
case R_ARM_GOT_PREL:
case R_ARM_THM_JUMP11:
@@ -704,6 +717,8 @@ WriteSections32 (
return TRUE;
}
+UINTN gMovwOffset = 0;
+
STATIC
VOID
WriteRelocations32 (
@@ -786,18 +801,18 @@ WriteRelocations32 (
case R_ARM_THM_ALU_PREL_11_0:
case R_ARM_THM_PC12:
case R_ARM_REL32_NOI:
- case R_ARM_ALU_PC_G0_NC:
- case R_ARM_ALU_PC_G0:
- case R_ARM_ALU_PC_G1_NC:
- case R_ARM_ALU_PC_G1:
- case R_ARM_ALU_PC_G2:
- case R_ARM_LDR_PC_G1:
- case R_ARM_LDR_PC_G2:
- case R_ARM_LDRS_PC_G0:
- case R_ARM_LDRS_PC_G1:
- case R_ARM_LDRS_PC_G2:
- case R_ARM_LDC_PC_G0:
- case R_ARM_LDC_PC_G1:
+ case R_ARM_ALU_PC_G0_NC:
+ case R_ARM_ALU_PC_G0:
+ case R_ARM_ALU_PC_G1_NC:
+ case R_ARM_ALU_PC_G1:
+ case R_ARM_ALU_PC_G2:
+ case R_ARM_LDR_PC_G1:
+ case R_ARM_LDR_PC_G2:
+ case R_ARM_LDRS_PC_G0:
+ case R_ARM_LDRS_PC_G1:
+ case R_ARM_LDRS_PC_G2:
+ case R_ARM_LDC_PC_G0:
+ case R_ARM_LDC_PC_G1:
case R_ARM_LDC_PC_G2:
case R_ARM_GOT_PREL:
case R_ARM_THM_JUMP11:
@@ -812,19 +827,18 @@ WriteRelocations32 (
CoffAddFixup (
mCoffSectionsOffset[RelShdr->sh_info]
+ (Rel->r_offset - SecShdr->sh_addr),
- EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW
+ EFI_IMAGE_REL_BASED_ARM_MOV32T
);
+
+ // PE/COFF treats MOVW/MOVT relocation as single 64-bit instruction
+ // Track this address so we can log an error for unsupported sequence of MOVW/MOVT
+ gMovwOffset = mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr);
break;
case R_ARM_THM_MOVT_ABS:
- CoffAddFixup (
- mCoffSectionsOffset[RelShdr->sh_info]
- + (Rel->r_offset - SecShdr->sh_addr),
- EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT
- );
-
- // The relocation entry needs to contain the lower 16-bits so we can do math
- CoffAddFixupEntry ((UINT16)(Sym->st_value - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]));
+ if ((gMovwOffset + 4) != (mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr))) {
+ Error (NULL, 0, 3000, "Not Supported", "PE/COFF requires MOVW+MOVT instruction sequence %x +4 != %x.", gMovwOffset, mCoffSectionsOffset[RelShdr->sh_info] + (Rel->r_offset - SecShdr->sh_addr));
+ }
break;
case R_ARM_ABS32:
diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c
index 7c2e87e68b..fbe6ff8232 100644
--- a/BaseTools/Source/C/GenFw/Elf64Convert.c
+++ b/BaseTools/Source/C/GenFw/Elf64Convert.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2011, 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
@@ -256,6 +256,7 @@ ScanSections64 (
EFI_IMAGE_DOS_HEADER *DosHdr;
EFI_IMAGE_OPTIONAL_HEADER_UNION *NtHdr;
UINT32 CoffEntry;
+ UINT32 SectionCount;
CoffEntry = 0;
mCoffOffset = 0;
@@ -284,6 +285,7 @@ ScanSections64 (
//
mCoffOffset = CoffAlign(mCoffOffset);
mTextOffset = mCoffOffset;
+ SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
if (IsTextShdr(shdr)) {
@@ -308,6 +310,7 @@ ScanSections64 (
}
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += (UINT32) shdr->sh_size;
+ SectionCount ++;
}
}
@@ -315,10 +318,15 @@ ScanSections64 (
mCoffOffset = CoffAlign(mCoffOffset);
}
+ if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
+ Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 text section. Source level debug might not work correctly.", mInImageName);
+ }
+
//
// Then data sections.
//
mDataOffset = mCoffOffset;
+ SectionCount = 0;
for (i = 0; i < mEhdr->e_shnum; i++) {
Elf_Shdr *shdr = GetShdrByIndex(i);
if (IsDataShdr(shdr)) {
@@ -337,10 +345,15 @@ ScanSections64 (
}
mCoffSectionsOffset[i] = mCoffOffset;
mCoffOffset += (UINT32) shdr->sh_size;
+ SectionCount ++;
}
}
mCoffOffset = CoffAlign(mCoffOffset);
+ if (SectionCount > 1 && mOutImageType == FW_EFI_IMAGE) {
+ Warning (NULL, 0, 0, NULL, "Mulitple sections in %s are merged into 1 data section. Source level debug might not work correctly.", mInImageName);
+ }
+
//
// The HII resource sections.
//
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.c b/BaseTools/Source/C/GenFw/ElfConvert.c
index 135fa90fa0..e573554d03 100644
--- a/BaseTools/Source/C/GenFw/ElfConvert.c
+++ b/BaseTools/Source/C/GenFw/ElfConvert.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2011, 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
@@ -170,7 +170,7 @@ ConvertElf (
//
// Determine ELF type and set function table pointer correctly.
//
- VerboseMsg ("Check Efl Image Header");
+ VerboseMsg ("Check Elf Image Header");
EiClass = (*FileBuffer)[EI_CLASS];
if (EiClass == ELFCLASS32) {
if (!InitializeElf32 (*FileBuffer, &ElfFunctions)) {
diff --git a/BaseTools/Source/C/GenFw/ElfConvert.h b/BaseTools/Source/C/GenFw/ElfConvert.h
index edd9d52958..185dbb759c 100644
--- a/BaseTools/Source/C/GenFw/ElfConvert.h
+++ b/BaseTools/Source/C/GenFw/ElfConvert.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2011, 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
@@ -27,6 +27,7 @@ extern CHAR8 *mInImageName;
extern UINT32 mImageTimeStamp;
extern UINT8 *mCoffFile;
extern UINT32 mTableOffset;
+extern UINT32 mOutImageType;
//
// Common EFI specific data.
diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c
index e41fe6e82b..90ba251102 100644
--- a/BaseTools/Source/C/GenFw/GenFw.c
+++ b/BaseTools/Source/C/GenFw/GenFw.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -62,25 +62,6 @@ Abstract:
#define HII_RESOURCE_SECTION_INDEX 1
#define HII_RESOURCE_SECTION_NAME "HII"
-//
-// Action for this tool.
-//
-#define FW_DUMMY_IMAGE 0
-#define FW_EFI_IMAGE 1
-#define FW_TE_IMAGE 2
-#define FW_ACPI_IMAGE 3
-#define FW_BIN_IMAGE 4
-#define FW_ZERO_DEBUG_IMAGE 5
-#define FW_SET_STAMP_IMAGE 6
-#define FW_MCI_IMAGE 7
-#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 FW_REBASE_IMAGE 12
-#define FW_SET_ADDRESS_IMAGE 13
-
-#define DUMP_TE_HEADER 0x11
#define DEFAULT_MC_PAD_BYTE_VALUE 0xFF
#define DEFAULT_MC_ALIGNMENT 16
@@ -121,6 +102,7 @@ static const char *gHiiPackageRCFileHeader[] = {
CHAR8 *mInImageName;
UINT32 mImageTimeStamp = 0;
UINT32 mImageSize = 0;
+UINT32 mOutImageType = FW_DUMMY_IMAGE;
STATIC
@@ -1080,7 +1062,6 @@ Returns:
char *OutImageName;
char *ModuleType;
CHAR8 *TimeStamp;
- UINT32 OutImageType;
FILE *fpIn;
FILE *fpOut;
FILE *fpInOut;
@@ -1147,7 +1128,6 @@ Returns:
mInImageName = NULL;
OutImageName = NULL;
ModuleType = NULL;
- OutImageType = FW_DUMMY_IMAGE;
Type = 0;
Status = STATUS_SUCCESS;
FileBuffer = NULL;
@@ -1221,8 +1201,8 @@ Returns:
goto Finish;
}
ModuleType = argv[1];
- if (OutImageType != FW_TE_IMAGE) {
- OutImageType = FW_EFI_IMAGE;
+ if (mOutImageType != FW_TE_IMAGE) {
+ mOutImageType = FW_EFI_IMAGE;
}
argc -= 2;
argv += 2;
@@ -1230,49 +1210,49 @@ Returns:
}
if ((stricmp (argv[0], "-l") == 0) || (stricmp (argv[0], "--stripped") == 0)) {
- OutImageType = FW_RELOC_STRIPEED_IMAGE;
+ mOutImageType = FW_RELOC_STRIPEED_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-c") == 0) || (stricmp (argv[0], "--acpi") == 0)) {
- OutImageType = FW_ACPI_IMAGE;
+ mOutImageType = FW_ACPI_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-t") == 0) || (stricmp (argv[0], "--terse") == 0)) {
- OutImageType = FW_TE_IMAGE;
+ mOutImageType = FW_TE_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-u") == 0) || (stricmp (argv[0], "--dump") == 0)) {
- OutImageType = DUMP_TE_HEADER;
+ mOutImageType = DUMP_TE_HEADER;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-b") == 0) || (stricmp (argv[0], "--exe2bin") == 0)) {
- OutImageType = FW_BIN_IMAGE;
+ mOutImageType = FW_BIN_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-z") == 0) || (stricmp (argv[0], "--zero") == 0)) {
- OutImageType = FW_ZERO_DEBUG_IMAGE;
+ mOutImageType = FW_ZERO_DEBUG_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-s") == 0) || (stricmp (argv[0], "--stamp") == 0)) {
- OutImageType = FW_SET_STAMP_IMAGE;
+ mOutImageType = FW_SET_STAMP_IMAGE;
if (argv[1] == NULL || argv[1][0] == '-') {
Error (NULL, 0, 1003, "Invalid option value", "time stamp is missing for -s option");
goto Finish;
@@ -1305,14 +1285,14 @@ Returns:
}
if ((stricmp (argv[0], "-m") == 0) || (stricmp (argv[0], "--mcifile") == 0)) {
- OutImageType = FW_MCI_IMAGE;
+ mOutImageType = FW_MCI_IMAGE;
argc --;
argv ++;
continue;
}
if ((stricmp (argv[0], "-j") == 0) || (stricmp (argv[0], "--join") == 0)) {
- OutImageType = FW_MERGE_IMAGE;
+ mOutImageType = FW_MERGE_IMAGE;
argc --;
argv ++;
continue;
@@ -1341,7 +1321,7 @@ Returns:
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
goto Finish;
}
- OutImageType = FW_REBASE_IMAGE;
+ mOutImageType = FW_REBASE_IMAGE;
NewBaseAddress = (UINT64) Temp64;
argc -= 2;
argv += 2;
@@ -1360,7 +1340,7 @@ Returns:
Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
goto Finish;
}
- OutImageType = FW_SET_ADDRESS_IMAGE;
+ mOutImageType = FW_SET_ADDRESS_IMAGE;
NewBaseAddress = (UINT64) Temp64;
argc -= 2;
argv += 2;
@@ -1423,14 +1403,14 @@ Returns:
}
if (stricmp (argv[0], "--hiipackage") == 0) {
- OutImageType = FW_HII_PACKAGE_LIST_RCIMAGE;
+ mOutImageType = FW_HII_PACKAGE_LIST_RCIMAGE;
argc --;
argv ++;
continue;
}
if (stricmp (argv[0], "--hiibinpackage") == 0) {
- OutImageType = FW_HII_PACKAGE_LIST_BINIMAGE;
+ mOutImageType = FW_HII_PACKAGE_LIST_BINIMAGE;
argc --;
argv ++;
continue;
@@ -1475,7 +1455,7 @@ Returns:
VerboseMsg ("%s tool start.", UTILITY_NAME);
- if (OutImageType == FW_DUMMY_IMAGE) {
+ if (mOutImageType == FW_DUMMY_IMAGE) {
Error (NULL, 0, 1001, "Missing option", "No create file action specified; pls specify -e, -c or -t option to create efi image, or acpi table or TeImage!");
if (ReplaceFlag) {
Error (NULL, 0, 1001, "Missing option", "-r option is not supported as the independent option. It can be used together with other create file option specified at the above.");
@@ -1494,7 +1474,7 @@ Returns:
//
// Combine MciBinary files to one file
//
- if ((OutImageType == FW_MERGE_IMAGE) && ReplaceFlag) {
+ if ((mOutImageType == FW_MERGE_IMAGE) && ReplaceFlag) {
Error (NULL, 0, 1002, "Conflicting option", "-r replace option cannot be used with -j merge files option.");
goto Finish;
}
@@ -1502,12 +1482,12 @@ Returns:
//
// Combine HiiBinary packages to a single package list
//
- if ((OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) && ReplaceFlag) {
+ if ((mOutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) && ReplaceFlag) {
Error (NULL, 0, 1002, "Conflicting option", "-r replace option cannot be used with --hiipackage merge files option.");
goto Finish;
}
- if ((OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) && ReplaceFlag) {
+ if ((mOutImageType == 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;
}
@@ -1521,7 +1501,7 @@ Returns:
//
// Action will be taken for the input file.
//
- switch (OutImageType) {
+ switch (mOutImageType) {
case FW_EFI_IMAGE:
VerboseMsg ("Create efi image on module type %s based on the input PE image.", ModuleType);
break;
@@ -1599,7 +1579,7 @@ Returns:
fpOut = NULL;
}
VerboseMsg ("Output file name is %s", OutImageName);
- } else if (!ReplaceFlag && OutImageType != DUMP_TE_HEADER) {
+ } else if (!ReplaceFlag && mOutImageType != DUMP_TE_HEADER) {
Error (NULL, 0, 1001, "Missing option", "output file");
goto Finish;
}
@@ -1634,7 +1614,7 @@ Returns:
//
// Combine multi binary HII package files.
//
- if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE || OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
+ if (mOutImageType == FW_HII_PACKAGE_LIST_RCIMAGE || mOutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
//
// Open output file handle.
//
@@ -1711,7 +1691,7 @@ Returns:
//
// write the hii package into the binary package list file with the resource section header
//
- if (OutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
+ if (mOutImageType == FW_HII_PACKAGE_LIST_BINIMAGE) {
//
// Create the resource section header
//
@@ -1735,7 +1715,7 @@ Returns:
//
// write the hii package into the text package list rc file.
//
- if (OutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) {
+ if (mOutImageType == FW_HII_PACKAGE_LIST_RCIMAGE) {
for (Index = 0; gHiiPackageRCFileHeader[Index] != NULL; Index++) {
fprintf (fpOut, "%s\n", gHiiPackageRCFileHeader[Index]);
}
@@ -1770,7 +1750,7 @@ Returns:
//
// Combine MciBinary files to one file
//
- if (OutImageType == FW_MERGE_IMAGE) {
+ if (mOutImageType == FW_MERGE_IMAGE) {
//
// Open output file handle.
//
@@ -1821,7 +1801,7 @@ Returns:
//
// Convert MicroCode.txt file to MicroCode.bin file
//
- if (OutImageType == FW_MCI_IMAGE) {
+ if (mOutImageType == FW_MCI_IMAGE) {
fpIn = fopen (mInImageName, "r");
if (fpIn == NULL) {
Error (NULL, 0, 0001, "Error opening file", mInImageName);
@@ -1935,7 +1915,7 @@ Returns:
//
// Dump TeImage Header into output file.
//
- if (OutImageType == DUMP_TE_HEADER) {
+ if (mOutImageType == DUMP_TE_HEADER) {
memcpy (&TEImageHeader, FileBuffer, sizeof (TEImageHeader));
if (TEImageHeader.Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {
Error (NULL, 0, 3000, "Invalid", "TE header signature of file %s is not correct.", mInImageName);
@@ -1994,12 +1974,12 @@ Returns:
// Following code to convert dll to efi image or te image.
// Get new image type
//
- if ((OutImageType == FW_EFI_IMAGE) || (OutImageType == FW_TE_IMAGE)) {
+ if ((mOutImageType == FW_EFI_IMAGE) || (mOutImageType == FW_TE_IMAGE)) {
if (ModuleType == NULL) {
- if (OutImageType == FW_EFI_IMAGE) {
+ if (mOutImageType == FW_EFI_IMAGE) {
Error (NULL, 0, 1001, "Missing option", "EFI_FILETYPE");
goto Finish;
- } else if (OutImageType == FW_TE_IMAGE) {
+ } else if (mOutImageType == FW_TE_IMAGE) {
//
// Default TE Image Type is Boot service driver
//
@@ -2047,7 +2027,7 @@ Returns:
}
//
- // Convert EFL image to PeImage
+ // Convert ELF image to PeImage
//
if (IsElfHeader(FileBuffer)) {
VerboseMsg ("Convert %s from ELF to PE/COFF.", mInImageName);
@@ -2066,7 +2046,7 @@ Returns:
//
// Remove reloc section from PE or TE image
//
- if (OutImageType == FW_RELOC_STRIPEED_IMAGE) {
+ if (mOutImageType == FW_RELOC_STRIPEED_IMAGE) {
//
// Check TeImage
//
@@ -2184,7 +2164,7 @@ Returns:
//
// Set new base address into image
//
- if (OutImageType == FW_REBASE_IMAGE || OutImageType == FW_SET_ADDRESS_IMAGE) {
+ if (mOutImageType == FW_REBASE_IMAGE || mOutImageType == FW_SET_ADDRESS_IMAGE) {
if ((PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) && (PeHdr->Pe32.FileHeader.Machine != IMAGE_FILE_MACHINE_IA64)) {
if (NewBaseAddress >= 0x100000000ULL) {
Error (NULL, 0, 3000, "Invalid", "New base address is larger than 4G for 32bit PE image");
@@ -2198,7 +2178,7 @@ Returns:
//
NewBaseAddress = (UINT64) (0 - NewBaseAddress);
}
- if (OutImageType == FW_REBASE_IMAGE) {
+ if (mOutImageType == FW_REBASE_IMAGE) {
Status = RebaseImage (mInImageName, FileBuffer, NewBaseAddress);
} else {
Status = SetAddressToSectionHeader (mInImageName, FileBuffer, NewBaseAddress);
@@ -2221,7 +2201,7 @@ Returns:
//
// Extract bin data from Pe image.
//
- if (OutImageType == FW_BIN_IMAGE) {
+ if (mOutImageType == FW_BIN_IMAGE) {
if (FileLength < PeHdr->Pe32.OptionalHeader.SizeOfHeaders) {
Error (NULL, 0, 3000, "Invalid", "FileSize of %s is not a legal size.", mInImageName);
goto Finish;
@@ -2230,7 +2210,7 @@ Returns:
// Output bin data from exe file
//
FileLength = FileLength - PeHdr->Pe32.OptionalHeader.SizeOfHeaders;
- memcpy (FileBuffer, FileBuffer + PeHdr->Pe32.OptionalHeader.SizeOfHeaders, FileLength);
+ memmove (FileBuffer, FileBuffer + PeHdr->Pe32.OptionalHeader.SizeOfHeaders, FileLength);
VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength);
goto WriteFile;
}
@@ -2238,7 +2218,7 @@ Returns:
//
// Zero Debug Information of Pe Image
//
- if (OutImageType == FW_ZERO_DEBUG_IMAGE) {
+ if (mOutImageType == FW_ZERO_DEBUG_IMAGE) {
Status = ZeroDebugData (FileBuffer, TRUE);
if (EFI_ERROR (Status)) {
Error (NULL, 0, 3000, "Invalid", "Zero DebugData Error status is 0x%x", (int) Status);
@@ -2255,7 +2235,7 @@ Returns:
//
// Set Time Stamp of Pe Image
//
- if (OutImageType == FW_SET_STAMP_IMAGE) {
+ if (mOutImageType == FW_SET_STAMP_IMAGE) {
Status = SetStamp (FileBuffer, TimeStamp);
if (EFI_ERROR (Status)) {
goto Finish;
@@ -2271,7 +2251,7 @@ Returns:
//
// Extract acpi data from pe image.
//
- if (OutImageType == FW_ACPI_IMAGE) {
+ if (mOutImageType == FW_ACPI_IMAGE) {
SectionHeader = (EFI_IMAGE_SECTION_HEADER *) ((UINT8 *) &(PeHdr->Pe32.OptionalHeader) + PeHdr->Pe32.FileHeader.SizeOfOptionalHeader);
for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index ++, SectionHeader ++) {
if (strcmp ((char *)SectionHeader->Name, ".data") == 0 || strcmp ((char *)SectionHeader->Name, ".sdata") == 0) {
@@ -2292,7 +2272,7 @@ Returns:
//
// Output Apci data to file
//
- memcpy (FileBuffer, FileBuffer + SectionHeader->PointerToRawData, FileLength);
+ memmove (FileBuffer, FileBuffer + SectionHeader->PointerToRawData, FileLength);
VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength);
goto WriteFile;
}
@@ -2599,7 +2579,7 @@ Returns:
//
ZeroDebugData (FileBuffer, FALSE);
- if (OutImageType == FW_TE_IMAGE) {
+ if (mOutImageType == FW_TE_IMAGE) {
if ((PeHdr->Pe32.FileHeader.NumberOfSections &~0xFF) || (Type &~0xFF)) {
//
// Pack the subsystem and NumberOfSections into 1 byte. Make sure they fit both.
@@ -2622,7 +2602,7 @@ Returns:
// Update Image to TeImage
//
FileLength = FileLength - TEImageHeader.StrippedSize;
- memcpy (FileBuffer + sizeof (EFI_TE_IMAGE_HEADER), FileBuffer + TEImageHeader.StrippedSize, FileLength);
+ memmove (FileBuffer + sizeof (EFI_TE_IMAGE_HEADER), FileBuffer + TEImageHeader.StrippedSize, FileLength);
FileLength = FileLength + sizeof (EFI_TE_IMAGE_HEADER);
memcpy (FileBuffer, &TEImageHeader, sizeof (EFI_TE_IMAGE_HEADER));
VerboseMsg ("the size of output file is %u bytes", (unsigned) (FileLength));
diff --git a/BaseTools/Source/C/GenFw/GenFw.h b/BaseTools/Source/C/GenFw/GenFw.h
index 11b3aa941e..e36dc085ff 100644
--- a/BaseTools/Source/C/GenFw/GenFw.h
+++ b/BaseTools/Source/C/GenFw/GenFw.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2011, 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
@@ -15,6 +15,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef _GEN_FW_H_
#define _GEN_FW_H_
+//
+// Action for this tool.
+//
+#define FW_DUMMY_IMAGE 0
+#define FW_EFI_IMAGE 1
+#define FW_TE_IMAGE 2
+#define FW_ACPI_IMAGE 3
+#define FW_BIN_IMAGE 4
+#define FW_ZERO_DEBUG_IMAGE 5
+#define FW_SET_STAMP_IMAGE 6
+#define FW_MCI_IMAGE 7
+#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 FW_REBASE_IMAGE 12
+#define FW_SET_ADDRESS_IMAGE 13
+
+#define DUMP_TE_HEADER 0x11
+
VOID
SetHiiResourceHeader (
UINT8 *HiiBinData,
diff --git a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
index f54ee63a83..8eaf4c3e78 100644
--- a/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
+++ b/BaseTools/Source/C/Include/IndustryStandard/PeImage.h
@@ -516,8 +516,6 @@ typedef struct {
#define EFI_IMAGE_REL_BASED_IA64_IMM64 9
#define EFI_IMAGE_REL_BASED_DIR64 10
-#define EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW 11
-#define EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT 12
///
/// Line number format.
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
index 24ac977892..5985a7ad5d 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp
@@ -2,7 +2,7 @@
VfrCompiler main class and main function.
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -383,7 +383,7 @@ CVfrCompiler::Usage (
CONST CHAR8 *Help[] = {
" ",
"VfrCompile version " VFR_COMPILER_VERSION VFR_COMPILER_UPDATE_TIME,
- "Copyright (c) 2004-2010 Intel Corporation. All rights reserved.",
+ "Copyright (c) 2004-2011 Intel Corporation. All rights reserved.",
" ",
"Usage: VfrCompile [options] VfrFile",
" ",
diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.h b/BaseTools/Source/C/VfrCompile/VfrCompiler.h
index c32325f0b7..7525bb5603 100644
--- a/BaseTools/Source/C/VfrCompile/VfrCompiler.h
+++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.h
@@ -2,7 +2,7 @@
VfrCompiler internal defintions.
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -23,7 +23,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define PROGRAM_NAME "VfrCompile"
#define VFR_COMPILER_VERSION " 1.95 (UEFI 2.1)"
-#define VFR_COMPILER_UPDATE_TIME " updated on 2009/05/20"
+#define VFR_COMPILER_UPDATE_TIME " updated on 2011/02/25"
//
// This is how we invoke the C preprocessor on the VFR source file
// to resolve #defines, #includes, etc. To make C source files
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp
index 3bfe5d576a..b0f9197e36 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp
@@ -2,7 +2,7 @@
VfrCompiler error handler.
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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,6 +34,7 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_VARSTOREID_REDEFINED, ": varstore id already defined" },
{ VFR_RETURN_UNDEFINED, ": undefined" },
{ VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION, ": some variable has not defined by a question"},
+ { VFR_RETURN_VARSTORE_DATATYPE_REDEFINED_ERROR, ": Data Structure is defined by more than one varstores, it can't be referred as varstore, only varstore name could be used."},
{ VFR_RETURN_GET_EFIVARSTORE_ERROR, ": get efi varstore error"},
{ VFR_RETURN_EFIVARSTORE_USE_ERROR, ": can not use the efi varstore like this" },
{ VFR_RETURN_EFIVARSTORE_SIZE_ERROR, ": unsupport efi varstore size should be <= 8 bytes" },
diff --git a/BaseTools/Source/C/VfrCompile/VfrError.h b/BaseTools/Source/C/VfrCompile/VfrError.h
index 29cccabd29..258ae9b8af 100644
--- a/BaseTools/Source/C/VfrCompile/VfrError.h
+++ b/BaseTools/Source/C/VfrCompile/VfrError.h
@@ -2,7 +2,7 @@
VfrCompiler Error definition
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -32,6 +32,7 @@ typedef enum {
VFR_RETURN_VARSTOREID_REDEFINED,
VFR_RETURN_UNDEFINED,
VFR_RETURN_VAR_NOTDEFINED_BY_QUESTION,
+ VFR_RETURN_VARSTORE_DATATYPE_REDEFINED_ERROR,
VFR_RETURN_GET_EFIVARSTORE_ERROR,
VFR_RETURN_EFIVARSTORE_USE_ERROR,
VFR_RETURN_EFIVARSTORE_SIZE_ERROR,
diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
index 88d3422162..4cdd1cc5db 100644
--- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
+++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h
@@ -2,7 +2,7 @@
The definition of CFormPkg's member function
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -1697,6 +1697,25 @@ public:
}
};
+class CIfrGuid : public CIfrObj, public CIfrOpHeader {
+private:
+ EFI_IFR_GUID *mGuid;
+
+public:
+ CIfrGuid (UINT8 Size) : CIfrObj (EFI_IFR_GUID_OP, (CHAR8 **)&mGuid, sizeof (EFI_IFR_GUID)+Size),
+ CIfrOpHeader (EFI_IFR_GUID_OP, &mGuid->Header, sizeof (EFI_IFR_GUID)+Size) {
+ memset (&mGuid->Guid, 0, sizeof (EFI_GUID));
+ }
+
+ VOID SetGuid (IN EFI_GUID *Guid) {
+ memcpy (&mGuid->Guid, Guid, sizeof (EFI_GUID));
+ }
+
+ VOID SetData (IN UINT8* DataBuff, IN UINT8 Size) {
+ memcpy ((UINT8 *)mGuid + sizeof (EFI_IFR_GUID), DataBuff, Size);
+ }
+};
+
class CIfrDup : public CIfrObj, public CIfrOpHeader {
private:
EFI_IFR_DUP *mDup;
diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
index fc0215134d..02a7b5c1f4 100644
--- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g
+++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g
@@ -1,5 +1,5 @@
/*++
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -233,6 +233,11 @@ VfrParserStart (
#token Refresh("refresh") "refresh"
#token Interval("interval") "interval"
#token VarstoreDevice("varstoredevice") "varstoredevice"
+#token GuidOp("guidop") "guidop"
+#token EndGuidOp("endguidop") "endguidop"
+#token DataType("datatype") "datatype"
+#token Data("data") "data"
+
//
// Define the class and subclass tokens
//
@@ -559,10 +564,195 @@ vfrFormSetList :
vfrStatementVarStoreNameValue |
vfrStatementDefaultStore |
vfrStatementDisableIfFormSet |
- vfrStatementSuppressIfFormSet
+ vfrStatementSuppressIfFormSet |
+ vfrStatementExtension
)*
;
+vfrStatementExtension:
+ <<
+ EFI_GUID Guid;
+ CIfrGuid *GuidObj = NULL;
+ CHAR8 *TypeName = NULL;
+ UINT32 TypeSize = 0;
+ UINT8 *DataBuff = NULL;
+ UINT32 Size = 0;
+ UINT8 Idx = 0;
+ UINT32 LineNum;
+ BOOLEAN IsStruct = FALSE;
+ UINT32 ArrayNum = 0;
+ >>
+ L:GuidOp
+ Uuid "=" guidDefinition[Guid]
+ {"," DataType "="
+ (
+ U64:"UINT64" {OpenBracket AN1:Number CloseBracket <<ArrayNum = _STOU32(AN1->getText());>>}
+ << TypeName = U64->getText(); LineNum = U64->getLine(); >>
+ | U32:"UINT32" {OpenBracket AN2:Number CloseBracket <<ArrayNum = _STOU32(AN2->getText());>>}
+ << TypeName = U32->getText(); LineNum = U32->getLine(); >>
+ | U16:"UINT16" {OpenBracket AN3:Number CloseBracket <<ArrayNum = _STOU32(AN3->getText());>>}
+ << TypeName = U16->getText(); LineNum = U16->getLine(); >>
+ | U8:"UINT8" {OpenBracket AN4:Number CloseBracket <<ArrayNum = _STOU32(AN4->getText());>>}
+ << TypeName = U8->getText(); LineNum = U8->getLine(); >>
+ | BL:"BOOLEAN" {OpenBracket AN5:Number CloseBracket <<ArrayNum = _STOU32(AN5->getText());>>}
+ << TypeName = BL->getText(); LineNum = BL->getLine(); >>
+ | SI:"EFI_STRING_ID" {OpenBracket AN6:Number CloseBracket <<ArrayNum = _STOU32(AN6->getText());>>}
+ << TypeName = SI->getText(); LineNum = SI->getLine(); >>
+ | D:"EFI_HII_DATE" {OpenBracket AN7:Number CloseBracket <<ArrayNum = _STOU32(AN7->getText());>>}
+ << TypeName = D->getText(); LineNum = D->getLine(); IsStruct = TRUE;>>
+ | T:"EFI_HII_TIME" {OpenBracket AN8:Number CloseBracket <<ArrayNum = _STOU32(AN8->getText());>>}
+ << TypeName = T->getText(); LineNum = T->getLine(); IsStruct = TRUE;>>
+ | TN:StringIdentifier {OpenBracket AN9:Number CloseBracket <<ArrayNum = _STOU32(AN9->getText());>>}
+ << TypeName = TN->getText(); LineNum = TN->getLine(); IsStruct = TRUE;>>
+ )
+ <<
+ _PCATCH(gCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &TypeSize), LineNum);
+ if (ArrayNum > 0) {
+ Size = TypeSize*ArrayNum;
+ } else {
+ Size = TypeSize;
+ }
+ if (Size > (128 - sizeof (EFI_IFR_GUID))) return;
+ DataBuff = (UINT8 *)malloc(Size);
+ for (Idx = 0; Idx < Size; Idx++) {
+ DataBuff[Idx] = 0;
+ }
+ >>
+ vfrExtensionData [DataBuff, Size, TypeName, TypeSize, IsStruct, ArrayNum]
+ }
+ <<
+ {
+ GuidObj = new CIfrGuid(Size);
+ if (GuidObj != NULL) {
+ GuidObj->SetLineNo(L->getLine());
+ GuidObj->SetGuid (&Guid);
+ }
+ }
+ if (TypeName != NULL) {
+ GuidObj->SetData(DataBuff, Size);
+ }
+ >>
+ {","
+ (
+ vfrStatementExtension
+ )*
+ E:EndGuidOp << GuidObj->SetScope(1); CRT_END_OP (E); >>
+ }
+ <<
+ if (GuidObj != NULL) delete GuidObj;
+ if (DataBuff != NULL) free(DataBuff);
+ >>
+ ";"
+;
+
+vfrExtensionData[UINT8 *DataBuff, UINT32 Size, CHAR8 *TypeName, UINT32 TypeSize, BOOLEAN IsStruct, UINT32 ArrayNum]:
+ <<
+ CHAR8 *TFName = NULL;
+ UINT32 ArrayIdx = 0;
+ UINT16 FieldOffset;
+ UINT8 FieldType;
+ UINT32 FieldSize;
+ UINT64 Data_U64 = 0;
+ UINT32 Data_U32 = 0;
+ UINT16 Data_U16 = 0;
+ UINT8 Data_U8 = 0;
+ BOOLEAN Data_BL = 0;
+ EFI_STRING_ID Data_SID = 0;
+ BOOLEAN IsArray = FALSE;
+ UINT8 *ByteOffset = NULL;
+ >>
+(
+ ("," "data" {OpenBracket IDX1:Number CloseBracket <<IsArray = TRUE;>>}
+ <<
+ ArrayIdx = 0;
+ if (IsArray == TRUE) {
+ ArrayIdx = _STOU8(IDX1->getText());
+ if (ArrayIdx >= ArrayNum) return;
+ IsArray = FALSE;
+ }
+ ByteOffset = DataBuff + (ArrayIdx * TypeSize);
+ if (IsStruct == TRUE) {
+ _STRCAT(&TFName, TypeName);
+ }
+ >>
+ ("." FN:StringIdentifier
+ <<
+ if (IsStruct == TRUE) {
+ _STRCAT(&TFName, ".");
+ _STRCAT(&TFName, FN->getText());
+ }
+ >>
+ {
+ OpenBracket IDX2:Number CloseBracket
+ <<
+ if (IsStruct == TRUE) {
+ _STRCAT(&TFName, "[");
+ _STRCAT(&TFName, IDX2->getText());
+ _STRCAT(&TFName, "]");
+ }
+ >>
+ }
+ )*
+ "=" RD:Number
+ <<
+ if (IsStruct == FALSE) {
+ if (strcmp ("UINT64", TypeName) == 0) {
+ Data_U64 = _STOU64(RD->getText());
+ memcpy (ByteOffset, &Data_U64, TypeSize);
+ }else if (strcmp ("UINT32", TypeName) == 0) {
+ Data_U32 = _STOU32(RD->getText());
+ memcpy (ByteOffset, &Data_U32, TypeSize);
+ }else if (strcmp ("UINT16", TypeName) == 0) {
+ Data_U16 = _STOU16(RD->getText());
+ memcpy (ByteOffset, &Data_U16, TypeSize);
+ }else if (strcmp ("UINT8", TypeName) == 0) {
+ Data_U8 = _STOU8(RD->getText());
+ memcpy (ByteOffset, &Data_U8, TypeSize);
+ }else if (strcmp ("BOOLEAN", TypeName)== 0) {
+ Data_BL = _STOU8(RD->getText());
+ memcpy (ByteOffset, &Data_BL, TypeSize);
+ }else if (strcmp ("EFI_STRING_ID", TypeName) == 0) {
+ Data_SID = _STOSID(RD->getText());
+ memcpy (ByteOffset, &Data_SID, TypeSize);
+ }
+ } else {
+ gCVfrVarDataTypeDB.GetDataFieldInfo(TFName, FieldOffset, FieldType, FieldSize);
+ switch (FieldType) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ Data_U8 = _STOU8(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_U8, FieldSize);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ Data_U16 = _STOU16(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_U16, FieldSize);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ Data_U32 = _STOU32(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_U32, FieldSize);
+ break;
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ Data_U64 = _STOU64(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_U64, FieldSize);
+ break;
+ case EFI_IFR_TYPE_BOOLEAN:
+ Data_BL = _STOU8(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_BL, FieldSize);
+ break;
+ case EFI_IFR_TYPE_STRING:
+ Data_SID = _STOSID(RD->getText());
+ memcpy (ByteOffset + FieldOffset, &Data_SID, FieldSize);
+ break;
+ default:
+ break;
+ }
+ }
+ if (TFName != NULL) { delete TFName; TFName = NULL; }
+ >>
+ )*
+)
+;
+
+
vfrStatementDefaultStore :
<< UINT16 DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; >>
D:DefaultStore N:StringIdentifier ","
@@ -1060,7 +1250,8 @@ vfrFormDefinition :
vfrStatementLabel |
vfrStatementBanner |
// Just for framework vfr compatibility
- vfrStatementInvalid
+ vfrStatementInvalid |
+ vfrStatementExtension
)*
E:EndForm <<
if (mCompatibleMode) {
@@ -1118,7 +1309,8 @@ vfrFormMapDefinition :
vfrStatementQuestions |
vfrStatementConditional |
vfrStatementLabel |
- vfrStatementBanner
+ vfrStatementBanner |
+ vfrStatementExtension
)*
E:EndForm << CRT_END_OP (E); >>
";"
@@ -2146,7 +2338,8 @@ vfrStatementQuestionTag :
vfrStatementNoSubmitIf |
vfrStatementDisableIfQuest |
vfrStatementRefresh |
- vfrStatementVarstoreDevice
+ vfrStatementVarstoreDevice |
+ vfrStatementExtension
;
vfrStatementQuestionTagList :
@@ -2175,6 +2368,7 @@ vfrStatementStatList :
vfrStatementQuestions |
vfrStatementConditionalNew |
vfrStatementLabel |
+ vfrStatementExtension |
// Just for framework vfr compatibility
vfrStatementInvalid
;
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
index 3797cd8228..b839a0ab0e 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp
@@ -2,7 +2,7 @@
Vfr common library functions.
-Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -622,6 +622,9 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
if (*VarStr == ']') {
VarStr++;
}
+ if (*VarStr == '.') {
+ VarStr++;
+ }
return VFR_RETURN_SUCCESS;
case ']':
return VFR_RETURN_DATA_STRING_ERROR;
@@ -1456,10 +1459,8 @@ CVfrDataStorage::DeclareNameVarStoreBegin (
return VFR_RETURN_FATAL_ERROR;
}
- for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {
- if (strcmp (pNode->mVarStoreName, StoreName) == 0) {
- return VFR_RETURN_REDEFINED;
- }
+ if (GetVarStoreId (StoreName, &VarStoreId) == VFR_RETURN_SUCCESS) {
+ return VFR_RETURN_REDEFINED;
}
VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_NAME);
@@ -1531,10 +1532,8 @@ CVfrDataStorage::DeclareEfiVarStore (
return VFR_RETURN_EFIVARSTORE_SIZE_ERROR;
}
- for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {
- if (strcmp (pNode->mVarStoreName, StoreName) == 0) {
- return VFR_RETURN_REDEFINED;
- }
+ if (GetVarStoreId (StoreName, &VarStoreId) == VFR_RETURN_SUCCESS) {
+ return VFR_RETURN_REDEFINED;
}
VarStoreId = GetFreeVarStoreId (EFI_VFR_VARSTORE_EFI);
@@ -1560,11 +1559,16 @@ CVfrDataStorage::DeclareBufferVarStore (
{
SVfrVarStorageNode *pNew = NULL;
SVfrDataType *pDataType = NULL;
+ EFI_VARSTORE_ID TempVarStoreId;
if ((StoreName == NULL) || (Guid == NULL) || (DataTypeDB == NULL)) {
return VFR_RETURN_FATAL_ERROR;
}
+ if (GetVarStoreId (StoreName, &TempVarStoreId) == VFR_RETURN_SUCCESS) {
+ return VFR_RETURN_REDEFINED;
+ }
+
CHECK_ERROR_RETURN(DataTypeDB->GetDataType (TypeName, &pDataType), VFR_RETURN_SUCCESS);
if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
@@ -1591,11 +1595,50 @@ CVfrDataStorage::DeclareBufferVarStore (
}
EFI_VFR_RETURN_CODE
+CVfrDataStorage::GetVarStoreByDataType (
+ IN CHAR8 *DataTypeName,
+ OUT SVfrVarStorageNode **VarNode
+ )
+{
+ SVfrVarStorageNode *pNode;
+ SVfrVarStorageNode *MatchNode;
+
+ //
+ // Framework VFR uses Data type name as varstore name, so don't need check again.
+ //
+ if (VfrCompatibleMode) {
+ return VFR_RETURN_UNDEFINED;
+ }
+
+ MatchNode = NULL;
+ for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (strcmp (pNode->mStorageInfo.mDataType->mTypeName, DataTypeName) == 0) {
+ if (MatchNode == NULL) {
+ MatchNode = pNode;
+ } else {
+ //
+ // More than one varstores referred the same data structures.
+ //
+ return VFR_RETURN_VARSTORE_DATATYPE_REDEFINED_ERROR;
+ }
+ }
+ }
+
+ if (MatchNode == NULL) {
+ return VFR_RETURN_UNDEFINED;
+ }
+
+ *VarNode = MatchNode;
+ return VFR_RETURN_SUCCESS;
+}
+
+EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreId (
IN CHAR8 *StoreName,
OUT EFI_VARSTORE_ID *VarStoreId
)
{
+ EFI_VFR_RETURN_CODE ReturnCode;
SVfrVarStorageNode *pNode;
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
@@ -1623,8 +1666,18 @@ CVfrDataStorage::GetVarStoreId (
}
mCurrVarStorageNode = NULL;
- *VarStoreId = EFI_VARSTORE_ID_INVALID;
- return VFR_RETURN_UNDEFINED;
+ *VarStoreId = EFI_VARSTORE_ID_INVALID;
+
+ //
+ // Assume that Data strucutre name is used as StoreName, and check again.
+ //
+ ReturnCode = GetVarStoreByDataType (StoreName, &pNode);
+ if (pNode != NULL) {
+ mCurrVarStorageNode = pNode;
+ *VarStoreId = pNode->mVarStoreId;
+ }
+
+ return ReturnCode;
}
EFI_VFR_RETURN_CODE
@@ -1634,6 +1687,7 @@ CVfrDataStorage::GetBufferVarStoreDataTypeName (
)
{
SVfrVarStorageNode *pNode;
+ EFI_VFR_RETURN_CODE ReturnCode;
if ((StoreName == NULL) || (DataTypeName == NULL)) {
return VFR_RETURN_FATAL_ERROR;
@@ -1645,8 +1699,16 @@ CVfrDataStorage::GetBufferVarStoreDataTypeName (
}
}
+ ReturnCode = VFR_RETURN_UNDEFINED;
+ //
+ // Assume that Data strucutre name is used as StoreName, and check again.
+ //
if (pNode == NULL) {
- return VFR_RETURN_UNDEFINED;
+ ReturnCode = GetVarStoreByDataType (StoreName, &pNode);
+ }
+
+ if (pNode == NULL) {
+ return ReturnCode;
}
if (pNode->mStorageInfo.mDataType == NULL) {
@@ -1664,6 +1726,7 @@ CVfrDataStorage::GetVarStoreType (
)
{
SVfrVarStorageNode *pNode;
+ EFI_VFR_RETURN_CODE ReturnCode;
if (StoreName == NULL) {
return VFR_RETURN_FATAL_ERROR;
@@ -1691,7 +1754,16 @@ CVfrDataStorage::GetVarStoreType (
}
VarStoreType = EFI_VFR_VARSTORE_INVALID;
- return VFR_RETURN_UNDEFINED;
+
+ //
+ // Assume that Data strucutre name is used as StoreName, and check again.
+ //
+ ReturnCode = GetVarStoreByDataType (StoreName, &pNode);
+ if (pNode != NULL) {
+ VarStoreType = pNode->mVarStoreType;
+ }
+
+ return ReturnCode;
}
EFI_VFR_VARSTORE_TYPE
@@ -1841,6 +1913,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
{
SVfrVarStorageNode *pNode = NULL;
EFI_IFR_TYPE_VALUE Value = gZeroEfiIfrTypeValue;
+ EFI_VFR_RETURN_CODE ReturnCode;
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
if (strcmp (pNode->mVarStoreName, StoreName) == 0) {
@@ -1848,8 +1921,16 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
}
}
+ ReturnCode = VFR_RETURN_UNDEFINED;
+ //
+ // Assume that Data strucutre name is used as StoreName, and check again.
+ //
if (pNode == NULL) {
- return VFR_RETURN_UNDEFINED;
+ ReturnCode = GetVarStoreByDataType (StoreName, &pNode);
+ }
+
+ if (pNode == NULL) {
+ return ReturnCode;
}
gCVfrBufferConfig.Open ();
diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
index bec5d67b94..b921115b0a 100644
--- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
+++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h
@@ -2,7 +2,7 @@
Vfr common library functions.
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, 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
@@ -307,6 +307,7 @@ public:
EFI_VFR_RETURN_CODE GetVarStoreType (IN CHAR8 *, OUT EFI_VFR_VARSTORE_TYPE &);
EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT CHAR8 **);
+ EFI_VFR_RETURN_CODE GetVarStoreByDataType (IN CHAR8 *, OUT SVfrVarStorageNode **);
EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN CHAR8 *, OUT CHAR8 **);
EFI_VFR_RETURN_CODE GetEfiVarStoreInfo (IN EFI_VARSTORE_INFO *);