summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Sample
diff options
context:
space:
mode:
Diffstat (limited to 'EdkCompatibilityPkg/Sample')
-rw-r--r--EdkCompatibilityPkg/Sample/CommonTools.env23
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Common.dsc173
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc3
-rw-r--r--EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h15
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c11
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c148
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h38
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c51
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c66
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c36
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c35
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c32
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c59
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h12
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c219
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c37
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h5
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c475
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h8
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c37
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c208
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c2561
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h63
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c2533
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h267
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile103
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c244
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h125
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c53
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Makefile4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c21
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c80
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile27
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c905
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h116
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c326
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c28
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c28
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c164
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c27
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h49
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c48
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c740
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile71
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c564
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c94
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h60
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h4
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp133
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h11
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp80
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h8
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp107
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h198
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g1001
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp424
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h68
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile5
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h6
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g83
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp16
-rw-r--r--EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile4
-rw-r--r--EdkCompatibilityPkg/Sample/Version.env4
67 files changed, 11536 insertions, 1712 deletions
diff --git a/EdkCompatibilityPkg/Sample/CommonTools.env b/EdkCompatibilityPkg/Sample/CommonTools.env
index cd7d4c2ea7..567e746c83 100644
--- a/EdkCompatibilityPkg/Sample/CommonTools.env
+++ b/EdkCompatibilityPkg/Sample/CommonTools.env
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -83,6 +83,7 @@ GENFVIMAGE = $(EDK_TOOLS_OUTPUT)\GenFvImage
GENSECTION = $(EDK_TOOLS_OUTPUT)\GenSection
GENTEIMAGE = $(EDK_TOOLS_OUTPUT)\GenTEImage
GUIDCHK = $(EDK_TOOLS_OUTPUT)\GuidChk
+HIIPACK = $(EDK_TOOLS_OUTPUT)\HiiPack
MAKEDEPS = $(EDK_TOOLS_OUTPUT)\MakeDeps
PROCESSDSC = $(EDK_TOOLS_OUTPUT)\ProcessDsc
STRGATHER = $(EDK_TOOLS_OUTPUT)\StrGather
@@ -188,6 +189,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
@@ -274,6 +276,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ia32\$(EFI_ASSEMBLER_NAME)\binr\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
ASM_ARCH_FLAGS = $(ASM_ARCH_FLAGS) /Zi /DDEBUG
@@ -381,6 +384,7 @@ ASMLINK = $(EDK_TOOLS_BIN)\Ipf\$(EFI_ASSEMBLER_NAME)\link
!ENDIF
BSCMAKE = bscmake
+RC = rc
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
C_STD_FLAGS = $(C_STD_FLAGS) /Zi /Gm /Fd$(DEST_DIR)\$(BASE_NAME)Obj
@@ -531,8 +535,10 @@ EBC_CC = $(EBC_TOOLS_PATH)\Bin\Iec
EBC_LINK = $(EBC_TOOLS_PATH)\Bin\Link
EBC_LIB = $(EBC_TOOLS_PATH)\Bin\Link /lib
+RC = rc
+
!IF "$(EFI_SYMBOLIC_DEBUG)" == "YES"
-EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /Zd /Zi
+EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /Zi
EBC_LINK_STD_FLAGS = $(EBC_LINK_STD_FLAGS) /DEBUG
!ENDIF
@@ -579,6 +585,15 @@ VFRCOMPILE_FLAGS = $(VFRCOMPILE_FLAGS) -ppflag "$(VERSION_FLAGS)"
ASM_STD_FLAGS = $(ASM_STD_FLAGS) $(VERSION_FLAGS)
!ENDIF
+!IF "$(TOOLCHAIN)" != "TOOLCHAIN_MSVC"
+BUILD_STRING_FLAGS = /D EFI_BUILD_VERSION="L\"$(EDK_BUILD_VERSION)\"" /D EFI_FIRMWARE_VENDOR="L\"TianoCore.org\""
+!ELSE
+BUILD_STRING_FLAGS = /D UTILITY_BUILD="\"$(EDK_BUILD_VERSION)\"" /D UTILITY_VENDOR="\"TianoCore.org\""
+!ENDIF
+
+C_STD_FLAGS = $(C_STD_FLAGS) $(BUILD_STRING_FLAGS)
+EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) $(BUILD_STRING_FLAGS)
+
!IF "$(EFI_DEBUG)" == "YES"
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_DEBUG
!ENDIF
@@ -611,6 +626,10 @@ FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_DXE_PERFORMANCE
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_S3_RESUME
!ENDIF
+!IF "$(EFI_NO_CSM_SUPPORT)" == "YES"
+FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_NO_CSM_SUPPORT
+!ENDIF
+
!IF "$(EFI_SIZE_REDUCTION_APPLIED)" == "YES"
FEATURE_FLAGS = $(FEATURE_FLAGS) /D EFI_SIZE_REDUCTION_APPLIED
!ENDIF
diff --git a/EdkCompatibilityPkg/Sample/Platform/Common.dsc b/EdkCompatibilityPkg/Sample/Platform/Common.dsc
index c077e81c9e..be582eec68 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Common.dsc
+++ b/EdkCompatibilityPkg/Sample/Platform/Common.dsc
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -268,7 +268,7 @@ $(DEST_DIR)\$(FILE).obj : $(SOURCE_FILE_NAME) $(INF_FILENAME) $(ALL_DEPS)
# know how to create the .apr file, then you're missing (or mispelled) the
# "APRIORI=" on the component lines in components section in the DSC file.
#
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)
+$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME) $(INF_FILENAME)
$(GENAPRIORI) -v -f $(SOURCE_FILE_NAME) -o $(DEST_DIR)\$(BASE_NAME).bin
$(DEST_DIR)\$(BASE_NAME).sec : $(DEST_DIR)\$(BASE_NAME).bin
@@ -299,34 +299,29 @@ clean :
[Build.Ia32.Makefile,Build.Ipf.Makefile,Build.Ebc.Makefile,Build.x64.Makefile]
#
-# Copy the makefile directly from the source directory, then make it
-# writable so we can copy over it later if we try to.
+# Set some required macros
#
-$(DEST_DIR)\makefile.new : $(SOURCE_DIR)\makefile.new
- copy $(SOURCE_DIR)\makefile.new $(DEST_DIR)\makefile.new
- attrib -r $(DEST_DIR)\makefile.new
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR) \
+ BUILD_DIR=$(BUILD_DIR) \
+ FILE_GUID=$(FILE_GUID) \
+ DEST_DIR=$(DEST_DIR) \
+ PROCESSOR=$(PROCESSOR) \
+ TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
+ BASE_NAME=$(BASE_NAME) \
+ PACKAGE_FILENAME=$(PACKAGE_FILENAME)
#
-# Make the all target, set some required macros.
+# Just call the makefile from the source directory, passing in some
+# useful info.
#
-call_makefile :
- $(MAKE) -f $(DEST_DIR)\makefile.new all \
- SOURCE_DIR=$(SOURCE_DIR) \
- BUILD_DIR=$(BUILD_DIR) \
- FILE_GUID=$(FILE_GUID) \
- DEST_DIR=$(DEST_DIR) \
- PROCESSOR=$(PROCESSOR) \
- TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
- BASE_NAME=$(BASE_NAME) \
- PACKAGE_FILENAME=$(PACKAGE_FILENAME)
-
-all : $(DEST_DIR)\makefile.new call_makefile
+all :
+ $(MAKE) -f $(SOURCE_DIR)\makefile.new all $(MAKEFILE_MACROS)
#
# Remove the generated temp and final files for this modules.
#
clean :
- @- $(MAKE) -f $(DEST_DIR)\makefile.new clean > NUL 2>&1
+ @- $(MAKE) -f $(SOURCE_DIR)\makefile.new clean $(MAKEFILE_MACROS) > NUL 2>&1
!IF ("$(FILE_GUID)" != "")
@if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
!ENDIF
@@ -345,27 +340,31 @@ clean :
[Build.Ia32.Custom_Makefile,Build.Ipf.Custom_Makefile,Build.Ebc.Custom_Makefile,Build.x64.Custom_Makefile]
#
+# Set some required macros
+#
+MAKEFILE_MACROS = SOURCE_DIR=$(SOURCE_DIR) \
+ BUILD_DIR=$(BUILD_DIR) \
+ DEST_DIR=$(DEST_DIR) \
+ FILE_GUID=$(FILE_GUID) \
+ PROCESSOR=$(PROCESSOR) \
+ TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
+ BASE_NAME=$(BASE_NAME) \
+ PLATFORM=$(PLATFORM) \
+ SOURCE_FV=$(SOURCE_FV) \
+ PACKAGE_FILENAME=$(PACKAGE_FILENAME)
+
+#
# Just call the makefile from the source directory, passing in some
# useful info.
#
all :
- $(MAKE) -f $(SOURCE_DIR)\makefile all \
- SOURCE_DIR=$(SOURCE_DIR) \
- BUILD_DIR=$(BUILD_DIR) \
- DEST_DIR=$(DEST_DIR) \
- FILE_GUID=$(FILE_GUID) \
- PROCESSOR=$(PROCESSOR) \
- TOOLCHAIN=TOOLCHAIN_$(PROCESSOR) \
- BASE_NAME=$(BASE_NAME) \
- PLATFORM=$(PLATFORM) \
- SOURCE_FV=$(SOURCE_FV) \
- PACKAGE_FILENAME=$(PACKAGE_FILENAME)
+ $(MAKE) -f $(SOURCE_DIR)\makefile all $(MAKEFILE_MACROS)
#
# Remove the generated temp and final files for this modules.
#
clean :
- @- $(MAKE) -f $(SOURCE_DIR)\makefile clean > NUL 2>&1
+ @- $(MAKE) -f $(SOURCE_DIR)\makefile clean $(MAKEFILE_MACROS) > NUL 2>&1
!IF ("$(FILE_GUID)" != "")
@if exist $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).* del $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).*
!ENDIF
@@ -496,9 +495,29 @@ clean :
!IF "$(LOCALIZE)" == "YES"
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"
-STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
+#
+# This will generate HII resource section in PE/COFF image.
+#
+# Note: when HII package list is built into resource section, Driver no longer
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
+# to minimize the code size.
+#
+HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
+LINK_FLAGS_DLL = $(LINK_FLAGS_DLL) $(DEST_DIR)\$(BASE_NAME).res
+
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
+ $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
+
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
+ $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
+!ENDIF
+
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
#
# There will be one HII pack containing all the strings. Add that file
# to the list of HII pack files we'll use to create our final HII export file.
@@ -507,6 +526,15 @@ HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii
!ENDIF
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
+#
+# Note: currently -ppflag option is only available for UefiStrGather
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
+#
+STRGATHER_PPFLAG = $(C_FLAGS: /GS-=)
+STRGATHER_FLAGS = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+!ENDIF
+
$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
$(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
-skipext .uni -skipext .h $(SOURCE_FILES)
@@ -528,7 +556,7 @@ OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)
$(CC) $(C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
!ENDIF
@@ -677,7 +705,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo.>$(TARGET_VER)
type $(TARGET_VER)>$(TARGET_VER)
!ENDIF
@@ -741,7 +769,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -796,7 +824,7 @@ $(TARGET_DXE_DPX) : $(SOURCE_DIR)\$(DXE_DPX_SOURCE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(SOURCE_DIR)\$(DXE_DPX_SOURCE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DXE_DPX) :
+$(TARGET_DXE_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DXE_DPX)
type $(TARGET_DXE_DPX) > $(TARGET_DXE_DPX)
!ENDIF
@@ -963,7 +991,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo.>$(TARGET_VER)
type $(TARGET_VER)>$(TARGET_VER)
!ENDIF
@@ -1027,7 +1055,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1069,9 +1097,29 @@ LIBS = $(LIBS) $(EBC_TOOLS_PATH)\lib\EbcLib.lib
!IF "$(LOCALIZE)" == "YES"
-!IF "$(EFI_GENERATE_HII_EXPORT)" == "YES"
-STRGATHER_FLAGS = $(STRGATHER_FLAGS) -hpk $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+!IF (("$(EFI_GENERATE_HII_RESOURCE)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"))
+#
+# This will generate HII resource section in PE/COFF image.
+#
+# Note: when HII package list is built into resource section, Driver no longer
+# refer to C array generated by VfrCompiler ($(FILE_NAME)Bin) and StrGather
+# ($(BASE_NAME)Strings); while in current build rule, those C array objects
+# will still be linked with the Driver, so please turn on link flag "/OPT:REF"
+# to minimize the code size.
+#
+HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
+LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).res
+OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME).res
+
+$(DEST_DIR)\$(BASE_NAME).rc : $(HII_PACK_FILES)
+ $(HIIPACK) -g $(FILE_GUID) $(HII_PACK_FILES) -rc $(DEST_DIR)\$(BASE_NAME).rc -hii $(DEST_DIR)\$(BASE_NAME).hii
+$(DEST_DIR)\$(BASE_NAME).res : $(DEST_DIR)\$(BASE_NAME).rc
+ $(RC) /fo $(DEST_DIR)\$(BASE_NAME).res $(DEST_DIR)\$(BASE_NAME).rc
+
+!ENDIF
+
+!IF (("$(EFI_GENERATE_HII_EXPORT)" == "YES") && ("$(EFI_SPECIFICATION_VERSION)" < "0x0002000A"))
#
# There will be one HII pack containing all the strings. Add that file
# to the list of HII pack files we'll use to create our final HII export file.
@@ -1081,6 +1129,15 @@ HII_PACK_FILES = $(HII_PACK_FILES) $(DEST_DIR)\$(BASE_NAME)Strings.hpk
LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME).hii
!ENDIF
+!IF ("$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A")
+#
+# Note: currently -ppflag option is only available for UefiStrGather
+# Note: /GS- will cause warning for preprocess, so filter it out from STRGATHER_PPFLAG
+#
+STRGATHER_PPFLAG = $(EBC_C_FLAGS: /GS-=)
+STRGATHER_FLAGS = $(STRGATHER_FLAGS) -ppflag "$(STRGATHER_PPFLAG)" -oh $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+!ENDIF
+
$(DEST_DIR)\$(BASE_NAME).sdb : $(SDB_FILES) $(SOURCE_FILES)
$(STRGATHER) -scan -vdbr $(STRGATHER_FLAGS) -od $(DEST_DIR)\$(BASE_NAME).sdb \
-skipext .uni -skipext .h $(SOURCE_FILES)
@@ -1102,7 +1159,7 @@ OBJECTS = $(OBJECTS) $(DEST_DIR)\$(BASE_NAME)Strings.obj
$(DEST_DIR)\$(BASE_NAME)Strings.obj : $(DEST_DIR)\$(BASE_NAME)Strings.c $(INF_FILENAME) $(ALL_DEPS)
$(EBC_CC) $(EBC_C_FLAGS) $(DEST_DIR)\$(BASE_NAME)Strings.c
-LOCALIZE_TARGETS = $(LOCALIZE_TARGETS) $(DEST_DIR)\$(BASE_NAME)StrDefs.h
+LOCALIZE_TARGETS = $(DEST_DIR)\$(BASE_NAME)StrDefs.h $(LOCALIZE_TARGETS)
!ENDIF
@@ -1170,7 +1227,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo. > $(TARGET_VER)
type $(TARGET_VER) > $(TARGET_VER)
!ENDIF
@@ -1234,7 +1291,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1293,7 +1350,7 @@ clean :
# This section, as it now exists, only supports boot service drivers.
#
[=============================================================================]
-[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI]
+[Build.Ia32.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ipf.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI,Build.Ebc.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI,Build.x64.BS_DRIVER_EFI|RT_DRIVER_EFI|APPLICATION_EFI|PE32_PEIM_EFI]
#
# Defines for standard intermediate files and build targets. For the source
# .efi file, take the one in the source directory if it exists. If there's not
@@ -1320,6 +1377,8 @@ TARGET_DLL = $(BIN_DIR)\$(BASE_NAME).dll
#
!IF "$(COMPONENT_TYPE)" == "APPLICATION"
TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).app
+!ELSE IF "$(COMPONENT_TYPE)" == "PE32_PEIM"
+TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).pei
!ELSE
TARGET_FFS_FILE = $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).dxe
!ENDIF
@@ -1348,7 +1407,7 @@ $(TARGET_VER) : $(INF_FILENAME)
$(GENSECTION) -O $(TARGET_VER) -S EFI_SECTION_VERSION -V $(BUILD_NUMBER)
!ENDIF
!ELSE
-$(TARGET_VER) :
+$(TARGET_VER) : $(INF_FILENAME)
echo. > $(TARGET_VER)
type $(TARGET_VER) > $(TARGET_VER)
!ENDIF
@@ -1412,7 +1471,7 @@ $(TARGET_DPX) : $(DPX_SOURCE_FILE) $(INF_FILENAME)
!ERROR Dependency expression source file "$(DPX_SOURCE_FILE)" does not exist.
!ENDIF
!ELSE
-$(TARGET_DPX) :
+$(TARGET_DPX) : $(INF_FILENAME)
echo. > $(TARGET_DPX)
type $(TARGET_DPX) > $(TARGET_DPX)
!ENDIF
@@ -1438,18 +1497,17 @@ clean :
[=============================================================================]
[Compile.Ia32.Bin|Bmp,Compile.x64.Bin|Bmp,Compile.Ipf.Bin|Bmp]
#
-# We simply copy the binary file from the source directory to the destination directory
+# We simply define the binary source file name
#
-$(DEST_DIR)\$(BASE_NAME).bin : $(SOURCE_FILE_NAME)
- copy $** $@
+BINARY_SOURCE_FILE = $(SOURCE_FILE_NAME)
[=============================================================================]
[Build.Ia32.BINARY|Legacy16|Logo,Build.Ipf.BINARY|Legacy16|Logo,Build.x64.BINARY|Legacy16|Logo]
#
# Use GenFfsFile to convert it to an FFS file
#
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)
- $(GENSECTION) -I $(DEST_DIR)\$(BASE_NAME).bin -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
+ $(GENSECTION) -I $(BINARY_SOURCE_FILE) -O $(DEST_DIR)\$(BASE_NAME).sec -S EFI_SECTION_RAW
$(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).ffs
@@ -1469,7 +1527,8 @@ clean :
#
# Use GenFfsFile to convert it to an raw FFS file
#
-$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(DEST_DIR)\$(BASE_NAME).bin $(PACKAGE_FILENAME)
+$(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw : $(BINARY_SOURCE_FILE) $(PACKAGE_FILENAME) $(INF_FILENAME)
+ copy $(BINARY_SOURCE_FILE) $(DEST_DIR)\$(BASE_NAME).bin /Y
$(GENFFSFILE) -B $(DEST_DIR) -P1 $(PACKAGE_FILENAME) -V
all : $(BIN_DIR)\$(FILE_GUID)-$(BASE_NAME).raw
@@ -1516,6 +1575,8 @@ STRGATHER_FLAGS = $(STRGATHER_FLAGS) -db $(DEST_DIR)\$(FILE).sdb
LOCALIZE = YES
[=============================================================================]
+[Compile.Ia32.hfr,Compile.Ipf.hfr,Compile.Ebc.hfr,Compile.x64.hfr]
+[=============================================================================]
[Compile.Ia32.Vfr,Compile.Ipf.Vfr,Compile.x64.Vfr]
#
@@ -1695,7 +1756,7 @@ HII_IFR_PACK_FILES = $(HII_IFR_PACK_FILES) $(DEST_DIR)\$(FILE).hpk
#
# Run GenSection on the firmware volume image.
#
-$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME)
+$(DEST_DIR)\$(SOURCE_FV)Fv.sec : $(SOURCE_FILE_NAME) $(INF_FILENAME)
$(GENSECTION) -I $(SOURCE_FILE_NAME) -O $(DEST_DIR)\$(SOURCE_FV)Fv.sec -S EFI_SECTION_FIRMWARE_VOLUME_IMAGE
[=============================================================================]
diff --git a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
index 533695cd47..0eba5f9e3a 100644
--- a/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
+++ b/EdkCompatibilityPkg/Sample/Platform/EdkIIGlueLibAll.dsc
@@ -1,5 +1,5 @@
#/*++
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@@ -54,3 +54,4 @@ $(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib\DxeSmbusLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib\PeiSmbusLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\DxePerformanceLib\DxePerformanceLib.inf
$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\PeiPerformanceLib\PeiPerformanceLib.inf
+$(EDK_PREFIX)Foundation\Library\EdkIIGlueLib\Library\SmmRuntimeDxeReportStatusCodeLib\SmmRuntimeDxeReportStatusCodeLib.inf
diff --git a/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h b/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
index 6f2839fa4a..099ce167d3 100644
--- a/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
+++ b/EdkCompatibilityPkg/Sample/Platform/Generic/Pei/Capsule/Capsule.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -20,8 +20,21 @@ Abstract:
#ifndef _CAPSULE_PEIM_H
#define _CAPSULE_PEIM_H
+#include "Tiano.h"
+
//
// If capsule data is passed via a variable, then this name should be used.
//
#define EFI_CAPSULE_VARIABLE_NAME L"CapsuleUpdateData"
+
+//
+// The variable describes the long mode buffer used by IA32 Capsule PEIM
+// to call X64 CapsuleCoalesce code to handle >4GB capsule blocks.
+//
+#define EFI_CAPSULE_LONG_MODE_BUFFER_NAME L"CapsuleLongModeBuffer"
+typedef struct {
+ UINT64 Base;
+ UINT64 Length;
+} EFI_CAPSULE_LONG_MODE_BUFFER;
+
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
index 341204852c..f133d358d5 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/FvLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -707,8 +707,13 @@ Returns:
//
FileLength = GetLength (FfsHeader->Size);
OccupiedFileLength = (FileLength + 0x07) & (-1 << 3);
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
Checksum = CalculateSum8 ((UINT8 *) FfsHeader, FileLength - TailSize);
Checksum = (UINT8) (Checksum - FfsHeader->State);
+#else
+ Checksum = CalculateSum8 ((UINT8 *) ((UINTN)FfsHeader + sizeof (EFI_FFS_FILE_HEADER)), FileLength - TailSize - sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = Checksum + (UINT8)FfsHeader->IntegrityCheck.Checksum.File;
+#endif
if (Checksum != 0) {
Error (NULL, 0, 0, FileGuidString, "invalid FFS file checksum");
return EFI_ABORTED;
@@ -716,10 +721,10 @@ Returns:
} else {
//
// File does not have a checksum
- // Verify contents are 0x5A as spec'd
+ // Verify contents are 0x5A(Framework) and 0xAA(PI 1.0) as spec'd
//
if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
- Error (NULL, 0, 0, FileGuidString, "invalid fixed FFS file header checksum");
+ Error (NULL, 0, 0, FileGuidString, "invalid fixed file checksum");
return EFI_ABORTED;
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
index 3d9fe11ab9..5abea63106 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -344,6 +344,152 @@ Returns:
}
EFI_STATUS
+FindTokenInstanceInSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN UINTN Instance,
+ OUT CHAR8 *Token,
+ OUT CHAR8 *Value
+ )
+/*++
+
+Routine Description:
+
+ Finds the Instance-th token in a section.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Instance Specify the Instance-th token to search for, starting from zero
+ Token The token name to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+ Value The token value to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Token and Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+{
+ CHAR8 InputBuffer[_MAX_PATH];
+ CHAR8 *CurrentToken;
+ CHAR8 *CurrentValue;
+ BOOLEAN ParseError;
+ BOOLEAN ReadError;
+ UINTN InstanceIndex;
+
+ //
+ // Check input parameters
+ //
+ if (InputFile->FileImage == NULL ||
+ InputFile->Eof == NULL ||
+ InputFile->CurrentFilePointer == NULL ||
+ Section == NULL ||
+ strlen (Section) == 0 ||
+ Value == NULL
+ ) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Initialize error codes
+ //
+ ParseError = FALSE;
+ ReadError = FALSE;
+
+ //
+ // Initialize our instance counter for the search token
+ //
+ InstanceIndex = 0;
+
+ if (FindSection (InputFile, Section)) {
+ //
+ // Found the desired section, find and read the desired token
+ //
+ do {
+ //
+ // Read a line from the file
+ //
+ if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {
+ //
+ // Error reading from input file
+ //
+ ReadError = TRUE;
+ break;
+ }
+ //
+ // Get the first non-whitespace string
+ //
+ CurrentToken = strtok (InputBuffer, " \t\n");
+ if (CurrentToken == NULL) {
+ //
+ // Whitespace line found (or comment) so continue
+ //
+ CurrentToken = InputBuffer;
+ continue;
+ }
+ //
+ // Make sure we have not reached the end of the current section
+ //
+ if (CurrentToken[0] == '[') {
+ break;
+ }
+ //
+ // Check if it is the correct instance
+ //
+ if (Instance == InstanceIndex) {
+ //
+ // Copy the contents following the =
+ //
+ CurrentValue = strtok (NULL, "= \t\n");
+ if (CurrentValue == NULL) {
+ //
+ // Nothing found, parsing error
+ //
+ ParseError = TRUE;
+ } else {
+ //
+ // Copy the current token to the output value
+ //
+ strcpy (Token, CurrentToken);
+ strcpy (Value, CurrentValue);
+ return EFI_SUCCESS;
+ }
+ } else {
+ //
+ // Increment the occurrance found
+ //
+ InstanceIndex++;
+ }
+ } while (
+ !ParseError &&
+ !ReadError &&
+ InputFile->CurrentFilePointer < InputFile->Eof &&
+ CurrentToken[0] != '[' &&
+ InstanceIndex <= Instance
+ );
+ }
+ //
+ // Distinguish between read errors and INF file format errors.
+ //
+ if (ReadError) {
+ return EFI_LOAD_ERROR;
+ }
+
+ if (ParseError) {
+ return EFI_ABORTED;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
StringToGuid (
IN CHAR8 *AsciiGuidBuffer,
OUT EFI_GUID *GuidBuffer
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
index 7dba8f8fdc..3d5eb5c34f 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Common/ParseInf.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -124,6 +124,42 @@ Returns:
EFI_NOT_FOUND Section/Token/Value not found.
--*/
+
+EFI_STATUS
+FindTokenInstanceInSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN UINTN Instance,
+ OUT CHAR8 *Token,
+ OUT CHAR8 *Value
+ )
+;
+/*++
+
+Routine Description:
+
+ Finds the Instance-th token in a section.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Instance Specify the Instance-th token to search for, starting from zero
+ Token The token name to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+ Value The token value to return. Caller should allocate the buffer.
+ Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Token and Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+
EFI_STATUS
StringToGuid (
IN CHAR8 *AsciiGuidBuffer,
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
index d30d6272cf..8fbcd10a4e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiCompress/EfiCompressMain.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2010, 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
@@ -25,6 +25,9 @@ Abstract:
#include "TianoCommon.h"
#include "Compress.h"
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "EfiCompress"
+
typedef enum {
EFI_COMPRESS = 1,
TIANO_COMPRESS = 2
@@ -365,22 +368,32 @@ Usage (
CHAR8 *ExeName
)
{
- fprintf (
- stdout,
- "\n"
- "Usage: %s [-tCompressType] InFileName OutFileName\n"
- " %*c [[-tCompressType] InFileName OutFileName ...]\n"
- "\n"
- "where:\n"
- " CompressType - optional compress algorithm (EFI | Tiano), case insensitive.\n"
- " If ommitted, compress type specified ahead is used, \n"
- " default is EFI\n"
- " e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\ \n"
- " c.in c.out -tEFI d.in d.out\n"
- " a.in and d.in are compressed using EFI compress algorithm\n"
- " b.in and c.in are compressed using Tiano compress algorithm\n"
- " InFileName - input file path\n"
- " OutFileName - output file path\n",
- ExeName, strlen(ExeName), ' '
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Compress Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] SOURCE DEST ...",
+ "Description:",
+ " Compress a list of SOURCE(s) to accordingly DEST(s) using the specified",
+ " compress algorithm.",
+ "Options:",
+ " -tCompressAlgo Optional compress algorithm (EFI | Tiano), case insensitive.",
+ " If ommitted, compress type specified ahead is used,",
+ " default is EFI\n"
+ " e.g.: EfiCompress a.in a.out -tTiano b.in b.out \\",
+ " c.in c.out -tEFI d.in d.out",
+ " a.in and d.in are compressed using EFI compress algorithm",
+ " b.in and c.in are compressed using Tiano compress algorithm",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
index 11ae84f8ff..cf8efc86e1 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/EfiRom/EfiRom.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2010, 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
@@ -45,7 +45,8 @@ Abstract:
//
// Version of this utility
//
-#define UTILITY_VERSION "v2.6"
+#define UTILITY_NAME "EfiRom"
+#define UTILITY_VERSION "v2.7"
//
// Define some status return values
@@ -1311,39 +1312,42 @@ Returns:
--*/
{
- int Index;
- static const char *Msg[] = {
- "EfiRom "UTILITY_VERSION" - Intel EFI Make Option ROM utility",
- " Copyright (C), 1999 - 2002 Intel Coproration\n",
- " Create an option ROM image from a list of input files",
- " Usage: efirom {-p} [-v VendorId] [-d DeviceId] {-o OutFileName} ",
- " [-e|-b] [FileName(s)]",
- " where:",
- " VendorId - required hex PCI Vendor ID for the device",
- " DeviceId - required hex PCI Device ID for the device",
- " OutFileName - optional output file name. Default is the first input",
- " file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
- " FileNames - input PE32 or binary file name(s)",
- " BinFileName - input binary file name(s)",
- " -p - for verbose output",
- " -l - to not automatically set the LAST bit on the last file",
- " -b - following FileNames are binary files",
- " -e - following FileNames are EFI PE32 image files",
- " -ec - following FileNames are EFI PE32 image files, and should",
- " be compressed by this utility",
- " -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
- " the following FileName",
- " -rev Revision - to use hex Revision in the PCI data structure header for",
- " the following FileName",
- " -dump - to dump the headers of an existing option ROM image",
- "",
- "Example usage: EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel EFI Make Option ROM Utility",
+ " Copyright (C), 1999 - 2008 Intel Coproration",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... SOURCE ...",
+ "Description:",
+ " Create an option ROM image from a list of input files",
+ "Options:",
+ " -v VendorId - required hex PCI Vendor ID for the device",
+ " -d DeviceId - required hex PCI Device ID for the device",
+ " -o OutFileName - optional output file name. Default is the first input",
+ " file name with a "DEFAULT_OUTPUT_EXTENSION" file extension",
+ " -e SOURCE ... - input are EFI PE32 image file(s)",
+ " -b SOURCE ... - input are Legacy binary file(s)",
+ " -ec SOURCE ... - input are EFI PE32 image file(s) and should be compressed",
+ " -p - for verbose output",
+ " -l - to not automatically set the LAST bit on the last file",
+ " -cc ClassCode - to use hex ClassCode in the PCI data structure header for",
+ " the following SOURCE(s)",
+ " -rev Revision - to use hex Revision in the PCI data structure header for",
+ " the following one SOURCE",
+ " -dump - to dump the headers of an existing option ROM image",
+ "Example Usage:",
+ " EfiRom -v 0xABCD -d 0x1234 -b File1.bin File2.bin -e File1.efi File2.efi",
NULL
};
- for (Index = 0; Msg[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Msg[Index]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
index eb23dc7637..d5f2ecee0a 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/FwImage/fwimage.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -29,7 +29,8 @@ Abstract:
#include "EfiImage.h"
#include "EfiUtilityMsgs.c"
-#define UTILITY_NAME "FwImage"
+#define UTILITY_NAME "FwImage"
+#define UTILITY_VERSION "v1.0"
typedef union {
IMAGE_NT_HEADERS32 PeHeader32;
@@ -41,10 +42,33 @@ Usage (
VOID
)
{
- printf ("Usage: " UTILITY_NAME " {-t time-date} {-e} {-r} [APPLICATION|BS_DRIVER|RT_DRIVER|SAL_RT_DRIVER|COMBINED_PEIM_DRIVER|SECURITY_CORE|PEI_CORE|PE32_PEIM|RELOCATABLE_PEIM] peimage [outimage]\n");
- printf (" -t: Add Time Stamp for output image\n");
- printf (" -e: Not clear ExceptionTable for output image\n");
- printf (" -r: Not strip zero pending of .reloc for output image\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Firmware Image Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... FWTYPE SOURCE [DEST]",
+ "Description:",
+ " Converts a pe32/pe32+ SOURCE to DEST with FWTYPE image type.",
+ "Options:",
+ " FWTYPE Can be one of APPLICATION, BS_DRIVER, RT_DRIVER, SAL_RT_DRIVER,",
+ " COMBINED_PEIM_DRIVER, SECURITY_CORE, PEI_CORE, PE32_PEIM and",
+ " RELOCATABLE_PEIM",
+ " -t time-date Add Time Stamp for output image",
+ " -e Not clear ExceptionTable for output image",
+ " -r Not strip zero pending of .reloc for output image",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
static
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
index e346a1e4c8..81ffcb78df 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenAprioriFile/GenAprioriFile.c
@@ -1,6 +1,6 @@
/*++
- Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2010, 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
@@ -39,7 +39,8 @@ Abstract:
// #define STATUS_WARNING 1
// #define STATUS_ERROR 2
//
-#define UTILITY_NAME "GenAprioriFile"
+#define UTILITY_NAME "GenAprioriFile"
+#define UTILITY_VERSION "v1.0"
//
// Here's all our globals.
//
@@ -447,18 +448,26 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
- UTILITY_NAME " -- create an Apriori file consumable by the DXE dispatcher",
- " Usage: "UTILITY_NAME " [Options]",
- " Options include:",
- " -h or -? for this help information",
- " -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
- " -o OutputFile write output to OutputFile (required)",
- " -i for intelligent re-creation of OutputFile",
- " -null to terminate the output file with a NULL GUID",
- " -v verbose option",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Apriori File Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Description:",
+ " Generate an Apriori file consumable by the DXE or PEI dispatcher.",
+ "Options:",
+ " -h or -? for this help information",
+ " -f AprioriFile parse the GUID'ed files in AprioriFile (required)",
+ " -o OutputFile write output to OutputFile (required)",
+ " -i for intelligent re-creation of OutputFile",
+ " -null to terminate the output file with a NULL GUID",
+ " -v verbose option",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
index b1f3f1eec4..5bbbd14c7e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenCRC32Section/GenCRC32Section.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -35,9 +35,9 @@ Abstract:
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
-#define TOOLVERSION "0.2"
+#define UTILITY_VERSION "v1.0"
-#define UTILITY_NAME "GenCrc32Section"
+#define UTILITY_NAME "GenCrc32Section"
EFI_GUID gEfiCrc32SectionGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
@@ -134,12 +134,26 @@ PrintUsage (
VOID
)
{
- printf ("Usage:\n");
- printf (UTILITY_NAME " -i \"inputfile1\" \"inputfile2\" -o \"outputfile\" \n");
- printf (" -i \"inputfile\":\n ");
- printf (" specifies the input files that would be signed to CRC32 Guided section.\n");
- printf (" -o \"outputfile\":\n");
- printf (" specifies the output file that is a CRC32 Guided section.\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate CRC32 Section Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Options:",
+ " -i Input1 ... specifies the input file(s) that would be signed to CRC32",
+ " Guided section.",
+ " -o Output specifies the output file that is a CRC32 Guided section",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
INT32
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
index 37c1039c0f..2cfc3079ab 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -77,7 +77,15 @@ Abstract:
#include "GenDepex.h"
-#define TOOL_NAME "GenDepex"
+//
+// Utility Name
+//
+#define UTILITY_NAME "GenDepex"
+
+//
+// Utility version information
+//
+#define UTILITY_VERSION "v1.0"
extern
BOOLEAN
@@ -106,13 +114,19 @@ Returns:
--*/
{
- printf (
- "%s, Tiano Dependency Expression Generation Utility. Version %d.%d.\n",
- UTILITY_NAME,
- UTILITY_MAJOR_VERSION,
- UTILITY_MINOR_VERSION
- );
- printf ("Copyright (C) 1996-2002 Intel Corporation. All rights reserved.\n\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Dependency Expression Utility",
+ " Copyright (C), 1996 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
VOID
@@ -135,15 +149,22 @@ Returns:
--*/
{
- printf (
- "Usage: %s -I <INFILE> -O <OUTFILE> [-P <Optional Boundary for padding up>] \n",
- UTILITY_NAME
- );
- printf (" Where:\n");
- printf (" <INFILE> is the input pre-processed dependency text files name.\n");
- printf (" <OUTFILE> is the output binary dependency files name.\n");
- printf (" <Optional Boundary for padding up> is the padding integer value.\n");
- printf (" This is the boundary to align the output file size to.\n");
+ int Index;
+ const char *Str[] = {
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -I INFILE The input pre-processed dependency text files name",
+ " -O OUTFILE The output binary dependency files name",
+ " -P BOUNDARY The padding integer value to align the output file size",
+ NULL
+ };
+
+ PrintGenDepexUtilityInfo ();
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
DEPENDENCY_OPCODE
@@ -742,7 +763,7 @@ Returns:
// print an error message.
//
*(Ptrx + 20) = 0;
- printf (TOOL_NAME " ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
+ printf (UTILITY_NAME" ERROR: Unrecognized input at: \"%s\"...\n", Ptrx);
return EFI_INVALID_PARAMETER;
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
index a1d6ec30d3..0321a4c840 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenDepex/GenDepex.h
@@ -1,5 +1,5 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -53,15 +53,5 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#define EVAL_STACK_SIZE 0x1024
#define BUFFER_SIZE 0x100
-//
-// Utility Name
-//
-#define UTILITY_NAME "GenDepex"
-
-//
-// Utility version information
-//
-#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 4
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
index d4053671f5..269a5b81cb 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFfsFile/GenFfsFile.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -43,7 +43,7 @@ Abstract:
#include "SimpleFileParsing.h"
#define UTILITY_NAME "GenFfsFile"
-#define TOOLVERSION "0.32"
+#define UTILITY_VERSION "v1.1"
#define MAX_ARRAY_SIZE 100
static
@@ -123,6 +123,7 @@ static struct {
UINT8 BuildDirectory[_MAX_PATH];
UINT8 PrimaryPackagePath[_MAX_PATH];
UINT8 OverridePackagePath[_MAX_PATH];
+ UINT8 OutputFilePath[_MAX_PATH];
BOOLEAN Verbose;
MACRO *MacroList;
} mGlobals;
@@ -187,22 +188,33 @@ Returns:
--*/
{
- printf ("Usage:\n");
- printf (UTILITY_NAME " -b \"build directory\" -p1 \"package1.inf\" -p2 \"package2.inf\"\n");
- printf (" -d \"name=value\" -v\n");
- printf (" -b \"build directory\":\n");
- printf (" specifies the full path to the component build directory.\n");
- printf (" -p1 \"P1_path\":\n");
- printf (" specifies fully qualified file name to the primary package file.\n");
- printf (" This file will normally exist in the same directory as the makefile\n");
- printf (" for the component. Required.\n");
- printf (" -p2 \"P2_path\":\n");
- printf (" specifies fully qualified file name to the override package file.\n");
- printf (" This file will normally exist in the build tip. Optional.\n");
- printf (" -d \"name=value\":\n");
- printf (" add a macro definition for package file. Optional.\n");
- printf (" -v :\n");
- printf (" verbose. Optional.\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate FFS File Utility",
+ " Copyright (C), 2004 - 2009 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -b BuildDirectory Specifies the full path to the component build directory",
+ " -p1 P1Path Specifies fully qualified file name to the primary package",
+ " file. This file will normally exist in the same directory",
+ " as the makefile for the component. Required.",
+ " -p2 P2Path Specifies fully qualified file name to the override",
+ " package. This file will normally exist in the build tip.",
+ " Optional.",
+ " -d Name=Value Add a macro definition for the package file. Optional.",
+ " -o OutputFile Specifies the file name of output file. Optional.",
+ " -v Verbose. Optional.",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
static
@@ -2160,54 +2172,64 @@ here:
StripQuotes (BaseName);
}
- if (BaseName[0] != 0) {
- sprintf (InputString, "%s-%s", GuidString, BaseName);
+ if (mGlobals.OutputFilePath[0]) {
+ //
+ // Use user specified output file name
+ //
+ strcpy (InputString, mGlobals.OutputFilePath);
} else {
- strcpy (InputString, GuidString);
- }
+ //
+ // Construct the output file name according to FileType
+ //
+ if (BaseName[0] != 0) {
+ sprintf (InputString, "%s-%s", GuidString, BaseName);
+ } else {
+ strcpy (InputString, GuidString);
+ }
- switch (StringToType (FileType)) {
+ switch (StringToType (FileType)) {
- case EFI_FV_FILETYPE_SECURITY_CORE:
- strcat (InputString, ".SEC");
- break;
+ case EFI_FV_FILETYPE_SECURITY_CORE:
+ strcat (InputString, ".SEC");
+ break;
- case EFI_FV_FILETYPE_PEIM:
- case EFI_FV_FILETYPE_PEI_CORE:
- case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
- strcat (InputString, ".PEI");
- break;
+ case EFI_FV_FILETYPE_PEIM:
+ case EFI_FV_FILETYPE_PEI_CORE:
+ case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
+ strcat (InputString, ".PEI");
+ break;
- case EFI_FV_FILETYPE_DRIVER:
- case EFI_FV_FILETYPE_DXE_CORE:
- strcat (InputString, ".DXE");
- break;
+ case EFI_FV_FILETYPE_DRIVER:
+ case EFI_FV_FILETYPE_DXE_CORE:
+ strcat (InputString, ".DXE");
+ break;
- case EFI_FV_FILETYPE_APPLICATION:
- strcat (InputString, ".APP");
- break;
+ case EFI_FV_FILETYPE_APPLICATION:
+ strcat (InputString, ".APP");
+ break;
- case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
- strcat (InputString, ".FVI");
- break;
+ case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
+ strcat (InputString, ".FVI");
+ break;
- case EFI_FV_FILETYPE_RAW:
- strcat (InputString, ".RAW");
- break;
+ case EFI_FV_FILETYPE_RAW:
+ strcat (InputString, ".RAW");
+ break;
- case EFI_FV_FILETYPE_ALL:
- Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
- goto Done;
+ case EFI_FV_FILETYPE_ALL:
+ Error (mGlobals.OverridePackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
+ goto Done;
- default:
- strcat (InputString, ".FFS");
- break;
+ default:
+ strcat (InputString, ".FFS");
+ break;
+ }
}
if (ForceUncompress) {
strcat (InputString, ".ORG");
}
-
+
Out = fopen (InputString, "wb");
if (Out == NULL) {
Error (NULL, 0, 0, InputString, "could not open output file for writing");
@@ -2242,7 +2264,11 @@ here:
sizeof (EFI_FFS_FILE_HEADER)
);
if (FileHeader.Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) &FileHeader, FileSize);
+#else
+ FileHeader.IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)&FileHeader + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
FileHeader.IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2307,48 +2333,58 @@ here:
StripQuotes (BaseName);
}
- if (BaseName[0] != 0) {
- sprintf (InputString, "%s-%s", GuidString, BaseName);
+ if (mGlobals.OutputFilePath[0]) {
+ //
+ // Use user specified output file name
+ //
+ strcpy (InputString, mGlobals.OutputFilePath);
} else {
- strcpy (InputString, GuidString);
- }
+ //
+ // Construct the output file name according to FileType
+ //
+ if (BaseName[0] != 0) {
+ sprintf (InputString, "%s-%s", GuidString, BaseName);
+ } else {
+ strcpy (InputString, GuidString);
+ }
- switch (StringToType (FileType)) {
+ switch (StringToType (FileType)) {
- case EFI_FV_FILETYPE_SECURITY_CORE:
- strcat (InputString, ".SEC");
- break;
+ case EFI_FV_FILETYPE_SECURITY_CORE:
+ strcat (InputString, ".SEC");
+ break;
- case EFI_FV_FILETYPE_PEIM:
- case EFI_FV_FILETYPE_PEI_CORE:
- case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
- strcat (InputString, ".PEI");
- break;
+ case EFI_FV_FILETYPE_PEIM:
+ case EFI_FV_FILETYPE_PEI_CORE:
+ case EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER:
+ strcat (InputString, ".PEI");
+ break;
- case EFI_FV_FILETYPE_DRIVER:
- case EFI_FV_FILETYPE_DXE_CORE:
- strcat (InputString, ".DXE");
- break;
+ case EFI_FV_FILETYPE_DRIVER:
+ case EFI_FV_FILETYPE_DXE_CORE:
+ strcat (InputString, ".DXE");
+ break;
- case EFI_FV_FILETYPE_APPLICATION:
- strcat (InputString, ".APP");
- break;
+ case EFI_FV_FILETYPE_APPLICATION:
+ strcat (InputString, ".APP");
+ break;
- case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
- strcat (InputString, ".FVI");
- break;
+ case EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE:
+ strcat (InputString, ".FVI");
+ break;
- case EFI_FV_FILETYPE_RAW:
- strcat (InputString, ".RAW");
- break;
+ case EFI_FV_FILETYPE_RAW:
+ strcat (InputString, ".RAW");
+ break;
- case EFI_FV_FILETYPE_ALL:
- Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
- goto Done;
+ case EFI_FV_FILETYPE_ALL:
+ Error (mGlobals.PrimaryPackagePath, 1, 0, "invalid FFS file type for this utility", NULL);
+ goto Done;
- default:
- strcat (InputString, ".FFS");
- break;
+ default:
+ strcat (InputString, ".FFS");
+ break;
+ }
}
if (ForceUncompress) {
@@ -2624,6 +2660,23 @@ Returns:
OriginalOverridePackagePath = Argv[1];
Argc--;
Argv++;
+ } else if (_strcmpi (Argv[0], "-o") == 0) {
+ //
+ // OPTION: -o OutputFilePath
+ // Make sure there is another argument, then save it to out globals.
+ //
+ if (Argc < 2) {
+ Error (NULL, 0, 0, Argv[0], "option requires the output file name");
+ return STATUS_ERROR;
+ }
+ if (mGlobals.OutputFilePath[0]) {
+ Error (NULL, 0, 0, Argv[0], "option can only be specified once");
+ return STATUS_ERROR;
+ }
+
+ strcpy (mGlobals.OutputFilePath, Argv[1]);
+ Argc--;
+ Argv++;
} else if (_strcmpi (Argv[0], "-v") == 0) {
//
// OPTION: -v verbose
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
index 8d9a7768ec..6e45c8695d 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -49,12 +49,19 @@ Returns:
--*/
{
- printf (
- "%s - Tiano Firmware Volume Generation Utility."" Version %i.%i\n\n",
- UTILITY_NAME,
- UTILITY_MAJOR_VERSION,
- UTILITY_MINOR_VERSION
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Firmware Volume Utility",
+ " Copyright (C), 2004 - 2009 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
VOID
@@ -77,9 +84,19 @@ Returns:
--*/
{
- printf ("Usage: %s -I FvInfFileName\n", UTILITY_NAME);
- printf (" Where:\n");
- printf ("\tFvInfFileName is the name of the image description file.\n\n");
+ int Index;
+ const char *Str[] = {
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Options:",
+ " -I FvInfFileName The name of the image description file.",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
index d0dd1bbe02..08a62af3e6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageExe.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -38,8 +38,7 @@ Abstract:
//
// Utility version information
//
-#define UTILITY_MAJOR_VERSION 0
-#define UTILITY_MINOR_VERSION 1
+#define UTILITY_VERSION "v1.1"
#define UTILITY_DATE __DATE__
//
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
index cb193ce2ce..b5ed87a131 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -968,13 +968,17 @@ Returns:
Status = FindToken (InfFile, OPTIONS_SECTION_STRING, EFI_NUM_BLOCKS_STRING, Index, Value);
if (Status == EFI_SUCCESS) {
- //
- // Update the number of blocks
- //
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
- return EFI_ABORTED;
+ if (strcmp (Value, AUTO_STRING) == 0) {
+ Value64 = (UINT64) -1;
+ } else {
+ //
+ // Update the number of blocks
+ //
+ Status = AsciiStringToUint64 (Value, FALSE, &Value64);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, Value, "invalid value for %s", EFI_NUM_BLOCKS_STRING);
+ return EFI_ABORTED;
+ }
}
FvInfo->FvBlocks[Index].NumBlocks = (UINT32) Value64;
@@ -1040,99 +1044,59 @@ Returns:
if (FindSection (InfFile, COMPONENT_SECTION_STRING)) {
Index = 0;
- //
- // Read component FV_VARIABLE
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_VARIABLE_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_VARIABLE_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
+ while (TRUE) {
+ Status = FindTokenInstanceInSection (
+ InfFile,
+ COMPONENT_SECTION_STRING,
+ Index,
+ FvInfo->FvComponents[Index].ComponentName,
+ Value
+ );
if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_VARIABLE_STRING);
- return EFI_ABORTED;
+ break;
}
-
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_VARIABLE_STRING);
- }
-
- Index++;
- //
- // Read component FV_EVENT_LOG
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_EVENT_LOG_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_EVENT_LOG_STRING);
Status = AsciiStringToUint64 (Value, FALSE, &Value64);
if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_EVENT_LOG_STRING);
+ Error (NULL, 0, 0, Value, "not a valid integer");
return EFI_ABORTED;
}
FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_EVENT_LOG_STRING);
+ Index++;
}
-
- Index++;
- //
- // Read component FV_FTW_WORKING
- //
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_WORKING_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
+ }
+ //
+ // Compute size for easy access later
+ //
+ FvInfo->Size = 0;
+ for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {
+ if ((FvInfo->Size == (UINTN) -1 && Index > 0) ||
+ (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1 && Index > 0)
+ ) {
//
- // Add the component
+ // Error 1. more pairs after AUTO
+ // Error 2. AUTO appear in non-first position
//
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_WORKING_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_WORKING_STRING);
- return EFI_ABORTED;
- }
+ Error (NULL, 0, 0, NULL, "cannot have more than one pair of %s and %s if %s is set to %s",
+ EFI_NUM_BLOCKS_STRING, EFI_BLOCK_SIZE_STRING,
+ EFI_NUM_BLOCKS_STRING, AUTO_STRING
+ );
+ return EFI_ABORTED;
+ }
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
+ if (FvInfo->FvBlocks[Index].NumBlocks == (UINT32) -1) {
+ FvInfo->Size = (UINTN) -1;
} else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_WORKING_STRING);
+ FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
}
+ }
- Index++;
+ if (FvInfo->Size == (UINTN) -1 && FvInfo->FvFiles[0][0] == 0) {
//
- // Read component FV_FTW_SPARE
+ // Non FFS FV cannot set block number to AUTO
//
- Status = FindToken (InfFile, COMPONENT_SECTION_STRING, EFI_NV_FTW_SPARE_STRING, 0, Value);
-
- if (Status == EFI_SUCCESS) {
- //
- // Add the component
- //
- strcpy (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING);
- Status = AsciiStringToUint64 (Value, FALSE, &Value64);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: %s is not a valid integer.\n", EFI_NV_FTW_SPARE_STRING);
- return EFI_ABORTED;
- }
-
- FvInfo->FvComponents[Index].Size = (UINTN) Value64;
- } else {
- printf ("WARNING: Could not read %s.\n", EFI_NV_FTW_SPARE_STRING);
- }
- }
- //
- // Compute size for easy access later
- //
- FvInfo->Size = 0;
- for (Index = 0; FvInfo->FvBlocks[Index].NumBlocks; Index++) {
- FvInfo->Size += FvInfo->FvBlocks[Index].NumBlocks * FvInfo->FvBlocks[Index].BlockLength;
+ Error (NULL, 0, 0, "non-FFS FV", "cannot set %s to %s", EFI_NUM_BLOCKS_STRING, AUTO_STRING);
+ return EFI_ABORTED;
}
return EFI_SUCCESS;
@@ -1372,7 +1336,11 @@ Returns:
PadFile->State = 0;
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, PadFileSize);
+#else
+ PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN)PadFile + sizeof (EFI_FFS_FILE_HEADER)), PadFileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -1876,12 +1844,139 @@ Returns:
}
EFI_STATUS
+ReallocateFvImage (
+ IN OUT MEMORY_FILE *FvImage,
+ IN OUT FV_INFO *FvInfo,
+ IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
+ IN OUT UINTN *FvImageCapacity
+ )
+/*++
+Routine Description:
+ Increase the size of FV image by 1 block. The routine may reallocate memory
+ depending on the capacity of the FV image.
+
+Arguments:
+ FvImage The memory image of the FV to add it to. The current offset
+ must be valid.
+ FvInfo Pointer to information about the FV.
+ VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
+ to the end of the FvImage then no VTF previously found.
+ FvImageCapacity Capacity of image buffer for FV.
+
+Returns:
+ EFI_SUCCESS The function completed successfully.
+ EFI_OUT_OF_RESOURCES Insufficient resources exist to complete the reallocation.
+
+--*/
+{
+ CHAR8 *FileImage;
+ UINTN OldSize;
+ UINTN IncreaseSize;
+ EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
+ BOOLEAN AllocateNewMemory;
+ EFI_FFS_FILE_HEADER *NewVtfFileImage;
+ UINT32 VtfFileLength;
+ UINT8 TempByte;
+
+ OldSize = (UINTN) FvImage->Eof - (UINTN) FvImage->FileImage;
+ IncreaseSize = FvInfo->FvBlocks[0].BlockLength;
+ assert (OldSize == FvInfo->FvBlocks[0].NumBlocks * FvInfo->FvBlocks[0].BlockLength);
+
+ //
+ // Assume we have enough capacity
+ //
+ AllocateNewMemory = FALSE;
+
+
+ if (OldSize + IncreaseSize > *FvImageCapacity) {
+ AllocateNewMemory = TRUE;
+ //
+ // Increase capacity by one unit
+ //
+ *FvImageCapacity = OldSize + FV_CAPACITY_INCREASE_UNIT;
+ FileImage = malloc (*FvImageCapacity);
+
+ if (FileImage == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Initialize the content per FV polarity
+ //
+ if (FvInfo->FvAttributes & EFI_FVB_ERASE_POLARITY) {
+ memset (FileImage, -1, *FvImageCapacity);
+ } else {
+ memset (FileImage, 0, *FvImageCapacity);
+ }
+
+ //
+ // Copy the FV content before VTF
+ //
+ memcpy (FileImage, FvImage->FileImage, (UINTN) *VtfFileImage - (UINTN) FvImage->FileImage);
+ } else {
+ FileImage = FvImage->FileImage;
+ }
+
+ //
+ // Move VTF if it exists
+ //
+ NewVtfFileImage = (EFI_FFS_FILE_HEADER *) (FileImage + ((UINTN) *VtfFileImage - (UINTN) FvImage->FileImage) + IncreaseSize);
+ if ((UINTN) *VtfFileImage != (UINTN) FvImage->Eof) {
+ //
+ // Exchange the VTF buffer from end to start for two purpose:
+ // 1. Exchange: Preserve the default value per FV polarity
+ // 2. End->Start: Avoid destroying the VTF data during exchanging
+ //
+ VtfFileLength = GetLength ((*VtfFileImage)->Size);
+ while (VtfFileLength-- != 0) {
+ TempByte = ((UINT8 *) VtfFileImage)[VtfFileLength];
+ ((UINT8 *) VtfFileImage)[VtfFileLength] = ((UINT8 *) NewVtfFileImage)[VtfFileLength];
+ ((UINT8 *) NewVtfFileImage)[VtfFileLength] = TempByte;
+ }
+ }
+
+ //
+ // Update VTF Pointer
+ //
+ *VtfFileImage = NewVtfFileImage;
+
+ //
+ // Update FvInfo
+ //
+ FvInfo->FvBlocks[0].NumBlocks ++;
+
+ //
+ // Update FV Header
+ //
+ FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) FileImage;
+ FvHeader->FvBlockMap[0].NumBlocks = FvInfo->FvBlocks[0].NumBlocks;
+ FvHeader->FvLength = OldSize + IncreaseSize;
+ FvHeader->Checksum = 0;
+ FvHeader->Checksum = CalculateChecksum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
+
+ //
+ // Update FvImage
+ //
+ if (AllocateNewMemory) {
+ free (FvImage->FileImage);
+ FvImage->CurrentFilePointer = FileImage + (FvImage->CurrentFilePointer - FvImage->FileImage);
+ FvImage->FileImage = FileImage;
+ }
+ FvImage->Eof = FvImage->FileImage + OldSize + IncreaseSize;
+
+ InitializeFvLib (FvImage->FileImage, OldSize + IncreaseSize);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
AddFile (
IN OUT MEMORY_FILE *FvImage,
IN FV_INFO *FvInfo,
IN UINTN Index,
IN OUT EFI_FFS_FILE_HEADER **VtfFileImage,
- IN OUT MEMORY_FILE *SymImage
+ IN OUT MEMORY_FILE *SymImage,
+ IN OUT UINTN *FvImageCapacity
)
/*++
@@ -1892,14 +1987,15 @@ Routine Description:
Arguments:
- FvImage The memory image of the FV to add it to. The current offset
- must be valid.
- FvInfo Pointer to information about the FV.
- Index The file in the FvInfo file list to add.
- VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
- to the end of the FvImage then no VTF previously found.
- SymImage The memory image of the Sym file to update if symbols are present.
- The current offset must be valid.
+ FvImage The memory image of the FV to add it to. The current offset
+ must be valid.
+ FvInfo Pointer to information about the FV.
+ Index The file in the FvInfo file list to add.
+ VtfFileImage A pointer to the VTF file within the FvImage. If this is equal
+ to the end of the FvImage then no VTF previously found.
+ SymImage The memory image of the Sym file to update if symbols are present.
+ The current offset must be valid.
+ FvImageCapacity Capacity of image buffer for FV.
Returns:
@@ -1964,16 +2060,28 @@ Returns:
// Verify read successful
//
if (NumBytesRead != sizeof (UINT8) * FileSize) {
- free (FileBuffer);
Error (NULL, 0, 0, FvInfo->FvFiles[Index], "failed to read input file contents");
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
//
// Verify space exists to add the file
//
- if (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
- Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
- return EFI_OUT_OF_RESOURCES;
+ while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
+ if (FvInfo->Size != (UINTN) -1) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient space remains to add the file");
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
}
//
// Update the file state based on polarity of the FV.
@@ -2033,7 +2141,11 @@ Returns:
}
if ((*VtfFileImage)->Attributes & FFS_ATTRIB_CHECKSUM) {
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
VtfFileChecksum = CalculateChecksum8 ((UINT8 *) *VtfFileImage, FileSize - TailSize);
+ #else
+ VtfFileChecksum = CalculateChecksum8 ((UINT8 *) ((UINTN)*VtfFileImage + sizeof (EFI_FFS_FILE_HEADER)), FileSize - TailSize - sizeof(EFI_FFS_FILE_HEADER));
+ #endif
(*VtfFileImage)->IntegrityCheck.Checksum.File = VtfFileChecksum;
} else {
(*VtfFileImage)->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
@@ -2048,15 +2160,15 @@ Returns:
}
#endif
(*VtfFileImage)->State = FileState;
- free (FileBuffer);
- return EFI_SUCCESS;
+ Status = EFI_SUCCESS;
+ goto Exit;
} else {
//
// Already found a VTF file.
//
Error (NULL, 0, 0, "multiple VTF files are illegal in a single FV", NULL);
- free (FileBuffer);
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
}
//
@@ -2065,68 +2177,93 @@ Returns:
Status = ReadFfsAlignment ((EFI_FFS_FILE_HEADER *) FileBuffer, &CurrentFileAlignment);
if (EFI_ERROR (Status)) {
printf ("ERROR: Could not determine alignment of file %s.\n", FvInfo->FvFiles[Index]);
- free (FileBuffer);
- return EFI_ABORTED;
+ Status = EFI_ABORTED;
+ goto Exit;
}
//
// Add pad file if necessary
//
- Status = AddPadFile (FvImage, CurrentFileAlignment);
- if (EFI_ERROR (Status)) {
- printf ("ERROR: Could not align the file data properly.\n");
- free (FileBuffer);
- return EFI_ABORTED;
+ while (EFI_ERROR (AddPadFile (FvImage, CurrentFileAlignment))) {
+ if (FvInfo->Size != (UINTN) -1) {
+ printf ("ERROR: Could not align the file data properly.\n");
+ Status = EFI_ABORTED;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
}
+
//
// Add file
//
- if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) {
- //
- // Copy the file
- //
- memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
+ while (FileSize > (UINTN) ((UINTN) *VtfFileImage - (UINTN) FvImage->CurrentFilePointer)) {
+ if (FvInfo->Size != (UINTN) -1) {
+ printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
+ Status = EFI_ABORTED;
+ goto Exit;
+ } else {
+ //
+ // FV Size is AUTO, increase by one one block
+ //
+ Status = ReallocateFvImage (FvImage, FvInfo, VtfFileImage, FvImageCapacity);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0, FvInfo->FvFiles[Index], "insufficient resources to add the file");
+ goto Exit;
+ }
+ }
+ }
- //
- // If the file is XIP, rebase
- //
- CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
- //
- // Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
- // if (EFI_ERROR(Status)) {
- // printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
- // return EFI_ABORTED;
- // }
- //
- // Update Symbol file
- //
- Status = AddSymFile (
- CurrentFileBaseAddress,
- (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
- SymImage,
- FvInfo->FvFiles[Index]
- );
- assert (!EFI_ERROR (Status));
+ //
+ // Copy the file
+ //
+ memcpy (FvImage->CurrentFilePointer, FileBuffer, FileSize);
+
+ //
+ // If the file is XIP, rebase
+ //
+ CurrentFileBaseAddress = FvInfo->BaseAddress + ((UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage);
+ //
+ // Status = RebaseFfsFile ((EFI_FFS_FILE_HEADER*) FvImage->CurrentFilePointer, CurrentFileBaseAddress);
+ // if (EFI_ERROR(Status)) {
+ // printf ("ERROR: Could not rebase the file %s.\n", FvInfo->FvFiles[Index]);
+ // return EFI_ABORTED;
+ // }
+ //
+ // Update Symbol file
+ //
+ Status = AddSymFile (
+ CurrentFileBaseAddress,
+ (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer,
+ SymImage,
+ FvInfo->FvFiles[Index]
+ );
+ assert (!EFI_ERROR (Status));
+
+ //
+ // Update the current pointer in the FV image
+ //
+ FvImage->CurrentFilePointer += FileSize;
- //
- // Update the current pointer in the FV image
- //
- FvImage->CurrentFilePointer += FileSize;
- } else {
- printf ("ERROR: The firmware volume is out of space, could not add file %s.\n", FvInfo->FvFiles[Index]);
- return EFI_ABORTED;
- }
//
// Make next file start at QWord Boundry
//
while (((UINTN) FvImage->CurrentFilePointer & 0x07) != 0) {
FvImage->CurrentFilePointer++;
}
+
+Exit:
//
// Free allocated memory.
//
free (FileBuffer);
-
- return EFI_SUCCESS;
+ return Status;
}
EFI_STATUS
@@ -2250,8 +2387,7 @@ Returns:
} else if (_stricmp (FvInfo->FvComponents[Index].ComponentName, EFI_NV_FTW_SPARE_STRING) == 0) {
AddFTWSpareBlock (FvImage, FvInfo->FvComponents[Index].Size, FvInfo);
} else {
- printf ("Error. Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
- return EFI_ABORTED;
+ printf ("Warning: Unknown Non-FFS block %s \n", FvInfo->FvComponents[Index].ComponentName);
}
FvImage = FvImage + FvInfo->FvComponents[Index].Size;
@@ -2332,7 +2468,11 @@ Returns:
PadFile->State = 0;
PadFile->IntegrityCheck.Checksum.Header = CalculateChecksum8 ((UINT8 *) PadFile, sizeof (EFI_FFS_FILE_HEADER));
if (PadFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) PadFile, FileSize);
+#else
+ PadFile->IntegrityCheck.Checksum.File = CalculateChecksum8 ((UINT8 *) ((UINTN) PadFile + sizeof (EFI_FFS_FILE_HEADER)), FileSize - sizeof (EFI_FFS_FILE_HEADER));
+#endif
} else {
PadFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2611,10 +2751,18 @@ Returns:
VtfFile->IntegrityCheck.Checksum.File = 0;
VtfFile->State = 0;
if (VtfFile->Attributes & FFS_ATTRIB_CHECKSUM) {
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
(UINT8 *) VtfFile,
GetLength (VtfFile->Size) - TailSize
);
+
+#else
+ VtfFile->IntegrityCheck.Checksum.File = CalculateChecksum8 (
+ (UINT8 *) ((UINTN)VtfFile + sizeof (EFI_FFS_FILE_HEADER)),
+ GetLength (VtfFile->Size) - TailSize - sizeof (EFI_FFS_FILE_HEADER)
+ );
+#endif
} else {
VtfFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
}
@@ -2780,6 +2928,7 @@ Returns:
UINTN Index;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
EFI_FFS_FILE_HEADER *VtfFileImage;
+ UINTN FvImageCapacity;
//
// Check for invalid parameter
@@ -2811,12 +2960,22 @@ Returns:
//
// Calculate the FV size
//
- *FvImageSize = FvInfo.Size;
+ if (FvInfo.Size != (UINTN) -1) {
+ *FvImageSize = FvInfo.Size;
+ FvImageCapacity = FvInfo.Size;
+ } else {
+ //
+ // For auto size, set default as one block
+ //
+ FvInfo.FvBlocks[0].NumBlocks = 1;
+ *FvImageSize = FvInfo.FvBlocks[0].BlockLength;
+ FvImageCapacity = FV_CAPACITY_INCREASE_UNIT;
+ }
//
// Allocate the FV
//
- *FvImage = malloc (*FvImageSize);
+ *FvImage = malloc (FvImageCapacity);
if (*FvImage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
@@ -2831,9 +2990,9 @@ Returns:
// Initialize the FV to the erase polarity
//
if (FvInfo.FvAttributes & EFI_FVB_ERASE_POLARITY) {
- memset (*FvImage, -1, *FvImageSize);
+ memset (*FvImage, -1, FvImageCapacity);
} else {
- memset (*FvImage, 0, *FvImageSize);
+ memset (*FvImage, 0, FvImageCapacity);
}
//
// Initialize FV header
@@ -2913,7 +3072,7 @@ Returns:
//
// Initialize the FV library.
//
- InitializeFvLib (FvImageMemoryFile.FileImage, FvInfo.Size);
+ InitializeFvLib (FvImageMemoryFile.FileImage, *FvImageSize);
//
// Files start on 8 byte alignments, so move to the next 8 byte aligned
@@ -2935,7 +3094,15 @@ Returns:
//
// Add the file
//
- Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile);
+ Status = AddFile (&FvImageMemoryFile, &FvInfo, Index, &VtfFileImage, &SymImageMemoryFile, &FvImageCapacity);
+
+ //
+ // Update FvImageSize and FvImage as they may be changed in AddFile routine
+ //
+ if (FvInfo.Size == (UINTN) -1) {
+ *FvImageSize = FvInfo.FvBlocks[0].NumBlocks * FvInfo.FvBlocks[0].BlockLength;
+ *FvImage = FvImageMemoryFile.FileImage;
+ }
//
// Exit if error detected while adding the file
@@ -2966,7 +3133,7 @@ Returns:
// reset vector. If the PEI Core is found, the VTF file will probably get
// corrupted by updating the entry point.
//
- if ((FvInfo.BaseAddress + FvInfo.Size) == FV_IMAGES_TOP_ADDRESS) {
+ if ((FvInfo.BaseAddress + *FvImageSize) == FV_IMAGES_TOP_ADDRESS) {
Status = UpdateResetVector (&FvImageMemoryFile, &FvInfo, VtfFileImage);
if (EFI_ERROR(Status)) {
printf ("ERROR: Could not update the reset vector.\n");
@@ -2974,7 +3141,7 @@ Returns:
return EFI_ABORTED;
}
}
- }
+ }
//
// Determine final Sym file size
//
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
index c8e63e83d1..7b8ab11413 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenFvImage/GenFvImageLibInternal.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -44,6 +44,8 @@ Abstract:
#define MAX_NUMBER_OF_FILES_IN_FV 1000
#define MAX_NUMBER_OF_COMPONENTS_IN_FV 10
+#define FV_CAPACITY_INCREASE_UNIT 0x100000
+
//
// INF file strings
//
@@ -150,6 +152,7 @@ Abstract:
#define TRUE_STRING "TRUE"
#define FALSE_STRING "FALSE"
#define NULL_STRING "NULL"
+#define AUTO_STRING "AUTO"
//
// Defines to calculate the offset for PEI CORE entry points
@@ -206,6 +209,7 @@ EFI_STATUS
ParseFvInf (
IN MEMORY_FILE *InfFile,
IN FV_INFO *FvInfo
- );
+ )
+;
#endif
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
index 1d1c307e87..fd367c3d62 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenSection/GenSection.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -35,6 +35,7 @@ Abstract:
#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
#define UTILITY_NAME "GenSection"
+#define UTILITY_VERSION "v1.0"
#define PARAMETER_NOT_SPECIFIED "Parameter not specified"
#define MAXIMUM_INPUT_FILE_NUM 10
@@ -81,37 +82,52 @@ PrintUsageMessage (
VOID
)
{
- UINTN SectionType;
- UINTN DisplayCount;
-
- printf ("Usage: "UTILITY_NAME " -i InputFile -o OutputFile -s SectionType [SectionType params]\n\n");
- printf (" Where SectionType is one of the following section types:\n\n");
+ UINTN SectionType;
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate Section Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]",
+ "Common Options:",
+ " -i InputFile Specifies the input file",
+ " -o OutputFile Specifies the output file",
+ " -s SectionType Specifies the type of the section, which can be one of",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
- DisplayCount = 0;
for (SectionType = 0; SectionType <= EFI_SECTION_LAST_SECTION_TYPE; SectionType++) {
if (SectionTypeName[SectionType] != NULL) {
- printf (" %s\n", SectionTypeName[SectionType]);
+ fprintf (stdout, " %s\n", SectionTypeName[SectionType]);
}
}
-
- printf ("\n and SectionType dependent parameters are as follows:\n\n");
- printf (
- " %s: -t < %s | %s >\n",
+ fprintf (stdout, "Section dependent options:\n");
+ fprintf (stdout,
+ " %s: -t < %s | %s >\n",
SectionTypeName[EFI_SECTION_COMPRESSION],
CompressionTypeName[EFI_NOT_COMPRESSED],
CompressionTypeName[EFI_STANDARD_COMPRESSION]
);
- printf (
- " %s: -t < %s >\n"" // Currently only CRC32 is supported\n\n",
+ fprintf (stdout,
+ " %s: -t < %s > // Only CRC32 is supported\n",
SectionTypeName[EFI_SECTION_GUID_DEFINED],
GUIDedSectionTypeName[EFI_SECTION_CRC32_GUID_DEFINED]
);
printf (
- " %s: -v VersionNumber\n"" [-a \"Version string\"]\n\n",
+ " %s: -v VersionNumber [-a \"Version string\"]\n",
SectionTypeName[EFI_SECTION_VERSION]
);
printf (
- " %s: -a \"Human readable name\"\n\n",
+ " %s: -a \"Human readable name\"\n",
SectionTypeName[EFI_SECTION_USER_INTERFACE]
);
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c b/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
index f9988257f1..178e9322aa 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GenTEImage/GenTEImage.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 1999 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2010, 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
@@ -33,7 +33,7 @@ Abstract:
// Version of this utility
//
#define UTILITY_NAME "GenTEImage"
-#define UTILITY_VERSION "v0.11"
+#define UTILITY_VERSION "v1.0"
//
// Define the max length of a filename
@@ -767,23 +767,28 @@ Returns:
--*/
{
- int Index;
- static const char *Msg[] = {
- UTILITY_NAME " version "UTILITY_VERSION " - TE image utility",
- " Generate a TE image from an EFI PE32 image",
- " Usage: "UTILITY_NAME " {-v} {-dump} {-h|-?} {-o OutFileName} InFileName",
- " [-e|-b] [FileName(s)]",
- " where:",
- " -v - for verbose output",
- " -dump - to dump the input file to a text file",
- " -h -? - for this help information",
- " -o OutFileName - to write output to OutFileName rather than InFileName"DEFAULT_OUTPUT_EXTENSION,
- " InFileName - name of the input PE32 file",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Generate TE Image Utility",
+ " Copyright (C), 1999 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... PE32IMAGE",
+ "Description:",
+ " Generate a TE image from an EFI PE32 image.",
+ "Options:",
+ " -v - for verbose output",
+ " -dump - to dump the input file to a text file",
+ " -h -? - for this help information",
+ " -o OutFileName - to write output to OutFileName rather than PE32IMAGE"DEFAULT_OUTPUT_EXTENSION,
NULL
};
- for (Index = 0; Msg[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Msg[Index]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
index 7b9aa041c5..f1084a3cd9 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/GuidChk/GuidChk.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -38,6 +38,9 @@ Abstract:
#define MAX_PATH 1024
#endif
+#define UTILITY_NAME "GuidChk"
+#define UTILITY_VERSION "v1.0"
+
typedef struct {
INT8 *Extension;
INT8 ExtensionCode;
@@ -593,25 +596,32 @@ Usage (
VOID
)
{
- int Index;
- char *Str[] = {
- "GuidChk - scan files for duplicate GUID or signature definitions",
- "",
- "Usage: GuidChk {options}\n",
- " Options: ",
- " -d dirname exclude searching of a directory",
- " -f filename exclude searching of a file",
- " -e extension exclude searching of files by extension",
- " -p print all GUIDS found",
- " -g check for duplicate guids",
- " -s check for duplicate signatures",
- " -x print guid+defined symbol name",
- " -b outfile write internal GUID+basename list to outfile",
- " -u dirname exclude searching all subdirectories of a directory",
- " -h -? print this help text",
- " ",
- " Example: GuidChk -g -u build -d fv -f make.inf -e .pkg",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel GUID Check Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Description:",
+ " Scan files for duplicate GUID or signature definitions.",
+ "Options:",
+ " -d dirname exclude searching of a directory",
+ " -f filename exclude searching of a file",
+ " -e extension exclude searching of files by extension",
+ " -p print all GUIDS found",
+ " -g check for duplicate guids",
+ " -s check for duplicate signatures",
+ " -x print guid+defined symbol name",
+ " -b outfile write internal GUID+basename list to outfile",
+ " -u dirname exclude searching all subdirectories of a directory",
+ " -h -? print this help text",
+ "Example Usage:",
+ " GuidChk -g -u build -d fv -f make.inf -e .pkg",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
new file mode 100644
index 0000000000..b63a1f8347
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/FindFiles.c
@@ -0,0 +1,208 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FindFiles.c
+
+Abstract:
+
+ OS-specific functions to assist in finding files in
+ subdirectories.
+
+--*/
+
+#include <windows.h>
+#include <direct.h>
+//
+// #include <io.h> // for _chmod()
+//
+#include <sys/stat.h>
+//
+// #include <errno.h> // for errno
+//
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "HiiPack.h"
+
+extern
+void
+Error (
+ char *Name,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ char *Text,
+ char *MsgFmt,
+ ...
+ );
+
+static
+int
+ProcessDirectory (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ );
+
+/*****************************************************************************/
+int
+FindFiles (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+ Find files of a given name under a root directory
+
+Arguments:
+ RootDirectory - base directory -- look in this directory and
+ all its subdirectories for files matching FileMask.
+ FileMask - file mask of files to find
+ Callback - function to call for each file found
+
+Returns:
+
+--*/
+{
+ char FullPath[MAX_PATH];
+ //
+ // If RootDirectory is relative, then append to cwd.
+ //
+ if (isalpha (RootDirectory[0]) && (RootDirectory[1] == ':')) {
+ strcpy (FullPath, RootDirectory);
+ } else {
+ //
+ // Get current working directory
+ //
+ if (_getcwd (FullPath, sizeof (FullPath)) == NULL) {
+ Error (NULL, 0, 0, "failed to get current working directory", NULL);
+ return 1;
+ }
+ //
+ // Append the relative path they passed in
+ //
+ if (FullPath[strlen (FullPath) - 1] != '\\') {
+ strcat (FullPath, "\\");
+ }
+
+ strcat (FullPath, RootDirectory);
+ }
+
+ if (FullPath[strlen (FullPath) - 1] == '\\') {
+ FullPath[strlen (FullPath) - 1] = 0;
+ }
+ //
+ // Process the directory
+ //
+ return ProcessDirectory (FullPath, FileMask, Callback);
+}
+
+static
+int
+ProcessDirectory (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+ Process a directory to find all files matching a given file mask
+
+Arguments:
+ RootDirectory - base directory -- look in this directory and
+ all its subdirectories for files matching FileMask.
+ FileMask - file mask of files to find
+ Callback - function to call for each file found
+
+Returns:
+
+--*/
+{
+ HANDLE Handle;
+ WIN32_FIND_DATA FindData;
+ char TempName[MAX_PATH];
+
+ Handle = INVALID_HANDLE_VALUE;
+ //
+ // Concatenate the filemask to the directory to create the full
+ // path\mask path name.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FileMask);
+ memset (&FindData, 0, sizeof (FindData));
+ Handle = FindFirstFile (TempName, &FindData);
+ if (Handle != INVALID_HANDLE_VALUE) {
+ do {
+ if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FindData.cFileName);
+ if (Callback (TempName) != 0) {
+ goto Done;
+ }
+ }
+ } while (FindNextFile (Handle, &FindData));
+ }
+
+ if (Handle != INVALID_HANDLE_VALUE) {
+ FindClose (Handle);
+ Handle = INVALID_HANDLE_VALUE;
+ }
+ //
+ // Now create a *.* file mask to get all subdirectories and recursive call this
+ // function to handle each one found.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\*.*");
+ memset (&FindData, 0, sizeof (FindData));
+ Handle = FindFirstFile (TempName, &FindData);
+ //
+ // Loop until no more files/directories
+ //
+ if (Handle != INVALID_HANDLE_VALUE) {
+ do {
+ if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ //
+ // Make sure it's not "." or ".."
+ //
+ if ((strcmp (FindData.cFileName, ".") != 0) && (strcmp (FindData.cFileName, "..") != 0)) {
+ //
+ // Found a valid directory. Put it all together and make a recursive call
+ // to process it.
+ //
+ strcpy (TempName, RootDirectory);
+ strcat (TempName, "\\");
+ strcat (TempName, FindData.cFileName);
+ if (ProcessDirectory (TempName, FileMask, Callback) != 0) {
+ goto Done;
+ }
+ }
+ }
+ } while (FindNextFile (Handle, &FindData));
+ }
+
+Done:
+ //
+ // Free the handle
+ //
+ if (Handle != INVALID_HANDLE_VALUE) {
+ FindClose (Handle);
+ }
+
+ return 0;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
new file mode 100644
index 0000000000..70b88279d2
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.c
@@ -0,0 +1,2561 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiPack.c
+
+Abstract:
+
+ Process HII export and pack files and create HII export files,
+ dumps, or variable defaults packs.
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+#include "EfiInternalFormRepresentation.h"
+#include "HiiPack.h"
+#include "Hii.h"
+#include "IfrParse.h"
+#include "StringParse.h"
+
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "HiiPack"
+#define MAX_PATH 260
+
+//
+// We may have to create an empty IFR formset to provide a GUID for an HII
+// export pack. Create a structure definition to make it easier.
+//
+#pragma pack(1)
+
+typedef struct {
+ EFI_HII_IFR_PACK PackHeader;
+ EFI_IFR_FORM_SET Formset;
+ EFI_IFR_END_FORM_SET EndFormset;
+} EMPTY_FORMSET_PACK;
+
+#pragma pack()
+//
+// We'll store lists of file names from the command line in
+// a linked list of these
+//
+typedef struct _FILE_NAME_LIST {
+ struct _FILE_NAME_LIST *Next;
+ UINT8 FileName[MAX_PATH];
+ int Tag; // used for whatever
+} FILE_NAME_LIST;
+
+//
+// When merging HII export packs, we save HII data table headers in a linked
+// list of these.
+//
+typedef struct _DATA_TABLE_HEADER_LIST {
+ struct _DATA_TABLE_HEADER_LIST *Next;
+ EFI_HII_DATA_TABLE DataTableHeader;
+} DATA_TABLE_HEADER_LIST;
+//
+// Create some defines for the different operation modes supported by this utility
+//
+#define MODE_CREATE_HII_EXPORT 1
+#define MODE_MERGE_HII_EXPORTS 2
+#define MODE_EMIT_DEFAULTS 3
+#define MODE_DUMP_HII_EXPORT 4
+//
+// Here's all our globals.
+//
+static struct {
+ FILE_NAME_LIST *PackFileNames; // Input HII pack file names
+ FILE_NAME_LIST *HiiExportFileNames; // Input files when merging
+ CHAR8 OutputFileName[MAX_PATH]; // Output dump file
+ BOOLEAN MfgFlag; // From -mfg command line arg
+ BOOLEAN NoEmptyVarPacks; // From -noemptyvarpacks command line arg
+ BOOLEAN NoVarPacks; // From -novarpacks command line arg
+ EFI_GUID Guid; // Guid specified on command line
+ BOOLEAN GuidSpecified;
+ BOOLEAN DumpStrings; // In dump mode, dump string data
+ int Verbose;
+ int Mode; // Mode this utility is operating in
+} mGlobals;
+
+static
+void
+Usage (
+ VOID
+ );
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ );
+
+static
+STATUS
+DumpHiiExportFile (
+ char *HiiExportFileName,
+ char *OutputFileName
+ );
+
+static
+void
+DumpString (
+ FILE *OutFptr,
+ int StringIndex,
+ CHAR16 *Str,
+ int Indent
+ );
+
+static
+void
+DumpStringPack (
+ FILE *OutFptr,
+ EFI_HII_STRING_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+DumpVariablePacks (
+ FILE *OutFptr,
+ EFI_HII_VARIABLE_PACK *Pack,
+ int NumPacks,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+TestDumpHiiPack (
+ FILE *OutFptr,
+ char *BufferStart,
+ int BufferSize
+ );
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ char *Buffer,
+ int Count,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+DumpIfrPack (
+ FILE *OutFptr,
+ EFI_HII_IFR_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ );
+
+static
+void
+FreeGlobals (
+ VOID
+ );
+
+static
+STATUS
+AddStringPack (
+ EFI_HII_STRING_PACK *PackHeader
+ );
+
+static
+STATUS
+ProcessHiiExportFile (
+ char *FileName,
+ int MfgDefaults
+ );
+
+static
+STATUS
+ProcessIfrFiles (
+ FILE_NAME_LIST *FileName
+ );
+
+static
+STATUS
+EmitDefaults (
+ FILE_NAME_LIST *HiiExportFiles,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ );
+
+static
+STATUS
+MergeHiiExports (
+ FILE_NAME_LIST *HiiExportFiles,
+ char *OutputFileName,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ );
+
+void
+GuidToString (
+ EFI_GUID *Guid,
+ char *Str
+ );
+
+static
+CHAR16 *
+AsciiToWchar (
+ CHAR8 *Str
+ );
+
+static
+STATUS
+CreateHiiExport (
+ char *OutputFileName,
+ EFI_GUID *DummyFormsetGuid,
+ FILE_NAME_LIST *PackFiles,
+ int MfgDefaults
+ );
+
+int
+main (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Call the routine to parse the command-line options, then process the file.
+
+Arguments:
+
+ Standard C main() argc and argv.
+
+Returns:
+
+ 0 if successful
+ nonzero otherwise
+
+--*/
+// GC_TODO: Argc - add argument and description to function comment
+// GC_TODO: ] - add argument and description to function comment
+{
+ STATUS Status;
+ //
+ // Set the utility name for error reporting purposes
+ //
+ SetUtilityName (UTILITY_NAME);
+ //
+ // Process the command-line arguments
+ //
+ Status = ProcessArgs (Argc, Argv);
+ if (Status != STATUS_SUCCESS) {
+ return Status;
+ }
+ //
+ // Switch based on whether we're dumping, merging, etc.
+ //
+ if (mGlobals.Mode == MODE_DUMP_HII_EXPORT) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Dumping HII export file %s => %s\n", mGlobals.HiiExportFileNames, mGlobals.OutputFileName);
+ }
+
+ DumpHiiExportFile (mGlobals.HiiExportFileNames->FileName, mGlobals.OutputFileName);
+ } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ CreateHiiExport (mGlobals.OutputFileName, &mGlobals.Guid, mGlobals.PackFileNames, mGlobals.MfgFlag);
+ } else if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {
+ MergeHiiExports (mGlobals.HiiExportFileNames, mGlobals.OutputFileName, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);
+ } else if (mGlobals.Mode == MODE_EMIT_DEFAULTS) {
+ EmitDefaults (mGlobals.HiiExportFileNames, mGlobals.MfgFlag, mGlobals.NoEmptyVarPacks);
+ }
+ //
+ //
+ FreeGlobals ();
+ IfrParseEnd ();
+ StringEnd ();
+ return GetUtilityStatus ();
+}
+
+/******************************************************************************/
+static
+STATUS
+MergeHiiExports (
+ FILE_NAME_LIST *HiiExportFiles,
+ char *OutputFileName,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of input HII export pack files, read in the contents
+ of each and create a single HII export pack that contains the contents
+ of all the input files.
+
+Arguments:
+
+ HiiExportFiles - pointer to linked list of input HII export pack file names
+ OutputFileName - name of output (merged) HII export file
+ MfgDefaults - non-zero to emit manufacturing defaults in output file
+ NoEmptyVarPacks - non-zero to not emit 0-length variable packs to the output file
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ EFI_HII_HANDLE HiiHandle;
+ FILE *OutFptr;
+ FILE *InFptr;
+ STATUS Status;
+ CHAR8 *Buffer;
+ int FileSize;
+ int DataTableIndex;
+ int Count;
+ int NumDataTables;
+ EFI_HII_EXPORT_TABLE *HiiExportTableHeader;
+ EFI_HII_EXPORT_TABLE TempHiiExportTableHeader;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ EFI_HII_STRING_PACK *StringPack;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ EFI_HII_IFR_PACK *IfrPack;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ EFI_GUID PackageGuid;
+ EFI_GUID FormsetGuid;
+ long DataTableHeaderOffset;
+ DATA_TABLE_HEADER_LIST *DataTableList;
+ DATA_TABLE_HEADER_LIST *LastDataTable;
+ DATA_TABLE_HEADER_LIST *TempDataTable;
+ //
+ // Init locals
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ Buffer = NULL;
+ InFptr = NULL;
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+ DataTableList = NULL;
+ LastDataTable = NULL;
+ //
+ // Initialize our IFR parser and string routines
+ //
+ IfrParseInit ();
+ StringInit ();
+ //
+ // Process each input HII export file
+ //
+ NumDataTables = 0;
+ while (HiiExportFiles != NULL) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);
+ }
+ //
+ // Read in the entire file contents
+ //
+ if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (CHAR8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ HiiExportTableHeader = (EFI_HII_EXPORT_TABLE *) Buffer;
+ //
+ // Walk all the data tables
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);
+ for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {
+ NumDataTables++;
+ //
+ // Make sure we're still pointing into our buffer
+ //
+ if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {
+ Error (NULL, 0, 0, "bad data table size in input file", NULL);
+ goto Done;
+ }
+ //
+ // Save a copy of the data table header
+ //
+ TempDataTable = (DATA_TABLE_HEADER_LIST *) malloc (sizeof (DATA_TABLE_HEADER_LIST));
+ if (TempDataTable == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ memset ((void *) TempDataTable, 0, sizeof (DATA_TABLE_HEADER_LIST));
+ memcpy (&TempDataTable->DataTableHeader, DataTableHeader, sizeof (EFI_HII_DATA_TABLE));
+ if (DataTableList == NULL) {
+ DataTableList = TempDataTable;
+ } else {
+ LastDataTable->Next = TempDataTable;
+ }
+
+ LastDataTable = TempDataTable;
+ //
+ // If there is an IFR pack, parse it
+ //
+ if (DataTableHeader->IfrDataOffset != 0) {
+ if (IfrParsePack (
+ HiiHandle,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ &DataTableHeader->PackageGuid
+ ) != STATUS_SUCCESS
+ ) {
+ goto Done;
+ }
+ }
+ //
+ // If there is string data, save it
+ //
+ if (DataTableHeader->StringDataOffset != 0) {
+ Status = StringParsePack (
+ HiiHandle,
+ (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),
+ NULL,
+ &DataTableHeader->PackageGuid
+ );
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ }
+ //
+ // If there is device path data, process it
+ //
+ if (DataTableHeader->DevicePathOffset != 0) {
+ Error (NULL, 0, 0, "application error", "%s contains unsupported device path data", HiiExportFiles->FileName);
+ goto Done;
+ }
+ //
+ // Next data pack
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);
+ HiiHandle++;
+ }
+
+ free (Buffer);
+ Buffer = NULL;
+ //
+ // Next input file
+ //
+ HiiExportFiles = HiiExportFiles->Next;
+ }
+ //
+ // Now create defaults
+ //
+ if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Create and write the output HII export header
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ memset ((void *) &TempHiiExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));
+ TempHiiExportTableHeader.NumberOfHiiDataTables = HiiHandle - FIRST_HII_PACK_HANDLE;
+ memcpy (&TempHiiExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));
+ if (fwrite ((void *) &TempHiiExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");
+ goto Done;
+ }
+ //
+ // Now go back through all the handles and create new data packs for each, writing out
+ // the contents as we go.
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ for (TempDataTable = DataTableList; TempDataTable != NULL; TempDataTable = TempDataTable->Next) {
+ //
+ // Write a data table header to the output file. We'll rewind the file and
+ // write an updated one when we're done with this data set
+ //
+ DataTableHeaderOffset = ftell (OutFptr);
+ TempDataTable->DataTableHeader.HiiHandle = HiiHandle;
+ TempDataTable->DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // We may change the number of variable data when merging export files, so init to 0
+ //
+ TempDataTable->DataTableHeader.NumberOfVariableData = 0;
+ if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");
+ goto Done;
+ }
+ //
+ // Get the string pack if any
+ //
+ Status = StringGetPack (HiiHandle, &StringPack, &FileSize, &Count, &FormsetGuid, &PackageGuid);
+ if (Status == STATUS_SUCCESS) {
+ TempDataTable->DataTableHeader.StringDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ TempDataTable->DataTableHeader.DataTableSize += FileSize;
+ //
+ // TempDataTable->DataTableHeader.NumberOfLanguages should be unchanged
+ //
+ if (fwrite ((void *) StringPack, FileSize, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write string pack to output file", NULL);
+ goto Done;
+ }
+ }
+ //
+ // Get the IFR pack
+ //
+ Status = IfrGetIfrPack (HiiHandle, &IfrPack, &FormsetGuid);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Write the IFR pack, followed by the variable packs
+ //
+ TempDataTable->DataTableHeader.IfrDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ TempDataTable->DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ if (fwrite ((void *) IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write IFR pack to output file", NULL);
+ goto Done;
+ }
+ //
+ // If this is just a formset stub, then don't write the variable packs
+ //
+ if (IfrPack->Header.Length != sizeof (EMPTY_FORMSET_PACK)) {
+ //
+ // Go through all the variable packs and see if they're referenced by this IFR
+ //
+ Count = 0;
+ do {
+ Status = IfrGetVarPack (Count, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Check for variable data length of 0
+ //
+ if ((NoEmptyVarPacks == 0) ||
+ ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)
+ ) {
+ //
+ // See if it's referenced by this IFR
+ //
+ if (IfrReferencesVarPack (HiiHandle, VarPack) == STATUS_SUCCESS) {
+ if (TempDataTable->DataTableHeader.VariableDataOffset == 0) {
+ TempDataTable->DataTableHeader.VariableDataOffset = TempDataTable->DataTableHeader.DataTableSize;
+ }
+
+ TempDataTable->DataTableHeader.DataTableSize += VarPack->Header.Length;
+ TempDataTable->DataTableHeader.NumberOfVariableData++;
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write variable pack to output file", NULL);
+ goto Done;
+ }
+
+ }
+ }
+ }
+
+ Count++;
+ } while (Status == STATUS_SUCCESS);
+ }
+
+ Status = STATUS_SUCCESS;
+ }
+ //
+ // Get the device path pack
+ //
+ //
+ // Rewind the file and write the updated data table header.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &TempDataTable->DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII data table header to output file");
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ HiiHandle++;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ StringEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ while (DataTableList != NULL) {
+ TempDataTable = DataTableList->Next;
+ free (DataTableList);
+ DataTableList = TempDataTable;
+ }
+
+ return Status;
+}
+
+/******************************************************************************/
+static
+STATUS
+CreateHiiExport (
+ char *OutputFileName,
+ EFI_GUID *DummyFormsetGuid,
+ FILE_NAME_LIST *PackFiles,
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII pack file names, walk the list to
+ process them and create a single HII export file.
+
+Arguments:
+
+ OutputFileName - name of output HII export file to create
+ DummyFormsetGuid - IFR formsets contain a GUID which is used in many
+ places while processing data tables. If we were not
+ given an IFR pack, then we'll create a stub IFR
+ pack using this GUID as the formset GUID.
+ PackFiles - linked list of HII pack files to process
+ MfgDefaults - when creating variable packs (via IFR pack processing),
+ use manufacturing defaults rather than standard defaults
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ EMPTY_FORMSET_PACK EmptyFormset;
+ EFI_HII_DATA_TABLE DataTableHeader;
+ EFI_HII_EXPORT_TABLE ExportTableHeader;
+ long DataTableHeaderOffset;
+ long FileSize;
+ FILE *OutFptr;
+ FILE *InFptr;
+ FILE_NAME_LIST *TempFile;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ EFI_GUID TempGuid;
+ EFI_GUID PackageGuid;
+ char *Buffer;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ EFI_HII_IFR_PACK *IfrPack;
+ EFI_HII_STRING_PACK_HEADER *StringPack;
+ EFI_HII_STRING_PACK_HEADER TerminatorStringPack;
+ int NumIfr;
+ int NumStrings;
+ int Index;
+ int VarPackIndex;
+ //
+ // If no input HII pack files, then why are we here? Should have been caught when
+ // args were processed though.
+ //
+ if (PackFiles == NULL) {
+ Error (NULL, 0, 0, "no input pack files specified", NULL);
+ return STATUS_ERROR;
+ }
+
+ InFptr = NULL;
+ Status = STATUS_ERROR;
+ Buffer = NULL;
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+ //
+ // Figure out how many data tables we are going to need. We'll create one
+ // data table if no more than one IFR, or we'll create one data table per IFR,
+ // and then one for strings if multiple IFR
+ //
+ NumIfr = 0;
+ NumStrings = 0;
+ for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {
+ if (TempFile->Tag == EFI_HII_IFR) {
+ NumIfr++;
+ } else if (TempFile->Tag == EFI_HII_STRING) {
+ NumStrings++;
+ }
+ }
+ //
+ // Three possibilities:
+ // 1) No IFR, so create one data table that contains only strings and an empty formset
+ // 2) Only 1 IFR, so create an export table with one data table that contains the IFR
+ // and all the strings
+ // 3) Multiple IFR, so create a data table for each IFR and another data table with
+ // all the strings.
+ //
+ // Initialize the export table header and write it out
+ //
+ memset ((void *) &ExportTableHeader, 0, sizeof (EFI_HII_EXPORT_TABLE));
+ if (NumIfr < 2) {
+ ExportTableHeader.NumberOfHiiDataTables = 1;
+ } else {
+ //
+ // One data table per IFR, plus one for strings (if any).
+ //
+ ExportTableHeader.NumberOfHiiDataTables = (UINT16) NumIfr;
+ if (NumStrings != 0) {
+ ExportTableHeader.NumberOfHiiDataTables++;
+ }
+ }
+ //
+ // Init the GUID in the HII export table header
+ //
+ memcpy (&ExportTableHeader.Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID));
+ if (fwrite ((void *) &ExportTableHeader, sizeof (EFI_HII_EXPORT_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write HII export table header to output file");
+ goto Done;
+ }
+ //
+ // *****************************************************************************************
+ //
+ // CASE 1 - No IFR => one data table that contains only strings and an empty formset.
+ // No variable data.
+ //
+ // CASE 2 - Only 1 IFR => create an export table with one data table that contains the IFR
+ // and all the strings plus variable data
+ //
+ // CASE 3 - Multiple IFR => create a data table for each IFR and another data table with
+ // all the strings. Each IFR data table has variable data if applicable.
+ //
+ // *****************************************************************************************
+ //
+ // If the user did not give us an IFR file, then we'll have to create an empty formset
+ // and emit it to the output file. In this case, we need a formset GUID on the command
+ // line.
+ //
+ if ((NumIfr == 0) && (mGlobals.GuidSpecified == 0)) {
+ //
+ // Warning (NULL, 0, 0, "using NULL GUID for empty formset", "specify -g GUID on the command line if desired");
+ //
+ memset ((void *) &PackageGuid, 0, sizeof (EFI_GUID));
+ } else if (mGlobals.GuidSpecified) {
+ //
+ // Use it for the package GUID
+ //
+ memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));
+ }
+ //
+ // Init the data table header.
+ // Write out the blank data table header. Save the offset so we can
+ // write an updated version at the end of processing.
+ //
+ memset ((void *) &DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));
+ DataTableHeaderOffset = ftell (OutFptr);
+ DataTableHeader.HiiHandle = FIRST_HII_PACK_HANDLE;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table (first time) to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+ //
+ // Set the data table size, then write out all the string packs
+ //
+ DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // Write out the string files to a single data record
+ //
+ for (TempFile = PackFiles; TempFile != NULL; TempFile = TempFile->Next) {
+ //
+ // Continue to next file if it's not a string pack file
+ //
+ if (TempFile->Tag != EFI_HII_STRING) {
+ continue;
+ }
+ //
+ // Set the offset in the header if this is the first string pack
+ //
+ if (DataTableHeader.StringDataOffset == 0) {
+ DataTableHeader.StringDataOffset = DataTableHeader.DataTableSize;
+ }
+
+ if ((InFptr = fopen (TempFile->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to open input string pack file for reading");
+ goto Done;
+ }
+ //
+ // Get the file size, then read it into a buffer
+ //
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (char *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, TempFile->FileName, "memory allocation failure reading in file contents");
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Verify that it's actually a string pack
+ //
+ StringPack = (EFI_HII_STRING_PACK_HEADER *) Buffer;
+ while ((char *) StringPack < Buffer + FileSize) {
+ if (StringPack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, TempFile->FileName, "file does not consist entirely of string packs");
+ goto Done;
+ }
+
+ if (StringPack->Header.Length == 0) {
+ break;
+ }
+
+ DataTableHeader.NumberOfLanguages++;
+ DataTableHeader.DataTableSize += StringPack->Header.Length;
+ //
+ // Write the string pack to the output file
+ //
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing string pack to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (StringPack, StringPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, TempFile->FileName, "failed to write string pack to output file");
+ goto Done;
+ }
+ //
+ // Sanity check that adding the length advances us (no wrap)
+ //
+ if ((char *) StringPack + StringPack->Header.Length <= (char *) StringPack) {
+ Error (NULL, 0, 0, TempFile->FileName, "invalid pack size in file");
+ goto Done;
+ }
+
+ StringPack = (EFI_HII_STRING_PACK_HEADER *) ((char *) StringPack + StringPack->Header.Length);
+ }
+ //
+ // Free up buffer, go to next input string pack file
+ //
+ free (Buffer);
+ Buffer = NULL;
+ }
+ //
+ // Write a null-terminator string pack if we had any string packs at all
+ //
+ if (DataTableHeader.StringDataOffset != 0) {
+ memset (&TerminatorStringPack, 0, sizeof (EFI_HII_STRING_PACK_HEADER));
+ TerminatorStringPack.Header.Length = 0;
+ TerminatorStringPack.Header.Type = EFI_HII_STRING;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing terminator string pack to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (&TerminatorStringPack, sizeof (EFI_HII_STRING_PACK_HEADER), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write string pack terminator to output file", NULL);
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += sizeof (EFI_HII_STRING_PACK_HEADER);
+ }
+ //
+ // Parse all the IFR packs, then get the GUID from the first
+ // one so we can use it for the package GUID if necessary.
+ //
+ memcpy (&PackageGuid, &mGlobals.Guid, sizeof (EFI_GUID));
+ if (NumIfr != 0) {
+ IfrParseInit ();
+ if (ProcessIfrFiles (PackFiles) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Set variable defaults in all variable packs
+ //
+ IfrSetDefaults (MfgDefaults);
+ //
+ // Get the GUID from the first IFR pack if the user did not specify a GUID on
+ // the command line.
+ //
+ if (mGlobals.GuidSpecified == 0) {
+ if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &PackageGuid) != STATUS_SUCCESS) {
+ Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");
+ goto Done;
+ }
+ }
+ }
+ //
+ // Set the package GUID in the data table header.
+ //
+ memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // If no IFR, then create and write the empty formset. Otherwise
+ // parse the IFR and emit it and the variable data for it.
+ //
+ if (NumIfr == 0) {
+ memset ((void *) &EmptyFormset, 0, sizeof (EMPTY_FORMSET_PACK));
+ EmptyFormset.PackHeader.Header.Type = EFI_HII_IFR;
+ EmptyFormset.PackHeader.Header.Length = sizeof (EMPTY_FORMSET_PACK);
+ //
+ // Formset Opcode
+ //
+ EmptyFormset.Formset.Header.OpCode = EFI_IFR_FORM_SET_OP;
+ EmptyFormset.Formset.Header.Length = (UINT8) sizeof (EFI_IFR_FORM_SET);
+ memcpy (&EmptyFormset.Formset.Guid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // EndFormset Opcode
+ //
+ EmptyFormset.EndFormset.Header.OpCode = EFI_IFR_END_FORM_SET_OP;
+ EmptyFormset.EndFormset.Header.Length = (UINT8) sizeof (EFI_IFR_END_FORM_SET);
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing stub IFR formset to to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (&EmptyFormset, sizeof (EMPTY_FORMSET_PACK), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write formset stub to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += sizeof (EMPTY_FORMSET_PACK);
+ //
+ // Go back and re-write the data table header, reposition to the end, then return.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table (second time) to offset 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ if (mGlobals.Verbose) {
+ fprintf (
+ stdout,
+ "final file offset=0x%X DataTableHeader.DataTableSize=0x%X\n",
+ ftell (OutFptr),
+ DataTableHeader.DataTableSize
+ );
+ }
+ } else if (NumIfr == 1) {
+ //
+ // They gave us one input IFR file. We parsed it above, so get each one
+ // and emit the IFR and each variable pack it references.
+ // Update the data pack header for the IFR pack, then write the IFR pack data
+ //
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (IfrGetIfrPack (FIRST_HII_PACK_HANDLE, &IfrPack, &TempGuid) != STATUS_SUCCESS) {
+ Error (NULL, 0, 0, "internal application error", "failed to retrieve IFR pack after parsing");
+ goto Done;
+ }
+
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing IFR pack to 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ //
+ // Now go through all the variable packs discovered during IFR processing
+ // and write them to the output file
+ //
+ if (mGlobals.NoVarPacks == 0) {
+ Index = 0;
+ do {
+ Status = IfrGetVarPack (Index, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // If this is the first variable pack, then update the "offset
+ // to variable data" in the data table header
+ //
+ if (Index == 0) {
+ DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;
+ }
+
+ DataTableHeader.DataTableSize += VarPack->Header.Length;
+ DataTableHeader.NumberOfVariableData++;
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");
+ goto Done;
+ }
+
+ Index++;
+ }
+ } while (Status == STATUS_SUCCESS);
+ }
+ //
+ // Reposition in the output file and write the updated data table header
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ } else {
+ //
+ // Multiple IFR input files. Close out the current data table (strings)
+ // if applicable. Then retrieve each parsed IFR pack and create a data pack
+ // that contains the IFR (one per data set) and the variable packs that
+ // the given IFR form references.
+ //
+ if (NumStrings != 0) {
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ } else {
+ //
+ // No strings, so back up over the data table header we wrote because we assumed
+ // at least one string pack.
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ }
+ //
+ // Now go through all the IFR packs and write them out, along with variable
+ // data referenced by each. Note that multiple IFR forms can refer to the
+ // same variables, so the same variable data could be duplicated in multiple
+ // data packs.
+ //
+ Index = FIRST_HII_PACK_HANDLE;
+ while (IfrGetIfrPack (Index, &IfrPack, &TempGuid) == STATUS_SUCCESS) {
+ //
+ // Initialize the data table header
+ //
+ memset (&DataTableHeader, 0, sizeof (EFI_HII_DATA_TABLE));
+ memcpy (&DataTableHeader.PackageGuid, &PackageGuid, sizeof (EFI_GUID));
+ //
+ // If we didn't have strings, then the HiiHandle should be just Index,
+ // rather than Index+1. But since the HiiHandle is not required to start
+ // with 1, we'll let it be Index+1.
+ //
+ DataTableHeader.HiiHandle = (EFI_HII_HANDLE) (Index + 1);
+ DataTableHeader.DataTableSize = sizeof (EFI_HII_DATA_TABLE);
+ //
+ // Save the file offset of the data table header so we can write an updated
+ // version later.
+ //
+ DataTableHeaderOffset = ftell (OutFptr);
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "writing data table header to 0x%X\n", ftell (OutFptr));
+ }
+
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ DataTableHeader.IfrDataOffset = DataTableHeader.DataTableSize;
+ if (fwrite (IfrPack, IfrPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write IFR pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.DataTableSize += IfrPack->Header.Length;
+ //
+ // Go through all the variable packs and see if this IFR references each. If the
+ // IFR does reference it, then add the variable pack to the output.
+ //
+ if (mGlobals.NoVarPacks == 0) {
+ VarPackIndex = 0;
+ while (IfrGetVarPack (VarPackIndex, &VarPack) == STATUS_SUCCESS) {
+ //
+ // See if the IFR references this variable pack
+ //
+ if (IfrReferencesVarPack (Index, VarPack) == STATUS_SUCCESS) {
+ //
+ // If this is the first variable pack, then set the offset in
+ // the data table header.
+ //
+ if (DataTableHeader.VariableDataOffset == 0) {
+ DataTableHeader.VariableDataOffset = DataTableHeader.DataTableSize;
+ }
+ //
+ // Write the variable pack
+ //
+ if (fwrite (VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutputFileName, "failed to write variable pack to output file");
+ goto Done;
+ }
+
+ DataTableHeader.NumberOfVariableData++;
+ DataTableHeader.DataTableSize += VarPack->Header.Length;
+ }
+
+ VarPackIndex++;
+ }
+ }
+ //
+ // Write the updated data table header
+ //
+ fseek (OutFptr, DataTableHeaderOffset, SEEK_SET);
+ if (fwrite ((void *) &DataTableHeader, sizeof (EFI_HII_DATA_TABLE), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, "failed to write Data Table Header to output file", NULL);
+ goto Done;
+ }
+
+ fseek (OutFptr, 0, SEEK_END);
+ //
+ // Next IFR pack
+ //
+ Index++;
+ }
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ StringEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+/******************************************************************************/
+static
+STATUS
+ProcessIfrFiles (
+ FILE_NAME_LIST *FileName
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of pack file names, read in each IFR pack file
+ and process the contents.
+
+Arguments:
+
+ FileName - pointer to linked list of input pack file names
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE *InFptr;
+ char *Buffer;
+ long BufferSize;
+ STATUS Status;
+ STATUS IfrStatus;
+ int Handle;
+ EFI_GUID FormsetGuid;
+ EFI_HII_PACK_HEADER *PackHeader;
+ //
+ // Process each input IFR file
+ //
+ Status = STATUS_ERROR;
+ Handle = 1;
+ InFptr = NULL;
+ Buffer = NULL;
+ while (FileName != NULL) {
+ //
+ // Only process IFR pack files
+ //
+ if (FileName->Tag != EFI_HII_IFR) {
+ FileName = FileName->Next;
+ continue;
+ }
+ //
+ // Open the input file, then read the contents
+ //
+ if ((InFptr = fopen (FileName->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, FileName->FileName, "failed to open input IFR file");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (char *) malloc (BufferSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, BufferSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, FileName->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Check the buffer contents -- better be an IFR pack
+ //
+ if (BufferSize < sizeof (EFI_HII_PACK_HEADER)) {
+ Error (NULL, 0, 0, FileName->FileName, "file is not large enough to contain an IFR pack");
+ goto Done;
+ }
+
+ PackHeader = (EFI_HII_PACK_HEADER *) Buffer;
+ if (PackHeader->Type != EFI_HII_IFR) {
+ Error (NULL, 0, 0, FileName->FileName, "file does not appear to be an IFR pack");
+ goto Done;
+ }
+ //
+ // Process the contents
+ //
+ memset ((void *) &FormsetGuid, 0, sizeof (EFI_GUID));
+ IfrStatus = IfrParsePack (Handle, (EFI_HII_IFR_PACK *) PackHeader, &FormsetGuid);
+ if (IfrStatus != STATUS_SUCCESS) {
+ goto Done;
+ }
+
+ Handle++;
+ free (Buffer);
+ Buffer = NULL;
+ FileName = FileName->Next;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ return Status;
+}
+
+static
+STATUS
+EmitDefaults (
+ FILE_NAME_LIST *HiiExportFiles,
+ int MfgDefaults,
+ int NoEmptyVarPacks
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII export files, read in each file,
+ process the contents, and then emit variable packs.
+
+Arguments:
+
+ HiiExportFiles - linked list of HII export files to process
+ MfgDefaults - emit manufacturing defaults
+ NoEmptyVarPacks - don't emit variable packs if they are 0-length
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ int HiiHandle;
+ FILE *OutFptr;
+ FILE *InFptr;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ CHAR8 OutFileName[MAX_PATH];
+ CHAR8 GuidString[100];
+ STATUS Status;
+ CHAR8 *Buffer;
+ int FileSize;
+ int DataTableIndex;
+ EFI_HII_EXPORT_TABLE *HiiExportTableHeader;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ //
+ // Init locals
+ //
+ HiiHandle = FIRST_HII_PACK_HANDLE;
+ Buffer = NULL;
+ InFptr = NULL;
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+ //
+ // Initialize our IFR parser
+ //
+ IfrParseInit ();
+ //
+ // Process each input HII export file
+ //
+ while (HiiExportFiles != NULL) {
+ if (mGlobals.Verbose) {
+ fprintf (stdout, "Processing file %s\n", HiiExportFiles->FileName);
+ }
+ //
+ // Read in the entire file contents
+ //
+ if ((InFptr = fopen (HiiExportFiles->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to open HII export file for reading");
+ goto Done;
+ }
+
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (CHAR8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFiles->FileName, "failed to read file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ HiiExportTableHeader = (EFI_HII_EXPORT_TABLE *) Buffer;
+ //
+ // Walk all the data tables
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) (HiiExportTableHeader + 1);
+ for (DataTableIndex = 0; DataTableIndex < (int) HiiExportTableHeader->NumberOfHiiDataTables; DataTableIndex++) {
+ //
+ // Make sure we're still pointing into our buffer
+ //
+ if (((char *) DataTableHeader < Buffer) || ((char *) DataTableHeader > Buffer + FileSize)) {
+ Error (NULL, 0, 0, "bad data table size in input file", NULL);
+ goto Done;
+ }
+ //
+ // If there is an IFR pack, parse it
+ //
+ HiiHandle++;
+ if (DataTableHeader->IfrDataOffset != 0) {
+ if (IfrParsePack (
+ HiiHandle,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ &DataTableHeader->PackageGuid
+ ) != STATUS_SUCCESS
+ ) {
+ goto Done;
+ }
+ }
+ //
+ // Next data pack
+ //
+ DataTableHeader = (EFI_HII_DATA_TABLE *) ((char *) DataTableHeader + DataTableHeader->DataTableSize);
+ }
+
+ free (Buffer);
+ Buffer = NULL;
+ //
+ // Next input file
+ //
+ HiiExportFiles = HiiExportFiles->Next;
+ }
+ //
+ // Now create defaults
+ //
+ if (IfrSetDefaults (MfgDefaults) != STATUS_SUCCESS) {
+ goto Done;
+ }
+ //
+ // Now retrieve each variable pack and write it out to a GUID-VarName.hpk file
+ //
+ HiiHandle = 0;
+ do {
+ Status = IfrGetVarPack (HiiHandle, &VarPack);
+ if (Status == STATUS_SUCCESS) {
+ //
+ // Check for variable data length of 0
+ //
+ if ((NoEmptyVarPacks == 0) ||
+ ((VarPack->Header.Length - sizeof (EFI_HII_VARIABLE_PACK) - VarPack->VariableNameLength) != 0)
+ ) {
+ //
+ // Open the output file and write the variable pack
+ //
+ GuidToString (&VarPack->VariableGuid, GuidString);
+ if (MfgDefaults) {
+ sprintf (
+ OutFileName,
+ "%s-%S-MfgDefaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ } else {
+ sprintf (
+ OutFileName,
+ "%s-%S-Defaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ }
+
+ if (mGlobals.Verbose) {
+ fprintf (
+ stdout,
+ "Creating %svariable defaults pack file %s\n",
+ MfgDefaults ? "manufacturing " : "",
+ OutFileName
+ );
+ }
+
+ if ((OutFptr = fopen (OutFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutFileName, "failed to open output file for writing", NULL);
+ goto Done;
+ }
+
+ if (fwrite ((void *) VarPack, VarPack->Header.Length, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0, OutFileName, "failed to write defaults to output file");
+ goto Done;
+ }
+
+ fclose (OutFptr);
+ OutFptr = NULL;
+ } else {
+ //
+ // Print a message that we skipped one if in verbose mode
+ //
+ if (mGlobals.Verbose) {
+ GuidToString (&VarPack->VariableGuid, GuidString);
+ if (MfgDefaults) {
+ sprintf (
+ OutFileName,
+ "%s-%S-MfgDefaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ } else {
+ sprintf (
+ OutFileName,
+ "%s-%S-Defaults%s",
+ GuidString,
+ (CHAR16 *) (VarPack + 1),
+ DEFAULT_HII_PACK_FILENAME_EXTENSION
+ );
+ }
+
+ fprintf (
+ stdout,
+ "Skipping 0-length %svariable defaults pack file %s\n",
+ MfgDefaults ? "manufacturing " : "",
+ OutFileName
+ );
+ }
+ }
+ }
+
+ HiiHandle++;
+ } while (Status == STATUS_SUCCESS);
+ Status = STATUS_SUCCESS;
+Done:
+ IfrParseEnd ();
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+static
+void
+FreeGlobals (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up an memory we allocated so we can exit cleanly
+
+Arguments:
+
+Returns: NA
+
+--*/
+{
+ FILE_NAME_LIST *Next;
+ //
+ // Free up input pack file names
+ //
+ while (mGlobals.PackFileNames != NULL) {
+ Next = mGlobals.PackFileNames->Next;
+ free (mGlobals.PackFileNames);
+ mGlobals.PackFileNames = Next;
+ }
+ //
+ // Free up input HII export file names
+ //
+ while (mGlobals.HiiExportFileNames != NULL) {
+ Next = mGlobals.HiiExportFileNames->Next;
+ free (mGlobals.HiiExportFileNames);
+ mGlobals.HiiExportFileNames = Next;
+ }
+}
+
+static
+STATUS
+DumpHiiExportFile (
+ char *HiiExportFileName,
+ char *OutputFileName
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an HII export file for debug purposes
+
+Arguments:
+
+ HiiExportFileName - name of input HII export file
+ OutputFileName - name of output file to dump contents
+
+Returns:
+ STATUS_SUCCESS - no problems
+ STATUS_ERROR - problems encountered processing the file
+
+--*/
+{
+ FILE *InFptr;
+
+ FILE *OutFptr;
+ char *Buffer;
+ char *BufferStart;
+ char *BufferEnd;
+ int BufferSize;
+ STATUS Status;
+ char GuidString[100];
+ int Counter;
+ int NumberOfTables;
+ EFI_HII_DATA_TABLE *DataTableHeader;
+ EFI_GUID HiiExportRevisionGuid = EFI_HII_PROTOCOL_GUID;
+ //
+ // Init locals
+ //
+ InFptr = NULL;
+ OutFptr = NULL;
+ BufferStart = NULL;
+ Status = STATUS_ERROR;
+ //
+ // Open the input file
+ //
+ if ((InFptr = fopen (HiiExportFileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, HiiExportFileName, "failed to open input HII export file for reading");
+ goto Done;
+ }
+ //
+ // Open the output file
+ //
+ if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+ //
+ // Get the file size, then allocate a buffer and read in the file contents.
+ //
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = (int) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ BufferStart = (char *) malloc (BufferSize);
+ if (BufferStart == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (BufferStart, BufferSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0, HiiExportFileName, "error reading file contents");
+ goto Done;
+ }
+
+ fclose (InFptr);
+ InFptr = NULL;
+ //
+ // Crude check of the input data -- check the size and GUID
+ //
+ if (BufferSize < sizeof (EFI_HII_EXPORT_TABLE)) {
+ Error (NULL, 0, 0, HiiExportFileName, "files not large enough to contain an HII export table header");
+ goto Done;
+ }
+
+ if (memcmp (&((EFI_HII_EXPORT_TABLE *) BufferStart)->Revision, &HiiExportRevisionGuid, sizeof (EFI_GUID)) != 0) {
+ Error (NULL, 0, 0, HiiExportFileName, "invalid HII export revision GUID -- is this an HII export file?");
+ //
+ // See if it's a HII pack file
+ //
+ TestDumpHiiPack (OutFptr, BufferStart, BufferSize);
+ goto Done;
+ }
+ //
+ // Now walk the export data
+ //
+ Buffer = BufferStart;
+ BufferEnd = BufferStart + BufferSize;
+ //
+ // Dump the header
+ //
+ fprintf (OutFptr, "HII dump of file %s\n\n", HiiExportFileName);
+ NumberOfTables = ((EFI_HII_EXPORT_TABLE *) Buffer)->NumberOfHiiDataTables;
+ fprintf (OutFptr, "Number of data tables: %d\n", NumberOfTables);
+ GuidToString (&((EFI_HII_EXPORT_TABLE *) Buffer)->Revision, GuidString);
+ fprintf (OutFptr, "HII export revision: %s\n", GuidString);
+ //
+ // Now walk the data tables
+ //
+ Buffer += sizeof (EFI_HII_EXPORT_TABLE);
+ for (Counter = 0; Counter < NumberOfTables; Counter++) {
+ DataTableHeader = (EFI_HII_DATA_TABLE *) Buffer;
+ fprintf (OutFptr, "----------------------------------------------------------\n");
+ fprintf (OutFptr, " DataTable at offset 0x%08X\n", (int) Buffer - (int) BufferStart);
+ fprintf (OutFptr, " HII Handle: 0x%08X\n", DataTableHeader->HiiHandle);
+ GuidToString (&DataTableHeader->PackageGuid, GuidString);
+ fprintf (OutFptr, " Package GUID: %s\n", GuidString);
+ fprintf (OutFptr, " Data table size: 0x%08X\n", DataTableHeader->DataTableSize);
+ fprintf (OutFptr, " IFR data offset: 0x%08X\n", DataTableHeader->IfrDataOffset);
+ fprintf (OutFptr, " String data offset: 0x%08X\n", DataTableHeader->StringDataOffset);
+ fprintf (OutFptr, " Variable data offset: 0x%08X\n", DataTableHeader->VariableDataOffset);
+ fprintf (OutFptr, " Device path offset: 0x%08X\n", DataTableHeader->DevicePathOffset);
+ fprintf (OutFptr, " Number of variable data: 0x%08X\n", DataTableHeader->NumberOfVariableData);
+ fprintf (OutFptr, " Number of languages: 0x%08X\n", DataTableHeader->NumberOfLanguages);
+ //
+ // Dump strings
+ //
+ if (DataTableHeader->StringDataOffset != 0) {
+ DumpStringPack (
+ OutFptr,
+ (EFI_HII_STRING_PACK *) ((char *) DataTableHeader + DataTableHeader->StringDataOffset),
+ DataTableHeader->StringDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump IFR
+ //
+ if (DataTableHeader->IfrDataOffset != 0) {
+ DumpIfrPack (
+ OutFptr,
+ (EFI_HII_IFR_PACK *) ((char *) DataTableHeader + DataTableHeader->IfrDataOffset),
+ DataTableHeader->IfrDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump variables
+ //
+ if (DataTableHeader->VariableDataOffset != 0) {
+ DumpVariablePacks (
+ OutFptr,
+ (EFI_HII_VARIABLE_PACK *) ((char *) DataTableHeader + DataTableHeader->VariableDataOffset),
+ DataTableHeader->NumberOfVariableData,
+ DataTableHeader->VariableDataOffset,
+ 6
+ );
+ }
+ //
+ // Dump device path
+ //
+ //
+ // Check position before advancing
+ //
+ if ((Buffer + DataTableHeader->DataTableSize < Buffer) || (Buffer + DataTableHeader->DataTableSize > BufferEnd)) {
+ Error (NULL, 0, 0, HiiExportFileName, "bad data table size at offset 0x%X", (int) Buffer - (int) BufferStart);
+ goto Done;
+ }
+
+ Buffer += DataTableHeader->DataTableSize;
+ }
+
+ Status = STATUS_SUCCESS;
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (BufferStart != NULL) {
+ free (BufferStart);
+ }
+
+ return Status;
+}
+
+static
+void
+DumpIfrPack (
+ FILE *OutFptr,
+ EFI_HII_IFR_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an IFR pack for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to IFR pack to dump
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ EFI_IFR_FORM_SET *IfrFormSet;
+ char GuidString[100];
+ if (Pack->Header.Type != EFI_HII_IFR) {
+ Error (NULL, 0, 0, "found non-IFR pack type at IFR data offset", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cIFR pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ //
+ // Get the GUID from the formset
+ //
+ IfrFormSet = (EFI_IFR_FORM_SET *) (Pack + 1);
+ GuidToString (&IfrFormSet->Guid, GuidString);
+ fprintf (OutFptr, "%*c Variable GUID %s\n", Indent, ' ', GuidString);
+ //
+ // Print the IFR formset size, with a note indicating if it's a min (likely stub)
+ // formset
+ //
+ if (Pack->Header.Length == sizeof (EMPTY_FORMSET_PACK)) {
+ fprintf (
+ OutFptr,
+ "%*c IFR formset size 0x%08X (empty formset)\n",
+ Indent,
+ ' ',
+ Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)
+ );
+ } else {
+ fprintf (
+ OutFptr,
+ "%*c IFR formset size 0x%08X\n",
+ Indent,
+ ' ',
+ Pack->Header.Length - sizeof (EFI_HII_IFR_PACK)
+ );
+ }
+ //
+ // Dump raw bytes -- not much use
+ //
+}
+
+static
+void
+DumpVariablePacks (
+ FILE *OutFptr,
+ EFI_HII_VARIABLE_PACK *Pack,
+ int NumPacks,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of an IFR pack for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to variable pack to dump
+ NumPacks - number of packs in Pack[] array
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ int Count;
+
+ int Len;
+ char GuidString[100];
+
+ for (Count = 0; Count < NumPacks; Count++) {
+ if (Pack->Header.Type != EFI_HII_VARIABLE) {
+ Error (NULL, 0, 0, "found non-variable pack type in variable pack array", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cVariable pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ GuidToString (&Pack->VariableGuid, GuidString);
+ fprintf (OutFptr, "%*c Variable GUID %s\n", Indent, ' ', GuidString);
+ fprintf (OutFptr, "%*c Variable Name %S\n", Indent, ' ', (CHAR16 *) (Pack + 1));
+ Len = sizeof (EFI_HII_VARIABLE_PACK) + Pack->VariableNameLength;
+ fprintf (OutFptr, "%*c Variable Size 0x%08X\n", Indent, ' ', Pack->Header.Length - Len);
+ //
+ // Dump raw bytes
+ //
+ DumpRawBytes (OutFptr, (char *) Pack + Len, Pack->Header.Length - Len, Len, Indent + 2);
+ BaseOffset += Pack->Header.Length;
+ Pack = (EFI_HII_VARIABLE_PACK *) ((char *) Pack + Pack->Header.Length);
+ }
+}
+
+static
+void
+DumpStringPack (
+ FILE *OutFptr,
+ EFI_HII_STRING_PACK *Pack,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump the contents of a string pack array for debug purposes
+
+Arguments:
+
+ OutFptr - file pointer to which to dump the output
+ Pack - pointer to string pack array to dump
+ BaseOffset - offset from which Pack starts in its parent data table
+ Indent - indent this many spaces when printing text to OutFptr
+
+Returns:
+ NA
+
+--*/
+{
+ int Count;
+ int *IndexPtr;
+ CHAR16 *WCPtr;
+ //
+ // String pack array is terminated with a zero-length string pack
+ //
+ while (Pack->Header.Length > 0) {
+ if (Pack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, "found non-string pack type in string pack array", NULL);
+ return ;
+ }
+
+ fprintf (OutFptr, "%*cString pack at offset 0x%08X\n", Indent, ' ', BaseOffset);
+ fprintf (OutFptr, "%*c Length 0x%08X\n", Indent, ' ', Pack->Header.Length);
+ fprintf (
+ OutFptr,
+ "%*c Language %S\n",
+ Indent,
+ ' ',
+ (CHAR16 *) ((char *) Pack + Pack->LanguageNameString)
+ );
+ fprintf (
+ OutFptr,
+ "%*c Printable Language %S\n",
+ Indent,
+ ' ',
+ (CHAR16 *) ((char *) Pack + Pack->PrintableLanguageName)
+ );
+ fprintf (OutFptr, "%*c Number of strings 0x%08X\n", Indent, ' ', Pack->NumStringPointers);
+ fprintf (OutFptr, "%*c Attributes 0x%08X\n", Indent, ' ', Pack->Attributes);
+ IndexPtr = (int *) (Pack + 1);
+ //
+ // Dump string data
+ //
+ if (mGlobals.DumpStrings) {
+ for (Count = 0; Count < (int) Pack->NumStringPointers; Count++) {
+ fprintf (OutFptr, "%*c String 0x%04X: ", Indent, ' ', Count);
+ //
+ // Print raw hex bytes
+ //
+ for (WCPtr = (CHAR16 *) ((char *) Pack +*IndexPtr); *WCPtr != 0; WCPtr++) {
+ fprintf (OutFptr, "%02X ", (unsigned int) *WCPtr);
+ }
+
+ fprintf (OutFptr, "00\n");
+ IndexPtr++;
+ }
+ }
+
+ BaseOffset += Pack->Header.Length;
+ Pack = (EFI_HII_STRING_PACK *) ((char *) Pack + Pack->Header.Length);
+ }
+}
+
+static
+void
+TestDumpHiiPack (
+ FILE *OutFptr,
+ char *Buffer,
+ int BufferSize
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ OutFptr - GC_TODO: add argument description
+ Buffer - GC_TODO: add argument description
+ BufferSize - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_HII_PACK_HEADER *PackHeader;
+
+ PackHeader = (EFI_HII_PACK_HEADER *) Buffer;
+ //
+ // Check size match
+ //
+ if (PackHeader->Length != (unsigned int) BufferSize) {
+ return ;
+ }
+ //
+ // Check type
+ //
+ switch (PackHeader->Type) {
+ case EFI_HII_STRING:
+ fprintf (stdout, "Dumping as string pack\n");
+ DumpStringPack (OutFptr, (EFI_HII_STRING_PACK *) Buffer, 0, 2);
+ break;
+
+ case EFI_HII_IFR:
+ fprintf (stdout, "Dumping as IFR pack\n");
+ DumpIfrPack (OutFptr, (EFI_HII_IFR_PACK *) Buffer, 0, 2);
+ break;
+
+ case EFI_HII_VARIABLE:
+ fprintf (stdout, "Dumping as IFR pack\n");
+ DumpVariablePacks (OutFptr, (EFI_HII_VARIABLE_PACK *) Buffer, 1, 0, 2);
+ break;
+ }
+}
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ char *Buffer,
+ int Count,
+ int BaseOffset,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ OutFptr - GC_TODO: add argument description
+ Buffer - GC_TODO: add argument description
+ Count - GC_TODO: add argument description
+ BaseOffset - GC_TODO: add argument description
+ Indent - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ int Counter;
+
+ for (Counter = 0; Counter < Count; Counter++) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter != 0) {
+ fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);
+ } else {
+ fprintf (OutFptr, "\n%*c%08X ", Indent, ' ', Counter);
+ }
+ }
+
+ fprintf (OutFptr, "%02X ", (unsigned int) (unsigned char) *Buffer);
+ Buffer++;
+ }
+
+ fprintf (OutFptr, "\n");
+}
+
+void
+GuidToString (
+ EFI_GUID *Guid,
+ char *Str
+ )
+/*++
+
+Routine Description:
+
+ Given a pointer to a GUID, sprint the value into a string
+
+Arguments:
+
+ Guid - pointer to input GUID
+ Str - pointer to outgoing printed GUID value
+
+Returns:
+ NA
+
+--*/
+{
+ sprintf (
+ Str,
+ "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ Guid->Data1,
+ Guid->Data2,
+ Guid->Data3,
+ Guid->Data4[0],
+ Guid->Data4[1],
+ Guid->Data4[2],
+ Guid->Data4[3],
+ Guid->Data4[4],
+ Guid->Data4[5],
+ Guid->Data4[6],
+ Guid->Data4[7]
+ );
+}
+
+int
+FindFilesCallback (
+ char *FoundFileName
+ )
+/*++
+
+Routine Description:
+
+ Callback function used to get files matching a file mask. This
+ function is called when the command-line arguments to this utility
+ are parsed and the user specified "-s Path FileMask" to process
+ all HII export files in Path and its subdirectories that match
+ FileMask.
+
+Arguments:
+
+ FoundFileName - name of file found.
+
+Returns:
+ non-zero - caller should halt processing
+ zero - no problems while processing FoundFileName
+
+--*/
+{
+ FILE_NAME_LIST *FileName;
+
+ FILE_NAME_LIST *TempFileName;
+
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ strcpy (FileName->FileName, FoundFileName);
+ if (mGlobals.HiiExportFileNames == NULL) {
+ mGlobals.HiiExportFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.HiiExportFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+
+ return 0;
+}
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ As per standard C main()
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+// GC_TODO: Argc - add argument and description to function comment
+// GC_TODO: ] - add argument and description to function comment
+{
+ FILE_NAME_LIST *FileName;
+
+ FILE_NAME_LIST *TempFileName;
+ FILE *InFptr;
+ EFI_HII_PACK_HEADER PackHeader;
+
+ memset ((void *) &mGlobals, 0, sizeof (mGlobals));
+ //
+ // Skip program name
+ //
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+ //
+ // First arg must be one of create, merge, defaults, or dump
+ //
+ if (_stricmp (Argv[0], "create") == 0) {
+ mGlobals.Mode = MODE_CREATE_HII_EXPORT;
+ } else if (_stricmp (Argv[0], "merge") == 0) {
+ mGlobals.Mode = MODE_MERGE_HII_EXPORTS;
+ } else if (_stricmp (Argv[0], "defaults") == 0) {
+ mGlobals.Mode = MODE_EMIT_DEFAULTS;
+ } else if (_stricmp (Argv[0], "dump") == 0) {
+ mGlobals.Mode = MODE_DUMP_HII_EXPORT;
+ } else if (strcmp (Argv[0], "-?") == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ } else {
+ Error (NULL, 0, 0, Argv[0], "unrecognized mode");
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ //
+ // Process until no more args.
+ //
+ while (Argc > 0) {
+ if (_stricmp (Argv[0], "-o") == 0) {
+ //
+ // -o option to specify the output file
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output file name");
+ return STATUS_ERROR;
+ }
+
+ if (mGlobals.OutputFileName[0] == 0) {
+ mGlobals.OutputFileName[MAX_PATH - 1] = 0;
+ strncpy (mGlobals.OutputFileName, Argv[1], MAX_PATH - 1);
+ } else {
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-o option already specified with '%s'", mGlobals.OutputFileName);
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ } else if (_stricmp (Argv[0], "-mfg") == 0) {
+ mGlobals.MfgFlag = 1;
+ } else if (_stricmp (Argv[0], "-g") == 0) {
+ //
+ // -g option to specify the guid
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing GUID");
+ return STATUS_ERROR;
+ }
+
+ StringToGuid (Argv[1], &mGlobals.Guid);
+ mGlobals.GuidSpecified = 1;
+ Argv++;
+ Argc--;
+ } else if (_stricmp (Argv[0], "-v") == 0) {
+ mGlobals.Verbose = 1;
+ } else if (_stricmp (Argv[0], "-p") == 0) {
+ //
+ // -p option to specify an input pack file. Only valid for 'create' mode
+ //
+ if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Open the file, read the pack header, and figure out what type of
+ // HII pack it is.
+ //
+ if ((InFptr = fopen (Argv[0], "rb")) == NULL) {
+ Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");
+ return STATUS_ERROR;
+ }
+
+ if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {
+ Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+
+ fclose (InFptr);
+ if ((PackHeader.Type != EFI_HII_STRING) &&
+ (PackHeader.Type != EFI_HII_IFR) &&
+ (PackHeader.Type != EFI_HII_VARIABLE)
+ ) {
+ Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);
+ return STATUS_ERROR;
+ }
+ //
+ // Add this file name to our list of pack files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ FileName->Tag = (int) PackHeader.Type;
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.PackFileNames == NULL) {
+ mGlobals.PackFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else if (_stricmp (Argv[0], "-noemptyvarpacks") == 0) {
+ mGlobals.NoEmptyVarPacks = 1;
+ } else if (_stricmp (Argv[0], "-novarpacks") == 0) {
+ mGlobals.NoVarPacks = 1;
+ } else if (_stricmp (Argv[0], "-x") == 0) {
+ //
+ // -x option to specify an input HII export file name. Not valid for 'create' mode
+ //
+ if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option is not valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing HII export input file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Add this file name to our list of export files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.HiiExportFileNames == NULL) {
+ mGlobals.HiiExportFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.HiiExportFileNames;
+ TempFileName->Next != NULL;
+ TempFileName = TempFileName->Next
+ )
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else if (_stricmp (Argv[0], "-dumpstrings") == 0) {
+ mGlobals.DumpStrings = 1;
+ } else if (_stricmp (Argv[0], "-s") == 0) {
+ //
+ // -s option to specify input HII export files using a path and file mask.
+ // Only valid in merge mode
+ //
+ if (mGlobals.Mode != MODE_MERGE_HII_EXPORTS) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'merge' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing root directory name");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 2) || (Argv[2][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing file mask");
+ return STATUS_ERROR;
+ }
+ //
+ // Call our function to process the directory and file mask. If
+ // the directory does not start with c:\, then prepend cwd to it.
+ //
+ if (FindFiles (Argv[1], Argv[2], FindFilesCallback)) {
+ Error (NULL, 0, 0, "failed to process matching files", "%s\\%s", Argv[1], Argv[2]);
+ return STATUS_ERROR;
+ }
+
+ Argv += 2;
+ Argc -= 2;
+ } else if (_stricmp (Argv[0], "-p") == 0) {
+ //
+ // -p option to specify an input pack file. Only valid for 'create' mode
+ //
+ if (mGlobals.Mode != MODE_CREATE_HII_EXPORT) {
+ Error (NULL, 0, 0, Argv[0], "option only valid in 'create' mode");
+ return STATUS_ERROR;
+ }
+
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing pack file name");
+ return STATUS_ERROR;
+ }
+ //
+ // Consume arguments until next -arg or end
+ //
+ do {
+ Argv++;
+ Argc--;
+ //
+ // Open the file, read the pack header, and figure out what type of
+ // HII pack it is.
+ //
+ if ((InFptr = fopen (Argv[0], "rb")) == NULL) {
+ Error (NULL, 0, 0, Argv[0], "failed to open input HII pack file for reading");
+ return STATUS_ERROR;
+ }
+
+ if (fread (&PackHeader, sizeof (EFI_HII_PACK_HEADER), 1, InFptr) != 1) {
+ Error (NULL, 0, 0, Argv[0], "failed to read pack header from input HII pack file");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+
+ fclose (InFptr);
+ if ((PackHeader.Type != EFI_HII_STRING) &&
+ (PackHeader.Type != EFI_HII_IFR) &&
+ (PackHeader.Type != EFI_HII_VARIABLE)
+ ) {
+ Error (NULL, 0, 0, Argv[0], "unsupported HII pack type 0x%X", (unsigned int) PackHeader.Type);
+ return STATUS_ERROR;
+ }
+ //
+ // Add this file name to our list of pack files
+ //
+ FileName = (FILE_NAME_LIST *) malloc (sizeof (FILE_NAME_LIST));
+ if (FileName == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) FileName, 0, sizeof (FILE_NAME_LIST));
+ FileName->Tag = (int) PackHeader.Type;
+ strcpy (FileName->FileName, Argv[0]);
+ if (mGlobals.PackFileNames == NULL) {
+ mGlobals.PackFileNames = FileName;
+ } else {
+ //
+ // Add to the end of the list
+ //
+ for (TempFileName = mGlobals.PackFileNames; TempFileName->Next != NULL; TempFileName = TempFileName->Next)
+ ;
+ TempFileName->Next = FileName;
+ }
+ } while ((Argc > 1) && (Argv[1][0] != '-'));
+ } else {
+ Error (NULL, 0, 0, Argv[0], "unrecognized option");
+ return STATUS_ERROR;
+ }
+
+ Argv++;
+ Argc--;
+ }
+ //
+ // All modes except 'defaults' requires an output file name
+ //
+ if (mGlobals.Mode != MODE_EMIT_DEFAULTS) {
+ if (mGlobals.OutputFileName[0] == 0) {
+ Error (NULL, 0, 0, "must specify '-o OutputFileName'", NULL);
+ return STATUS_ERROR;
+ }
+ //
+ // If merging, then you have to specify at least one HII export files.
+ // We support specifying only one file in case you want to take an export file
+ // and emit a copy with different (for example, manufacturing) defaults.
+ //
+ if (mGlobals.Mode == MODE_MERGE_HII_EXPORTS) {
+ if (mGlobals.HiiExportFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one HII export file in 'merge' mode", NULL);
+ return STATUS_ERROR;
+ }
+ } else if (mGlobals.Mode == MODE_CREATE_HII_EXPORT) {
+ //
+ // Must have specified at least one HII pack file
+ //
+ if (mGlobals.PackFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one input HII pack file in 'create' mode", NULL);
+ return STATUS_ERROR;
+ }
+ }
+ } else {
+ //
+ // Must have specified an input HII export file name
+ //
+ if (mGlobals.HiiExportFileNames == NULL) {
+ Error (NULL, 0, 0, "must specify at least one '-x HiiExportFileName'", NULL);
+ return STATUS_ERROR;
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Create/Dump HII Database Files Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME " [MODE] [OPTION]",
+ "Modes:",
+ " create create an HII export file from one or more HII pack files",
+ " merge merge two or more HII export files into one HII export file",
+ " defaults emit variable defaults from an input HII export file",
+ " dump ASCII dump the contents of an HII export file",
+ "Options for all modes:",
+ " -o FileName write output to FileName",
+ " -mfg use manufacturing defaults from IFR rather than standard defaults",
+ " -g GUID use GUID for a package GUID in the data tables where applicable",
+ " -v verbose operation",
+ "Options for 'create' mode:",
+ " -p PackFileName(s) include contents of HII pack file PackFileName",
+ " in the output file",
+ " -novarpacks don't emit variable packs to the output file",
+ "Options for 'merge' mode:",
+ " -x HiiExportFileName(s) include contents of HII export file",
+ " HiiExportFileName in the output file",
+ " -s Path FileMask include all matching HII export files in Path",
+ " and its subdirectories in the output file.",
+ " If Path does not begin with the form C:\\, then",
+ " it is assumed to be relative to the current working",
+ " directory. FileMask may contain wildcard characters.",
+ "Options for 'defaults' mode:",
+ " -x HiiExportFileName emit defaults from all variables referenced",
+ " in input file HiiExportFileName",
+ " -noemptyvarpacks don't emit variable packs for 0-length variables",
+ "Options for 'dump' mode:",
+ " -x HiiExportFileName dump contents of input file HiiExportFileName",
+ " -dumpstrings dump string data",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
new file mode 100644
index 0000000000..e9fa66b759
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/HiiPack.h
@@ -0,0 +1,63 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiPack.h
+
+Abstract:
+
+ Common defines and prototypes for the HII pack tool.
+
+--*/
+
+#ifndef _HII_PACK_H_
+#define _HII_PACK_H_
+
+#define DEFAULT_VARIABLE_NAME_L L"Setup"
+#define DEFAULT_VARIABLE_NAME "Setup"
+
+#define MAX_VARIABLE_NAME 256
+#define FIRST_HII_PACK_HANDLE 1
+
+typedef
+int
+(*FIND_FILE_CALLBACK) (
+ char *FileName
+ );
+
+extern
+int
+FindFiles (
+ char *RootDirectory,
+ char *FileMask,
+ FIND_FILE_CALLBACK Callback
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ RootDirectory - GC_TODO: add argument description
+ FileMask - GC_TODO: add argument description
+ Callback - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _HII_PACK_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
new file mode 100644
index 0000000000..e69af5c259
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.c
@@ -0,0 +1,2533 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IfrParse.c
+
+Abstract:
+
+ Routines for parsing and managing HII IFR packs.
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "EfiInternalFormRepresentation.h"
+#include "Hii.h"
+#include "IfrParse.h"
+#include "HiiPack.h"
+
+typedef struct _VARIABLE_STORE_ENTRY {
+ struct _VARIABLE_STORE_ENTRY *Next;
+ CHAR8 VarName[MAX_VARIABLE_NAME];
+ char *VarBuffer;
+ int VarBufferSize;
+ EFI_HII_VARIABLE_PACK *VarPack;
+ int VarPackSize;
+} VARIABLE_STORE_ENTRY;
+
+typedef STATUS (*IFR_PARSE_FUNCTION) (IFR_PARSE_CONTEXT * Context);
+
+typedef struct {
+ INT8 *Name;
+ INT32 Size;
+ IFR_PARSE_FUNCTION Parse;
+} IFR_PARSE_TABLE_ENTRY;
+
+static
+STATUS
+IfrParse01 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse02 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse03 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse05 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse06 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse07 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse08 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse09 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0A (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0B (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0C (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0D (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0E (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse0F (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse10 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse11 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse12 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse13 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse14 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse15 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse16 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse17 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse18 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse19 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1A (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1B (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1C (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1D (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1E (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse1F (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse20 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse21 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse22 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse23 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse24 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse25 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse26 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse27 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse28 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse29 (
+ IFR_PARSE_CONTEXT *Context
+ );
+static
+STATUS
+IfrParse2A (
+ IFR_PARSE_CONTEXT *Context
+ );
+
+static const IFR_PARSE_TABLE_ENTRY mIfrParseTable[] = {
+ {
+ 0,
+ 0,
+ NULL
+ }, // invalid
+ {
+ "EFI_IFR_FORM",
+ sizeof (EFI_IFR_FORM),
+ IfrParse01
+ },
+ {
+ "EFI_IFR_SUBTITLE",
+ sizeof (EFI_IFR_SUBTITLE),
+ IfrParse02
+ },
+ {
+ "EFI_IFR_TEXT",
+ -6,
+ IfrParse03
+ }, // sizeof (EFI_IFR_TEXT) },
+ {
+ "unused 0x04 opcode",
+ 0,
+ NULL
+ }, // EFI_IFR_GRAPHIC_OP
+ {
+ "EFI_IFR_ONE_OF",
+ sizeof (EFI_IFR_ONE_OF),
+ IfrParse05
+ },
+ {
+ "EFI_IFR_CHECK_BOX",
+ sizeof (EFI_IFR_CHECK_BOX),
+ IfrParse06
+ },
+ {
+ "EFI_IFR_NUMERIC",
+ sizeof (EFI_IFR_NUMERIC),
+ IfrParse07
+ },
+ {
+ "EFI_IFR_PASSWORD",
+ sizeof (EFI_IFR_PASSWORD),
+ IfrParse08
+ },
+ {
+ "EFI_IFR_ONE_OF_OPTION",
+ sizeof (EFI_IFR_ONE_OF_OPTION),
+ IfrParse09
+ },
+ {
+ "EFI_IFR_SUPPRESS",
+ sizeof (EFI_IFR_SUPPRESS),
+ IfrParse0A
+ },
+ {
+ "EFI_IFR_END_FORM",
+ sizeof (EFI_IFR_END_FORM),
+ IfrParse0B
+ },
+ {
+ "EFI_IFR_HIDDEN",
+ sizeof (EFI_IFR_HIDDEN),
+ IfrParse0C
+ },
+ {
+ "EFI_IFR_END_FORM_SET",
+ sizeof (EFI_IFR_END_FORM_SET),
+ IfrParse0D
+ },
+ {
+ "EFI_IFR_FORM_SET",
+ sizeof (EFI_IFR_FORM_SET),
+ IfrParse0E
+ },
+ {
+ "EFI_IFR_REF",
+ sizeof (EFI_IFR_REF),
+ IfrParse0F
+ },
+ {
+ "EFI_IFR_END_ONE_OF",
+ sizeof (EFI_IFR_END_ONE_OF),
+ IfrParse10
+ },
+ {
+ "EFI_IFR_INCONSISTENT",
+ sizeof (EFI_IFR_INCONSISTENT),
+ IfrParse11
+ },
+ {
+ "EFI_IFR_EQ_ID_VAL",
+ sizeof (EFI_IFR_EQ_ID_VAL),
+ IfrParse12
+ },
+ {
+ "EFI_IFR_EQ_ID_ID",
+ sizeof (EFI_IFR_EQ_ID_ID),
+ IfrParse13
+ },
+ {
+ "EFI_IFR_EQ_ID_LIST",
+ -(int) (sizeof (EFI_IFR_EQ_ID_LIST)),
+ IfrParse14
+ },
+ {
+ "EFI_IFR_AND",
+ sizeof (EFI_IFR_AND),
+ IfrParse15
+ },
+ {
+ "EFI_IFR_OR",
+ sizeof (EFI_IFR_OR),
+ IfrParse16
+ },
+ {
+ "EFI_IFR_NOT",
+ sizeof (EFI_IFR_NOT),
+ IfrParse17
+ },
+ {
+ "EFI_IFR_END_IF",
+ sizeof (EFI_IFR_END_IF),
+ IfrParse18
+ },
+ {
+ "EFI_IFR_GRAYOUT",
+ sizeof (EFI_IFR_GRAYOUT),
+ IfrParse19
+ },
+ {
+ "EFI_IFR_DATE",
+ sizeof (EFI_IFR_DATE) / 3,
+ IfrParse1A
+ },
+ {
+ "EFI_IFR_TIME",
+ sizeof (EFI_IFR_TIME) / 3,
+ IfrParse1B
+ },
+ {
+ "EFI_IFR_STRING",
+ sizeof (EFI_IFR_STRING),
+ IfrParse1C
+ },
+ {
+ "EFI_IFR_LABEL",
+ sizeof (EFI_IFR_LABEL),
+ IfrParse1D
+ },
+ {
+ "EFI_IFR_SAVE_DEFAULTS",
+ sizeof (EFI_IFR_SAVE_DEFAULTS),
+ IfrParse1E
+ },
+ {
+ "EFI_IFR_RESTORE_DEFAULTS",
+ sizeof (EFI_IFR_RESTORE_DEFAULTS),
+ IfrParse1F
+ },
+ {
+ "EFI_IFR_BANNER",
+ sizeof (EFI_IFR_BANNER),
+ IfrParse20
+ },
+ {
+ "EFI_IFR_INVENTORY",
+ sizeof (EFI_IFR_INVENTORY),
+ IfrParse21
+ },
+ {
+ "EFI_IFR_EQ_VAR_VAL_OP",
+ sizeof (EFI_IFR_EQ_VAR_VAL),
+ IfrParse22
+ },
+ {
+ "EFI_IFR_ORDERED_LIST_OP",
+ sizeof (EFI_IFR_ORDERED_LIST),
+ IfrParse23
+ },
+ {
+ "EFI_IFR_VARSTORE_OP",
+ -(int) (sizeof (EFI_IFR_VARSTORE)),
+ IfrParse24
+ },
+ {
+ "EFI_IFR_VARSTORE_SELECT_OP",
+ sizeof (EFI_IFR_VARSTORE_SELECT),
+ IfrParse25
+ },
+ {
+ "EFI_IFR_VARSTORE_SELECT_PAIR_OP",
+ sizeof (EFI_IFR_VARSTORE_SELECT_PAIR),
+ IfrParse26
+ },
+ {
+ "EFI_IFR_TRUE",
+ sizeof (EFI_IFR_TRUE),
+ IfrParse27
+ },
+ {
+ "EFI_IFR_FALSE",
+ sizeof (EFI_IFR_FALSE),
+ IfrParse28
+ },
+ {
+ "EFI_IFR_GT",
+ sizeof (EFI_IFR_GT),
+ IfrParse29
+ },
+ {
+ "EFI_IFR_GE",
+ sizeof (EFI_IFR_GE),
+ IfrParse2A
+ },
+};
+#define PARSE_TABLE_ENTRIES (sizeof (mIfrParseTable) / sizeof (mIfrParseTable[0]))
+
+static
+STATUS
+GetVarStoreInfo (
+ IFR_PARSE_CONTEXT *Context,
+ UINT16 VarId,
+ EFI_GUID **VarStoreGuid,
+ char **VarStoreName
+ );
+
+static
+void
+FreeVarStores (
+ VOID
+ );
+
+static
+STATUS
+CreateVarStore (
+ EFI_GUID *VarGuid,
+ CHAR8 *VarName,
+ int VarStoreSize
+ );
+
+static
+STATUS
+SetDefaults (
+ IFR_PARSE_CONTEXT *Context,
+ UINT32 MfgDefaults
+ );
+
+//
+// Globals
+//
+static IFR_PARSE_CONTEXT *mParseContext = NULL;
+static VARIABLE_STORE_ENTRY *mVariableStores = NULL;
+static int BreakOnOpcodeTag = 0;
+static int OpcodeTag = 1;
+
+/*****************************************************************************/
+STATUS
+IfrParseCheck (
+ char *Buffer,
+ long BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Check a buffer to ensure that is is parseable IFR
+
+Arguments:
+
+ Buffer - pointer to raw IFR bytes
+ BufferSize - size of IFR pointed to by Buffer
+
+Returns:
+
+ STATUS_SUCCESS if successful
+ STATUS_ERROR otherwise
+
+--*/
+{
+ char *Start;
+
+ char *End;
+
+ char *Pos;
+ EFI_IFR_OP_HEADER *OpHeader;
+ char *FileName;
+ FileName = "";
+ //
+ // Walk the list of IFR statements in the IFR pack
+ //
+ Start = Buffer;
+ Pos = Buffer;
+ End = Start + BufferSize;
+ while ((Pos >= Start) && (Pos < End)) {
+ OpHeader = (EFI_IFR_OP_HEADER *) Pos;
+ //
+ // Check range on size
+ //
+ if (Pos + OpHeader->Length > End) {
+ Error (NULL, 0, 0, FileName, "invalid IFR opcode size at offset 0x%X", (int) Pos - (int) Start);
+ return STATUS_ERROR;
+ }
+
+ if (OpHeader->Length == 0) {
+ Error (NULL, 0, 0, FileName, "IFR opcode size=0 at offset 0x%X", (int) Pos - (int) Start);
+ return STATUS_ERROR;
+ }
+ //
+ // See if it's the END_FORMSET opcode
+ //
+ if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {
+ break;
+ }
+ //
+ // Advance to next IFR statement/opcode
+ //
+ Pos += OpHeader->Length;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+STATUS
+IfrParseInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize this module for IFR pack parsing
+
+Arguments:
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+STATUS
+IfrParseEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up memory allocated during IFR pack parsing done by this module
+
+Arguments:
+ None
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ IFR_PARSE_CONTEXT *NextContext;
+ IFR_PARSE_ENTRY *NextEntry;
+ //
+ // Free up the memory from our parse contexts
+ //
+ while (mParseContext != NULL) {
+ while (mParseContext->Ifr != NULL) {
+ NextEntry = mParseContext->Ifr->Next;
+ //
+ // We pointed directly into the user buffer, rather than make
+ // a copy, so don't free up the bytes.
+ //
+ free (mParseContext->Ifr);
+ mParseContext->Ifr = NextEntry;
+ }
+
+ NextContext = mParseContext->Next;
+ free (mParseContext->PackHeader);
+ free (mParseContext);
+ mParseContext = NextContext;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+FreeVarStores (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *NextVarStore;
+ //
+ // Free up memory from our variable stores
+ //
+ while (mVariableStores != NULL) {
+ if (mVariableStores->VarPack != NULL) {
+ free (mVariableStores->VarPack);
+ }
+
+ NextVarStore = mVariableStores->Next;
+ free (mVariableStores);
+ mVariableStores = NextVarStore;
+ }
+}
+
+/******************************************************************************
+ FUNCTION: IfrParsePack()
+
+ DESCRIPTION: Given a pointer to an IFR pack, parse it to create a linked
+ list of opcodes and relevant data required for later dumping.
+
+
+*******************************************************************************/
+STATUS
+IfrParsePack (
+ int Handle,
+ EFI_HII_IFR_PACK *PackHeader,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Given a pointer to an IFR pack, parse it to create a linked
+ list of opcodes and relevant data required for later dumping.
+
+Arguments:
+
+ Handle - the handle number associated with this IFR pack. It
+ can be used later to retrieve more info on the particular
+ pack
+ PackHeader - pointer to IFR pack to parse
+ PackageGuid - on input, it comes from the HII data table entry for this pack.
+ On output, we'll return the IFR formset GUID.
+
+Returns:
+
+ STATUS_SUCCESS always
+
+--*/
+{
+ EFI_IFR_OP_HEADER *OpHeader;
+ IFR_PARSE_CONTEXT *Context;
+ IFR_PARSE_CONTEXT *TempContext;
+ IFR_PARSE_ENTRY *IfrEntry;
+ //
+ // Initialize our context
+ //
+ Context = (IFR_PARSE_CONTEXT *) malloc (sizeof (IFR_PARSE_CONTEXT));
+ if (Context == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) Context, 0, sizeof (IFR_PARSE_CONTEXT));
+ //
+ // Cache a copy of the input pack so the caller can free their copy
+ //
+ Context->PackHeader = (EFI_HII_IFR_PACK *) malloc (PackHeader->Header.Length);
+ if (Context->PackHeader == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ memcpy (Context->PackHeader, PackHeader, PackHeader->Header.Length);
+ Context->IfrBufferStart = (char *) (Context->PackHeader + 1);
+ Context->CurrentPos = Context->IfrBufferStart;
+ Context->IfrBufferLen = PackHeader->Header.Length - sizeof (EFI_HII_IFR_PACK);
+ Context->Handle = Handle;
+ Context->FormsetGuid = &Context->NullGuid;
+ Context->PackageGuid = *PackageGuid;
+ //
+ // Add it to the end of our list
+ //
+ if (mParseContext == NULL) {
+ mParseContext = Context;
+ } else {
+ TempContext = mParseContext;
+ while (TempContext->Next != NULL) {
+ TempContext = TempContext->Next;
+ }
+
+ TempContext->Next = Context;
+ }
+ //
+ // Walk the opcodes in the pack
+ //
+ while
+ (
+ (Context->CurrentPos >= Context->IfrBufferStart) &&
+ (Context->CurrentPos < Context->IfrBufferStart + Context->IfrBufferLen)
+ ) {
+ OpHeader = (EFI_IFR_OP_HEADER *) Context->CurrentPos;
+ //
+ // Allocate a new IFR entry to put in our linked list, then
+ // point directly to the caller's raw data.
+ //
+ IfrEntry = (IFR_PARSE_ENTRY *) malloc (sizeof (IFR_PARSE_ENTRY));
+ if (IfrEntry == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) IfrEntry, 0, sizeof (IFR_PARSE_ENTRY));
+ IfrEntry->Tag = ++OpcodeTag;
+ if (OpcodeTag == BreakOnOpcodeTag) {
+ EFI_BREAKPOINT ();
+ }
+
+ IfrEntry->RawIfrHeader = (EFI_IFR_OP_HEADER *) (Context->CurrentPos);
+ //
+ // Add this entry to our linked list. If it's not the first, then
+ // forward the variable store settings from the previous entry.
+ //
+ if (Context->LastIfr != NULL) {
+ IfrEntry->VarStoreGuid1 = Context->LastIfr->VarStoreGuid1;
+ IfrEntry->VarStoreName1 = Context->LastIfr->VarStoreName1;
+ IfrEntry->VarStoreGuid2 = Context->LastIfr->VarStoreGuid2;
+ IfrEntry->VarStoreName2 = Context->LastIfr->VarStoreName2;
+ Context->LastIfr->Next = IfrEntry;
+ } else {
+ Context->Ifr = IfrEntry;
+ }
+
+ Context->LastIfr = IfrEntry;
+ //
+ // Switch on the opcode to parse it
+ //
+ if (OpHeader->OpCode < PARSE_TABLE_ENTRIES) {
+ if (mIfrParseTable[OpHeader->OpCode].Parse != NULL) {
+ mIfrParseTable[OpHeader->OpCode].Parse (Context);
+ }
+ } else {
+ Error (
+ NULL,
+ 0,
+ 0,
+ "invalid opcode found in IFR",
+ "offset=0x%X opcode=0x%02X",
+ (int) OpHeader - (int) Context->PackHeader,
+ (int) OpHeader->OpCode
+ );
+ free (IfrEntry);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+ //
+ // If it's the END_FORMSET opcode, then we're done
+ //
+ if (OpHeader->OpCode == EFI_IFR_END_FORM_SET_OP) {
+ break;
+ }
+ //
+ // Advance to next IFR statement/opcode
+ //
+ if (OpHeader->Length == 0) {
+ Error (NULL, 0, 0, "0-length IFR opcode encountered", NULL);
+ free (IfrEntry);
+ free (Context->PackHeader);
+ free (Context);
+ return STATUS_ERROR;
+ }
+
+ Context->CurrentPos += OpHeader->Length;
+ }
+ //
+ // Return the form GUID.
+ //
+ *PackageGuid = *Context->FormsetGuid;
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************
+ FUNCTION: GetVarStoreInfo()
+
+ DESCRIPTION: IFR contains VARSTORE opcodes to specify where variable data
+ for following opcodes is supposed to be stored. One VARSTORE statement
+ allows you to specify the variable store GUID and a key, and another
+ VARSTORE (select) allows you to specify the key of a VARSTORE statement.
+ Given the key from a VARSTORE_SELECT statement, go find the corresponding
+ VARSTORE statement with a matching key and return the varstore GUID and
+ name. If key == 0, then the variable store is FormsetGuid."Setup"
+*******************************************************************************/
+static
+STATUS
+GetVarStoreInfo (
+ IFR_PARSE_CONTEXT *Context,
+ UINT16 VarId,
+ EFI_GUID **VarStoreGuid,
+ char **VarStoreName
+ )
+/*++
+
+Routine Description:
+
+ Get variable store information from an IFR pack for a given variable store ID.
+
+Arguments:
+
+ Context - pointer to IFR parse context
+ VarId - variable store ID referenced by IFR being parsed
+ VarStoreGuid - outgoing GUID of the variable store corresponding to VarId
+ VarStoreName - outgoing variable name of variable store corresponding to VarId
+
+Returns:
+
+ STATUS_SUCCESS - variable store with matching VarId found, and outoing GUID/Name are valid
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ IFR_PARSE_ENTRY *Ptr;
+ EFI_IFR_VARSTORE *VarStore;
+ if (Context == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Walk the entire IFR form and find a variable store opcode that
+ // has a matching variable store ID.
+ //
+ for (Ptr = Context->Ifr; Ptr != NULL; Ptr = Ptr->Next) {
+ if (Ptr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {
+ if (VarId == 0) {
+ *VarStoreGuid = &((EFI_IFR_FORM_SET *) (Ptr->RawIfrHeader))->Guid;
+ *VarStoreName = DEFAULT_VARIABLE_NAME;
+ return STATUS_SUCCESS;
+ }
+ } else if (Ptr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {
+ //
+ // See if it's a variable ID match
+ //
+ VarStore = (EFI_IFR_VARSTORE *) Ptr->RawIfrHeader;
+ if (VarStore->VarId == VarId) {
+ *VarStoreGuid = &VarStore->Guid;
+ *VarStoreName = (char *) (VarStore + 1);
+ return STATUS_SUCCESS;
+ }
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrSetDefaults (
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Go through all the IFR forms we've parsed so far and create and set variable
+ defaults.
+
+Arguments:
+
+ MfgDefaults - non-zero if manufacturing defaults are desired
+
+Returns:
+
+ STATUS_SUCCESS - always
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+ //
+ // First free up any variable stores we've created so far.
+ //
+ FreeVarStores ();
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ //
+ // Call our internal function to handle it
+ //
+ SetDefaults (Context, MfgDefaults);
+ }
+
+ return STATUS_SUCCESS;
+
+}
+
+/******************************************************************************/
+STATUS
+IfrGetIfrPack (
+ int Handle,
+ EFI_HII_IFR_PACK **PackHeader,
+ EFI_GUID *FormsetGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ if (Context->Handle == Handle) {
+ *PackHeader = Context->PackHeader;
+ memcpy (FormsetGuid, Context->FormsetGuid, sizeof (EFI_GUID));
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrReferencesVarPack (
+ int IfrHandle,
+ EFI_HII_VARIABLE_PACK *VarPack
+ )
+/*++
+
+Routine Description:
+
+ Given an HII handle number (which corrresponds to a handle number passed
+ in to IfrParsePack()), see if the IFR references the specified variable
+ pack.
+
+Arguments:
+
+ IfrHandle - handle number for the IFR pack to check (passed to IfrParsePack())
+ VarPack - variable pack to check to see if the IFR references
+
+Returns:
+
+ STATUS_SUCCESS if the IFR on the given handle references the variable pack
+ STATUS_WARNING the IFR does not reference the variable pack
+ STATUS_ERROR invalid IFR handle
+
+--*/
+{
+ IFR_PARSE_CONTEXT *Context;
+ char VarName[MAX_VARIABLE_NAME];
+ IFR_PARSE_ENTRY *ParseEntry;
+
+ for (Context = mParseContext; Context != NULL; Context = Context->Next) {
+ if (Context->Handle == IfrHandle) {
+ //
+ // Create an ASCII version of the variable name, since that's what is
+ // referenced in IFR.
+ //
+ sprintf (VarName, "%S", (CHAR16 *) (VarPack + 1));
+ //
+ // Walk all the opcodes and see if the IFR references this variable pack
+ //
+ for (ParseEntry = Context->Ifr; ParseEntry != NULL; ParseEntry = ParseEntry->Next) {
+ //
+ // Check for Name.Guid match for primary IFR variable store
+ //
+ if ((strcmp (VarName, ParseEntry->VarStoreName1) == 0) &&
+ (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid1, sizeof (EFI_GUID)) == 0)
+ ) {
+ return STATUS_SUCCESS;
+ }
+ //
+ // Check for Name.Guid match for secondary IFR variable store
+ //
+ if ((ParseEntry->VarStoreName2 != NULL) &&
+ (strcmp (VarName, ParseEntry->VarStoreName2) == 0) &&
+ (memcmp (&VarPack->VariableGuid, ParseEntry->VarStoreGuid2, sizeof (EFI_GUID)) == 0)
+ ) {
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_WARNING;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+IfrGetVarPack (
+ int VarIndex,
+ EFI_HII_VARIABLE_PACK **VarPack
+ )
+/*++
+
+Routine Description:
+
+ Get the variable defaults. It is expected that the caller
+ called IfrSetDefaults() previously to walk all the IFR forms we know about
+ and create and initialize default values.
+
+Arguments:
+
+ VarIndex - a 0-based index into all the variable stores we know about
+ VarPack - outgoing pointer to a variable pack
+
+Returns:
+
+ STATUS_ERROR - VarIndex exceeds the number of variable packs we know of
+ STATUS_SUCCESS - otherwise
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+ //
+ // Initialize outgoing parameters
+ //
+ *VarPack = NULL;
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (VarIndex == 0) {
+ *VarPack = Entry->VarPack;
+ return STATUS_SUCCESS;
+ }
+
+ VarIndex--;
+ }
+
+ return STATUS_ERROR;
+}
+
+static
+STATUS
+SetVariableValue (
+ EFI_GUID *VarGuid,
+ char *VarName,
+ int VarOffset,
+ int VarSize,
+ void *VarValue
+ )
+/*++
+
+Routine Description:
+
+ Given a variable GUID.Name, offset, size, and value, set the bytes in
+ the variable to the provided value.
+
+Arguments:
+ VarGuid - GUID of variable to set
+ VarName - name of variable to set
+ VarOffset - byte offset into the variable store
+ VarSize - size of the value in the variable store (in bytes)
+ VarValue - pointer to buffer containing the value to set
+
+Returns:
+
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+ char *Src;
+ char *Dest;
+ //
+ // Go through our list of variable stores to find the match
+ //
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {
+ if (strcmp (VarName, Entry->VarName) == 0) {
+ //
+ // Found match -- check offset. If it's beyond the size of the variable store
+ // buffer, then return a warning. Note that date-time can be beyond the
+ // end of the varstore, which is ok.
+ //
+ if (VarOffset + VarSize <= Entry->VarBufferSize) {
+ //
+ // Stuff the data
+ //
+ Dest = Entry->VarBuffer + VarOffset;
+ Src = (char *) VarValue;
+ while (VarSize > 0) {
+ *Dest = *Src;
+ Src++;
+ Dest++;
+ VarSize--;
+ }
+
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_WARNING;
+ }
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+static
+STATUS
+SetDefaults (
+ IFR_PARSE_CONTEXT *Context,
+ UINT32 MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ Set variable defaults by walking a single IFR form.
+
+Arguments:
+
+ Context - Pointer to the IFR context.
+ MfgDefaults - Number of Mfg defaults
+
+Returns:
+
+ EFI_INVALID_PARAMETER - arguments to function are invalid
+ STATUS_SUCCESS - function executed successfully
+
+--*/
+{
+ int Size;
+ int CachedVarOffset;
+ int CachedVarSize;
+ int OrderedList;
+ IFR_PARSE_ENTRY *SavedParseEntry;
+ EFI_IFR_CHECK_BOX *IfrCheckBox;
+ EFI_IFR_ONE_OF_OPTION *IfrOneOfOption;
+ EFI_IFR_NUMERIC *IfrNumeric;
+ STATUS Status;
+ char ZeroByte;
+
+ //
+ // Walk the opcodes to set default values and stuff them into the variable stores
+ //
+
+ if (Context == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Status = STATUS_SUCCESS;
+ Context->CurrentIfr = Context->Ifr;
+ SavedParseEntry = NULL;
+ OrderedList = 0;
+ CachedVarOffset = 0;
+ CachedVarSize = 0;
+ ZeroByte = 0;
+
+ while (Context->CurrentIfr != NULL) {
+ if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_FORM_SET_OP) {
+ //
+ // Formset opcode -- create a variable pack
+ //
+ Status = CreateVarStore (
+ &((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->Guid,
+ DEFAULT_VARIABLE_NAME,
+ ((EFI_IFR_FORM_SET *) (Context->CurrentIfr->RawIfrHeader))->NvDataSize
+ );
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_VARSTORE_OP) {
+ //
+ // Variable store opcode -- create a variable pack
+ //
+ Status = CreateVarStore (
+ &((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Guid,
+ (char *) Context->CurrentIfr->RawIfrHeader + sizeof (EFI_IFR_VARSTORE),
+ ((EFI_IFR_VARSTORE *) (Context->CurrentIfr->RawIfrHeader))->Size
+ );
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OP) {
+ //
+ // Need this parse context later when we find the default ONE_OF_OPTION.
+ // Clear out the variable store first, so that we're covered if someone
+ // has two one-of opcode that operate on the same data.
+ // So "last one wins" is the behavior.
+ //
+ OrderedList = 0;
+ SavedParseEntry = Context->CurrentIfr;
+ CachedVarOffset = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = ((EFI_IFR_ONE_OF *) Context->CurrentIfr->RawIfrHeader)->Width;
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ORDERED_LIST_OP) {
+ //
+ // Need this parse context later as we parse the ONE_OF_OP's in the ordered list
+ //
+ OrderedList = 1;
+ SavedParseEntry = Context->CurrentIfr;
+ CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->MaxEntries;
+
+ while (CachedVarSize > 0) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ 1, // variable data size
+ (void *) &ZeroByte
+ );
+ //
+ // variable value
+ //
+ CachedVarSize--;
+ CachedVarOffset++;
+ }
+
+ CachedVarOffset = ((EFI_IFR_ORDERED_LIST *) Context->CurrentIfr->RawIfrHeader)->QuestionId;
+ CachedVarSize = 1;
+ //
+ // ((EFI_IFR_ORDERED_LIST *)Context->CurrentIfr->RawIfrHeader)->Width;
+ //
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_ONE_OF_OPTION_OP) {
+ IfrOneOfOption = (EFI_IFR_ONE_OF_OPTION *) Context->CurrentIfr->RawIfrHeader;
+ //
+ // If we're in an ordered list, then copy the value to the data store
+ //
+ if (OrderedList) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ 1, // variable data size
+ (void *) &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ // Advance the offset for the next ordered list item
+ //
+ CachedVarOffset += CachedVarSize;
+ } else {
+ //
+ // ONE-OF list. See if the default flag is set (provided we're not doing mfg defaults)
+ //
+ if (!MfgDefaults) {
+ if (IfrOneOfOption->Flags & EFI_IFR_FLAG_DEFAULT) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ CachedVarSize, // variable data size
+ &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ }
+ } else {
+ if (IfrOneOfOption->Flags & EFI_IFR_FLAG_MANUFACTURING) {
+ Status = SetVariableValue (
+ SavedParseEntry->VarStoreGuid1, // GUID of variable store to write
+ SavedParseEntry->VarStoreName1, // name of variable store to write
+ CachedVarOffset, // offset into variable store
+ CachedVarSize, // variable data size
+ &IfrOneOfOption->Value
+ );
+ //
+ // variable value
+ //
+ }
+ }
+ }
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_CHECKBOX_OP) {
+ //
+ // If we're saving defaults, and the default flag is set, or we're saving
+ // manufacturing defaults and the manufacturing flag is set, then save a 1.
+ // By default the varstore buffer is cleared, so we don't need to save a 0 ever.
+ //
+ IfrCheckBox = (EFI_IFR_CHECK_BOX *) Context->CurrentIfr->RawIfrHeader;
+ if (((MfgDefaults == 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_DEFAULT)) ||
+ ((MfgDefaults != 0) && (IfrCheckBox->Flags & EFI_IFR_FLAG_MANUFACTURING))
+ ) {
+ Size = 1;
+ Status = SetVariableValue (
+ Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write
+ Context->CurrentIfr->VarStoreName1, // name of variable store to write
+ IfrCheckBox->QuestionId, // offset into variable store
+ IfrCheckBox->Width, // variable data size
+ (void *) &Size
+ );
+ //
+ // variable value
+ //
+ }
+ } else if (Context->CurrentIfr->RawIfrHeader->OpCode == EFI_IFR_NUMERIC_OP) {
+ IfrNumeric = (EFI_IFR_NUMERIC *) Context->CurrentIfr->RawIfrHeader;
+ Status = SetVariableValue (
+ Context->CurrentIfr->VarStoreGuid1, // GUID of variable store to write
+ Context->CurrentIfr->VarStoreName1, // name of variable store to write
+ IfrNumeric->QuestionId, // offset into variable store
+ IfrNumeric->Width, // variable data size
+ (void *) &IfrNumeric->Default
+ );
+ //
+ // variable value
+ //
+ }
+
+ Context->CurrentIfr = Context->CurrentIfr->Next;
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+CreateVarStore (
+ EFI_GUID *VarGuid,
+ CHAR8 *VarName,
+ int VarStoreSize
+ )
+/*++
+
+Routine Description:
+
+ Given a variable GUID.Name and the size of the variable store, allocate
+ storage for maintaining the variable value.
+
+Arguments:
+
+ VarGuid - GUID for a variable
+ VarName - Name of the variable
+ VarStoreSize - size of the variable store
+
+Returns:
+
+ STATUS_ERROR - problem with storage allocation
+ STATUS_SUCCESS - function executed successfully
+
+--*/
+{
+ VARIABLE_STORE_ENTRY *Entry;
+
+ VARIABLE_STORE_ENTRY *TempEntry;
+ int PackSize;
+ int VarNameLen;
+ //
+ // If the variable store size is zero, then do nothing. This could be valid
+ // if variable steering is used in the IFR such that FormsetGUID."Setup" variable
+ // store is never used.
+ //
+ // OPEN: What about a form that only has a time/date question? Then if some other
+ // function called SetDefaults(), attempting to set time/date would result in an
+ // error in the SetVarValue() function.
+ //
+ if (VarStoreSize == 0) {
+ return STATUS_SUCCESS;
+ }
+ //
+ // Go through our list of variable stores and see if we've already created one
+ // for this Guid.Name. If so, check the size and return. Otherwise create
+ // one and add it to the list.
+ //
+ for (Entry = mVariableStores; Entry != NULL; Entry = Entry->Next) {
+ if (memcmp (VarGuid, &Entry->VarPack->VariableGuid, sizeof (EFI_GUID)) == 0) {
+ if (strcmp (VarName, Entry->VarName) == 0) {
+ //
+ // Already have one. Check size.
+ //
+ if (Entry->VarBufferSize != VarStoreSize) {
+ Error (NULL, 0, 0, "mismatched variable store size between two formsets", VarName);
+ return STATUS_ERROR;
+ }
+
+ return STATUS_SUCCESS;
+ }
+ }
+ }
+ //
+ // Create a new one.
+ //
+ Entry = (VARIABLE_STORE_ENTRY *) malloc (sizeof (VARIABLE_STORE_ENTRY));
+ if (Entry == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset ((void *) Entry, 0, sizeof (VARIABLE_STORE_ENTRY));
+ //
+ // Compute size of the varpack
+ //
+ VarNameLen = strlen (VarName) + 1;
+ PackSize = sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16) + VarStoreSize;
+ Entry->VarPack = (EFI_HII_VARIABLE_PACK *) malloc (PackSize);
+ if (Entry->VarPack == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Entry);
+ return STATUS_ERROR;
+ }
+
+ Entry->VarPack->Header.Length = PackSize;
+ Entry->VarPack->Header.Type = EFI_HII_VARIABLE;
+ Entry->VarPack->VariableNameLength = VarNameLen * sizeof (CHAR16);
+ Entry->VarName[MAX_VARIABLE_NAME - 1] = 0;
+ strncpy (Entry->VarName, VarName, MAX_VARIABLE_NAME - 1);
+#ifdef USE_VC8
+ swprintf ((CHAR16 *) (Entry->VarPack + 1), (strlen (VarName) + 1) * sizeof (CHAR16), L"%S", VarName);
+#else
+ swprintf ((CHAR16 *) (Entry->VarPack + 1), L"%S", VarName);
+#endif
+ memcpy (&Entry->VarPack->VariableGuid, VarGuid, sizeof (EFI_GUID));
+ //
+ // Point VarBuffer into the allocated buffer (for convenience)
+ //
+ Entry->VarBuffer = (char *) Entry->VarPack + sizeof (EFI_HII_VARIABLE_PACK) + VarNameLen * sizeof (CHAR16);
+ memset ((void *) Entry->VarBuffer, 0, VarStoreSize);
+ Entry->VarBufferSize = VarStoreSize;
+ //
+ // Add this new varstore to our list
+ //
+ if (mVariableStores == NULL) {
+ mVariableStores = Entry;
+ } else {
+ for (TempEntry = mVariableStores; TempEntry->Next != NULL; TempEntry = TempEntry->Next)
+ ;
+ TempEntry->Next = Entry;
+ }
+ return STATUS_SUCCESS;
+}
+
+/******************************************************************************/
+
+/*++
+
+Routine Description:
+
+ The following IfrParseXX() functions are used to parse an IFR opcode numbered
+ XX via a dispatch table.
+
+Arguments:
+
+ Context - IFR parsing context into which pertinent data for the
+ current opcode can be saved. Context->LastIfr->RawIfrHeader points to
+ the raw IFR bytes currently being parsed.
+
+Returns:
+
+ STATUS_SUCCESS - always
+
+--*/
+
+/*******************************************************************************/
+static
+STATUS
+IfrParse01 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse02 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse03 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// Parse the IFR EFI_IFR_ONE_OF opcode.
+//
+static
+STATUS
+IfrParse05 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse06 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse07 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse08 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse09 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0B (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0C (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0D (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0E (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_IFR_FORM_SET *Op;
+ Op = (EFI_IFR_FORM_SET *) Context->LastIfr->RawIfrHeader;
+ Context->LastIfr->VarStoreGuid1 = &Op->Guid;
+ Context->LastIfr->VarStoreName1 = "Setup";
+ Context->FormsetGuid = &Op->Guid;
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse0F (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse10 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse11 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse12 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse13 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse14 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse15 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse16 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse17 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse18 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse19 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1B (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1C (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1D (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1E (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse1F (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse20 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse21 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse22 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+
+static
+STATUS
+IfrParse23 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// EFI_IFR_VARSTORE
+//
+static
+STATUS
+IfrParse24 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ EFI_IFR_VARSTORE *Op;
+ Op = (EFI_IFR_VARSTORE *) Context->LastIfr->RawIfrHeader;
+ return STATUS_SUCCESS;
+}
+//
+// VARSTORE_SELECT
+//
+static
+STATUS
+IfrParse25 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STATUS Status;
+ EFI_IFR_VARSTORE_SELECT *Op;
+ Op = (EFI_IFR_VARSTORE_SELECT *) Context->LastIfr->RawIfrHeader;
+ Status = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);
+ //
+ // VARSTORE_SELECT sets both
+ //
+ Context->LastIfr->VarStoreGuid2 = Context->LastIfr->VarStoreGuid1;
+ Context->LastIfr->VarStoreName2 = Context->LastIfr->VarStoreName1;
+ return Status;
+}
+//
+// VARSTORE_SELECT_PAIR
+//
+static
+STATUS
+IfrParse26 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STATUS Status;
+ EFI_IFR_VARSTORE_SELECT_PAIR *Op;
+
+ Op = (EFI_IFR_VARSTORE_SELECT_PAIR *) Context->LastIfr->RawIfrHeader;
+ Status = GetVarStoreInfo (Context, Op->VarId, &Context->LastIfr->VarStoreGuid1, &Context->LastIfr->VarStoreName1);
+ Status = GetVarStoreInfo (
+ Context,
+ Op->SecondaryVarId,
+ &Context->LastIfr->VarStoreGuid2,
+ &Context->LastIfr->VarStoreName2
+ );
+ return Status;
+}
+//
+// TRUE
+//
+static
+STATUS
+IfrParse27 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+//
+// FALSe
+//
+static
+STATUS
+IfrParse28 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+static
+STATUS
+IfrParse29 (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
+static
+STATUS
+IfrParse2A (
+ IFR_PARSE_CONTEXT *Context
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Context - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ return STATUS_SUCCESS;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
new file mode 100644
index 0000000000..6a2a597b33
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/IfrParse.h
@@ -0,0 +1,267 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IfrParse.h
+
+Abstract:
+
+ Prototypes and defines for the IFR parsing services.
+
+--*/
+
+#ifndef _IFR_PARSE_H_
+#define _IFR_PARSE_H_
+
+#define DEFAULT_HII_PACK_FILENAME_EXTENSION ".hpk"
+//
+// When we parse IFR, we'll keep the IFR in a linked list of
+// these.
+//
+typedef struct _IFR_PARSE_ENTRY {
+ struct _IFR_PARSE_ENTRY *Next;
+ int Tag; // for debugging
+ EFI_IFR_OP_HEADER *RawIfrHeader;
+ //
+ // GUIDs for variable storage
+ //
+ EFI_GUID *VarStoreGuid1;
+ char *VarStoreName1;
+ EFI_GUID *VarStoreGuid2;
+ char *VarStoreName2;
+} IFR_PARSE_ENTRY;
+
+typedef struct _IFR_PARSE_CONTEXT {
+ struct _IFR_PARSE_CONTEXT *Next;
+ EFI_HII_IFR_PACK *PackHeader;
+ char *IfrBufferStart;
+ char *CurrentPos;
+ long IfrBufferLen;
+ int Handle;
+ IFR_PARSE_ENTRY *Ifr;
+ IFR_PARSE_ENTRY *LastIfr;
+ IFR_PARSE_ENTRY *CurrentIfr;
+ FILE *OutFptr;
+ CHAR16 *Language;
+ EFI_GUID *FormsetGuid;
+ EFI_GUID NullGuid; // for use until we set the Guid field correctly
+ EFI_GUID PackageGuid; // from the PackageGuid in the HII data table
+} IFR_PARSE_CONTEXT;
+
+STATUS
+IfrGetVarPack (
+ int VarIndex,
+ EFI_HII_VARIABLE_PACK **VarPack
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ VarIndex - GC_TODO: add argument description
+ VarPack - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParsePack (
+ int Handle,
+ EFI_HII_IFR_PACK *PackHeader,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseCheck (
+ char *Buffer,
+ long BufferSize
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Buffer - GC_TODO: add argument description
+ BufferSize - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrParseDump (
+ int Handle,
+ CHAR16 *Language,
+ FILE *OutFptr
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ Language - GC_TODO: add argument description
+ OutFptr - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrSetDefaults (
+ int MfgDefaults
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ MfgDefaults - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrGetIfrPack (
+ int Handle,
+ EFI_HII_IFR_PACK **PackHeader,
+ EFI_GUID *FormsetGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ PackHeader - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+IfrReferencesVarPack (
+ int IfrHandle,
+ EFI_HII_VARIABLE_PACK *VarPack
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ IfrHandle - GC_TODO: add argument description
+ VarPack - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _IFR_PARSE_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
new file mode 100644
index 0000000000..83f6ba7ff8
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/Makefile
@@ -0,0 +1,103 @@
+#/*++
+#
+# Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# Makefile
+#
+# Abstract:
+#
+# This file is used to build the HiiPack utility
+#
+#--*/
+
+#
+# Make sure environmental variable EDK_SOURCE is set
+#
+!IFNDEF EDK_SOURCE
+!ERROR EDK_SOURCE environmental variable not set
+!ENDIF
+
+#
+# Do this if you want to compile from this directory
+#
+!IFNDEF TOOLCHAIN
+TOOLCHAIN = TOOLCHAIN_MSVC
+!ENDIF
+
+!INCLUDE $(BUILD_DIR)\PlatformTools.env
+
+#
+# Target specific information
+#
+
+TARGET_NAME = HiiPack
+TARGET_SRC_DIR = $(EDK_TOOLS_SOURCE)\$(TARGET_NAME)
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\HiiPack.exe
+
+#
+# Build targets
+#
+
+all: $(TARGET_EXE)
+
+INC = $(INC) -I "$(EDK_SOURCE)\Foundation\Framework\Protocol\Hii"
+
+INC_DEPS = "$(TARGET_SRC_DIR)\HiiPack.h" "$(TARGET_SRC_DIR)\IfrParse.h" "$(TARGET_SRC_DIR)\StringParse.h"
+
+LIBS = "$(EDK_TOOLS_OUTPUT)\Common.lib"
+
+OBJECTS = $(EDK_TOOLS_OUTPUT)\FindFiles.obj \
+ $(EDK_TOOLS_OUTPUT)\HiiPack.obj \
+ $(EDK_TOOLS_OUTPUT)\IfrParse.obj \
+ $(EDK_TOOLS_OUTPUT)\StringParse.obj
+
+#
+# Build EXE
+#
+
+$(EDK_TOOLS_OUTPUT)\FindFiles.obj : $(TARGET_SRC_DIR)\FindFiles.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\FindFiles.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SRC_DIR)\HiiPack.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\HiiPack.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\IfrParse.obj : $(TARGET_SRC_DIR)\IfrParse.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\IfrParse.c /Fo$@
+
+$(EDK_TOOLS_OUTPUT)\StringParse.obj : $(TARGET_SRC_DIR)\StringParse.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(INC) $(TARGET_SRC_DIR)\StringParse.c /Fo$@
+
+#
+# Add Binary Build description for this tool.
+#
+
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
+ if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
+!ELSE
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+!IF ("$(EFI_BINARY_BUILD)" == "YES")
+ if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
+ if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
+ if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
+ copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
+!ENDIF
+!ENDIF
+
+clean:
+ @if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\FindFiles.* del $(EDK_TOOLS_OUTPUT)\FindFiles.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\IfrParse* del $(EDK_TOOLS_OUTPUT)\IfrParse.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\StringParse.* del $(EDK_TOOLS_OUTPUT)\StringParse.* > NUL
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
new file mode 100644
index 0000000000..8dd26e1529
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.c
@@ -0,0 +1,244 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StringParse.c
+
+Abstract:
+
+ Routines for parsing HII string packs
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "Tiano.h"
+#include "EfiUtilityMsgs.h"
+#include "EfiInternalFormRepresentation.h"
+#include "Hii.h"
+#include "StringParse.h"
+#include "HiiPack.h"
+
+typedef struct _STRING_PACK_RECORD {
+ struct _STRING_PACK_RECORD *Next;
+ int Handle;
+ EFI_GUID PackageGuid;
+ EFI_GUID FormsetGuid;
+ EFI_HII_STRING_PACK *StringPack;
+ int StringPackSize;
+ int NumStringPacks;
+} STRING_PACK_RECORD;
+
+static STRING_PACK_RECORD *mStringPacks = NULL;
+
+STATUS
+StringGetPack (
+ int Handle, // matches handle passed in with StringParsePack()
+ EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
+ int *StringPackSize, // sizeof buffer pointed to by StringPack
+ int *NumStringPacks, // in the array pointed to by StringPack
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Get a string pack given to us previously
+
+Arguments:
+ Handle - handle of string pack to get
+ StringPack - outgoing pointer to string pack on the given handle
+ StringPackSize - outgoing size of string pack pointed to by StringPack
+ NumStringPacks - outgoing number of string packs in StringPack[] array
+ FormsetGuid - outgoing GUID passed in with the string pack when it was parsed
+ PackageGuid - outgoing GUID passed in with the string pack when it was parsed
+
+Returns:
+
+ STATUS_SUCCESS - string pack with matching handle was found
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STRING_PACK_RECORD *Rec;
+
+ for (Rec = mStringPacks; Rec != NULL; Rec = Rec->Next) {
+ if (Rec->Handle == Handle) {
+ *StringPack = Rec->StringPack;
+ *StringPackSize = Rec->StringPackSize;
+ *NumStringPacks = Rec->NumStringPacks;
+ return STATUS_SUCCESS;
+ }
+ }
+
+ return STATUS_ERROR;
+}
+
+STATUS
+StringParsePack (
+ int Handle,
+ EFI_HII_STRING_PACK *StringPack,
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ Parse a string pack, saving the information for later retrieval by the caller
+
+Arguments:
+ Handle - handle of string pack
+ StringPack - pointer to string pack array to parse
+ FormsetGuid - GUID of the string pack
+ PackageGuid - package GUID from the HII data table from which this string pack orginated
+
+Returns:
+
+ STATUS_SUCCESS - Stringpack processed successfully
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STRING_PACK_RECORD *Rec;
+
+ STRING_PACK_RECORD *TempRec;
+ int PackSize;
+ EFI_HII_STRING_PACK *TempPack;
+ //
+ // Allocate a new string pack record
+ //
+ Rec = (STRING_PACK_RECORD *) malloc (sizeof (STRING_PACK_RECORD));
+ if (Rec == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ return STATUS_ERROR;
+ }
+
+ memset (Rec, 0, sizeof (STRING_PACK_RECORD));
+ Rec->Handle = Handle;
+ if (PackageGuid != NULL) {
+ memcpy (&Rec->PackageGuid, PackageGuid, sizeof (EFI_GUID));
+ }
+
+ if (FormsetGuid != NULL) {
+ memcpy (&Rec->FormsetGuid, FormsetGuid, sizeof (EFI_GUID));
+ }
+ //
+ // Walk the string packs to find the terminator
+ //
+ TempPack = StringPack;
+ PackSize = 0;
+ while (TempPack->Header.Length > 0) {
+ if (TempPack->Header.Type != EFI_HII_STRING) {
+ Error (NULL, 0, 0, "found a non-string pack in the string pack array", NULL);
+ free (Rec);
+ return STATUS_ERROR;
+ }
+
+ PackSize += TempPack->Header.Length;
+ Rec->NumStringPacks++;
+ TempPack = (EFI_HII_STRING_PACK *) ((char *) TempPack + TempPack->Header.Length);
+ }
+ //
+ // Add space for the terminator
+ //
+ PackSize += sizeof (EFI_HII_STRING_PACK);
+ Rec->StringPackSize = PackSize;
+ //
+ // Make a copy of the incoming string pack
+ //
+ Rec->StringPack = (EFI_HII_STRING_PACK *) malloc (PackSize);
+ if (Rec->StringPack == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ free (Rec);
+ return STATUS_ERROR;
+ }
+
+ memcpy ((void *) Rec->StringPack, StringPack, PackSize);
+ //
+ // Add this record to our list
+ //
+ if (mStringPacks == NULL) {
+ mStringPacks = Rec;
+ } else {
+ for (TempRec = mStringPacks; TempRec->Next != NULL; TempRec = TempRec->Next)
+ ;
+ TempRec->Next = Rec;
+ }
+ free (Rec->StringPack);
+ free (Rec);
+ return STATUS_SUCCESS;
+}
+
+STATUS
+StringInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ StringEnd ();
+ return STATUS_SUCCESS;
+}
+
+STATUS
+StringEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ STRING_PACK_RECORD *Next;
+ //
+ // Free up all the memory we've allocated
+ //
+ while (mStringPacks != NULL) {
+ if (mStringPacks->StringPack != NULL) {
+ free (mStringPacks->StringPack);
+ }
+
+ Next = mStringPacks->Next;
+ free (mStringPacks);
+ mStringPacks = Next;
+ }
+
+ return STATUS_SUCCESS;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
new file mode 100644
index 0000000000..a5df7d0ccb
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/HiiPack/StringParse.h
@@ -0,0 +1,125 @@
+/*++
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StringParse.h
+
+Abstract:
+
+ Prototypes and defines for the string pack parsing services.
+
+--*/
+
+#ifndef _STRING_PARSE_H_
+#define _STRING_PARSE_H_
+
+STATUS
+StringGetPack (
+ int Handle, // matches handle passed in with StringParsePack()
+ EFI_HII_STRING_PACK **StringPack, // returned pointer to string pack
+ int *StringPackSize, // sizeof buffer pointed to by StringPack
+ int *NumStringPacks, // in the array pointed to by StringPack
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ StringPack - GC_TODO: add argument description
+ StringPackSize - GC_TODO: add argument description
+ NumStringPacks - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringParsePack (
+ int Handle,
+ EFI_HII_STRING_PACK *StringPack,
+ EFI_GUID *FormsetGuid,
+ EFI_GUID *PackageGuid
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ Handle - GC_TODO: add argument description
+ StringPack - GC_TODO: add argument description
+ FormsetGuid - GC_TODO: add argument description
+ PackageGuid - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+STATUS
+StringEnd (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif // #ifndef _STRING_PARSE_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
index 3b780de4ab..13fdd22aa5 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/MakeDeps/MakeDeps.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -37,6 +37,7 @@ typedef struct _STRING_LIST {
} STRING_LIST;
#define UTILITY_NAME "MakeDeps"
+#define UTILITY_VERSION "v1.0"
#define MAX_LINE_LEN 2048
#define MAX_PATH 2048
@@ -1488,30 +1489,36 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
- UTILITY_NAME " -- make dependencies",
- " Usage: MakeDeps [options]",
- " Options include:",
- " -h or -? for this help information",
- " -f SourceFile add SourceFile to list of files to scan",
- " -i IncludePath add IncludePath to list of search paths",
- " -o OutputFile write output dependencies to OutputFile",
- " -s SubDir for each IncludePath, also search IncludePath\\SubDir",
- " -v for verbose output",
- " -ignorenotfound don't warn for files not found",
- " -target Target for single SourceFile, target is Target, not SourceFile.obj",
- " -q quiet mode to not report files not found if ignored",
- " -sub sym str replace all occurrances of 'str' with 'sym' in the output",
- " -nosystem not process system <include> files",
- " -neverfail always return a success return code",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Make Dependencies Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]...",
+ "Options:",
+ " -h or -? for this help information",
+ " -f SourceFile add SourceFile to list of files to scan",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -o OutputFile write output dependencies to OutputFile",
+ " -s SubDir for each IncludePath, also search IncludePath\\SubDir",
+ " -v for verbose output",
+ " -ignorenotfound don't warn for files not found",
+ " -target Target for single SourceFile, target is Target, not SourceFile.obj",
+ " -q quiet mode to not report files not found if ignored",
+ " -sub sym str replace all occurrances of 'str' with 'sym' in the output",
+ " -nosystem not process system <include> files",
+ " -neverfail always return a success return code",
//
- // " -nodupes keep track of include files, don't rescan duplicates",
+ // " -nodupes keep track of include files, don't rescan duplicates",
//
- " -usesumdeps path use summary dependency files in 'path' directory.",
- " -asm The SourceFiles are assembler files",
- " -cl The SourceFiles are the output of cl with /showIncludes",
- "",
+ " -usesumdeps path use summary dependency files in 'path' directory.",
+ " -asm The SourceFiles are assembler files",
+ " -cl The SourceFiles are the output of cl with /showIncludes",
NULL
};
for (Index = 0; Str[Index] != NULL; Index++) {
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
index 772417e1f7..c8e85e51f6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -44,9 +44,11 @@ MAKEFILES = $(EDK_TOOLS_SOURCE)\Common\Makefile \
!IF "$(EFI_SPECIFICATION_VERSION)" >= "0x0002000A"
$(EDK_TOOLS_SOURCE)\UefiVfrCompile\makefile \
$(EDK_TOOLS_SOURCE)\UefiStrGather\makefile \
+ $(EDK_TOOLS_SOURCE)\UefiHiiPack\Makefile \
!ELSE
$(EDK_TOOLS_SOURCE)\VfrCompile\makefile \
$(EDK_TOOLS_SOURCE)\StrGather\makefile \
+ $(EDK_TOOLS_SOURCE)\HiiPack\Makefile \
!ENDIF
$(EDK_TOOLS_SOURCE)\SplitFile\Makefile \
$(EDK_TOOLS_SOURCE)\Strip\Makefile \
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
index 3d7a97ca7d..2f6ac471e6 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ModifyInf/ModifyInf.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 1999 - 2002, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2010, 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,6 +23,8 @@ Abstract:
#include "stdio.h"
#include "string.h"
+#define UTILITY_NAME "ModifyInf"
+#define UTILITY_VERSION "v1.0"
//
// Read a line into buffer including '\r\n'
//
@@ -263,7 +265,22 @@ Returns:
--*/
{
- printf ("ModifyInf InputFVInfFileName OutputFVInfFileName [Pattern strings]\r\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Modify INF File Utility",
+ " Copyright (C), 1999 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" SOURCE DEST [PATTERN]",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
index 3e60b0344b..5181373a54 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/FWVolume.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -35,18 +35,7 @@ Abstract:
#define EFI_BASE_ADDRESS "EFI_BASE_ADDRESS"
#define DEFAULT_FV_INF_DIR "FV" // default dir for where we create the FV INF file
#define DEFAULT_FV_DIR "$(BUILD_DIR)" // where the FV file comes from
-#define MALLOC(size) malloc (size)
-#define FREE(ptr) free (ptr)
-//
-// Disable warning for unused function arguments
-//
-#pragma warning(disable : 4100)
-//
-// Disable warning for while(1) code
-//
-// #pragma warning (disable : 4127)
-//
typedef struct {
char *ComponentType;
char *Extension;
@@ -196,8 +185,7 @@ static
void
AddFirmwareVolumes (
char *FVs,
- int ComponentsInstance,
- FILE_LIST *FileListPtr
+ int ComponentsInstance
);
static
@@ -503,7 +491,7 @@ Returns:
// Add these firmware volumes to the list of known firmware
// volume names.
//
- AddFirmwareVolumes (FVs, ComponentsInstance, Ptr);
+ AddFirmwareVolumes (FVs, ComponentsInstance);
return STATUS_SUCCESS;
}
@@ -528,7 +516,7 @@ CFVDestructor (
//
while (mFVList != NULL) {
mFVListLast = mFVList->Next;
- FREE (mFVList);
+ free (mFVList);
mFVList = mFVListLast;
}
}
@@ -957,10 +945,10 @@ Returns:
//
// Now go through the list of all NonFFS FVs they specified and search for
// a [build.fv.$(FV)] or [build.fv] command and emit the commands to the
- // output makefile. Add them to the "fvs" target as well.
+ // output makefile. Add them to the "fvs_0" target as well.
//
if (mNonFfsFVList != NULL) {
- fprintf (MakeFptr, "fvs ::");
+ fprintf (MakeFptr, "fvs_0 ::");
FVPtr = mNonFfsFVList;
while (FVPtr != NULL) {
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
@@ -1022,43 +1010,40 @@ Returns:
DSCFileRestorePosition (DSC);
}
}
+
//
- // Go through our list of firmware volumes and create an "fvs" target that
- // builds everything. It has to be a mix of components and FV's in order.
- // For example: fvs : components_0 fv\fv001.fv fv\fv002.fv components_1 fv\fv003.fv
+ // Get the components count
//
- ComponentsInstance = 0;
- ComponentCount = 0;
- fprintf (MakeFptr, "fvs ::");
- for (;;) {
- //
- // First see if we have any components for this section. If we don't,
- // then we're done
- //
- for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
- if (FileListPtr->ComponentsInstance == ComponentsInstance) {
- break;
- }
- }
-
- if (FileListPtr == NULL) {
- break;
+ ComponentCount = -1;
+ for (FileListPtr = mFileList; FileListPtr != NULL; FileListPtr = FileListPtr->Next) {
+ if (FileListPtr->ComponentsInstance > ComponentCount) {
+ ComponentCount = FileListPtr->ComponentsInstance;
}
+ }
+ ComponentCount++;
- fprintf (MakeFptr, " components_%d", ComponentsInstance);
- ComponentCount++;
- //
- // Now print any firmware volumes that match this components instance
- //
+ //
+ // Now print firmware volumes build targets fvs_0, fvs_1 etc.
+ //
+ for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
+ fprintf (MakeFptr, "fvs_%d ::", ComponentsInstance);
for (FVPtr = mFVList; FVPtr != NULL; FVPtr = FVPtr->Next) {
if (FVPtr->ComponentsInstance == ComponentsInstance) {
fprintf (MakeFptr, " %s%s.fv", FVDir, FVPtr->FVFileName);
}
}
-
- ComponentsInstance++;
+ fprintf (MakeFptr, "\n\n");
+ }
+
+ //
+ // Create an "fvs" target that builds everything. It has to be a mix of
+ // components and FV's in order. For example:
+ // fvs :: components_0 fvs_0 components_1 fvs_1
+ //
+ fprintf (MakeFptr, "fvs ::");
+ for (ComponentsInstance = 0; ComponentsInstance < ComponentCount; ComponentsInstance++) {
+ fprintf (MakeFptr, " components_%d fvs_%d", ComponentsInstance, ComponentsInstance);
}
-
fprintf (MakeFptr, "\n\n");
//
@@ -1351,8 +1336,7 @@ static
void
AddFirmwareVolumes (
char *FVs,
- int ComponentsInstance,
- FILE_LIST *FileListPtr
+ int ComponentsInstance
)
{
FV_LIST *FvPtr;
@@ -1386,7 +1370,7 @@ AddFirmwareVolumes (
// If we didn't find a match, then create a new one
//
if (FvPtr == NULL) {
- FvPtr = MALLOC (sizeof (FV_LIST));
+ FvPtr = malloc (sizeof (FV_LIST));
if (FvPtr == NULL) {
Error (__FILE__, __LINE__, 0, "application error", "memory allocation failed");
return ;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
index 417951cf59..e2a4b5f06b 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/Makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -49,25 +49,31 @@ TARGET_EXE = $(EDK_TOOLS_OUTPUT)\ProcessDsc.exe
all: $(TARGET_EXE)
-INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
-INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\DSCFile.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\MultiThread.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\FWVolume.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\Exceptions.h $(INC_DEPS)
+INC_DEPS = $(TARGET_SRC_DIR)\Common.h $(INC_DEPS)
LIBS = $(LIBS) "$(EDK_TOOLS_OUTPUT)\Common.lib"
-OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
- $(EDK_TOOLS_OUTPUT)\FWVolume.obj \
- $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
+OBJECTS = $(EDK_TOOLS_OUTPUT)\DSCFile.obj \
+ $(EDK_TOOLS_OUTPUT)\MultiThread.obj \
+ $(EDK_TOOLS_OUTPUT)\FWVolume.obj \
+ $(EDK_TOOLS_OUTPUT)\ProcessDsc.obj \
$(EDK_TOOLS_OUTPUT)\Exceptions.obj
#
# Compile each source file
#
+C_FLAGS = $(C_FLAGS) /MT /wd4201
$(EDK_TOOLS_OUTPUT)\DSCFile.obj : $(TARGET_SRC_DIR)\DSCFile.c $(INC_DEPS)
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\DSCFile.c /Fo$@
+$(EDK_TOOLS_OUTPUT)\MultiThread.obj : $(TARGET_SRC_DIR)\MultiThread.c $(INC_DEPS)
+ $(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\MultiThread.c /Fo$@
+
$(EDK_TOOLS_OUTPUT)\FWVolume.obj : $(TARGET_SRC_DIR)\FWVolume.c $(INC_DEPS)
$(CC) $(C_FLAGS) $(TARGET_SRC_DIR)\FWVolume.c /Fo$@
@@ -88,7 +94,9 @@ $(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
!ELSE
$(TARGET_EXE) : $(OBJECTS) $(LIBS)
- $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS) shlwapi.lib \
+ /NODEFAULTLIB:libc.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:libcd.lib \
+ /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib
!IF ("$(EFI_BINARY_BUILD)" == "YES")
if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
@@ -100,5 +108,6 @@ $(TARGET_EXE) : $(OBJECTS) $(LIBS)
clean:
@if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* del $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\DscFile.* del $(EDK_TOOLS_OUTPUT)\DscFile.* > NUL
+ @if exist $(EDK_TOOLS_OUTPUT)\MultiThread.* del $(EDK_TOOLS_OUTPUT)\MultiThread.* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\Exceptions* del $(EDK_TOOLS_OUTPUT)\Exceptions.* > NUL
@if exist $(EDK_TOOLS_OUTPUT)\FwVolume.* del $(EDK_TOOLS_OUTPUT)\FwVolume.* > NUL
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
new file mode 100644
index 0000000000..b6a72eca78
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.c
@@ -0,0 +1,905 @@
+/*++
+
+Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MultiThread.c
+
+Abstract:
+
+ This module is used to add multi-thread build support to ProcessDsc utility
+ to improve the build performance.
+
+--*/
+
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <direct.h>
+#include "Common.h"
+#include "MultiThread.h"
+
+BUILD_ITEM *
+AddBuildItem (
+ BUILD_ITEM **BuildList,
+ INT8 *BaseName,
+ INT8 *Processor,
+ INT8 *Makefile
+ )
+/*++
+
+Routine Description:
+
+ Add a build item to a specified build list
+
+Arguments:
+
+ BuildList - build list where the new build item will be added
+ BaseName - base name of the new module
+ Processor - processor type of the new module
+ Makefile - makefile name of the new module
+
+Returns:
+
+ Pointer to the newly added build item
+
+--*/
+{
+ BUILD_ITEM *NewBuildItem;
+
+ //
+ // Create a new build item
+ //
+ NewBuildItem = malloc (sizeof (BUILD_ITEM));
+ if (NewBuildItem == NULL) {
+ return NULL;
+ }
+ memset (NewBuildItem, 0, sizeof (BUILD_ITEM));
+ NewBuildItem->BaseName = _strdup (BaseName);
+ NewBuildItem->Processor = _strdup (Processor);
+ NewBuildItem->Makefile = _strdup (Makefile);
+
+ //
+ // Add the build item to the head of the build list
+ //
+ NewBuildItem->Next = *BuildList;
+ *BuildList = NewBuildItem;
+
+ return NewBuildItem;
+}
+
+SOURCE_FILE_ITEM *
+AddSourceFile (
+ BUILD_ITEM *BuildItem,
+ INT8 *FileName
+ )
+/*++
+
+Routine Description:
+
+ Add a source file for a build item
+
+Arguments:
+
+ BuildItem - build item to add the source file
+ FileName - source file name to be added
+
+Returns:
+
+ Pointer to the newly added source file item
+
+--*/
+{
+ SOURCE_FILE_ITEM *NewSourceFile;
+
+ //
+ // Create a new source file item
+ //
+ NewSourceFile = malloc (sizeof (SOURCE_FILE_ITEM));
+ if (NewSourceFile == NULL) {
+ return NULL;
+ }
+ memset (NewSourceFile, 0, sizeof (SOURCE_FILE_ITEM));
+ NewSourceFile->FileName = _strdup (FileName);
+
+ //
+ // Add the source file item to the head of the source file list
+ //
+ NewSourceFile->Next = BuildItem->SourceFileList;
+ BuildItem->SourceFileList = NewSourceFile;
+
+ return NewSourceFile;
+}
+
+DEPENDENCY_ITEM *
+AddDependency (
+ BUILD_ITEM *BuildList,
+ BUILD_ITEM *BuildItem,
+ INT8 *BaseName,
+ INT8 AdjustIndex
+ )
+/*++
+
+Routine Description:
+
+ Add a build dependency for a build item in the specified build list
+
+Arguments:
+
+ BuildList - build list where to search the dependency
+ BuildItem - build item to add the dependency
+ BaseName - dependency module base name
+ AdjustIndex - Adjust BuildItem->Index when non-zero
+
+Returns:
+
+ Pointer to the newly added build dependency
+
+--*/
+{
+ BUILD_ITEM *TempBuildItem;
+ DEPENDENCY_ITEM *NewDependency;
+
+ //
+ // Search the dependency in the build list
+ //
+ TempBuildItem = BuildList;
+ while (TempBuildItem != NULL) {
+ if ((_stricmp (TempBuildItem->BaseName, BaseName) == 0) &&
+ (_stricmp (TempBuildItem->Processor, BuildItem->Processor) == 0) &&
+ (TempBuildItem != BuildItem)) {
+ break;
+ }
+ TempBuildItem = TempBuildItem->Next;
+ }
+ if (TempBuildItem == NULL) {
+ return NULL;
+ }
+
+ //
+ // This index is used to isolate two modules with same base name and processor.
+ // (ProcessDsc allows duplicate base name libraries.)
+ //
+ if (AdjustIndex) {
+ BuildItem->Index = TempBuildItem->Index + 1;
+ }
+
+ //
+ // Create a new build dependency item
+ //
+ NewDependency = malloc (sizeof (DEPENDENCY_ITEM));
+ if (NewDependency == NULL) {
+ return NULL;
+ }
+ memset (NewDependency, 0, sizeof (DEPENDENCY_ITEM));
+ NewDependency->Dependency = TempBuildItem;
+
+ //
+ // Add the build dependency item to the head of the dependency list
+ //
+ NewDependency->Next = BuildItem->DependencyList;
+ BuildItem->DependencyList = NewDependency;
+
+ return NewDependency;
+}
+
+void
+FreeBuildList (
+ BUILD_ITEM *BuildList
+ )
+/*++
+
+Routine Description:
+
+ Free a build list
+
+Arguments:
+
+ BuildList - build list to be freed
+
+Returns:
+
+--*/
+{
+ BUILD_ITEM *TempBuildItem;
+ BUILD_ITEM *FreeBuildItem;
+ SOURCE_FILE_ITEM *TempSourceFile;
+ SOURCE_FILE_ITEM *FreeSourceFile;
+ DEPENDENCY_ITEM *TempDependency;
+ DEPENDENCY_ITEM *FreeDependency;
+
+ TempBuildItem = BuildList;
+ while (TempBuildItem != NULL) {
+ free (TempBuildItem->BaseName);
+ free (TempBuildItem->Processor);
+ free (TempBuildItem->Makefile);
+
+ //
+ // Free source file list
+ //
+ TempSourceFile = TempBuildItem->SourceFileList;
+ while (TempSourceFile != NULL) {
+ FreeSourceFile = TempSourceFile;
+ TempSourceFile = TempSourceFile->Next;
+ free (FreeSourceFile);
+ }
+
+ //
+ // Free dependency list
+ //
+ TempDependency = TempBuildItem->DependencyList;
+ while (TempDependency != NULL) {
+ FreeDependency = TempDependency;
+ TempDependency = TempDependency->Next;
+ free (FreeDependency);
+ }
+
+ FreeBuildItem = TempBuildItem;
+ TempBuildItem = TempBuildItem->Next;
+ free (FreeBuildItem);
+ }
+}
+
+COMPONENTS_ITEM *
+AddComponentsItem (
+ COMPONENTS_ITEM **ComponentsList
+ )
+/*++
+
+Routine Description:
+
+ Add a new components item to a specified components list
+
+Arguments:
+
+ ComponentsList - components list where the new components item will be added
+
+Returns:
+
+ Pointer to the newly added components item
+
+--*/
+{
+ COMPONENTS_ITEM *NewComponents;
+ COMPONENTS_ITEM *TempComponents;
+
+ //
+ // Create a new components item
+ //
+ NewComponents = malloc (sizeof (COMPONENTS_ITEM));
+ if (NewComponents == NULL) {
+ return NULL;
+ }
+ memset (NewComponents, 0, sizeof (COMPONENTS_ITEM));
+
+ //
+ // Add the components item to the tail of the components list
+ //
+ TempComponents = *ComponentsList;
+ if (TempComponents == NULL) {
+ *ComponentsList = NewComponents;
+ } else {
+ while (TempComponents->Next != NULL) {
+ TempComponents = TempComponents->Next;
+ }
+ TempComponents->Next = NewComponents;
+ }
+
+ return NewComponents;
+}
+
+void
+FreeComponentsList (
+ COMPONENTS_ITEM *ComponentsList
+ )
+/*++
+
+Routine Description:
+
+ Free a components list
+
+Arguments:
+
+ ComponentsList - components list to be freed
+
+Returns:
+
+--*/
+{
+ COMPONENTS_ITEM *TempComponents;
+ COMPONENTS_ITEM *FreeComponents;
+
+ TempComponents = ComponentsList;
+ while (TempComponents != NULL) {
+ FreeBuildList (TempComponents->BuildList);
+ FreeComponents = TempComponents;
+ TempComponents = TempComponents->Next;
+ free (FreeComponents);
+ }
+}
+
+//
+// Module globals for multi-thread build
+//
+static INT8 mError; // non-zero means error occurred
+static INT8 mDone; // non-zero means no more build items available for build
+static UINT32 mThreadNumber; // thread number
+static INT8 *mBuildDir; // build directory
+static INT8 mLogDir[MAX_PATH]; // build item log dir
+static CRITICAL_SECTION mCriticalSection; // critical section object
+static HANDLE mSemaphoreHandle; // semaphore for "ready for build" items in mWaitingList
+static HANDLE mEventHandle; // event signaled when one build item is finished
+static BUILD_ITEM *mPendingList; // build list for build items which are not ready for build
+static BUILD_ITEM *mWaitingList; // build list for build items which are ready for build
+static BUILD_ITEM *mBuildingList; // build list for build items which are buiding
+static BUILD_ITEM *mDoneList; // build list for build items which already finish the build
+
+//
+// Restore the BuildList (not care about the sequence of the build items)
+//
+static void
+RestoreBuildList (
+ BUILD_ITEM **BuildList
+ )
+{
+ BUILD_ITEM *TempBuildItem;
+
+ if (mPendingList != NULL) {
+ //
+ // Add the mPendingList to the header of *BuildList
+ //
+ TempBuildItem = mPendingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mPendingList;
+ }
+
+ if (mWaitingList != NULL) {
+ //
+ // Add the mWaitingList to the header of *BuildList
+ //
+ TempBuildItem = mWaitingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mWaitingList;
+ }
+
+ if (mBuildingList != NULL) {
+ //
+ // Add the mBuildingList to the header of *BuildList
+ //
+ TempBuildItem = mBuildingList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mBuildingList;
+ }
+
+ if (mDoneList != NULL) {
+ //
+ // Add the mDoneList to the header of *BuildList
+ //
+ TempBuildItem = mDoneList;
+ while (TempBuildItem->Next != NULL) {
+ TempBuildItem = TempBuildItem->Next;
+ }
+ TempBuildItem->Next = *BuildList;
+ *BuildList = mDoneList;
+ }
+}
+
+//
+// Return non-zero when no source file build conflict
+//
+static INT8
+CheckSourceFile (
+ SOURCE_FILE_ITEM *SourceFileList
+ )
+{
+ BUILD_ITEM *TempBuildItem;
+ SOURCE_FILE_ITEM *TempSourceFile;
+
+ while (SourceFileList != NULL) {
+ TempBuildItem = mBuildingList;
+ while (TempBuildItem != NULL) {
+ TempSourceFile = TempBuildItem->SourceFileList;
+ while (TempSourceFile != NULL) {
+ if (_stricmp (SourceFileList->FileName, TempSourceFile->FileName) == 0) {
+ return 0;
+ }
+ TempSourceFile = TempSourceFile->Next;
+ }
+ TempBuildItem = TempBuildItem->Next;
+ }
+ SourceFileList = SourceFileList->Next;
+ }
+
+ return 1;
+}
+
+//
+// Return non-zero when all the dependency build items has been built
+//
+static INT8
+CheckDependency (
+ DEPENDENCY_ITEM *DependencyList
+ )
+{
+ while (DependencyList != NULL) {
+ if (!(DependencyList->Dependency->CompleteFlag)) {
+ return 0;
+ }
+ DependencyList = DependencyList->Next;
+ }
+
+ return 1;
+}
+
+//
+// Run the build task. The system() function call will cause stdout conflict
+// in multi-thread envroment, so implement this through CreateProcess().
+//
+static INT8
+RunBuildTask (
+ INT8 *WorkingDir,
+ INT8 *LogFile,
+ INT8 *BuildCmd
+ )
+{
+ HANDLE FileHandle;
+ SECURITY_ATTRIBUTES SecAttr;
+ PROCESS_INFORMATION ProcInfo;
+ STARTUPINFO StartInfo;
+ BOOL FuncRetn;
+ DWORD ExitCode;
+
+ //
+ // Init SecAttr
+ //
+ SecAttr.nLength = sizeof (SECURITY_ATTRIBUTES);
+ SecAttr.bInheritHandle = TRUE;
+ SecAttr.lpSecurityDescriptor = NULL;
+
+ //
+ // Create the log file
+ //
+ FileHandle = CreateFile (
+ LogFile, // file to create
+ GENERIC_WRITE, // open for writing
+ 0, // do not share
+ &SecAttr, // can be inherited by child processes
+ CREATE_ALWAYS, // overwrite existing
+ FILE_ATTRIBUTE_NORMAL, // normal file
+ NULL // no attr. template
+ );
+
+ if (FileHandle == INVALID_HANDLE_VALUE) {
+ EnterCriticalSection (&mCriticalSection);
+ Error (NULL, 0, 0, NULL, "could not open file %s", LogFile);
+ LeaveCriticalSection (&mCriticalSection);
+ return 1;
+ }
+
+ //
+ // Init ProcInfo and StartInfo
+ //
+ ZeroMemory (&ProcInfo, sizeof (PROCESS_INFORMATION));
+ ZeroMemory (&StartInfo, sizeof (STARTUPINFO));
+ StartInfo.cb = sizeof (STARTUPINFO);
+ StartInfo.hStdError = FileHandle;
+ StartInfo.hStdOutput = FileHandle;
+ StartInfo.hStdInput = GetStdHandle (STD_INPUT_HANDLE);
+ StartInfo.dwFlags = STARTF_USESTDHANDLES;
+
+ //
+ // Create the child process
+ //
+ FuncRetn = CreateProcess (
+ NULL, // no application name
+ BuildCmd, // command line
+ NULL, // process security attributes
+ NULL, // primary thread security attributes
+ TRUE, // handles are inherited
+ 0, // creation flags
+ NULL, // use parent's environment
+ WorkingDir, // set current directory
+ &StartInfo, // STARTUPINFO pointer
+ &ProcInfo // receives PROCESS_INFORMATION
+ );
+
+ if (FuncRetn == FALSE) {
+ EnterCriticalSection (&mCriticalSection);
+ Error (NULL, 0, 0, NULL, "could not create child process");
+ LeaveCriticalSection (&mCriticalSection);
+ CloseHandle (FileHandle);
+ return 1;
+ }
+
+ //
+ // Wait until child process exits
+ //
+ WaitForSingleObject (ProcInfo.hProcess, INFINITE);
+ GetExitCodeProcess (ProcInfo.hProcess, &ExitCode);
+ CloseHandle (ProcInfo.hProcess);
+ CloseHandle (ProcInfo.hThread);
+ CloseHandle (FileHandle);
+
+ if (ExitCode != 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+//
+// Thread function
+//
+static DWORD WINAPI
+ThreadProc (
+ LPVOID lpParam
+ )
+{
+ UINT32 ThreadId;
+ BUILD_ITEM *PreviousBuildItem;
+ BUILD_ITEM *CurrentBuildItem;
+ BUILD_ITEM *NextBuildItem;
+ INT8 WorkingDir[MAX_PATH];
+ INT8 LogFile[MAX_PATH];
+ INT8 BuildCmd[MAX_PATH];
+
+ ThreadId = (UINT32)lpParam;
+ //
+ // Loop until error occurred or no more build items available for build
+ //
+ for (;;) {
+ WaitForSingleObject (mSemaphoreHandle, INFINITE);
+ if (mError || mDone) {
+ return 0;
+ }
+
+ //
+ // When code runs here, there must have one build item available for this
+ // thread. Loop until error occurred or get one build item for build.
+ //
+ for (;;) {
+ EnterCriticalSection (&mCriticalSection);
+ PreviousBuildItem = NULL;
+ CurrentBuildItem = mWaitingList;
+ while (CurrentBuildItem != NULL) {
+ NextBuildItem = CurrentBuildItem->Next;
+ //
+ // CheckSourceFile() is to avoid concurrently build the same source file
+ // which may cause the muti-thread build failure
+ //
+ if (CheckSourceFile (CurrentBuildItem->SourceFileList)) {
+ //
+ // Move the current build item from mWaitingList
+ //
+ if (PreviousBuildItem != NULL) {
+ PreviousBuildItem->Next = NextBuildItem;
+ } else {
+ mWaitingList = NextBuildItem;
+ }
+ //
+ // Add the current build item to the head of mBuildingList
+ //
+ CurrentBuildItem->Next = mBuildingList;
+ mBuildingList = CurrentBuildItem;
+ //
+ // If no more build items is pending or waiting for build,
+ // wake up every child thread for exit.
+ //
+ if ((mPendingList == NULL) && (mWaitingList == NULL)) {
+ mDone = 1;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
+ }
+ break;
+ }
+ PreviousBuildItem = CurrentBuildItem;
+ CurrentBuildItem = NextBuildItem;
+ }
+ if (CurrentBuildItem != NULL) {
+ //
+ // Display build item info
+ //
+ printf ("\t[Thread_%d] nmake -nologo -f %s all\n", ThreadId, CurrentBuildItem->Makefile);
+ //
+ // Prepare build task
+ //
+ sprintf (WorkingDir, "%s\\%s", mBuildDir, CurrentBuildItem->Processor);
+ sprintf (LogFile, "%s\\%s_%s_%d.txt", mLogDir, CurrentBuildItem->BaseName,
+ CurrentBuildItem->Processor, CurrentBuildItem->Index);
+ sprintf (BuildCmd, "nmake -nologo -f %s all", CurrentBuildItem->Makefile);
+ LeaveCriticalSection (&mCriticalSection);
+ break;
+ } else {
+ LeaveCriticalSection (&mCriticalSection);
+ //
+ // All the build items in mWaitingList have source file conflict with
+ // mBuildingList. This rarely hapeens. Need wait for the build items in
+ // mBuildingList to be finished by other child threads.
+ //
+ Sleep (1000);
+ if (mError) {
+ return 0;
+ }
+ }
+ }
+
+ //
+ // Start to build the CurrentBuildItem
+ //
+ if (RunBuildTask (WorkingDir, LogFile, BuildCmd)) {
+ //
+ // Build failure
+ //
+ mError = 1;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, mThreadNumber, NULL);
+ SetEvent(mEventHandle);
+
+ return mError;
+ } else {
+ //
+ // Build success
+ //
+ CurrentBuildItem->CompleteFlag = 1;
+
+ EnterCriticalSection (&mCriticalSection);
+ //
+ // Move this build item from mBuildingList
+ //
+ if (mBuildingList == CurrentBuildItem) {
+ mBuildingList = mBuildingList->Next;
+ } else {
+ NextBuildItem = mBuildingList;
+ while (NextBuildItem->Next != CurrentBuildItem) {
+ NextBuildItem = NextBuildItem->Next;
+ }
+ NextBuildItem->Next = CurrentBuildItem->Next;
+ }
+ //
+ // Add this build item to mDoneList
+ //
+ CurrentBuildItem->Next = mDoneList;
+ mDoneList = CurrentBuildItem;
+ LeaveCriticalSection (&mCriticalSection);
+
+ SetEvent(mEventHandle);
+ }
+ }
+}
+
+INT8
+StartMultiThreadBuild (
+ BUILD_ITEM **BuildList,
+ UINT32 ThreadNumber,
+ INT8 *BuildDir
+ )
+/*++
+
+Routine Description:
+
+ Start multi-thread build for a specified build list
+
+Arguments:
+
+ BuildList - build list for multi-thread build
+ ThreadNumber - thread number for multi-thread build
+ BuildDir - build dir
+
+Returns:
+
+ 0 - Successfully finished the multi-thread build
+ other value - Build failure
+
+--*/
+{
+ UINT32 Index;
+ UINT32 Count;
+ BUILD_ITEM *PreviousBuildItem;
+ BUILD_ITEM *CurrentBuildItem;
+ BUILD_ITEM *NextBuildItem;
+ HANDLE *ThreadHandle;
+ INT8 Cmd[MAX_PATH];
+
+ mError = 0;
+ mDone = 0;
+ mThreadNumber = ThreadNumber;
+ mBuildDir = BuildDir;
+ mPendingList = *BuildList;
+ *BuildList = NULL;
+ mWaitingList = NULL;
+ mBuildingList = NULL;
+ mDoneList = NULL;
+
+ //
+ // Do nothing when mPendingList is empty
+ //
+ if (mPendingList == NULL) {
+ return 0;
+ }
+
+ //
+ // Get build item count of mPendingList
+ //
+ Count = 0;
+ CurrentBuildItem = mPendingList;
+ while (CurrentBuildItem != NULL) {
+ Count++;
+ CurrentBuildItem = CurrentBuildItem->Next;
+ }
+
+ //
+ // The semaphore is also used to wake up child threads for exit,
+ // so need to make sure "maximum count" >= "thread number".
+ //
+ if (Count < ThreadNumber) {
+ Count = ThreadNumber;
+ }
+
+ //
+ // Init mSemaphoreHandle
+ //
+ mSemaphoreHandle = CreateSemaphore (
+ NULL, // default security attributes
+ 0, // initial count
+ Count, // maximum count
+ NULL // unnamed semaphore
+ );
+ if (mSemaphoreHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create semaphore");
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+
+ //
+ // Init mEventHandle
+ //
+ mEventHandle = CreateEvent(
+ NULL, // default security attributes
+ FALSE, // auto-reset event
+ TRUE, // initial state is signaled
+ NULL // object not named
+ );
+ if (mEventHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create event");
+ CloseHandle (mSemaphoreHandle);
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+
+ //
+ // Init mCriticalSection
+ //
+ InitializeCriticalSection (&mCriticalSection);
+
+ //
+ // Create build item log dir
+ //
+ sprintf (mLogDir, "%s\\Log", mBuildDir);
+ _mkdir (mLogDir);
+
+ //
+ // Create child threads for muti-thread build
+ //
+ ThreadHandle = malloc (ThreadNumber * sizeof (HANDLE));
+ if (ThreadHandle == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to allocate memory");
+ CloseHandle (mSemaphoreHandle);
+ CloseHandle (mEventHandle);
+ RestoreBuildList (BuildList);
+ return 1;
+ }
+ for (Index = 0; Index < ThreadNumber; Index++) {
+ ThreadHandle[Index] = CreateThread (
+ NULL, // default security attributes
+ 0, // use default stack size
+ ThreadProc, // thread function
+ (LPVOID)Index, // argument to thread function: use Index as thread id
+ 0, // use default creation flags
+ NULL // thread identifier not needed
+ );
+ if (ThreadHandle[Index] == NULL) {
+ Error (NULL, 0, 0, NULL, "failed to create Thread_%d", Index);
+ mError = 1;
+ ThreadNumber = Index;
+ //
+ // Make sure to wake up every child thread for exit
+ //
+ ReleaseSemaphore (mSemaphoreHandle, ThreadNumber, NULL);
+ break;
+ }
+ }
+
+ //
+ // Loop until error occurred or no more build items pending for build
+ //
+ for (;;) {
+ WaitForSingleObject (mEventHandle, INFINITE);
+ if (mError) {
+ break;
+ }
+ Count = 0;
+
+ EnterCriticalSection (&mCriticalSection);
+ PreviousBuildItem = NULL;
+ CurrentBuildItem = mPendingList;
+ while (CurrentBuildItem != NULL) {
+ NextBuildItem = CurrentBuildItem->Next;
+ if (CheckDependency (CurrentBuildItem->DependencyList)) {
+ //
+ // Move the current build item from mPendingList
+ //
+ if (PreviousBuildItem != NULL) {
+ PreviousBuildItem->Next = NextBuildItem;
+ } else {
+ mPendingList = NextBuildItem;
+ }
+ //
+ // Add the current build item to the head of mWaitingList
+ //
+ CurrentBuildItem->Next = mWaitingList;
+ mWaitingList = CurrentBuildItem;
+ Count++;
+ } else {
+ PreviousBuildItem = CurrentBuildItem;
+ }
+ CurrentBuildItem = NextBuildItem;
+ }
+ LeaveCriticalSection (&mCriticalSection);
+
+ ReleaseSemaphore (mSemaphoreHandle, Count, NULL);
+ if (mPendingList == NULL) {
+ break;
+ }
+ }
+
+ //
+ // Wait until all threads have terminated
+ //
+ WaitForMultipleObjects (ThreadNumber, ThreadHandle, TRUE, INFINITE);
+
+ if (mError && (mBuildingList != NULL)) {
+ //
+ // Dump build failure log of the first build item which doesn't finish the build
+ //
+ printf ("\tnmake -nologo -f %s all\n", mBuildingList->Makefile);
+ sprintf (Cmd, "type %s\\%s_%s_%d.txt 2>NUL", mLogDir, mBuildingList->BaseName,
+ mBuildingList->Processor, mBuildingList->Index);
+ _flushall ();
+ if (system (Cmd)) {
+ Error (NULL, 0, 0, NULL, "failed to run \"%s\"", Cmd);
+ }
+ }
+
+ DeleteCriticalSection (&mCriticalSection);
+ for (Index = 0; Index < ThreadNumber; Index++) {
+ CloseHandle (ThreadHandle[Index]);
+ }
+ free (ThreadHandle);
+ CloseHandle (mSemaphoreHandle);
+ CloseHandle (mEventHandle);
+ RestoreBuildList (BuildList);
+
+ return mError;
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
new file mode 100644
index 0000000000..7a5566a913
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/MultiThread.h
@@ -0,0 +1,116 @@
+/*++
+
+Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MultiThread.h
+
+Abstract:
+
+ Defines and function prototypes for the ProcessDsc utility.
+
+--*/
+
+#ifndef _MULTI_THREAD_H_
+#define _MULTI_THREAD_H_
+
+typedef struct _COMPONENTS_ITEM COMPONENTS_ITEM;
+typedef struct _BUILD_ITEM BUILD_ITEM;
+typedef struct _SOURCE_FILE_ITEM SOURCE_FILE_ITEM;
+typedef struct _DEPENDENCY_ITEM DEPENDENCY_ITEM;
+
+//
+// Use this structure to keep track of module build items
+//
+typedef struct _BUILD_ITEM {
+ BUILD_ITEM *Next;
+ INT8 *BaseName;
+ INT8 *Processor;
+ INT8 *Makefile;
+ UINT32 Index;
+ UINT32 CompleteFlag;
+ SOURCE_FILE_ITEM *SourceFileList;
+ DEPENDENCY_ITEM *DependencyList;
+} BUILD_ITEM;
+
+//
+// Use this structure to keep track of module source files
+//
+typedef struct _SOURCE_FILE_ITEM {
+ SOURCE_FILE_ITEM *Next;
+ INT8 *FileName;
+} SOURCE_FILE_ITEM;
+
+//
+// Use this structure to keep track of module build dependencies
+//
+typedef struct _DEPENDENCY_ITEM {
+ DEPENDENCY_ITEM *Next;
+ BUILD_ITEM *Dependency;
+} DEPENDENCY_ITEM;
+
+//
+// Use this structure to keep track of [components] and [components.n] sections
+//
+typedef struct _COMPONENTS_ITEM {
+ COMPONENTS_ITEM *Next;
+ BUILD_ITEM *BuildList;
+} COMPONENTS_ITEM;
+
+//
+// Function prototypes
+//
+BUILD_ITEM *
+AddBuildItem (
+ BUILD_ITEM **BuildList,
+ INT8 *BaseName,
+ INT8 *Processor,
+ INT8 *Makefile
+ );
+
+
+SOURCE_FILE_ITEM *
+AddSourceFile (
+ BUILD_ITEM *BuildItem,
+ INT8 *FileName
+ );
+
+DEPENDENCY_ITEM *
+AddDependency (
+ BUILD_ITEM *BuildList,
+ BUILD_ITEM *BuildItem,
+ INT8 *BaseName,
+ INT8 AdjustIndex
+ );
+
+void
+FreeBuildList (
+ BUILD_ITEM *BuildList
+ );
+
+COMPONENTS_ITEM *
+AddComponentsItem (
+ COMPONENTS_ITEM **ComponentsList
+ );
+
+void
+FreeComponentsList (
+ COMPONENTS_ITEM *ComponentsList
+ );
+
+INT8
+StartMultiThreadBuild (
+ BUILD_ITEM **BuildList,
+ UINT32 ThreadNumber,
+ INT8 *BuildDir
+ );
+
+#endif // ifndef _MULTI_THREAD_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
index 20faf6f69f..5f64bf5685 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/ProcessDsc/ProcessDsc.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -27,25 +27,18 @@ Abstract:
#include <direct.h> // for _mkdir()
#include <errno.h>
#include <stdlib.h> // for getenv()
+#include <shlwapi.h> // for PathCanonicalize()
#include "DSCFile.h"
+#include "MultiThread.h"
#include "FWVolume.h"
#include "Exceptions.h"
#include "Common.h"
#include "EfiUtilityMsgs.h"
#include "TianoBind.h"
-//
-// Disable warning for while(1) code
-//
-#pragma warning(disable : 4127)
-//
-// Disable warning for unreferenced function parameters
-//
-#pragma warning(disable : 4100)
-
-extern int errno;
-#define PROGRAM_NAME "ProcessDsc"
+#define UTILITY_NAME "ProcessDsc"
+#define UTILITY_VERSION "v1.0"
//
// Common symbol name definitions. For example, the user can reference
@@ -220,25 +213,39 @@ typedef struct _SYMBOL {
} SYMBOL;
//
-// Define new SYMBOL list to record all module name used in the platform.dsc file.
+// Module globals for multi-thread build
//
-SYMBOL *gModuleList = NULL;
+static BUILD_ITEM **mCurrentBuildList; // build list currently handling
+static BUILD_ITEM *mCurrentBuildItem; // build item currently handling
+
+//
+// Define masks for the build targets
+//
+#define BUILD_TARGET_COMPONENTS 0x01
+#define BUILD_TARGET_LIBRARIES 0x02
+#define BUILD_TARGET_FVS 0x04
+#define BUILD_TARGET_ALL 0xff
+
//
// This structure is used to save globals
//
struct {
- INT8 *DscFilename;
- SYMBOL *Symbol;
- INT8 MakefileName[MAX_PATH]; // output makefile name
- INT8 XRefFileName[MAX_PATH];
- INT8 GuidDatabaseFileName[MAX_PATH];
- INT8 ModuleMakefileName[MAX_PATH];
- FILE *MakefileFptr;
- FILE *ModuleMakefileFptr;
- SYMBOL *ModuleList;
- SYMBOL *OutdirList;
- UINT32 Verbose;
+ INT8 *DscFilename;
+ SYMBOL *Symbol;
+ INT8 MakefileName[MAX_PATH]; // output makefile name
+ INT8 XRefFileName[MAX_PATH];
+ INT8 GuidDatabaseFileName[MAX_PATH];
+ INT8 ModuleMakefileName[MAX_PATH];
+ FILE *MakefileFptr;
+ FILE *ModuleMakefileFptr;
+ SYMBOL *ModuleList;
+ SYMBOL *OutdirList;
+ UINT32 Verbose;
+ UINT32 ThreadNumber;
+ UINT32 BuildTarget;
+ BUILD_ITEM *LibraryList;
+ COMPONENTS_ITEM *ComponentsList;
} gGlobals;
//
@@ -584,16 +591,18 @@ Returns:
--*/
{
- int i;
- DSC_FILE DSCFile;
- SECTION *Sect;
- INT8 Line[MAX_LINE_LEN];
- INT8 ExpLine[MAX_LINE_LEN];
- INT8 *EMsg;
- FILE *FpModule;
- SYMBOL *TempSymbol;
-
- SetUtilityName (PROGRAM_NAME);
+ int i;
+ DSC_FILE DSCFile;
+ SECTION *Sect;
+ INT8 Line[MAX_LINE_LEN];
+ INT8 ExpLine[MAX_LINE_LEN];
+ INT8 *BuildDir;
+ INT8 *EMsg;
+ FILE *FpModule;
+ SYMBOL *TempSymbol;
+ COMPONENTS_ITEM *TempComponents;
+
+ SetUtilityName (UTILITY_NAME);
InitExceptions ();
@@ -710,6 +719,7 @@ Returns:
//
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_SECTION_NAME);
if (Sect != NULL) {
+ mCurrentBuildList = &gGlobals.LibraryList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_LIBRARIES, 0);
}
@@ -721,6 +731,7 @@ Returns:
//
Sect = DSCFileFindSection (&DSCFile, LIBRARIES_PLATFORM_SECTION_NAME);
if (Sect != NULL) {
+ mCurrentBuildList = &gGlobals.LibraryList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_PLATFORM_LIBRARIES, 0);
}
@@ -735,6 +746,8 @@ Returns:
Sect = DSCFileFindSection (&DSCFile, COMPONENTS_SECTION_NAME);
if (Sect != NULL) {
fprintf (gGlobals.MakefileFptr, "components_0 : \n");
+ TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
+ mCurrentBuildList = &TempComponents->BuildList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, 0);
fprintf (gGlobals.MakefileFptr, "\n");
}
@@ -754,6 +767,8 @@ Returns:
Sect = DSCFileFindSection (&DSCFile, Line);
if (Sect != NULL) {
fprintf (gGlobals.MakefileFptr, "components_%d : \n", i);
+ TempComponents = AddComponentsItem (&gGlobals.ComponentsList);
+ mCurrentBuildList = &TempComponents->BuildList;
ProcessSectionComponents (&DSCFile, DSC_SECTION_TYPE_COMPONENTS, i);
fprintf (gGlobals.MakefileFptr, "\n");
} else {
@@ -807,12 +822,52 @@ ProcessingError:
fclose (gGlobals.ModuleMakefileFptr);
gGlobals.ModuleMakefileFptr = NULL;
}
-
+
+ //
+ // Start multi-thread build if ThreadNumber is specified and no error status
+ //
+ if ((gGlobals.ThreadNumber != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
+ BuildDir = GetSymbolValue (BUILD_DIR);
+ if (gGlobals.BuildTarget & BUILD_TARGET_LIBRARIES) {
+ if (StartMultiThreadBuild (&gGlobals.LibraryList, gGlobals.ThreadNumber, BuildDir) != 0) {
+ Error (NULL, 0, 0, NULL, "Multi-thread build libraries failure");
+ goto Cleanup;
+ }
+ }
+ i = 0;
+ TempComponents = gGlobals.ComponentsList;
+ while (TempComponents != NULL) {
+ if (gGlobals.BuildTarget & BUILD_TARGET_COMPONENTS) {
+ if (StartMultiThreadBuild (&TempComponents->BuildList, gGlobals.ThreadNumber, BuildDir) != 0) {
+ Error (NULL, 0, 0, NULL, "Multi-thread build components %d failure", i);
+ goto Cleanup;
+ }
+ }
+ if (gGlobals.BuildTarget & BUILD_TARGET_FVS) {
+ sprintf (ExpLine, "nmake -nologo -f %s fvs_%d", gGlobals.MakefileName, i);
+ _flushall ();
+ if (system (ExpLine)) {
+ Error (NULL, 0, 0, NULL, "Build FVs for components %d failure", i);
+ goto Cleanup;
+ }
+ }
+ i++;
+ TempComponents = TempComponents->Next;
+ }
+ }
+
+Cleanup:
//
// Clean up
//
+ FreeBuildList (gGlobals.LibraryList);
+ gGlobals.LibraryList = NULL;
+ FreeComponentsList (gGlobals.ComponentsList);
+ gGlobals.ComponentsList = NULL;
FreeSymbols (gGlobals.ModuleList);
+ gGlobals.ModuleList = NULL;
FreeSymbols (gGlobals.OutdirList);
+ gGlobals.OutdirList = NULL;
FreeSymbols (gGlobals.Symbol);
gGlobals.Symbol = NULL;
CFVDestructor ();
@@ -1312,6 +1367,16 @@ Returns:
}
//
+ // Add a new build item to mCurrentBuildList
+ //
+ mCurrentBuildItem = AddBuildItem (mCurrentBuildList, GetSymbolValue (BASE_NAME), Processor, FileName);
+ //
+ // ProcessDsc allows duplicate base name libraries. Make sure the duplicate
+ // base name libraries will be built in the same order as listed in DSC file.
+ //
+ AddDependency (*mCurrentBuildList, mCurrentBuildItem, mCurrentBuildItem->BaseName, 1);
+
+ //
// Add Module name to the global module list
//
AddModuleName (&gGlobals.ModuleList, GetSymbolValue (BASE_NAME), GetSymbolValue (INF_FILENAME));
@@ -1336,6 +1401,7 @@ Returns:
// files in this component. This macro can then be used elsewhere to
// process all the files making up the component. Required for scanning
// files for string localization.
+ // Also add source files to mCurrentBuildItem.
//
ProcessSourceFiles (DSCFile, &ComponentFile, MakeFptr, SOURCE_MODE_SOURCE_FILES);
//
@@ -1370,7 +1436,8 @@ Returns:
// Process all the libraries to define "LIBS = x.lib y.lib..."
// Be generous and append ".lib" if they forgot.
// Make a macro definition: LIBS = $(LIBS) xlib.lib ylib.lib...
- // Also add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
+ // Add libs dependency for single module build: basenamebuild :: xlibbuild ylibbuild ...
+ // Also add libs dependency to mCurrentBuildItem.
//
ProcessLibs (&ComponentFile, MakeFptr);
@@ -1829,8 +1896,14 @@ Returns:
OverridePath = GetSymbolValue (SOURCE_OVERRIDE_PATH);
if (OverridePath != NULL) {
ReplaceSlash (OverridePath);
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", OverridePath);
fprintf (MakeFptr, "INC = $(INC) -I %s\n", OverridePath);
- fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", OverridePath, Processor);
+ fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", OverridePath, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", OverridePath, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", OverridePath);
+ fprintf (MakeFptr, "!ENDIF\n");
}
//
// Try for an [includes.$(PROCESSOR).$(PLATFORM)]
@@ -1909,43 +1982,45 @@ ProcessIncludesSectionSingle (
//
if (Cptr[1] == 0) {
fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\n");
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
} else {
//
// Handle case of ".\path\path\path" or "..\path\path\path"
//
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s \n",
- Cptr
- );
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s \n",
- Cptr,
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST($(SOURCE_DIR)\\%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(SOURCE_DIR)\\%s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir $(SOURCE_DIR)\\%s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
}
} else if ((Cptr[1] != ':') && isalpha (*Cptr)) {
- fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s \n", Cptr);
- fprintf (
- MakeFptr,
- "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s \n",
- Cptr,
- Processor
- );
+ fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST($(EFI_SOURCE)\\%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I $(EFI_SOURCE)\\%s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir $(EFI_SOURCE)\\%s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
} else {
//
// The line is something like: $(EFI_SOURCE)\dxe\include. Add it to
// the existing $(INC) definition. Add user includes before any
// other existing paths.
//
- fprintf (MakeFptr, "INC = $(INC) -I %s \n", Cptr);
- fprintf (MakeFptr, "INC = $(INC) -I %s\\%s \n", Cptr, Processor);
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", Cptr);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\n", Cptr);
+ fprintf (MakeFptr, "!IF EXIST(%s\\%s)\n", Cptr, Processor);
+ fprintf (MakeFptr, "INC = $(INC) -I %s\\%s\n", Cptr, Processor);
+ fprintf (MakeFptr, "!ENDIF\n");
+ fprintf (MakeFptr, "!ELSE\n");
+ fprintf (MakeFptr, "!MESSAGE Warning: include dir %s does not exist\n", Cptr);
+ fprintf (MakeFptr, "!ENDIF\n");
}
}
}
@@ -2260,16 +2335,35 @@ ProcessSourceFilesSection (
// SOURCE_FILES = $(SOURCE_FILES) c:\Path\ThisFile.c
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", TempFileName);
+ //
+ // Save the source absolute path
+ //
+ if (PathCanonicalize (FilePath, TempFileName)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
} else if (IsAbsolutePath (FileName)) {
//
// For Absolute path, don't print $(SOURCE_FILE) directory.
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) %s\n", FileName);
+ //
+ // Save the source absolute path
+ //
+ if (PathCanonicalize (FilePath, FileName)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
} else {
//
// SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\ThisFile.c
//
fprintf (MakeFptr, "SOURCE_FILES = $(SOURCE_FILES) $(SOURCE_DIR)\\%s\n", FileName);
+ //
+ // Save the source absolute path
+ //
+ sprintf (Str, "%s\\%s", GetSymbolValue (SOURCE_DIR), FileName);
+ if (PathCanonicalize (FilePath, Str)) {
+ AddSourceFile (mCurrentBuildItem, FilePath);
+ }
}
} else if (Mode & SOURCE_MODE_BUILD_COMMANDS) {
//
@@ -2612,6 +2706,10 @@ ProcessLibsSingle (
Cptr[strlen (Cptr) - 4] = 0;
fprintf (gGlobals.ModuleMakefileFptr, " %sbuild", Cptr);
}
+ //
+ // Add libs dependency for mCurrentBuildItem
+ //
+ AddDependency (*mCurrentBuildList, mCurrentBuildItem, Cptr, 0);
}
}
}
@@ -2767,8 +2865,9 @@ ProcessIncludeFilesSingle (
if (Cptr >= TempFileName) {
*Cptr = 0;
}
-
+ fprintf (MakeFptr, "!IF EXIST(%s)\n", TempFileName);
fprintf (MakeFptr, "INC = -I %s $(INC)\n", TempFileName);
+ fprintf (MakeFptr, "!ENDIF\n");
}
}
//
@@ -4173,6 +4272,63 @@ Returns:
}
break;
+ //
+ // Enable multi-thread build and specify the thread number
+ //
+ case 'n':
+ case 'N':
+ //
+ // Skip to next arg
+ //
+ Argc--;
+ Argv++;
+ if (Argc == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "missing input thread number with option");
+ Usage ();
+ return STATUS_ERROR;
+ } else {
+ gGlobals.ThreadNumber = atoi (Argv[0]);
+ if (gGlobals.ThreadNumber == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input thread number should not be %s", Argv[1]);
+ return STATUS_ERROR;
+ } else if (gGlobals.ThreadNumber > MAXIMUM_WAIT_OBJECTS) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input thread number should not greater than %d", MAXIMUM_WAIT_OBJECTS);
+ return STATUS_ERROR;
+ }
+ }
+ break;
+
+ //
+ // Specify the multi-thread build target
+ //
+ case 't':
+ case 'T':
+ //
+ // Skip to next arg
+ //
+ Argc--;
+ Argv++;
+ if (Argc == 0) {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "missing input build target with option");
+ Usage ();
+ return STATUS_ERROR;
+ } else if (_stricmp (Argv[0], "all") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_ALL;
+ } else if (_stricmp (Argv[0], "libraries") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_LIBRARIES;
+ } else if (_stricmp (Argv[0], "components") == 0) {
+ gGlobals.BuildTarget |= BUILD_TARGET_COMPONENTS;
+ } else {
+ Argv--;
+ Error (NULL, 0, 0, Argv[0], "input build target not supported");
+ Usage ();
+ }
+ break;
+
case 'v':
case 'V':
gGlobals.Verbose = 1;
@@ -4228,7 +4384,14 @@ Returns:
if (FreeCwd) {
free (Cptr);
}
-
+
+ //
+ // Default build target is all
+ //
+ if (gGlobals.BuildTarget == 0) {
+ gGlobals.BuildTarget = BUILD_TARGET_ALL;
+ }
+
return 0;
}
@@ -4426,18 +4589,29 @@ Usage (
VOID
)
{
- int i;
- static const INT8 *Help[] = {
- "Usage: ProcessDsc {options} [Dsc Filename]",
- " Options:",
- " -d var=value to define symbol 'var' to 'value'",
- " -v for verbose mode",
- " -g filename to preparse GUID listing file",
- " -x filename to create a cross-reference file",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Process DSC File Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION]... DSCFILE",
+ "Options:",
+ " -d var=value to define symbol 'var' to 'value'",
+ " -v for verbose mode",
+ " -g filename to preparse GUID listing file",
+ " -x filename to create a cross-reference file",
+ " -n threadnumber to build with multi-thread",
+ " -t target to build the specified target:",
+ " all, libraries or components",
NULL
};
- for (i = 0; Help[i] != NULL; i++) {
- fprintf (stdout, "%s\n", Help[i]);
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
@@ -4562,7 +4736,7 @@ SmartOpen (
if (SmartFile->FileContent != NULL) {
memset (SmartFile->FileContent, 0, FileSize + 1);
//
- // Usually FileLength < FileSize, because in text mode, carriage return-linefeed
+ // Usually FileLength < FileSize, because in text mode, carriage return¨Clinefeed
// combinations are translated into single linefeeds on input
//
SmartFile->FileLength = fread (SmartFile->FileContent, sizeof(char), FileSize, Fptr);
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
index 866c6a4523..6777973810 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/SetStamp/SetStamp.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,7 +22,8 @@ Abstract:
#include <time.h>
#define LINE_MAXLEN 80
-
+#define UTILITY_NAME "SetStamp"
+#define UTILITY_VERSION "v1.0"
void
PrintUsage (
void
@@ -38,10 +39,25 @@ Returns:
None
--*/
{
- //
- // print usage of command
- //
- printf ("Usage: SetStamp <PE-File> <TIME-File>\n");
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Set Time Stamp Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" PEFILE TIMEFILE",
+ "Description:",
+ " Set Date/Time Stamp of Portable Executable (PE) format file",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
index 74ac5a143c..c0df181f63 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/SplitFile/splitfile.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2010, 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
@@ -21,6 +21,9 @@ Abstract:
#include "string.h"
#include "stdlib.h"
+#define UTILITY_NAME "SplitFile"
+#define UTILITY_VERSION "v1.0"
+
void
helpmsg (
void
@@ -40,11 +43,24 @@ Returns:
--*/
{
- printf (
- "SplitFile Filename Offset\n"" Filename = Input file to split\n"" Offset = offset at which to split file\n"
- "\n\n""SplitFile will break a file in two pieces at the requested offset\n"
- " outputting Filename1 and Filename2\n"
- );
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Split File Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" FILE OFFSET",
+ "Description:",
+ " Break the FILE in two pieces FILE1 and FILE2 at the requested OFFSET.",
+ NULL
+ };
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
}
int
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
index f830400b24..2d6d35bb88 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -29,7 +29,8 @@ Abstract:
#include "StrGather.h"
#include "StringDB.h"
-#define TOOL_VERSION "0.31"
+#define UTILITY_NAME "StrGather"
+#define UTILITY_VERSION "v1.0"
typedef UINT16 WCHAR;
@@ -281,11 +282,6 @@ ParseIndirectionFiles (
TEXT_STRING_LIST *Files
);
-STATUS
-StringDBCreateHiiExportPack (
- INT8 *OutputFileName
- );
-
int
main (
int Argc,
@@ -311,7 +307,7 @@ Returns:
{
STATUS Status;
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
//
// Process the command-line arguments
//
@@ -405,7 +401,7 @@ Returns:
// Dump the string data as HII binary string pack if requested
//
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
- StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
+ StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
}
//
// Always update the database if no errors and not in dump mode. If they specified -od
@@ -1481,7 +1477,7 @@ FindFile (
// Put the path and filename together
//
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
- Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
+ Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
return NULL;
}
//
@@ -1581,7 +1577,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
return STATUS_ERROR;
}
//
@@ -1591,7 +1587,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1599,7 +1595,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1624,7 +1620,7 @@ ProcessArgs (
// Indirection file -- check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
return STATUS_ERROR;
}
//
@@ -1634,7 +1630,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1642,7 +1638,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1665,13 +1661,13 @@ ProcessArgs (
// Check for one more arg (the database file name)
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
return STATUS_ERROR;
}
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1679,7 +1675,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1702,14 +1698,14 @@ ProcessArgs (
// which we can dump our database.
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
return STATUS_ERROR;
}
if (mGlobals.DumpUFileName[0] == 0) {
strcpy (mGlobals.DumpUFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
return STATUS_ERROR;
}
@@ -1720,14 +1716,14 @@ ProcessArgs (
// -hpk option to create an HII export pack of the input database file
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
return STATUS_ERROR;
}
if (mGlobals.HiiExportPackFileName[0] == 0) {
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
return STATUS_ERROR;
}
@@ -1751,7 +1747,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
return STATUS_ERROR;
}
@@ -1763,7 +1759,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
Usage ();
return STATUS_ERROR;
}
@@ -1776,7 +1772,7 @@ ProcessArgs (
// -oh to specify output .h defines file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
return STATUS_ERROR;
}
@@ -1788,7 +1784,7 @@ ProcessArgs (
// -dep to specify output dependency file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
return STATUS_ERROR;
}
@@ -1800,7 +1796,7 @@ ProcessArgs (
// -skipext to skip scanning of files with certain filename extensions
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
return STATUS_ERROR;
}
//
@@ -1810,7 +1806,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1818,7 +1814,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1845,7 +1841,7 @@ ProcessArgs (
// "-lang eng" or "-lang spa+cat" to only output certain languages
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
Usage ();
return STATUS_ERROR;
}
@@ -1861,7 +1857,7 @@ ProcessArgs (
// Output database file name -- check for another arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
return STATUS_ERROR;
}
@@ -1872,7 +1868,7 @@ ProcessArgs (
//
// Unrecognized arg
//
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
Usage ();
return STATUS_ERROR;
}
@@ -1919,7 +1915,7 @@ ProcessArgs (
//
if (mGlobals.Mode == MODE_SCAN) {
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
Usage ();
return STATUS_ERROR;
}
@@ -1929,14 +1925,14 @@ ProcessArgs (
while (Argc > 0) {
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
if (NewList->Str == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
@@ -1956,7 +1952,7 @@ ProcessArgs (
// Parse mode -- must specify an input unicode file name
//
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
Usage ();
return STATUS_ERROR;
}
@@ -1989,7 +1985,7 @@ AddCommandLineLanguage (
//
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
if (WNewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1997,7 +1993,7 @@ AddCommandLineLanguage (
WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
if (WNewList->Str == NULL) {
free (WNewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
//
@@ -2024,7 +2020,7 @@ AddCommandLineLanguage (
(From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
)
) {
- Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
+ Error (UTILITY_NAME, 0, 0, Language, "invalid format for language name on command line");
FREE (WNewList->Str);
FREE (WNewList);
return STATUS_ERROR;
@@ -2523,48 +2519,56 @@ Returns:
--*/
{
- int Index;
- static const char *Str[] = {
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel String Gather Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
- PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
- " Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
- " "PROGRAM_NAME " -scan {scan options} [FileName]",
- " "PROGRAM_NAME " -dump {dump options}",
- " Common options include:",
- " -h or -? for this help information",
- " -db Database required name of output/input database file",
- " -bn BaseName for use in the .h and .c output files",
- " Default = "DEFAULT_BASE_NAME,
- " -v for verbose output",
- " -vdbw for verbose output when writing database",
- " -vdbr for verbose output when reading database",
- " -od FileName to specify an output database file name",
- " Parse options include:",
- " -i IncludePath add IncludePath to list of search paths",
- " -dep FileName to specify an output dependency file name",
- " -newdb to not read in existing database file",
- " -uqs to indicate that unquoted strings are used",
- " FileNames name of one or more unicode files to parse",
- " Scan options include:",
- " -scan scan text file(s) for STRING_TOKEN() usage",
- " -skipext .ext to skip scan of files with .ext filename extension",
- " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
- " found in the database",
- " FileNames one or more files to scan",
- " Dump options include:",
- " -oc FileName write string data to FileName",
- " -oh FileName write string defines to FileName",
- " -ou FileName dump database to unicode file FileName",
- " -lang Lang only dump for the language 'Lang'",
- " -if FileName to specify an indirection file",
- " -hpk FileName to create an HII export pack of the strings",
+ "Usage:",
+ " "UTILITY_NAME" -parse [OPTION] FILE",
+ " "UTILITY_NAME" -scan [OPTION] FILE",
+ " "UTILITY_NAME" -dump [OPTION]",
+ "Description:",
+ " Process unicode strings file.",
+ "Common options include:",
+ " -h or -? for this help information",
+ " -db Database required name of output/input database file",
+ " -bn BaseName for use in the .h and .c output files",
+ " Default = "DEFAULT_BASE_NAME,
+ " -v for verbose output",
+ " -vdbw for verbose output when writing database",
+ " -vdbr for verbose output when reading database",
+ " -od FileName to specify an output database file name",
+ "Parse options include:",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -dep FileName to specify an output dependency file name",
+ " -newdb to not read in existing database file",
+ " -uqs to indicate that unquoted strings are used",
+ " FileNames name of one or more unicode files to parse",
+ "Scan options include:",
+ " -scan scan text file(s) for STRING_TOKEN() usage",
+ " -skipext .ext to skip scan of files with .ext filename extension",
+ " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
+ " found in the database",
+ " FileNames one or more files to scan",
+ "Dump options include:",
+ " -oc FileName write string data to FileName",
+ " -oh FileName write string defines to FileName",
+ " -ou FileName dump database to unicode file FileName",
+ " -lang Lang only dump for the language 'Lang'",
+ " -if FileName to specify an indirection file",
+ " -hpk FileName to create an HII export pack of the strings",
"",
- " The expected process is to parse a unicode string file to create an initial",
- " database of string identifier names and string definitions. Then text files",
- " should be scanned for STRING_TOKEN() usages, and the referenced",
- " strings will be tagged as used in the database. After all files have been",
- " scanned, then the database should be dumped to create the necessary output",
- " files.",
+ "The expected process is to parse a unicode string file to create an initial",
+ "database of string identifier names and string definitions. Then text files",
+ "should be scanned for STRING_TOKEN() usages, and the referenced",
+ "strings will be tagged as used in the database. After all files have been",
+ "scanned, then the database should be dumped to create the necessary output",
+ "files.",
"",
NULL
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
index d4da8e8690..e0dc783a8d 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StrGather.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -25,8 +25,6 @@ Abstract:
#define MALLOC(size) malloc (size)
#define FREE(ptr) free (ptr)
-#define PROGRAM_NAME "StrGather"
-
typedef CHAR16 WCHAR;
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
index 6b17f48c6d..08afd83fb3 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -2508,7 +2508,8 @@ Returns:
--*/
STATUS
StringDBCreateHiiExportPack (
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
FILE *Fptr;
@@ -2524,6 +2525,9 @@ StringDBCreateHiiExportPack (
WCHAR *TempStringPtr;
WCHAR *LangName;
STRING_IDENTIFIER *StringIdentifier;
+ WCHAR_STRING_LIST *LOIPtr;
+ BOOLEAN LanguageOk;
+
if ((Fptr = fopen (FileName, "wb")) == NULL) {
Error (NULL, 0, 0, FileName, "failed to open output HII export file");
@@ -2545,6 +2549,25 @@ StringDBCreateHiiExportPack (
ZeroString[0] = 0;
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
//
+ // If we have a language list, then make sure this language is in that
+ // list.
+ //
+ LanguageOk = TRUE;
+ if (LanguagesOfInterest != NULL) {
+ LanguageOk = FALSE;
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcsncmp (LOIPtr->Str, Lang->LanguageName, LANGUAGE_IDENTIFIER_NAME_LEN) == 0) {
+ LanguageOk = TRUE;
+ break;
+ }
+ }
+ }
+
+ if (!LanguageOk) {
+ continue;
+ }
+
+ //
// Process each string for this language. We have to make 3 passes on the strings:
// Pass1: computes sizes and fill in the string pack header
// Pass2: write the array of offsets
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
index 92801f70f8..a4c2837ae0 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/StrGather/StringDB.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -28,11 +28,13 @@ Abstract:
void
StringDBConstructor (
void
- );
+ )
+;
void
StringDBDestructor (
void
- );
+ )
+;
STATUS
StringDBAddString (
@@ -42,12 +44,14 @@ StringDBAddString (
WCHAR *String,
BOOLEAN Format,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBSetScope (
WCHAR *Scope
- );
+ )
+;
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
@@ -61,33 +65,38 @@ StringDBAddStringIdentifier (
WCHAR *StringIdentifier,
UINT16 *NewId,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBReadDatabase (
INT8 *DBFileName,
BOOLEAN IgnoreIfNotExist,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBWriteDatabase (
INT8 *DBFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBDumpDatabase (
INT8 *DBFileName,
INT8 *OutputFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBAddLanguage (
WCHAR *LanguageName,
WCHAR *PrintableLanguageName
- );
+ )
+;
STATUS
StringDBDumpCStrings (
@@ -95,28 +104,40 @@ StringDBDumpCStrings (
INT8 *BaseName,
WCHAR_STRING_LIST *LanguagesOfInterest,
WCHAR_MATCHING_STRING_LIST *IndirectionList
- );
+ )
+;
STATUS
StringDBDumpStringDefines (
INT8 *FileName,
INT8 *BaseName
- );
+ )
+;
STATUS
StringDBSetCurrentLanguage (
WCHAR *LanguageName
- );
+ )
+;
STATUS
StringDBSetStringReferenced (
INT8 *StringIdentifierName,
BOOLEAN IgnoreNotFound
- );
+ )
+;
void
StringDBFormatString (
WCHAR *String
+ )
+;
+
+STATUS
+StringDBCreateHiiExportPack (
+ INT8 *OutputFileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
);
+
#endif // #ifndef _STRING_DB_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c b/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
index 03e1831ca7..03d3c3e5dd 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/Strip/strip.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2010, 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
@@ -24,6 +24,50 @@ Abstract:
#include <string.h>
#include <malloc.h>
+#define UTILITY_NAME "Strip"
+#define UTILITY_VERSION "v1.0"
+
+static
+void
+Usage (
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel Strip Utility",
+ " Copyright (C), 2006 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" SOURCE DEST",
+ "Description:",
+ " Convert executable files to binary files.",
+ NULL
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
+ }
+}
+
int
main (
int argc,
@@ -55,7 +99,7 @@ Returns:
char *Ptrx;
if (argc < 3) {
- printf ("Need more args, such as file name to convert and output name\n");
+ Usage ();
return -1;
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
new file mode 100644
index 0000000000..c1a4c3358c
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/HiiPack.c
@@ -0,0 +1,740 @@
+/*++
+
+Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiPack.c
+
+Abstract:
+
+ Process HII package files to generate HII package list binary file or PE/COFF
+ resource script file (i.e. .rc file).
+
+--*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "Tiano.h"
+#include "EfiHii.h"
+
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+
+#define UTILITY_VERSION "v1.0"
+#define UTILITY_NAME "HiiPack"
+#define MAX_PATH 260
+
+//
+// Define HII resource section type and name
+//
+#define HII_RESOURCE_TYPE "HII"
+#define HII_RESOURCE_NAME 1
+
+//
+// We'll store lists of file names from the command line in
+// a linked list of these
+//
+typedef struct _FILE_NAME_LIST {
+ struct _FILE_NAME_LIST *Next;
+ UINT8 FileName[MAX_PATH];
+ UINT32 PackageType;
+ UINT32 Length;
+ UINT8 *Data;
+} FILE_NAME_LIST;
+
+//
+// Create some defines for the different operation modes supported by this utility
+//
+#define MODE_CREATE_HII_RESOURCE_FILE 0x0001
+#define MODE_CREATE_HII_PACKAGE_LIST 0x0002
+
+//
+// Here's all our globals.
+//
+static struct {
+ FILE_NAME_LIST *PackageFile; // all include paths to search
+ FILE_NAME_LIST *LastPackageFile;
+ UINT8 PackageListFileName[MAX_PATH]; // Output package list file name
+ UINT8 ResourceFileName[MAX_PATH]; // Output HII resource file name
+ EFI_GUID Guid; // Guid specified on command line
+ BOOLEAN GuidSpecified;
+ BOOLEAN Verbose;
+ UINT32 Mode; // Mode this utility is operating in
+} mGlobals;
+
+static
+void
+Usage (
+ VOID
+ );
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ );
+
+static
+void
+FreeGlobals (
+ VOID
+ );
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ UINT8 *Buffer,
+ int Count,
+ int Indent
+ );
+
+static
+STATUS
+CreateResourceScript (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ );
+
+static
+STATUS
+CreatePackageList (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ );
+
+int
+main (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Call the routine to parse the command-line options, then process the file.
+
+Arguments:
+
+ Standard C main() argc and argv.
+
+Returns:
+
+ 0 if successful
+ nonzero otherwise
+
+--*/
+{
+ STATUS Status;
+
+ //
+ // Set the utility name for error reporting purposes
+ //
+ SetUtilityName (UTILITY_NAME);
+
+ //
+ // Process the command-line arguments
+ //
+ Status = ProcessArgs (Argc, Argv);
+ if (Status != STATUS_SUCCESS) {
+ return Status;
+ }
+
+ //
+ // Switch based on args
+ //
+ if (mGlobals.Mode & MODE_CREATE_HII_RESOURCE_FILE) {
+ CreateResourceScript (mGlobals.ResourceFileName, &mGlobals.Guid, mGlobals.PackageFile);
+ }
+
+ if (mGlobals.Mode & MODE_CREATE_HII_PACKAGE_LIST) {
+ CreatePackageList (mGlobals.PackageListFileName, &mGlobals.Guid, mGlobals.PackageFile);
+ }
+
+ FreeGlobals ();
+
+ return GetUtilityStatus ();
+}
+
+/******************************************************************************/
+static const char *gRcFileHeader[] = {
+ "//",
+ "// DO NOT EDIT -- auto-generated file",
+ "//",
+ "// This file is generated by the hiipack utility",
+ "//",
+ NULL
+};
+
+static
+STATUS
+CreateResourceScript (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII package files, walk the list to
+ process them and create a single HII resource script file.
+
+Arguments:
+
+ OutputFileName - name of output HII resource script file to create
+ PackageListGuid - the specified package list GUID
+ PackageFiles - linked list of HII package files to process
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ UINT8 *PackageList;
+ UINT8 *Buffer;
+ UINT32 PackageListLen;
+ FILE *OutFptr;
+ UINTN Index;
+ FILE_NAME_LIST *Package;
+
+ //
+ // If no input HII pack files, then why are we here? Should have been caught when
+ // args were processed though.
+ //
+ if (PackageFiles == NULL) {
+ Error (NULL, 0, 0, "no input package file(s) specified", NULL);
+ return STATUS_ERROR;
+ }
+
+ OutFptr = NULL;
+ Status = STATUS_ERROR;
+
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "w")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ //
+ // Write file header
+ //
+ for (Index = 0; gRcFileHeader[Index] != NULL; Index++) {
+ fprintf (OutFptr, "%s\n", gRcFileHeader[Index]);
+ }
+
+ //
+ // Write nameID and typeID
+ //
+ fprintf (OutFptr, "\n");
+ fprintf (OutFptr, "%d %s\n", HII_RESOURCE_NAME, HII_RESOURCE_TYPE);
+ fprintf (OutFptr, "{\n");
+
+ //
+ // Prepare package list
+ //
+ PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Package = PackageFiles;
+ while (Package != NULL) {
+ PackageListLen += Package->Length;
+ Package = Package->Next;
+ }
+ //
+ // Inlucde the length of EFI_HII_PACKAGE_END
+ //
+ PackageListLen += sizeof (EFI_HII_PACKAGE_HEADER);
+
+ Buffer = (UINT8 *) malloc (PackageListLen);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+ PackageList = Buffer;
+
+ memcpy (Buffer, PackageListGuid, sizeof (EFI_GUID));
+ Buffer += sizeof (EFI_GUID);
+ memcpy (Buffer, &PackageListLen, sizeof (UINT32));
+ Buffer += sizeof (UINT32);
+
+ Package = PackageFiles;
+ while (Package != NULL) {
+ memcpy (Buffer, Package->Data, Package->Length);
+ Buffer += Package->Length;
+ Package = Package->Next;
+ }
+ //
+ // Append EFI_HII_PACKAGE_END
+ //
+ ((EFI_HII_PACKAGE_HEADER *) Buffer)->Type = EFI_HII_PACKAGE_END;
+ ((EFI_HII_PACKAGE_HEADER *) Buffer)->Length = sizeof (EFI_HII_PACKAGE_HEADER);
+
+ //
+ // Dump package list
+ //
+ DumpRawBytes (OutFptr, PackageList, PackageListLen, 2);
+
+ //
+ // Write file tail
+ //
+ fprintf (OutFptr, "}\n");
+
+ Status = STATUS_SUCCESS;
+
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return Status;
+}
+
+static
+STATUS
+CreatePackageList (
+ char *OutputFileName,
+ EFI_GUID *PackageListGuid,
+ FILE_NAME_LIST *PackageFiles
+ )
+/*++
+
+Routine Description:
+
+ Given a linked list of HII package files, walk the list to
+ process them and create a binary HII package list file.
+
+Arguments:
+
+ OutputFileName - name of output HII package list file to create
+ PackageListGuid - the specified package list GUID
+ PackageFiles - linked list of HII package files to process
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE *OutFptr;
+ UINT32 PackageListLen;
+ FILE_NAME_LIST *Package;
+
+ if (OutputFileName == NULL || PackageListGuid == NULL || PackageFiles == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Open the output file for writing
+ //
+ if ((OutFptr = fopen (OutputFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0, OutputFileName, "failed to open output file for writing");
+ goto Done;
+ }
+
+ //
+ // Write package list header
+ //
+ PackageListLen = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Package = PackageFiles;
+ while (Package != NULL) {
+ PackageListLen += Package->Length;
+ Package = Package->Next;
+ }
+ fwrite (PackageListGuid, sizeof (UINT8), sizeof (EFI_GUID), OutFptr);
+ fwrite (&PackageListLen, sizeof (UINT8), sizeof (UINT32), OutFptr);
+
+ //
+ // Write packages
+ //
+ Package = PackageFiles;
+ while (Package != NULL) {
+ fwrite (Package->Data, sizeof (UINT8), Package->Length, OutFptr);
+ Package = Package->Next;
+ }
+
+Done:
+ if (OutFptr != NULL) {
+ fclose (OutFptr);
+ }
+
+ return STATUS_SUCCESS;
+}
+
+static
+void
+FreeGlobals (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Free up an memory we allocated so we can exit cleanly
+
+Arguments:
+
+Returns: NA
+
+--*/
+{
+ FILE_NAME_LIST *Next;
+
+ //
+ // Free up input package file names
+ //
+ while (mGlobals.PackageFile != NULL) {
+ Next = mGlobals.PackageFile->Next;
+ if (mGlobals.PackageFile->Data != NULL) {
+ free (mGlobals.PackageFile->Data);
+ }
+ free (mGlobals.PackageFile);
+ mGlobals.PackageFile = Next;
+ }
+}
+
+static
+void
+DumpRawBytes (
+ FILE *OutFptr,
+ UINT8 *Buffer,
+ int Count,
+ int Indent
+ )
+/*++
+
+Routine Description:
+
+ Dump buffer data into output file.
+
+Arguments:
+
+ OutFptr - FILE pointer to output file.
+ Buffer - the buffer to dump
+ Count - number of bytes to dump
+ Indent - indent at each line start
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int Counter;
+ int Count2;
+ UINT16 *Ptr16;
+
+ Ptr16 = (UINT16 *) Buffer;
+ Count2 = Count - (Count & 0x1);
+
+ for (Counter = 0; Counter < Count2; Counter += 2) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter == 0) {
+ fprintf (OutFptr, "%*c", Indent, ' ');
+ } else {
+ fprintf (OutFptr, "\n%*c", Indent, ' ');
+ }
+ }
+
+ fprintf (OutFptr, "0x%04X, ", (unsigned int) *Ptr16);
+ Ptr16++;
+ }
+
+ //
+ // Handle the last byte
+ //
+ if ((Count & 0x1) != 0) {
+ if ((Counter & 0xF) == 0) {
+ if (Counter == 0) {
+ fprintf (OutFptr, "%*c", Indent, ' ');
+ } else {
+ fprintf (OutFptr, "\n%*c", Indent, ' ');
+ }
+ }
+
+ fprintf (OutFptr, "0x%04X, ", (unsigned int) (*Ptr16 & 0xff));
+ }
+
+ fprintf (OutFptr, "\n");
+}
+
+static
+STATUS
+LoadPackage (
+ FILE_NAME_LIST *NameList
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ NameList - the FILE_NAME_LIST linked list node
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ STATUS Status;
+ FILE *InFptr;
+ UINT32 BufferSize;
+ UINT8 *Buffer;
+ EFI_HII_PACKAGE_HEADER *PackageHeader;
+ EFI_IFR_FORM_SET *FormSet;
+
+ Status = STATUS_SUCCESS;
+ if (NameList == NULL) {
+ return STATUS_ERROR;
+ }
+
+ //
+ // Try to open the package file
+ //
+ if ((InFptr = fopen (NameList->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0, NameList->FileName, "failed to open input file for read");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Get the file size, then allocate a buffer and read in the file contents.
+ //
+ fseek (InFptr, 0, SEEK_END);
+ BufferSize = (UINT32) ftell (InFptr);
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (UINT8 *) malloc (BufferSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 0, "memory allocation failure", NULL);
+ goto Done;
+ }
+
+ if (fread (Buffer, sizeof (UINT8), BufferSize, InFptr) != BufferSize) {
+ Error (NULL, 0, 0, NameList->FileName, "error reading file contents");
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ NameList->Length = BufferSize;
+ NameList->Data = Buffer;
+
+ PackageHeader = (EFI_HII_PACKAGE_HEADER *) Buffer;
+ NameList->PackageType = PackageHeader->Type;
+
+ if (!mGlobals.GuidSpecified && NameList->PackageType == EFI_HII_PACKAGE_FORMS) {
+ FormSet = (EFI_IFR_FORM_SET *) (Buffer + sizeof (EFI_HII_PACKAGE_HEADER));
+ memcpy (&mGlobals.Guid, &FormSet->Guid, sizeof (EFI_GUID));
+ mGlobals.GuidSpecified = TRUE;
+ }
+
+Done:
+ fclose (InFptr);
+
+ return Status;
+}
+
+
+static
+STATUS
+ProcessArgs (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Process the command line arguments
+
+Arguments:
+
+ As per standard C main()
+
+Returns:
+
+ STATUS_SUCCESS - if successful
+ STATUS_ERROR - otherwise
+
+--*/
+{
+ FILE_NAME_LIST *NewList;
+ STATUS Status;
+
+ Status = STATUS_SUCCESS;
+ memset ((void *) &mGlobals, 0, sizeof (mGlobals));
+
+ //
+ // Skip program name
+ //
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ if (_stricmp (Argv[0], "-h") == 0 || _stricmp (Argv[0], "-?") == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Process until no more args.
+ //
+ while (Argc > 0) {
+ if (_stricmp (Argv[0], "-rc") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising HII resource file name", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ strcpy (mGlobals.ResourceFileName, Argv[0]);
+ mGlobals.Mode |= MODE_CREATE_HII_RESOURCE_FILE;
+
+ } else if (_stricmp (Argv[0], "-hii") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising HII package list file name", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ strcpy (mGlobals.PackageListFileName, Argv[0]);
+ mGlobals.Mode |= MODE_CREATE_HII_PACKAGE_LIST;
+
+ } else if (_stricmp (Argv[0], "-g") == 0) {
+ Argc--;
+ Argv++;
+
+ if (Argc == 0) {
+ Error (UTILITY_NAME, 0, 0, "mising package list GUID", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ Status = StringToGuid (Argv[0], &mGlobals.Guid);
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ mGlobals.GuidSpecified = TRUE;
+
+ } else {
+ //
+ // This is a package file
+ //
+ NewList = malloc (sizeof (FILE_NAME_LIST));
+ if (NewList == NULL) {
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
+ Status = STATUS_ERROR;
+ goto Done;
+ }
+
+ memset (NewList, 0, sizeof (FILE_NAME_LIST));
+ strcpy (NewList->FileName, Argv[0]);
+
+ if (mGlobals.PackageFile == NULL) {
+ mGlobals.PackageFile = NewList;
+ } else {
+ mGlobals.LastPackageFile->Next = NewList;
+ }
+ mGlobals.LastPackageFile = NewList;
+
+ Status = LoadPackage (NewList);
+ if (Status != STATUS_SUCCESS) {
+ goto Done;
+ }
+ }
+
+ Argc--;
+ Argv++;
+ }
+
+ if (!mGlobals.GuidSpecified) {
+ Error (UTILITY_NAME, 0, 0, "please specify HII pakcage list GUID", NULL);
+ Status = STATUS_ERROR;
+ }
+
+Done:
+ if (Status != STATUS_SUCCESS) {
+ FreeGlobals ();
+ }
+
+ return Status;
+}
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ int i;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - UEFI HII Package List Utility",
+ " Copyright (C), 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] PACKAGE [PACKAGE [...]]",
+ "Description:",
+ " Merge HII package files into a single HII Package List.",
+ "Options:",
+ " -rc FileName write output to PE/COFF Resource Script file",
+ " -hii FileName write output to binary Package List file",
+ " -g GUID use GUID for the HII Package List Guid",
+ "",
+ "PACKAGE is the raw binary HII package file generated by StrGather or",
+ "VfrCompiler which named as *.hpk. For example, merge a Form package and",
+ "a String package into one HII package list:",
+ " \""UTILITY_NAME" -rc Sample.rc -hii Sample.hii \\",
+ " -g 12345678-1234-1234-1234-123456789abc Vfr.hpk Strings.hpk\"",
+ NULL
+ };
+ for (i = 0; Str[i] != NULL; i++) {
+ fprintf (stdout, "%s\n", Str[i]);
+ }
+}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
new file mode 100644
index 0000000000..ac12d760e8
--- /dev/null
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiHiiPack/Makefile
@@ -0,0 +1,71 @@
+#/*++
+#
+# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# Makefile
+#
+# Abstract:
+#
+# Makefile for building the UEFI HiiPack utility
+#
+#--*/
+
+#
+# Make sure environmental variable EDK_SOURCE is set
+#
+!IFNDEF EDK_SOURCE
+!ERROR EDK_SOURCE environmental variable not set
+!ENDIF
+
+!INCLUDE $(BUILD_DIR)\PlatformTools.env
+
+#
+# Target specific information
+#
+TARGET_NAME = HiiPack
+TARGET_SOURCE_DIR = $(EDK_TOOLS_SOURCE)\Uefi$(TARGET_NAME)
+TARGET_EXE = $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).exe
+
+OBJECTS = $(EDK_TOOLS_OUTPUT)\HiiPack.obj
+LIBS = $(LIBS) $(EDK_TOOLS_OUTPUT)\Common.lib
+
+#
+# Build targets
+#
+
+all: $(TARGET_EXE)
+
+#
+# Compile each tool source file
+#
+$(EDK_TOOLS_OUTPUT)\HiiPack.obj : $(TARGET_SOURCE_DIR)\HiiPack.c
+ $(CC) $(C_FLAGS) $(TARGET_SOURCE_DIR)\HiiPack.c /Fo$@
+
+#
+# Add Binary Build description for this tool.
+#
+
+!IF (("$(EFI_BINARY_TOOLS)" == "YES") && EXIST($(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe))
+$(TARGET_EXE): $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).exe $(TARGET_EXE) /Y
+ if exist $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb \
+ copy $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb /Y
+!ELSE
+$(TARGET_EXE) : $(OBJECTS) $(LIBS)
+ $(LINK) $(MSVS_LINK_LIBPATHS) $(L_FLAGS) $(LIBS) /out:$(TARGET_EXE) $(OBJECTS)
+!IF ("$(EFI_BINARY_BUILD)" == "YES")
+ if not exist $(EFI_PLATFORM_BIN)\Tools mkdir $(EFI_PLATFORM_BIN)\Tools
+ if exist $(TARGET_EXE) copy $(TARGET_EXE) $(EFI_PLATFORM_BIN)\tools\$(TARGET_NAME).exe /Y
+ if exist $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb \
+ copy $(EDK_TOOLS_OUTPUT)\$(TARGET_NAME).pdb $(EFI_PLATFORM_BIN)\Tools\$(TARGET_NAME).pdb /Y
+!ENDIF
+!ENDIF
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
index dd5bdb45ed..535a265046 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
- StrGather.c
+ StrGather.c
Abstract:
@@ -29,7 +29,8 @@ Abstract:
#include "StrGather.h"
#include "StringDB.h"
-#define TOOL_VERSION "0.31"
+#define UTILITY_NAME "StrGather"
+#define UTILITY_VERSION "v1.2"
typedef UINT16 WCHAR;
@@ -48,6 +49,15 @@ typedef UINT16 WCHAR;
#define MODE_DUMP 3
//
+// This is how we invoke the C preprocessor on the source file
+// to resolve #if, #else, etc.
+//
+#define PREPROCESSOR_COMMAND "cl"
+#define PREPROCESSOR_OPTIONS "/nologo /EP /TC /DSTRGATHER"
+#define PREPROCESS_TEMP_FILE_EXTENSION ".ii"
+#define PREPROCESS_OUTPUT_FILE_EXTENSION ".iii"
+
+//
// We keep a linked list of these for the source files we process
//
typedef struct _SOURCE_FILE {
@@ -83,6 +93,8 @@ static struct {
TEXT_STRING_LIST *LastIndirectionFileName;
TEXT_STRING_LIST *DatabaseFileName;
TEXT_STRING_LIST *LastDatabaseFileName;
+ TEXT_STRING_LIST *PreprocessFlags;
+ TEXT_STRING_LIST *LastPreprocessFlags;
WCHAR_STRING_LIST *Language;
WCHAR_STRING_LIST *LastLanguage;
WCHAR_MATCHING_STRING_LIST *IndirectionList; // from indirection file(s)
@@ -94,6 +106,8 @@ static struct {
BOOLEAN IgnoreNotFound; // when scanning
BOOLEAN VerboseScan;
BOOLEAN UnquotedStrings; // -uqs option
+ BOOLEAN Preprocess; // -ppflag option
+ INT8 PreprocessFileName[MAX_PATH];
INT8 OutputDatabaseFileName[MAX_PATH];
INT8 StringHFileName[MAX_PATH];
INT8 StringCFileName[MAX_PATH]; // output .C filename
@@ -294,11 +308,6 @@ ParseIndirectionFiles (
TEXT_STRING_LIST *Files
);
-STATUS
-StringDBCreateHiiExportPack (
- INT8 *OutputFileName
- );
-
int
main (
int Argc,
@@ -309,7 +318,7 @@ main (
Routine Description:
Call the routine to parse the command-line options, then process the file.
-
+
Arguments:
Argc - Standard C main() argc and argv.
@@ -319,12 +328,12 @@ Returns:
0 if successful
nonzero otherwise
-
+
--*/
{
STATUS Status;
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
//
// Process the command-line arguments
//
@@ -374,12 +383,12 @@ Returns:
if ((mGlobals.OutputDependencyFptr = fopen (mGlobals.OutputDependencyFileName, "w")) == NULL) {
Error (NULL, 0, 0, mGlobals.OutputDependencyFileName, "failed to open output dependency file");
goto Finish;
- }
+ }
}
Status = ProcessIncludeFile (&mGlobals.SourceFiles, NULL);
if (mGlobals.OutputDependencyFptr != NULL) {
fclose (mGlobals.OutputDependencyFptr);
- }
+ }
if (Status != STATUS_SUCCESS) {
goto Finish;
}
@@ -401,7 +410,8 @@ Returns:
if ((mGlobals.StringCFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
Status = StringDBDumpCStrings (
mGlobals.BaseName,
- mGlobals.StringCFileName
+ mGlobals.StringCFileName,
+ mGlobals.Language
);
if (Status != EFI_SUCCESS) {
goto Finish;
@@ -418,7 +428,7 @@ Returns:
// Dump the string data as HII binary string pack if requested
//
if ((mGlobals.HiiExportPackFileName[0] != 0) && (GetUtilityStatus () < STATUS_ERROR)) {
- StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName);
+ StringDBCreateHiiExportPack (mGlobals.HiiExportPackFileName, mGlobals.Language);
}
//
// Always update the database if no errors and not in dump mode. If they specified -od
@@ -457,7 +467,7 @@ ProcessIncludeFile (
Routine Description:
Given a source file, open the file and parse it
-
+
Arguments:
SourceFile - name of file to parse
@@ -466,7 +476,7 @@ Arguments:
Returns:
Standard status.
-
+
--*/
{
static UINT32 NestDepth = 0;
@@ -513,18 +523,18 @@ Returns:
goto Finish;
}
}
-
+
//
- // Output the dependency
+ // Output the dependency
//
if (mGlobals.OutputDependencyFptr != NULL) {
- fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
+ fprintf (mGlobals.OutputDependencyFptr, "%s : %s\n", mGlobals.DatabaseFileName->Str, FoundFileName);
//
// Add pseudo target to avoid incremental build failure when the file is deleted
//
- fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
+ fprintf (mGlobals.OutputDependencyFptr, "%s : \n", FoundFileName);
}
-
+
//
// Process the file found
//
@@ -695,13 +705,13 @@ PreprocessFile (
Routine Description:
Preprocess a file to replace all carriage returns with NULLs so
we can print lines from the file to the screen.
-
+
Arguments:
SourceFile - structure that we use to keep track of an input file.
Returns:
Nothing.
-
+
--*/
{
BOOLEAN InComment;
@@ -1736,7 +1746,7 @@ FindFile (
// Put the path and filename together
//
if (strlen (List->Str) + strlen (FileName) + 1 > FoundFileNameLen) {
- Error (PROGRAM_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
+ Error (UTILITY_NAME, 0, 0, NULL, "internal error - cannot concatenate path+filename");
return NULL;
}
//
@@ -1770,6 +1780,9 @@ ProcessArgs (
)
{
TEXT_STRING_LIST *NewList;
+ char *Cptr;
+ char *Cptr2;
+
//
// Clear our globals
//
@@ -1836,7 +1849,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing include path");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing include path");
return STATUS_ERROR;
}
//
@@ -1846,7 +1859,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1854,7 +1867,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1879,7 +1892,7 @@ ProcessArgs (
// Indirection file -- check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing indirection file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing indirection file name");
return STATUS_ERROR;
}
//
@@ -1889,7 +1902,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1897,7 +1910,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1920,13 +1933,13 @@ ProcessArgs (
// Check for one more arg (the database file name)
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database file name");
return STATUS_ERROR;
}
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1934,7 +1947,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 1);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -1957,14 +1970,14 @@ ProcessArgs (
// which we can dump our database.
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing database dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing database dump output file name");
return STATUS_ERROR;
}
if (mGlobals.DumpUFileName[0] == 0) {
strcpy (mGlobals.DumpUFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-ou option already specified with '%s'", mGlobals.DumpUFileName);
return STATUS_ERROR;
}
@@ -1975,14 +1988,14 @@ ProcessArgs (
// -hpk option to create an HII export pack of the input database file
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing raw string data dump output file name");
return STATUS_ERROR;
}
if (mGlobals.HiiExportPackFileName[0] == 0) {
strcpy (mGlobals.HiiExportPackFileName, Argv[1]);
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
+ Error (UTILITY_NAME, 0, 0, Argv[1], "-or option already specified with '%s'", mGlobals.HiiExportPackFileName);
return STATUS_ERROR;
}
@@ -2006,7 +2019,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output C filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output C filename");
return STATUS_ERROR;
}
@@ -2018,7 +2031,7 @@ ProcessArgs (
// check for one more arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing base name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing base name");
Usage ();
return STATUS_ERROR;
}
@@ -2031,7 +2044,7 @@ ProcessArgs (
// -oh to specify output .h defines file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output .h filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output .h filename");
return STATUS_ERROR;
}
@@ -2043,7 +2056,7 @@ ProcessArgs (
// -dep to specify output dependency file name
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output dependency filename");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output dependency filename");
return STATUS_ERROR;
}
@@ -2055,7 +2068,7 @@ ProcessArgs (
// -skipext to skip scanning of files with certain filename extensions
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing filename extension");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing filename extension");
return STATUS_ERROR;
}
//
@@ -2065,7 +2078,7 @@ ProcessArgs (
//
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -2073,7 +2086,7 @@ ProcessArgs (
NewList->Str = malloc (strlen (Argv[1]) + 2);
if (NewList->Str == NULL) {
free (NewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
@@ -2097,10 +2110,10 @@ ProcessArgs (
Argv++;
} else if (_stricmp (Argv[0], "-lang") == 0) {
//
- // "-lang eng" or "-lang spa+cat" to only output certain languages
+ // "-lang zh-Hans" or "-lang en-US" to only output certain languages
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing language name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing language name");
Usage ();
return STATUS_ERROR;
}
@@ -2116,18 +2129,78 @@ ProcessArgs (
// Output database file name -- check for another arg
//
if ((Argc <= 1) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output database file name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output database file name");
return STATUS_ERROR;
}
strcpy (mGlobals.OutputDatabaseFileName, Argv[1]);
Argv++;
Argc--;
+ } else if (_stricmp (Argv[0], "-ppflag") == 0) {
+ //
+ // -ppflag "Preprocess flags" -- check for another arg
+ //
+ if ((Argc <= 1) || (Argv[1][0] == '-')) {
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing preprocess flags");
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Allocate memory for a new list element, fill it in, and
+ // add it to our list of preprocess flag.
+ //
+ NewList = malloc (sizeof (TEXT_STRING_LIST));
+ if (NewList == NULL) {
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
+ return STATUS_ERROR;
+ }
+
+ memset ((char *) NewList, 0, sizeof (TEXT_STRING_LIST));
+ NewList->Str = malloc (strlen (Argv[1]) * 2 + 1);
+ if (NewList->Str == NULL) {
+ free (NewList);
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Convert '"' to '\"' in preprocess flag
+ //
+ Cptr = Argv[1];
+ Cptr2 = NewList->Str;
+ if (*Cptr == '"') {
+ *Cptr2++ = '\\';
+ *Cptr2++ = '"';
+ Cptr++;
+ }
+ while (*Cptr != '\0') {
+ if ((*Cptr == '"') && (*(Cptr - 1) != '\\')) {
+ *Cptr2++ = '\\';
+ }
+ *Cptr2++ = *Cptr++;
+ }
+ *Cptr2 = '\0';
+
+ //
+ // Add it to our linked list
+ //
+ if (mGlobals.PreprocessFlags == NULL) {
+ mGlobals.PreprocessFlags = NewList;
+ } else {
+ mGlobals.LastPreprocessFlags->Next = NewList;
+ }
+ mGlobals.LastPreprocessFlags = NewList;
+
+ mGlobals.Preprocess = TRUE;
+
+ Argv++;
+ Argc--;
} else {
//
// Unrecognized arg
//
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
Usage ();
return STATUS_ERROR;
}
@@ -2174,7 +2247,15 @@ ProcessArgs (
//
if (mGlobals.Mode == MODE_SCAN) {
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify at least one source file to scan with -scan");
+ Usage ();
+ return STATUS_ERROR;
+ }
+ //
+ // If -ppflag is specified, -oh should also be specified for preprocess
+ //
+ if (mGlobals.Preprocess && (mGlobals.StringHFileName[0] == 0)) {
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify string defines file name to preprocess before scan");
Usage ();
return STATUS_ERROR;
}
@@ -2184,14 +2265,14 @@ ProcessArgs (
while (Argc > 0) {
NewList = malloc (sizeof (TEXT_STRING_LIST));
if (NewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
memset (NewList, 0, sizeof (TEXT_STRING_LIST));
NewList->Str = (UINT8 *) malloc (strlen (Argv[0]) + 1);
if (NewList->Str == NULL) {
- Error (PROGRAM_NAME, 0, 0, "memory allocation failure", NULL);
+ Error (UTILITY_NAME, 0, 0, "memory allocation failure", NULL);
return STATUS_ERROR;
}
@@ -2211,7 +2292,7 @@ ProcessArgs (
// Parse mode -- must specify an input unicode file name
//
if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify input unicode string file name with -parse");
Usage ();
return STATUS_ERROR;
}
@@ -2222,7 +2303,7 @@ ProcessArgs (
return STATUS_SUCCESS;
}
//
-// Found "-lang eng,spa+cat" on the command line. Parse the
+// Found "-lang zh-Hans;en-US" on the command line. Parse the
// language list and save the setting for later processing.
//
static
@@ -2231,69 +2312,33 @@ AddCommandLineLanguage (
IN INT8 *Language
)
{
+ char Separator[] = ";";
+ char *Token;
WCHAR_STRING_LIST *WNewList;
- WCHAR *From;
- WCHAR *To;
+
//
// Keep processing the input string until we find the end.
//
- while (*Language) {
- //
- // Allocate memory for a new list element, fill it in, and
- // add it to our list.
- //
+ Token = strtok (Language, Separator);
+ while (Token != NULL) {
WNewList = MALLOC (sizeof (WCHAR_STRING_LIST));
if (WNewList == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
-
- memset ((char *) WNewList, 0, sizeof (WCHAR_STRING_LIST));
- WNewList->Str = malloc ((strlen (Language) + 1) * sizeof (WCHAR));
+ WNewList->Next = NULL;
+ WNewList->Str = MALLOC ((strlen (Token) + 1) * sizeof (WCHAR));
if (WNewList->Str == NULL) {
free (WNewList);
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
- //
- // Copy it as unicode to our new structure. Then remove the
- // plus signs in it, and verify each language name is 3 characters
- // long. If we find a comma, then we're done with this group, so
- // break out.
- //
#ifdef USE_VC8
- swprintf (WNewList->Str, (strlen (Language) + 1) * sizeof (WCHAR), L"%S", Language);
+ swprintf (WNewList->Str, (strlen (Token) + 1) * sizeof (WCHAR), L"%S", Token);
#else
- swprintf (WNewList->Str, L"%S", Language);
+ swprintf (WNewList->Str, L"%S", Token);
#endif
- From = To = WNewList->Str;
- while (*From) {
- if (*From == L',') {
- break;
- }
- if ((wcslen (From) < LANGUAGE_IDENTIFIER_NAME_LEN) ||
- (
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != 0) &&
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != UNICODE_PLUS_SIGN) &&
- (From[LANGUAGE_IDENTIFIER_NAME_LEN] != L',')
- )
- ) {
- Error (PROGRAM_NAME, 0, 0, Language, "invalid format for language name on command line");
- FREE (WNewList->Str);
- FREE (WNewList);
- return STATUS_ERROR;
- }
-
- wcsncpy (To, From, LANGUAGE_IDENTIFIER_NAME_LEN);
- To += LANGUAGE_IDENTIFIER_NAME_LEN;
- From += LANGUAGE_IDENTIFIER_NAME_LEN;
- if (*From == L'+') {
- From++;
- }
- }
-
- *To = 0;
//
// Add it to our linked list
//
@@ -2304,17 +2349,7 @@ AddCommandLineLanguage (
}
mGlobals.LastLanguage = WNewList;
- //
- // Skip to next entry (comma-separated list)
- //
- while (*Language) {
- if (*Language == L',') {
- Language++;
- break;
- }
-
- Language++;
- }
+ Token = strtok (NULL, Separator);
}
return STATUS_SUCCESS;
@@ -2450,6 +2485,166 @@ Done:
}
static
+INTN
+PreprocessSourceFile (
+ UINT8 *SourceFileName
+ )
+{
+ char *Cptr;
+ FILE *InFptr;
+ FILE *OutFptr;
+ UINT32 CmdLen;
+ char *PreProcessCmd;
+ char BaseName[MAX_PATH];
+ char TempFileName[MAX_PATH];
+ char SourceFileDir[MAX_PATH];
+ char Line[MAX_LINE_LEN];
+ TEXT_STRING_LIST *List;
+ char InsertLine[] = "#undef STRING_TOKEN\n";
+ int Status;
+
+ //
+ // Check whehter source file exist
+ //
+ InFptr = fopen (SourceFileName, "r");
+ if (InFptr == NULL) {
+ Error (NULL, 0, 0, SourceFileName, "failed to open input file for scanning");
+ return STATUS_ERROR;
+ }
+
+ //
+ // Get source file directory
+ //
+ strcpy (SourceFileDir, SourceFileName);
+ Cptr = strrchr (SourceFileDir, '\\');
+ if (Cptr != NULL) {
+ *Cptr = '\0';
+ }
+
+ //
+ // Generate preprocess output file name
+ //
+ strcpy (BaseName, mGlobals.OutputDatabaseFileName);
+ Cptr = strrchr (BaseName, '\\');
+ if (Cptr != NULL) {
+ *++Cptr = '\0';
+ }
+
+ Cptr = strrchr (SourceFileName, '\\');
+ if (Cptr != NULL) {
+ Cptr++;
+ }
+ strcat (BaseName, Cptr);
+
+ Cptr = strrchr (BaseName, '.');
+ if (Cptr != NULL) {
+ *Cptr = '\0';
+ }
+
+ strcpy (mGlobals.PreprocessFileName, BaseName);
+ strcat (mGlobals.PreprocessFileName, PREPROCESS_OUTPUT_FILE_EXTENSION);
+
+ strcpy (TempFileName, BaseName);
+ strcat (TempFileName, PREPROCESS_TEMP_FILE_EXTENSION);
+
+ //
+ // Insert "#undef STRING_TOKEN" after each line of "#include ...", so as to
+ // preserve the STRING_TOKEN() for scanning after preprocess
+ //
+ OutFptr = fopen (TempFileName, "w");
+ if (OutFptr == NULL) {
+ Error (NULL, 0, 0, TempFileName, "failed to open file for write");
+ fclose (InFptr);
+ return STATUS_ERROR;
+ }
+ while (fgets (Line, MAX_LINE_LEN, InFptr) != NULL) {
+ fputs (Line, OutFptr);
+ Cptr = Line;
+
+ //
+ // Skip leading blank space
+ //
+ while (*Cptr == ' ' || *Cptr == '\t') {
+ Cptr++;
+ }
+
+ if (*Cptr == '#' && strncmp (Cptr + 1, "include", 7) == 0){
+ fputs (InsertLine, OutFptr);
+ }
+ }
+ fclose (InFptr);
+ fclose (OutFptr);
+
+ //
+ // Prepare preprocess command
+ //
+ CmdLen = 1;
+ CmdLen += strlen (PREPROCESSOR_COMMAND);
+ CmdLen++;
+ CmdLen += strlen (PREPROCESSOR_OPTIONS);
+ CmdLen++;
+
+ //
+ // "-I SourceFileDir "
+ //
+ CmdLen += strlen (SourceFileDir);
+ CmdLen += 4;
+
+ List = mGlobals.PreprocessFlags;
+ while (List != NULL) {
+ CmdLen += strlen (List->Str);
+ CmdLen++;
+
+ List = List->Next;
+ }
+
+ CmdLen += strlen (TempFileName);
+ CmdLen += 3;
+ CmdLen += strlen (mGlobals.PreprocessFileName);
+
+ PreProcessCmd = malloc (CmdLen);
+ if (PreProcessCmd == NULL) {
+ Error (NULL, 0, 0, UTILITY_NAME, "memory allocation fail (%d bytes)\n", CmdLen);
+ return STATUS_ERROR;
+ }
+
+ strcpy (PreProcessCmd, PREPROCESSOR_COMMAND);
+ strcat (PreProcessCmd, " ");
+ strcat (PreProcessCmd, PREPROCESSOR_OPTIONS);
+ strcat (PreProcessCmd, " ");
+
+
+ strcat (PreProcessCmd, "-I ");
+ strcat (PreProcessCmd, SourceFileDir);
+ strcat (PreProcessCmd, " ");
+
+ List = mGlobals.PreprocessFlags;
+ while (List != NULL) {
+ strcat (PreProcessCmd, List->Str);
+ strcat (PreProcessCmd, " ");
+
+ List = List->Next;
+ }
+
+ strcat (PreProcessCmd, TempFileName);
+ strcat (PreProcessCmd, " > ");
+ strcat (PreProcessCmd, mGlobals.PreprocessFileName);
+
+ //
+ // Preprocess the source file
+ //
+ Status = system (PreProcessCmd);
+ if (Status != 0) {
+ Error (NULL, 0, 0, PreProcessCmd, "failed to spawn C preprocessor on source file\n");
+ free (PreProcessCmd);
+ return STATUS_ERROR;
+ }
+
+ free (PreProcessCmd);
+ return STATUS_SUCCESS;
+}
+
+static
STATUS
ScanFiles (
TEXT_STRING_LIST *ScanFiles
@@ -2457,6 +2652,7 @@ ScanFiles (
{
char Line[MAX_LINE_LEN];
FILE *Fptr;
+ char *FileName;
UINT32 LineNum;
char *Cptr;
char *SavePtr;
@@ -2464,6 +2660,7 @@ ScanFiles (
char *StringTokenPos;
TEXT_STRING_LIST *SList;
BOOLEAN SkipIt;
+ BOOLEAN FileExist;
//
// Put a null-terminator at the end of the line. If we read in
@@ -2474,6 +2671,7 @@ ScanFiles (
// Process each file. If they gave us a skip extension list, then
// skip it if the extension matches.
//
+ FileExist = FALSE;
while (ScanFiles != NULL) {
SkipIt = FALSE;
for (SList = mGlobals.SkipExt; SList != NULL; SList = SList->Next) {
@@ -2493,9 +2691,36 @@ ScanFiles (
printf ("Scanning %s\n", ScanFiles->Str);
}
- Fptr = fopen (ScanFiles->Str, "r");
+ if (mGlobals.Preprocess) {
+ //
+ // Create an empty string defines file for preprocessor
+ //
+ if (!FileExist) {
+ Fptr = fopen (mGlobals.StringHFileName, "w");
+ if (Fptr == NULL) {
+ Error (NULL, 0, 0, mGlobals.StringHFileName, "failed to open file for write");
+ return STATUS_ERROR;
+ }
+
+ fclose (Fptr);
+ FileExist = TRUE;
+ }
+
+ //
+ // Preprocess using C preprocessor
+ //
+ if (PreprocessSourceFile (ScanFiles->Str) != STATUS_SUCCESS) {
+ return STATUS_ERROR;
+ }
+
+ FileName = mGlobals.PreprocessFileName;
+ } else {
+ FileName = ScanFiles->Str;
+ }
+
+ Fptr = fopen (FileName, "r");
if (Fptr == NULL) {
- Error (NULL, 0, 0, ScanFiles->Str, "failed to open input file for scanning");
+ Error (NULL, 0, 0, FileName, "failed to open input file for scanning");
return STATUS_ERROR;
}
@@ -2613,6 +2838,13 @@ ScanFiles (
ScanFiles = ScanFiles->Next;
}
+ //
+ // Remove the empty string defines file
+ //
+ if (FileExist) {
+ remove (mGlobals.StringHFileName);
+ }
+
return STATUS_SUCCESS;
}
//
@@ -2647,6 +2879,15 @@ FreeLists (
mGlobals.ScanFileName = Temp;
}
//
+ // Free up preprocess flags list
+ //
+ while (mGlobals.PreprocessFlags != NULL) {
+ Temp = mGlobals.PreprocessFlags->Next;
+ free (mGlobals.PreprocessFlags->Str);
+ free (mGlobals.PreprocessFlags);
+ mGlobals.PreprocessFlags = Temp;
+ }
+ //
// If they gave us a list of filename extensions to
// skip on scan, then free them up.
//
@@ -2767,7 +3008,7 @@ Usage (
Routine Description:
Print usage information for this utility.
-
+
Arguments:
None.
@@ -2775,51 +3016,62 @@ Arguments:
Returns:
Nothing.
-
+
--*/
{
- int Index;
- static const char *Str[] = {
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI String Gather Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
"",
- PROGRAM_NAME " version "TOOL_VERSION " -- process unicode strings file",
- " Usage: "PROGRAM_NAME " -parse {parse options} [FileNames]",
- " "PROGRAM_NAME " -scan {scan options} [FileName]",
- " "PROGRAM_NAME " -dump {dump options}",
- " Common options include:",
- " -h or -? for this help information",
- " -db Database required name of output/input database file",
- " -bn BaseName for use in the .h and .c output files",
- " Default = "DEFAULT_BASE_NAME,
- " -v for verbose output",
- " -vdbw for verbose output when writing database",
- " -vdbr for verbose output when reading database",
- " -od FileName to specify an output database file name",
- " Parse options include:",
- " -i IncludePath add IncludePath to list of search paths",
- " -dep FileName to specify an output dependency file name",
- " -newdb to not read in existing database file",
- " -uqs to indicate that unquoted strings are used",
- " FileNames name of one or more unicode files to parse",
- " Scan options include:",
- " -scan scan text file(s) for STRING_TOKEN() usage",
- " -skipext .ext to skip scan of files with .ext filename extension",
- " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
- " found in the database",
- " FileNames one or more files to scan",
- " Dump options include:",
- " -oc FileName write string data to FileName",
- " -oh FileName write string defines to FileName",
- " -ou FileName dump database to unicode file FileName",
- " -lang Lang only dump for the language 'Lang'",
- " -if FileName to specify an indirection file",
- " -hpk FileName to create an HII export pack of the strings",
+ "Usage:",
+ " "UTILITY_NAME" -parse [OPTION] FILE",
+ " "UTILITY_NAME" -scan [OPTION] FILE",
+ " "UTILITY_NAME" -dump [OPTION]",
+ "Description:",
+ " Process unicode strings file.",
+ "Common options include:",
+ " -h or -? for this help information",
+ " -db Database required name of output/input database file",
+ " -bn BaseName for use in the .h and .c output files",
+ " Default = "DEFAULT_BASE_NAME,
+ " -v for verbose output",
+ " -vdbw for verbose output when writing database",
+ " -vdbr for verbose output when reading database",
+ " -od FileName to specify an output database file name",
+ "Parse options include:",
+ " -i IncludePath add IncludePath to list of search paths",
+ " -dep FileName to specify an output dependency file name",
+ " -newdb to not read in existing database file",
+ " -uqs to indicate that unquoted strings are used",
+ " FileNames name of one or more unicode files to parse",
+ "Scan options include:",
+ " -scan scan text file(s) for STRING_TOKEN() usage",
+ " -skipext .ext to skip scan of files with .ext filename extension",
+ " -ppflag \"Flags\" to specify the C preprocessor flags",
+ " -oh FileName to specify string defines file name for preprocessor",
+ " -ignorenotfound ignore if a given STRING_TOKEN(STR) is not ",
+ " found in the database",
+ " FileNames one or more files to scan",
+ "Dump options include:",
+ " -oc FileName write string data to FileName",
+ " -oh FileName write string defines to FileName",
+ " -ou FileName dump database to unicode file FileName",
+ " -lang Lang only dump for the language 'Lang'",
+ " use ';' to separate multiple languages",
+ " -if FileName to specify an indirection file",
+ " -hpk FileName to create an HII export pack of the strings",
"",
- " The expected process is to parse a unicode string file to create an initial",
- " database of string identifier names and string definitions. Then text files",
- " should be scanned for STRING_TOKEN() usages, and the referenced",
- " strings will be tagged as used in the database. After all files have been",
- " scanned, then the database should be dumped to create the necessary output",
- " files.",
+ "The expected process is to parse a unicode string file to create an initial",
+ "database of string identifier names and string definitions. Then text files",
+ "should be scanned for STRING_TOKEN() usages, and the referenced",
+ "strings will be tagged as used in the database. After all files have been",
+ "scanned, then the database should be dumped to create the necessary output",
+ "files.",
"",
NULL
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
index c45fe28552..4ab20d9359 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StrGather.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -25,8 +25,6 @@ Abstract:
#define MALLOC(size) malloc (size)
#define FREE(ptr) do { if ((ptr) != NULL) { free (ptr); } } while (0)
-#define PROGRAM_NAME "StrGather"
-
typedef CHAR16 WCHAR;
#define UNICODE_TO_ASCII(w) (INT8) ((w) & 0xFF)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
index 563204bab9..eaa15ad763 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -2559,13 +2559,15 @@ ExportPackOut:
STATUS
StringDBCreateHiiExportPack (
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
- FILE *File = NULL;
- LANGUAGE_LIST *Lang = NULL;
- EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr = NULL;
- SPkgBlkBuffer *BlkList = NULL;
+ FILE *File;
+ LANGUAGE_LIST *Lang;
+ EFI_HII_STRING_PACKAGE_HDR *StrPkgHdr;
+ SPkgBlkBuffer *BlkList;
+ WCHAR_STRING_LIST *LOIPtr;
if (FileName == NULL) {
return STATUS_ERROR;
@@ -2577,18 +2579,26 @@ StringDBCreateHiiExportPack (
}
for (Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
- if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
- fclose (File);
- return STATUS_SUCCESS;
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
+ break;
+ }
}
- StrPkgWriteHdrBinary (File, StrPkgHdr);
- StrPkgWriteBlkListBinary (File, BlkList);
+ if ((LanguagesOfInterest == NULL) ||
+ (LanguagesOfInterest != NULL && LOIPtr != NULL)) {
+ if (StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr, &BlkList) != STATUS_SUCCESS) {
+ fclose (File);
+ return STATUS_SUCCESS;
+ }
- StrPkgHdrFree (StrPkgHdr);
- StrPkgBlkBufferListFree (BlkList);
- }
+ StrPkgWriteHdrBinary (File, StrPkgHdr);
+ StrPkgWriteBlkListBinary (File, BlkList);
+ StrPkgHdrFree (StrPkgHdr);
+ StrPkgBlkBufferListFree (BlkList);
+ }
+ }
fclose (File);
return STATUS_SUCCESS;
}
@@ -2605,16 +2615,18 @@ static const char *gSourceFileHeader[] = {
STATUS
StringDBDumpCStrings (
INT8 *BaseName,
- INT8 *FileName
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterest
)
{
EFI_STATUS Status;
- FILE *File = NULL;
- LANGUAGE_LIST *Lang = NULL;
- EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr = NULL;
- SPkgBlkBuffer **BlkList = NULL;
+ FILE *File;
+ LANGUAGE_LIST *Lang;
+ EFI_HII_STRING_PACKAGE_HDR **StrPkgHdr;
+ SPkgBlkBuffer **BlkList;
UINT32 Index;
- UINT32 LangNumber = 0;
+ UINT32 LangNumber;
+ WCHAR_STRING_LIST *LOIPtr;
if ((BaseName == NULL) || (FileName == NULL)) {
return STATUS_ERROR;
@@ -2631,14 +2643,36 @@ StringDBDumpCStrings (
BlkList = (SPkgBlkBuffer **) malloc (sizeof (SPkgBlkBuffer *) * LangNumber);
for (Index = 0; Index < LangNumber; Index++) {
StrPkgHdr[Index] = NULL;
- BlkList[Index] = NULL;
+ BlkList[Index] = NULL;
}
- for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
- Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
- if (EFI_ERROR(Status)) {
- return Status;
+ for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next) {
+ for (LOIPtr = LanguagesOfInterest; LOIPtr != NULL; LOIPtr = LOIPtr->Next) {
+ if (wcscmp (LOIPtr->Str, Lang->LanguageName) == 0) {
+ break;
+ }
}
+ if ((LanguagesOfInterest == NULL) ||
+ (LanguagesOfInterest != NULL && LOIPtr != NULL)) {
+ Status = StringDBGenStrPkgHdrAndBlkList(Lang, &StrPkgHdr[Index], &BlkList[Index]);
+ Index++;
+ if (EFI_ERROR(Status)) {
+ free (StrPkgHdr);
+ free (BlkList);
+ return STATUS_ERROR;
+ }
+ }
+ }
+
+ //
+ // Update LangNumber after filter
+ //
+ LangNumber = Index;
+
+ if (LangNumber == 0) {
+ free (StrPkgHdr);
+ free (BlkList);
+ return STATUS_SUCCESS;
}
if ((File = fopen (FileName, "w")) == NULL) {
@@ -2657,11 +2691,9 @@ StringDBDumpCStrings (
//
StrPkgWirteArrayLength (File, LangNumber, StrPkgHdr);
- for (Index = 0, Lang = mDBData.LanguageList; Lang != NULL; Lang = Lang->Next, Index++) {
- if (StrPkgHdr[Index] != NULL) {
- StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
- StrPkgWriteBlkListCFile (File, BlkList[Index], (Lang->Next == NULL) ? TRUE : FALSE);
- }
+ for (Index = 0; Index < LangNumber; Index++) {
+ StrPkgWriteHdrCFile (File, StrPkgHdr[Index]);
+ StrPkgWriteBlkListCFile (File, BlkList[Index], (Index == LangNumber - 1) ? TRUE : FALSE);
StrPkgHdrFree (StrPkgHdr[Index]);
StrPkgBlkBufferListFree (BlkList[Index]);
@@ -2670,5 +2702,7 @@ StringDBDumpCStrings (
fprintf (File, "\n};\n");
fclose (File);
+ free (StrPkgHdr);
+ free (BlkList);
return STATUS_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
index 9e4088bcf8..d98b5b71cc 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiStrGather/StringDB.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -134,11 +134,13 @@ typedef struct _SPkgBlkBuffer {
void
StringDBConstructor (
void
- );
+ )
+;
void
StringDBDestructor (
void
- );
+ )
+;
STATUS
StringDBAddString (
@@ -148,12 +150,14 @@ StringDBAddString (
WCHAR *String,
BOOLEAN Format,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBSetScope (
WCHAR *Scope
- );
+ )
+;
#define STRING_FLAGS_REFERENCED 0x0001 // if referenced somewhere
#define STRING_FLAGS_UNDEFINED 0x0002 // if we added it for padding purposes
@@ -167,72 +171,92 @@ StringDBAddStringIdentifier (
WCHAR *StringIdentifier,
UINT16 *NewId,
UINT16 Flags
- );
+ )
+;
STATUS
StringDBReadDatabase (
INT8 *DBFileName,
BOOLEAN IgnoreIfNotExist,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBWriteDatabase (
INT8 *DBFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBDumpDatabase (
INT8 *DBFileName,
INT8 *OutputFileName,
BOOLEAN Verbose
- );
+ )
+;
STATUS
StringDBAddLanguage (
WCHAR *LanguageName,
WCHAR *PrintableLanguageName,
WCHAR *SecondaryLanguageList
- );
+ )
+;
STATUS
StringDBAddSecondaryLanguage (
WCHAR *LanguageName,
WCHAR *SecondaryLanguageList
- );
+ )
+;
STATUS
StringDBDumpCStrings (
INT8 *BaseName,
- INT8 *FileName
- );
+ INT8 *FileName,
+ WCHAR_STRING_LIST *LanguagesOfInterests
+ )
+;
+
+STATUS
+StringDBCreateHiiExportPack (
+ INT8 *OutputFileName,
+ WCHAR_STRING_LIST *LanguagesOfInterests
+ )
+;
STATUS
StringDBDumpStringDefines (
INT8 *FileName,
INT8 *BaseName
- );
+ )
+;
STATUS
StringDBSetCurrentLanguage (
WCHAR *LanguageName
- );
+ )
+;
STATUS
StringDBSetStringReferenced (
INT8 *StringIdentifierName,
BOOLEAN IgnoreNotFound
- );
+ )
+;
void
StringDBFormatString (
WCHAR *String
- );
+ )
+;
LANGUAGE_LIST *
StringDBFindLanguageList (
WCHAR *LanguageName
- );
+ )
+;
#endif // #ifndef _STRING_DB_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
index 55830c9907..b4a849db7b 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/EfiVfr.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -15,8 +15,6 @@ Module Name:
Abstract:
- Defines and prototypes for the UEFI VFR compiler internal use.
-
--*/
#ifndef _EFIVFR_H_
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
index 6adef8a41b..2972e1692a 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrCompiler.cpp
+ VfrCompiler.cpp
Abstract:
@@ -41,7 +41,7 @@ CVfrCompiler::IS_RUN_STATUS (
VOID
CVfrCompiler::OptionInitialization (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -57,6 +57,7 @@ CVfrCompiler::OptionInitialization (
mOptions.PreprocessorOutputFileName[0] = '\0';
mOptions.VfrBaseFileName[0] = '\0';
mOptions.IncludePaths = NULL;
+ mOptions.SkipCPreprocessor = FALSE;
mOptions.CPreprocessorOptions = NULL;
for (Index = 1; (Index < Argc) && (Argv[Index][0] == '-'); Index++) {
@@ -70,7 +71,7 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-i") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -i - missing path argument\n", PROGRAM_NAME);
+ printf ("%s -i - missing path argument\n", UTILITY_NAME);
goto Fail;
}
@@ -78,30 +79,33 @@ CVfrCompiler::OptionInitialization (
} else if (_stricmp(Argv[Index], "-od") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing output directory name\n", PROGRAM_NAME);
+ printf ("%s -od - missing output directory name\n", UTILITY_NAME);
goto Fail;
}
strcpy (mOptions.OutputDirectory, Argv[Index]);
+ strcat (mOptions.OutputDirectory, "\\");
} else if (_stricmp(Argv[Index], "-ibin") == 0) {
mOptions.CreateIfrPkgFile = TRUE;
} else if (_stricmp(Argv[Index], "-nostrings") == 0) {
+ } else if (_stricmp(Argv[Index], "-nopp") == 0) {
+ mOptions.SkipCPreprocessor = TRUE;
} else if (_stricmp(Argv[Index], "-ppflag") == 0) {
Index++;
if ((Index >= Argc) || (Argv[Index][0] == '-')) {
- printf ("%s -od - missing C-preprocessor argument\n", PROGRAM_NAME);
+ printf ("%s -od - missing C-preprocessor argument\n", UTILITY_NAME);
goto Fail;
}
AppendCPreprocessorOptions (Argv[Index]);
} else {
- printf ("%s unrecognized option %s\n", PROGRAM_NAME, Argv[Index]);
+ printf ("%s unrecognized option %s\n", UTILITY_NAME, Argv[Index]);
Usage ();
goto Fail;
}
}
if (Index != Argc - 1) {
- printf ("%s must specify VFR file name", PROGRAM_NAME);
+ printf ("%s must specify VFR file name\n", UTILITY_NAME);
Usage ();
goto Fail;
} else {
@@ -140,7 +144,7 @@ Fail:
if (mOptions.IncludePaths != NULL) {
delete mOptions.IncludePaths;
mOptions.IncludePaths = NULL;
- }
+ }
if (mOptions.CPreprocessorOptions != NULL) {
delete mOptions.CPreprocessorOptions;
mOptions.CPreprocessorOptions = NULL;
@@ -161,7 +165,7 @@ CVfrCompiler::AppendIncludePath (
}
IncludePaths = new INT8[Len];
if (IncludePaths == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
IncludePaths[0] = '\0';
@@ -190,7 +194,7 @@ CVfrCompiler::AppendCPreprocessorOptions (
}
Opt = new INT8[Len];
if (Opt == NULL) {
- printf ("%s memory allocation failure\n", PROGRAM_NAME);
+ printf ("%s memory allocation failure\n", UTILITY_NAME);
return;
}
Opt[0] = 0;
@@ -217,7 +221,11 @@ CVfrCompiler::SetBaseFileName (
}
pFileName = mOptions.VfrFileName;
- while ((pPath = strchr (pFileName, '\\')) != NULL) {
+ while (
+ ((pPath = strchr (pFileName, '\\')) != NULL) ||
+ ((pPath = strchr (pFileName, '/')) != NULL)
+ )
+ {
pFileName = pPath + 1;
}
@@ -300,7 +308,7 @@ CVfrCompiler::SetRecordListFileName (
}
CVfrCompiler::CVfrCompiler (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
@@ -333,35 +341,40 @@ CVfrCompiler::~CVfrCompiler (
SET_RUN_STATUS(STATUS_DEAD);
}
-VOID
+VOID
CVfrCompiler::Usage (
VOID
)
{
- UINT32 Index;
- CONST INT8 *Help[] = {
- " ",
- "VfrCompile version " VFR_COMPILER_VERSION,
- " ",
- " Usage: VfrCompile {options} [VfrFile]",
- " ",
- " where options include:",
- " -? or -h prints this help",
- " -l create an output IFR listing file",
- " -i IncPath add IncPath to the search path for VFR included files",
- " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
- " -ibin create an IFR HII pack file"
- " -ppflag C-preprocessor argument",
- " where parameters include:",
- " VfrFile name of the input VFR script file",
- " ",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel UEFI VFR Compiler Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] VFRFILE",
+ "Description:",
+ " Compile VFRFILE.",
+ "Options:",
+ " -? or -h print this help",
+ " -l create an output IFR listing file",
+ " -i IncPath add IncPath to the search path for VFR included files",
+ " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
+ " -ibin create an IFR HII pack file",
+ " -ppflag CFlags pass Flags as C-preprocessor-flag",
+ " -v or -version print version information",
NULL
- };
- for (Index = 0; Help[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Help[Index]);
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
+
VOID
CVfrCompiler::PreProcess (
VOID
@@ -375,8 +388,12 @@ CVfrCompiler::PreProcess (
goto Fail;
}
+ if (mOptions.SkipCPreprocessor == TRUE) {
+ goto Out;
+ }
+
if ((pVfrFile = fopen (mOptions.VfrFileName, "r")) == NULL) {
- printf ("%s could not open input VFR file - %s\n", PROGRAM_NAME, mOptions.VfrFileName);
+ printf ("%s could not open input VFR file - %s\n", UTILITY_NAME, mOptions.VfrFileName);
goto Fail;
}
fclose (pVfrFile);
@@ -392,7 +409,7 @@ CVfrCompiler::PreProcess (
PreProcessCmd = new INT8[CmdLen + 10];
if (PreProcessCmd == NULL) {
- printf ("%s could not allocate memory\n", PROGRAM_NAME);
+ printf ("%s could not allocate memory\n", UTILITY_NAME);
goto Fail;
}
strcpy (PreProcessCmd, mPreProcessCmd), strcat (PreProcessCmd, " ");
@@ -407,11 +424,13 @@ CVfrCompiler::PreProcess (
strcat (PreProcessCmd, mOptions.PreprocessorOutputFileName);
if (system (PreProcessCmd) != 0) {
- printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", PROGRAM_NAME, PreProcessCmd);
+ printf ("%s failed to spawn C preprocessor on VFR file \n\t - %s\n", UTILITY_NAME, PreProcessCmd);
goto Fail;
}
delete PreProcessCmd;
+
+Out:
SET_RUN_STATUS (STATUS_PREPROCESSED);
return;
@@ -429,22 +448,27 @@ CVfrCompiler::Compile (
VOID
)
{
- FILE *VfrFile = NULL;
+ FILE *pInFile = NULL;
+ INT8 *InFileName = NULL;
if (!IS_RUN_STATUS(STATUS_PREPROCESSED)) {
goto Fail;
}
- if ((VfrFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
+ gCVfrErrorHandle.SetInputFile (InFileName);
+
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input file - %s\n", UTILITY_NAME, InFileName);
goto Fail;
}
- if (VfrParserStart (VfrFile) != 0) {
+ if (VfrParserStart (pInFile) != 0) {
goto Fail;
}
- fclose (VfrFile);
+ fclose (pInFile);
if (gCFormPkg.HavePendingUnassigned () == TRUE) {
gCFormPkg.PendingAssignPrintAll ();
@@ -456,11 +480,11 @@ CVfrCompiler::Compile (
Fail:
if (!IS_RUN_STATUS(STATUS_DEAD)) {
- printf ("%s compile error!\n", PROGRAM_NAME);
+ printf ("%s compile error!\n", UTILITY_NAME);
SET_RUN_STATUS (STATUS_FAILED);
}
- if (VfrFile != NULL) {
- fclose (VfrFile);
+ if (pInFile != NULL) {
+ fclose (pInFile);
}
}
@@ -477,7 +501,7 @@ CVfrCompiler::GenBinary (
if (mOptions.CreateIfrPkgFile == TRUE) {
if ((pFile = fopen (mOptions.PkgOutputFileName, "wb")) == NULL) {
- printf ("can not open PkgFileName\n", mOptions.PkgOutputFileName);
+ printf ("can not open %s\n", mOptions.PkgOutputFileName);
goto Fail;
}
if (gCFormPkg.BuildPkg (pFile) != VFR_RETURN_SUCCESS) {
@@ -548,27 +572,30 @@ CVfrCompiler::GenRecordListFile (
VOID
)
{
- FILE *pInFile = NULL;
- FILE *pOutFile = NULL;
+ INT8 *InFileName = NULL;
+ FILE *pInFile = NULL;
+ FILE *pOutFile = NULL;
INT8 LineBuf[MAX_LINE_LEN];
UINT32 LineNo;
+ InFileName = (mOptions.SkipCPreprocessor == TRUE) ? mOptions.VfrFileName : mOptions.PreprocessorOutputFileName;
+
if (mOptions.CreateRecordListFile == TRUE) {
- if ((mOptions.PreprocessorOutputFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
+ if ((InFileName[0] == '\0') || (mOptions.RecordListFile[0] == '\0')) {
return;
}
- if ((pInFile = fopen (mOptions.PreprocessorOutputFileName, "r")) == NULL) {
- printf ("%s failed to open input VFR preprocessor output file - %s\n", PROGRAM_NAME, mOptions.PreprocessorOutputFileName);
+ if ((pInFile = fopen (InFileName, "r")) == NULL) {
+ printf ("%s failed to open input VFR preprocessor output file - %s\n", UTILITY_NAME, InFileName);
return;
}
if ((pOutFile = fopen (mOptions.RecordListFile, "w")) == NULL) {
- printf ("%s failed to open record list file for writing - %s\n", PROGRAM_NAME, mOptions.RecordListFile);
+ printf ("%s failed to open record list file for writing - %s\n", UTILITY_NAME, mOptions.RecordListFile);
goto Err1;
}
- fprintf (pOutFile, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (pOutFile, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
LineNo = 0;
while (!feof (pInFile)) {
if (fgets (LineBuf, MAX_LINE_LEN, pInFile) != NULL) {
@@ -590,7 +617,7 @@ Err1:
INT32
main (
- IN INT32 Argc,
+ IN INT32 Argc,
IN INT8 **Argv
)
{
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
index 0410f84252..bc487f88ba 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrCompiler.h
@@ -1,17 +1,17 @@
/*++
-Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
-
+
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrCompiler.h
+ VfrCompiler.h
Abstract:
@@ -26,8 +26,8 @@ Abstract:
#include "VfrFormPkg.h"
#include "VfrUtilityLib.h"
-#define PROGRAM_NAME "VfrCompile"
-#define VFR_COMPILER_VERSION "UEFI 2.1"
+#define UTILITY_NAME "VfrCompile"
+#define UTILITY_VERSION "v1.1"
//
// This is how we invoke the C preprocessor on the VFR source file
@@ -56,6 +56,7 @@ typedef struct {
INT8 PreprocessorOutputFileName[MAX_PATH];
INT8 VfrBaseFileName[MAX_PATH]; // name of input VFR file with no path or extension
INT8 *IncludePaths;
+ bool SkipCPreprocessor;
INT8 *CPreprocessorOptions;
} OPTIONS;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
index 4a366136bf..d6fc7cf909 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrError.cpp
+ VfrError.cpp
Abstract:
@@ -25,33 +25,36 @@ Abstract:
static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
{ VFR_RETURN_SUCCESS, NULL },
{ VFR_RETURN_ERROR_SKIPED, NULL },
- { VFR_RETURN_FATAL_ERROR, "fatal error!!" },
-
- { VFR_RETURN_MISMATCHED, "unexpected token" },
- { VFR_RETURN_INVALID_PARAMETER, "Invalid parameter" },
- { VFR_RETURN_OUT_FOR_RESOURCES, "system out of memory" },
- { VFR_RETURN_UNSUPPORTED, "unsupported" },
- { VFR_RETURN_REDEFINED, "already defined" },
- { VFR_RETURN_FORMID_REDEFINED, "form id already defined" },
- { VFR_RETURN_QUESTIONID_REDEFINED, "question id already defined" },
- { 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_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" },
- { VFR_RETURN_GET_NVVARSTORE_ERROR, "get name value varstore error" },
- { VFR_RETURN_QVAR_REUSE, "variable reused by more than one question" },
- { VFR_RETURN_FLAGS_UNSUPPORTED, "flags unsupported" },
- { VFR_RETURN_ERROR_ARRARY_NUM, "array number error" },
- { VFR_RETURN_DATA_STRING_ERROR, "data field string error or not support"},
- { VFR_RETURN_CODEUNDEFINED, "Undefined Error Code" }
+ { VFR_RETURN_FATAL_ERROR, ": fatal error!!" },
+
+ { VFR_RETURN_MISMATCHED, ": unexpected token" },
+ { VFR_RETURN_INVALID_PARAMETER, ": invalid parameter" },
+ { VFR_RETURN_OUT_FOR_RESOURCES, ": system out of memory" },
+ { VFR_RETURN_UNSUPPORTED, ": unsupported" },
+ { VFR_RETURN_REDEFINED, ": already defined" },
+ { VFR_RETURN_FORMID_REDEFINED, ": form id already defined" },
+ { VFR_RETURN_QUESTIONID_REDEFINED, ": question id already defined" },
+ { 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_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" },
+ { VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },
+ { VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },
+ { VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },
+ { VFR_RETURN_ERROR_ARRARY_NUM, ": array number error" },
+ { VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
+ { VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
+ { VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},
+ { VFR_RETURN_CODEUNDEFINED, ": undefined Error Code" }
};
CVfrErrorHandle::CVfrErrorHandle (
VOID
)
{
+ mInputFileName = NULL;
mScopeRecordListHead = NULL;
mScopeRecordListTail = NULL;
mVfrErrorHandleTable = VFR_ERROR_HANDLE_TABLE;
@@ -63,6 +66,10 @@ CVfrErrorHandle::~CVfrErrorHandle (
{
SVfrFileScopeRecord *pNode = NULL;
+ if (mInputFileName != NULL) {
+ delete mInputFileName;
+ }
+
while (mScopeRecordListHead != NULL) {
pNode = mScopeRecordListHead;
mScopeRecordListHead = mScopeRecordListHead->mNext;
@@ -74,8 +81,19 @@ CVfrErrorHandle::~CVfrErrorHandle (
mVfrErrorHandleTable = NULL;
}
+VOID
+CVfrErrorHandle::SetInputFile (
+ IN INT8 *InputFile
+ )
+{
+ if (InputFile != NULL) {
+ mInputFileName = new INT8[strlen(InputFile) + 1];
+ strcpy (mInputFileName, InputFile);
+ }
+}
+
SVfrFileScopeRecord::SVfrFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 LineNum
)
{
@@ -116,7 +134,7 @@ SVfrFileScopeRecord::~SVfrFileScopeRecord (
VOID
CVfrErrorHandle::ParseFileScopeRecord (
- IN INT8 *Record,
+ IN INT8 *Record,
IN UINT32 WholeScopeLine
)
{
@@ -155,6 +173,15 @@ CVfrErrorHandle::GetFileNameLineNum (
*FileName = NULL;
*FileLine = 0xFFFFFFFF;
+ //
+ // Some errors occur before scope record list been built.
+ //
+ if (mScopeRecordListHead == NULL) {
+ *FileLine = LineNum;
+ *FileName = mInputFileName;
+ return ;
+ }
+
for (pNode = mScopeRecordListHead; pNode->mNext != NULL; pNode = pNode->mNext) {
if ((LineNum > pNode->mWholeScopeLine) && (pNode->mNext->mWholeScopeLine > LineNum)) {
*FileName = pNode->mFileName;
@@ -168,9 +195,10 @@ CVfrErrorHandle::GetFileNameLineNum (
}
VOID
-CVfrErrorHandle::PrintError (
+CVfrErrorHandle::PrintMsg (
IN UINT32 LineNum,
IN INT8 *TokName,
+ IN INT8 *MsgType,
IN INT8 *ErrorMsg
)
{
@@ -178,7 +206,7 @@ CVfrErrorHandle::PrintError (
UINT32 FileLine;
GetFileNameLineNum (LineNum, &FileName, &FileLine);
- printf ("%s line %d: error %s %s\n", FileName, FileLine, TokName, ErrorMsg);
+ printf ("%s line %d: %s %s %s\n", FileName, FileLine, MsgType, TokName, ErrorMsg);
}
UINT8
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
index 3becd9b6e1..8c0e4c9a47 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrError.h
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrError.h
+ VfrError.h
Abstract:
@@ -45,6 +45,8 @@ typedef enum {
VFR_RETURN_FLAGS_UNSUPPORTED,
VFR_RETURN_ERROR_ARRARY_NUM,
VFR_RETURN_DATA_STRING_ERROR,
+ VFR_RETURN_DEFAULT_VALUE_REDEFINED,
+ VFR_RETURN_CONSTANT_ONLY,
VFR_RETURN_CODEUNDEFINED
} EFI_VFR_RETURN_CODE;
@@ -65,6 +67,7 @@ struct SVfrFileScopeRecord {
class CVfrErrorHandle {
private:
+ INT8 *mInputFileName;
SVFR_ERROR_HANDLE *mVfrErrorHandleTable;
SVfrFileScopeRecord *mScopeRecordListHead;
SVfrFileScopeRecord *mScopeRecordListTail;
@@ -73,10 +76,11 @@ public:
CVfrErrorHandle (VOID);
~CVfrErrorHandle (VOID);
+ VOID SetInputFile (IN INT8 *);
VOID ParseFileScopeRecord (IN INT8 *, IN UINT32);
VOID GetFileNameLineNum (IN UINT32, OUT INT8 **, OUT UINT32 *);
UINT8 HandleError (IN EFI_VFR_RETURN_CODE, IN UINT32 LineNum = 0, IN INT8 *TokName = "\0");
- VOID PrintError (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *ErrorMsg = "\0");
+ VOID PrintMsg (IN UINT32 LineNum = 0, IN INT8 *TokName = "\0", IN INT8 *MsgType = "Error", IN INT8 *ErrorMsg = "\0");
};
#define CHECK_ERROR_RETURN(f, v) do { EFI_VFR_RETURN_CODE r; if ((r = (f)) != (v)) { return r; } } while (0)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
index ddae865498..50398c6317 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.cpp
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrFormPkg.cpp
+ VfrFormPkg.cpp
Abstract:
@@ -25,25 +25,34 @@ Abstract:
*/
SPendingAssign::SPendingAssign (
- IN INT8 *Key,
- IN VOID *Addr,
- IN UINT32 Len,
- IN UINT32 LineNo
+ IN INT8 *Key,
+ IN VOID *Addr,
+ IN UINT32 Len,
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
+ mKey = NULL;
+ mAddr = Addr;
+ mLen = Len;
+ mFlag = PENDING;
+ mLineNo = LineNo;
+ mMsg = NULL;
+ mNext = NULL;
+
if (Key != NULL) {
mKey = new INT8[strlen (Key) + 1];
if (mKey != NULL) {
strcpy (mKey, Key);
}
- } else {
- mKey = NULL;
}
- mAddr = Addr;
- mLen = Len;
- mFlag = PENDING;
- mLineNo = LineNo;
- mNext = NULL;
+
+ if (Msg != NULL) {
+ mMsg = new INT8[strlen (Msg) + 1];
+ if (mMsg != NULL) {
+ strcpy (mMsg, Msg);
+ }
+ }
}
SPendingAssign::~SPendingAssign (
@@ -56,12 +65,15 @@ SPendingAssign::~SPendingAssign (
mAddr = NULL;
mLen = 0;
mLineNo = 0;
+ if (mMsg != NULL) {
+ delete mMsg;
+ }
mNext = NULL;
}
VOID
SPendingAssign::SetAddrAndLen (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 LineNo
)
{
@@ -71,7 +83,7 @@ SPendingAssign::SetAddrAndLen (
VOID
SPendingAssign::AssignValue (
- IN VOID *Addr,
+ IN VOID *Addr,
IN UINT32 Len
)
{
@@ -227,7 +239,7 @@ CFormPkg::Close (
UINT32
CFormPkg::Read (
- IN CHAR8 *Buffer,
+ IN CHAR8 *Buffer,
IN UINT32 Size
)
{
@@ -270,7 +282,7 @@ CFormPkg::BuildPkgHdr (
return VFR_RETURN_OUT_FOR_RESOURCES;
}
- (*PkgHdr)->Type = EFI_HII_PACKAGE_FORM;
+ (*PkgHdr)->Type = EFI_HII_PACKAGE_FORMS;
(*PkgHdr)->Length = mPkgLength + sizeof (EFI_HII_PACKAGE_HEADER);
return VFR_RETURN_SUCCESS;
}
@@ -357,7 +369,7 @@ CFormPkg::_WRITE_PKG_END (
#define BYTES_PRE_LINE 0x10
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CFormPkg::GenCFile (
IN INT8 *BaseName,
IN FILE *pFile
@@ -407,15 +419,16 @@ CFormPkg::GenCFile (
EFI_VFR_RETURN_CODE
CFormPkg::AssignPending (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen,
- IN UINT32 LineNo
+ IN UINT32 LineNo,
+ IN INT8 *Msg
)
{
SPendingAssign *pNew;
- pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo);
+ pNew = new SPendingAssign (Key, ValAddr, ValLen, LineNo, Msg);
if (pNew == NULL) {
return VFR_RETURN_OUT_FOR_RESOURCES;
}
@@ -427,8 +440,8 @@ CFormPkg::AssignPending (
VOID
CFormPkg::DoPendingAssign (
- IN INT8 *Key,
- IN VOID *ValAddr,
+ IN INT8 *Key,
+ IN VOID *ValAddr,
IN UINT32 ValLen
)
{
@@ -470,7 +483,7 @@ CFormPkg::PendingAssignPrintAll (
for (pNode = PendingAssignList; pNode != NULL; pNode = pNode->mNext) {
if (pNode->mFlag == PENDING) {
- gCVfrErrorHandle.PrintError (pNode->mLineNo, pNode->mKey, "can not assign value because not defined");
+ gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", pNode->mMsg);
}
}
}
@@ -492,10 +505,7 @@ SIfrRecord::~SIfrRecord (
VOID
)
{
- if (mIfrBinBuf != NULL) {
- delete mIfrBinBuf;
- mIfrBinBuf = NULL;
- }
+ mIfrBinBuf = NULL;
mLineNo = 0xFFFFFFFF;
mOffset = 0xFFFFFFFF;
mBinBufLen = 0;
@@ -537,8 +547,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
return NULL;
}
- for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
- (Idx != RecordIdx) && (pNode != NULL);
+ for (Idx = (EFI_IFR_RECORDINFO_IDX_START + 1), pNode = mIfrRecordListHead;
+ (Idx != RecordIdx) && (pNode != NULL);
Idx++, pNode = pNode->mNext)
;
@@ -547,8 +557,8 @@ CIfrRecordInfoDB::GetRecordInfoFromIdx (
UINT32
CIfrRecordInfoDB::IfrRecordRegister (
- IN UINT32 LineNo,
- IN CHAR8 *IfrBinBuf,
+ IN UINT32 LineNo,
+ IN CHAR8 *IfrBinBuf,
IN UINT8 BinBufLen,
IN UINT32 Offset
)
@@ -577,7 +587,7 @@ CIfrRecordInfoDB::IfrRecordRegister (
VOID
CIfrRecordInfoDB::IfrRecordInfoUpdate (
- IN UINT32 RecordIdx,
+ IN UINT32 RecordIdx,
IN UINT32 LineNo,
IN CHAR8 *BinBuf,
IN UINT8 BinBufLen,
@@ -585,23 +595,25 @@ CIfrRecordInfoDB::IfrRecordInfoUpdate (
)
{
SIfrRecord *pNode;
+ SIfrRecord *Prev;
if ((pNode = GetRecordInfoFromIdx (RecordIdx)) == NULL) {
return;
}
+ if (LineNo == 0) {
+ //
+ // Line number is not specified explicitly, try to use line number of previous opcode
+ //
+ Prev = GetRecordInfoFromIdx (RecordIdx - 1);
+ if (Prev != NULL) {
+ LineNo = Prev->mLineNo;
+ }
+ }
pNode->mLineNo = LineNo;
pNode->mOffset = Offset;
pNode->mBinBufLen = BinBufLen;
- if (BinBuf != NULL) {
- if (pNode->mIfrBinBuf != NULL) {
- delete pNode->mIfrBinBuf;
- }
- pNode->mIfrBinBuf = new CHAR8[BinBufLen];
- if (pNode->mIfrBinBuf != NULL) {
- memcpy (pNode->mIfrBinBuf, BinBuf, BinBufLen);
- }
- }
+ pNode->mIfrBinBuf = BinBuf;
}
VOID
@@ -626,7 +638,7 @@ CIfrRecordInfoDB::IfrRecordOutput (
fprintf (File, ">%08X: ", pNode->mOffset);
if (pNode->mIfrBinBuf != NULL) {
for (Index = 0; Index < pNode->mBinBufLen; Index++) {
- fprintf (File, "%02X ", pNode->mIfrBinBuf[Index]);
+ fprintf (File, "%02X ", (UINT8)(pNode->mIfrBinBuf[Index]));
}
}
fprintf (File, "\n");
@@ -650,6 +662,7 @@ CIfrObj::_EMIT_PENDING_OBJ (
if (mObjBinBuf != NULL) {
delete mObjBinBuf;
+ mObjBinBuf = ObjBinBuf;
}
}
@@ -689,7 +702,7 @@ static struct {
{ sizeof (EFI_IFR_DATE), 1 }, // EFI_IFR_DATE_OP
{ sizeof (EFI_IFR_TIME), 1 }, // EFI_IFR_TIME_OP
{ sizeof (EFI_IFR_STRING), 1 }, // EFI_IFR_STRING_OP
- { sizeof (EFI_IFR_REFRESH), 1 }, // EFI_IFR_REFRESH_OP
+ { sizeof (EFI_IFR_REFRESH), 0 }, // EFI_IFR_REFRESH_OP
{ sizeof (EFI_IFR_DISABLE_IF), 1 }, // EFI_IFR_DISABLE_IF_OP - 0x1E
{ 0, 0 }, // 0x1F
{ sizeof (EFI_IFR_TO_LOWER), 0 }, // EFI_IFR_TO_LOWER_OP - 0x20
@@ -829,10 +842,10 @@ CIfrObj::~CIfrObj (
UINT8 gScopeCount = 0;
CIfrOpHeader::CIfrOpHeader (
- IN UINT8 OpCode,
+ IN UINT8 OpCode,
IN VOID *StartAddr,
- IN UINT8 Length
- ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
+ IN UINT8 Length
+ ) : mHeader ((EFI_IFR_OP_HEADER *)StartAddr)
{
mHeader->OpCode = OpCode;
mHeader->Length = (Length == 0) ? gOpcodeSizesScopeTable[OpCode].mSize : Length;
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
index b890b27a25..c8e7d98756 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrFormPkg.h
@@ -11,7 +11,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
-VfrFormPkg.h
+ VfrFormPkg.h
Abstract:
@@ -25,6 +25,8 @@ Abstract:
#include "VfrError.h"
#include "VfrUtilityLib.h"
+#define NO_QST_REFED "no question refered"
+
/*
* The functions below are used for flags setting
*/
@@ -75,9 +77,10 @@ struct SPendingAssign {
UINT32 mLen;
ASSIGN_FLAG mFlag;
UINT32 mLineNo;
+ INT8 *mMsg;
struct SPendingAssign *mNext;
- SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ SPendingAssign (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *);
~SPendingAssign ();
VOID SetAddrAndLen (IN VOID *, IN UINT32);
@@ -126,7 +129,7 @@ public:
EFI_VFR_RETURN_CODE GenCFile (IN INT8 *, IN FILE *);
public:
- EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32);
+ EFI_VFR_RETURN_CODE AssignPending (IN INT8 *, IN VOID *, IN UINT32, IN UINT32, IN INT8 *Msg = NULL);
VOID DoPendingAssign (IN INT8 *, IN VOID *, IN UINT32);
bool HavePendingUnassigned (VOID);
VOID PendingAssignPrintAll (VOID);
@@ -368,48 +371,159 @@ public:
}
};
-static CIfrQuestionHeader *gCurrentQuestion = 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
*/
@@ -418,10 +532,11 @@ private:
EFI_IFR_FORM_SET *mFormSet;
public:
- CIfrFormSet () : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet),
- CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header) {
+ CIfrFormSet (UINT8 Size) : CIfrObj (EFI_IFR_FORM_SET_OP, (CHAR8 **)&mFormSet, Size),
+ CIfrOpHeader (EFI_IFR_FORM_SET_OP, &mFormSet->Header, Size) {
mFormSet->Help = EFI_STRING_ID_INVALID;
mFormSet->FormSetTitle = EFI_STRING_ID_INVALID;
+ mFormSet->Flags = 0;
memset (&mFormSet->Guid, 0, sizeof (EFI_GUID));
}
@@ -436,6 +551,17 @@ public:
VOID SetHelp (IN EFI_STRING_ID Help) {
mFormSet->Help = Help;
}
+
+ VOID SetClassGuid (IN EFI_GUID *Guid) {
+ if (mFormSet->Flags > 0 && ExpendObjBin(sizeof(EFI_GUID))) {
+ IncLength (sizeof (EFI_GUID));
+ }
+ memcpy (&(mFormSet->ClassGuid[mFormSet->Flags++]), Guid, sizeof (EFI_GUID));
+ }
+
+ UINT8 GetFlags() {
+ return mFormSet->Flags;
+ }
};
class CIfrEnd : public CIfrObj, public CIfrOpHeader {
@@ -817,7 +943,7 @@ private:
public:
CIfrResetButton () : CIfrObj (EFI_IFR_RESET_BUTTON_OP, (CHAR8 **)&mResetButton),
CIfrOpHeader (EFI_IFR_RESET_BUTTON_OP, &mResetButton->Header),
- CIfrStatementHeader (&mResetButton->Question.Header) {
+ CIfrStatementHeader (&mResetButton->Statement) {
mResetButton->DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
}
@@ -834,7 +960,7 @@ public:
CIfrCheckBox () : CIfrObj (EFI_IFR_CHECKBOX_OP, (CHAR8 **)&mCheckBox),
CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header),
CIfrQuestionHeader (&mCheckBox->Question) {
- mCheckBox->Flags = EFI_IFR_CHECKBOX_DEFAULT;
+ mCheckBox->Flags = 0;
gCurrentQuestion = this;
}
@@ -860,6 +986,10 @@ public:
return _FLAGS_ZERO (LFlags) ? VFR_RETURN_SUCCESS : VFR_RETURN_FLAGS_UNSUPPORTED;
}
+
+ UINT8 GetFlags (VOID) {
+ return mCheckBox->Flags;
+ }
};
class CIfrAction : public CIfrObj, public CIfrOpHeader, public CIfrQuestionHeader {
@@ -929,13 +1059,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;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrNumeric () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -965,11 +1097,13 @@ public:
CIfrQuestionHeader (&mOneOf->Question),
CIfrMinMaxStepData (&mOneOf->data) {
mOneOf->Flags = 0;
- gCurrentQuestion = this;
+ gCurrentQuestion = this;
+ gCurrentMinMaxData = this;
}
~CIfrOneOf () {
- gCurrentQuestion = NULL;
+ gCurrentQuestion = NULL;
+ gCurrentMinMaxData = NULL;
}
EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) {
@@ -1428,7 +1562,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId1 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId1), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1440,7 +1574,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdId->QuestionId2 = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdId->QuestionId2), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
@@ -1466,7 +1600,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVal->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVal->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1498,7 +1632,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mEqIdVList->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mEqIdVList->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
@@ -1540,7 +1674,7 @@ public:
if (QuestionId != EFI_QUESTION_ID_INVALID) {
mQuestionRef1->QuestionId = QuestionId;
} else {
- gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo);
+ gCFormPkg.AssignPending (VarIdStr, (VOID *)(&mQuestionRef1->QuestionId), sizeof (EFI_QUESTION_ID), LineNo, NO_QST_REFED);
}
}
};
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
index 1a31b2e41d..85060c8e84 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrSyntax.g
@@ -29,7 +29,7 @@ Abstract:
#include "stdio.h"
#include "PBlackBox.h"
#include "DLexerBase.h"
-#include "VfrLexer.h"
+#include "VfrLexer.h"
#include "AToken.h"
#define GET_LINENO(Obj) ((Obj)->getLine())
@@ -42,9 +42,9 @@ class CVfrDLGLexer : public VfrLexer
{
public:
CVfrDLGLexer (DLGFileInput *F) : VfrLexer (F) {};
- INT32 errstd (char *Text)
- {
- printf ("unrecognized input '%s'\n", Text);
+ INT32 errstd (char *Text)
+ {
+ printf ("unrecognized input '%s'\n", Text);
}
};
@@ -70,7 +70,7 @@ VfrParserStart (
// is not preceeded with a backslash.
//
#lexclass QUOTED_STRING
-#token TheString "~[\"]*\"" << mode (START); >>
+#token TheString "~[\"]*\"" << mode (START); >>
//
// Define a lexclass for skipping over C++ style comments
@@ -92,7 +92,7 @@ VfrParserStart (
//
// Skip whitespace
//
-#token "[\ \t]" << skip (); >>
+#token "[\ \t]" << skip (); >>
//
// Skip over newlines, but count them
@@ -128,13 +128,12 @@ VfrParserStart (
#token Title("title") "title"
#token FormId("formid") "formid"
#token OneOf("oneof") "oneof"
-#token EndoneOf("endoneof") "endoneof"
+#token EndOneOf("endoneof") "endoneof"
#token Prompt("prompt") "prompt"
#token OrderedList("orderedlist") "orderedlist"
#token MaxContainers("maxcontainers") "maxcontainers"
#token EndList("endlist") "endlist"
#token EndForm("endform") "endform"
-#token EndOneOf("endoneof") "endoneof"
#token Form("form") "form"
#token Subtitle("subtitle") "subtitle"
#token Help("help") "help"
@@ -157,26 +156,27 @@ VfrParserStart (
#token Inventory("inventory") "inventory"
#token NonNvDataMap("_NON_NV_DATA_MAP") "_NON_NV_DATA_MAP"
#token Struct("struct") "struct"
+#token Boolean("BOOLEAN") "BOOLEAN"
#token Uint64("UINT64") "UINT64"
#token Uint32("UINT32") "UINT32"
#token Uint16("UINT16") "UINT16"
#token Char16("CHAR16") "CHAR16"
#token Uint8("UINT8") "UINT8"
-#token GUID("guid") "guid"
+#token Uuid("guid") "guid"
#token CheckBox("checkbox") "checkbox"
#token EndCheckBox("endcheckbox") "endcheckbox"
#token Numeric("numeric") "numeric"
-#token EndNumeric("endnumeric") "endnumeric"
-#token Minimum("minimum") "minimum"
-#token Maximum("maximum") "maximum"
-#token STEP("step") "step"
-#token Default("default") "default"
-#token Password("password") "password"
-#token EndPassword("endpassword") "endpassword"
+#token EndNumeric("endnumeric") "endnumeric"
+#token Minimum("minimum") "minimum"
+#token Maximum("maximum") "maximum"
+#token STEP("step") "step"
+#token Default("default") "default"
+#token Password("password") "password"
+#token EndPassword("endpassword") "endpassword"
#token String("string") "string"
-#token EndString("endstring") "endstring"
-#token MinSize("minsize") "minsize"
-#token MaxSize("maxsize") "maxsize"
+#token EndString("endstring") "endstring"
+#token MinSize("minsize") "minsize"
+#token MaxSize("maxsize") "maxsize"
#token Encoding("encoding") "encoding"
#token SuppressIf("suppressif") "suppressif"
#token DisableIf("disableif") "disableif"
@@ -198,6 +198,7 @@ VfrParserStart (
#token OptionOnlyFlag("OPTIONS_ONLY") "OPTIONS_ONLY"
#token Class("class") "class"
#token Subclass("subclass") "subclass"
+#token ClassGuid("classguid") "classguid"
#token TypeDef("typedef") "typedef"
#token Restore("restore") "restore"
#token Save("save") "save"
@@ -253,36 +254,71 @@ VfrParserStart (
//
vfrProgram > [UINT8 Return] :
- << mParserStatus = 0; >>
+ <<
+ mParserStatus = 0;
+ mConstantOnlyInExpression = FALSE;
+ >>
(
- (
- "\#pragma" "pack" "\(" A:Number "\)" << _PCATCH(mCVfrVarDataTypeDB.Pack (_STOU32(A->getText())), A); >>
- vfrDataStructDefinition
- "\#pragma" "pack" "\(" "\)" << mCVfrVarDataTypeDB.UnPack (); >>
- )
- |
- (
- vfrDataStructDefinition
- )
+ vfrPragmaPackDefinition
+ | vfrDataStructDefinition
)*
- vfrFromSetDefinition
+ vfrFormSetDefinition
<< $Return = mParserStatus; >>
;
-//*****************************************************************************
-//
-// the syntax of data struct definition
-//
+pragmaPackShowDef :
+ L:"show" << mCVfrVarDataTypeDB.Pack (L->getLine(), VFR_PACK_SHOW); >>
+ ;
+
+pragmaPackStackDef :
+ <<
+ UINT32 LineNum;
+ UINT8 PackAction;
+ INT8 *Identifier = NULL;
+ UINT32 PackNumber = DEFAULT_PACK_ALIGN;
+ >>
+ (
+ L1:"push" << LineNum = L1->getLine(); PackAction = VFR_PACK_PUSH; >>
+ | L2:"pop" << LineNum = L2->getLine(); PackAction = VFR_PACK_POP; >>
+ )
+ {
+ "," ID:StringIdentifier << Identifier = ID->getText(); >>
+ }
+ {
+ "," N:Number << PackAction |= VFR_PACK_ASSIGN; PackNumber = _STOU32(N->getText()); >>
+ }
+ << mCVfrVarDataTypeDB.Pack (LineNum, PackAction, Identifier, PackNumber); >>
+ ;
+
+pragmaPackNumber :
+ <<
+ UINT32 LineNum;
+ UINT32 PackNumber = DEFAULT_PACK_ALIGN;
+ >>
+ N:Number << LineNum = N->getLine(); PackNumber = _STOU32(N->getText()); >>
+ << mCVfrVarDataTypeDB.Pack (LineNum, VFR_PACK_ASSIGN, NULL, PackNumber); >>
+ ;
+
+vfrPragmaPackDefinition :
+ "\#pragma" "pack" "\("
+ {
+ pragmaPackShowDef
+ | pragmaPackStackDef
+ | pragmaPackNumber
+ }
+ "\)"
+ ;
+
vfrDataStructDefinition :
{ TypeDef } Struct << mCVfrVarDataTypeDB.DeclareDataTypeBegin (); >>
- { NonNVDataMap }
+ { NonNvDataMap }
{
N1:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N1->getText()), N1); >>
}
- OpenBrace
+ OpenBrace
vfrDataStructFields
- CloseBrace
- {
+ CloseBrace
+ {
N2:StringIdentifier << _PCATCH(mCVfrVarDataTypeDB.SetNewTypeName (N2->getText()), N2); >>
}
";" << mCVfrVarDataTypeDB.DeclareDataTypeEnd (); >>
@@ -290,13 +326,13 @@ vfrDataStructDefinition :
vfrDataStructFields :
(
- dataStructField64 |
- dataStructField32 |
- dataStructField16 |
- dataStructField8 |
+ dataStructField64 |
+ dataStructField32 |
+ dataStructField16 |
+ dataStructField8 |
dataStructFieldBool |
dataStructFieldString |
- dataStructFieldDate |
+ dataStructFieldDate |
dataStructFieldTime |
dataStructFieldUser
)*
@@ -304,8 +340,8 @@ vfrDataStructFields :
dataStructField64 :
<< UINT32 ArrayNum = 0; >>
- "UINT64"
- N:StringIdentifier
+ "UINT64"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -314,8 +350,8 @@ dataStructField64 :
dataStructField32 :
<< UINT32 ArrayNum = 0; >>
- "UINT32"
- N:StringIdentifier
+ "UINT32"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -325,7 +361,7 @@ dataStructField32 :
dataStructField16 :
<< UINT32 ArrayNum = 0; >>
("UINT16" | "CHAR16")
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -335,7 +371,7 @@ dataStructField16 :
dataStructField8 :
<< UINT32 ArrayNum = 0; >>
"UINT8"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -345,7 +381,7 @@ dataStructField8 :
dataStructFieldBool :
<< UINT32 ArrayNum = 0; >>
"BOOLEAN"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -355,7 +391,7 @@ dataStructFieldBool :
dataStructFieldString :
<< UINT32 ArrayNum = 0; >>
"EFI_STRING_ID"
- N:StringIdentifier
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -364,8 +400,8 @@ dataStructFieldString :
dataStructFieldDate :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_DATE"
- N:StringIdentifier
+ "EFI_HII_DATE"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -374,8 +410,8 @@ dataStructFieldDate :
dataStructFieldTime :
<< UINT32 ArrayNum = 0; >>
- "EFI_HII_TIME"
- N:StringIdentifier
+ "EFI_HII_TIME"
+ N:StringIdentifier
{
OpenBracket I:Number CloseBracket << ArrayNum = _STOU32(I->getText()); >>
}
@@ -394,30 +430,89 @@ dataStructFieldUser :
//*****************************************************************************
//
-// the syntax of from set definition
+// the syntax of GUID definition
//
-vfrFromSetDefinition :
+guidSubDefinition [EFI_GUID &Guid] :
+ G4:Number "," G5:Number "," G6:Number "," G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
+ <<
+ Guid.Data4[0] = _STOU8(G4->getText());
+ Guid.Data4[1] = _STOU8(G5->getText());
+ Guid.Data4[2] = _STOU8(G6->getText());
+ Guid.Data4[3] = _STOU8(G7->getText());
+ Guid.Data4[4] = _STOU8(G8->getText());
+ Guid.Data4[5] = _STOU8(G9->getText());
+ Guid.Data4[6] = _STOU8(G10->getText());
+ Guid.Data4[7] = _STOU8(G11->getText());
+ >>
+ ;
+
+guidDefinition [EFI_GUID &Guid] :
+ OpenBrace
+ G1:Number "," G2:Number "," G3:Number ","
+ <<
+ Guid.Data1 = _STOU32 (G1->getText());
+ Guid.Data2 = _STOU16 (G2->getText());
+ Guid.Data3 = _STOU16 (G3->getText());
+ >>
+ (
+ OpenBrace guidSubDefinition[Guid] CloseBrace
+ | guidSubDefinition[Guid]
+ )
+ CloseBrace
+ ;
+
+//*****************************************************************************
+//
+// the syntax of form set definition
+//
+vfrFormSetDefinition :
<<
EFI_GUID Guid;
- CIfrFormSet FSObj;
- UINT16 C, SC;
+ EFI_GUID DefaultClassGuid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID;
+ EFI_GUID ClassGuids[10];
+ UINT8 ClassGuidNum = 0;
+ CIfrFormSet *FSObj = NULL;
+ UINT16 C, SC;
>>
- L:FormSet << SET_LINE_INFO (FSObj, L); >>
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- FSObj.SetGuid (&Guid);
- >>
- ","
- Title "=" "STRING_TOKEN" "\(" S1:Number "\)" "," << FSObj.SetFormSetTitle (_STOSID(S1->getText())); >>
- Help "=" "STRING_TOKEN" "\(" S2:Number "\)" "," << FSObj.SetHelp (_STOSID(S2->getText())); >>
+ L:FormSet
+ Uuid "=" guidDefinition[Guid] ","
+ Title "=" "STRING_TOKEN" "\(" S1:Number "\)" ","
+ Help "=" "STRING_TOKEN" "\(" S2:Number "\)" ","
+ {
+ ClassGuid "=" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >>
+ (
+ "\|" guidDefinition[ClassGuids[ClassGuidNum]] << ++ClassGuidNum; >>
+ )*
+ ","
+ }
+ <<
+ switch (ClassGuidNum) {
+ case 0:
+ FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
+ FSObj->SetClassGuid(&DefaultClassGuid);
+ break;
+ case 1:
+ FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET));
+ FSObj->SetClassGuid(&ClassGuids[0]);
+ break;
+ case 2:
+ FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + sizeof(EFI_GUID));
+ FSObj->SetClassGuid(&ClassGuids[0]);
+ FSObj->SetClassGuid(&ClassGuids[1]);
+ break;
+ default:
+ FSObj = new CIfrFormSet(sizeof(EFI_IFR_FORM_SET) + 2 * sizeof(EFI_GUID));
+ FSObj->SetClassGuid(&ClassGuids[0]);
+ FSObj->SetClassGuid(&ClassGuids[1]);
+ FSObj->SetClassGuid(&ClassGuids[2]);
+ break;
+ }
+
+ SET_LINE_INFO (*FSObj, L);
+ FSObj->SetGuid (&Guid);
+ FSObj->SetFormSetTitle (_STOSID(S1->getText()));
+ FSObj->SetHelp (_STOSID(S2->getText()));
+ >>
{
Class "=" classDefinition[C] "," << {CIfrClass CObj; CObj.SetClass(C);} >>
}
@@ -429,7 +524,7 @@ vfrFromSetDefinition :
//_DeclareDefaultLinearVarStore (GET_LINENO (L));
>>
vfrFormSetList
- E:EndFormSet << CRT_END_OP (E); >>
+ E:EndFormSet << CRT_END_OP (E); if (FSObj != NULL) {delete FSObj;}>>
";"
;
@@ -441,7 +536,7 @@ vfrFormSetList :
vfrStatementVarStoreEfi |
vfrStatementVarStoreNameValue |
vfrStatementDefaultStore |
- vfrStatementDisableIfFromSet
+ vfrStatementDisableIfFormSet
)*
;
@@ -452,7 +547,7 @@ vfrStatementDefaultStore :
{
"," Attribute "=" A:Number << DefaultId = _STOU16(A->getText()); >>
}
- <<
+ <<
if (mCVfrDefaultStore.DefaultIdRegistered (DefaultId) == FALSE) {
CIfrDefaultStore DSObj;
_PCATCH(mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), N->getText(), _STOSID(S->getText()), DefaultId)), D->getLine();
@@ -468,7 +563,7 @@ vfrStatementDefaultStore :
vfrStatementVarStoreLinear :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStore VSObj;
INT8 *TypeName;
UINT32 LineNum;
@@ -487,31 +582,28 @@ vfrStatementVarStoreLinear :
)
{ Key "=" Number "," } // Key is used to assign Varid in Framework VFR but no use in UEFI2.1 VFR
{
- VarId "=" ID:Number "," << VarStoreId = _STOU16(ID->getText()); >>
+ VarId "=" ID:Number "," <<
+ _PCATCH(
+ (INTN)(VarStoreId = _STOU16(ID->getText())) != 0,
+ (INTN)TRUE,
+ ID,
+ "varid 0 is not allowed."
+ );
+ >>
}
Name "=" SN:StringIdentifier ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid]
<<
_PCATCH(mCVfrDataStorage.DeclareBufferVarStore (
- SN->getText(),
- &Guid,
- &mCVfrVarDataTypeDB,
+ SN->getText(),
+ &Guid,
+ &mCVfrVarDataTypeDB,
TypeName,
VarStoreId
), LineNum);
>>
- <<
- VSObj.SetGuid (&Guid);
+ <<
+ VSObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
VSObj.SetVarStoreId (VarStoreId);
_PCATCH(mCVfrVarDataTypeDB.GetDataTypeSize(TypeName, &Size), LineNum);
@@ -534,22 +626,11 @@ vfrStatementVarStoreEfi :
<< VSEObj.SetAttributes (Attr); >>
Name "=" "STRING_TOKEN" "\(" VN:Number "\)" ","
VarSize "=" N:Number ","
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
- <<
+ Uuid "=" guidDefinition[Guid] << mCVfrDataStorage.DeclareEfiVarStore (SN->getText(), &Guid, _STOSID(VN->getText()), _STOU32(N->getText())); >>
+ <<
VSEObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSEObj.SetVarStoreId (VarStoreId);
+ VSEObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -560,7 +641,7 @@ vfrVarStoreEfiAttr [UINT32 & Attr] :
vfrStatementVarStoreNameValue :
<<
- EFI_GUID Guid;
+ EFI_GUID Guid;
CIfrVarStoreNameValue VSNVObj;
EFI_VARSTORE_ID VarStoreId;
>>
@@ -569,22 +650,11 @@ vfrStatementVarStoreNameValue :
(
Name "=" "STRING_TOKEN" "\(" N:Number "\)" "," << _PCATCH(mCVfrDataStorage.NameTableAddItem (_STOSID(N->getText())), SN); >>
)+
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
- << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
- <<
+ Uuid "=" guidDefinition[Guid] << _PCATCH(mCVfrDataStorage.DeclareNameVarStoreEnd (&Guid), SN); >>
+ <<
VSNVObj.SetGuid (&Guid);
_PCATCH(mCVfrDataStorage.GetVarStoreId(SN->getText(), &VarStoreId), SN);
- VSNVObj.SetVarStoreId (VarStoreId);
+ VSNVObj.SetVarStoreId (VarStoreId);
>>
";"
;
@@ -597,7 +667,7 @@ classDefinition[UINT16 & Class] :
<< $Class = 0; >>
validClassNames[$Class] ( "\|" validClassNames[$Class] )*
;
-
+
validClassNames[UINT16 & Class] :
ClassNonDevice << $Class |= EFI_NON_DEVICE_CLASS; >>
| ClassDiskDevice << $Class |= EFI_DISK_DEVICE_CLASS; >>
@@ -618,10 +688,13 @@ subclassDefinition[UINT16 & SubClass] :
| N:Number << $SubClass |= _STOU16(N->getText()); >>
;
-vfrStatementDisableIfFromSet :
- << CIfrDisableIf DIObj; >>
+vfrStatementDisableIfFormSet :
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
D:DisableIf << DIObj.SetLineNo(D->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrFormSetList
E:EndIf << CRT_END_OP (E); >>
";"
@@ -638,7 +711,7 @@ vfrStatementHeader[CIfrStatementHeader *SHObj] :
vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_NORMAL]:
<<
- EFI_VARSTORE_INFO Info;
+ EFI_VARSTORE_INFO Info;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *QName = NULL;
INT8 *VarIdStr = NULL;
@@ -653,10 +726,10 @@ vfrQuestionHeader[CIfrQuestionHeader & QHObj, EFI_QUESION_TYPE QType = QUESTION_
{
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "has already been used please assign another number");
>>
}
- <<
+ <<
switch (QType) {
case QUESTION_NORMAL:
mCVfrQuestionDB.RegisterQuestion (QName, VarIdStr, QId);
@@ -692,10 +765,10 @@ vfrQuestionHeaderWithNoStorage[CIfrQuestionHeader *QHObj] :
{
QuestionId "=" ID:Number "," <<
QId = _STOQID(ID->getText());
- _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
+ _PCATCH(mCVfrQuestionDB.FindQuestion (QId), VFR_RETURN_UNDEFINED, ID, "redefined quesiont ID");
>>
}
- <<
+ <<
mCVfrQuestionDB.RegisterQuestion (QName, NULL, QId);
$QHObj->SetQuestionId (QId);
>>
@@ -718,13 +791,14 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
INT8 *VarStr = NULL;
INT8 *SName = NULL;
INT8 *TName = NULL;
+ EFI_IFR_TYPE_VALUE Dummy = {0};
>>
(
SN1:StringIdentifier << SName = SN1->getText(); _STRCAT(&VarIdStr, SN1->getText()); >>
OpenBracket I1:Number CloseBracket << Idx = _STOU32(I1->getText()); _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<<
_PCATCH(mCVfrDataStorage.GetVarStoreType (SName, VarStoreType), SN1);
- _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
+ _PCATCH(mCVfrDataStorage.GetVarStoreId (SName, &$Info.mVarStoreId), SN1);
_PCATCH(mCVfrDataStorage.GetNameVarStoreInfo (&$Info, Idx), SN1);
>>
)
@@ -739,7 +813,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
_STRCAT(&VarStr, TName);
}
>>
-
+
(
"." <<
_PCATCH(((VarStoreType != EFI_VFR_VARSTORE_BUFFER) ? VFR_RETURN_EFIVARSTORE_USE_ERROR : VFR_RETURN_SUCCESS), SN2);
@@ -750,7 +824,7 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
OpenBracket I2:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I2->getText()); _STRCAT(&VarIdStr, "]"); >>
<< _STRCAT(&VarStr, "["); _STRCAT(&VarStr, I2->getText()); _STRCAT(&VarStr, "]"); >>
}
- )* <<
+ )* <<
switch (VarStoreType) {
case EFI_VFR_VARSTORE_EFI:
_PCATCH(mCVfrDataStorage.GetEfiVarStoreInfo (&$Info), SN2);
@@ -758,6 +832,19 @@ vfrStorageVarId[EFI_VARSTORE_INFO & Info, INT8 *&QuestVarIdStr] :
case EFI_VFR_VARSTORE_BUFFER:
_PCATCH(mCVfrVarDataTypeDB.GetDataFieldInfo (VarStr, $Info.mInfo.mVarOffset, $Info.mVarType, $Info.mVarTotalSize), SN2->getLine());
//_PCATCH(mCVfrDataStorage.BufferVarStoreRequestElementAdd (SName, Info), SN2);
+ _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Register (
+ SName,
+ NULL),
+ SN2->getLine());
+ _PCATCH((EFI_VFR_RETURN_CODE)gCVfrBufferConfig.Write (
+ 'a',
+ SName,
+ NULL,
+ $Info.mVarType,
+ $Info.mInfo.mVarOffset,
+ $Info.mVarTotalSize,
+ Dummy),
+ SN2->getLine());
break;
case EFI_VFR_VARSTORE_NAME:
default: break;
@@ -775,7 +862,11 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
SN1:StringIdentifier << _STRCAT(&VarIdStr, SN1->getText()); LineNo = SN1->getLine(); >>
OpenBracket I1:Number CloseBracket << _STRCAT(&VarIdStr, "["); _STRCAT(&VarIdStr, I1->getText()); _STRCAT(&VarIdStr, "]"); >>
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) {
+ _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+ }
+ >>
|
(
SN2:StringIdentifier << _STRCAT (&VarIdStr, SN2->getText()); LineNo = SN2->getLine(); >>
@@ -787,11 +878,15 @@ vfrQuestionDataFieldName [EFI_QUESTION_ID &QId, UINT32 &Mask, INT8 *&VarIdStr, U
}
)*
<< mCVfrQuestionDB.GetQuestionId (NULL, VarIdStr, $QId, $Mask); >>
- )
+ ) <<
+ if (mConstantOnlyInExpression) {
+ _PCATCH(VFR_RETURN_CONSTANT_ONLY, LineNo);
+ }
+ >>
;
vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
- N1:Number <<
+ N1:Number <<
switch ($Type) {
case EFI_IFR_TYPE_NUM_SIZE_8 :
$Value.u8 = _STOU8(N1->getText());
@@ -815,7 +910,7 @@ vfrConstantValueField[UINT8 Type] > [EFI_IFR_TYPE_VALUE Value] :
case EFI_IFR_TYPE_DATE :
default :
break;
- }
+ }
>>
| B1:True << $Value.b = TRUE; >>
| B2:False << $Value.b = FALSE; >>
@@ -845,7 +940,7 @@ vfrFormDefinition :
vfrStatementQuestions |
vfrStatementConditional |
vfrStatementLabel |
- vfrStatementBanner
+ vfrStatementBanner
// Just for framework vfr compatibility
//vfrStatementInvalid
)*
@@ -853,14 +948,17 @@ vfrFormDefinition :
";"
;
-vfrStatementRules :
- << CIfrRule RObj; >>
+vfrStatementRules :
+ <<
+ CIfrRule RObj;
+ UINT32 ExpOpCount = 0;
+ >>
R:Rule << RObj.SetLineNo(R->getLine()); >>
S1:StringIdentifier "," <<
mCVfrRulesDB.RegisterRule (S1->getText());
- RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
+ RObj.SetRuleId (mCVfrRulesDB.GetRuleId(S1->getText()));
>>
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndRule << CRT_END_OP (E); >>
";"
;
@@ -868,7 +966,7 @@ vfrStatementRules :
vfrStatementDefault :
<<
BOOLEAN IsExp = FALSE;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrDefault DObj;
EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
INT8 *VarStoreName = NULL;
@@ -877,30 +975,40 @@ vfrStatementDefault :
D:Default << DObj.SetLineNo(D->getLine()); >>
(
(
- vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); >>
- | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] ","
- << DObj.SetType (_GET_CURRQEST_DATATYPE()); DObj.SetValue(Val); >>
+ vfrStatementValue "," << IsExp = TRUE; DObj.SetScope (1); CIfrEnd EndObj1; EndObj1.SetLineNo(D->getLine()); >>
+ | "=" vfrConstantValueField[_GET_CURRQEST_DATATYPE()] > [Val] "," <<
+ 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());
+ DObj.SetValue(Val);
+ >>
)
{
DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >>
}
- <<
- _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
- _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
- if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
- _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- DefaultId,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
- Val), D->getLine());
- }
- >>
+ <<
+ _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), D->getLine());
+ _PCATCH(mCVfrDataStorage.GetVarStoreType (VarStoreName, VarStoreType), D->getLine());
+ if ((IsExp == FALSE) && (VarStoreType == EFI_VFR_VARSTORE_BUFFER)) {
+ _PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+ DefaultId,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
+ Val),
+ D->getLine()
+ );
+ }
+ >>
)
;
vfrStatementStat :
- vfrStatementSubTitle |
+ vfrStatementSubTitle |
vfrStatementStaticText |
vfrStatementCrossReference
;
@@ -932,14 +1040,18 @@ vfrStatementInvalid :
;
flagsField :
- Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
+ Number | InteractiveFlag | ManufacturingFlag | DefaultFlag |
NVAccessFlag | ResetRequiredFlag | LateCheckFlag
;
vfrStatementValue :
- << CIfrValue VObj; >>
+ <<
+ CIfrValue VObj;
+ UINT32 ExpOpCount = 0;
+ >>
V:Value << VObj.SetLineNo(V->getLine()); >>
- "=" vfrStatementExpression[0]
+ "=" vfrStatementExpression[0, ExpOpCount]
+ << { CIfrEnd EndObj; EndObj.SetLineNo(0); } >>
;
vfrStatementSubTitle :
@@ -965,7 +1077,7 @@ subtitleFlagsField [UINT8 & Flags] :
;
vfrStatementStaticText :
- <<
+ <<
UINT8 Flags = 0;
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
EFI_STRING_ID TxtTwo = EFI_STRING_ID_INVALID;
@@ -983,6 +1095,7 @@ vfrStatementStaticText :
<<
if (Flags & EFI_IFR_FLAG_CALLBACK) {
CIfrAction AObj;
+ AObj.SetLineNo (T->getLine());
mCVfrQuestionDB.RegisterQuestion (NULL, NULL, QId);
AObj.SetQuestionId (QId);
AObj.SetPrompt (_STOSID(S2->getText()));
@@ -1013,7 +1126,7 @@ vfrStatementCrossReference :
;
vfrStatementGoto :
- <<
+ <<
UINT8 RefType = 1;
EFI_STRING_ID DevPath;
EFI_GUID FSId;
@@ -1030,39 +1143,23 @@ vfrStatementGoto :
(
(
DevicePath "=" "STRING_TOKEN" "\(" P:Number "\)" ","
- FormSetGuid "="
- OpenBrace
- G11:Number "," G12:Number "," G13:Number "," G14:Number "," G15:Number "," G16:Number ","
- G17:Number "," G18:Number "," G19:Number "," G110:Number "," G111:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F1:Number ","
Question "=" QN1:Number ","
- <<
+ <<
RefType = 4;
- _CRGUID (&FSId, G11->getText (), G12->getText (), G13->getText (),
- G14->getText (), G15->getText (), G16->getText (),
- G17->getText (), G18->getText (), G19->getText (),
- G110->getText (), G111->getText ());
- DevPath = _STOSID(P->getText());
+ DevPath = _STOSID(P->getText());
FId = _STOFID(F1->getText());
QId = _STOQID(QN1->getText());
>>
)
|
(
- FormSetGuid "="
- OpenBrace
- G21:Number "," G22:Number "," G23:Number "," G24:Number "," G25:Number "," G26:Number ","
- G27:Number "," G28:Number "," G29:Number "," G210:Number "," G211:Number
- CloseBrace ","
+ FormSetGuid "=" guidDefinition[FSId] ","
FormId "=" F2:Number ","
Question "=" QN2:Number ","
<<
RefType = 3;
- _CRGUID (&FSId, G21->getText (), G22->getText (), G23->getText (),
- G24->getText (), G25->getText (), G26->getText (),
- G27->getText (), G28->getText (), G29->getText (),
- G210->getText (), G211->getText ());
FId = _STOFID(F2->getText());
QId = _STOQID(QN2->getText());
>>
@@ -1070,7 +1167,7 @@ vfrStatementGoto :
|
(
FormId "=" F3:Number "," << RefType = 2; FId = _STOFID(F3->getText()); >>
- Question "="
+ Question "="
(
QN3:StringIdentifier "," << mCVfrQuestionDB.GetQuestionId (QN3->getText (), NULL, QId, BitMask); >>
| QN4:Number "," << QId = _STOQID(QN4->getText()); >>
@@ -1078,7 +1175,7 @@ vfrStatementGoto :
)
|
(
- F4:Number "," <<
+ F4:Number "," <<
RefType = 1;
FId = _STOFID(F4->getText());
>>
@@ -1088,31 +1185,31 @@ vfrStatementGoto :
switch (RefType) {
case 4:
{
- R4Obj = new CIfrRef4;
- QHObj = R4Obj;
- R4Obj->SetLineNo(G->getLine());
- R4Obj->SetDevicePath (DevPath);
- R4Obj->SetFormSetId (FSId);
- R4Obj->SetFormId (FId);
- R4Obj->SetQuestionId (QId);
+ R4Obj = new CIfrRef4;
+ QHObj = R4Obj;
+ R4Obj->SetLineNo(G->getLine());
+ R4Obj->SetDevicePath (DevPath);
+ R4Obj->SetFormSetId (FSId);
+ R4Obj->SetFormId (FId);
+ R4Obj->SetQuestionId (QId);
break;
}
case 3:
{
- R3Obj = new CIfrRef3;
- QHObj = R3Obj;
- R3Obj->SetLineNo(G->getLine());
- R3Obj->SetFormSetId (FSId);
- R3Obj->SetFormId (FId);
- R3Obj->SetQuestionId (QId);
+ R3Obj = new CIfrRef3;
+ QHObj = R3Obj;
+ R3Obj->SetLineNo(G->getLine());
+ R3Obj->SetFormSetId (FSId);
+ R3Obj->SetFormId (FId);
+ R3Obj->SetQuestionId (QId);
break;
}
case 2:
{
- R2Obj = new CIfrRef2;
- QHObj = R2Obj;
- R2Obj->SetLineNo(G->getLine());
- R2Obj->SetFormId (FId);
+ R2Obj = new CIfrRef2;
+ QHObj = R2Obj;
+ R2Obj->SetLineNo(G->getLine());
+ R2Obj->SetFormId (FId);
_PCATCH(R2Obj->SetQuestionId (QId), QN3);
break;
}
@@ -1155,12 +1252,12 @@ getStringId :
vfrStatementResetButton :
<<
- CIfrResetButton RBObj;
+ CIfrResetButton RBObj;
UINT16 DefaultId;
>>
L:ResetButton << RBObj.SetLineNo(L->getLine()); >>
- DefaultStore
- "=" N:StringIdentifier "," <<
+ DefaultStore
+ "=" N:StringIdentifier "," <<
_PCATCH(mCVfrDefaultStore.GetDefaultId (N->getText(), &DefaultId), N->getLine());
RBObj.SetDefaultId (DefaultId);
>>
@@ -1184,23 +1281,59 @@ vfrStatementBooleanType :
// prompt = STRING_TOKEN(STR_CHECK_BOX_PROMPT),
// help = STRING_TOKEN(STR_CHECK_BOX_HELP),
// flags = CHECKBOX_DEFAULT | CALLBACK,
-// default value = TRUE, defaultstore = MyDefaultStore,
+// default value = TRUE, defaultstore = MyDefaultStore,
// endcheckbox;
//
vfrStatementCheckBox :
<<
- CIfrCheckBox CBObj;
+ CIfrCheckBox CBObj;
+ EFI_IFR_TYPE_VALUE Val = {0};
+ INT8 *VarStoreName = NULL;
>>
L:CheckBox << CBObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[CBObj] ","
- { F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] "," }
+ {
+ F:FLAGS "=" vfrCheckBoxFlags[CBObj, F->getLine()] ","
+ <<
+ _PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), VFR_RETURN_SUCCESS, L, "Failed to retrieve varstore name");
+ Val.b = TRUE;
+ if (CBObj.GetFlags () & 0x01) {
+ _PCATCH(
+ mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+ EFI_HII_DEFAULT_CLASS_STANDARD,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
+ Val
+ ),
+ VFR_RETURN_SUCCESS,
+ L,
+ "No standard default storage found"
+ );
+ }
+ if (CBObj.GetFlags () & 0x02) {
+ _PCATCH(
+ mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
+ EFI_HII_DEFAULT_CLASS_MANUFACTURING,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
+ Val
+ ),
+ VFR_RETURN_SUCCESS,
+ L,
+ "No manufacturing default storage found"
+ );
+ }
+ >>
+ }
{
Key "=" KN:Number "," << AssignQuestionKey (CBObj, KN); >>
}
vfrStatementQuestionOptionList
E:EndCheckBox << CRT_END_OP (E); >>
";"
- ;
+ ;
vfrCheckBoxFlags [CIfrCheckBox & CBObj, UINT32 LineNum] :
<<
@@ -1256,7 +1389,7 @@ vfrStatementDate :
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrDate DObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Date << DObj.SetLineNo(L->getLine()); >>
(
@@ -1285,14 +1418,14 @@ vfrStatementDate :
Help "=" "STRING_TOKEN" "\(" DH:Number "\)" ","
minMaxDateStepDefault[Val.date, 2]
<<
- mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldDateQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
DObj.SetQuestionId (QId);
DObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_DATE_STORAGE_TIME);
DObj.SetPrompt (_STOSID(YP->getText()));
DObj.SetHelp (_STOSID(YH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_DATE, Val); DObj.SetLineNo (D1Y->getLine());} >>
( vfrStatementInconsistentIf )*
)
)
@@ -1307,10 +1440,10 @@ minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] :
{
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: D.Year = _STOU16(N->getText()); break;
- case 1: D.Month = _STOU8(N->getText()); break;
+ case 0: D.Year = _STOU16(N->getText()); break;
+ case 1: D.Month = _STOU8(N->getText()); break;
case 2: D.Day = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1400,18 +1533,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;
+ mCVfrVarDataTypeDB.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]
;
@@ -1420,9 +1573,9 @@ vfrStatementOneOf :
CIfrOneOf OObj;
>>
L:OneOf << OObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[OObj] ","
+ vfrQuestionHeader[OObj] "," << _PCATCH(OObj.SetFlags (OObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
{ F:FLAGS "=" vfrOneofFlagsField[OObj, F->getLine()] "," }
- {
+ {
vfrSetMinMaxStep[OObj]
}
vfrStatementQuestionOptionList
@@ -1432,11 +1585,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;
+ mCVfrVarDataTypeDB.GetDataTypeSize (_GET_CURRQEST_DATATYPE(), &DataTypeSize);
+ _GET_CURRQEST_VARTINFO().mVarTotalSize = DataTypeSize;
+ }
+ _PCATCH(OObj.SetFlags (HFlags, LFlags), LineNum);
+ >>
;
vfrStatementStringType :
@@ -1449,7 +1618,7 @@ vfrStatementString :
CIfrString SObj;
>>
L:String << SObj.SetLineNo(L->getLine()); >>
- vfrQuestionHeader[SObj] "," << _PCATCH(SObj.SetFlags (SObj.FLAGS(), _GET_CURRQEST_DATATYPE()), L->getLine()); >>
+ vfrQuestionHeader[SObj] ","
{ F:FLAGS "=" vfrStringFlagsField[SObj, F->getLine()] "," }
{
Key "=" KN:Number "," << AssignQuestionKey (SObj, KN); >>
@@ -1478,7 +1647,7 @@ stringFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
vfrStatementPassword :
<<
- CIfrPassword PObj;
+ CIfrPassword PObj;
>>
L:Password << PObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[PObj] ","
@@ -1507,12 +1676,12 @@ passwordFlagsField [UINT8 & HFlags] :
vfrStatementOrderedList :
<<
- CIfrOrderedList OLObj;
+ CIfrOrderedList OLObj;
>>
L:OrderedList << OLObj.SetLineNo(L->getLine()); >>
vfrQuestionHeader[OLObj] ","
- << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_VARSIZE()); >>
- {
+ << OLObj.SetMaxContainers ((UINT8)_GET_CURRQEST_ARRAY_SIZE()); >>
+ {
MaxContainers "=" M:Number "," << OLObj.SetMaxContainers (_STOU8(M->getText())); >>
}
{ F:FLAGS "=" vfrOrderedListFlags[OLObj, F->getLine()] }
@@ -1542,14 +1711,14 @@ vfrStatementTime :
EFI_QUESTION_ID QId = EFI_QUESTION_ID_INVALID;
INT8 *VarIdStr[3] = {NULL, };
CIfrTime TObj;
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
>>
L:Time << TObj.SetLineNo(L->getLine()); >>
(
(
vfrQuestionHeader[TObj, QUESTION_TIME] ","
{ F:FLAGS "=" vfrTimeFlags[TObj, F->getLine()] "," }
- vfrStatementDefault
+ vfrStatementQuestionOptionList
)
|
(
@@ -1571,14 +1740,14 @@ vfrStatementTime :
Help "=" "STRING_TOKEN" "\(" SH:Number "\)" ","
minMaxTimeStepDefault[Val.time, 2]
<<
- mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
+ mCVfrQuestionDB.RegisterOldTimeQuestion (VarIdStr[0], VarIdStr[1], VarIdStr[2], QId);
TObj.SetQuestionId (QId);
TObj.SetFlags (EFI_IFR_QUESTION_FLAG_DEFAULT, QF_TIME_STORAGE_TIME);
TObj.SetPrompt (_STOSID(HP->getText()));
TObj.SetHelp (_STOSID(HH->getText()));
if (VarIdStr[0] != NULL) { delete VarIdStr[0]; } if (VarIdStr[1] != NULL) { delete VarIdStr[1]; } if (VarIdStr[2] != NULL) { delete VarIdStr[2]; }
>>
- << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val);} >>
+ << {CIfrDefault DObj(EFI_HII_DEFAULT_CLASS_STANDARD, EFI_IFR_TYPE_TIME, Val); DObj.SetLineNo (T1H->getLine());} >>
)
)
E:EndTime << CRT_END_OP (E); >>
@@ -1592,10 +1761,10 @@ minMaxTimeStepDefault[EFI_HII_TIME & T, UINT8 KeyValue] :
{
"default" "=" N:Number "," <<
switch (KeyValue) {
- case 0: T.Hour = _STOU8(N->getText()); break;
- case 1: T.Minute = _STOU8(N->getText()); break;
+ case 0: T.Hour = _STOU8(N->getText()); break;
+ case 1: T.Minute = _STOU8(N->getText()); break;
case 2: T.Second = _STOU8(N->getText()); break;
- }
+ }
>>
}
;
@@ -1622,7 +1791,7 @@ vfrStatementQuestionTag :
vfrStatementNoSubmitIf |
vfrStatementDisableIfQuest |
vfrStatementRefresh |
- vfrStatementVarstoreDevice
+ vfrStatementVarstoreDevice
;
vfrStatementQuestionTagList :
@@ -1639,7 +1808,7 @@ vfrStatementQuestionOptionTag :
vfrStatementQuestionOptionList :
(
vfrStatementQuestionTag |
- vfrStatementQuestionOptionTag
+ vfrStatementQuestionOptionTag
)*
;
@@ -1648,34 +1817,43 @@ vfrStatementStatList :
vfrStatementQuestions |
vfrStatementConditional |
// Just for framework vfr compatibility
- vfrStatementLabel
+ vfrStatementLabel
//vfrStatementInvalid
;
vfrStatementDisableIfStat :
- << CIfrDisableIf DIObj; >>
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementSuppressIfStat :
- << CIfrSuppressIf SIObj; >>
+ <<
+ CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
";"
;
vfrStatementGrayOutIfStat :
- << CIfrGrayOutIf GOIObj; >>
+ <<
+ CIfrGrayOutIf GOIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:GrayOutIf << GOIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
";"
( vfrStatementStatList )*
E:EndIf << CRT_END_OP (E); >>
@@ -1712,27 +1890,36 @@ vfrStatementLocked :
;
vfrStatementInconsistentIf :
- << CIfrInconsistentIf IIObj; >>
+ <<
+ CIfrInconsistentIf IIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:InconsistentIf << IIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << IIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementNoSubmitIf :
- << CIfrNoSubmitIf NSIObj; >>
+ <<
+ CIfrNoSubmitIf NSIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:NoSubmitIf << NSIObj.SetLineNo(L->getLine()); >>
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" "," << NSIObj.SetError (_STOSID(S->getText())); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
E:EndIf << CRT_END_OP (E); >>
;
vfrStatementDisableIfQuest :
- << CIfrDisableIf DIObj; >>
+ <<
+ CIfrDisableIf DIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:DisableIf << DIObj.SetLineNo(L->getLine()); >>
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";" << mConstantOnlyInExpression = FALSE; >>
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1750,10 +1937,13 @@ vfrStatementVarstoreDevice :
;
vfrStatementSuppressIfQuest :
- << CIfrSuppressIf SIObj; >>
+ <<
+ CIfrSuppressIf SIObj;
+ UINT32 ExpOpCount = 0;
+ >>
L:SuppressIf << SIObj.SetLineNo(L->getLine()); >>
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0] ";"
+ vfrStatementExpression[0, ExpOpCount] ";"
vfrStatementQuestionOptionList
E:EndIf << CRT_END_OP (E); >>
;
@@ -1764,28 +1954,51 @@ vfrStatementOptions :
vfrStatementOneOfOption :
<<
- EFI_IFR_TYPE_VALUE Val;
+ EFI_IFR_TYPE_VALUE Val = {0};
CIfrOneOfOption OOOObj;
INT8 *VarStoreName = NULL;
-
+
>>
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()]
<<
if (OOOObj.GetFlags () & 0x10) {
_PCATCH(mCVfrDataStorage.GetVarStoreName (_GET_CURRQEST_VARTINFO().mVarStoreId, &VarStoreName), L->getLine());
_PCATCH(mCVfrDefaultStore.BufferVarStoreAltConfigAdd (
- EFI_HII_DEFAULT_CLASS_STANDARD,
- _GET_CURRQEST_VARTINFO(),
- VarStoreName,
- _GET_CURRQEST_DATATYPE (),
+ EFI_HII_DEFAULT_CLASS_STANDARD,
+ _GET_CURRQEST_VARTINFO(),
+ VarStoreName,
+ _GET_CURRQEST_DATATYPE (),
Val
), L->getLine());
}
>>
- { "," Key "=" Number } // no use in UEFI2.1 VFR
(
"," vfrImageTag << OOOObj.SetScope (1); CIfrEnd EOOOObj; >>
)*
@@ -1794,7 +2007,7 @@ vfrStatementOneOfOption :
vfrOneOfOptionFlags [CIfrOneOfOption & OOOObj, UINT32 LineNum] :
<<
- UINT8 LFlags = _GET_CURRQEST_DATATYPE();
+ UINT8 LFlags = 0;
UINT8 HFlags = 0;
>>
oneofoptionFlagsField[HFlags, LFlags] ( "\|" oneofoptionFlagsField[HFlags, LFlags] )*
@@ -1814,27 +2027,6 @@ oneofoptionFlagsField [UINT8 & HFlags, UINT8 & LFlags] :
| DefaultFlag << $LFlags |= 0x10; >>
;
-//vfrStatementGuid :
-// <<
-// EFI_GUID Guid;
-// CIfrGuid GObj;
-// >>
-// GuidAction
-// GUID "="
-// OpenBrace
-// G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
-// G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
-// CloseBrace
-// <<
-// _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
-// G4->getText (), G5->getText (), G6->getText (),
-// G7->getText (), G8->getText (), G9->getText (),
-// G10->getText (), G11->getText ());
-// >>
-// << GObj.SetGuid (&Guid); >>
-// ";"
-// ;
-
vfrStatementLabel :
<< CIfrLabel LObj; >>
L:Label << LObj.SetLineNo(L->getLine()); >>
@@ -1847,9 +2039,9 @@ vfrStatementBanner :
B:Banner { "," } << BObj.SetLineNo(B->getLine()); >>
Title "=" "STRING_TOKEN" "\(" S:Number "\)" "," << BObj.SetTitle (_STOSID(S->getText())); >>
(
- (
+ (
Line L:Number "," << BObj.SetLine (_STOU16(L->getText())); >>
- Align
+ Align
(
Left << BObj.SetAlign (0); >>
| Center << BObj.SetAlign (1); >>
@@ -1867,17 +2059,18 @@ vfrStatementBanner :
//
// keep some syntax for compatibility but not generate any IFR object
//
-vfrStatementInvalidHidden :
+vfrStatementInvalidHidden :
Hidden
Value "=" Number ","
Key "=" Number ";"
;
vfrStatementInvalidInconsistentIf :
+ << UINT32 ExpOpCount = 0; >>
InconsistentIf
Prompt "=" "STRING_TOKEN" "\(" S:Number "\)" ","
{ FLAGS "=" flagsField ( "\|" flagsField )* "," }
- vfrStatementExpression[0]
+ vfrStatementExpression[0, ExpOpCount]
EndIf
";"
;
@@ -1889,15 +2082,15 @@ vfrStatementInvalidInventory :
{
Text "=" "STRING_TOKEN" "\(" Number "\)"
}
- ";"
+ ";"
;
-vfrStatementInvalidSaveRestoreDefaults :
+vfrStatementInvalidSaveRestoreDefaults :
(Save | Restore)
Defaults ","
FormId "=" Number ","
Prompt "=" "STRING_TOKEN" "\(" Number "\)" ","
- Help "=" "STRING_TOKEN" "\(" Number "\)"
+ Help "=" "STRING_TOKEN" "\(" Number "\)"
{ "," FLAGS "=" flagsField ( "\|" flagsField )* }
{ "," Key "=" Number }
";"
@@ -1939,13 +2132,13 @@ vfrStatementInvalidSaveRestoreDefaults :
#token QuestionRefVal("questionrefval") "questionrefval"
#token StringRefVal("stringrefval") "stringrefval"
-vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] :
+vfrStatementExpression [UINT32 RootLevel, UINT32 & ExpOpCount] :
<< if ($RootLevel == 0) {_CLEAR_SAVED_OPHDR ();} >>
andTerm[$RootLevel, $ExpOpCount]
(
L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >>
)*
- << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; } >>
+ << if (($RootLevel == 0) && ($ExpOpCount > 1)) {_SET_SAVED_OPHDR_SCOPE(); CIfrEnd EObj; EObj.SetLineNo (0);} >>
;
andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
@@ -1956,7 +2149,7 @@ andTerm[UINT32 & RootLevel, UINT32 & ExpOpCount] :
;
bitwiseorTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- bitwiseandTerm[$RootLevel, $ExpOpCount]
+ bitwiseandTerm[$RootLevel, $ExpOpCount]
(
L:"\|" bitwiseandTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrBitWiseOr BWOObj(L->getLine()); >>
)*
@@ -2004,7 +2197,7 @@ compareTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
;
shiftTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- addMinusTerm[$RootLevel, $ExpOpCount]
+ addMinusTerm[$RootLevel, $ExpOpCount]
(
(
L1:"\<<" addMinusTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrShiftLeft SLObj(L1->getLine()); >>
@@ -2030,20 +2223,42 @@ addMinusTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
;
multdivmodTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
- atomTerm[$RootLevel, $ExpOpCount]
- (
+ castTerm[$RootLevel, $ExpOpCount]
+ (
(
- L1:"\*" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
+ L1:"\*" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrMultiply MObj(L1->getLine()); >>
)
|
(
- L2:"/" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
+ L2:"/" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrDivide DObj(L2->getLine()); >>
)
|
(
- L3:"%" atomTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
- )
+ L3:"%" castTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrModulo MObj(L3->getLine()); >>
+ )
)*
+ ;
+
+castTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
+ << UINT8 CastType = 0xFF; >>
+ (
+ L:"\("
+ (
+ Boolean << CastType = 0; >>
+ | Uint64 << CastType = 1; >>
+ | Uint32 << CastType = 1; >>
+ | Uint16 << CastType = 1; >>
+ | Uint8 << CastType = 1; >>
+ )
+ "\)"
+ )*
+ atomTerm[$RootLevel, $ExpOpCount]
+ <<
+ switch (CastType) {
+ case 0: { CIfrToBoolean TBObj(L->getLine()); $ExpOpCount++; } break;
+ case 1: { CIfrToUint TUObj(L->getLine()); $ExpOpCount++; } break;
+ }
+ >>
;
atomTerm [UINT32 & RootLevel, UINT32 & ExpOpCount]:
@@ -2119,7 +2334,7 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] :
_SAVE_OPHDR_COND (EIVObj, ($ExpOpCount == 0));
EIVObj.SetQuestionId (QId, VarIdStr, LineNo);
EIVObj.SetValue (ConstVal);
- $ExpOpCount++;
+ $ExpOpCount++;
} else {
IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, EQUAL);
}
@@ -2163,7 +2378,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vfrQuestionDataFieldName[QId[0], Mask[0], VarIdStr[0], LineNo[0]]
(
(
- "=="
+ "=="
vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]]
<<
if (Mask[0] & Mask[1]) {
@@ -2173,7 +2388,7 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
_SAVE_OPHDR_COND (EIIObj, ($ExpOpCount == 0));
EIIObj.SetQuestionId1 (QId[0], VarIdStr[0], LineNo[0]);
EIIObj.SetQuestionId2 (QId[1], VarIdStr[1], LineNo[1]);
- $ExpOpCount++;
+ $ExpOpCount++;
}
>>
)
@@ -2215,7 +2430,7 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
>>
L:IdEqValList
vfrQuestionDataFieldName[QId, Mask, VarIdStr, LineNo]
- "=="
+ "=="
(
V:Number << ValueList[ListLen] = _STOU16(V->getText()); ListLen++; >>
)+
@@ -2239,9 +2454,9 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vareqvarlExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
L:VarEqVal Var "\(" V1:Number "\)" "==" V2:Number <<
{
- CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
- _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
- U64Obj1.SetValue (_STOU64(V1->getText()));
+ CIfrUint64 U64Obj1(L->getLine()), U64Obj2(L->getLine());
+ _SAVE_OPHDR_COND (U64Obj1, ($ExpOpCount == 0));
+ U64Obj1.SetValue (_STOU64(V1->getText()));
U64Obj2.SetValue (_STOU64(V2->getText()));
}
>>
@@ -2267,25 +2482,14 @@ questionref13Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
Path "=" "STRING_TOKEN" "\(" S:Number "\)" << Type = 0x4; DevPath = _STOSID(S->getText()); >>
}
{
- GUID "="
- OpenBrace
- G1:Number "," G2:Number "," G3:Number "," G4:Number "," G5:Number "," G6:Number ","
- G7:Number "," G8:Number "," G9:Number "," G10:Number "," G11:Number
- CloseBrace
- <<
- Type = 0x5;
- _CRGUID (&Guid, G1->getText (), G2->getText (), G3->getText (),
- G4->getText (), G5->getText (), G6->getText (),
- G7->getText (), G8->getText (), G9->getText (),
- G10->getText (), G11->getText ());
- >>
+ Uuid "=" guidDefinition[Guid] << Type = 0x5; >>
}
)
|
(
"\("
(
- QN:StringIdentifier <<
+ QN:StringIdentifier <<
QName = QN->getText();
LineNo = QN->getLine();
mCVfrQuestionDB.GetQuestionId (QN->getText(), NULL, QId, BitMask);
@@ -2340,6 +2544,7 @@ vfrExpressionUnaryOp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
| bitwisenotExp[$RootLevel, $ExpOpCount]
| question2refExp[$RootLevel, $ExpOpCount]
| stringref2Exp[$RootLevel, $ExpOpCount]
+ | toboolExp[$RootLevel, $ExpOpCount]
| unintExp[$RootLevel, $ExpOpCount]
| toupperExp[$RootLevel, $ExpOpCount]
| tolwerExp[$RootLevel, $ExpOpCount]
@@ -2433,7 +2638,7 @@ findExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
findFormat[Format] ( "\|" findFormat[Format] )*
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
@@ -2460,7 +2665,7 @@ tokenExp[UINT32 & RootLevel, UINT32 & ExpOpCount] :
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
- ","
+ ","
vfrStatementExpression[$RootLevel + 1, $ExpOpCount]
"\)" << { CIfrToken TObj(L->getLine()); $ExpOpCount++; } >>
;
@@ -2489,12 +2694,13 @@ spanFlags [UINT8 & Flags] :
//******************************************************************************
//
-// Parser class definition.
-//
+// Parser class definition.
+//
class EfiVfrParser {
<<
private:
UINT8 mParserStatus;
+ BOOLEAN mConstantOnlyInExpression;
CVfrDefaultStore mCVfrDefaultStore;
CVfrVarDataTypeDB mCVfrVarDataTypeDB;
@@ -2517,12 +2723,14 @@ private:
UINT8 _GET_CURRQEST_DATATYPE ();
UINT32 _GET_CURRQEST_VARSIZE ();
+ UINT32 _GET_CURRQEST_ARRAY_SIZE ();
public:
- VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr, IN INT8 *);
+ VOID _PCATCH (IN INTN, IN INTN, IN ANTLRTokenPtr, IN INT8 *);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN ANTLRTokenPtr);
VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32);
+ VOID _PCATCH (IN EFI_VFR_RETURN_CODE, IN UINT32, IN INT8 *);
VOID syn (ANTLRAbstractToken *, ANTLRChar *, SetWordType *, ANTLRTokenType, INT32);
@@ -2557,7 +2765,7 @@ public:
<<
VOID
EfiVfrParser::_SAVE_OPHDR_COND (
- IN CIfrOpHeader &OpHdr,
+ IN CIfrOpHeader &OpHdr,
IN BOOLEAN Cond
)
{
@@ -2637,17 +2845,48 @@ EfiVfrParser::_GET_CURRQEST_VARSIZE (
return mCurrQestVarInfo.mVarTotalSize;
}
+UINT32
+EfiVfrParser::_GET_CURRQEST_ARRAY_SIZE (
+ VOID
+ )
+{
+ UINT8 Size = 1;
+
+ switch (mCurrQestVarInfo.mVarType) {
+ case EFI_IFR_TYPE_NUM_SIZE_8:
+ Size = 1;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_16:
+ Size = 2;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_32:
+ Size = 4;
+ break;
+
+ case EFI_IFR_TYPE_NUM_SIZE_64:
+ Size = 8;
+ break;
+
+ default:
+ break;
+ }
+
+ return (mCurrQestVarInfo.mVarTotalSize / Size);
+}
+
VOID
EfiVfrParser::_PCATCH (
- IN EFI_VFR_RETURN_CODE ReturnCode,
- IN EFI_VFR_RETURN_CODE ExpectCode,
+ IN INTN ReturnCode,
+ IN INTN ExpectCode,
IN ANTLRTokenPtr Tok,
IN INT8 *ErrorMsg
)
{
if (ReturnCode != ExpectCode) {
mParserStatus++;
- gCVfrErrorHandle.PrintError (Tok->getLine(), Tok->getText(), ErrorMsg);
+ gCVfrErrorHandle.PrintMsg (Tok->getLine(), Tok->getText(), "Error", ErrorMsg);
}
}
@@ -2675,14 +2914,24 @@ EfiVfrParser::_PCATCH (
)
{
mParserStatus += gCVfrErrorHandle.HandleError (ReturnCode, LineNum);
+}
+
+VOID
+EfiVfrParser::_PCATCH (
+ IN EFI_VFR_RETURN_CODE ReturnCode,
+ IN UINT32 LineNum,
+ IN INT8 *ErrorMsg
+ )
+{
+ mParserStatus = mParserStatus + gCVfrErrorHandle.HandleError (ReturnCode, LineNum, ErrorMsg);
}
-VOID
+VOID
EfiVfrParser::syn (
- ANTLRAbstractToken *Tok,
- ANTLRChar *Egroup,
- SetWordType *Eset,
- ANTLRTokenType ETok,
+ ANTLRAbstractToken *Tok,
+ ANTLRChar *Egroup,
+ SetWordType *Eset,
+ ANTLRTokenType ETok,
INT32 Huh
)
{
@@ -2737,7 +2986,7 @@ EfiVfrParser::_STOU8 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2767,7 +3016,7 @@ EfiVfrParser::_STOU16 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2797,7 +3046,7 @@ EfiVfrParser::_STOU32 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -2807,7 +3056,7 @@ UINT64
EfiVfrParser::_STOU64 (
IN INT8 *Str
)
-{
+{
BOOLEAN IsHex;
UINT64 Value;
INT8 c;
@@ -2827,16 +3076,16 @@ EfiVfrParser::_STOU64 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
-}
+}
EFI_HII_DATE
EfiVfrParser::_STOD (
- IN INT8 *Year,
- IN INT8 *Month,
+ IN INT8 *Year,
+ IN INT8 *Month,
IN INT8 *Day
)
{
@@ -2851,8 +3100,8 @@ EfiVfrParser::_STOD (
EFI_HII_TIME
EfiVfrParser::_STOT (
- IN INT8 *Hour,
- IN INT8 *Minute,
+ IN INT8 *Hour,
+ IN INT8 *Minute,
IN INT8 *Second
)
{
@@ -2881,7 +3130,7 @@ EfiVfrParser::_STOFID (
return (EFI_FORM_ID)_STOU16(Str);
}
-EFI_QUESTION_ID
+EFI_QUESTION_ID
EfiVfrParser::_STOQID (
IN INT8 *Str
)
@@ -2918,17 +3167,17 @@ EfiVfrParser::_STRCAT (
VOID
EfiVfrParser::_CRGUID (
- IN EFI_GUID *Guid,
- IN INT8 *G1,
- IN INT8 *G2,
- IN INT8 *G3,
- IN INT8 *G4,
- IN INT8 *G5,
- IN INT8 *G6,
- IN INT8 *G7,
- IN INT8 *G8,
- IN INT8 *G9,
- IN INT8 *G10,
+ IN EFI_GUID *Guid,
+ IN INT8 *G1,
+ IN INT8 *G2,
+ IN INT8 *G3,
+ IN INT8 *G4,
+ IN INT8 *G5,
+ IN INT8 *G6,
+ IN INT8 *G7,
+ IN INT8 *G8,
+ IN INT8 *G9,
+ IN INT8 *G10,
IN INT8 *G11
)
{
@@ -2964,9 +3213,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- TypeNameList[Index],
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ TypeNameList[Index],
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
TypeNameList[Index],
EFI_VARSTORE_ID_INVALID
);
@@ -2985,9 +3234,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Date",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Date",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_DATE",
EFI_VARSTORE_ID_INVALID
);
@@ -3006,9 +3255,9 @@ EfiVfrParser::_DeclareDefaultLinearVarStore (
VSObj.SetLineNo (LineNo);
mCVfrDataStorage.DeclareBufferVarStore (
- "Time",
- &DefaultGuid,
- &mCVfrVarDataTypeDB,
+ "Time",
+ &DefaultGuid,
+ &mCVfrVarDataTypeDB,
"EFI_HII_TIME",
EFI_VARSTORE_ID_INVALID
);
@@ -3026,7 +3275,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
IN UINT32 LineNo
)
{
- CIfrDefaultStore DSObj;
+ CIfrDefaultStore DSObj;
mCVfrDefaultStore.RegisterDefaultStore (DSObj.GetObjBinAddr(), "Standard Defaults", EFI_STRING_ID_INVALID, EFI_HII_DEFAULT_CLASS_STANDARD);
DSObj.SetLineNo (LineNo);
@@ -3036,7 +3285,7 @@ EfiVfrParser::_DeclareStandardDefaultStorage (
VOID
EfiVfrParser::AssignQuestionKey (
- IN CIfrQuestionHeader &QHObj,
+ IN CIfrQuestionHeader &QHObj,
IN ANTLRTokenPtr KeyTok
)
{
@@ -3059,7 +3308,7 @@ EfiVfrParser::AssignQuestionKey (
VOID
EfiVfrParser::ConvertIdExpr (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3093,7 +3342,7 @@ EfiVfrParser::ConvertIdExpr (
VOID
EfiVfrParser::IdEqValDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
@@ -3145,7 +3394,7 @@ EfiVfrParser::IdEqValDoSpecial (
VOID
EfiVfrParser::IdEqIdDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId1,
IN INT8 *VarId1Str,
@@ -3192,7 +3441,7 @@ EfiVfrParser::IdEqIdDoSpecial (
VOID
EfiVfrParser::IdEqListDoSpecial (
- IN UINT32 &ExpOpCount,
+ IN UINT32 &ExpOpCount,
IN UINT32 LineNo,
IN EFI_QUESTION_ID QId,
IN INT8 *VarIdStr,
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
index caadc29da9..d6f5f437f2 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.cpp
@@ -1,5 +1,4 @@
/*++
-
Copyright (c) 2004 - 2010, 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
@@ -10,8 +9,7 @@ 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:
-
-VfrUtilityLib.cpp
+ VfrUtilityLib.cpp
Abstract:
@@ -74,12 +72,13 @@ CVfrBinaryOutput::WriteEnd (
}
SConfigInfo::SConfigInfo (
- IN UINT8 Type,
- IN UINT16 Offset,
- IN UINT32 Width,
+ IN UINT8 Type,
+ IN UINT16 Offset,
+ IN UINT32 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mNext = NULL;
mOffset = Offset;
mWidth = (UINT16)Width;
mValue = new UINT8[mWidth];
@@ -125,51 +124,51 @@ SConfigInfo::~SConfigInfo (
}
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
- mId = NULL;
- mInfo = NULL;
+ mName = NULL;
+ mId = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
}
SConfigItem::SConfigItem (
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT16 Width,
IN EFI_IFR_TYPE_VALUE Value
)
{
+ mName = NULL;
mId = NULL;
- mInfo = NULL;
mInfoStrList = NULL;
mNext = NULL;
- if (Id != NULL) {
- if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
- strcpy (mId, Id);
+ if (Name != NULL) {
+ if ((mName = new INT8[strlen (Name) + 1]) != NULL) {
+ strcpy (mName, Name);
}
}
- if (Info != NULL) {
- if ((mInfo = new INT8[strlen (Info) + 1]) != NULL) {
- strcpy (mInfo, Info);
+ if (Id != NULL) {
+ if ((mId = new INT8[strlen (Id) + 1]) != NULL) {
+ strcpy (mId, Id);
}
}
@@ -182,8 +181,8 @@ SConfigItem::~SConfigItem (
{
SConfigInfo *Info;
+ BUFFER_SAFE_FREE (mName);
BUFFER_SAFE_FREE (mId);
- BUFFER_SAFE_FREE (mInfo);
while (mInfoStrList != NULL) {
Info = mInfoStrList;
mInfoStrList = mInfoStrList->mNext;
@@ -194,17 +193,17 @@ SConfigItem::~SConfigItem (
UINT8
CVfrBufferConfig::Register (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *pNew;
- if (Select (Id) == 0) {
+ if (Select (Name) == 0) {
return 1;
}
- if ((pNew = new SConfigItem (Id, Info)) == NULL) {
+ if ((pNew = new SConfigItem (Name, Id)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -237,25 +236,27 @@ CVfrBufferConfig::Eof(
UINT8
CVfrBufferConfig::Select (
- IN INT8 *Id,
- IN INT8 *Info
+ IN INT8 *Name,
+ IN INT8 *Id
)
{
SConfigItem *p;
- if (Id == NULL) {
+ if (Name == NULL) {
mItemListPos = mItemListHead;
return 0;
} else {
for (p = mItemListHead; p != NULL; p = p->mNext) {
- if (strcmp (p->mId, Id) != 0) {
+ if (strcmp (p->mName, Name) != 0) {
continue;
}
- if ((p->mInfo != NULL) && (Info != NULL)) {
- if (strcmp (p->mInfo, Info) != 0) {
+ if (Id != NULL) {
+ if (p->mId == NULL || strcmp (p->mId, Id) != 0) {
continue;
}
+ } else if (p->mId != NULL) {
+ continue;
}
mItemListPos = p;
@@ -269,8 +270,8 @@ CVfrBufferConfig::Select (
UINT8
CVfrBufferConfig::Write (
IN CONST CHAR8 Mode,
- IN INT8 *Id,
- IN INT8 *Info,
+ IN INT8 *Name,
+ IN INT8 *Id,
IN UINT8 Type,
IN UINT16 Offset,
IN UINT32 Width,
@@ -281,16 +282,14 @@ CVfrBufferConfig::Write (
SConfigItem *pItem;
SConfigInfo *pInfo;
+ if ((Ret = Select (Name)) != 0) {
+ return Ret;
+ }
+
switch (Mode) {
case 'a' : // add
- if (Select (Id) == 0) {
- if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
- return 2;
- }
- pInfo->mNext = mItemListPos->mInfoStrList;
- mItemListPos->mInfoStrList = pInfo;
- } else {
- if ((pItem = new SConfigItem (Id, Info, Type, Offset, Width, Value)) == NULL) {
+ if (Select (Name, Id) != 0) {
+ if ((pItem = new SConfigItem (Name, Id, Type, Offset, Width, Value)) == NULL) {
return 2;
}
if (mItemListHead == NULL) {
@@ -301,14 +300,26 @@ CVfrBufferConfig::Write (
mItemListTail = pItem;
}
mItemListPos = pItem;
+ } else {
+ // tranverse the list to find out if there's already the value for the same offset
+ for (pInfo = mItemListPos->mInfoStrList; pInfo != NULL; pInfo = pInfo->mNext) {
+ if (pInfo->mOffset == Offset) {
+ // check if the value and width are the same; return error if not
+ if ((Id != NULL) && (pInfo->mWidth != Width || memcmp(pInfo->mValue, &Value, Width) != 0)) {
+ return VFR_RETURN_DEFAULT_VALUE_REDEFINED;
+ }
+ return 0;
+ }
+ }
+ if((pInfo = new SConfigInfo (Type, Offset, Width, Value)) == NULL) {
+ return 2;
+ }
+ pInfo->mNext = mItemListPos->mInfoStrList;
+ mItemListPos->mInfoStrList = pInfo;
}
break;
case 'd' : // delete
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
-
if (mItemListHead == mItemListPos) {
mItemListHead = mItemListPos->mNext;
delete mItemListPos;
@@ -327,18 +338,15 @@ CVfrBufferConfig::Write (
break;
case 'i' : // set info
- if ((Ret = Select (Id)) != 0) {
- return Ret;
- }
- if (mItemListPos->mInfo != NULL) {
- delete mItemListPos->mInfo;
+ if (mItemListPos->mId != NULL) {
+ delete mItemListPos->mId;
}
- mItemListPos->mInfo = NULL;
- if (Info != NULL) {
- if ((mItemListPos->mInfo = new INT8[strlen (Info) + 1]) == NULL) {
+ mItemListPos->mId = NULL;
+ if (Id != NULL) {
+ if ((mItemListPos->mId = new INT8[strlen (Id) + 1]) == NULL) {
return 2;
}
- strcpy (mItemListPos->mInfo, Info);
+ strcpy (mItemListPos->mId, Id);
}
break;
@@ -352,29 +360,29 @@ CVfrBufferConfig::Write (
#if 0
UINT8
CVfrBufferConfig::ReadId (
- OUT INT8 **Id,
- OUT INT8 **Info
+ OUT INT8 **Name,
+ OUT INT8 **Id
)
{
if (mInfoStrItemListPos == NULL) {
return 1; // end read or some error occur
}
+ if (Name != NULL) {
+ *Name = new INT8 (strlen (mInfoStrItemListPos->mName + 1));
+ strcpy (*Name, mInfoStrItemListPos->mName);
+ }
if (Id != NULL) {
*Id = new INT8 (strlen (mInfoStrItemListPos->mId + 1));
strcpy (*Id, mInfoStrItemListPos->mId);
}
- if (Info != NULL) {
- *Info = new INT8 (strlen (mInfoStrItemListPos->mInfo + 1));
- strcpy (*Info, mInfoStrItemListPos->mInfo);
- }
return 0;
}
UINT8
CVfrBufferConfig::ReadInfo (
- IN INT8 *Id,
+ IN INT8 *Name,
IN UINT32 Index,
IN OUT UINT32 &Number,
OUT INT8 *Offset,
@@ -387,8 +395,8 @@ CVfrBufferConfig::ReadInfo (
UINT32 idx;
UINT32 num;
- if (Id != NULL) {
- if ((ret = Select (Id)) != 0) {
+ if (Name != NULL) {
+ if ((ret = Select (Name)) != 0) {
return ret;
}
}
@@ -473,8 +481,28 @@ CVfrBufferConfig::OutputCFile (
}
for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
- if (Item->mInfoStrList != NULL) {
- fprintf (pFile, "\nunsigned char %s%sDefault%04x[] = {", BaseName, Item->mId, Item->mInfo);
+ if (Item->mId != NULL || Item->mInfoStrList == NULL) {
+ continue;
+ }
+ fprintf (pFile, "\nunsigned char %s%sBlockName[] = {", BaseName, Item->mName);
+
+ TotalLen = sizeof (UINT32);
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ TotalLen += sizeof (UINT16) * 2;
+ }
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
+
+ for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
+ Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
+ }
+ fprintf (pFile, "\n};\n");
+ }
+
+ for (Item = mItemListHead; Item != NULL; Item = Item->mNext) {
+ if (Item->mId != NULL && Item->mInfoStrList != NULL) {
+ fprintf (pFile, "\nunsigned char %s%sDefault%s[] = {", BaseName, Item->mName, Item->mId);
TotalLen = sizeof (UINT32);
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
@@ -483,6 +511,7 @@ CVfrBufferConfig::OutputCFile (
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&TotalLen, sizeof (UINT32));
for (Info = Item->mInfoStrList; Info != NULL; Info = Info->mNext) {
+ fprintf (pFile, "\n");
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mOffset, sizeof (UINT16));
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)&Info->mWidth, sizeof (UINT16));
if (Info->mNext == NULL) {
@@ -490,9 +519,8 @@ CVfrBufferConfig::OutputCFile (
} else {
Output.WriteLine (pFile, BYTES_PRE_LINE, " ", (INT8 *)Info->mValue, Info->mWidth);
}
- fprintf (pFile, "\n");
}
- fprintf (pFile, "};\n");
+ fprintf (pFile, "\n};\n");
}
}
}
@@ -536,7 +564,7 @@ static struct {
{"UINT16", EFI_IFR_TYPE_NUM_SIZE_16, sizeof (UINT16), sizeof (UINT16)},
{"UINT8", EFI_IFR_TYPE_NUM_SIZE_8, sizeof (UINT8), sizeof (UINT8)},
{"BOOLEAN", EFI_IFR_TYPE_BOOLEAN, sizeof (BOOLEAN), sizeof (BOOLEAN)},
- {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT8)},
+ {"EFI_HII_DATE", EFI_IFR_TYPE_DATE, sizeof (EFI_HII_DATE), sizeof (UINT16)},
{"EFI_STRING_ID", EFI_IFR_TYPE_STRING, sizeof (EFI_STRING_ID),sizeof (EFI_STRING_ID)},
{"EFI_HII_TIME", EFI_IFR_TYPE_TIME, sizeof (EFI_HII_TIME), sizeof (UINT8)},
{NULL, EFI_IFR_TYPE_OTHER, 0, 0}
@@ -610,7 +638,7 @@ _STR2U32 (
}
if (c >= '0' && c <= '9') {
Value += (c - '0');
- }
+ }
}
return Value;
@@ -627,7 +655,7 @@ CVfrVarDataTypeDB::RegisterNewType (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractStructTypeName (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
OUT INT8 *TName
)
{
@@ -650,7 +678,7 @@ CVfrVarDataTypeDB::ExtractStructTypeName (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
- IN INT8 *&VarStr,
+ IN INT8 *&VarStr,
IN INT8 *FName,
OUT UINT32 &ArrayIdx
)
@@ -658,15 +686,15 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
UINT32 Idx;
INT8 ArrayStr[MAX_NAME_LEN + 1];
- ArrayIdx = INVALID_ARRAY_INDEX;
+ ArrayIdx = INVALID_ARRAY_INDEX;
if (FName == NULL) {
return VFR_RETURN_FATAL_ERROR;
}
while((*VarStr != '\0') &&
- (*VarStr != '.') &&
- (*VarStr != '[') &&
+ (*VarStr != '.') &&
+ (*VarStr != '[') &&
(*VarStr != ']')) {
*FName = *VarStr;
VarStr++;
@@ -703,8 +731,8 @@ CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetTypeField (
- IN INT8 *FName,
- IN SVfrDataType *Type,
+ IN INT8 *FName,
+ IN SVfrDataType *Type,
OUT SVfrDataField *&Field
)
{
@@ -726,7 +754,7 @@ CVfrVarDataTypeDB::GetTypeField (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetFieldOffset (
- IN SVfrDataField *Field,
+ IN SVfrDataField *Field,
IN UINT32 ArrayIdx,
OUT UINT32 &Offset
)
@@ -834,7 +862,7 @@ CVfrVarDataTypeDB::InternalTypesListInit (
pSecondsField->mNext = NULL;
pSecondsField->mArrayNum = 0;
- New->mMembers = pHoursField;
+ New->mMembers = pHoursField;
} else {
New->mMembers = NULL;
}
@@ -853,6 +881,7 @@ CVfrVarDataTypeDB::CVfrVarDataTypeDB (
mNewDataType = NULL;
mCurrDataField = NULL;
mPackAlign = DEFAULT_PACK_ALIGN;
+ mPackStack = NULL;
InternalTypesListInit ();
}
@@ -861,8 +890,9 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
VOID
)
{
- SVfrDataType *pType;
- SVfrDataField *pField;
+ SVfrDataType *pType;
+ SVfrDataField *pField;
+ SVfrPackStackNode *pPack;
if (mNewDataType != NULL) {
delete mNewDataType;
@@ -879,30 +909,64 @@ CVfrVarDataTypeDB::~CVfrVarDataTypeDB (
delete pType;
}
+ while (mPackStack != NULL) {
+ pPack = mPackStack;
+ mPackStack = mPackStack->mNext;
+ delete pPack;
+ }
}
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::Pack (
- IN UINT32 Align
+ IN UINT32 LineNum,
+ IN UINT8 Action,
+ IN INT8 *Identifier,
+ IN UINT32 Number
)
{
- if (Align == 0) {
- return VFR_RETURN_INVALID_PARAMETER;
- } else if (Align > 1) {
- mPackAlign = Align + Align % 2;
- } else {
- mPackAlign = Align;
+ UINT32 PackAlign;
+ INT8 Msg[64] = {0, };
+
+ if (Action & VFR_PACK_SHOW) {
+ sprintf (Msg, "value of pragma pack(show) == %d", mPackAlign);
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", Msg);
}
- return VFR_RETURN_SUCCESS;
-}
+ if (Action & VFR_PACK_PUSH) {
+ SVfrPackStackNode *pNew = NULL;
-VOID
-CVfrVarDataTypeDB::UnPack (
- VOID
- )
-{
- mPackAlign = DEFAULT_PACK_ALIGN;
+ if ((pNew = new SVfrPackStackNode (Identifier, mPackAlign)) == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+ pNew->mNext = mPackStack;
+ mPackStack = pNew;
+ }
+
+ if (Action & VFR_PACK_POP) {
+ SVfrPackStackNode *pNode = NULL;
+
+ if (mPackStack == NULL) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes");
+ }
+
+ for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->Match (Identifier) == TRUE) {
+ mPackAlign = pNode->mNumber;
+ mPackStack = pNode->mNext;
+ }
+ }
+ }
+
+ if (Action & VFR_PACK_ASSIGN) {
+ PackAlign = (Number > 1) ? Number + Number % 2 : Number;
+ if ((PackAlign == 0) || (PackAlign > 16)) {
+ gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "expected pragma parameter to be '1', '2', '4', '8', or '16'");
+ } else {
+ mPackAlign = PackAlign;
+ }
+ }
+
+ return VFR_RETURN_SUCCESS;
}
VOID
@@ -952,8 +1016,8 @@ CVfrVarDataTypeDB::SetNewTypeName (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::DataTypeAddField (
- IN INT8 *FieldName,
- IN INT8 *TypeName,
+ IN INT8 *FieldName,
+ IN INT8 *TypeName,
IN UINT32 ArrayNum
)
{
@@ -991,7 +1055,7 @@ CVfrVarDataTypeDB::DataTypeAddField (
mNewDataType->mMembers = pNewField;
pNewField->mNext = NULL;
} else {
- for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
+ for (pTmp = mNewDataType->mMembers; pTmp->mNext != NULL; pTmp = pTmp->mNext)
;
pTmp->mNext = pNewField;
pNewField->mNext = NULL;
@@ -1051,6 +1115,38 @@ CVfrVarDataTypeDB::GetDataType (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataTypeSize (
+ IN UINT8 DataType,
+ OUT UINT32 *Size
+ )
+{
+ SVfrDataType *pDataType = NULL;
+
+ if (Size == NULL) {
+ return VFR_RETURN_FATAL_ERROR;
+ }
+
+ *Size = 0;
+ DataType = DataType & 0x0F;
+
+ //
+ // For user defined data type, the size can't be got by this function.
+ //
+ if (DataType == EFI_IFR_TYPE_OTHER) {
+ return VFR_RETURN_SUCCESS;
+ }
+
+ for (pDataType = mDataTypeList; pDataType != NULL; pDataType = pDataType->mNext) {
+ if (DataType == pDataType->mType) {
+ *Size = pDataType->mTotalSize;
+ return VFR_RETURN_SUCCESS;
+ }
+ }
+
+ return VFR_RETURN_UNDEFINED;
+}
+
+EFI_VFR_RETURN_CODE
+CVfrVarDataTypeDB::GetDataTypeSize (
IN INT8 *TypeName,
OUT UINT32 *Size
)
@@ -1075,9 +1171,9 @@ CVfrVarDataTypeDB::GetDataTypeSize (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetDataFieldInfo (
- IN INT8 *VarStr,
- OUT UINT16 &Offset,
- OUT UINT8 &Type,
+ IN INT8 *VarStr,
+ OUT UINT16 &Offset,
+ OUT UINT8 &Type,
OUT UINT32 &Size
)
{
@@ -1113,7 +1209,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
EFI_VFR_RETURN_CODE
CVfrVarDataTypeDB::GetUserDefinedTypeNameList (
- OUT INT8 ***NameList,
+ OUT INT8 ***NameList,
OUT UINT32 *ListSize
)
{
@@ -1444,10 +1540,10 @@ CVfrDataStorage::DeclareNameVarStoreEnd (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareEfiVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN EFI_STRING_ID NameStrId,
IN UINT32 VarSize
)
@@ -1480,10 +1576,10 @@ CVfrDataStorage::DeclareEfiVarStore (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::DeclareBufferVarStore (
- IN INT8 *StoreName,
- IN EFI_GUID *Guid,
+ IN INT8 *StoreName,
+ IN EFI_GUID *Guid,
IN CVfrVarDataTypeDB *DataTypeDB,
IN INT8 *TypeName,
IN EFI_VARSTORE_ID VarStoreId
@@ -1521,7 +1617,7 @@ CVfrDataStorage::DeclareBufferVarStore (
return VFR_RETURN_SUCCESS;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreId (
IN INT8 *StoreName,
OUT EFI_VARSTORE_ID *VarStoreId
@@ -1625,9 +1721,47 @@ CVfrDataStorage::GetVarStoreType (
return VFR_RETURN_UNDEFINED;
}
+EFI_VFR_VARSTORE_TYPE
+CVfrDataStorage::GetVarStoreType (
+ IN EFI_VARSTORE_ID VarStoreId
+ )
+{
+ SVfrVarStorageNode *pNode;
+ EFI_VFR_VARSTORE_TYPE VarStoreType;
+
+ VarStoreType = EFI_VFR_VARSTORE_INVALID;
+
+ if (VarStoreId == EFI_VARSTORE_ID_INVALID) {
+ return VarStoreType;
+ }
+
+ for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mEfiVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ for (pNode = mNameVarStoreList; pNode != NULL; pNode = pNode->mNext) {
+ if (pNode->mVarStoreId == VarStoreId) {
+ VarStoreType = pNode->mVarStoreType;
+ return VarStoreType;
+ }
+ }
+
+ return VarStoreType;
+}
+
EFI_VFR_RETURN_CODE
CVfrDataStorage::GetVarStoreName (
- IN EFI_VARSTORE_ID VarStoreId,
+ IN EFI_VARSTORE_ID VarStoreId,
OUT INT8 **VarStoreName
)
{
@@ -1725,7 +1859,7 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
INT8 NewReqElt[128] = {'\0',};
INT8 *OldReqElt = NULL;
SVfrVarStorageNode *pNode = NULL;
- EFI_IFR_TYPE_VALUE Value;
+ EFI_IFR_TYPE_VALUE Value = {0};
for (pNode = mBufferVarStoreList; pNode != NULL; pNode = pNode->mNext) {
if (strcmp (pNode->mVarStoreName, StoreName) == NULL) {
@@ -1749,8 +1883,8 @@ CVfrDataStorage::BufferVarStoreRequestElementAdd (
SVfrDefaultStoreNode::SVfrDefaultStoreNode (
IN EFI_IFR_DEFAULTSTORE *ObjBinAddr,
- IN INT8 *RefName,
- IN EFI_STRING_ID DefaultStoreNameId,
+ IN INT8 *RefName,
+ IN EFI_STRING_ID DefaultStoreNameId,
IN UINT16 DefaultId
)
{
@@ -1828,7 +1962,7 @@ CVfrDefaultStore::RegisterDefaultStore (
}
/*
- * assign new reference name or new default store name id only if
+ * assign new reference name or new default store name id only if
* the original is invalid
*/
EFI_VFR_RETURN_CODE
@@ -1911,8 +2045,8 @@ CVfrDefaultStore::GetDefaultId (
STATIC
EFI_VFR_RETURN_CODE
AltCfgItemPrintToBuffer (
- IN INT8 *NewAltCfg,
- IN EFI_VARSTORE_INFO Info,
+ IN INT8 *NewAltCfg,
+ IN EFI_VARSTORE_INFO Info,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE Value
)
@@ -1923,9 +2057,9 @@ AltCfgItemPrintToBuffer (
if (NewAltCfg != NULL) {
Count = sprintf (
- NewAltCfg,
- "&OFFSET=%x&WIDTH=%x&VALUE=",
- Info.mInfo.mVarOffset,
+ NewAltCfg,
+ "&OFFSET=%x&WIDTH=%x&VALUE=",
+ Info.mInfo.mVarOffset,
Info.mVarTotalSize
);
NewAltCfg += Count;
@@ -1984,7 +2118,7 @@ AltCfgItemPrintToBuffer (
}
}
- return VFR_RETURN_FATAL_ERROR;
+ return VFR_RETURN_FATAL_ERROR;
}
EFI_VFR_RETURN_CODE
@@ -1998,6 +2132,7 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
{
SVfrDefaultStoreNode *pNode = NULL;
INT8 NewAltCfg[2 * 2 * sizeof (UINT16) + 1] = {0,};
+ INTN Returnvalue = 0;
if (VarStoreName == NULL) {
return VFR_RETURN_FATAL_ERROR;
@@ -2016,28 +2151,23 @@ CVfrDefaultStore::BufferVarStoreAltConfigAdd (
gCVfrBufferConfig.Open ();
sprintf (NewAltCfg, "%04x", pNode->mDefaultId);
- if ((gCVfrBufferConfig.Select(VarStoreName) == 0) &&
- (gCVfrBufferConfig.Select(VarStoreName, NewAltCfg) != 0)) {
- if (gCVfrBufferConfig.Write ('i', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Select(VarStoreName)) == 0) {
+ if ((Returnvalue = gCVfrBufferConfig.Write ('a', VarStoreName, NewAltCfg, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value)) != 0) {
goto WriteError;
}
}
- if (gCVfrBufferConfig.Write ('a', VarStoreName, NULL, Type, Info.mInfo.mVarOffset, Info.mVarTotalSize, Value) != 0) {
- goto WriteError;
- }
-
gCVfrBufferConfig.Close ();
return VFR_RETURN_SUCCESS;
WriteError:
gCVfrBufferConfig.Close ();
- return VFR_RETURN_FATAL_ERROR;
+ return (EFI_VFR_RETURN_CODE)Returnvalue;
}
SVfrRuleNode::SVfrRuleNode (
- IN INT8 *RuleName,
+ IN INT8 *RuleName,
IN UINT8 RuleId
)
{
@@ -2143,7 +2273,7 @@ EFI_VARSTORE_INFO::EFI_VARSTORE_INFO (
mVarTotalSize = Info.mVarTotalSize;
}
-BOOLEAN
+BOOLEAN
EFI_VARSTORE_INFO::operator == (
IN EFI_VARSTORE_INFO *Info
)
@@ -2195,7 +2325,7 @@ CVfrQuestionDB::ChekQuestionIdFree (
return (mFreeQIdBitMap[Index] & (0x80000000 >> Offset)) == 0;
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUsed (
IN EFI_QUESTION_ID QId
)
@@ -2206,7 +2336,7 @@ CVfrQuestionDB::MarkQuestionIdUsed (
mFreeQIdBitMap[Index] |= (0x80000000 >> Offset);
}
-VOID
+VOID
CVfrQuestionDB::MarkQuestionIdUnused (
IN EFI_QUESTION_ID QId
)
@@ -2321,9 +2451,9 @@ CVfrQuestionDB::RegisterQuestion (
VOID
CVfrQuestionDB::RegisterOldDateQuestion (
- IN INT8 *YearVarId,
- IN INT8 *MonthVarId,
- IN INT8 *DayVarId,
+ IN INT8 *YearVarId,
+ IN INT8 *MonthVarId,
+ IN INT8 *DayVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2379,7 +2509,7 @@ Err:
VOID
CVfrQuestionDB::RegisterNewDateQuestion (
IN INT8 *Name,
- IN INT8 *BaseVarId,
+ IN INT8 *BaseVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2463,9 +2593,9 @@ Err:
VOID
CVfrQuestionDB::RegisterOldTimeQuestion (
- IN INT8 *HourVarId,
- IN INT8 *MinuteVarId,
- IN INT8 *SecondVarId,
+ IN INT8 *HourVarId,
+ IN INT8 *MinuteVarId,
+ IN INT8 *SecondVarId,
IN OUT EFI_QUESTION_ID &QuestionId
)
{
@@ -2634,7 +2764,7 @@ CVfrQuestionDB::UpdateQuestionId (
return VFR_RETURN_SUCCESS;
}
-VOID
+VOID
CVfrQuestionDB::GetQuestionId (
IN INT8 *Name,
IN INT8 *VarIdStr,
@@ -2672,7 +2802,7 @@ CVfrQuestionDB::GetQuestionId (
return ;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN EFI_QUESTION_ID QuestionId
)
@@ -2692,7 +2822,7 @@ CVfrQuestionDB::FindQuestion (
return VFR_RETURN_UNDEFINED;
}
-EFI_VFR_RETURN_CODE
+EFI_VFR_RETURN_CODE
CVfrQuestionDB::FindQuestion (
IN INT8 *Name
)
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
index 38687b948d..fe37f83e16 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/VfrUtilityLib.h
@@ -1,5 +1,4 @@
/*++
-
Copyright (c) 2004 - 2010, 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
@@ -10,8 +9,7 @@ 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:
-
-VfrUtilityLib.h
+ VfrUtilityLib.h
Abstract:
@@ -28,7 +26,7 @@ Abstract:
#define MAX_NAME_LEN 64
#define DEFAULT_ALIGN 1
-#define DEFAULT_PACK_ALIGN 0xFFFFFFFF
+#define DEFAULT_PACK_ALIGN 0x8
#define DEFAULT_NAME_TABLE_ITEMS 1024
#define EFI_BITS_SHIFT_PER_UINT32 0x5
@@ -58,9 +56,9 @@ struct SConfigInfo {
};
struct SConfigItem {
- INT8 *mId;
- INT8 *mInfo;
- SConfigInfo *mInfoStrList;
+ INT8 *mName; // varstore name
+ INT8 *mId; // varstore ID
+ SConfigInfo *mInfoStrList; // list of Offset/Value in the varstore
SConfigItem *mNext;
public:
@@ -115,10 +113,59 @@ struct SVfrDataType {
SVfrDataType *mNext;
};
+#define VFR_PACK_ASSIGN 0x01
+#define VFR_PACK_SHOW 0x02
+#define VFR_PACK_PUSH 0x04
+#define VFR_PACK_POP 0x08
+
+#define PACKSTACK_MAX_SIZE 0x400
+
+struct SVfrPackStackNode {
+ INT8 *mIdentifier;
+ UINT32 mNumber;
+ SVfrPackStackNode *mNext;
+
+ SVfrPackStackNode (IN INT8 *Identifier, IN UINT32 Number) {
+ mIdentifier = NULL;
+ mNumber = Number;
+ mNext = NULL;
+
+ if (Identifier != NULL) {
+ mIdentifier = new INT8[strlen (Identifier) + 1];
+ strcpy (mIdentifier, Identifier);
+ }
+ }
+
+ ~SVfrPackStackNode (VOID) {
+ if (mIdentifier != NULL) {
+ delete mIdentifier;
+ }
+ mNext = NULL;
+ }
+
+ bool Match (IN INT8 *Identifier) {
+ if (Identifier == NULL) {
+ return TRUE;
+ } else if (mIdentifier == NULL) {
+ return FALSE;
+ } else if (strcmp (Identifier, mIdentifier) == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+};
+
class CVfrVarDataTypeDB {
private:
- SVfrDataType *mDataTypeList;
UINT32 mPackAlign;
+ SVfrPackStackNode *mPackStack;
+
+public:
+ EFI_VFR_RETURN_CODE Pack (IN UINT32, IN UINT8, IN INT8 *Identifier = NULL, IN UINT32 Number = DEFAULT_PACK_ALIGN);
+
+private:
+ SVfrDataType *mDataTypeList;
SVfrDataType *mNewDataType;
SVfrDataType *mCurrDataType;
@@ -138,9 +185,6 @@ public:
CVfrVarDataTypeDB (VOID);
~CVfrVarDataTypeDB (VOID);
- EFI_VFR_RETURN_CODE Pack (IN UINT32);
- VOID UnPack (VOID);
-
VOID DeclareDataTypeBegin (VOID);
EFI_VFR_RETURN_CODE SetNewTypeName (IN INT8 *);
EFI_VFR_RETURN_CODE DataTypeAddField (IN INT8 *, IN INT8 *, IN UINT32);
@@ -148,6 +192,7 @@ public:
EFI_VFR_RETURN_CODE GetDataType (IN INT8 *, OUT SVfrDataType **);
EFI_VFR_RETURN_CODE GetDataTypeSize (IN INT8 *, OUT UINT32 *);
+ EFI_VFR_RETURN_CODE GetDataTypeSize (IN UINT8, OUT UINT32 *);
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN INT8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &);
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT INT8 ***, OUT UINT32 *);
@@ -245,6 +290,7 @@ public:
EFI_VFR_RETURN_CODE GetVarStoreId (IN INT8 *, OUT EFI_VARSTORE_ID *);
EFI_VFR_RETURN_CODE GetVarStoreType (IN INT8 *, OUT EFI_VFR_VARSTORE_TYPE &);
+ EFI_VFR_VARSTORE_TYPE GetVarStoreType (IN EFI_VARSTORE_ID);
EFI_VFR_RETURN_CODE GetVarStoreName (IN EFI_VARSTORE_ID, OUT INT8 **);
EFI_VFR_RETURN_CODE GetBufferVarStoreDataTypeName (IN INT8 *, OUT INT8 **);
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
index e4424fcc3f..b266cfe03c 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/UefiVfrCompile/makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -55,7 +55,8 @@ INC = -I $(SRC) \
ANTLR_FLAGS = -CC -e3 -ck 3 -k 2
DLG_FLAGS = -C2 -i -CC
LINK_FLAGS_PCCTS = /DEBUG /PDB:$*.pdb
-C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
+C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /WX /Od /EHsc /Zi /Fd$(ETO)\$(TARGET_NAME)Obj /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) \
+ $(BUILD_STRING_FLAGS) /D PCCTS_USE_NAMESPACE_STD #/D CVFR_VARDATATYPEDB_DEBUG /D CIFROBJ_DEUBG /D VFREXP_DEBUG
VFR_GRAMMER_FILE = $(SRC)\VfrSyntax.g
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
index c520ad28f5..b82713177c 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/EfiVfr.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -31,7 +31,8 @@ Abstract:
// This number should be incremented with each change to the VFR compiler.
// We write the version to the output list file for debug purposes.
//
-#define VFR_COMPILER_VERSION "1.88"
+#define UTILITY_VERSION "v1.9"
+#define UTILITY_NAME "VfrCompile"
//
// Maximum file path for filenames
@@ -39,7 +40,6 @@ Abstract:
#define MAX_PATH 255
#define MAX_QUEUE_COUNT 255
#define MAX_LINE_LEN 1024
-#define PROGRAM_NAME "VfrCompile"
//
// We parse C-style structure definitions which can then be referenced
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
index ce574ada12..7c0d78f010 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrCompile.g
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -130,7 +130,7 @@ Returns:
// Set our program name for the error printing routines.
// Then set printing limits.
//
- SetUtilityName (PROGRAM_NAME);
+ SetUtilityName (UTILITY_NAME);
SetPrintLimits (20, 20, 30);
//
// Process the command-line arguments
@@ -145,7 +145,7 @@ Returns:
// Verify the VFR script file exists
//
if ((VfrFptr = fopen (gOptions.VfrFileName, "r")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
+ Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "could not open input VFR file");
Cleanup();
return STATUS_ERROR;
}
@@ -164,7 +164,7 @@ Returns:
}
Cmd = (char *)malloc (Len);
if (Cmd == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "could not allocate memory");
+ Error (UTILITY_NAME, 0, 0, NULL, "could not allocate memory");
Cleanup();
return STATUS_ERROR;
}
@@ -182,7 +182,7 @@ Returns:
strcat (Cmd, gOptions.PreprocessorOutputFileName);
Status = system (Cmd);
if (Status != 0) {
- Error (PROGRAM_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
+ Error (UTILITY_NAME, 0, 0, gOptions.VfrFileName, "failed to spawn C preprocessor on VFR file");
printf ("Command: '%s %s'\n", PREPROCESSOR_COMMAND, Cmd);
Cleanup();
return STATUS_ERROR;
@@ -192,7 +192,7 @@ Returns:
// Open the preprocessor output file
//
if ((VfrFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, "failed to open input VFR preprocessor output file",
+ Error (UTILITY_NAME, 0, 0, "failed to open input VFR preprocessor output file",
gOptions.PreprocessorOutputFileName);
Cleanup();
return STATUS_ERROR;
@@ -339,7 +339,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-i") == 0) {
if ((Argc < 2) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing path argument");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing path argument");
return STATUS_ERROR;
}
Argc--;
@@ -351,7 +351,7 @@ Returns:
}
IncludePaths = (INT8 *)malloc (Len);
if (IncludePaths == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
IncludePaths[0] = 0;
@@ -367,7 +367,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-od") == 0) {
if ((Argc < 2) || (Argv[1][0] == '-')) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing output directory name");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing output directory name");
return STATUS_ERROR;
}
Argc--;
@@ -383,7 +383,7 @@ Returns:
//
} else if (_stricmp (Argv[0], "-ppflag") == 0) {
if (Argc < 2) {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "missing C-preprocessor argument");
return STATUS_ERROR;
}
Argc--;
@@ -394,7 +394,7 @@ Returns:
}
CPreprocessorOptions = (INT8 *)malloc (Len);
if (CPreprocessorOptions == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return STATUS_ERROR;
}
CPreprocessorOptions[0] = 0;
@@ -406,7 +406,7 @@ Returns:
strcat (CPreprocessorOptions, Argv[0]);
gOptions.CPreprocessorOptions = CPreprocessorOptions;
} else {
- Error (PROGRAM_NAME, 0, 0, Argv[0], "unrecognized option");
+ Error (UTILITY_NAME, 0, 0, Argv[0], "unrecognized option");
return STATUS_ERROR;
}
Argc--;
@@ -416,10 +416,10 @@ Returns:
// Must specify at least the vfr file name
//
if (Argc > 1) {
- Error (PROGRAM_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
+ Error (UTILITY_NAME, 0, 0, Argv[1], "unrecognized argument after VFR file name");
return STATUS_ERROR;
} else if (Argc < 1) {
- Error (PROGRAM_NAME, 0, 0, NULL, "must specify VFR file name");
+ Error (UTILITY_NAME, 0, 0, NULL, "must specify VFR file name");
return STATUS_ERROR;
}
strcpy (gOptions.VfrFileName, Argv[0]);
@@ -501,26 +501,31 @@ Returns:
--*/
{
- int Index;
- const char *Help[] = {
- " ",
- "VfrCompile version " VFR_COMPILER_VERSION,
- " ",
- " Usage: VfrCompile {options} [VfrFile]",
- " ",
- " where options include:",
- " -? or -h prints this help",
- " -l create an output IFR listing file",
- " -i IncPath add IncPath to the search path for VFR included files",
- " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
- " -ibin create an IFR HII pack file",
- " where parameters include:",
- " VfrFile name of the input VFR script file",
- " ",
+ int Index;
+ const char *Str[] = {
+ UTILITY_NAME" "UTILITY_VERSION" - Intel VFR Compiler Utility",
+ " Copyright (C), 2004 - 2008 Intel Corporation",
+#if ( defined(UTILITY_BUILD) && defined(UTILITY_VENDOR) )
+ " Built from "UTILITY_BUILD", project of "UTILITY_VENDOR,
+#endif
+ "",
+ "Usage:",
+ " "UTILITY_NAME" [OPTION] VFRFILE",
+ "Description:",
+ " Compile VFRFILE.",
+ "Options:",
+ " -? or -h print this help",
+ " -l create an output IFR listing file",
+ " -i IncPath add IncPath to the search path for VFR included files",
+ " -od OutputDir deposit all output files to directory OutputDir (default=cwd)",
+ " -ibin create an IFR HII pack file",
+ " -ppflag CFlags pass Flags as C-preprocessor-flag",
+ " -v or -version print version information",
NULL
- };
- for (Index = 0; Help[Index] != NULL; Index++) {
- fprintf (stdout, "%s\n", Help[Index]);
+ };
+
+ for (Index = 0; Str[Index] != NULL; Index++) {
+ fprintf (stdout, "%s\n", Str[Index]);
}
}
@@ -591,7 +596,7 @@ Returns:
}
gLastLineDefinition = LineDef;
} else {
- Error (PROGRAM_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
+ Error (UTILITY_NAME, 0, 0, "invalid line definition in preprocessor output file", TokenString);
free (LineDef);
return;
}
@@ -2318,7 +2323,7 @@ EfiVfrParser::QueueIdEqValList (
U16 = (UINT16_LIST *)malloc (sizeof (UINT16_LIST));
if (U16 == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failed");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failed");
} else {
memset ((char *)U16, 0, sizeof (UINT16_LIST));
U16->Value = Value;
@@ -2378,7 +2383,7 @@ EfiVfrParser::PrintErrorMessage (
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
Error (FileName, LineNum, 0, Msg1, Msg2);
} else {
- Error (PROGRAM_NAME, 0, 0, Msg1, Msg2);
+ Error (UTILITY_NAME, 0, 0, Msg1, Msg2);
}
}
VOID
@@ -2394,7 +2399,7 @@ EfiVfrParser::PrintWarningMessage (
FileName = ConvertLineNumber ((UINT32 *)&LineNum);
Warning (FileName, LineNum, 0, Msg1, Msg2);
} else {
- Warning (PROGRAM_NAME, 0, 0, Msg1, Msg2);
+ Warning (UTILITY_NAME, 0, 0, Msg1, Msg2);
}
}
VOID
@@ -3357,7 +3362,7 @@ Returns:
NewRef = (GOTO_REFERENCE *)malloc (sizeof (GOTO_REFERENCE));
if (NewRef == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return;
}
memset ((char *)NewRef, 0, sizeof (GOTO_REFERENCE));
@@ -3423,7 +3428,7 @@ Returns:
//
NewFormId = (FORM_ID_VALUE *)malloc (sizeof (FORM_ID_VALUE));
if (NewFormId == NULL) {
- Error (PROGRAM_NAME, 0, 0, NULL, "memory allocation failure");
+ Error (UTILITY_NAME, 0, 0, NULL, "memory allocation failure");
return;
}
memset ((char *)NewFormId, 0, sizeof (FORM_ID_VALUE));
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
index 4d3ba3d318..8555f2eb73 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/VfrServices.cpp
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2010, 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
@@ -220,7 +220,7 @@ Returns:
//
if (GetUtilityStatus () != STATUS_ERROR) {
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "w")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
+ Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
return;
}
//
@@ -290,7 +290,7 @@ Returns:
strcat (gOptions.IfrOutputFileName, ".hpk");
}
if ((IfrBinFptr = fopen (gOptions.IfrOutputFileName, "wb")) == NULL) {
- Error (PROGRAM_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
+ Error (UTILITY_NAME, 0, 0, gOptions.IfrOutputFileName, "could not open file for writing");
return;
}
//
@@ -329,10 +329,10 @@ Returns:
// Open the input VFR file and the output list file
//
if ((InFptr = fopen (gOptions.PreprocessorOutputFileName, "r")) == NULL) {
- Warning (PROGRAM_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
+ Warning (UTILITY_NAME, 0, 0, gOptions.PreprocessorOutputFileName, "could not open file for creating a list file");
} else {
if ((OutFptr = fopen (gOptions.VfrListFileName, "w")) == NULL) {
- Warning (PROGRAM_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
+ Warning (UTILITY_NAME, 0, 0, gOptions.VfrListFileName, "could not open output list file for writing");
fclose (InFptr);
InFptr = NULL;
} else {
@@ -350,7 +350,7 @@ Returns:
//
// Write out the VFR compiler version
//
- fprintf (OutFptr, "//\n// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (OutFptr, "//\n// VFR compiler version " UTILITY_VERSION "\n//\n");
Curr = mIfrBytes;
while (Curr != NULL) {
//
@@ -590,7 +590,7 @@ Returns:
// Check for buffer overflow
//
if (mQueuedByteCount >= MAX_QUEUE_COUNT) {
- Error (PROGRAM_NAME, 0, 0, NULL, "opcode queue overflow");
+ Error (UTILITY_NAME, 0, 0, NULL, "opcode queue overflow");
} else {
mQueuedBytes[mQueuedByteCount] = ByteVal;
mQueuedKeyBytes[mQueuedByteCount] = KeyByte;
@@ -750,5 +750,5 @@ Returns:
//
// Write out the VFR compiler version
//
- fprintf (OutFptr, "// VFR compiler version " VFR_COMPILER_VERSION "\n//\n");
+ fprintf (OutFptr, "// VFR compiler version " UTILITY_VERSION "\n//\n");
}
diff --git a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
index b55b09c4ed..1859deb03e 100644
--- a/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
+++ b/EdkCompatibilityPkg/Sample/Tools/Source/VfrCompile/makefile
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2004 - 2010, 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
@@ -37,7 +37,7 @@ TOOLCHAIN = TOOLCHAIN_MSVC
TARGET_NAME = VfrCompile
ANTLR_H = $(PCCTS_DIR)\h
-C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS)
+C_FLAGS_PCCTS = -I. -I$(ANTLR_H) /Zi /Fd$(EDK_TOOLS_OUTPUT)\$(TARGET_NAME)Obj /WX /Od /D _CRT_SECURE_NO_DEPRECATE $(VERSION_FLAGS) $(BUILD_STRING_FLAGS)
C_FLAGS_PCCTS = $(C_FLAGS_PCCTS)
LINK_FLAGS_PCCTS =
diff --git a/EdkCompatibilityPkg/Sample/Version.env b/EdkCompatibilityPkg/Sample/Version.env
index 1c6e9a9f03..cef19d4ce9 100644
--- a/EdkCompatibilityPkg/Sample/Version.env
+++ b/EdkCompatibilityPkg/Sample/Version.env
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2010, 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
@@ -39,3 +39,5 @@ PI_SPECIFICATION_VERSION = 0x00000009
!ENDIF
TIANO_RELEASE_VERSION = 0x00080006
+
+EDK_BUILD_VERSION = Edk1.06