From fd171542e0aa89ac12a09d79608173f48019b14b Mon Sep 17 00:00:00 2001 From: vanjeff Date: Fri, 11 Sep 2009 03:14:43 +0000 Subject: Sync basetools' source and binary files with r1707 of the basetools project. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9257 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Bin/Win32/BootSectImage.exe | Bin 393216 -> 393216 bytes BaseTools/Bin/Win32/EfiLdrImage.exe | Bin 421888 -> 421888 bytes BaseTools/Bin/Win32/EfiRom.exe | Bin 446464 -> 446464 bytes BaseTools/Bin/Win32/Fpd2Dsc.exe | Bin 1429893 -> 1428166 bytes BaseTools/Bin/Win32/GenBootSector.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/GenCrc32.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/GenDepex.exe | Bin 610615 -> 609978 bytes BaseTools/Bin/Win32/GenFds.exe | Bin 1435795 -> 1436502 bytes BaseTools/Bin/Win32/GenFfs.exe | Bin 430080 -> 430080 bytes BaseTools/Bin/Win32/GenFv.exe | Bin 479232 -> 475136 bytes BaseTools/Bin/Win32/GenFw.exe | Bin 466944 -> 466944 bytes BaseTools/Bin/Win32/GenPage.exe | Bin 421888 -> 421888 bytes BaseTools/Bin/Win32/GenSec.exe | Bin 446464 -> 446464 bytes BaseTools/Bin/Win32/GenVtf.exe | Bin 442368 -> 442368 bytes BaseTools/Bin/Win32/LzmaCompress.exe | Bin 397312 -> 397312 bytes BaseTools/Bin/Win32/MigrationMsa2Inf.exe | Bin 1376958 -> 1377946 bytes BaseTools/Bin/Win32/Spd2Dec.exe | Bin 1383590 -> 1382227 bytes BaseTools/Bin/Win32/Split.exe | Bin 425984 -> 425984 bytes BaseTools/Bin/Win32/TargetTool.exe | Bin 580600 -> 581279 bytes BaseTools/Bin/Win32/TianoCompress.exe | Bin 434176 -> 434176 bytes BaseTools/Bin/Win32/Trim.exe | Bin 672865 -> 672823 bytes BaseTools/Bin/Win32/VfrCompile.exe | Bin 1146880 -> 1146880 bytes BaseTools/Bin/Win32/VolInfo.exe | Bin 471040 -> 471040 bytes BaseTools/Bin/Win32/build.exe | Bin 1691067 -> 1686082 bytes BaseTools/Conf/build_rule.template | 87 +++++- BaseTools/Conf/tools_def.template | 268 +++++++++++++++++ BaseTools/ReadMe.txt | 4 +- BaseTools/Source/C/BootSectImage/bootsectimage.c | 36 +-- BaseTools/Source/C/Common/BasePeCoff.c | 56 ++-- BaseTools/Source/C/Common/CommonLib.c | 6 +- BaseTools/Source/C/Common/EfiUtilityMsgs.c | 14 +- BaseTools/Source/C/Common/EfiUtilityMsgs.h | 4 +- BaseTools/Source/C/Common/MyAlloc.c | 56 ++-- .../Source/C/Common/ParseGuidedSectionTools.c | 1 + BaseTools/Source/C/Common/ParseInf.c | 10 +- BaseTools/Source/C/Common/SimpleFileParsing.c | 14 +- BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c | 8 +- BaseTools/Source/C/EfiRom/EfiRom.c | 59 ++-- BaseTools/Source/C/GenBootSector/GenBootSector.c | 11 +- BaseTools/Source/C/GenCrc32/GenCrc32.c | 15 +- BaseTools/Source/C/GenFfs/GenFfs.c | 22 +- BaseTools/Source/C/GenFv/GenFv.c | 81 ++--- BaseTools/Source/C/GenFv/GenFvInternalLib.c | 256 ++++++++-------- BaseTools/Source/C/GenFw/GenFw.c | 145 +++++---- BaseTools/Source/C/GenFw/elf_generic.h | 88 ------ BaseTools/Source/C/GenPage/GenPage.c | 5 +- BaseTools/Source/C/GenSec/GenSec.c | 49 +-- BaseTools/Source/C/GenVtf/GenVtf.c | 24 +- BaseTools/Source/C/GenVtf/GenVtf.h | 3 + .../Source/C/GnuGenBootSector/GnuGenBootSector.c | 11 +- BaseTools/Source/C/Include/Common/BaseTypes.h | 16 +- BaseTools/Source/C/Include/Common/PiFirmwareFile.h | 1 + BaseTools/Source/C/Include/Common/UefiCapsule.h | 3 +- .../Common/UefiInternalFormRepresentation.h | 2 +- BaseTools/Source/C/Include/Ia32/ProcessorBind.h | 4 +- .../Source/C/Include/IndustryStandard/Acpi1_0.h | 1 + BaseTools/Source/C/LzmaCompress/LzmaCompress.c | 2 +- BaseTools/Source/C/Makefiles/header.makefile | 2 +- BaseTools/Source/C/Makefiles/ms.common | 2 +- BaseTools/Source/C/Split/Split.c | 4 +- BaseTools/Source/C/TianoCompress/TianoCompress.c | 11 +- BaseTools/Source/C/VfrCompile/VfrError.cpp | 6 +- BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp | 11 + BaseTools/Source/C/VfrCompile/VfrFormPkg.h | 35 ++- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 178 ++++++++--- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 +- BaseTools/Source/C/VfrCompile/VfrUtilityLib.h | 5 +- BaseTools/Source/C/VolInfo/VolInfo.c | 35 ++- BaseTools/Source/Python/AutoGen/AutoGen.py | 35 ++- BaseTools/Source/Python/AutoGen/GenMake.py | 8 +- BaseTools/Source/Python/AutoGen/StrGather.py | 10 +- BaseTools/Source/Python/Common/DscClassObject.py | 9 +- BaseTools/Source/Python/Common/FdfParserLite.py | 49 ++- BaseTools/Source/Python/Common/Misc.py | 12 +- BaseTools/Source/Python/Ecc/Ecc.py | 70 ++--- BaseTools/Source/Python/GenFds/Capsule.py | 19 +- BaseTools/Source/Python/GenFds/CapsuleData.py | 7 +- BaseTools/Source/Python/GenFds/Fd.py | 20 +- BaseTools/Source/Python/GenFds/FdfParser.py | 334 +++++++++++++++------ BaseTools/Source/Python/GenFds/FfsFileStatement.py | 3 +- BaseTools/Source/Python/GenFds/Fv.py | 30 +- BaseTools/Source/Python/GenFds/GenFds.py | 74 ++--- .../Source/Python/GenFds/GenFdsGlobalVariable.py | 6 +- .../Source/Python/GenFds/OptRomInfStatement.py | 10 +- BaseTools/Source/Python/GenFds/OptionRom.py | 2 +- BaseTools/Source/Python/GenFds/Region.py | 219 +++++++++----- .../Source/Python/Workspace/MetaFileParser.py | 20 +- .../Source/Python/Workspace/WorkspaceDatabase.py | 156 ++++++---- BaseTools/Source/Python/build/build.py | 14 +- BaseTools/Tests/CheckPythonSyntax.py | 4 +- BaseTools/toolsetup.bat | 4 +- 91 files changed, 1795 insertions(+), 975 deletions(-) delete mode 100644 BaseTools/Source/C/GenFw/elf_generic.h (limited to 'BaseTools') diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe index 966832de32..b019e9e816 100755 Binary files a/BaseTools/Bin/Win32/BootSectImage.exe and b/BaseTools/Bin/Win32/BootSectImage.exe differ diff --git a/BaseTools/Bin/Win32/EfiLdrImage.exe b/BaseTools/Bin/Win32/EfiLdrImage.exe index 89c655d3dc..bb4f216d00 100755 Binary files a/BaseTools/Bin/Win32/EfiLdrImage.exe and b/BaseTools/Bin/Win32/EfiLdrImage.exe differ diff --git a/BaseTools/Bin/Win32/EfiRom.exe b/BaseTools/Bin/Win32/EfiRom.exe index 643162e87b..e733065ad5 100755 Binary files a/BaseTools/Bin/Win32/EfiRom.exe and b/BaseTools/Bin/Win32/EfiRom.exe differ diff --git a/BaseTools/Bin/Win32/Fpd2Dsc.exe b/BaseTools/Bin/Win32/Fpd2Dsc.exe index a1fbc59d91..3596a11e70 100755 Binary files a/BaseTools/Bin/Win32/Fpd2Dsc.exe and b/BaseTools/Bin/Win32/Fpd2Dsc.exe differ diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe index 48a17af7e6..2de33515c5 100755 Binary files a/BaseTools/Bin/Win32/GenBootSector.exe and b/BaseTools/Bin/Win32/GenBootSector.exe differ diff --git a/BaseTools/Bin/Win32/GenCrc32.exe b/BaseTools/Bin/Win32/GenCrc32.exe index 01234aff5f..13a9f95431 100755 Binary files a/BaseTools/Bin/Win32/GenCrc32.exe and b/BaseTools/Bin/Win32/GenCrc32.exe differ diff --git a/BaseTools/Bin/Win32/GenDepex.exe b/BaseTools/Bin/Win32/GenDepex.exe index ba2f00a56f..bf95890df0 100755 Binary files a/BaseTools/Bin/Win32/GenDepex.exe and b/BaseTools/Bin/Win32/GenDepex.exe differ diff --git a/BaseTools/Bin/Win32/GenFds.exe b/BaseTools/Bin/Win32/GenFds.exe index c9c35caccf..35a9cdca6b 100755 Binary files a/BaseTools/Bin/Win32/GenFds.exe and b/BaseTools/Bin/Win32/GenFds.exe differ diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe index 3ee7925217..b4ae615890 100755 Binary files a/BaseTools/Bin/Win32/GenFfs.exe and b/BaseTools/Bin/Win32/GenFfs.exe differ diff --git a/BaseTools/Bin/Win32/GenFv.exe b/BaseTools/Bin/Win32/GenFv.exe index 6011dd3176..5496946bd7 100755 Binary files a/BaseTools/Bin/Win32/GenFv.exe and b/BaseTools/Bin/Win32/GenFv.exe differ diff --git a/BaseTools/Bin/Win32/GenFw.exe b/BaseTools/Bin/Win32/GenFw.exe index f2b04ed369..9b54f6a9bd 100755 Binary files a/BaseTools/Bin/Win32/GenFw.exe and b/BaseTools/Bin/Win32/GenFw.exe differ diff --git a/BaseTools/Bin/Win32/GenPage.exe b/BaseTools/Bin/Win32/GenPage.exe index 41ac4348e1..0de67229b0 100755 Binary files a/BaseTools/Bin/Win32/GenPage.exe and b/BaseTools/Bin/Win32/GenPage.exe differ diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe index 0c828b8919..c928617651 100755 Binary files a/BaseTools/Bin/Win32/GenSec.exe and b/BaseTools/Bin/Win32/GenSec.exe differ diff --git a/BaseTools/Bin/Win32/GenVtf.exe b/BaseTools/Bin/Win32/GenVtf.exe index 32eb2c1c48..f0acfc357c 100755 Binary files a/BaseTools/Bin/Win32/GenVtf.exe and b/BaseTools/Bin/Win32/GenVtf.exe differ diff --git a/BaseTools/Bin/Win32/LzmaCompress.exe b/BaseTools/Bin/Win32/LzmaCompress.exe index 8ca0bbc214..c4e15ef7e3 100644 Binary files a/BaseTools/Bin/Win32/LzmaCompress.exe and b/BaseTools/Bin/Win32/LzmaCompress.exe differ diff --git a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe index c45663f20f..f2d4b18e87 100755 Binary files a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe and b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe differ diff --git a/BaseTools/Bin/Win32/Spd2Dec.exe b/BaseTools/Bin/Win32/Spd2Dec.exe index 26a173da06..7fdad3e50e 100755 Binary files a/BaseTools/Bin/Win32/Spd2Dec.exe and b/BaseTools/Bin/Win32/Spd2Dec.exe differ diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe index 4b01ebab3f..305c068b57 100755 Binary files a/BaseTools/Bin/Win32/Split.exe and b/BaseTools/Bin/Win32/Split.exe differ diff --git a/BaseTools/Bin/Win32/TargetTool.exe b/BaseTools/Bin/Win32/TargetTool.exe index 8e13c992b8..1e250c8b9b 100755 Binary files a/BaseTools/Bin/Win32/TargetTool.exe and b/BaseTools/Bin/Win32/TargetTool.exe differ diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe index b95b67f7cb..8ba3c2fd10 100755 Binary files a/BaseTools/Bin/Win32/TianoCompress.exe and b/BaseTools/Bin/Win32/TianoCompress.exe differ diff --git a/BaseTools/Bin/Win32/Trim.exe b/BaseTools/Bin/Win32/Trim.exe index 2dd6c4d5ca..3fd05d5dcc 100755 Binary files a/BaseTools/Bin/Win32/Trim.exe and b/BaseTools/Bin/Win32/Trim.exe differ diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe index e9b9977627..d1d0e29ce9 100755 Binary files a/BaseTools/Bin/Win32/VfrCompile.exe and b/BaseTools/Bin/Win32/VfrCompile.exe differ diff --git a/BaseTools/Bin/Win32/VolInfo.exe b/BaseTools/Bin/Win32/VolInfo.exe index ebbe39809f..7cff9e93d3 100755 Binary files a/BaseTools/Bin/Win32/VolInfo.exe and b/BaseTools/Bin/Win32/VolInfo.exe differ diff --git a/BaseTools/Bin/Win32/build.exe b/BaseTools/Bin/Win32/build.exe index ac127742c0..56245f547b 100755 Binary files a/BaseTools/Bin/Win32/build.exe and b/BaseTools/Bin/Win32/build.exe differ diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template index e961674d34..f036fb375f 100644 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -1,6 +1,6 @@ # # Copyright (c) 2007-2009, Intel Corporation -# +# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved. # All rights reserved. This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -125,8 +125,9 @@ "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src} - - "$(CC)" -o ${dst} $(CC_FLAGS) $(INC) ${src} + + # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues + "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src} "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst} [C-Header-File] @@ -139,7 +140,7 @@ [Assembly-Code-File.COMMON.COMMON] - + ?.asm, ?.Asm, ?.ASM @@ -156,10 +157,11 @@ Trim --source-code --convert-hex -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i "$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii - + "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i - "$(ASM)" -o ${dst} $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii + # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues + "$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii [Assembly-Code-File.COMMON.IPF] @@ -174,7 +176,8 @@ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i - "$(ASM)" -o ${dst} $(ASM_FLAGS) ${d_path}(+)${s_base}.iii + # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues + "$(ASM)" $(ASM_FLAGS) -o ${dst} ${d_path}(+)${s_base}.iii [Visual-Form-Representation-File] @@ -191,9 +194,8 @@ -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1 "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i - Trim --vfr-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -$(MD) ${d_path} > NUL 2>&1 - "$(VFR)" $(VFR_FLAGS) --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii + "$(VFR)" $(VFR_FLAGS) --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i [Object-File] @@ -208,6 +210,16 @@ "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @"$(OBJECT_FILES_LIST)" + + + "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST) + + + # $(OBJECT_FILES_LIST) has wrong paths for cygwin + "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES) + + + "$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST) [Static-Library-File] @@ -226,6 +238,17 @@ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @"$(STATIC_LIBRARY_FILES_LIST)" -\) $(DLINK2_FLAGS) "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} + + "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + + + #$(STATIC_LIBRARY_FILES_LIST) has wrong paths for cygwin + "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS) + + + "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + + [Static-Library-File.USER_DEFINED] *.lib @@ -242,6 +265,17 @@ "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS) + + "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + + + #$(STATIC_LIBRARY_FILES_LIST) has the wrong paths for cygwin + "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS) + + + "$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + + [Dynamic-Library-File] ?.dll @@ -249,11 +283,21 @@ $(DEBUG_DIR)(+)$(MODULE_NAME).efi - + GenFw -e $(MODULE_TYPE) -o ${dst} ${src} $(CP) ${dst} $(OUTPUT_DIR) $(CP) ${dst} $(BIN_DIR) -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR) + + + # tool to convert Mach-O to PE/COFF + "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff + # create symbol file for GDB debug + -$(DSYMUTIL) ${src} + GenFw -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff + $(CP) ${dst} $(OUTPUT_DIR) + $(CP) ${dst} $(BIN_DIR) + -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR) [Dependency-Expression-File] @@ -326,7 +370,14 @@ "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src} "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll - + + + "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src} + "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj + "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi + GenFw -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi + + [Masm16-Code-File] ?.asm16, ?.Asm16, ?.ASM16 @@ -342,6 +393,20 @@ "$(ASM)" /nologo /c /omf /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src} "$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,, + + "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i + Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i + "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii + "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj -) + + + "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i + Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i + "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii + "$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj + otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst} + + [Microcode-File] ?.txt, ?.TXT, ?.Txt, ?.mut diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index bd8b03ef3d..b3132a08fe 100644 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -1,5 +1,6 @@ # # Copyright (c) 2006-2009, Intel Corporation +# Portions copyright (c) 2008-2009 Apple Inc. All rights reserved. # # All rights reserved. This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -100,6 +101,12 @@ DEFINE ICC_WIN_ASLPP_FLAGS = /nologo /EP /C DEFINE ICC_WIN_ASLCC_FLAGS = /Y- /TC /WX- /Od /Dmain=ReferenceAcpiTable DEFINE ICC_WIN_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:CONSOLE /NODEFAULTLIB:libmmt /NODEFAULTLIB:libirc +DEFINE IPHONE_TOOLS = /Developer/Platforms/iPhoneOS.platform/Developer +DEFINE RVCT31_TOOLS_PATH = c:/Program Files/ARM/RVCT/Programs/3.1/761/win_32-pentium +DEFINE RVCT31CYGWIN_TOOLS_PATH = /cygdrive/c/Program\ Files/ARM/RVCT/Programs/3.1/761/win_32-pentium + +# Update to the location of the gcc executables +DEFINE ARMGCC_BIN = / #################################################################################### # @@ -2040,6 +2047,267 @@ RELEASE_MYTOOLS_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT *_MYTOOLS_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC *_MYTOOLS_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP + +#################################################################################### +# +# Xcode Support for building on Mac OS X (Snow Leopard) +# +#################################################################################### +# XCODE32 - Xcode 3.2 Tools (Snow Leopard) +*_XCODE32_*_*_FAMILY = GCC +*_XCODE32_*_*_BUILDRULEFAMILY = XCODE + + +*_XCODE32_*_ASL_PATH = /usr/bin/iasl + +*_XCODE32_*_MAKE_PATH = make + +# This tool needs to be installed seperatly from Xcode 3.2 +*_XCODE32_*_MTOC_PATH = /Developer/usr/bin/mtoc +*_XCODE32_*_DSYMUTIL_PATH = /usr/bin/dsymutil + + DEBUG_XCODE32_*_MTOC_FLAGS = -align 0x20 -d $(DEBUG_DIR)/$(MODULE_NAME).dll +RELEASE_XCODE32_*_MTOC_FLAGS = -align 0x20 + +################## +# IA32 definitions +################## +*_XCODE32_IA32_CC_PATH = gcc +*_XCODE32_IA32_SLINK_PATH = libtool +*_XCODE32_IA32_DLINK_PATH = ld +*_XCODE32_IA32_ASM_PATH = as +*_XCODE32_IA32_PP_PATH = gcc +*_XCODE32_IA32_VFRPP_PATH = gcc +*_XCODE32_IA32_ASL_PATH = iasl +*_XCODE32_IA32_ASLCC_PATH = gcc +*_XCODE32_IA32_ASLPP_PATH = gcc +*_XCODE32_IA32_ASLDLINK_PATH = ld + + DEBUG_XCODE32_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -slow_stubs -pie -all_load -dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +RELEASE_XCODE32_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -slow_stubs -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +*_XCODE32_IA32_SLINK_FLAGS = -static -o + DEBUG_XCODE32_IA32_ASM_FLAGS = -arch i386 -g +RELEASE_XCODE32_IA32_ASM_FLAGS = -arch i386 +*_XCODE32_IA32_PP_FLAGS = -arch i386 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h +*_XCODE32_IA32_VFRPP_FLAGS = -arch i386 -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h + DEBUG_XCODE32_IA32_CC_FLAGS = -arch i386 -save-temps -g -O0 -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector +RELEASE_XCODE32_IA32_CC_FLAGS = -arch i386 -Oz -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector + +*_XCODE32_IA32_ASLCC_FLAGS = -arch i386 -x c -save-temps -g -O0 -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h -mdynamic-no-pic +*_XCODE32_IA32_ASLDLINK_FLAGS = -arch i386 -e _main -preload -segalign 0x20 -slow_stubs -pie -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +*_XCODE32_IA32_ASLPP_FLAGS = -arch i386 -x c -E +*_XCODE32_IA32_ASL_FLAGS = + +################## +# X64 definitions - still a work in progress. This tool chain does not produce +# the correct ABI, it is just used to compile the code.... +################## +*_XCODE32_X64_CC_PATH = gcc-4.2 +*_XCODE32_X64_SLINK_PATH = libtool +*_XCODE32_X64_DLINK_PATH = ld +*_XCODE32_X64_ASM_PATH = as +*_XCODE32_X64_PP_PATH = gcc-4.2 +*_XCODE32_X64_VFRPP_PATH = gcc-4.2 +*_XCODE32_X64_ASL_PATH = iasl +*_XCODE32_X64_ASLCC_PATH = gcc +*_XCODE32_X64_ASLPP_PATH = gcc +*_XCODE32_X64_ASLDLINK_PATH = ld + +*_XCODE32_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -slow_stubs -pie -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +*_XCODE32_X64_SLINK_FLAGS = -static -o + + DEBUG_XCODE32_X64_ASM_FLAGS = -arch x86_64 -g +RELEASE_XCODE32_X64_ASM_FLAGS = -arch x86_64 +*_XCODE32_X64_PP_FLAGS = -arch x86_64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h +*_XCODE32_X64_VFRPP_FLAGS = -arch x86_64 -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h + + DEBUG_XCODE32_X64_CC_FLAGS = -arch x86_64 -save-temps -g -O0 -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-address -fomit-frame-pointer -static -c -include AutoGen.h -fno-stack-protector +RELEASE_XCODE32_X64_CC_FLAGS = -arch x86_64 -Oz -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-address -fomit-frame-pointer -static -c -include AutoGen.h -fno-stack-protector + +################## +# ARM definitions - still a work in progress (Assumes iPhone SDK installed) +################## + +*_XCODE32_ARM_ARCHCC_FLAGS = -arch armv6 -march=armv6 -mthumb +*_XCODE32_ARM_ARCHASM_FLAGS = -arch armv6 +*_XCODE32_ARM_ARCHDLINK_FLAGS = -arch armv6 +*_XCODE32_ARM_PLATFORM_FLAGS = +*_XCODE32_ARM_INTRINSIC_FLAGS = CompilerIntrinsicsLib.lib + +*_XCODE32_ARM_CC_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc +*_XCODE32_ARM_SLINK_PATH = DEF(IPHONE_TOOLS)/usr/bin/libtool +*_XCODE32_ARM_DLINK_PATH = DEF(IPHONE_TOOLS)/usr/bin/ld +*_XCODE32_ARM_ASM_PATH = DEF(IPHONE_TOOLS)/usr/bin/as +*_XCODE32_ARM_PP_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc +*_XCODE32_ARM_VFRPP_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc + + DEBUG_XCODE32_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -slow_stubs -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map ENV(EDK_TOOLS_PATH)/Bin/Darwin-i386/ARM/DEBUG_XCODE32/$(INTRINSIC_FLAGS) +RELEASE_XCODE32_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -slow_stubs -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map ENV(EDK_TOOLS_PATH)/Bin/Darwin-i386/ARM/RELEASE_XCODE32/$(INTRINSIC_FLAGS) + +*_XCODE32_ARM_SLINK_FLAGS = -static -o + + DEBUG_XCODE32_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -g +RELEASE_XCODE32_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) +*_XCODE32_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h +*_XCODE32_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h + + DEBUG_XCODE32_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mthumb-interwork -g -Oz -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector +RELEASE_XCODE32_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mthumb-interwork -Oz -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector + + +#################################################################################### +# +# ARM Tools +# +#################################################################################### +# RVCT31 - Tools from ARM + +*_RVCT31_*_*_FAMILY = RVCT + +# +# Use default values, or override in DSC file +# +*_RVCT31_ARM_ARCHCC_FLAGS = --thumb --cpu ARM1176JZF-S +*_RVCT31_ARM_ARCHASM_FLAGS = --cpu ARM1176JZF-S +*_RVCT31_ARM_ARCHDLINK_FLAGS = +*_RVCT31_ARM_PLATFORM_FLAGS = +*_RVCT31_ARM_INTRINSIC_FLAGS = CompilerIntrinsicsLib.lib + + DEBUG_RVCT31_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map ENV(EDK_TOOLS_PATH)/Bin/Win32/ARM/DEBUG_RVCT31/$(INTRINSIC_FLAGS) +RELEASE_RVCT31_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map ENV(EDK_TOOLS_PATH)/Bin/Win32/ARM/RELEASE_RVCT31/$(INTRINSIC_FLAGS) + + +*_RVCT31_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) --apcs /interwork +*_RVCT31_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E +*_RVCT31_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h +*_RVCT31_ARM_MAKE_PATH = nmake +*_RVCT31_ARM_SLINK_FLAGS = --partial -o + DEBUG_RVCT31_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c -g -O2 --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_warning 167 +RELEASE_RVCT31_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_warning 167 + +################## +# ARM definitions +################## +*_RVCT31_ARM_CC_PATH = DEF(RVCT31_TOOLS_PATH)/armcc +*_RVCT31_ARM_SLINK_PATH = DEF(RVCT31_TOOLS_PATH)/armlink +*_RVCT31_ARM_DLINK_PATH = DEF(RVCT31_TOOLS_PATH)/armlink +*_RVCT31_ARM_ASM_PATH = DEF(RVCT31_TOOLS_PATH)/armasm +*_RVCT31_ARM_PP_PATH = DEF(RVCT31_TOOLS_PATH)/armcc +*_RVCT31_ARM_VFRPP_PATH = DEF(RVCT31_TOOLS_PATH)/armcc +*_RVCT31_ARM_FROMELF_PATH = DEF(RVCT31_TOOLS_PATH)/fromelf + +#################################################################################### +# +# ARM Tools & Cygwin +# +#################################################################################### +# ARMCYGWIN - Tools from ARM in a Cygwin environment + +*_RVCT31CYGWIN_*_*_FAMILY = RVCT +*_RVCT31CYGWIN_*_*_BUILDRULEFAMILY = RVCTCYGWIN + +*_RVCT31CYGWIN_ARM_CCPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc +*_RVCT31CYGWIN_ARM_SLINKPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armlink +*_RVCT31CYGWIN_ARM_DLINKPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armlink +*_RVCT31CYGWIN_ARM_ASMPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armasm +*_RVCT31CYGWIN_ARM_PPPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc +*_RVCT31CYGWIN_ARM_VFRPPPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc +*_RVCT31CYGWIN_ARM_FROMELFPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/fromelf + + +# +# Use default values, or override in DSC file +# +*_RVCT31CYGWIN_ARM_ARCHCC_FLAGS = --thumb --cpu ARM1176JZF-S +*_RVCT31CYGWIN_ARM_ARCHASM_FLAGS = --cpu ARM1176JZF-S +*_RVCT31CYGWIN_ARM_ARCHDLINK_FLAGS = +*_RVCT31CYGWIN_ARM_PLATFORM_FLAGS = +*_RVCT31CYGWIN_ARM_INTRINSIC_FLAGS = CompilerIntrinsicsLib.lib + + DEBUG_RVCT31CYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map` ENV(EDK_TOOLS_PATH)/Bin/CYGWIN_NT-5.1-i686/ARM/DEBUG_RVCT31CYGWIN/$(INTRINSIC_FLAGS) +RELEASE_RVCT31CYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map` ENV(EDK_TOOLS_PATH)/Bin/CYGWIN_NT-5.1-i686/ARM/DEBUG_RVCT31CYGWIN/$(INTRINSIC_FLAGS) + +*_RVCT31CYGWIN_ARM_ASM_FLAGS = "$(ASMPATH_FLAG)" $(ARCHASM_FLAGS) --apcs /interwork +*_RVCT31CYGWIN_ARM_PP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E +*_RVCT31CYGWIN_ARM_VFRPP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude `cygpath -m $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h` +*_RVCT31CYGWIN_ARM_MAKE_PATH = make +*_RVCT31CYGWIN_ARM_SLINK_FLAGS = "$(SLINKPATH_FLAG)" --partial -o + DEBUG_RVCT31CYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c -g -O2 --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --preinclude AutoGen.h --diag_warning 167 +RELEASE_RVCT31CYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --preinclude AutoGen.h --diag_warning 167 + +################## +# ARM definitions +################## +*_RVCT31CYGWIN_ARM_CC_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_SLINK_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_DLINK_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_ASM_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_PP_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_VFRPP_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py +*_RVCT31CYGWIN_ARM_FROMELF_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py + +#################################################################################### +# +# ARM GCC (GCC 4.1.1, etc.) +# +#################################################################################### +# ARMGCC - ARM version of the GCC cross compiler + +*_ARMGCC_*_*_FAMILY = GCC +*_ARMGCC_*_MAKE_PATH = make + +################## +# ASL definitions +################## +*_ARMGCC_*_ASL_PATH = DEF(UNIX_IASL_BIN) +*_ARMGCCC_*_ASL_FLAGS = +*_ARMGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS) +*_ARMGCC_*_ASLPP_FLAGS = -x c -E -P +*_ARMGCC_*_ASLCC_FLAGS = -x c +*_ARMGCC_*_ASLDLINK_FLAGS = DEF(UNIXGCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable + +################## +# ARM definitions +################## + +*_ARMGCC_ARM_ASLCC_PATH = DEF(ARMGCC_BIN)/arm-elf-gcc +*_ARMGCC_ARM_ASLDLINK_PATH = DEF(ARMGCC_BIN)/arm-elf-ld +*_ARMGCC_ARM_ASLPP_PATH = DEF(ARMGCC_BIN)/arm-elf-gcc + +*_ARMGCC_ARM_CC_PATH = DEF(ARMGCC_BIN)/arm-elf-gcc +*_ARMGCC_ARM_SLINK_PATH = DEF(ARMGCC_BIN)/arm-elf-ar +*_ARMGCC_ARM_DLINK_PATH = DEF(ARMGCC_BIN)/arm-elf-ld +*_ARMGCC_ARM_ASM_PATH = DEF(ARMGCC_BIN)/arm-elf-as +*_ARMGCC_ARM_PP_PATH = DEF(ARMGCC_BIN)/arm-elf-gcc +*_ARMGCC_ARM_VFRPP_PATH = DEF(ARMGCC_BIN)/arm-elf-gcc + +# +# Use default values, or override in DSC file +# +*_ARMGCC_ARM_ARCHCC_FLAGS = +*_ARMGCC_ARM_ARCHASM_FLAGS = +*_ARMGCC_ARM_ARCHDLINK_FLAGS = +*_ARMGCC_ARM_PLATFORM_FLAGS = +*_ARMGCC_ARM_INTRINSIC_FLAGS = CompilerIntrinsicsLib.lib + + DEBUG_ARMGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -mlittle-endian -g +RELEASE_ARMGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -mlittle-endian + +*_ARMGCC_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h +*_ARMGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h + +*_ARMGCC_ARM_MAKE_PATH = make + +*_ARMGCC_ARM_SLINK_FLAGS = -r +*_ARMGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --emit-relocs --oformat=elf32-littlearm -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map +# --gc-sections + + DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian -g -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h +RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h + + + + ################## # VfrCompiler definitions ################## diff --git a/BaseTools/ReadMe.txt b/BaseTools/ReadMe.txt index a37501e8da..82b3d5883f 100644 --- a/BaseTools/ReadMe.txt +++ b/BaseTools/ReadMe.txt @@ -66,7 +66,7 @@ Notes: or modules because the AutoGen.* files have been be removed. The "makefile" itself cannot generate AutoGen.* files. Only "build" command can. 3) All .exe binary file including C and python tools are generated from: - r1655 \BaseTools\Source\ + r1662 VfrCompiler tool update + r1707 \BaseTools\Source\ + r1707 VfrCompiler tool update Brief usage for Migration Tool MigrationMsa2Inf.exe: 1. Command line format: @@ -190,4 +190,4 @@ Brief usage for Migration Tool Fpd2Dsc.exe: 7. Pyton Source r767 \BaseTools\Source\Python\Fpd2Dsc -17-July-2009 +10-Sep-2009 diff --git a/BaseTools/Source/C/BootSectImage/bootsectimage.c b/BaseTools/Source/C/BootSectImage/bootsectimage.c index 10a545292b..d8dc8907a5 100644 --- a/BaseTools/Source/C/BootSectImage/bootsectimage.c +++ b/BaseTools/Source/C/BootSectImage/bootsectimage.c @@ -371,13 +371,13 @@ Return: if ((FatType == FatTypeFat32) && (FatBpb->Fat12_16.BPB_TotSec32 == 0)) { DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_TotSec32 - %04x, expected: Non-Zero", - FatBpb->Fat12_16.BPB_TotSec32); + (unsigned) FatBpb->Fat12_16.BPB_TotSec32); return FatTypeUnknown; } if ((FatType == FatTypeFat32) && (FatBpb->Fat32.BPB_FATSz32 == 0)) { DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_FATSz32 - %08x, expected: Non-Zero", - FatBpb->Fat32.BPB_FATSz32); + (unsigned) FatBpb->Fat32.BPB_FATSz32); return FatTypeUnknown; } if ((FatType == FatTypeFat32) && @@ -388,7 +388,7 @@ Return: if ((FatType == FatTypeFat32) && (FatBpb->Fat32.BPB_RootClus != 2)) { DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_RootClus - %08x, expected: %04x", - FatBpb->Fat32.BPB_RootClus, 2); + (unsigned) FatBpb->Fat32.BPB_RootClus, 2); } if ((FatType == FatTypeFat32) && (FatBpb->Fat32.BPB_FSInfo != 1)) { @@ -523,14 +523,14 @@ ParseBootSector ( printf (" 16 Sectors per FAT (small vol.) %04x\n", FatBpb.Fat12_16.BPB_FATSz16); printf (" 18 Sectors per track %04x\n", FatBpb.Fat12_16.BPB_SecPerTrk); printf (" 1A Heads %04x\n", FatBpb.Fat12_16.BPB_NumHeads); - printf (" 1C Hidden sectors %08x\n", FatBpb.Fat12_16.BPB_HiddSec); - printf (" 20 Sectors (over 32MB) %08x\n", FatBpb.Fat12_16.BPB_TotSec32); + printf (" 1C Hidden sectors %08x\n", (unsigned) FatBpb.Fat12_16.BPB_HiddSec); + printf (" 20 Sectors (over 32MB) %08x\n", (unsigned) FatBpb.Fat12_16.BPB_TotSec32); printf ("\n"); if (FatType != FatTypeFat32) { printf (" 24 BIOS drive %02x\n", FatBpb.Fat12_16.BS_DrvNum); printf (" 25 (Unused) %02x\n", FatBpb.Fat12_16.BS_Reserved1); printf (" 26 Ext. boot signature %02x\n", FatBpb.Fat12_16.BS_BootSig); - printf (" 27 Volume serial number %08x\n", FatBpb.Fat12_16.BS_VolID); + printf (" 27 Volume serial number %08x\n", (unsigned) FatBpb.Fat12_16.BS_VolID); printf (" 2B Volume lable %c%c%c%c%c%c%c%c%c%c%c\n", FatBpb.Fat12_16.BS_VolLab[0], FatBpb.Fat12_16.BS_VolLab[1], @@ -555,10 +555,10 @@ ParseBootSector ( printf ("\n"); } else { printf ("FAT32 Section\n"); - printf (" 24 Sectors per FAT (large vol.) %08x\n", FatBpb.Fat32.BPB_FATSz32); + printf (" 24 Sectors per FAT (large vol.) %08x\n", (unsigned) FatBpb.Fat32.BPB_FATSz32); printf (" 28 Flags %04x\n", FatBpb.Fat32.BPB_ExtFlags); printf (" 2A Version %04x\n", FatBpb.Fat32.BPB_FSVer); - printf (" 2C Root dir 1st cluster %08x\n", FatBpb.Fat32.BPB_RootClus); + printf (" 2C Root dir 1st cluster %08x\n", (unsigned) FatBpb.Fat32.BPB_RootClus); printf (" 30 FSInfo sector %04x\n", FatBpb.Fat32.BPB_FSInfo); printf (" 32 Backup boot sector %04x\n", FatBpb.Fat32.BPB_BkBootSec); printf (" 34 (Reserved) %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", @@ -578,7 +578,7 @@ ParseBootSector ( printf (" 40 BIOS drive %02x\n", FatBpb.Fat32.BS_DrvNum); printf (" 41 (Unused) %02x\n", FatBpb.Fat32.BS_Reserved1); printf (" 42 Ext. boot signature %02x\n", FatBpb.Fat32.BS_BootSig); - printf (" 43 Volume serial number %08x\n", FatBpb.Fat32.BS_VolID); + printf (" 43 Volume serial number %08x\n", (unsigned) FatBpb.Fat32.BS_VolID); printf (" 47 Volume lable %c%c%c%c%c%c%c%c%c%c%c\n", FatBpb.Fat32.BS_VolLab[0], FatBpb.Fat32.BS_VolLab[1], @@ -738,7 +738,7 @@ ParseMbr ( printf (" Offset Title Value\n"); printf ("==================================================================\n"); printf (" 0 Master bootstrap loader code (not list)\n"); - printf (" 1B8 Windows disk signature %08x\n", Mbr.UniqueMbrSignature); + printf (" 1B8 Windows disk signature %08x\n", (unsigned) Mbr.UniqueMbrSignature); printf ("\n"); printf ("Partition Table Entry #1\n"); printf (" 1BE 80 = active partition %02x\n", Mbr.PartitionRecord[0].BootIndicator); @@ -749,8 +749,8 @@ ParseMbr ( printf (" 1C3 End head %02x\n", Mbr.PartitionRecord[0].EndHead); printf (" 1C4 End sector %02x\n", Mbr.PartitionRecord[0].EndSector); printf (" 1C5 End cylinder %02x\n", Mbr.PartitionRecord[0].EndTrack); - printf (" 1C6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[0].StartingLBA); - printf (" 1CA Sectors in partition %08x\n", Mbr.PartitionRecord[0].SizeInLBA); + printf (" 1C6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[0].StartingLBA); + printf (" 1CA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[0].SizeInLBA); printf ("\n"); printf ("Partition Table Entry #2\n"); printf (" 1CE 80 = active partition %02x\n", Mbr.PartitionRecord[1].BootIndicator); @@ -761,8 +761,8 @@ ParseMbr ( printf (" 1D3 End head %02x\n", Mbr.PartitionRecord[1].EndHead); printf (" 1D4 End sector %02x\n", Mbr.PartitionRecord[1].EndSector); printf (" 1D5 End cylinder %02x\n", Mbr.PartitionRecord[1].EndTrack); - printf (" 1D6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[1].StartingLBA); - printf (" 1DA Sectors in partition %08x\n", Mbr.PartitionRecord[1].SizeInLBA); + printf (" 1D6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[1].StartingLBA); + printf (" 1DA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[1].SizeInLBA); printf ("\n"); printf ("Partition Table Entry #3\n"); printf (" 1DE 80 = active partition %02x\n", Mbr.PartitionRecord[2].BootIndicator); @@ -773,8 +773,8 @@ ParseMbr ( printf (" 1E3 End head %02x\n", Mbr.PartitionRecord[2].EndHead); printf (" 1E4 End sector %02x\n", Mbr.PartitionRecord[2].EndSector); printf (" 1E5 End cylinder %02x\n", Mbr.PartitionRecord[2].EndTrack); - printf (" 1E6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[2].StartingLBA); - printf (" 1EA Sectors in partition %08x\n", Mbr.PartitionRecord[2].SizeInLBA); + printf (" 1E6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[2].StartingLBA); + printf (" 1EA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[2].SizeInLBA); printf ("\n"); printf ("Partition Table Entry #4\n"); printf (" 1EE 80 = active partition %02x\n", Mbr.PartitionRecord[3].BootIndicator); @@ -785,8 +785,8 @@ ParseMbr ( printf (" 1F3 End head %02x\n", Mbr.PartitionRecord[3].EndHead); printf (" 1F4 End sector %02x\n", Mbr.PartitionRecord[3].EndSector); printf (" 1F5 End cylinder %02x\n", Mbr.PartitionRecord[3].EndTrack); - printf (" 1F6 Sectors preceding partition %08x\n", Mbr.PartitionRecord[3].StartingLBA); - printf (" 1FA Sectors in partition %08x\n", Mbr.PartitionRecord[3].SizeInLBA); + printf (" 1F6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[3].StartingLBA); + printf (" 1FA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[3].SizeInLBA); printf ("\n"); printf (" 1FE Signature %04x\n", Mbr.Signature); printf ("\n"); diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c index 72b6a52f89..0166c22460 100644 --- a/BaseTools/Source/C/Common/BasePeCoff.c +++ b/BaseTools/Source/C/Common/BasePeCoff.c @@ -856,6 +856,7 @@ Returns: PeHdr = NULL; TeHdr = NULL; + OptionHeader.Header = NULL; // // Assume success // @@ -1252,11 +1253,11 @@ PeCoffLoaderGetPdbPointer ( // // Get the DebugEntry offset in the raw data image. // - SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (Hdr.Te + 1); - Index = Hdr.Te->NumberOfSections; + SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (Hdr.Te + 1); + Index = Hdr.Te->NumberOfSections; for (Index1 = 0; Index1 < Index; Index1 ++) { - if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && - (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { + if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && + (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te + DirectoryEntry->VirtualAddress - SectionHeader [Index1].VirtualAddress + @@ -1324,8 +1325,8 @@ PeCoffLoaderGetPdbPointer ( // Get the DebugEntry offset in the raw data image. // for (Index1 = 0; Index1 < Index; Index1 ++) { - if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && - (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { + if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) && + (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ( (UINTN) Pe32Data + DirectoryEntry->VirtualAddress - @@ -1349,27 +1350,28 @@ PeCoffLoaderGetPdbPointer ( for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) { if (EFI_IMAGE_DEBUG_TYPE_CODEVIEW == DebugEntry->Type) { if (DebugEntry->SizeOfData > 0) { - // - // Get the DebugEntry offset in the raw data image. - // - for (Index1 = 0; Index1 < Index; Index1 ++) { - if ((DebugEntry->RVA >= SectionHeader[Index1].VirtualAddress) && - (DebugEntry->RVA < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { - CodeViewEntryPointer = (VOID *) ( - ((UINTN)Pe32Data) + - (UINTN) DebugEntry->RVA - - SectionHeader[Index1].VirtualAddress + - SectionHeader[Index1].PointerToRawData + - (UINTN)TEImageAdjust); - break; - } - } - if (Index1 >= Index) { - // - // Can't find CodeViewEntryPointer in raw PE/COFF image. - // - continue; - } + // + // Get the DebugEntry offset in the raw data image. + // + CodeViewEntryPointer = NULL; + for (Index1 = 0; Index1 < Index; Index1 ++) { + if ((DebugEntry->RVA >= SectionHeader[Index1].VirtualAddress) && + (DebugEntry->RVA < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) { + CodeViewEntryPointer = (VOID *) ( + ((UINTN)Pe32Data) + + (UINTN) DebugEntry->RVA - + SectionHeader[Index1].VirtualAddress + + SectionHeader[Index1].PointerToRawData + + (UINTN)TEImageAdjust); + break; + } + } + if (Index1 >= Index) { + // + // Can't find CodeViewEntryPointer in raw PE/COFF image. + // + continue; + } switch (* (UINT32 *) CodeViewEntryPointer) { case CODEVIEW_SIGNATURE_NB10: return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c index 970b2af27b..a0c6603a85 100644 --- a/BaseTools/Source/C/Common/CommonLib.c +++ b/BaseTools/Source/C/Common/CommonLib.c @@ -472,7 +472,7 @@ Returns: printf ( "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - Guid->Data1, + (unsigned) Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], @@ -529,7 +529,7 @@ Returns: sprintf ( (CHAR8 *)Buffer, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - Guid->Data1, + (unsigned) Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], @@ -545,7 +545,7 @@ Returns: sprintf ( (CHAR8 *)Buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - Guid->Data1, + (unsigned) Guid->Data1, Guid->Data2, Guid->Data3, Guid->Data4[0], diff --git a/BaseTools/Source/C/Common/EfiUtilityMsgs.c b/BaseTools/Source/C/Common/EfiUtilityMsgs.c index 9d697da82d..68cf02469e 100644 --- a/BaseTools/Source/C/Common/EfiUtilityMsgs.c +++ b/BaseTools/Source/C/Common/EfiUtilityMsgs.c @@ -34,7 +34,7 @@ Abstract: // STATIC STATUS mStatus = STATUS_SUCCESS; STATIC CHAR8 mUtilityName[50] = { 0 }; -STATIC UINT32 mPrintLogLevel = INFO_LOG_LEVEL; +STATIC UINT64 mPrintLogLevel = INFO_LOG_LEVEL; STATIC CHAR8 *mSourceFileName = NULL; STATIC UINT32 mSourceFileLineNum = 0; STATIC UINT32 mErrorCount = 0; @@ -355,7 +355,7 @@ VOID DebugMsg ( CHAR8 *FileName, UINT32 LineNumber, - UINT32 MsgLevel, + UINT64 MsgLevel, CHAR8 *Text, CHAR8 *MsgFmt, ... @@ -495,7 +495,7 @@ Notes: if (Cptr != NULL) { sprintf (Line, ": %s", Cptr); if (LineNumber != 0) { - sprintf (Line2, "(%d)", LineNumber); + sprintf (Line2, "(%u)", (unsigned) LineNumber); strcat (Line, Line2); } } @@ -509,7 +509,7 @@ Notes: } sprintf (Line, "%s", Cptr); if (LineNumber != 0) { - sprintf (Line2, "(%d)", LineNumber); + sprintf (Line2, "(%u)", (unsigned) LineNumber); strcat (Line, Line2); } } else { @@ -524,7 +524,7 @@ Notes: // message for you. It has to be decimal digits too. // if (MessageCode != 0) { - sprintf (Line2, ": %s %04d", Type, MessageCode); + sprintf (Line2, ": %s %04u", Type, (unsigned) MessageCode); } else { sprintf (Line2, ": %s", Type); } @@ -665,7 +665,7 @@ Returns: VOID SetPrintLevel ( - UINT32 LogLevel + UINT64 LogLevel ) /*++ @@ -843,7 +843,7 @@ TestUtilityMessages ( ) { CHAR8 *ArgStr = "ArgString"; - INTN ArgInt; + int ArgInt; ArgInt = 0x12345678; // diff --git a/BaseTools/Source/C/Common/EfiUtilityMsgs.h b/BaseTools/Source/C/Common/EfiUtilityMsgs.h index 6c2f9d2989..40e6e170ae 100644 --- a/BaseTools/Source/C/Common/EfiUtilityMsgs.h +++ b/BaseTools/Source/C/Common/EfiUtilityMsgs.h @@ -96,7 +96,7 @@ VOID DebugMsg ( CHAR8 *FileName, UINT32 LineNumber, - UINT32 MsgLevel, + UINT64 MsgLevel, CHAR8 *OffendingText, CHAR8 *MsgFmt, ... @@ -123,7 +123,7 @@ KeyMsg ( VOID SetPrintLevel ( - UINT32 LogLevel + UINT64 LogLevel ); VOID diff --git a/BaseTools/Source/C/Common/MyAlloc.c b/BaseTools/Source/C/Common/MyAlloc.c index b53713941c..64c5ff783e 100644 --- a/BaseTools/Source/C/Common/MyAlloc.c +++ b/BaseTools/Source/C/Common/MyAlloc.c @@ -86,7 +86,7 @@ MyCheck ( "Invalid parameter(s).\n", Final, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -98,7 +98,7 @@ MyCheck ( "Invalid parameter.\n", Final, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -121,12 +121,12 @@ MyCheck ( "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n", Final, File, - (UINT32)Line, + (unsigned)Line, Tmp->File, - (UINT32)Tmp->Line, - (UINT32)Tmp->Size, - *(UINT32 *) (Tmp->Buffer), - *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) + (unsigned) Tmp->Line, + (unsigned) Tmp->Size, + (unsigned) *(UINT32 *) (Tmp->Buffer), + (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) ); exit (1); @@ -141,17 +141,17 @@ MyCheck ( "\nSome allocated items have not been freed.\n", Final, File, - (UINT32)Line + (unsigned)Line ); for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) { printf ( "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n", Tmp->File, - (UINT32)Tmp->Line, - (UINT32)Tmp->Size, - *(UINT32 *) (Tmp->Buffer), - *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) + (unsigned) Tmp->Line, + (unsigned) Tmp->Size, + (unsigned) *(UINT32 *) (Tmp->Buffer), + (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)]) ); } } @@ -201,9 +201,9 @@ MyAlloc ( printf ( "\nMyAlloc(Size=%u, File=%s, Line=%u)" "\nInvalid parameter(s).\n", - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -214,9 +214,9 @@ MyAlloc ( printf ( "\nMyAlloc(Size=%u, File=%s, Line=%u)" "\nInvalid parameter.\n", - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -238,9 +238,9 @@ MyAlloc ( printf ( "\nMyAlloc(Size=%u, File=%s, Line=%u)" "\nOut of memory.\n", - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -315,9 +315,9 @@ MyRealloc ( "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)" "\nInvalid parameter(s).\n", Ptr, - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -328,9 +328,9 @@ MyRealloc ( "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)" "\nInvalid parameter.\n", Ptr, - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -349,9 +349,9 @@ MyRealloc ( "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)" "\nCould not find buffer.\n", Ptr, - (UINT32)Size, + (unsigned)Size, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -421,7 +421,7 @@ MyFree ( "\nInvalid parameter(s).\n", Ptr, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -433,7 +433,7 @@ MyFree ( "\nInvalid parameter.\n", Ptr, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -453,7 +453,7 @@ MyFree ( "\nCalled before memory allocated.\n", Ptr, File, - (UINT32)Line + (unsigned)Line ); exit (1); @@ -486,7 +486,7 @@ MyFree ( "\nNot found.\n", Ptr, File, - (UINT32)Line + (unsigned)Line ); exit (1); diff --git a/BaseTools/Source/C/Common/ParseGuidedSectionTools.c b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c index 02d0b11f0d..b643cdeb4f 100644 --- a/BaseTools/Source/C/Common/ParseGuidedSectionTools.c +++ b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c @@ -122,6 +122,7 @@ Returns: GUID_SEC_TOOL_ENTRY *NewGuidTool; FirstGuidTool = NULL; + LastGuidTool = NULL; while (TRUE) { NextLine = ReadMemoryFileLine (InputFile); diff --git a/BaseTools/Source/C/Common/ParseInf.c b/BaseTools/Source/C/Common/ParseInf.c index 8305f14aef..b39c5bde40 100644 --- a/BaseTools/Source/C/Common/ParseInf.c +++ b/BaseTools/Source/C/Common/ParseInf.c @@ -379,10 +379,10 @@ Returns: --*/ { INT32 Index; - UINT32 Data1; - UINT32 Data2; - UINT32 Data3; - UINT16 Data4[8]; + unsigned Data1; + unsigned Data2; + unsigned Data3; + unsigned Data4[8]; if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) { return EFI_INVALID_PARAMETER; @@ -416,7 +416,7 @@ Returns: // Index = sscanf ( AsciiGuidBuffer, - "%08x-%04x-%04x-%02hx%02hx-%02hx%02hx%02hx%02hx%02hx%02hx", + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", &Data1, &Data2, &Data3, diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.c b/BaseTools/Source/C/Common/SimpleFileParsing.c index 52ec129193..5a7111c8eb 100644 --- a/BaseTools/Source/C/Common/SimpleFileParsing.c +++ b/BaseTools/Source/C/Common/SimpleFileParsing.c @@ -536,7 +536,7 @@ Returns: --*/ { - UINT32 Val; + unsigned Val; SkipWhiteSpace (&mGlobals.SourceFile); if (EndOfFile (&mGlobals.SourceFile)) { @@ -554,7 +554,7 @@ Returns: mGlobals.SourceFile.FileBufferPtr += 2; sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", &Val); - *Value = Val; + *Value = (UINT32) Val; while (isxdigit (mGlobals.SourceFile.FileBufferPtr[0])) { mGlobals.SourceFile.FileBufferPtr++; } @@ -634,7 +634,7 @@ Returns: // depth. // if (mGlobals.VerboseFile) { - fprintf (stdout, "%*cProcessing file '%s'\n", (INT32)NestDepth * 2, ' ', SourceFile->FileName); + fprintf (stdout, "%*cProcessing file '%s'\n", (int)NestDepth * 2, ' ', SourceFile->FileName); fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile->FileName); } @@ -642,7 +642,7 @@ Returns: // Make sure we didn't exceed our maximum nesting depth // if (NestDepth > MAX_NEST_DEPTH) { - Error (NULL, 0, 3001, "Not Supported", "%s exceeeds max nesting depth (%d)", SourceFile->FileName, NestDepth); + Error (NULL, 0, 3001, "Not Supported", "%s exceeeds max nesting depth (%u)", SourceFile->FileName, (unsigned) NestDepth); Status = STATUS_ERROR; goto Finish; } @@ -698,7 +698,7 @@ Returns: fseek (SourceFile->Fptr, 0, SEEK_END); SourceFile->FileSize = ftell (SourceFile->Fptr); if (mGlobals.VerboseFile) { - printf ("FileSize = %d (0x%X)\n", (INT32)SourceFile->FileSize, (UINT32)SourceFile->FileSize); + printf ("FileSize = %u (0x%X)\n", (unsigned) SourceFile->FileSize, (unsigned) SourceFile->FileSize); } fseek (SourceFile->Fptr, 0, SEEK_SET); @@ -819,7 +819,7 @@ Returns: } printf ("'\n"); - printf ("FileSize = %d (0x%X)\n", (INT32)SourceFile->FileSize, (UINT32)SourceFile->FileSize); + printf ("FileSize = %u (0x%X)\n", (unsigned)SourceFile->FileSize, (unsigned)SourceFile->FileSize); RewindFile (SourceFile); } } @@ -1282,7 +1282,7 @@ Returns: --*/ { - UINT32 Value32; + unsigned Value32; UINT32 Index; FILE_POSITION FPos; CHAR8 TempString[20]; diff --git a/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c index 3591a4d71b..c2c8111d31 100644 --- a/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c +++ b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c @@ -131,7 +131,7 @@ Return: UINT64 : file size of input file --*/ { - UINT64 filesize, offset, length; + UINT32 filesize, offset, length; CHAR8 Buffer[8*1024]; fseek (in, 0, SEEK_END); @@ -252,7 +252,7 @@ Returns: continue; } // - // Don't recognize the paramter, should be regarded as the input file name. + // Don't recognize the parameter, should be regarded as the input file name. // InputFileNames[InputFileCount] = argv[0]; InputFileCount++; @@ -309,9 +309,9 @@ Returns: // And in the same time update the EfiLdrHeader and EfiLdrImage array // EfiLdrImage[i].Offset = EfiLdrHeader.FileLength; - EfiLdrImage[i].Length = filesize; + EfiLdrImage[i].Length = (UINT32) filesize; strncpy ((CHAR8*) EfiLdrImage[i].FileName, InputFileNames[i], sizeof (EfiLdrImage[i].FileName) - 1); - EfiLdrHeader.FileLength += filesize; + EfiLdrHeader.FileLength += (UINT32) filesize; EfiLdrHeader.NumberOfImages++; } diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c index d9c2e7c1c1..d43520ae47 100644 --- a/BaseTools/Source/C/EfiRom/EfiRom.c +++ b/BaseTools/Source/C/EfiRom/EfiRom.c @@ -88,8 +88,8 @@ Returns: // If dumping an image, then do that and quit // if (mOptions.DumpOption == 1) { - for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) { - if ((Ptr0 = strstr ((CONST CHAR8 *)FList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) { + if (mOptions.FileList != NULL) { + if ((Ptr0 = strstr ((CONST CHAR8 *) mOptions.FileList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) { DumpImage (mOptions.FileList); goto BailOut; } else { @@ -163,7 +163,7 @@ Returns: } if (mOptions.Verbose) { - VerboseMsg(" Output size = 0x%X\n", Size); + VerboseMsg(" Output size = 0x%X\n", (unsigned) Size); } if (Status != STATUS_SUCCESS) { @@ -238,7 +238,8 @@ Returns: UINT32 Index; UINT8 ByteCheckSum; - + PciDs23 = NULL; + PciDs30 = NULL; Status = STATUS_SUCCESS; // @@ -255,7 +256,7 @@ Returns: fseek (InFptr, 0, SEEK_END); FileSize = ftell (InFptr); if (mOptions.Verbose) { - VerboseMsg(" File size = 0x%X\n", FileSize); + VerboseMsg(" File size = 0x%X\n", (unsigned) FileSize); } fseek (InFptr, 0, SEEK_SET); @@ -365,7 +366,7 @@ Returns: Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1); if (mOptions.Verbose) { - VerboseMsg(" Checksum = %02x\n\n", (UINT32) Buffer[FileSize - 1]); + VerboseMsg(" Checksum = %02x\n\n", Buffer[FileSize - 1]); } // @@ -495,7 +496,7 @@ Returns: } if (mOptions.Verbose) { - VerboseMsg(" File size = 0x%X\n", FileSize); + VerboseMsg(" File size = 0x%X\n", (unsigned) FileSize); } // // Allocate memory for the entire file (in case we have to compress), then @@ -540,7 +541,7 @@ Returns: // Now compute the size, then swap buffer pointers. // if (mOptions.Verbose) { - VerboseMsg(" Comp size = 0x%X\n", CompressedFileSize); + VerboseMsg(" Comp size = 0x%X\n", (unsigned) CompressedFileSize); } TotalSize = CompressedFileSize + HeaderSize; @@ -820,7 +821,7 @@ Returns: } if (mOptions.Verbose) { - VerboseMsg(" Got subsystem = 0x%X from image\n", (int) *SubSystem); + VerboseMsg(" Got subsystem = 0x%X from image\n", *SubSystem); } // @@ -999,7 +1000,7 @@ Returns: return 1; } if (DebugLevel > 9) { - Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", Argv[1]); + Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 0-9, current input level is %d", Argv[1]); return 1; } if (DebugLevel>=5 && DebugLevel<=9) { @@ -1301,10 +1302,10 @@ Returns: // // Dump the contents of the header // - fprintf (stdout, "Image %d -- Offset 0x%X\n", ImageCount, ImageStart); + fprintf (stdout, "Image %u -- Offset 0x%X\n", (unsigned) ImageCount, (unsigned) ImageStart); fprintf (stdout, " ROM header contents\n"); - fprintf (stdout, " Signature 0x%04X\n", (UINT32) PciRomHdr.Signature); - fprintf (stdout, " PCIR offset 0x%04X\n", (UINT32) PciRomHdr.PcirOffset); + fprintf (stdout, " Signature 0x%04X\n", PciRomHdr.Signature); + fprintf (stdout, " PCIR offset 0x%04X\n", PciRomHdr.PcirOffset); // // Find PCI data structure // @@ -1349,11 +1350,11 @@ Returns: fprintf ( stdout, " Class Code 0x%06X\n", - (UINT32) (PciDs23.ClassCode[0] | (PciDs23.ClassCode[1] << 8) | (PciDs23.ClassCode[2] << 16)) + (unsigned) (PciDs23.ClassCode[0] | (PciDs23.ClassCode[1] << 8) | (PciDs23.ClassCode[2] << 16)) ); - fprintf (stdout, " Image size 0x%X\n", PciDs23.ImageLength * 512); + fprintf (stdout, " Image size 0x%X\n", (unsigned) PciDs23.ImageLength * 512); fprintf (stdout, " Code revision: 0x%04X\n", PciDs23.CodeRevision); - fprintf (stdout, " Indicator 0x%02X", (UINT32) PciDs23.Indicator); + fprintf (stdout, " Indicator 0x%02X", PciDs23.Indicator); } else { fprintf ( stdout, @@ -1367,18 +1368,18 @@ Returns: fprintf (stdout, " Device ID 0x%04X\n", PciDs30.DeviceId); fprintf (stdout, " Length 0x%04X\n", PciDs30.Length); fprintf (stdout, " Revision 0x%04X\n", PciDs30.Revision); - fprintf (stdout, " DeviceListOffset 0x%02X\n", (UINT32) PciDs30.DeviceListOffset); + fprintf (stdout, " DeviceListOffset 0x%02X\n", PciDs30.DeviceListOffset); fprintf ( stdout, " Class Code 0x%06X\n", - (UINT32) (PciDs30.ClassCode[0] | (PciDs30.ClassCode[1] << 8) | (PciDs30.ClassCode[2] << 16)) + (unsigned) (PciDs30.ClassCode[0] | (PciDs30.ClassCode[1] << 8) | (PciDs30.ClassCode[2] << 16)) ); - fprintf (stdout, " Image size 0x%X\n", PciDs30.ImageLength * 512); + fprintf (stdout, " Image size 0x%X\n", (unsigned) PciDs30.ImageLength * 512); fprintf (stdout, " Code revision: 0x%04X\n", PciDs30.CodeRevision); - fprintf (stdout, " MaxRuntimeImageLength 0x%02X\n", (UINT32) PciDs30.MaxRuntimeImageLength); - fprintf (stdout, " ConfigUtilityCodeHeaderOffset 0x%02X\n", (UINT32) PciDs30.ConfigUtilityCodeHeaderOffset); - fprintf (stdout, " DMTFCLPEntryPointOffset 0x%02X\n", (UINT32) PciDs30.DMTFCLPEntryPointOffset); - fprintf (stdout, " Indicator 0x%02X", (UINT32) PciDs30.Indicator); + fprintf (stdout, " MaxRuntimeImageLength 0x%02X\n", PciDs30.MaxRuntimeImageLength); + fprintf (stdout, " ConfigUtilityCodeHeaderOffset 0x%02X\n", PciDs30.ConfigUtilityCodeHeaderOffset); + fprintf (stdout, " DMTFCLPEntryPointOffset 0x%02X\n", PciDs30.DMTFCLPEntryPointOffset); + fprintf (stdout, " Indicator 0x%02X", PciDs30.Indicator); } // // Print the indicator, used to flag the last image @@ -1392,9 +1393,9 @@ Returns: // Print the code type. If EFI code, then we can provide more info. // if (mOptions.Pci23 == 1) { - fprintf (stdout, " Code type 0x%02X", (UINT32) PciDs23.CodeType); + fprintf (stdout, " Code type 0x%02X", PciDs23.CodeType); } else { - fprintf (stdout, " Code type 0x%02X", (UINT32) PciDs30.CodeType); + fprintf (stdout, " Code type 0x%02X", PciDs30.CodeType); } if (PciDs23.CodeType == PCI_CODE_TYPE_EFI_IMAGE || PciDs30.CodeType == PCI_CODE_TYPE_EFI_IMAGE) { fprintf (stdout, " (EFI image)\n"); @@ -1414,11 +1415,11 @@ Returns: // // Now dump more info // - fprintf (stdout, " EFI Signature 0x%04X\n", EfiRomHdr.EfiSignature); + fprintf (stdout, " EFI Signature 0x%04X\n", (unsigned) EfiRomHdr.EfiSignature); fprintf ( stdout, " Compression Type 0x%04X ", - (UINT32) EfiRomHdr.CompressionType + EfiRomHdr.CompressionType ); if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) { fprintf (stdout, "(compressed)\n"); @@ -1441,8 +1442,8 @@ Returns: fprintf ( stdout, " EFI image offset 0x%04X (@0x%X)\n", - (UINT32) EfiRomHdr.EfiImageHeaderOffset, - (UINT32) (EfiRomHdr.EfiImageHeaderOffset + ImageStart) + EfiRomHdr.EfiImageHeaderOffset, + EfiRomHdr.EfiImageHeaderOffset + (unsigned) ImageStart ); } else { diff --git a/BaseTools/Source/C/GenBootSector/GenBootSector.c b/BaseTools/Source/C/GenBootSector/GenBootSector.c index 47b5c5c67a..05839bb736 100644 --- a/BaseTools/Source/C/GenBootSector/GenBootSector.c +++ b/BaseTools/Source/C/GenBootSector/GenBootSector.c @@ -26,6 +26,9 @@ Abstract: #include #include +#include "ParseInf.h" +#include "EfiUtilityMsgs.h" + // // Utility Name // @@ -259,9 +262,9 @@ Routine Description: } else { fprintf ( stdout, - "%c: - DiskNum: %d, Type: %s\n", + "%c: - DiskNum: %u, Type: %s\n", DriveInfo.VolumeLetter, - DriveInfo.DiskNumber, + (unsigned) DriveInfo.DiskNumber, DriveInfo.DriveType->Description ); } @@ -438,11 +441,9 @@ ProcessBsOrMbr ( BYTE DiskPartition[0x200] = {0}; BYTE DiskPartitionBackup[0x200] = {0}; DWORD BytesReturn; - DWORD DbrOffset; INT DrvNumOffset; HANDLE InputHandle; HANDLE OutputHandle; - BOOL WriteToDisk; ERROR_STATUS Status; DWORD InputDbrOffset; DWORD OutputDbrOffset; @@ -731,7 +732,7 @@ main ( return 1; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel); return 1; } SetPrintLevel (LogLevel); diff --git a/BaseTools/Source/C/GenCrc32/GenCrc32.c b/BaseTools/Source/C/GenCrc32/GenCrc32.c index 63900b6461..a94f9202fe 100644 --- a/BaseTools/Source/C/GenCrc32/GenCrc32.c +++ b/BaseTools/Source/C/GenCrc32/GenCrc32.c @@ -22,6 +22,7 @@ Abstract: #include #include +#include "ParseInf.h" #include "EfiUtilityMsgs.h" #include "CommonLib.h" #include "Crc32.h" @@ -104,7 +105,7 @@ Returns: int main ( - INT32 argc, + int argc, CHAR8 *argv[] ) /*++ @@ -222,7 +223,7 @@ Returns: goto Finish; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel); goto Finish; } SetPrintLevel (LogLevel); @@ -294,7 +295,7 @@ Returns: fread (FileBuffer, 1, FileSize, InFile); fclose (InFile); - VerboseMsg ("the size of the input file is %d bytes", FileSize); + VerboseMsg ("the size of the input file is %u bytes", (unsigned) FileSize); // // Open output file @@ -318,9 +319,9 @@ Returns: // Done, write output file. // fwrite (&Crc32Value, 1, sizeof (Crc32Value), OutFile); - VerboseMsg ("The calculated CRC32 value is 0x%08x", Crc32Value); + VerboseMsg ("The calculated CRC32 value is 0x%08x", (unsigned) Crc32Value); fwrite (FileBuffer, 1, FileSize, OutFile); - VerboseMsg ("the size of the encoded file is %d bytes", FileSize + sizeof (UINT32)); + VerboseMsg ("the size of the encoded file is %u bytes", (unsigned) FileSize + sizeof (UINT32)); } else { // // Verify Crc32 Value @@ -330,7 +331,7 @@ Returns: Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!"); goto Finish; } - VerboseMsg ("The calculated CRC32 value is 0x%08x and File Crc32 value is 0x%08x", Crc32Value, *(UINT32 *)FileBuffer); + VerboseMsg ("The calculated CRC32 value is 0x%08x and File Crc32 value is 0x%08x", (unsigned) Crc32Value, (unsigned) (*(UINT32 *)FileBuffer)); if (Crc32Value != *(UINT32 *)FileBuffer) { Error (NULL, 0, 3000, "Invalid", "CRC32 value of input file is not correct!"); Status = STATUS_ERROR; @@ -340,7 +341,7 @@ Returns: // Done, write output file. // fwrite (FileBuffer + sizeof (UINT32), 1, FileSize - sizeof (UINT32), OutFile); - VerboseMsg ("the size of the decoded file is %d bytes", FileSize - sizeof (UINT32)); + VerboseMsg ("the size of the decoded file is %u bytes", (unsigned) FileSize - sizeof (UINT32)); } Finish: diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c index e8cd09e947..12a3b2f18c 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -322,7 +322,7 @@ Returns: FileSize = ftell (InFile); fseek (InFile, 0, SEEK_SET); DebugMsg (NULL, 0, 9, "Input section files", - "the input section name is %s and the size is %d bytes", InputFileName[Index], FileSize); + "the input section name is %s and the size is %u bytes", InputFileName[Index], (unsigned) FileSize); // // Check this section is Te/Pe section, and Calculate the numbers of Te/Pe section. @@ -374,7 +374,7 @@ Returns: SectHeader->Size[2] = (UINT8) ((Offset & 0xff0000) >> 16); } DebugMsg (NULL, 0, 9, "Pad raw section for section data alignment", - "Pad Raw section size is %d", Offset); + "Pad Raw section size is %u", (unsigned) Offset); Size = Size + Offset; } @@ -409,7 +409,7 @@ Returns: int main ( - INT32 argc, + int argc, CHAR8 *argv[] ) /*++ @@ -679,7 +679,7 @@ Returns: goto Finish; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel); goto Finish; } SetPrintLevel (LogLevel); @@ -719,7 +719,7 @@ Returns: VerboseMsg ("Fv File type is %s", mFfsFileType [FfsFiletype]); VerboseMsg ("Output file name is %s", OutputFileName); VerboseMsg ("FFS File Guid is %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - FileGuid.Data1, + (unsigned) FileGuid.Data1, FileGuid.Data2, FileGuid.Data3, FileGuid.Data4[0], @@ -744,7 +744,7 @@ Returns: // InputFileAlign[Index] = 1; } - VerboseMsg ("the %dth input section name is %s and section alignment is %d", Index, InputFileName[Index], InputFileAlign[Index]); + VerboseMsg ("the %dth input section name is %s and section alignment is %u", Index, InputFileName[Index], (unsigned) InputFileAlign[Index]); } // @@ -763,7 +763,7 @@ Returns: if ((FfsFiletype == EFI_FV_FILETYPE_SECURITY_CORE || FfsFiletype == EFI_FV_FILETYPE_PEI_CORE || FfsFiletype == EFI_FV_FILETYPE_DXE_CORE) && (PeSectionNum != 1)) { - Error (NULL, 0, 2000, "Invalid parameter", "Fv File type %s must have one and only one Pe or Te section, but %d Pe/Te section are input", mFfsFileType [FfsFiletype], PeSectionNum); + Error (NULL, 0, 2000, "Invalid parameter", "Fv File type %s must have one and only one Pe or Te section, but %u Pe/Te section are input", mFfsFileType [FfsFiletype], PeSectionNum); goto Finish; } @@ -810,7 +810,7 @@ Returns: // // Update FFS Alignment based on the max alignment required by input section files // - VerboseMsg ("the max alignment of all input sections is %d", MaxAlignment); + VerboseMsg ("the max alignment of all input sections is %u", (unsigned) MaxAlignment); for (Index = 0; Index < sizeof (mFfsValidAlign) / sizeof (UINT32) - 1; Index ++) { if ((MaxAlignment > mFfsValidAlign [Index]) && (MaxAlignment <= mFfsValidAlign [Index + 1])) { break; @@ -819,14 +819,14 @@ Returns: if (FfsAlign < Index) { FfsAlign = Index; } - VerboseMsg ("the alignment of the genreated FFS file is %d", mFfsValidAlign [FfsAlign + 1]); - FfsFileHeader.Attributes = FfsAttrib | (FfsAlign << 3); + VerboseMsg ("the alignment of the generated FFS file is %u", (unsigned) mFfsValidAlign [FfsAlign + 1]); + FfsFileHeader.Attributes = (EFI_FFS_FILE_ATTRIBUTES) (FfsAttrib | (FfsAlign << 3)); // // Now FileSize includes the EFI_FFS_FILE_HEADER // FileSize += sizeof (EFI_FFS_FILE_HEADER); - VerboseMsg ("the size of the genreated FFS file is %d bytes", FileSize); + VerboseMsg ("the size of the generated FFS file is %u bytes", (unsigned) FileSize); FfsFileHeader.Size[0] = (UINT8) (FileSize & 0xFF); FfsFileHeader.Size[1] = (UINT8) ((FileSize & 0xFF00) >> 8); FfsFileHeader.Size[2] = (UINT8) ((FileSize & 0xFF0000) >> 16); diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c index e080422e54..f2ff2d29cd 100644 --- a/BaseTools/Source/C/GenFv/GenFv.c +++ b/BaseTools/Source/C/GenFv/GenFv.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -141,7 +141,7 @@ Returns: fprintf (stdout, " --FvNameGuid GuidValue is the Fv Name Guid value.\n\ Its format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\n"); fprintf (stdout, " --capflag CapFlag Capsule Reset Flag can be PersistAcrossReset,\n\ - or PopulateSystemTable or not set.\n"); + or PopulateSystemTable or InitiateReset or not set\n"); fprintf (stdout, " --capheadsize HeadSize\n\ HeadSize is one HEX or DEC format value\n\ HeadSize is required by Capsule Image.\n"); @@ -218,6 +218,7 @@ Returns: Index = 0; mFvTotalSize = 0; mFvTakenSize = 0; + Status = EFI_SUCCESS; SetUtilityName (UTILITY_NAME); @@ -232,10 +233,10 @@ Returns: // memset (&mFvDataInfo, 0, sizeof (FV_INFO)); memset (&mCapDataInfo, 0, sizeof (CAP_INFO)); - // - // Set the default FvGuid - // - memcpy (&mFvDataInfo.FvFileSystemGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID)); + // + // Set the default FvGuid + // + memcpy (&mFvDataInfo.FvFileSystemGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID)); // // Parse command line @@ -312,7 +313,7 @@ Returns: return STATUS_ERROR; } mFvDataInfo.FvBlocks[0].Length = (UINT32) TempNumber; - DebugMsg (NULL, 0, 9, "FV Block Size", "%s = 0x%x", EFI_BLOCK_SIZE_STRING, TempNumber); + DebugMsg (NULL, 0, 9, "FV Block Size", "%s = 0x%llx", EFI_BLOCK_SIZE_STRING, (unsigned long long) TempNumber); argc -= 2; argv += 2; continue; @@ -329,7 +330,7 @@ Returns: return STATUS_ERROR; } mFvDataInfo.FvBlocks[0].NumBlocks = (UINT32) TempNumber; - DebugMsg (NULL, 0, 9, "FV Number Block", "%s = 0x%x", EFI_NUM_BLOCKS_STRING, TempNumber); + DebugMsg (NULL, 0, 9, "FV Number Block", "%s = 0x%llx", EFI_NUM_BLOCKS_STRING, (unsigned long long) TempNumber); argc -= 2; argv += 2; continue; @@ -341,7 +342,7 @@ Returns: return STATUS_ERROR; } strcpy (mFvDataInfo.FvFiles[Index], argv[1]); - DebugMsg (NULL, 0, 9, "FV component file", "the %dth name is %s", Index + 1, argv[1]); + DebugMsg (NULL, 0, 9, "FV component file", "the %uth name is %s", (unsigned) Index + 1, argv[1]); argc -= 2; argv += 2; @@ -356,8 +357,8 @@ Returns: Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]); return STATUS_ERROR; } - mFvDataInfo.SizeofFvFiles[Index] = TempNumber; - DebugMsg (NULL, 0, 9, "FV component file size", "the %dth size is %s", Index + 1, argv[1]); + mFvDataInfo.SizeofFvFiles[Index] = (UINT32) TempNumber; + DebugMsg (NULL, 0, 9, "FV component file size", "the %uth size is %s", (unsigned) Index + 1, argv[1]); argc -= 2; argv += 2; } @@ -388,7 +389,7 @@ Returns: return STATUS_ERROR; } mCapDataInfo.HeaderSize = (UINT32) TempNumber; - DebugMsg (NULL, 0, 9, "Capsule Header size", "%s = 0x%x", EFI_CAPSULE_HEADER_SIZE_STRING, TempNumber); + DebugMsg (NULL, 0, 9, "Capsule Header size", "%s = 0x%llx", EFI_CAPSULE_HEADER_SIZE_STRING, (unsigned long long) TempNumber); argc -= 2; argv += 2; continue; @@ -406,6 +407,8 @@ Returns: mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE; } else if (strcmp (argv[1], "PersistAcrossReset") == 0) { mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET; + } else if (strcmp (argv[1], "InitiateReset") == 0) { + mCapDataInfo.Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_INITIATE_RESET; } else { Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]); return STATUS_ERROR; @@ -506,7 +509,7 @@ Returns: return STATUS_ERROR; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel); return STATUS_ERROR; } SetPrintLevel (LogLevel); @@ -625,20 +628,20 @@ Returns: } fprintf (FpFile, "Capsule %s Image Header Information\n", InfFileName); fprintf (FpFile, " GUID %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", - CapsuleHeader->CapsuleGuid.Data1, - (UINT32) CapsuleHeader->CapsuleGuid.Data2, - (UINT32) CapsuleHeader->CapsuleGuid.Data3, - (UINT32) CapsuleHeader->CapsuleGuid.Data4[0], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[1], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[2], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[3], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[4], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[5], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[6], - (UINT32) CapsuleHeader->CapsuleGuid.Data4[7]); - fprintf (FpFile, " Header size 0x%08X\n", CapsuleHeader->HeaderSize); - fprintf (FpFile, " Flags 0x%08X\n", CapsuleHeader->Flags); - fprintf (FpFile, " Capsule image size 0x%08X\n", CapsuleHeader->CapsuleImageSize); + (unsigned) CapsuleHeader->CapsuleGuid.Data1, + (unsigned) CapsuleHeader->CapsuleGuid.Data2, + (unsigned) CapsuleHeader->CapsuleGuid.Data3, + (unsigned) CapsuleHeader->CapsuleGuid.Data4[0], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[1], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[2], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[3], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[4], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[5], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[6], + (unsigned) CapsuleHeader->CapsuleGuid.Data4[7]); + fprintf (FpFile, " Header size 0x%08X\n", (unsigned) CapsuleHeader->HeaderSize); + fprintf (FpFile, " Flags 0x%08X\n", (unsigned) CapsuleHeader->Flags); + fprintf (FpFile, " Capsule image size 0x%08X\n", (unsigned) CapsuleHeader->CapsuleImageSize); fclose (FpFile); } else if (CapsuleFlag) { VerboseMsg ("Create capsule image"); @@ -657,7 +660,7 @@ Returns: } else { VerboseMsg ("Create Fv image and its map file"); if (mFvDataInfo.BaseAddress != 0) { - VerboseMsg ("FvImage Rebase Address is 0x%X", mFvDataInfo.BaseAddress); + VerboseMsg ("FvImage Rebase Address is 0x%llX", (unsigned long long) mFvDataInfo.BaseAddress); } // // Call the GenerateFvImage to generate Fv Image @@ -690,21 +693,29 @@ Returns: fprintf (FpFile, "\n"); if (mFvDataInfo.BootBaseAddress != 0) { fprintf (FpFile, EFI_FV_BOOT_DRIVER_BASE_ADDRESS_STRING); - fprintf (FpFile, " = 0x%lx\n", mFvDataInfo.BootBaseAddress); - DebugMsg (NULL, 0, 9, "Updated boot driver base address", "%s = 0x%x", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, mFvDataInfo.BootBaseAddress); + fprintf ( + FpFile, + " = 0x%llx\n", + (unsigned long long)mFvDataInfo.BootBaseAddress + ); + DebugMsg (NULL, 0, 9, "Updated boot driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.BootBaseAddress); } if (mFvDataInfo.RuntimeBaseAddress != 0) { fprintf (FpFile, EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING); - fprintf (FpFile, " = 0x%lx\n", mFvDataInfo.RuntimeBaseAddress); - DebugMsg (NULL, 0, 9, "Updated runtime driver base address", "%s = 0x%x", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, mFvDataInfo.RuntimeBaseAddress); + fprintf ( + FpFile, + " = 0x%llx\n", + (unsigned long long)mFvDataInfo.RuntimeBaseAddress + ); + DebugMsg (NULL, 0, 9, "Updated runtime driver base address", "%s = 0x%llx", EFI_FV_RUNTIME_DRIVER_BASE_ADDRESS_STRING, (unsigned long long) mFvDataInfo.RuntimeBaseAddress); } fclose (FpFile); } if (Status == EFI_SUCCESS) { - DebugMsg (NULL, 0, 9, "The Total Fv Size", "%s = 0x%x", EFI_FV_TOTAL_SIZE_STRING, mFvTotalSize); - DebugMsg (NULL, 0, 9, "The used Fv Size", "%s = 0x%x", EFI_FV_TAKEN_SIZE_STRING, mFvTakenSize); - DebugMsg (NULL, 0, 9, "The space Fv size", "%s = 0x%x", EFI_FV_SPACE_SIZE_STRING, mFvTotalSize - mFvTakenSize); + DebugMsg (NULL, 0, 9, "The Total Fv Size", "%s = 0x%x", EFI_FV_TOTAL_SIZE_STRING, (unsigned) mFvTotalSize); + DebugMsg (NULL, 0, 9, "The used Fv Size", "%s = 0x%x", EFI_FV_TAKEN_SIZE_STRING, (unsigned) mFvTakenSize); + DebugMsg (NULL, 0, 9, "The space Fv size", "%s = 0x%x", EFI_FV_SPACE_SIZE_STRING, (unsigned) (mFvTotalSize - mFvTakenSize)); } VerboseMsg ("%s tool done with return code is 0x%x.", UTILITY_NAME, GetUtilityStatus ()); diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c index ad3e7a6e08..917baa11e8 100644 --- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c +++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -184,7 +184,8 @@ Returns: { CHAR8 Value[_MAX_PATH]; UINT64 Value64; - UINTN Index, Number, Index1; + UINTN Index; + UINTN Number; EFI_STATUS Status; EFI_GUID GuidValue; @@ -371,7 +372,7 @@ Returns: // Add the file // strcpy (FvInfo->FvFiles[Number + Index], Value); - DebugMsg (NULL, 0, 9, "FV component file", "the %dth name is %s", Index, Value); + DebugMsg (NULL, 0, 9, "FV component file", "the %uth name is %s", (unsigned) Index, Value); } else { break; } @@ -514,6 +515,7 @@ EFI_STATUS AddPadFile ( IN OUT MEMORY_FILE *FvImage, IN UINT32 DataAlignment, + IN VOID *FvEnd, IN EFI_FIRMWARE_VOLUME_EXT_HEADER *ExtHeader ) /*++ @@ -525,9 +527,10 @@ Routine Description: Arguments: - FvImage The memory image of the FV to add it to. The current offset - must be valid. + FvImage The memory image of the FV to add it to. + The current offset must be valid. DataAlignment The data alignment of the next FFS file. + FvEnd End of the empty data in FvImage. ExtHeader PI FvExtHeader Optional Returns: @@ -556,30 +559,6 @@ Returns: return EFI_SUCCESS; } - // - // Write pad file header - // - PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer; - - // - // Verify that we have enough space for the file header - // - if (ExtHeader != NULL) { - if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER) + ExtHeader->ExtHeaderSize) >= (UINTN) FvImage->Eof) { - return EFI_OUT_OF_RESOURCES; - } - } else { - if ((UINTN) (PadFile + sizeof (EFI_FFS_FILE_HEADER)) >= (UINTN) FvImage->Eof) { - return EFI_OUT_OF_RESOURCES; - } - } - - // - // write PadFile FFS header with PadType, don't need to set PAD file guid in its header. - // - PadFile->Type = EFI_FV_FILETYPE_FFS_PAD; - PadFile->Attributes = 0; - // // Calculate the pad file size // @@ -587,11 +566,7 @@ Returns: // This is the earliest possible valid offset (current plus pad file header // plus the next file header) // - if (ExtHeader != NULL) { - PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2) + ExtHeader->ExtHeaderSize; - } else { - PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2); - } + PadFileSize = (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage + (sizeof (EFI_FFS_FILE_HEADER) * 2); // // Add whatever it takes to get to the next aligned address @@ -609,6 +584,31 @@ Returns: // PadFileSize -= (UINTN) FvImage->CurrentFilePointer - (UINTN) FvImage->FileImage; + // + // Append extension header size + // + if (ExtHeader != NULL) { + PadFileSize = PadFileSize + ExtHeader->ExtHeaderSize; + } + + // + // Verify that we have enough space for the file header + // + if (((UINTN) FvImage->CurrentFilePointer + PadFileSize) > (UINTN) FvEnd) { + return EFI_OUT_OF_RESOURCES; + } + + // + // Write pad file header + // + PadFile = (EFI_FFS_FILE_HEADER *) FvImage->CurrentFilePointer; + + // + // Write PadFile FFS header with PadType, don't need to set PAD file guid in its header. + // + PadFile->Type = EFI_FV_FILETYPE_FFS_PAD; + PadFile->Attributes = 0; + // // Write pad file size (calculated size minus next file header size) // @@ -630,26 +630,26 @@ Returns: (EFI_FFS_FILE_HEADER *) PadFile, (EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage ); - + + // + // Update the current FV pointer + // + FvImage->CurrentFilePointer += PadFileSize; + if (ExtHeader != NULL) { // // Copy Fv Extension Header and Set Fv Extension header offset // memcpy (PadFile + 1, ExtHeader, ExtHeader->ExtHeaderSize); ((EFI_FIRMWARE_VOLUME_HEADER *) FvImage->FileImage)->ExtHeaderOffset = (UINT16) ((UINTN) (PadFile + 1) - (UINTN) FvImage->FileImage); + // + // Make next file start at QWord Boundry + // + while (((UINTN) FvImage->CurrentFilePointer & (EFI_FFS_FILE_HEADER_ALIGNMENT - 1)) != 0) { + FvImage->CurrentFilePointer++; + } } - // - // Verify that we have enough space (including the padding) - // - if (((UINTN)PadFile + PadFileSize) >= (UINTN) FvImage->Eof) { - return EFI_OUT_OF_RESOURCES; - } - // - // Update the current FV pointer - // - FvImage->CurrentFilePointer += PadFileSize; - return EFI_SUCCESS; } @@ -726,7 +726,7 @@ Returns: EFI_IMAGE_OPTIONAL_HEADER_UNION *ImgHdr; EFI_TE_IMAGE_HEADER *TEImageHeader; EFI_IMAGE_SECTION_HEADER *SectionHeader; - + unsigned long long TempLongAddress; // // Init local variable // @@ -806,20 +806,20 @@ Returns: // if (ImageBaseAddress == 0) { fprintf (FvMapFile, "%s (dummy) (", KeyWord); - fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress); + fprintf (FvMapFile, "BaseAddress=%08llx, ", (unsigned long long) ImageBaseAddress); } else { fprintf (FvMapFile, "%s (", KeyWord); - fprintf (FvMapFile, "BaseAddress=%08lx, ", ImageBaseAddress + Offset); + fprintf (FvMapFile, "BaseAddress=%08llx, ", (unsigned long long) (ImageBaseAddress + Offset)); } - fprintf (FvMapFile, "EntryPoint=%08lx, ", ImageBaseAddress + AddressOfEntryPoint); + fprintf (FvMapFile, "EntryPoint=%08llx, ", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint)); fprintf (FvMapFile, "GUID=%s", FileGuidName); fprintf (FvMapFile, ")\n"); for (; Index > 0; Index --, SectionHeader ++) { if (stricmp ((CHAR8 *)SectionHeader->Name, ".text") == 0) { - fprintf (FvMapFile, ".textbaseaddress=%08lx ",ImageBaseAddress + SectionHeader->VirtualAddress); + fprintf (FvMapFile, ".textbaseaddress=%08llx ", (unsigned long long) (ImageBaseAddress + SectionHeader->VirtualAddress)); } else if (stricmp ((CHAR8 *)SectionHeader->Name, ".data") == 0) { - fprintf (FvMapFile, ".databaseaddress=%08lx ",ImageBaseAddress + SectionHeader->VirtualAddress); + fprintf (FvMapFile, ".databaseaddress=%08llx ", (unsigned long long) (ImageBaseAddress + SectionHeader->VirtualAddress)); } } fprintf (FvMapFile, "\n\n"); @@ -869,25 +869,27 @@ Returns: // Printf Function Information // if (FunctionType == 1) { - sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName); + sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName); + FunctionAddress = (UINT64) TempLongAddress; if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) { - fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress); - fprintf (FvMapFile, "(%08lx) F ", FunctionAddress - Offset); + fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress)); + fprintf (FvMapFile, "(%08llx) F ", (unsigned long long) (FunctionAddress - Offset)); fprintf (FvMapFile, "%s\n", FunctionName); } else { - fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress); - fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset); + fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress)); + fprintf (FvMapFile, "(%08llx) ", (unsigned long long) (FunctionAddress - Offset)); fprintf (FvMapFile, "%s\n", FunctionName); } } else if (FunctionType == 2) { - sscanf (Line, "%s %s %lx %s", KeyWord, FunctionName, &FunctionAddress, FunctionTypeName); + sscanf (Line, "%s %s %llx %s", KeyWord, FunctionName, &TempLongAddress, FunctionTypeName); + FunctionAddress = (UINT64) TempLongAddress; if (FunctionTypeName [1] == '\0' && (FunctionTypeName [0] == 'f' || FunctionTypeName [0] == 'F')) { - fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress); - fprintf (FvMapFile, "(%08lx) FS ", FunctionAddress - Offset); + fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress)); + fprintf (FvMapFile, "(%08llx) FS ", (unsigned long long) (FunctionAddress - Offset)); fprintf (FvMapFile, "%s\n", FunctionName); } else { - fprintf (FvMapFile, " %016lx ", ImageBaseAddress + FunctionAddress); - fprintf (FvMapFile, "(%08lx) ", FunctionAddress - Offset); + fprintf (FvMapFile, " %016llx ", (unsigned long long) (ImageBaseAddress + FunctionAddress)); + fprintf (FvMapFile, "(%08llx) ", (unsigned long long) (FunctionAddress - Offset)); fprintf (FvMapFile, "%s\n", FunctionName); } } @@ -1028,7 +1030,7 @@ Returns: // for (Index1 = 0; Index1 < Index; Index1 ++) { if (CompareGuid ((EFI_GUID *) FileBuffer, &mFileGuidArray [Index1]) == 0) { - Error (NULL, 0, 2000, "Invalid parameter", "the %dth file and %dth file have the same file GUID.", Index1 + 1, Index + 1); + Error (NULL, 0, 2000, "Invalid parameter", "the %dth file and %uth file have the same file GUID.", (unsigned) Index1 + 1, (unsigned) Index + 1); PrintGuid ((EFI_GUID *) FileBuffer); return EFI_INVALID_PARAMETER; } @@ -1067,7 +1069,7 @@ Returns: // Sanity check. The file MUST align appropriately // if (((UINTN) *VtfFileImage + sizeof (EFI_FFS_FILE_HEADER) - (UINTN) FvImage->FileImage) % (1 << CurrentFileAlignment)) { - Error (NULL, 0, 3000, "Invalid", "VTF file cannot be aligned on a %d-byte boundary.", 1 << CurrentFileAlignment); + Error (NULL, 0, 3000, "Invalid", "VTF file cannot be aligned on a %u-byte boundary.", (unsigned) (1 << CurrentFileAlignment)); free (FileBuffer); return EFI_ABORTED; } @@ -1096,7 +1098,7 @@ Returns: // // Add pad file if necessary // - Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, NULL); + Status = AddPadFile (FvImage, 1 << CurrentFileAlignment, *VtfFileImage, NULL); if (EFI_ERROR (Status)) { Error (NULL, 0, 4002, "Resource", "FV space is full, could not add pad file for data alignment property."); free (FileBuffer); @@ -1105,7 +1107,7 @@ Returns: // // Add file // - if ((FvImage->CurrentFilePointer + FileSize) < FvImage->Eof) { + if ((UINTN) (FvImage->CurrentFilePointer + FileSize) <= (UINTN) (*VtfFileImage)) { // // Rebase the PE or TE image in FileBuffer of FFS file for XIP. // Rebase Bs and Rt drivers for the debug genfvmap tool. @@ -1174,6 +1176,10 @@ Returns: return EFI_SUCCESS; } + if ((UINTN) VtfFileImage < (UINTN) FvImage->CurrentFilePointer) { + return EFI_INVALID_PARAMETER; + } + // // Pad file starts at beginning of free space // @@ -1261,11 +1267,11 @@ Returns: UINT8 *BytePointer2; UINT16 *WordPointer; UINT16 CheckSum; + UINT32 IpiVector; UINTN Index; EFI_FFS_FILE_STATE SavedState; UINT64 FitAddress; FIT_TABLE *FitTablePtr; - UINT32 IpiVector; // // Verify input parameters @@ -1325,7 +1331,7 @@ Returns: SecCorePhysicalAddress = FvInfo->BaseAddress; SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; SecCorePhysicalAddress += EntryPoint; - DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%X", SecCorePhysicalAddress); + DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%llX", (unsigned long long) SecCorePhysicalAddress); // // Find the PEI Core @@ -1365,7 +1371,7 @@ Returns: PeiCorePhysicalAddress = FvInfo->BaseAddress; PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; PeiCorePhysicalAddress += EntryPoint; - DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%X", PeiCorePhysicalAddress); + DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress); if (MachineType == EFI_IMAGE_MACHINE_IA64) { // @@ -1381,8 +1387,8 @@ Returns: // if (PeiCorePhysicalAddress & 0xF) { Error (NULL, 0, 3000, "Invalid", - "PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %Xh.", - PeiCorePhysicalAddress + "PEI_CORE entry point is not aligned on a 16 byte boundary, address specified is %llXh.", + (unsigned long long) PeiCorePhysicalAddress ); return EFI_ABORTED; } @@ -1411,8 +1417,8 @@ Returns: // if (SecCorePhysicalAddress & 0xF) { Error (NULL, 0, 3000, "Invalid", - "SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %Xh.", - SecCorePhysicalAddress + "SALE_ENTRY entry point is not aligned on a 16 byte boundary, address specified is %llXh.", + (unsigned long long) SecCorePhysicalAddress ); return EFI_ABORTED; } @@ -1448,7 +1454,7 @@ Returns: // Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - IA32_SEC_CORE_ENTRY_OFFSET); - Ia32SecEntryOffset = SecCorePhysicalAddress - (FV_IMAGES_TOP_ADDRESS - IA32_SEC_CORE_ENTRY_OFFSET + 2); + Ia32SecEntryOffset = (INT32) (SecCorePhysicalAddress - (FV_IMAGES_TOP_ADDRESS - IA32_SEC_CORE_ENTRY_OFFSET + 2)); if (Ia32SecEntryOffset <= -65536) { Error (NULL, 0, 3000, "Invalid", "The SEC EXE file size is too large, it must be less than 64K."); return STATUS_ERROR; @@ -1461,7 +1467,7 @@ Returns: // Ia32ResetAddressPtr = (UINT32 *) ((UINTN) FvImage->Eof - 4); *Ia32ResetAddressPtr = (UINT32) (FvInfo->BaseAddress); - DebugMsg (NULL, 0, 9, "update BFV base address in the top FV image", "BFV base address = 0x%X.", FvInfo->BaseAddress); + DebugMsg (NULL, 0, 9, "update BFV base address in the top FV image", "BFV base address = 0x%llX.", (unsigned long long) FvInfo->BaseAddress); // // Update the Startup AP in the FVH header block ZeroVector region. @@ -1507,9 +1513,9 @@ Returns: // // IpiVector at the 4k aligned address in the top 2 blocks in the PEI FV. // - IpiVector = FV_IMAGES_TOP_ADDRESS - ((UINTN) FvImage->Eof - (UINTN) BytePointer); - DebugMsg (NULL, 0, 9, "Startup AP Vector address", "IpiVector at 0x%X", IpiVector); - if (IpiVector & 0xFFF != 0) { + IpiVector = (UINT32) (FV_IMAGES_TOP_ADDRESS - ((UINTN) FvImage->Eof - (UINTN) BytePointer)); + DebugMsg (NULL, 0, 9, "Startup AP Vector address", "IpiVector at 0x%X", (unsigned) IpiVector); + if ((IpiVector & 0xFFF) != 0) { Error (NULL, 0, 3000, "Invalid", "Startup AP Vector address are not 4K aligned, because the FV size is not 4K aligned"); return EFI_ABORTED; } @@ -1527,7 +1533,7 @@ Returns: // Volume Top File, but if you have one for some reason don't crash... // } else { - Error (NULL, 0, 3000, "Invalid", "machine type=0x%X in PEI core.", (UINT32) MachineType); + Error (NULL, 0, 3000, "Invalid", "machine type=0x%X in PEI core.", MachineType); return EFI_ABORTED; } @@ -1575,7 +1581,7 @@ Routine Description: FIQ +24 We support two schemes on ARM. - 1) Begining of the FV is the reset vector + 1) Beginning of the FV is the reset vector 2) Reset vector is data bytes FDF file and that code branches to reset vector in the beginning of the FV (fixed size offset). @@ -1671,7 +1677,7 @@ Returns: PeiCorePhysicalAddress = FvInfo->BaseAddress; PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; PeiCorePhysicalAddress += EntryPoint; - DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%X", PeiCorePhysicalAddress); + DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress); if (MachineType == EFI_IMAGE_MACHINE_ARMT) { memset (ResetVector, 0, sizeof (ResetVector)); @@ -1726,7 +1732,7 @@ Returns: SecCorePhysicalAddress = FvInfo->BaseAddress; SecCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; SecCorePhysicalAddress += EntryPoint; - DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%X", SecCorePhysicalAddress); + DebugMsg (NULL, 0, 9, "SecCore physical entry point address", "Address = 0x%llX", (unsigned long long) SecCorePhysicalAddress); // // Find the PEI Core. It may not exist if SEC loads DXE core directly @@ -1764,7 +1770,7 @@ Returns: PeiCorePhysicalAddress = FvInfo->BaseAddress; PeiCorePhysicalAddress += (UINTN) Pe32Section.Pe32Section + sizeof (EFI_SECTION_PE32) - (UINTN) FvImage->FileImage; PeiCorePhysicalAddress += EntryPoint; - DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%X", PeiCorePhysicalAddress); + DebugMsg (NULL, 0, 9, "PeiCore physical entry point address", "Address = 0x%llX", (unsigned long long) PeiCorePhysicalAddress); } @@ -1880,7 +1886,7 @@ Returns: // Verify NT header is expected // if (ImgHdr->Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) { - Error (NULL, 0, 3000, "Invalid", "Unrecognized image signature 0x%08X.", ImgHdr->Pe32.Signature); + Error (NULL, 0, 3000, "Invalid", "Unrecognized image signature 0x%08X.", (unsigned) ImgHdr->Pe32.Signature); return EFI_UNSUPPORTED; } // @@ -1990,7 +1996,7 @@ Returns: // if (mFvDataInfo.FvFileSystemGuidSet) { DebugMsg (NULL, 0, 9, "FV File System Guid", "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - mFvDataInfo.FvFileSystemGuid.Data1, + (unsigned) mFvDataInfo.FvFileSystemGuid.Data1, mFvDataInfo.FvFileSystemGuid.Data2, mFvDataInfo.FvFileSystemGuid.Data3, mFvDataInfo.FvFileSystemGuid.Data4[0], @@ -2007,7 +2013,7 @@ Returns: // if (mFvDataInfo.FvNameGuidSet) { DebugMsg (NULL, 0, 9, "FV Name Guid", "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - mFvDataInfo.FvNameGuid.Data1, + (unsigned) mFvDataInfo.FvNameGuid.Data1, mFvDataInfo.FvNameGuid.Data2, mFvDataInfo.FvNameGuid.Data3, mFvDataInfo.FvNameGuid.Data4[0], @@ -2043,7 +2049,7 @@ Returns: if (EFI_ERROR (Status)) { return Status; } - VerboseMsg ("the generated FV image size is %d bytes", mFvDataInfo.Size); + VerboseMsg ("the generated FV image size is %u bytes", (unsigned) mFvDataInfo.Size); // // support fv image and empty fv image @@ -2120,7 +2126,7 @@ Returns: // // If there is no FFS file, generate one empty FV // - if (mFvDataInfo.FvFiles[0][0] == 0) { + if (mFvDataInfo.FvFiles[0][0] == 0 && !mFvDataInfo.FvNameGuidSet) { goto WriteFile; } @@ -2155,15 +2161,15 @@ Returns: // if (mFvTotalSize != 0) { fprintf (FvMapFile, EFI_FV_TOTAL_SIZE_STRING); - fprintf (FvMapFile, " = 0x%x\n", mFvTotalSize); + fprintf (FvMapFile, " = 0x%x\n", (unsigned) mFvTotalSize); } if (mFvTakenSize != 0) { fprintf (FvMapFile, EFI_FV_TAKEN_SIZE_STRING); - fprintf (FvMapFile, " = 0x%x\n", mFvTakenSize); + fprintf (FvMapFile, " = 0x%x\n", (unsigned) mFvTakenSize); } if (mFvTotalSize != 0 && mFvTakenSize != 0) { fprintf (FvMapFile, EFI_FV_SPACE_SIZE_STRING); - fprintf (FvMapFile, " = 0x%x\n\n", mFvTotalSize - mFvTakenSize); + fprintf (FvMapFile, " = 0x%x\n\n", (unsigned) (mFvTotalSize - mFvTakenSize)); } // @@ -2172,7 +2178,7 @@ Returns: if (mFvDataInfo.FvNameGuidSet) { memcpy (&FvExtHeader.FvName, &mFvDataInfo.FvNameGuid, sizeof (EFI_GUID)); FvExtHeader.ExtHeaderSize = sizeof (EFI_FIRMWARE_VOLUME_EXT_HEADER); - AddPadFile (&FvImageMemoryFile, 8, &FvExtHeader); + AddPadFile (&FvImageMemoryFile, 4, VtfFileImage, &FvExtHeader); // // Fv Extension header change update Fv Header Check sum // @@ -2382,7 +2388,9 @@ Returns: UINT32 FfsAlignment; EFI_FFS_FILE_HEADER FfsHeader; BOOLEAN VtfFileFlag; + UINTN VtfFileSize; + VtfFileSize = 0; VtfFileFlag = FALSE; fpin = NULL; Index = 0; @@ -2453,24 +2461,22 @@ Returns: return EFI_ABORTED; } VtfFileFlag = TRUE; - // - // The space between Vft File and the latest file must be able to contain - // one ffs file header in order to add one pad file. - // - CurrentOffset += sizeof (EFI_FFS_FILE_HEADER); - } - // - // Get the alignment of FFS file - // - ReadFfsAlignment (&FfsHeader, &FfsAlignment); - FfsAlignment = 1 << FfsAlignment; - // - // Add Pad file - // - if (((CurrentOffset + sizeof (EFI_FFS_FILE_HEADER)) % FfsAlignment) != 0) { - CurrentOffset = (CurrentOffset + sizeof (EFI_FFS_FILE_HEADER) * 2 + FfsAlignment - 1) & ~(FfsAlignment - 1); - CurrentOffset -= sizeof (EFI_FFS_FILE_HEADER); - } + VtfFileSize = FfsFileSize; + continue; + } + + // + // Get the alignment of FFS file + // + ReadFfsAlignment (&FfsHeader, &FfsAlignment); + FfsAlignment = 1 << FfsAlignment; + // + // Add Pad file + // + if (((CurrentOffset + sizeof (EFI_FFS_FILE_HEADER)) % FfsAlignment) != 0) { + CurrentOffset = (CurrentOffset + sizeof (EFI_FFS_FILE_HEADER) * 2 + FfsAlignment - 1) & ~(FfsAlignment - 1); + CurrentOffset -= sizeof (EFI_FFS_FILE_HEADER); + } } // @@ -2489,8 +2495,8 @@ Returns: CurrentOffset = (CurrentOffset + EFI_FFS_FILE_HEADER_ALIGNMENT - 1) & ~(EFI_FFS_FILE_HEADER_ALIGNMENT - 1); } } - - DebugMsg (NULL, 0, 9, "FvImage size", "The caculated fv image size is 0x%x and the current set fv image size is 0x%x", CurrentOffset, FvInfoPtr->Size); + CurrentOffset += VtfFileSize; + DebugMsg (NULL, 0, 9, "FvImage size", "The caculated fv image size is 0x%x and the current set fv image size is 0x%x", (unsigned) CurrentOffset, (unsigned) FvInfoPtr->Size); if (FvInfoPtr->Size == 0) { // @@ -2504,7 +2510,7 @@ Returns: // // Not invalid // - Error (NULL, 0, 3000, "Invalid", "the required fv image size 0x%x exceeds the set fv image size 0x%x", CurrentOffset, FvInfoPtr->Size); + Error (NULL, 0, 3000, "Invalid", "the required fv image size 0x%x exceeds the set fv image size 0x%x", (unsigned) CurrentOffset, (unsigned) FvInfoPtr->Size); return EFI_INVALID_PARAMETER; } @@ -2627,8 +2633,8 @@ Returns: // // Check XipAddress, BootAddress and RuntimeAddress // - Flags = 0; - + Flags = 0; + XipBase = 0; if (FvInfo->BaseAddress != 0) { Flags |= REBASE_XIP_FILE; XipBase = FvInfo->BaseAddress + XipOffset; @@ -2686,7 +2692,7 @@ Returns: ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead; Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, Status); + Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, (int) Status); return Status; } @@ -2785,7 +2791,7 @@ Returns: ImageContext.Handle = PeFileBuffer; Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, Status); + Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and the return status is %x", FileName, (int) Status); return Status; } ImageContext.RelocationsStripped = FALSE; @@ -2935,7 +2941,7 @@ Returns: ImgHdr->Pe32Plus.OptionalHeader.ImageBase = NewPe32BaseAddress; } else { Error (NULL, 0, 3000, "Invalid", "unknown PE magic signature %X in PE32 image %s", - (UINT32) ImgHdr->Pe32.OptionalHeader.Magic, + ImgHdr->Pe32.OptionalHeader.Magic, FileName ); return EFI_ABORTED; @@ -3018,7 +3024,7 @@ WritePeMap: ImageContext.ImageRead = (PE_COFF_LOADER_READ_FILE) FfsRebaseImageRead; Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, Status); + Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, (int) Status); return Status; } @@ -3101,7 +3107,7 @@ WritePeMap: ImageContext.Handle = PeFileBuffer; Status = PeCoffLoaderGetImageInfo (&ImageContext); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, Status); + Error (NULL, 0, 3000, "Invalid TeImage", "The input file is %s and the return status is %x", FileName, (int) Status); return Status; } ImageContext.RelocationsStripped = FALSE; @@ -3365,8 +3371,14 @@ Returns: if (Status == EFI_SUCCESS) { if (strstr (Value, "PopulateSystemTable") != NULL) { CapInfo->Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET | CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE; + if (strstr (Value, "InitiateReset") != NULL) { + CapInfo->Flags |= CAPSULE_FLAGS_INITIATE_RESET; + } } else if (strstr (Value, "PersistAcrossReset") != NULL) { CapInfo->Flags |= CAPSULE_FLAGS_PERSIST_ACROSS_RESET; + if (strstr (Value, "InitiateReset") != NULL) { + CapInfo->Flags |= CAPSULE_FLAGS_INITIATE_RESET; + } } else { Error (NULL, 0, 2000, "Invalid parameter", "invalid Flag setting for %s.", EFI_CAPSULE_FLAGS_STRING); return EFI_ABORTED; @@ -3403,7 +3415,7 @@ Returns: // Add the file // strcpy (CapInfo->CapFiles[Index], Value); - DebugMsg (NULL, 0, 9, "Capsule component file", "the %dth file name is %s", Index, CapInfo->CapFiles[Index]); + DebugMsg (NULL, 0, 9, "Capsule component file", "the %uth file name is %s", (unsigned) Index, CapInfo->CapFiles[Index]); } else { break; } @@ -3568,7 +3580,7 @@ Returns: fwrite (CapBuffer, 1, CapSize, fpout); fclose (fpout); - VerboseMsg ("The size of the generated capsule image is %d bytes", CapSize); + VerboseMsg ("The size of the generated capsule image is %u bytes", (unsigned) CapSize); return EFI_SUCCESS; } diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c index d570f633d5..8c648eb407 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -23,6 +23,7 @@ Abstract: #ifndef __GNUC__ #include +#include #endif #include #include @@ -43,6 +44,8 @@ Abstract: #include #include "CommonLib.h" +#include "PeCoffLib.h" +#include "ParseInf.h" #include "EfiUtilityMsgs.h" #include "elf_common.h" @@ -321,6 +324,10 @@ Returns: ExpectedLength = sizeof(EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE); break; default: + if (AcpiHeader->Revision > EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION) { + ExpectedLength = AcpiHeader->Length; + break; + } Error (NULL, 0, 3000, "Invalid", "FACP revision check failed."); return STATUS_ERROR; } @@ -335,7 +342,10 @@ Returns: // case EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE: Facs = (EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)AcpiTable; - if ((Facs->Version != 0) && + if (Facs->Version > EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) { + break; + } + if ((Facs->Version != EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && (Facs->Version != EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION) && (Facs->Version != EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION)){ Error (NULL, 0, 3000, "Invalid", "FACS version check failed."); @@ -354,8 +364,7 @@ Returns: // case EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE: if (AcpiHeader->Revision > EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION) { - Error (NULL, 0, 3000, "Invalid", "DSDT revision check failed."); - return STATUS_ERROR; + break; } if (AcpiHeader->Length <= sizeof(EFI_ACPI_DESCRIPTION_HEADER)) { Error (NULL, 0, 3000, "Invalid", "DSDT length check failed."); @@ -367,6 +376,9 @@ Returns: // "APIC" Multiple APIC Description Table // case EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE: + if (AcpiHeader->Revision > EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) { + break; + } if ((AcpiHeader->Revision != EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) && (AcpiHeader->Revision != EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION) && (AcpiHeader->Revision != EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION)) { @@ -383,6 +395,9 @@ Returns: // "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table // case EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE: + if (AcpiHeader->Revision > EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION) { + break; + } if (AcpiHeader->Revision != EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION) { Error (NULL, 0, 3000, "Invalid", "MCFG revision check failed."); return STATUS_ERROR; @@ -437,7 +452,7 @@ Elf_Phdr *gPhdrBase; // PE section alignment. // const UINT32 CoffAlignment = 0x20; -const UINT32 CoffNbrSections = 4; +const UINT16 CoffNbrSections = 4; // // Current offset in coff file. @@ -508,7 +523,7 @@ CheckElfHeader( return 0; } if (Ehdr->e_version != EV_CURRENT) { - Error (NULL, 0, 3000, "Unsupported", "ELF e_version (%d) not EV_CURRENT (%d)", Ehdr->e_version, EV_CURRENT); + Error (NULL, 0, 3000, "Unsupported", "ELF e_version (%u) not EV_CURRENT (%d)", (unsigned) Ehdr->e_version, EV_CURRENT); return 0; } @@ -707,7 +722,7 @@ ScanSections( } NtHdr->Pe32.FileHeader.NumberOfSections = CoffNbrSections; - NtHdr->Pe32.FileHeader.TimeDateStamp = time(NULL); + NtHdr->Pe32.FileHeader.TimeDateStamp = (UINT32) time(NULL); NtHdr->Pe32.FileHeader.PointerToSymbolTable = 0; NtHdr->Pe32.FileHeader.NumberOfSymbols = 0; NtHdr->Pe32.FileHeader.SizeOfOptionalHeader = sizeof(NtHdr->Pe32.OptionalHeader); @@ -787,7 +802,7 @@ WriteSections( // // Ignore for unkown section type. // - VerboseMsg ("%s unknown section type %x. We directly copy this section into Coff file", mInImageName, (UINTN)Shdr->sh_type); + VerboseMsg ("%s unknown section type %x. We directly copy this section into Coff file", mInImageName, (unsigned)Shdr->sh_type); break; } } @@ -846,7 +861,7 @@ WriteSections( - (SecOffset - SecShdr->sh_addr); break; default: - Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, ELF_R_TYPE(Rel->r_info)); + Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info)); } } else if (Ehdr->e_machine == EM_ARM) { switch (ELF32_R_TYPE(Rel->r_info)) { @@ -862,7 +877,7 @@ WriteSections( *(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr + CoffSectionsOffset[Sym->st_shndx]; break; default: - Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, ELF32_R_TYPE(Rel->r_info)); + Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info)); } } } @@ -918,7 +933,7 @@ CoffAddFixup( // // Fill the entry. // - CoffAddFixupEntry((Type << 12) | (Offset & 0xfff)); + CoffAddFixupEntry((UINT16) ((Type << 12) | (Offset & 0xfff))); } @@ -976,7 +991,7 @@ WriteRelocations( EFI_IMAGE_REL_BASED_HIGHLOW); break; default: - Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, ELF_R_TYPE(Rel->r_info)); + Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info)); } } else if (Ehdr->e_machine == EM_ARM) { switch (ELF32_R_TYPE(Rel->r_info)) { @@ -993,10 +1008,10 @@ WriteRelocations( ); break; default: - Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, ELF32_R_TYPE(Rel->r_info)); + Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info)); } } else { - Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %d (processor type).", Ehdr->e_machine); + Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) Ehdr->e_machine); } } } @@ -1214,19 +1229,20 @@ ZeroXdataSection ( CHAR8 KeyWord [MAX_LINE_LEN]; CHAR8 SectionName [MAX_LINE_LEN]; UINT32 FunctionType = 0; - UINT32 SectionOffset; - UINT32 SectionLength; - UINT32 SectionNumber; + unsigned SectionOffset = 0; + unsigned SectionLength = 0; + unsigned SectionNumber = 0; CHAR8 *PdbPointer; - INT32 Index = 0; + INT32 Index; + UINT32 Index2; - for (Index = 0; Index < SectionTotalNumber; Index ++) { - if (stricmp ((char *)SectionHeader[Index].Name, ".zdata") == 0) { + for (Index2 = 0; Index2 < SectionTotalNumber; Index2++) { + if (stricmp ((char *)SectionHeader[Index2].Name, ".zdata") == 0) { // // try to zero the customized .zdata section, which is mapped to .xdata // - memset (FileBuffer + SectionHeader[Index].PointerToRawData, 0, SectionHeader[Index].SizeOfRawData); - DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", SectionHeader[Index].PointerToRawData, SectionHeader[Index].SizeOfRawData); + memset (FileBuffer + SectionHeader[Index2].PointerToRawData, 0, SectionHeader[Index2].SizeOfRawData); + DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", (unsigned) SectionHeader[Index2].PointerToRawData, (unsigned) SectionHeader[Index2].SizeOfRawData); return; } } @@ -1329,7 +1345,7 @@ ZeroXdataSection ( // Zero .xdata Section data // memset (FileBuffer + SectionHeader[SectionNumber-1].PointerToRawData + SectionOffset, 0, SectionLength); - DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", SectionHeader[SectionNumber-1].PointerToRawData + SectionOffset, SectionLength); + DebugMsg (NULL, 0, 9, NULL, "Zero the .xdata section for PE image at Offset 0x%x and Length 0x%x", (unsigned) SectionHeader[SectionNumber-1].PointerToRawData + SectionOffset, SectionLength); fclose (fpMapFile); return; } @@ -1610,7 +1626,7 @@ Returns: goto Finish; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel); goto Finish; } SetPrintLevel (LogLevel); @@ -1631,7 +1647,7 @@ Returns: InputFileName = (CHAR8 **) malloc (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *)); if (InputFileName == NULL) { Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!"); - return EFI_OUT_OF_RESOURCES; + goto Finish; } memset (InputFileName, 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *))); @@ -1646,7 +1662,7 @@ Returns: if (InputFileName == NULL) { Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!"); - return EFI_OUT_OF_RESOURCES; + goto Finish; } memset (&(InputFileName[InputFileNum]), 0, (MAXIMUM_INPUT_FILE_NUM * sizeof (CHAR8 *))); @@ -1883,7 +1899,7 @@ Returns: } if (Index != FileLength) { - Error (NULL, 0, 3000, "Invalid", "file length of %s (0x%x) does not equal expected TotalSize: 0x%04X.", mInImageName, FileLength, Index); + Error (NULL, 0, 3000, "Invalid", "file length of %s (0x%x) does not equal expected TotalSize: 0x%04X.", mInImageName, (unsigned) FileLength, (unsigned) Index); goto Finish; } @@ -1899,7 +1915,7 @@ Returns: Index += sizeof (*DataPointer); } if (CheckSum != 0) { - Error (NULL, 0, 3000, "Invalid", "checksum (0x%x) failed on file %s.", CheckSum, mInImageName); + Error (NULL, 0, 3000, "Invalid", "checksum (0x%x) failed on file %s.", (unsigned) CheckSum, mInImageName); goto Finish; } // @@ -1923,7 +1939,7 @@ Returns: goto Finish; } } - VerboseMsg ("the size of output file is %d bytes", FileLength); + VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength); // // Convert Mci.TXT to Mci.bin file successfully // @@ -1950,7 +1966,7 @@ Returns: fread (FileBuffer, 1, FileLength, fpIn); fclose (fpIn); - DebugMsg (NULL, 0, 9, "input file info", "the input file size is %d bytes", FileLength); + DebugMsg (NULL, 0, 9, "input file info", "the input file size is %u bytes", (unsigned) FileLength); // // Replace file @@ -1978,11 +1994,11 @@ Returns: fprintf (fpInOut, "%17X number of sections\n", TEImageHeader.NumberOfSections); fprintf (fpInOut, "%17X subsystems\n", TEImageHeader.Subsystem); fprintf (fpInOut, "%17X stripped size\n", TEImageHeader.StrippedSize); - fprintf (fpInOut, "%17X entry point\n", TEImageHeader.AddressOfEntryPoint); - fprintf (fpInOut, "%17X base of code\n", TEImageHeader.BaseOfCode); - fprintf (fpInOut, "%17lX image base\n", (long unsigned int)TEImageHeader.ImageBase); - fprintf (fpInOut, "%17X [%8X] RVA [size] of Base Relocation Directory\n", TEImageHeader.DataDirectory[0].VirtualAddress, TEImageHeader.DataDirectory[0].Size); - fprintf (fpInOut, "%17X [%8X] RVA [size] of Debug Directory\n", TEImageHeader.DataDirectory[1].VirtualAddress, TEImageHeader.DataDirectory[1].Size); + fprintf (fpInOut, "%17X entry point\n", (unsigned) TEImageHeader.AddressOfEntryPoint); + fprintf (fpInOut, "%17X base of code\n", (unsigned) TEImageHeader.BaseOfCode); + fprintf (fpInOut, "%17llX image base\n", (unsigned long long)TEImageHeader.ImageBase); + fprintf (fpInOut, "%17X [%8X] RVA [size] of Base Relocation Directory\n", (unsigned) TEImageHeader.DataDirectory[0].VirtualAddress, (unsigned) TEImageHeader.DataDirectory[0].Size); + fprintf (fpInOut, "%17X [%8X] RVA [size] of Debug Directory\n", (unsigned) TEImageHeader.DataDirectory[1].VirtualAddress, (unsigned) TEImageHeader.DataDirectory[1].Size); } if (fpOut != NULL) { @@ -1992,11 +2008,11 @@ Returns: fprintf (fpOut, "%17X number of sections\n", TEImageHeader.NumberOfSections); fprintf (fpOut, "%17X subsystems\n", TEImageHeader.Subsystem); fprintf (fpOut, "%17X stripped size\n", TEImageHeader.StrippedSize); - fprintf (fpOut, "%17X entry point\n", TEImageHeader.AddressOfEntryPoint); - fprintf (fpOut, "%17X base of code\n", TEImageHeader.BaseOfCode); - fprintf (fpOut, "%17lX image base\n", (long unsigned int)TEImageHeader.ImageBase); - fprintf (fpOut, "%17X [%8X] RVA [size] of Base Relocation Directory\n", TEImageHeader.DataDirectory[0].VirtualAddress, TEImageHeader.DataDirectory[0].Size); - fprintf (fpOut, "%17X [%8X] RVA [size] of Debug Directory\n", TEImageHeader.DataDirectory[1].VirtualAddress, TEImageHeader.DataDirectory[1].Size); + fprintf (fpOut, "%17X entry point\n", (unsigned) TEImageHeader.AddressOfEntryPoint); + fprintf (fpOut, "%17X base of code\n", (unsigned) TEImageHeader.BaseOfCode); + fprintf (fpOut, "%17llX image base\n", (unsigned long long)TEImageHeader.ImageBase); + fprintf (fpOut, "%17X [%8X] RVA [size] of Base Relocation Directory\n", (unsigned) TEImageHeader.DataDirectory[0].VirtualAddress, (unsigned) TEImageHeader.DataDirectory[0].Size); + fprintf (fpOut, "%17X [%8X] RVA [size] of Debug Directory\n", (unsigned) TEImageHeader.DataDirectory[1].VirtualAddress, (unsigned) TEImageHeader.DataDirectory[1].Size); } goto Finish; } @@ -2201,7 +2217,7 @@ Returns: if (fpInOut != NULL) { fwrite (FileBuffer + PeHdr->Pe32.OptionalHeader.SizeOfHeaders, 1, FileLength - PeHdr->Pe32.OptionalHeader.SizeOfHeaders, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength - PeHdr->Pe32.OptionalHeader.SizeOfHeaders); + VerboseMsg ("the size of output file is %u bytes", (unsigned) (FileLength - PeHdr->Pe32.OptionalHeader.SizeOfHeaders)); goto Finish; } @@ -2211,7 +2227,7 @@ Returns: if (OutImageType == FW_ZERO_DEBUG_IMAGE) { Status = ZeroDebugData (FileBuffer, TRUE); if (EFI_ERROR (Status)) { - Error (NULL, 0, 3000, "Invalid", "Zero DebugData Error status is 0x%lx", (UINTN) Status); + Error (NULL, 0, 3000, "Invalid", "Zero DebugData Error status is 0x%x", (int) Status); goto Finish; } @@ -2221,7 +2237,7 @@ Returns: if (fpInOut != NULL) { fwrite (FileBuffer, 1, FileLength, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength); + VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength); goto Finish; } @@ -2240,7 +2256,7 @@ Returns: if (fpInOut != NULL) { fwrite (FileBuffer, 1, FileLength, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength); + VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength); goto Finish; } @@ -2274,7 +2290,7 @@ Returns: if (fpInOut != NULL) { fwrite (FileBuffer + SectionHeader->PointerToRawData, 1, FileLength, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength); + VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength); goto Finish; } } @@ -2291,7 +2307,7 @@ Returns: DosHdr->e_lfanew = BackupDosHdr.e_lfanew; for (Index = sizeof (EFI_IMAGE_DOS_HEADER); Index < (UINT32 ) DosHdr->e_lfanew; Index++) { - FileBuffer[Index] = DosHdr->e_cp; + FileBuffer[Index] = (UINT8) DosHdr->e_cp; } } @@ -2397,7 +2413,7 @@ Returns: Optional32->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize); SectionHeader->SizeOfRawData = AllignedRelocSize; FileLength = Optional32->SizeOfImage; - DebugMsg (NULL, 0, 9, "Remove the zero padding bytes at the end of the base relocations", "The size of padding bytes is %d", SectionHeader->SizeOfRawData - AllignedRelocSize); + DebugMsg (NULL, 0, 9, "Remove the zero padding bytes at the end of the base relocations", "The size of padding bytes is %u", (unsigned) (SectionHeader->SizeOfRawData - AllignedRelocSize)); } } } @@ -2505,7 +2521,7 @@ Returns: Optional64->SizeOfInitializedData -= (SectionHeader->SizeOfRawData - AllignedRelocSize); SectionHeader->SizeOfRawData = AllignedRelocSize; FileLength = Optional64->SizeOfImage; - DebugMsg (NULL, 0, 9, "Remove the zero padding bytes at the end of the base relocations", "The size of padding bytes is %d", SectionHeader->SizeOfRawData - AllignedRelocSize); + DebugMsg (NULL, 0, 9, "Remove the zero padding bytes at the end of the base relocations", "The size of padding bytes is %u", (unsigned) (SectionHeader->SizeOfRawData - AllignedRelocSize)); } } } @@ -2561,8 +2577,8 @@ Returns: goto Finish; } - DebugMsg (NULL, 0, 9, "TeImage Header Info", "Machine type is %X, Number of sections is %X, Stripped size is %X, EntryPoint is %X, BaseOfCode is %X, ImageBase is %X", - TEImageHeader.Machine, TEImageHeader.NumberOfSections, TEImageHeader.StrippedSize, TEImageHeader.AddressOfEntryPoint, TEImageHeader.BaseOfCode, TEImageHeader.ImageBase); + DebugMsg (NULL, 0, 9, "TeImage Header Info", "Machine type is %X, Number of sections is %X, Stripped size is %X, EntryPoint is %X, BaseOfCode is %X, ImageBase is %llX", + TEImageHeader.Machine, TEImageHeader.NumberOfSections, TEImageHeader.StrippedSize, (unsigned) TEImageHeader.AddressOfEntryPoint, (unsigned) TEImageHeader.BaseOfCode, (unsigned long long) TEImageHeader.ImageBase); // // Update Image to TeImage // @@ -2574,7 +2590,7 @@ Returns: fwrite (&TEImageHeader, 1, sizeof (EFI_TE_IMAGE_HEADER), fpInOut); fwrite (FileBuffer + TEImageHeader.StrippedSize, 1, FileLength - TEImageHeader.StrippedSize, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength - TEImageHeader.StrippedSize); + VerboseMsg ("the size of output file is %u bytes", (unsigned) (FileLength - TEImageHeader.StrippedSize)); goto Finish; } WriteFile: @@ -2587,7 +2603,7 @@ WriteFile: if (fpInOut != NULL) { fwrite (FileBuffer, 1, FileLength, fpInOut); } - VerboseMsg ("the size of output file is %d bytes", FileLength); + VerboseMsg ("the size of output file is %u bytes", (unsigned) FileLength); Finish: if (fpInOut != NULL) { @@ -2813,13 +2829,13 @@ Returns: struct tm stime; struct tm *ptime; time_t newtime; - UINT32 Index; - UINT32 DebugDirectoryEntryRva; - UINT32 DebugDirectoryEntryFileOffset; - UINT32 ExportDirectoryEntryRva; - UINT32 ExportDirectoryEntryFileOffset; - UINT32 ResourceDirectoryEntryRva; - UINT32 ResourceDirectoryEntryFileOffset; + UINT32 Index; + UINT32 DebugDirectoryEntryRva; + UINT32 DebugDirectoryEntryFileOffset; + UINT32 ExportDirectoryEntryRva; + UINT32 ExportDirectoryEntryFileOffset; + UINT32 ResourceDirectoryEntryRva; + UINT32 ResourceDirectoryEntryFileOffset; EFI_IMAGE_DOS_HEADER *DosHdr; EFI_IMAGE_FILE_HEADER *FileHdr; EFI_IMAGE_OPTIONAL_HEADER32 *Optional32Hdr; @@ -2830,9 +2846,12 @@ Returns: // // Init variable. // - DebugDirectoryEntryRva = 0; - ExportDirectoryEntryRva = 0; - ResourceDirectoryEntryRva = 0; + DebugDirectoryEntryRva = 0; + DebugDirectoryEntryFileOffset = 0; + ExportDirectoryEntryRva = 0; + ExportDirectoryEntryFileOffset = 0; + ResourceDirectoryEntryRva = 0; + ResourceDirectoryEntryFileOffset = 0; // // Get time and date that will be set. // @@ -3041,6 +3060,7 @@ Returns: { CHAR8 Line[MAX_LINE_LEN]; CHAR8 *cptr; + unsigned ScannedData = 0; Line[MAX_LINE_LEN - 1] = 0; while (1) { @@ -3080,10 +3100,11 @@ Returns: for (; *cptr && isspace(*cptr); cptr++) { } if (isxdigit (*cptr)) { - if (sscanf (cptr, "%X", Data) != 1) { + if (sscanf (cptr, "%X", &ScannedData) != 1) { return STATUS_ERROR; } } + *Data = (UINT32) ScannedData; return STATUS_SUCCESS; } diff --git a/BaseTools/Source/C/GenFw/elf_generic.h b/BaseTools/Source/C/GenFw/elf_generic.h deleted file mode 100644 index dd4f8e14fd..0000000000 --- a/BaseTools/Source/C/GenFw/elf_generic.h +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * Copyright (c) 1998 John D. Polstra. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/sys/elf_generic.h,v 1.6.14.2 2007/12/03 21:30:36 marius Exp $ - */ - -#ifndef _SYS_ELF_GENERIC_H_ -#define _SYS_ELF_GENERIC_H_ 1 - -#include - -/* - * Definitions of generic ELF names which relieve applications from - * needing to know the word size. - */ - -#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 -#error "__ELF_WORD_SIZE must be defined as 32 or 64" -#endif - -#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define ELF_DATA ELFDATA2LSB -#elif BYTE_ORDER == BIG_ENDIAN -#define ELF_DATA ELFDATA2MSB -#else -#error "Unknown byte order" -#endif - -#define __elfN(x) __CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x) -#define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) -#define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) -#define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) - -__ElfType(Addr); -__ElfType(Half); -__ElfType(Off); -__ElfType(Sword); -__ElfType(Word); -__ElfType(Ehdr); -__ElfType(Shdr); -__ElfType(Phdr); -__ElfType(Dyn); -__ElfType(Rel); -__ElfType(Rela); -__ElfType(Sym); -__ElfType(Verdef); -__ElfType(Verdaux); -__ElfType(Verneed); -__ElfType(Vernaux); -__ElfType(Versym); - -/* Non-standard ELF types. */ -__ElfType(Hashelt); -__ElfType(Size); -__ElfType(Ssize); - -#define ELF_R_SYM __ELFN(R_SYM) -#define ELF_R_TYPE __ELFN(R_TYPE) -#define ELF_R_INFO __ELFN(R_INFO) -#define ELF_ST_BIND __ELFN(ST_BIND) -#define ELF_ST_TYPE __ELFN(ST_TYPE) -#define ELF_ST_INFO __ELFN(ST_INFO) - -#endif /* !_SYS_ELF_GENERIC_H_ */ diff --git a/BaseTools/Source/C/GenPage/GenPage.c b/BaseTools/Source/C/GenPage/GenPage.c index 99fbc1e472..dac55889d5 100644 --- a/BaseTools/Source/C/GenPage/GenPage.c +++ b/BaseTools/Source/C/GenPage/GenPage.c @@ -35,6 +35,7 @@ Abstract: #include #include "VirtualMemory.h" #include "EfiUtilityMsgs.h" +#include "ParseInf.h" #define EFI_PAGE_BASE_OFFSET_IN_LDR 0x70000 #define EFI_PAGE_BASE_ADDRESS (EFI_PAGE_BASE_OFFSET_IN_LDR + 0x20000) @@ -252,7 +253,7 @@ return: FileSize = ftell (NoPageFile); fseek (NoPageFile, 0, SEEK_SET); if (FileSize > gPageTableOffsetInFile) { - Error (NoPageFileName, 0, 0x4002, "Invalid parameter option", "Input file size (0x%x) exceeds the Page Table Offset (0x%x)", FileSize, gPageTableOffsetInFile); + Error (NoPageFileName, 0, 0x4002, "Invalid parameter option", "Input file size (0x%lx) exceeds the Page Table Offset (0x%x)", FileSize, (unsigned) gPageTableOffsetInFile); fclose (PageFile); fclose (NoPageFile); return -1; @@ -380,7 +381,7 @@ main ( return STATUS_ERROR; } if (TempValue > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", TempValue); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) TempValue); return STATUS_ERROR; } argc -= 2; diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c index 952034ad5f..32b8cfd5a0 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -160,7 +160,8 @@ Returns: EFI_SECTION_USER_INTERFACE, EFI_SECTION_VERSION,\n\ EFI_SECTION_FIRMWARE_VOLUME_IMAGE, EFI_SECTION_RAW,\n\ EFI_SECTION_FREEFORM_SUBTYPE_GUID,\n\ - EFI_SECTION_PEI_DEPEX. if -s option is not given, \n\ + EFI_SECTION_PEI_DEPEX, EFI_SECTION_SMM_DEPEX.\n\ + if -s option is not given, \n\ EFI_SECTION_ALL is default section type.\n"); fprintf (stdout, " -c [Type], --compress [Type]\n\ Compress method type can be PI_NONE or PI_STD.\n\ @@ -282,16 +283,16 @@ Returns: fseek (InFile, 0, SEEK_END); InputFileLength = ftell (InFile); fseek (InFile, 0, SEEK_SET); - DebugMsg (NULL, 0, 9, "Input file", "File name is %s and File size is %d bytes", InputFileName[0], InputFileLength); + DebugMsg (NULL, 0, 9, "Input file", "File name is %s and File size is %u bytes", InputFileName[0], (unsigned) InputFileLength); TotalLength = sizeof (EFI_COMMON_SECTION_HEADER) + InputFileLength; // // Size must fit in 3 bytes // if (TotalLength >= MAX_SECTION_SIZE) { - Error (NULL, 0, 2000, "Invalid paramter", "%s file size (0x%X) exceeds section size limit(%dM).", InputFileName[0], TotalLength, MAX_SECTION_SIZE>>20); + Error (NULL, 0, 2000, "Invalid paramter", "%s file size (0x%X) exceeds section size limit(%uM).", InputFileName[0], (unsigned) TotalLength, MAX_SECTION_SIZE>>20); goto Done; } - VerboseMsg ("the size of the created section file is %d bytes", TotalLength); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength); // // Fill in the fields in the local section header structure // @@ -404,7 +405,7 @@ Returns: fseek (InFile, 0, SEEK_END); FileSize = ftell (InFile); fseek (InFile, 0, SEEK_SET); - DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and the size is %d bytes", InputFileName[Index], FileSize); + DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and the size is %u bytes", InputFileName[Index], (unsigned) FileSize); // // Now read the contents of the file into the buffer // Buffer must be enough to contain the file content. @@ -561,10 +562,10 @@ Returns: } DebugMsg (NULL, 0, 9, "comprss file size", - "the original section size is %d bytes and the compressed section size is %d bytes", InputLength, CompressedLength); + "the original section size is %d bytes and the compressed section size is %u bytes", (unsigned) InputLength, (unsigned) CompressedLength); TotalLength = CompressedLength + sizeof (EFI_COMPRESSION_SECTION); if (TotalLength >= MAX_SECTION_SIZE) { - Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20); + Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20); if (FileBuffer != NULL) { free (FileBuffer); } @@ -573,7 +574,7 @@ Returns: } return STATUS_ERROR; } - VerboseMsg ("the size of the created section file is %d bytes", TotalLength); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength); // // Add the section header for the compressed data @@ -708,7 +709,7 @@ Returns: TotalLength = InputLength + sizeof (CRC32_SECTION_HEADER); if (TotalLength >= MAX_SECTION_SIZE) { - Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20); + Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20); free (FileBuffer); return STATUS_ERROR; } @@ -722,12 +723,12 @@ Returns: Crc32GuidSect->GuidSectionHeader.Attributes = EFI_GUIDED_SECTION_AUTH_STATUS_VALID; Crc32GuidSect->GuidSectionHeader.DataOffset = sizeof (CRC32_SECTION_HEADER); Crc32GuidSect->CRC32Checksum = Crc32Checksum; - DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %d", Crc32GuidSect->GuidSectionHeader.DataOffset); + DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", Crc32GuidSect->GuidSectionHeader.DataOffset); } else { TotalLength = InputLength + sizeof (EFI_GUID_DEFINED_SECTION); if (TotalLength >= MAX_SECTION_SIZE) { - Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%dM).", MAX_SECTION_SIZE>>20); + Error (NULL, 0, 2000, "Invalid paramter", "The size of all files exceeds section size limit(%uM).", MAX_SECTION_SIZE>>20); free (FileBuffer); return STATUS_ERROR; } @@ -739,10 +740,10 @@ Returns: VendorGuidSect->CommonHeader.Size[2] = (UINT8) ((TotalLength & 0xff0000) >> 16); memcpy (&(VendorGuidSect->SectionDefinitionGuid), VendorGuid, sizeof (EFI_GUID)); VendorGuidSect->Attributes = DataAttribute; - VendorGuidSect->DataOffset = sizeof (EFI_GUID_DEFINED_SECTION) + DataHeaderSize; - DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %d", VendorGuidSect->DataOffset); + VendorGuidSect->DataOffset = (UINT16) (sizeof (EFI_GUID_DEFINED_SECTION) + DataHeaderSize); + DebugMsg (NULL, 0, 9, "Guided section", "Data offset is %u", VendorGuidSect->DataOffset); } - VerboseMsg ("the size of the created section file is %d bytes", TotalLength); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) TotalLength); // // Set OutFileBuffer @@ -785,7 +786,7 @@ Returns: CHAR8 *CompressionName; CHAR8 *StringBuffer; EFI_GUID VendorGuid = mZeroGuid; - INT32 VersionNumber; + int VersionNumber; UINT8 SectType; UINT8 SectCompSubType; UINT16 SectGuidAttribute; @@ -972,7 +973,7 @@ Returns: goto Finish; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0~9, currnt input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0~9, currnt input level is %d", (int) LogLevel); goto Finish; } SetPrintLevel (LogLevel); @@ -1059,7 +1060,7 @@ Returns: SectGuidAttribute = 0; } VerboseMsg ("Vendor Guid is %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - VendorGuid.Data1, + (unsigned) VendorGuid.Data1, VendorGuid.Data2, VendorGuid.Data3, VendorGuid.Data4[0], @@ -1077,7 +1078,7 @@ Returns: VerboseMsg ("Guid Attribute is %s", mGUIDedSectionAttribue[EFI_GUIDED_SECTION_AUTH_STATUS_VALID]); } if (SectGuidHeaderLength != 0) { - VerboseMsg ("Guid Data Header size is 0x%x", SectGuidHeaderLength); + VerboseMsg ("Guid Data Header size is 0x%llx", (unsigned long long) SectGuidHeaderLength); } } else if (stricmp (SectionName, mSectionTypeName[EFI_SECTION_PE32]) == 0) { SectType = EFI_SECTION_PE32; @@ -1087,6 +1088,8 @@ Returns: SectType = EFI_SECTION_TE; } else if (stricmp (SectionName, mSectionTypeName[EFI_SECTION_DXE_DEPEX]) == 0) { SectType = EFI_SECTION_DXE_DEPEX; + } else if (stricmp (SectionName, mSectionTypeName[EFI_SECTION_SMM_DEPEX]) == 0) { + SectType = EFI_SECTION_SMM_DEPEX; } else if (stricmp (SectionName, mSectionTypeName[EFI_SECTION_VERSION]) == 0) { SectType = EFI_SECTION_VERSION; if (VersionNumber < 0 || VersionNumber > 9999) { @@ -1139,7 +1142,7 @@ Returns: // Check whether there is output file // for (Index = 0; Index < InputFileNum; Index ++) { - VerboseMsg ("the %dth input file name is %s", Index, InputFileName[Index]); + VerboseMsg ("the %uth input file name is %s", (unsigned) Index, InputFileName[Index]); } if (OutputFileName == NULL) { Error (NULL, 0, 1001, "Missing options", "Output file"); @@ -1199,7 +1202,7 @@ Returns: VersionSect->CommonHeader.Size[2] = (UINT8) ((Index & 0xff0000) >> 16); VersionSect->BuildNumber = (UINT16) VersionNumber; Ascii2UnicodeString (StringBuffer, VersionSect->VersionString); - VerboseMsg ("the size of the created section file is %d bytes", Index); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) Index); break; case EFI_SECTION_USER_INTERFACE: @@ -1219,7 +1222,7 @@ Returns: UiSect->CommonHeader.Size[1] = (UINT8) ((Index & 0xff00) >> 8); UiSect->CommonHeader.Size[2] = (UINT8) ((Index & 0xff0000) >> 16); Ascii2UnicodeString (StringBuffer, UiSect->FileNameString); - VerboseMsg ("the size of the created section file is %d bytes", Index); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) Index); break; case EFI_SECTION_ALL: @@ -1250,7 +1253,7 @@ Returns: &InputLength ); } - VerboseMsg ("the size of the created section file is %d bytes", InputLength); + VerboseMsg ("the size of the created section file is %u bytes", (unsigned) InputLength); break; default: // @@ -1266,7 +1269,7 @@ Returns: } if (Status != EFI_SUCCESS || OutFileBuffer == NULL) { - Error (NULL, 0, 2000, "Status is not successful", "Status value is 0x%X", (UINTN) Status); + Error (NULL, 0, 2000, "Status is not successful", "Status value is 0x%X", (int) Status); goto Finish; } diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index e633b7ccf8..eafbcbf002 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -122,8 +122,8 @@ Returns: CHAR8 StrPtr[40]; CHAR8 *Token; UINTN Length; - UINT32 Major; - UINT32 Minor; + unsigned Major; + unsigned Minor; Major = 0; Minor = 0; @@ -278,7 +278,7 @@ InitializeComps ( Routine Description: - This function intializes the relevant global variable which is being + This function initializes the relevant global variable which is being used to store the information retrieved from INF file. This also initializes the VTF symbol file. @@ -316,7 +316,7 @@ ParseAndUpdateComponents ( Routine Description: - This function intializes the relevant global variable which is being + This function initializes the relevant global variable which is being used to store the information retrieved from INF file. Arguments: @@ -347,7 +347,7 @@ Returns: } else if (strnicmp (*TokenStr, "COMP_TYPE", 9) == 0) { TokenStr++; if (AsciiStringToUint64 (*TokenStr, FALSE, &StringValue) != EFI_SUCCESS) { - Error (NULL, 0, 5001, "Cannot get: \"0x%x\".", *TokenStr); + Error (NULL, 0, 5001, "Cannot get: \"0x%s\".", *TokenStr); return ; } @@ -1970,7 +1970,7 @@ Returns: Fv1BaseAddress = StartAddress1; Fv1EndAddress = Fv1BaseAddress + Size1; - if (Fv1EndAddress != 0x100000000 || Size1 < 0x100000) { + if (Fv1EndAddress != 0x100000000ULL || Size1 < 0x100000) { Error (NULL, 0, 2000, "Invalid parameter", "Error BaseAddress and Size parameters!"); if (Size1 < 0x100000) { Error (NULL, 0, 2000, "Invalid parameter", "The FwVolumeSize must be larger than 1M!"); @@ -2281,11 +2281,7 @@ Returns: // TokenAddress += BaseAddress &~IPF_CACHE_BIT; -#ifdef __GNUC__ - fprintf (DestFile, "%s | %016lX | %s | %s%s\n", Type, TokenAddress, Section, BaseToken, Token); -#else - fprintf (DestFile, "%s | %016I64X | %s | %s%s\n", Type, TokenAddress, Section, BaseToken, Token); -#endif + fprintf (DestFile, "%s | %016llX | %s | %s%s\n", Type, (unsigned long long) TokenAddress, Section, BaseToken, Token); } } @@ -2689,7 +2685,7 @@ Returns: break; case EFI_ABORTED: - Error (NULL, 0, 3000, "Invaild", "Error detected while creating the file image."); + Error (NULL, 0, 3000, "Invalid", "Error detected while creating the file image."); break; case EFI_OUT_OF_RESOURCES: @@ -2697,11 +2693,11 @@ Returns: break; case EFI_VOLUME_CORRUPTED: - Error (NULL, 0, 3000, "Invaild", "No base address was specified."); + Error (NULL, 0, 3000, "Invalid", "No base address was specified."); break; default: - Error (NULL, 0, 3000, "Invaild", "GenVtfImage function returned unknown status %x.",Status ); + Error (NULL, 0, 3000, "Invalid", "GenVtfImage function returned unknown status %x.", (int) Status ); break; } } diff --git a/BaseTools/Source/C/GenVtf/GenVtf.h b/BaseTools/Source/C/GenVtf/GenVtf.h index 25ce1141ba..eab14f3aa6 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.h +++ b/BaseTools/Source/C/GenVtf/GenVtf.h @@ -33,6 +33,9 @@ Abstract: #include #include #include +#ifndef __GNUC__ +#include +#endif #include "assert.h" #include #include "ParseInf.h" diff --git a/BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c b/BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c index 178bec2476..6a25bee957 100644 --- a/BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c +++ b/BaseTools/Source/C/GnuGenBootSector/GnuGenBootSector.c @@ -27,6 +27,9 @@ Abstract: #include #include +#include "ParseInf.h" +#include "EfiUtilityMsgs.h" + // // Utility Name // @@ -293,10 +296,10 @@ PrintUsage ( [-h, --help]\n"); } -INTN +int main ( - INTN argc, - CHAR8 *argv[] + int argc, + char *argv[] ) { CHAR8 *AppName; @@ -393,7 +396,7 @@ main ( return 1; } if (LogLevel > 9) { - Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", LogLevel); + Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel); return 1; } SetPrintLevel (LogLevel); diff --git a/BaseTools/Source/C/Include/Common/BaseTypes.h b/BaseTools/Source/C/Include/Common/BaseTypes.h index 438d949a6b..43721ae469 100644 --- a/BaseTools/Source/C/Include/Common/BaseTypes.h +++ b/BaseTools/Source/C/Include/Common/BaseTypes.h @@ -26,7 +26,7 @@ #include // -// Modifiers to absract standard types to aid in debug of problems +// Modifiers to abstract standard types to aid in debug of problems // #define CONST const #define STATIC static @@ -38,8 +38,8 @@ // #ifndef IN // -// Some other envirnments use this construct, so #ifndef to prevent -// mulitple definition. +// Some other environments use this construct, so #ifndef to prevent +// multiple definition. // #define IN #define OUT @@ -68,13 +68,13 @@ // // Support for variable length argument lists using the ANSI standard. // -// Since we are using the ANSI standard we used the standard nameing and -// did not folow the coding convention +// Since we are using the ANSI standard we used the standard naming and +// did not follow the coding convention // // VA_LIST - typedef for argument list. // VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use. // VA_END (VA_LIST Marker) - Clear Marker -// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from +// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from // the ... list. You must know the size and pass it in this macro. // // example: @@ -136,12 +136,12 @@ #define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field))) /// -/// ALIGN_POINTER - aligns a pointer to the lowest boundry +/// ALIGN_POINTER - aligns a pointer to the lowest boundary /// #define ALIGN_POINTER(p, s) ((VOID *) ((UINTN)(p) + (((s) - ((UINTN) (p))) & ((s) - 1)))) /// -/// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor +/// ALIGN_VARIABLE - aligns a variable up to the next natural boundary for int size of a processor /// #define ALIGN_VARIABLE(Value, Adjustment) \ Adjustment = 0U; \ diff --git a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h index 1e9f6028b4..158e672970 100644 --- a/BaseTools/Source/C/Include/Common/PiFirmwareFile.h +++ b/BaseTools/Source/C/Include/Common/PiFirmwareFile.h @@ -134,6 +134,7 @@ typedef UINT8 EFI_SECTION_TYPE; #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18 #define EFI_SECTION_RAW 0x19 #define EFI_SECTION_PEI_DEPEX 0x1B +#define EFI_SECTION_SMM_DEPEX 0x1C typedef struct { UINT8 Size[3]; diff --git a/BaseTools/Source/C/Include/Common/UefiCapsule.h b/BaseTools/Source/C/Include/Common/UefiCapsule.h index d50492662b..70d87234f7 100644 --- a/BaseTools/Source/C/Include/Common/UefiCapsule.h +++ b/BaseTools/Source/C/Include/Common/UefiCapsule.h @@ -1,7 +1,7 @@ /** @file Defines for the EFI Capsule functionality. - Copyright (c) 2006 - 2008, Intel Corporation All rights reserved. + Copyright (c) 2006 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this @@ -30,5 +30,6 @@ typedef struct { #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000 #define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000 +#define CAPSULE_FLAGS_INITIATE_RESET 0x00040000 #endif // #ifndef _EFI_CAPSULE_H_ diff --git a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h index a127c952d4..f54614abf2 100644 --- a/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h +++ b/BaseTools/Source/C/Include/Common/UefiInternalFormRepresentation.h @@ -839,7 +839,7 @@ typedef struct _EFI_IFR_REF4 { typedef struct _EFI_IFR_RESET_BUTTON { EFI_IFR_OP_HEADER Header; - EFI_IFR_QUESTION_HEADER Question; + EFI_IFR_STATEMENT_HEADER Statement; EFI_DEFAULT_ID DefaultId; } EFI_IFR_RESET_BUTTON; diff --git a/BaseTools/Source/C/Include/Ia32/ProcessorBind.h b/BaseTools/Source/C/Include/Ia32/ProcessorBind.h index 122a0b1178..df778a583e 100644 --- a/BaseTools/Source/C/Include/Ia32/ProcessorBind.h +++ b/BaseTools/Source/C/Include/Ia32/ProcessorBind.h @@ -54,7 +54,7 @@ #pragma warning ( disable : 4057 ) // -// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning +// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning // #pragma warning ( disable : 4127 ) @@ -141,7 +141,7 @@ typedef INT32 INTN; // // Modifier to ensure that all protocol member functions and EFI intrinsics // use the correct C calling convention. All protocol member functions and -// EFI intrinsics are required to modify thier member functions with EFIAPI. +// EFI intrinsics are required to modify their member functions with EFIAPI. // #if _MSC_EXTENSIONS // diff --git a/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h b/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h index 946c524ddb..fb8599333c 100644 --- a/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h +++ b/BaseTools/Source/C/Include/IndustryStandard/Acpi1_0.h @@ -114,6 +114,7 @@ typedef struct { #define EFI_ACPI_1_0_TMR_VAL_EXT (1 << 8) #define EFI_ACPI_1_0_DCK_CAP (1 << 9) +#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x0 // // Firmware ACPI Control Structure // diff --git a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c index 7207a752a1..16b91da177 100644 --- a/BaseTools/Source/C/LzmaCompress/LzmaCompress.c +++ b/BaseTools/Source/C/LzmaCompress/LzmaCompress.c @@ -208,7 +208,7 @@ int main2(int numArgs, const char *args[], char *rs) CFileSeqInStream inStream; CFileOutStream outStream; int res; - int encodeMode; + int encodeMode = 0; Bool modeWasSet = False; const char *inputFile = NULL; const char *outputFile = "file.tmp"; diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile index 271b141a81..a4dc2255e7 100644 --- a/BaseTools/Source/C/Makefiles/header.makefile +++ b/BaseTools/Source/C/Makefiles/header.makefile @@ -25,7 +25,7 @@ endif INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I $(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I $(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) CPPFLAGS = $(INCLUDE) -CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -c -g +CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g .PHONY: all .PHONY: install diff --git a/BaseTools/Source/C/Makefiles/ms.common b/BaseTools/Source/C/Makefiles/ms.common index 2385518c1b..1523ce75ca 100644 --- a/BaseTools/Source/C/Makefiles/ms.common +++ b/BaseTools/Source/C/Makefiles/ms.common @@ -44,6 +44,6 @@ LINKER = $(LD) INC = -I . -I $(SOURCE_PATH)\Include -I $(ARCH_INCLUDE) -I $(SOURCE_PATH)\Common $(INC) -CFLAGS = $(CFLAGS) /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE +CFLAGS = $(CFLAGS) /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /W4 /WX /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE CPPFLAGS = $(CPPFLAGS) /EHsc /nologo /c /Zi /Od /RTC1 /D _DEBUG /MTd /D _CRT_SECURE_NO_DEPRECATE /D _CRT_NONSTDC_NO_DEPRECATE diff --git a/BaseTools/Source/C/Split/Split.c b/BaseTools/Source/C/Split/Split.c index 5ebda0901b..22e1a2be49 100644 --- a/BaseTools/Source/C/Split/Split.c +++ b/BaseTools/Source/C/Split/Split.c @@ -19,6 +19,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #ifdef __GNUC__ #include +#else +#include #endif #include #include "ParseInf.h" @@ -219,7 +221,7 @@ Returns: CHAR8 *OutputDir = NULL; CHAR8 *OutFileName1 = NULL; CHAR8 *OutFileName2 = NULL; - UINT64 SplitValue = -1; + UINT64 SplitValue = (UINT64) -1; FILE *Out1; FILE *Out2; CHAR8 *OutName1 = NULL; diff --git a/BaseTools/Source/C/TianoCompress/TianoCompress.c b/BaseTools/Source/C/TianoCompress/TianoCompress.c index b3ce640fde..ef35f1721d 100644 --- a/BaseTools/Source/C/TianoCompress/TianoCompress.c +++ b/BaseTools/Source/C/TianoCompress/TianoCompress.c @@ -84,7 +84,7 @@ STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL; -static UINTN DebugLevel; +static UINT64 DebugLevel; static BOOLEAN DebugMode; // // functions @@ -180,12 +180,11 @@ Returns: if (mCompSize + 1 + 8 > *DstSize) { *DstSize = mCompSize + 1 + 8; - return EFI_BUFFER_TOO_SMALL; - } else { + return EFI_BUFFER_TOO_SMALL; + } else { *DstSize = mCompSize + 1 + 8; - return EFI_SUCCESS; - } - return EFI_SUCCESS; + return EFI_SUCCESS; + } } STATIC diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp index b24cc725f0..963bd2da42 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -201,7 +201,11 @@ CVfrErrorHandle::PrintMsg ( { CHAR8 *FileName = NULL; UINT32 FileLine; - + + if (strncmp ("Warning", MsgType, strlen ("Warning")) == 0) { + VerboseMsg (ErrorMsg); + return; + } GetFileNameLineNum (LineNum, &FileName, &FileLine); Error (FileName, FileLine, 0x3000, TokName, "\t%s\n", ErrorMsg); } diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index 654daed549..298eb0289b 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -787,11 +787,22 @@ 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; diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h index 3f387666bd..fa671c1b1e 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.h +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.h @@ -254,7 +254,7 @@ public: VOID DecLength (UINT8 Size) { if (mHeader->Length >= Size) { - mHeader -= Size; + mHeader -= Size; } } @@ -358,7 +358,7 @@ public: VOID SetVarStoreInfo (IN EFI_VARSTORE_INFO *Info) { mHeader->VarStoreId = Info->mVarStoreId; - mHeader->VarStoreInfo.VarName = Info->mInfo.mVarName; + mHeader->VarStoreInfo.VarName = Info->mInfo.mVarName; mHeader->VarStoreInfo.VarOffset = Info->mInfo.mVarOffset; } @@ -398,7 +398,8 @@ public: } }; -static CIfrQuestionHeader *gCurrentQuestion = NULL; +static CIfrQuestionHeader *gCurrentQuestion = NULL; +static CIfrObj *gCurrentIfrOpcode = NULL; /* * The definition of CIfrMinMaxStepData @@ -537,6 +538,12 @@ public: } EFI_VFR_RETURN_CODE SetFormId (IN EFI_FORM_ID FormId) { + if (FormId == 0) { + // + // FormId can't be 0. + // + return VFR_RETURN_INVALID_PARAMETER; + } if (CIfrForm::ChekFormIdFree (FormId) == FALSE) { return VFR_RETURN_FORMID_REDEFINED; } @@ -688,7 +695,7 @@ public: ) : CIfrObj (EFI_IFR_DEFAULT_OP, (CHAR8 **)&mDefault), CIfrOpHeader (EFI_IFR_DEFAULT_OP, &mDefault->Header) { mDefault->Type = Type; - mDefault->Value = Value; + mDefault->Value = Value; mDefault->DefaultId = DefaultId; } @@ -722,7 +729,7 @@ private: public: CIfrSubtitle () : CIfrObj (EFI_IFR_SUBTITLE_OP, (CHAR8 **)&mSubtitle), CIfrOpHeader (EFI_IFR_SUBTITLE_OP, &mSubtitle->Header), - CIfrStatementHeader (&mSubtitle->Statement) { + CIfrStatementHeader (&mSubtitle->Statement) { mSubtitle->Flags = 0; } @@ -856,7 +863,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; } @@ -874,11 +881,11 @@ public: CIfrOpHeader (EFI_IFR_CHECKBOX_OP, &mCheckBox->Header), CIfrQuestionHeader (&mCheckBox->Question) { mCheckBox->Flags = 0; - gCurrentQuestion = this; + gCurrentQuestion = this; } ~CIfrCheckBox () { - gCurrentQuestion = NULL; + gCurrentQuestion = NULL; } EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, UINT8 LFlags) { @@ -974,11 +981,13 @@ public: CIfrQuestionHeader (&mNumeric->Question), CIfrMinMaxStepData (&mNumeric->data) { mNumeric->Flags = EFI_IFR_NUMERIC_SIZE_1 | EFI_IFR_DISPLAY_UINT_DEC; - gCurrentQuestion = this; + gCurrentQuestion = this; + gCurrentIfrOpcode = this; } ~CIfrNumeric () { - gCurrentQuestion = NULL; + gCurrentQuestion = NULL; + gCurrentIfrOpcode = NULL; } EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) { @@ -1008,11 +1017,13 @@ public: CIfrQuestionHeader (&mOneOf->Question), CIfrMinMaxStepData (&mOneOf->data) { mOneOf->Flags = 0; - gCurrentQuestion = this; + gCurrentQuestion = this; + gCurrentIfrOpcode = this; } ~CIfrOneOf () { - gCurrentQuestion = NULL; + gCurrentQuestion = NULL; + gCurrentIfrOpcode = NULL; } EFI_VFR_RETURN_CODE SetFlags (IN UINT8 HFlags, IN UINT8 LFlags) { diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index f91a2c3cea..c01f16e5d5 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -1078,7 +1078,7 @@ vfrStatementRules : vfrStatementDefault : << BOOLEAN IsExp = FALSE; - EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue; + EFI_IFR_TYPE_VALUE Val = gZeroEfiIfrTypeValue; CIfrDefault DObj; EFI_DEFAULT_ID DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD; CHAR8 *VarStoreName = NULL; @@ -1087,9 +1087,73 @@ 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 (gCurrentIfrOpcode != NULL && gCurrentIfrOpcode->GetObjBinAddr() != NULL) { + EFI_IFR_OP_HEADER *TempOpCode; + TempOpCode = (EFI_IFR_OP_HEADER *) gCurrentIfrOpcode->GetObjBinAddr(); + switch (TempOpCode->OpCode) { + case EFI_IFR_NUMERIC_OP: + EFI_IFR_NUMERIC *TempNumricCode; + TempNumricCode = (EFI_IFR_NUMERIC *) TempOpCode; + switch (_GET_CURRQEST_DATATYPE()) { + case EFI_IFR_TYPE_NUM_SIZE_64: + if (Val.u64 < TempNumricCode->data.u64.MinValue || Val.u64 > TempNumricCode->data.u64.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + if (Val.u32 < TempNumricCode->data.u32.MinValue || Val.u32 > TempNumricCode->data.u32.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + if (Val.u16 < TempNumricCode->data.u16.MinValue || Val.u16 > TempNumricCode->data.u16.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + if (Val.u8 < TempNumricCode->data.u8.MinValue || Val.u8 > TempNumricCode->data.u8.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "Numeric default value must be between MinValue and MaxValue."); + } + break; + } + break; + case EFI_IFR_ONE_OF_OP: + EFI_IFR_ONE_OF *TempOneOfCode; + TempOneOfCode = (EFI_IFR_ONE_OF *) TempOpCode; + if (TempOneOfCode->data.u64.MinValue != 0 || TempOneOfCode->data.u64.MaxValue != 0 || TempOneOfCode->data.u64.Step != 0) { + //OneOf MinMaxStep Data is set, Val value will be checked for MinMaxStep. + switch (_GET_CURRQEST_DATATYPE()) { + case EFI_IFR_TYPE_NUM_SIZE_64: + if (Val.u64 < TempOneOfCode->data.u64.MinValue || Val.u64 > TempOneOfCode->data.u64.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_32: + if (Val.u32 < TempOneOfCode->data.u32.MinValue || Val.u32 > TempOneOfCode->data.u32.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_16: + if (Val.u16 < TempOneOfCode->data.u16.MinValue || Val.u16 > TempOneOfCode->data.u16.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue."); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_8: + if (Val.u8 < TempOneOfCode->data.u8.MinValue || Val.u8 > TempOneOfCode->data.u8.MaxValue) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, D->getLine(), "OneOf default value must be between MinValue and MaxValue."); + } + break; + } + } + break; + } + } + DObj.SetType (_GET_CURRQEST_DATATYPE()); + DObj.SetValue(Val); + >> ) { DefaultStore "=" SN:StringIdentifier "," << _PCATCH(mCVfrDefaultStore.GetDefaultId (SN->getText(), &DefaultId), SN); DObj.SetDefaultId (DefaultId); >> @@ -1167,7 +1231,7 @@ flagsField : vfrStatementValue : << CIfrValue VObj; >> V:Value << VObj.SetLineNo(V->getLine()); >> - "=" vfrStatementExpression[0] + "=" vfrStatementExpression[0] << {CIfrEnd EndObj; EndObj.SetLineNo(V->getLine());} >> ; vfrStatementSubTitle : @@ -1588,15 +1652,30 @@ vfrStatementDate : ; minMaxDateStepDefault[EFI_HII_DATE & D, UINT8 KeyValue] : - Minimum "=" Number "," - Maximum "=" Number "," + Minimum "=" MinN:Number "," + Maximum "=" MaxN:Number "," { "step" "=" Number "," } { "default" "=" N:Number "," << switch (KeyValue) { - case 0: D.Year = _STOU16(N->getText()); break; - case 1: D.Month = _STOU8(N->getText()); break; - case 2: D.Day = _STOU8(N->getText()); break; + case 0: + D.Year = _STOU16(N->getText()); + if (D.Year < _STOU16 (MinN->getText()) || D.Year > _STOU16 (MaxN->getText())) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Year default value must be between Min year and Max year."); + } + break; + case 1: + D.Month = _STOU8(N->getText()); + if (D.Month < 1 || D.Month > 12) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Month default value must be between 1 and 12."); + } + break; + case 2: + D.Day = _STOU8(N->getText()); + if (D.Day < 1 || D.Day > 31) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Day default value must be between 1 and 31."); + } + break; } >> } @@ -1642,10 +1721,30 @@ vfrSetMinMaxStep[CIfrMinMaxStepData & MMSDObj] : Maximum "=" A:Number "," << switch (_GET_CURRQEST_DATATYPE ()) { - case EFI_IFR_TYPE_NUM_SIZE_64 : MaxU8 = _STOU64(A->getText()); break; - case EFI_IFR_TYPE_NUM_SIZE_32 : MaxU4 = _STOU32(A->getText()); break; - case EFI_IFR_TYPE_NUM_SIZE_16 : MaxU2 = _STOU16(A->getText()); break; - case EFI_IFR_TYPE_NUM_SIZE_8 : MaxU1 = _STOU8(A->getText()); break; + case EFI_IFR_TYPE_NUM_SIZE_64 : + MaxU8 = _STOU64(A->getText()); + if (MaxU8 < MinU8) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum"); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_32 : + MaxU4 = _STOU32(A->getText()); + if (MaxU4 < MinU4) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum"); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_16 : + MaxU2 = _STOU16(A->getText()); + if (MaxU2 < MinU2) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum"); + } + break; + case EFI_IFR_TYPE_NUM_SIZE_8 : + MaxU1 = _STOU8(A->getText()); + if (MaxU1 < MinU1) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, A->getLine(), "Maximum can't be less than Minimum"); + } + break; } >> { @@ -1894,9 +1993,24 @@ 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 2: T.Second = _STOU8(N->getText()); break; + case 0: + T.Hour = _STOU8(N->getText()); + if (T.Hour > 23) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Hour default value must be between 0 and 23."); + } + break; + case 1: + T.Minute = _STOU8(N->getText()); + if (T.Minute > 59) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Minute default value must be between 0 and 59."); + } + break; + case 2: + T.Second = _STOU8(N->getText()); + if (T.Second > 59) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, N->getLine(), "Second default value must be between 0 and 59."); + } + break; } >> } @@ -3090,7 +3204,6 @@ public: VOID _STRCAT (IN OUT CHAR8 **, IN CHAR8 *); - VOID _CRGUID (EFI_GUID *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *, CHAR8 *); VOID _DeclareDefaultLinearVarStore (IN UINT32); VOID _DeclareStandardDefaultStorage (IN UINT32); VOID _DeclareDefaultFrameworkVarStore (IN UINT32); @@ -3490,35 +3603,6 @@ EfiVfrParser::_STRCAT ( *Dest = NewStr; } -VOID -EfiVfrParser::_CRGUID ( - IN EFI_GUID *Guid, - IN CHAR8 *G1, - IN CHAR8 *G2, - IN CHAR8 *G3, - IN CHAR8 *G4, - IN CHAR8 *G5, - IN CHAR8 *G6, - IN CHAR8 *G7, - IN CHAR8 *G8, - IN CHAR8 *G9, - IN CHAR8 *G10, - IN CHAR8 *G11 - ) -{ - Guid->Data1 = _STOU32 (G1); - Guid->Data2 = _STOU16 (G2); - Guid->Data3 = _STOU16 (G3); - Guid->Data4[0] = _STOU8(G4); - Guid->Data4[1] = _STOU8(G5); - Guid->Data4[2] = _STOU8(G6); - Guid->Data4[3] = _STOU8(G7); - Guid->Data4[4] = _STOU8(G8); - Guid->Data4[5] = _STOU8(G9); - Guid->Data4[6] = _STOU8(G10); - Guid->Data4[7] = _STOU8(G11); -} - // // framework vfr to default declare varstore for each structure // diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index e59fbb7743..f047b2c471 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -870,7 +870,7 @@ CVfrVarDataTypeDB::Pack ( SVfrPackStackNode *pNode = NULL; if (mPackStack == NULL) { - gCVfrErrorHandle.PrintMsg (LineNum, "", "Warning", "#pragma pack(pop...) : more pops than pushes"); + gCVfrErrorHandle.PrintMsg (LineNum, "", "Error", "#pragma pack(pop...) : more pops than pushes"); } for (pNode = mPackStack; pNode != NULL; pNode = pNode->mNext) { @@ -884,7 +884,7 @@ CVfrVarDataTypeDB::Pack ( 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'"); + gCVfrErrorHandle.PrintMsg (LineNum, "", "Error", "expected pragma parameter to be '1', '2', '4', '8', or '16'"); } else { mPackAlign = PackAlign; } diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h index 76d7873e54..cb15f280d0 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.h @@ -2,7 +2,7 @@ Vfr common library functions. -Copyright (c) 2004 - 2008, Intel Corporation +Copyright (c) 2004 - 2009, Intel Corporation All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -421,7 +421,4 @@ public: UINT8 GetRuleId (IN CHAR8 *); }; -#define MIN(v1, v2) (((v1) < (v2)) ? (v1) : (v2)) -#define MAX(v1, v2) (((v1) > (v2)) ? (v1) : (v2)) - #endif diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c index 1df182e4d6..b7237b08e8 100644 --- a/BaseTools/Source/C/VolInfo/VolInfo.c +++ b/BaseTools/Source/C/VolInfo/VolInfo.c @@ -164,7 +164,7 @@ Returns: EFI_FIRMWARE_VOLUME_HEADER *FvImage; UINT32 FvSize; EFI_STATUS Status; - UINT32 Offset; + int Offset; BOOLEAN ErasePolarity; SetUtilityName (UTILITY_NAME); @@ -622,8 +622,8 @@ Returns: // // Print FV header information // - printf ("Signature: %s (%X)\n", (char *) Signature, VolumeHeader.Signature); - printf ("Attributes: %X\n", VolumeHeader.Attributes); + printf ("Signature: %s (%X)\n", (char *) Signature, (unsigned) VolumeHeader.Signature); + printf ("Attributes: %X\n", (unsigned) VolumeHeader.Attributes); if (VolumeHeader.Attributes & EFI_FVB2_READ_DISABLED_CAP) { printf (" EFI_FVB2_READ_DISABLED_CAP\n"); @@ -907,8 +907,8 @@ Returns: BytesRead += sizeof (EFI_FV_BLOCK_MAP_ENTRY); if (BlockMap.NumBlocks != 0) { - printf ("Number of Blocks: 0x%08X\n", BlockMap.NumBlocks); - printf ("Block Length: 0x%08X\n", BlockMap.Length); + printf ("Number of Blocks: 0x%08X\n", (unsigned) BlockMap.NumBlocks); + printf ("Block Length: 0x%08X\n", (unsigned) BlockMap.Length); Size += BlockMap.NumBlocks * BlockMap.Length; } @@ -924,7 +924,7 @@ Returns: return EFI_ABORTED; } - printf ("Total Volume Size: 0x%08X\n", Size); + printf ("Total Volume Size: 0x%08X\n", (unsigned) Size); *FvSize = Size; @@ -998,7 +998,7 @@ Returns: // FileLength = GetLength (FileHeader->Size); printf ("File Offset: 0x%08X\n", (unsigned) ((UINTN) FileHeader - (UINTN) FvImage)); - printf ("File Length: 0x%08X\n", FileLength); + printf ("File Length: 0x%08X\n", (unsigned) FileLength); printf ("File Attributes: 0x%02X\n", FileHeader->Attributes); printf ("File State: 0x%02X\n", FileHeader->State); @@ -1242,7 +1242,7 @@ Returns: SectionName = SectionNameToStr (Type); printf ("------------------------------------------------------------\n"); - printf (" Type: %s\n Size: 0x%08X\n", SectionName, SectionLength); + printf (" Type: %s\n Size: 0x%08X\n", SectionName, (unsigned) SectionLength); free (SectionName); switch (Type) { @@ -1288,7 +1288,7 @@ Returns: CompressedLength = SectionLength - sizeof (EFI_COMPRESSION_SECTION); UncompressedLength = ((EFI_COMPRESSION_SECTION *) Ptr)->UncompressedLength; CompressionType = ((EFI_COMPRESSION_SECTION *) Ptr)->CompressionType; - printf (" Uncompressed Length: 0x%08X\n", UncompressedLength); + printf (" Uncompressed Length: 0x%08X\n", (unsigned) UncompressedLength); if (CompressionType == EFI_NOT_COMPRESSED) { printf (" Compression Type: EFI_NOT_COMPRESSED\n"); @@ -1342,7 +1342,7 @@ Returns: return EFI_SECTION_ERROR; } } else { - Error (NULL, 0, 0003, "unrecognized compression type", "type 0x%X", (UINT32) CompressionType); + Error (NULL, 0, 0003, "unrecognized compression type", "type 0x%X", CompressionType); return EFI_SECTION_ERROR; } @@ -1365,8 +1365,8 @@ Returns: printf (" SectionDefinitionGuid: "); PrintGuid (&((EFI_GUID_DEFINED_SECTION *) Ptr)->SectionDefinitionGuid); printf ("\n"); - printf (" DataOffset: 0x%04X\n", ((EFI_GUID_DEFINED_SECTION *) Ptr)->DataOffset); - printf (" Attributes: 0x%04X\n", ((EFI_GUID_DEFINED_SECTION *) Ptr)->Attributes); + printf (" DataOffset: 0x%04X\n", (unsigned) ((EFI_GUID_DEFINED_SECTION *) Ptr)->DataOffset); + printf (" Attributes: 0x%04X\n", (unsigned) ((EFI_GUID_DEFINED_SECTION *) Ptr)->Attributes); ExtractionTool = LookupGuidedSectionToolPath ( @@ -1465,7 +1465,7 @@ Returns: // // Unknown section, return error // - Error (NULL, 0, 0003, "unrecognized section type found", "section type = 0x%X", (UINT32) Type); + Error (NULL, 0, 0003, "unrecognized section type found", "section type = 0x%X", Type); return EFI_SECTION_ERROR; } @@ -1588,7 +1588,7 @@ Returns: break; default: - printf ("Unrecognized byte in depex: 0x%X\n", (UINT32) *Ptr); + printf ("Unrecognized byte in depex: 0x%X\n", *Ptr); return EFI_SUCCESS; } } @@ -1732,11 +1732,14 @@ LoadGuidedSectionToolsTxt ( { CHAR8* PeerFilename; CHAR8* Places[] = { - FirmwareVolumeFilename, - //mUtilityFilename, + NULL, + //NULL, }; UINTN Index; + Places[0] = FirmwareVolumeFilename; + //Places[1] = mUtilityFilename; + mParsedGuidedSectionTools = NULL; for (Index = 0; Index < (sizeof(Places)/sizeof(Places[0])); Index++) { diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 028c4e34e3..647e1d0052 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1061,12 +1061,45 @@ class PlatformAutoGen(AutoGen): # def _ExpandBuildOption(self, Options): BuildOptions = {} + FamilyMatch = False + FamilyIsNull = True for Key in Options: Family = Key[0] Target, Tag, Arch, Tool, Attr = Key[1].split("_") # if tool chain family doesn't match, skip it - if Family and Tool in self.ToolDefinition and Family != self.ToolDefinition[Tool]["FAMILY"]: + if Tool in self.ToolDefinition and Family != "": + FamilyIsNull = False + if self.ToolDefinition[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "": + if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]: + continue + elif Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]: + continue + FamilyMatch = True + # expand any wildcard + if Target == "*" or Target == self.BuildTarget: + if Tag == "*" or Tag == self.ToolChain: + if Arch == "*" or Arch == self.Arch: + if Tool not in BuildOptions: + BuildOptions[Tool] = {} + if Attr != "FLAGS" or Attr not in BuildOptions[Tool]: + BuildOptions[Tool][Attr] = Options[Key] + else: + # append options for the same tool + BuildOptions[Tool][Attr] += " " + Options[Key] + # Build Option Family has been checked, which need't to be checked again for family. + if FamilyMatch or FamilyIsNull: + return BuildOptions + + for Key in Options: + Family = Key[0] + Target, Tag, Arch, Tool, Attr = Key[1].split("_") + # if tool chain family doesn't match, skip it + if Tool not in self.ToolDefinition or Family =="": continue + # option has been added before + if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]: + continue + # expand any wildcard if Target == "*" or Target == self.BuildTarget: if Tag == "*" or Tag == self.ToolChain: diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index f689a8692d..c5d8991e07 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -1308,8 +1308,14 @@ ${END}\t@cd $(BUILD_DIR)\n if PlatformInfo.FdfFile != None and PlatformInfo.FdfFile != "": FdfFileList = [PlatformInfo.FdfFile] # macros passed to GenFds + # MacroList.append('"%s=%s"' % ("WORKSPACE", GlobalData.gWorkspace)) + MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource)) + MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource)) for MacroName in GlobalData.gGlobalDefines: - MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName])) + if GlobalData.gGlobalDefines[MacroName] != "": + MacroList.append('"%s=%s"' % (MacroName, GlobalData.gGlobalDefines[MacroName])) + else: + MacroList.append('"%s"' % MacroName) else: FdfFileList = [] diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index e82ad3a10b..0f644445dc 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -171,9 +171,15 @@ def CreateHFileContent(BaseName, UniObjectClass): if Name != None: Line = '' if Referenced == True: - Line = DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + if (ValueStartPtr - len(DEFINE_STR + Name)) <= 0: + Line = DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) + else: + Line = DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) else: - Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED + if (ValueStartPtr - len(DEFINE_STR + Name)) <= 0: + Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED + else: + Line = COMMENT_DEFINE_STR + ' ' + Name + ' ' * (ValueStartPtr - len(DEFINE_STR + Name)) + DecToHexStr(Token, 4) + COMMENT_NOT_REFERENCED Str = WriteLine(Str, Line) Str = WriteLine(Str, '') diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py index ddccf6507d..50b6cc5bce 100644 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ b/BaseTools/Source/Python/Common/DscClassObject.py @@ -385,10 +385,11 @@ class Dsc(DscObject): for IncludeFile in IncludeFiles: if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper(): Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARIES, '', IncludeFile[2]) - for NewItem in open(Filename, 'r').readlines(): - if CleanString(NewItem) == '': - continue - MergeArches(Libraries, NewItem, Arch) + if os.path.exists(Filename): + for NewItem in open(Filename, 'r').readlines(): + if CleanString(NewItem) == '': + continue + MergeArches(Libraries, NewItem, Arch) for Record in RecordSet: if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper(): diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py index 59006fa5c5..5099ed611c 100644 --- a/BaseTools/Source/Python/Common/FdfParserLite.py +++ b/BaseTools/Source/Python/Common/FdfParserLite.py @@ -1599,7 +1599,7 @@ class FdfParser(object): if not self.__GetNextWord(): return True - if not self.__Token in ("SET", "FV", "FILE", "DATA"): + if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE"): self.__UndoToken() RegionObj.PcdOffset = self.__GetNextPcdName() self.Profile.PcdDict[RegionObj.PcdOffset] = RegionObj.Offset + long(Fd.BaseAddress, 0) @@ -1620,10 +1620,14 @@ class FdfParser(object): if not self.__GetNextWord(): return True - if self.__Token == "FV": + elif self.__Token == "FV": self.__UndoToken() self.__GetRegionFvType( RegionObj) + elif self.__Token == "CAPSULE": + self.__UndoToken() + self.__GetRegionCapType( RegionObj) + elif self.__Token == "FILE": self.__UndoToken() self.__GetRegionFileType( RegionObj) @@ -1664,7 +1668,38 @@ class FdfParser(object): raise Warning("expected FV name At Line ", self.FileName, self.CurrentLineNumber) RegionObj.RegionDataList.append(self.__Token) - + + ## __GetRegionCapType() method + # + # Get region capsule data for region + # + # @param self The object pointer + # @param RegionObj for whom region data is got + # + def __GetRegionCapType(self, RegionObj): + + if not self.__IsKeyword("CAPSULE"): + raise Warning("expected Keyword 'CAPSULE' at line", self.FileName, self.CurrentLineNumber) + + if not self.__IsToken("="): + raise Warning("expected '=' at line", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken(): + raise Warning("expected CAPSULE name at line", self.FileName, self.CurrentLineNumber) + + RegionObj.RegionType = "CAPSULE" + RegionObj.RegionDataList.append(self.__Token) + + while self.__IsKeyword("CAPSULE"): + + if not self.__IsToken("="): + raise Warning("expected '=' at line", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken(): + raise Warning("expected CAPSULE name at line", self.FileName, self.CurrentLineNumber) + + RegionObj.RegionDataList.append(self.__Token) + ## __GetRegionFileType() method # # Get region file data for region @@ -2713,7 +2748,7 @@ class FdfParser(object): Arch = self.__SkippedChars.rstrip(".") if Arch.upper() not in ("IA32", "X64", "IPF", "EBC", "ARM", "COMMON"): - raise Warning("Unknown Arch At line ", self.FileName, self.CurrentLineNumber) + raise Warning("Unknown Arch '%s'" % Arch, self.FileName, self.CurrentLineNumber) ModuleType = self.__GetModuleType() @@ -2763,7 +2798,7 @@ class FdfParser(object): "DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \ "UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \ "SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \ - "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION"): + "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_DRIVER", "SMM_CORE"): raise Warning("Unknown Module type At line ", self.FileName, self.CurrentLineNumber) return self.__Token @@ -2803,11 +2838,11 @@ class FdfParser(object): raise Warning("expected FILE At Line ", self.FileName, self.CurrentLineNumber) if not self.__GetNextWord(): - raise Warning("expected FV type At Line ", self.FileName, self.CurrentLineNumber) + raise Warning("expected FFS type At Line ", self.FileName, self.CurrentLineNumber) Type = self.__Token.strip().upper() if Type not in ("RAW", "FREEFORM", "SEC", "PEI_CORE", "PEIM",\ - "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE"): + "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM_DXE_COMBO", "SMM", "SMM_CORE"): raise Warning("Unknown FV type At line ", self.FileName, self.CurrentLineNumber) if not self.__IsToken("="): diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 14f6550f29..2c1041c55b 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -418,6 +418,14 @@ def RealPath(File, Dir='', OverrideDir=''): return NewFile def RealPath2(File, Dir='', OverrideDir=''): + if OverrideDir: + NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))] + if NewFile: + if OverrideDir[-1] == os.path.sep: + return NewFile[len(OverrideDir):], NewFile[0:len(OverrideDir)] + else: + return NewFile[len(OverrideDir)+1:], NewFile[0:len(OverrideDir)] + NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, File))] if NewFile: if Dir: @@ -428,10 +436,6 @@ def RealPath2(File, Dir='', OverrideDir=''): else: return NewFile, '' - if OverrideDir: - NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(OverrideDir, File))] - if NewFile: - return NewFile[len(OverrideDir)+1:], NewFile[0:len(OverrideDir)] return None, None ## Check if gvien file exists or not diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py index 4767645d05..ea9d0b343c 100644 --- a/BaseTools/Source/Python/Ecc/Ecc.py +++ b/BaseTools/Source/Python/Ecc/Ecc.py @@ -29,6 +29,7 @@ from Common.FdfClassObject import Fdf from Common.String import NormPath from Common import BuildToolError import c +import re, string from Exception import * ## Ecc @@ -51,29 +52,29 @@ class Ecc(object): self.IsInit = True self.ScanSourceCode = True self.ScanMetaData = True - + # Parse the options and args self.ParseOption() # Generate checkpoints list EccGlobalData.gConfig = Configuration(self.ConfigFile) - + # Generate exception list EccGlobalData.gException = ExceptionCheck(self.ExceptionFile) - + # Init Ecc database EccGlobalData.gDb = Database.Database(Database.DATABASE_PATH) EccGlobalData.gDb.InitDatabase(self.IsInit) - + # Build ECC database self.BuildDatabase() - + # Start to check self.Check() - + # Show report self.GenReport() - + # Close Database EccGlobalData.gDb.Close() @@ -94,7 +95,7 @@ class Ecc(object): # Clean report table EccGlobalData.gDb.TblReport.Drop() EccGlobalData.gDb.TblReport.Create() - + # Build database if self.IsInit: if self.ScanSourceCode: @@ -103,9 +104,9 @@ class Ecc(object): if self.ScanMetaData: EdkLogger.quiet("Building database for source code done!") self.BuildMetaDataFileDatabase() - + EccGlobalData.gIdentifierTableList = GetTableList((MODEL_FILE_C, MODEL_FILE_H), 'Identifier', EccGlobalData.gDb) - + ## BuildMetaDataFileDatabase # # Build the database for meta data files @@ -115,10 +116,11 @@ class Ecc(object): Op = open(EccGlobalData.gConfig.MetaDataFileCheckPathOfGenerateFileList, 'w+') #SkipDirs = Read from config file SkipDirs = EccGlobalData.gConfig.SkipDirList + SkipDirString = string.join(SkipDirs, '|') + p = re.compile(r'.*[\\/](?:%s)[\\/]?.*' % SkipDirString) for Root, Dirs, Files in os.walk(EccGlobalData.gTarget): - for Dir in Dirs: - if Dir.upper() in SkipDirs: - Dirs.remove(Dir) + if p.match(Root.upper()): + continue for Dir in Dirs: Dirname = os.path.join(Root, Dir) @@ -152,15 +154,15 @@ class Ecc(object): Filename = os.path.normpath(os.path.join(Root, File)) EdkLogger.quiet("Parsing %s" % Filename) Op.write("%s\r" % Filename) - Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) + Fdf(Filename, True, EccGlobalData.gWorkspace, EccGlobalData.gDb) continue Op.close() - + # Commit to database EccGlobalData.gDb.Conn.commit() - + EdkLogger.quiet("Building database for meta data files done!") - + ## # # Check each checkpoint @@ -170,7 +172,7 @@ class Ecc(object): EccCheck = Check() EccCheck.Check() EdkLogger.quiet("Checking done!") - + ## # # Generate the scan report @@ -179,7 +181,7 @@ class Ecc(object): EdkLogger.quiet("Generating report ...") EccGlobalData.gDb.TblReport.ToCSV(self.ReportFile) EdkLogger.quiet("Generating report done!") - + def GetRealPathCase(self, path): TmpPath = path.rstrip(os.sep) PathParts = TmpPath.split(os.sep) @@ -193,7 +195,7 @@ class Ecc(object): for Dir in Dirs: if Dir.upper() == PathParts[0].upper(): return Dir - + if PathParts[0].strip().endswith(':'): PathParts[0] = PathParts[0].upper() ParentDir = PathParts[0] @@ -201,7 +203,7 @@ class Ecc(object): if PathParts[0] == '': RealPath = os.sep ParentDir = os.sep - + PathParts.remove(PathParts[0]) # need to remove the parent for Part in PathParts: Dirs = os.listdir(ParentDir + os.sep) @@ -212,9 +214,9 @@ class Ecc(object): break ParentDir += os.sep ParentDir += Dir - + return RealPath - + ## ParseOption # # Parse options @@ -222,10 +224,10 @@ class Ecc(object): def ParseOption(self): EdkLogger.quiet("Loading ECC configuration ... done") (Options, Target) = self.EccOptionParser() - + # Check workspace envirnoment if "WORKSPACE" not in os.environ: - EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", + EdkLogger.error("ECC", BuildToolError.ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="WORKSPACE") else: EccGlobalData.gWorkspace = os.path.normpath(os.getenv("WORKSPACE")) @@ -234,7 +236,7 @@ class Ecc(object): os.environ["WORKSPACE"] = EccGlobalData.gWorkspace # Set log level self.SetLogLevel(Options) - + # Set other options if Options.ConfigFile != None: self.ConfigFile = Options.ConfigFile @@ -258,12 +260,12 @@ class Ecc(object): self.ScanSourceCode = False if Options.sourcecode != None: self.ScanMetaData = False - + ## SetLogLevel # # Set current log level of the tool based on args # - # @param Option: The option list including log level setting + # @param Option: The option list including log level setting # def SetLogLevel(self, Option): if Option.verbose != None: @@ -295,19 +297,19 @@ class Ecc(object): Parser.add_option("-m", "--metadata", action="store_true", type=None, help="Only scan meta-data files information if this option is specified.") Parser.add_option("-s", "--sourcecode", action="store_true", type=None, help="Only scan source code files information if this option is specified.") Parser.add_option("-k", "--keepdatabase", action="store_true", type=None, help="The existing Ecc database will not be cleaned except report information if this option is specified.") - Parser.add_option("-l", "--log filename", action="store", dest="LogFile", help="""If specified, the tool should emit the changes that - were made by the tool after printing the result message. - If filename, the emit to the file, otherwise emit to - standard output. If no modifications were made, then do not + Parser.add_option("-l", "--log filename", action="store", dest="LogFile", help="""If specified, the tool should emit the changes that + were made by the tool after printing the result message. + If filename, the emit to the file, otherwise emit to + standard output. If no modifications were made, then do not create a log file, or output a log message.""") Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.") Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed, "\ "including library instances selected, final dependency expression, "\ "and warning messages, etc.") Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.") - + (Opt, Args)=Parser.parse_args() - + return (Opt, Args) ## diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index 7f17fcda68..961b88a458 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -21,6 +21,7 @@ import os import subprocess import StringIO from Common.Misc import SaveFileOnChange +from GenFds import GenFds T_CHAR_LF = '\n' @@ -39,17 +40,26 @@ class Capsule (CapsuleClassObject) : self.BlockSize = None # For GenFv self.BlockNum = None + self.CapsuleName = None ## Generate capsule # # @param self The object pointer + # @retval string Generated Capsule file path # def GenCapsule(self): + if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys(): + return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] + + GenFdsGlobalVariable.InfLogger( "\nGenerate %s Capsule" %self.UiCapsuleName) CapInfFile = self.GenCapInf() CapInfFile.writelines("[files]" + T_CHAR_LF) - + CapFileList = [] for CapsuleDataObj in self.CapsuleDataList : + CapsuleDataObj.CapsuleName = self.CapsuleName FileName = CapsuleDataObj.GenCapsuleSubItem() + CapsuleDataObj.CapsuleName = None + CapFileList.append(FileName) CapInfFile.writelines("EFI_FILE_NAME = " + \ FileName + \ T_CHAR_LF) @@ -63,9 +73,14 @@ class Capsule (CapsuleClassObject) : GenFdsGlobalVariable.GenerateFirmwareVolume( CapOutputFile, [self.CapInfFileName], - Capsule=True + Capsule=True, + FfsList=CapFileList ) + + GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s Capsule Successfully" %self.UiCapsuleName) GenFdsGlobalVariable.SharpCounter = 0 + GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] = CapOutputFile + return CapOutputFile ## Generate inf file for capsule # diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index db29737963..0940094de0 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -45,6 +45,7 @@ class CapsuleFfs (CapsuleData): # def __init_(self) : self.Ffs = None + self.FvName = None ## generate FFS capsule data # @@ -64,7 +65,9 @@ class CapsuleFv (CapsuleData): # @param self The object pointer # def __init__(self) : + self.Ffs = None self.FvName = None + self.CapsuleName = None ## generate FV capsule data # @@ -76,9 +79,11 @@ class CapsuleFv (CapsuleData): if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper()) FdBuffer = StringIO.StringIO('') + FvObj.CapsuleName = self.CapsuleName FvFile = FvObj.AddToBuffer(FdBuffer) + FvObj.CapsuleName = None + FdBuffer.close() return FvFile - else: FvFile = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvName) return FvFile diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py index 99baa6abe5..370008c918 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -26,6 +26,7 @@ from CommonDataClass.FdfClass import FDClassObject from Common import EdkLogger from Common.BuildToolError import * from Common.Misc import SaveFileOnChange +from GenFds import GenFds ## generate FD # @@ -42,11 +43,12 @@ class FD(FDClassObject): # # Generate FD # - # @param self The object pointer - # @param FvBinDict dictionary contains generated FV name and its file name # @retval string Generated FD file name # - def GenFd (self, FvBinDict): + def GenFd (self): + if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): + return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] + # # Print Information # @@ -80,7 +82,7 @@ class FD(FDClassObject): PadRegion = Region.Region() PadRegion.Offset = PreviousRegionStart + PreviousRegionSize PadRegion.Size = RegionObj.Offset - PadRegion.Offset - PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict, self.DefineVarDict) + PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict) PreviousRegionStart = RegionObj.Offset PreviousRegionSize = RegionObj.Size # @@ -89,23 +91,19 @@ class FD(FDClassObject): if PreviousRegionSize > self.Size: EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s size too small' % self.FdUiName) GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function') - RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict, self.DefineVarDict) + RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.DefineVarDict) # # Create a empty Fd file # GenFdsGlobalVariable.VerboseLogger ('Create an empty Fd file') - FdFileName = os.path.join(GenFdsGlobalVariable.FvDir, - self.FdUiName + '.fd') - #FdFile = open(FdFileName, 'wb') - + FdFileName = os.path.join(GenFdsGlobalVariable.FvDir,self.FdUiName + '.fd') # # Write the buffer contents to Fd file # GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to Fd file') SaveFileOnChange(FdFileName, FdBuffer.getvalue()) - #FdFile.write(FdBuffer.getvalue()); - #FdFile.close(); FdBuffer.close(); + GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] = FdFileName return FdFileName ## generate VTF diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 0bf8f5514b..07de92610a 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -173,7 +173,7 @@ class FileProfile : self.FdDict = {} self.FvDict = {} - self.CapsuleList = [] + self.CapsuleDict = {} self.VtfList = [] self.RuleDict = {} self.OptRomDict = {} @@ -1622,7 +1622,7 @@ class FdfParser: if not self.__GetNextWord(): return True - if not self.__Token in ("SET", "FV", "FILE", "DATA"): + if not self.__Token in ("SET", "FV", "FILE", "DATA", "CAPSULE"): self.__UndoToken() RegionObj.PcdOffset = self.__GetNextPcdName() self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(Fd.BaseAddress, 0)) @@ -1639,10 +1639,14 @@ class FdfParser: if not self.__GetNextWord(): return True - if self.__Token == "FV": + elif self.__Token == "FV": self.__UndoToken() self.__GetRegionFvType( RegionObj) + elif self.__Token == "CAPSULE": + self.__UndoToken() + self.__GetRegionCapType( RegionObj) + elif self.__Token == "FILE": self.__UndoToken() self.__GetRegionFileType( RegionObj) @@ -1684,6 +1688,37 @@ class FdfParser: RegionObj.RegionDataList.append(self.__Token) + ## __GetRegionCapType() method + # + # Get region capsule data for region + # + # @param self The object pointer + # @param RegionObj for whom region data is got + # + def __GetRegionCapType(self, RegionObj): + + if not self.__IsKeyword("CAPSULE"): + raise Warning("expected Keyword 'CAPSULE'", self.FileName, self.CurrentLineNumber) + + if not self.__IsToken("="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken(): + raise Warning("expected CAPSULE name", self.FileName, self.CurrentLineNumber) + + RegionObj.RegionType = "CAPSULE" + RegionObj.RegionDataList.append(self.__Token) + + while self.__IsKeyword("CAPSULE"): + + if not self.__IsToken("="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + + if not self.__GetNextToken(): + raise Warning("expected CAPSULE name", self.FileName, self.CurrentLineNumber) + + RegionObj.RegionDataList.append(self.__Token) + ## __GetRegionFileType() method # # Get region file data for region @@ -2624,7 +2659,7 @@ class FdfParser: CapsuleObj.CreateFile = self.__Token self.__GetCapsuleStatements(CapsuleObj) - self.Profile.CapsuleList.append(CapsuleObj) + self.Profile.CapsuleDict[CapsuleObj.UiCapsuleName] = CapsuleObj return True ## __GetCapsuleStatements() method @@ -2638,10 +2673,9 @@ class FdfParser: self.__GetCapsuleTokens(Obj) self.__GetDefineStatements(Obj) self.__GetSetStatements(Obj) - self.__GetCapsuleData(Obj) - ## __GetCapsuleStatements() method + ## __GetCapsuleTokens() method # # Get token statements for capsule # @@ -3558,51 +3592,53 @@ class FdfParser: def __GetOptRomOverrides(self, Obj): if self.__IsToken('{'): Overrides = OptionRom.OverrideAttribs() - if self.__IsKeyword( "PCI_VENDOR_ID"): - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - if not self.__GetNextHexNumber(): - raise Warning("expected Hex vendor id", self.FileName, self.CurrentLineNumber) - Overrides.PciVendorId = self.__Token - - if self.__IsKeyword( "PCI_CLASS_CODE"): - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - if not self.__GetNextHexNumber(): - raise Warning("expected Hex class code", self.FileName, self.CurrentLineNumber) - Overrides.PciClassCode = self.__Token - - if self.__IsKeyword( "PCI_DEVICE_ID"): - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - if not self.__GetNextHexNumber(): - raise Warning("expected Hex device id", self.FileName, self.CurrentLineNumber) - - Overrides.PciDeviceId = self.__Token - - if self.__IsKeyword( "PCI_REVISION"): - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - if not self.__GetNextHexNumber(): - raise Warning("expected Hex revision", self.FileName, self.CurrentLineNumber) - Overrides.PciRevision = self.__Token - - if self.__IsKeyword( "COMPRESS"): - if not self.__IsToken( "="): - raise Warning("expected '='", self.FileName, self.CurrentLineNumber) - if not self.__GetNextToken(): - raise Warning("expected TRUE/FALSE for compress", self.FileName, self.CurrentLineNumber) - - if self.__Token.upper() == 'TRUE': - Overrides.NeedCompress = True - - if not self.__IsToken( "}"): - - if self.__Token not in ("PCI_CLASS_CODE", "PCI_VENDOR_ID", "PCI_DEVICE_ID", "PCI_REVISION", "COMPRESS"): - raise Warning("unknown attribute %s" % self.__Token, self.FileName, self.CurrentLineNumber) - - raise Warning("expected '}'", self.FileName, self.CurrentLineNumber) - + while True: + if self.__IsKeyword( "PCI_VENDOR_ID"): + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + if not self.__GetNextHexNumber(): + raise Warning("expected Hex vendor id", self.FileName, self.CurrentLineNumber) + Overrides.PciVendorId = self.__Token + continue + + if self.__IsKeyword( "PCI_CLASS_CODE"): + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + if not self.__GetNextHexNumber(): + raise Warning("expected Hex class code", self.FileName, self.CurrentLineNumber) + Overrides.PciClassCode = self.__Token + continue + + if self.__IsKeyword( "PCI_DEVICE_ID"): + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + if not self.__GetNextHexNumber(): + raise Warning("expected Hex device id", self.FileName, self.CurrentLineNumber) + + Overrides.PciDeviceId = self.__Token + continue + + if self.__IsKeyword( "PCI_REVISION"): + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + if not self.__GetNextHexNumber(): + raise Warning("expected Hex revision", self.FileName, self.CurrentLineNumber) + Overrides.PciRevision = self.__Token + continue + + if self.__IsKeyword( "COMPRESS"): + if not self.__IsToken( "="): + raise Warning("expected '='", self.FileName, self.CurrentLineNumber) + if not self.__GetNextToken(): + raise Warning("expected TRUE/FALSE for compress", self.FileName, self.CurrentLineNumber) + Overrides.NeedCompress = self.__Token.upper() == 'TRUE' + continue + + if self.__IsToken( "}"): + break + else: + EdkLogger.error("FdfParser", FORMAT_INVALID, File=self.FileName, Line=self.CurrentLineNumber) + Obj.OverrideAttribs = Overrides ## __GetOptRomFileStatement() method @@ -3635,8 +3671,52 @@ class FdfParser: Obj.FfsList.append(FfsFileObj) return True - - + + ## __GetCapInFd() method + # + # Get Cap list contained in FD + # + # @param self The object pointer + # @param FdName FD name + # @retval CapList List of Capsule in FD + # + def __GetCapInFd (self, FdName): + + CapList = [] + if FdName.upper() in self.Profile.FdDict.keys(): + FdObj = self.Profile.FdDict[FdName.upper()] + for elementRegion in FdObj.RegionList: + if elementRegion.RegionType == 'CAPSULE': + for elementRegionData in elementRegion.RegionDataList: + if elementRegionData.endswith(".cap"): + continue + if elementRegionData != None and elementRegionData.upper() not in CapList: + CapList.append(elementRegionData.upper()) + return CapList + + ## __GetReferencedFdCapTuple() method + # + # Get FV and FD list referenced by a capsule image + # + # @param self The object pointer + # @param CapObj Capsule section to be searched + # @param RefFdList referenced FD by section + # @param RefFvList referenced FV by section + # + def __GetReferencedFdCapTuple(self, CapObj, RefFdList = [], RefFvList = []): + + for CapsuleDataObj in CapObj.CapsuleDataList : + if CapsuleDataObj.FvName != None and CapsuleDataObj.FvName.upper() not in RefFvList: + RefFvList.append (CapsuleDataObj.FvName.upper()) + elif CapsuleDataObj.Ffs != None: + if isinstance(CapsuleDataObj.Ffs, FfsFileStatement.FileStatement): + if CapsuleDataObj.Ffs.FvName != None and CapsuleDataObj.Ffs.FvName.upper() not in RefFvList: + RefFvList.append(CapsuleDataObj.Ffs.FvName.upper()) + elif CapsuleDataObj.Ffs.FdName != None and CapsuleDataObj.Ffs.FdName.upper() not in RefFdList: + RefFdList.append(CapsuleDataObj.Ffs.FdName.upper()) + else: + self.__GetReferencedFdFvTupleFromSection(CapsuleDataObj.Ffs, RefFdList, RefFvList) + ## __GetFvInFd() method # # Get FV list contained in FD @@ -3653,6 +3733,8 @@ class FdfParser: for elementRegion in FdObj.RegionList: if elementRegion.RegionType == 'FV': for elementRegionData in elementRegion.RegionDataList: + if elementRegionData.endswith(".fv"): + continue if elementRegionData != None and elementRegionData.upper() not in FvList: FvList.append(elementRegionData.upper()) return FvList @@ -3711,60 +3793,126 @@ class FdfParser: # @retval False Not exists cycle reference # def CycleReferenceCheck(self): + # + # Check the cycle between FV and FD image + # + MaxLength = len (self.Profile.FvDict) + for FvName in self.Profile.FvDict.keys(): + LogStr = "\nCycle Reference Checking for FV: %s\n" % FvName + RefFvStack = [] + RefFvStack.append(FvName) + FdAnalyzedList = [] + + Index = 0 + while RefFvStack != [] and Index < MaxLength: + Index = Index + 1 + FvNameFromStack = RefFvStack.pop() + if FvNameFromStack.upper() in self.Profile.FvDict.keys(): + FvObj = self.Profile.FvDict[FvNameFromStack.upper()] + else: + continue - CycleRefExists = False + RefFdList = [] + RefFvList = [] + self.__GetReferencedFdFvTuple(FvObj, RefFdList, RefFvList) - try: - for FvName in self.Profile.FvDict.keys(): - LogStr = "Cycle Reference Checking for FV: %s\n" % FvName - RefFvStack = [] - RefFvStack.append(FvName) - FdAnalyzedList = [] - - while RefFvStack != []: - FvNameFromStack = RefFvStack.pop() - if FvNameFromStack.upper() in self.Profile.FvDict.keys(): - FvObj = self.Profile.FvDict[FvNameFromStack.upper()] - else: + for RefFdName in RefFdList: + if RefFdName in FdAnalyzedList: continue - RefFdList = [] - RefFvList = [] - self.__GetReferencedFdFvTuple(FvObj, RefFdList, RefFvList) + LogStr += "FV %s contains FD %s\n" % (FvNameFromStack, RefFdName) + FvInFdList = self.__GetFvInFd(RefFdName) + if FvInFdList != []: + for FvNameInFd in FvInFdList: + LogStr += "FD %s contains FV %s\n" % (RefFdName,FvNameInFd) + if FvNameInFd not in RefFvStack: + RefFvStack.append(FvNameInFd) + + if FvName in RefFvStack or FvNameFromStack in RefFvStack: + EdkLogger.info(LogStr) + return True + FdAnalyzedList.append(RefFdName) + for RefFvName in RefFvList: + LogStr += "FV %s contains FV %s\n" % (FvNameFromStack, RefFvName) + if RefFvName not in RefFvStack: + RefFvStack.append(RefFvName) + + if FvName in RefFvStack or FvNameFromStack in RefFvStack: + EdkLogger.info(LogStr) + return True + + # + # Check the cycle between Capsule and FD image + # + MaxLength = len (self.Profile.CapsuleDict) + for CapName in self.Profile.CapsuleDict.keys(): + # + # Capsule image to be checked. + # + LogStr = "\n\n\nCycle Reference Checking for Capsule: %s\n" % CapName + RefCapStack = [] + RefCapStack.append(CapName) + FdAnalyzedList = [] + FvAnalyzedList = [] + + Index = 0 + while RefCapStack != [] and Index < MaxLength: + Index = Index + 1 + CapNameFromStack = RefCapStack.pop() + if CapNameFromStack.upper() in self.Profile.CapsuleDict.keys(): + CapObj = self.Profile.CapsuleDict[CapNameFromStack.upper()] + else: + continue + + RefFvList = [] + RefFdList = [] + self.__GetReferencedFdCapTuple(CapObj, RefFdList, RefFvList) + + FvListLength = 0 + FdListLength = 0 + while FvListLength < len (RefFvList) or FdListLength < len (RefFdList): for RefFdName in RefFdList: if RefFdName in FdAnalyzedList: continue - LogStr += "FD %s is referenced by FV %s\n" % (RefFdName, FvNameFromStack) + LogStr += "Capsule %s contains FD %s\n" % (CapNameFromStack, RefFdName) + CapInFdList = self.__GetCapInFd(RefFdName) + if CapInFdList != []: + for CapNameInFd in CapInFdList: + LogStr += "FD %s contains Capsule %s\n" % (RefFdName,CapNameInFd) + if CapNameInFd not in RefCapStack: + RefCapStack.append(CapNameInFd) + + if CapName in RefCapStack or CapNameFromStack in RefCapStack: + EdkLogger.info(LogStr) + return True + FvInFdList = self.__GetFvInFd(RefFdName) if FvInFdList != []: - LogStr += "FD %s contains FV: " % RefFdName - for FvObj in FvInFdList: - LogStr += FvObj - LogStr += ' \n' - if FvObj not in RefFvStack: - RefFvStack.append(FvObj) - - if FvName in RefFvStack: - CycleRefExists = True - raise Warning(LogStr) - FdAnalyzedList.append(RefFdName) + for FvNameInFd in FvInFdList: + LogStr += "FD %s contains FV %s\n" % (RefFdName,FvNameInFd) + if FvNameInFd not in RefFvList: + RefFvList.append(FvNameInFd) + FdAnalyzedList.append(RefFdName) + # + # the number of the parsed FV and FD image + # + FvListLength = len (RefFvList) + FdListLength = len (RefFdList) for RefFvName in RefFvList: - LogStr += "FV %s is referenced by FV %s\n" % (RefFvName, FvNameFromStack) - if RefFvName not in RefFvStack: - RefFvStack.append(RefFvName) - - if FvName in RefFvStack: - CycleRefExists = True - raise Warning(LogStr) - - except Warning: - print LogStr + if RefFvName in FvAnalyzedList: + continue + LogStr += "Capsule %s contains FV %s\n" % (CapNameFromStack, RefFvName) + if RefFvName.upper() in self.Profile.FvDict.keys(): + FvObj = self.Profile.FvDict[RefFvName.upper()] + else: + continue + self.__GetReferencedFdFvTuple(FvObj, RefFdList, RefFvList) + FvAnalyzedList.append(RefFvName) - finally: - return CycleRefExists + return False if __name__ == "__main__": parser = FdfParser("..\LakeportX64Pkg.fdf") diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index ed778f3d44..e3f2e68fb8 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -78,8 +78,7 @@ class FileStatement (FileStatementClassObject) : if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName)) Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper()) - FvBin = {} - FileName = Fd.GenFd(FvBin) + FileName = Fd.GenFd() SectionFiles = [FileName] elif self.FileName != None: diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 74248f71c3..23ec58200b 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -44,6 +44,7 @@ class FV (FvClassObject): self.BaseAddress = None self.InfFileName = None self.FvAddressFileName = None + self.CapsuleName = None ## AddToBuffer() # @@ -61,10 +62,27 @@ class FV (FvClassObject): # def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) : - if self.UiFvName.upper() in GenFds.FvBinDict.keys(): - return GenFds.FvBinDict[self.UiFvName.upper()] - - GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV ..." %self.UiFvName) + if self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys(): + return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] + + # + # Check whether FV in Capsule is in FD flash region. + # If yes, return error. Doesn't support FV in Capsule image is also in FD flash region. + # + if self.CapsuleName != None: + for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + for RegionObj in FdObj.RegionList: + if RegionObj.RegionType == 'FV': + for RegionData in RegionObj.RegionDataList: + if RegionData.endswith(".fv"): + continue + elif RegionData.upper() + 'fv' in GenFds.ImageBinDict.keys(): + continue + elif self.UiFvName.upper() == RegionData.upper(): + GenFdsGlobalVariable.ErrorLogger("Capsule %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, self.UiFvName.upper())) + + GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvName) self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict) # @@ -115,12 +133,12 @@ class FV (FvClassObject): # FvFileObj = open ( FvOutputFile,'r+b') - GenFdsGlobalVariable.InfLogger( "\nGenerate %s FV Successfully" %self.UiFvName) + GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successfully" %self.UiFvName) GenFdsGlobalVariable.SharpCounter = 0 Buffer.write(FvFileObj.read()) FvFileObj.close() - GenFds.FvBinDict[self.UiFvName.upper()] = FvOutputFile + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] = FvOutputFile return FvOutputFile ## __InitializeInf__() diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index 2bc416f828..1df19100d3 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -20,7 +20,7 @@ import sys import os import linecache import FdfParser -from Common.BuildToolError import * +import Common.BuildToolError as BuildToolError from GenFdsGlobalVariable import GenFdsGlobalVariable from Workspace.WorkspaceDatabase import WorkspaceDatabase from Workspace.BuildClassObject import PcdClassObject @@ -77,10 +77,10 @@ def main(): EdkLogger.SetLevel(EdkLogger.INFO) if (Options.Workspace == None): - EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "WORKSPACE not defined", + EdkLogger.error("GenFds", OPTION_MISSING, "WORKSPACE not defined", ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.") elif not os.path.exists(Options.Workspace): - EdkLogger.error("GenFds", BuildToolError.PARAMETER_INVALID, "WORKSPACE is invalid", + EdkLogger.error("GenFds", PARAMETER_INVALID, "WORKSPACE is invalid", ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.") else: Workspace = os.path.normcase(Options.Workspace) @@ -95,17 +95,17 @@ def main(): FdfFilename = Options.filename FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro(FdfFilename) else: - EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing FDF filename") + EdkLogger.error("GenFds", OPTION_MISSING, "Missing FDF filename") if (Options.BuildTarget): GenFdsGlobalVariable.TargetName = Options.BuildTarget else: - EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing build target") + EdkLogger.error("GenFds", OPTION_MISSING, "Missing build target") if (Options.ToolChain): GenFdsGlobalVariable.ToolChainTag = Options.ToolChain else: - EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing tool chain tag") + EdkLogger.error("GenFds", OPTION_MISSING, "Missing tool chain tag") if FdfFilename[0:2] == '..': FdfFilename = os.path.realpath(FdfFilename) @@ -113,7 +113,7 @@ def main(): FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename) if not os.path.exists(FdfFilename): - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=FdfFilename) + EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=FdfFilename) GenFdsGlobalVariable.FdfFile = FdfFilename GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename) @@ -128,19 +128,19 @@ def main(): ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform) if not os.path.exists(ActivePlatform) : - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist!") + EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") if ActivePlatform.find(Workspace) == -1: - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!") + EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!") ActivePlatform = ActivePlatform.replace(Workspace, '') if len(ActivePlatform) > 0 : if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/': ActivePlatform = ActivePlatform[1:] else: - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist!") + EdkLogger.error("GenFds", FILE_NOT_FOUND, "ActivePlatform doesn't exist!") else : - EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing active platform") + EdkLogger.error("GenFds", OPTION_MISSING, "Missing active platform") GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace) @@ -148,26 +148,28 @@ def main(): if os.path.isfile(BuildConfigurationFile) == True: TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile) else: - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) + EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=BuildConfigurationFile) if Options.Macros: for Pair in Options.Macros: Pair.strip('"') List = Pair.split('=') if len(List) == 2: - FdfParser.InputMacroDict[List[0].strip()] = List[1].strip() if List[0].strip() == "EFI_SOURCE": GlobalData.gEfiSource = List[1].strip() + continue elif List[0].strip() == "EDK_SOURCE": GlobalData.gEdkSource = List[1].strip() + continue else: GlobalData.gEdkGlobal[List[0].strip()] = List[1].strip() + FdfParser.InputMacroDict[List[0].strip()] = List[1].strip() else: - FdfParser.InputMacroDict[List[0].strip()] = None + FdfParser.InputMacroDict[List[0].strip()] = "" """call Workspace build create database""" os.environ["WORKSPACE"] = Workspace - BuildWorkSpace = WorkspaceDatabase(':memory:', GlobalData.gGlobalDefines) + BuildWorkSpace = WorkspaceDatabase(':memory:', FdfParser.InputMacroDict) BuildWorkSpace.InitDatabase() # @@ -179,7 +181,7 @@ def main(): if (Options.archList) : ArchList = Options.archList.split(',') else: -# EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing build ARCH") +# EdkLogger.error("GenFds", OPTION_MISSING, "Missing build ARCH") ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList) & set(ArchList) @@ -206,7 +208,7 @@ def main(): OutputDir = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, OutputDir) if not os.path.exists(OutputDir): - EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=OutputDir) + EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=OutputDir) GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir """ Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """ @@ -214,20 +216,20 @@ def main(): FdfParserObj.ParseFile() if FdfParserObj.CycleReferenceCheck(): - EdkLogger.error("GenFds", BuildToolError.FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") + EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file") if (Options.uiFdName) : if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys(): GenFds.OnlyGenerateThisFd = Options.uiFdName else: - EdkLogger.error("GenFds", BuildToolError.OPTION_VALUE_INVALID, + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FD in FDF file: %s" % Options.uiFdName) if (Options.uiFvName) : if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys(): GenFds.OnlyGenerateThisFv = Options.uiFvName else: - EdkLogger.error("GenFds", BuildToolError.OPTION_VALUE_INVALID, + EdkLogger.error("GenFds", OPTION_VALUE_INVALID, "No such an FV in FDF file: %s" % Options.uiFvName) """Modify images from build output if the feature of loading driver at fixed address is on.""" @@ -240,8 +242,8 @@ def main(): GenFds.DisplayFvSpaceInfo(FdfParserObj) except FdfParser.Warning, X: - EdkLogger.error(X.ToolName, BuildToolError.FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False) - ReturnCode = BuildToolError.FORMAT_INVALID + EdkLogger.error(X.ToolName, FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False) + ReturnCode = FORMAT_INVALID except FatalError, X: if Options.debug != None: import traceback @@ -309,8 +311,8 @@ def myOptionParser(): # class GenFds : FdfParsef = None - # FvName in FDF, FvBinFile name - FvBinDict = {} + # FvName, FdName, CapName in FDF, Image file name + ImageBinDict = {} OnlyGenerateThisFd = None OnlyGenerateThisFv = None @@ -324,17 +326,17 @@ class GenFds : def GenFd (OutputDir, FdfParser, WorkSpace, ArchList): GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList) - GenFdsGlobalVariable.VerboseLogger(" Gen Fd !") + GenFdsGlobalVariable.VerboseLogger(" Generate all Fd images and their required FV and Capsule images!") if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper()) if FdObj != None: - FdObj.GenFd(GenFds.FvBinDict) - elif GenFds.OnlyGenerateThisFv == None: + FdObj.GenFd() + elif GenFds.OnlyGenerateThisFd == None: for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] - FdObj.GenFd(GenFds.FvBinDict) + FdObj.GenFd() - GenFdsGlobalVariable.VerboseLogger(" Gen FV ! ") + GenFdsGlobalVariable.VerboseLogger("\n Generate other FV images! ") if GenFds.OnlyGenerateThisFv != None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper()) if FvObj != None: @@ -343,7 +345,7 @@ class GenFds : FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj)) Buffer.close() return - elif GenFds.OnlyGenerateThisFd == None: + elif GenFds.OnlyGenerateThisFv == None: for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): Buffer = StringIO.StringIO('') FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] @@ -352,12 +354,14 @@ class GenFds : Buffer.close() if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None: - GenFdsGlobalVariable.VerboseLogger(" Gen Capsule !") - for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleList: - CapsuleObj.GenCapsule() - + if GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict != {}: + GenFdsGlobalVariable.VerboseLogger("\n Generate other Capsule images!") + for CapsuleName in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): + CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[CapsuleName] + CapsuleObj.GenCapsule() + if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}: - GenFdsGlobalVariable.VerboseLogger(" Gen Option ROM !") + GenFdsGlobalVariable.VerboseLogger("\n Generate all Option ROM!") for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys(): OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName] OptRomObj.AddToBuffer(None) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index d556ce7ade..77c8821a05 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -360,7 +360,7 @@ class GenFdsGlobalVariable: try: PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE) except Exception, X: - EdkLogger.error("GenFds", BuildToolError.COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0])) + EdkLogger.error("GenFds", COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0])) (out, error) = PopenObject.communicate() while PopenObject.returncode == None : @@ -371,7 +371,7 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.InfLogger (error) if PopenObject.returncode != 0: print "###", cmd - EdkLogger.error("GenFds", BuildToolError.COMMAND_FAILURE, errorMess) + EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess) def VerboseLogger (msg): EdkLogger.verbose(msg) @@ -380,7 +380,7 @@ class GenFdsGlobalVariable: EdkLogger.info(msg) def ErrorLogger (msg, File = None, Line = None, ExtraData = None): - EdkLogger.error('GenFds', BuildToolError.GENFDS_ERROR, msg, File, Line, ExtraData) + EdkLogger.error('GenFds', GENFDS_ERROR, msg, File, Line, ExtraData) def DebugLogger (Level, msg): EdkLogger.debug(Level, msg) diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py index b9f0af54c9..8cd7429d58 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -48,7 +48,15 @@ class OptRomInfStatement (FfsInfStatement): if self.OverrideAttribs == None: self.OverrideAttribs = OptionRom.OverrideAttribs() - + + if self.OverrideAttribs.NeedCompress == None: + self.OverrideAttribs.NeedCompress = self.OptRomDefs.get ('COMPRESS') + if self.OverrideAttribs.NeedCompress is not None: + if self.OverrideAttribs.NeedCompress.upper() not in ('TRUE', 'FALSE'): + GenFdsGlobalVariable.ErrorLogger( "Expected TRUE/FALSE for COMPRESS: %s" %self.InfFileName) + self.OverrideAttribs.NeedCompress = \ + self.OverrideAttribs.NeedCompress.upper() == 'TRUE' + if self.OverrideAttribs.PciVendorId == None: self.OverrideAttribs.PciVendorId = self.OptRomDefs.get ('PCI_VENDOR_ID') diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source/Python/GenFds/OptionRom.py index e102e65f1c..28e77aad5f 100644 --- a/BaseTools/Source/Python/GenFds/OptionRom.py +++ b/BaseTools/Source/Python/GenFds/OptionRom.py @@ -135,6 +135,6 @@ class OverrideAttribs: self.PciClassCode = None self.PciDeviceId = None self.PciRevision = None - self.NeedCompress = False + self.NeedCompress = None \ No newline at end of file diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py index ed16c6fa98..99f1ac39ac 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -20,10 +20,10 @@ from GenFdsGlobalVariable import GenFdsGlobalVariable import StringIO from CommonDataClass.FdfClass import RegionClassObject import os +from stat import * from Common import EdkLogger from Common.BuildToolError import * - ## generate Region # # @@ -52,9 +52,9 @@ class Region(RegionClassObject): # @retval string Generated FV file path # - def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, FvBinDict, vtfDict = None, MacroDict = {}): + def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, ImageBinDict, vtfDict = None, MacroDict = {}): Size = self.Size - GenFdsGlobalVariable.InfLogger('Generate Region at Offset 0x%X' % self.Offset) + GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' % self.Offset) GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" %Size) GenFdsGlobalVariable.SharpCounter = 0 @@ -62,15 +62,14 @@ class Region(RegionClassObject): # # Get Fv from FvDict # - FvBuffer = StringIO.StringIO('') RegionBlockSize = self.BlockSizeOfRegion(BlockSizeList) RegionBlockNum = self.BlockNumOfRegion(RegionBlockSize) self.FvAddress = int(BaseAddress, 16) + self.Offset - FvBaseAddress = '0x%X' %self.FvAddress - + FvBaseAddress = '0x%X' %self.FvAddress + FvOffset = 0 for RegionData in self.RegionDataList: - + FileName = None if RegionData.endswith(".fv"): RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict) GenFdsGlobalVariable.InfLogger(' Region FV File Name = .fv : %s'%RegionData) @@ -79,83 +78,165 @@ class Region(RegionClassObject): if not os.path.exists(RegionData): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) - BinFile = open (RegionData, 'r+b') - FvBuffer.write(BinFile.read()) - if FvBuffer.len > Size: + FileName = RegionData + elif RegionData.upper() + 'fv' in ImageBinDict.keys(): + GenFdsGlobalVariable.InfLogger(' Region Name = FV') + FileName = ImageBinDict[RegionData.upper() + 'fv'] + else: + # + # Generate FvImage. + # + FvObj = None + if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): + FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper()) + + if FvObj != None : + GenFdsGlobalVariable.InfLogger(' Region Name = FV') + # + # Call GenFv tool + # + BlockSize = RegionBlockSize + BlockNum = RegionBlockNum + if FvObj.BlockSizeList != []: + if FvObj.BlockSizeList[0][0] != None: + BlockSize = FvObj.BlockSizeList[0][0] + if FvObj.BlockSizeList[0][1] != None: + BlockNum = FvObj.BlockSizeList[0][1] + self.FvAddress = self.FvAddress + FvOffset + FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment) + if self.FvAddress % FvAlignValue != 0: + EdkLogger.error("GenFds", GENFDS_ERROR, + "FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment)) + FvBuffer = StringIO.StringIO('') + FvBaseAddress = '0x%X' %self.FvAddress + FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict) + if FvBuffer.len > Size: + FvBuffer.close() + EdkLogger.error("GenFds", GENFDS_ERROR, + "Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size)) + # + # Put the generated image into FD buffer. + # + Buffer.write(FvBuffer.getvalue()) + FvBuffer.close() + FvOffset = FvOffset + FvBuffer.len + Size = Size - FvBuffer.len + continue + else: + EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData)) + # + # Add the exist Fv image into FD buffer + # + if FileName != None: + FileLength = os.stat(FileName)[ST_SIZE] + if FileLength > Size: EdkLogger.error("GenFds", GENFDS_ERROR, "Size of FV File (%s) is larger than Region Size 0x%X specified." \ % (RegionData, Size)) - break - - if RegionData.upper() in FvBinDict.keys(): - continue + BinFile = open (FileName, 'r+b') + Buffer.write(BinFile.read()) + BinFile.close() + Size = Size - FileLength + # + # Pad the left buffer + # + if Size > 0: + if (ErasePolarity == '1') : + PadData = 0xFF + else : + PadData = 0 + for i in range(0, Size): + Buffer.write(pack('B', PadData)) - FvObj = None - if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): - FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper()) + if self.RegionType == 'CAPSULE': + # + # Get Capsule from Capsule Dict + # + for RegionData in self.RegionDataList: + if RegionData.endswith(".cap"): + RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict) + GenFdsGlobalVariable.InfLogger(' Region CAPSULE Image Name = .cap : %s'%RegionData) + if RegionData[1] != ':' : + RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData) + if not os.path.exists(RegionData): + EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) - if FvObj != None : - GenFdsGlobalVariable.InfLogger(' Region Name = FV') + FileName = RegionData + elif RegionData.upper() + 'cap' in ImageBinDict.keys(): + GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE') + FileName = ImageBinDict[RegionData.upper() + 'cap'] + else: # - # Call GenFv tool + # Generate Capsule image and Put it into FD buffer # - BlockSize = RegionBlockSize - BlockNum = RegionBlockNum - if FvObj.BlockSizeList != []: - if FvObj.BlockSizeList[0][0] != None: - BlockSize = FvObj.BlockSizeList[0][0] - if FvObj.BlockSizeList[0][1] != None: - BlockNum = FvObj.BlockSizeList[0][1] - self.FvAddress = self.FvAddress + FvBuffer.len - FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment) - if self.FvAddress % FvAlignValue != 0: - EdkLogger.error("GenFds", GENFDS_ERROR, - "FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment)) - FvBaseAddress = '0x%X' %self.FvAddress - FileName = FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict) - - if FvBuffer.len > Size: - EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size)) - else: - EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData)) + CapsuleObj = None + if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict.keys(): + CapsuleObj = GenFdsGlobalVariable.FdfParser.Profile.CapsuleDict[RegionData.upper()] + if CapsuleObj != None : + CapsuleObj.CapsuleName = RegionData.upper() + GenFdsGlobalVariable.InfLogger(' Region Name = CAPSULE') + # + # Call GenFv tool to generate Capsule Image + # + FileName = CapsuleObj.GenCapsule() + CapsuleObj.CapsuleName = None + else: + EdkLogger.error("GenFds", GENFDS_ERROR, "Capsule (%s) is NOT described in FDF file!" % (RegionData)) - if FvBuffer.len > 0: - Buffer.write(FvBuffer.getvalue()) - else: - BinFile = open (FileName, 'rb') + # + # Add the capsule image into FD buffer + # + FileLength = os.stat(FileName)[ST_SIZE] + if FileLength > Size: + EdkLogger.error("GenFds", GENFDS_ERROR, + "Size 0x%X of Capsule File (%s) is larger than Region Size 0x%X specified." \ + % (FileLength, RegionData, Size)) + BinFile = open (FileName, 'r+b') Buffer.write(BinFile.read()) - - FvBuffer.close() + BinFile.close() + Size = Size - FileLength + # + # Pad the left buffer + # + if Size > 0: + if (ErasePolarity == '1') : + PadData = 0xFF + else : + PadData = 0 + for i in range(0, Size): + Buffer.write(pack('B', PadData)) if self.RegionType == 'FILE': - FvBuffer = StringIO.StringIO('') for RegionData in self.RegionDataList: RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict) - GenFdsGlobalVariable.InfLogger(' Region File Name = FILE: %s'%RegionData) if RegionData[1] != ':' : RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData) if not os.path.exists(RegionData): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData) - - BinFile = open (RegionData, 'r+b') - FvBuffer.write(BinFile.read()) - if FvBuffer.len > Size : + # + # Add the file image into FD buffer + # + FileLength = os.stat(RegionData)[ST_SIZE] + if FileLength > Size: EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of File (%s) large than Region Size " % RegionData) - + "Size of File (%s) is larger than Region Size 0x%X specified." \ + % (RegionData, Size)) + GenFdsGlobalVariable.InfLogger(' Region File Name = %s'%RegionData) + BinFile = open (RegionData, 'r+b') + Buffer.write(BinFile.read()) + BinFile.close() + Size = Size - FileLength # - # If File contents less than region size, append "0xff" after it + # Pad the left buffer # - if FvBuffer.len < Size: - for index in range(0, (Size-FvBuffer.len)): - if (ErasePolarity == '1'): - FvBuffer.write(pack('B', int('0xFF', 16))) - else: - FvBuffer.write(pack('B', int('0x00', 16))) - Buffer.write(FvBuffer.getvalue()) - FvBuffer.close() + if Size > 0: + if (ErasePolarity == '1') : + PadData = 0xFF + else : + PadData = 0 + for i in range(0, Size): + Buffer.write(pack('B', PadData)) if self.RegionType == 'DATA' : GenFdsGlobalVariable.InfLogger(' Region Name = DATA') @@ -168,12 +249,16 @@ class Region(RegionClassObject): else: for item in Data : Buffer.write(pack('B', int(item, 16))) - if DataSize < Size: - if (ErasePolarity == '1'): + Size = Size - DataSize + # + # Pad the left buffer + # + if Size > 0: + if (ErasePolarity == '1') : PadData = 0xFF - else: + else : PadData = 0 - for i in range(Size - DataSize): + for i in range(0, Size): Buffer.write(pack('B', PadData)) if self.RegionType == None: diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 294237daee..40eb82656d 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -16,6 +16,7 @@ # import os import time +import copy import Common.EdkLogger as EdkLogger from CommonDataClass.DataClass import * @@ -55,7 +56,7 @@ class MetaFileParser(object): self._FileType = FileType self.MetaFile = FilePath self._FileDir = os.path.dirname(self.MetaFile) - self._Macros = {} + self._Macros = copy.copy(Macros) # for recursive parsing self._Owner = Owner @@ -87,7 +88,9 @@ class MetaFileParser(object): ## Set parsing complete flag in both class and table def _Done(self): self._Finished = True - self._Table.SetEndFlag() + ## Do not set end flag when processing included files + if self._From == -1: + self._Table.SetEndFlag() ## Return the table containg parsed data # @@ -208,11 +211,14 @@ class MetaFileParser(object): if TokenList[0] == '': EdkLogger.error('Parser', FORMAT_INVALID, "No macro name given", ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex+1) - if len(TokenList) == 1: - self._Macros[TokenList[0]] = '' - else: - # keep the macro definition for later use - self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False) + + # Macros defined in the command line override ones defined in the meta-data file + if not TokenList[0] in self._Macros: + if len(TokenList) == 1: + self._Macros[TokenList[0]] = '' + else: + # keep the macro definition for later use + self._Macros[TokenList[0]] = ReplaceMacro(TokenList[1], self._Macros, False) return TokenList[0], self._Macros[TokenList[0]] diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index df0fa81ebb..348d219aa9 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -17,6 +17,7 @@ import sqlite3 import os import os.path +import pickle import Common.EdkLogger as EdkLogger import Common.GlobalData as GlobalData @@ -24,6 +25,7 @@ import Common.GlobalData as GlobalData from Common.String import * from Common.DataType import * from Common.Misc import * +from types import * from CommonDataClass.CommonClass import SkuInfoClass @@ -1109,6 +1111,7 @@ class InfBuildData(ModuleBuildClassObject): "BS_DRIVER" : "DXE_DRIVER", "RT_DRIVER" : "DXE_RUNTIME_DRIVER", "SAL_RT_DRIVER" : "DXE_SAL_DRIVER", + "SMM_DRIVER" : "SMM_DRIVER", # "BS_DRIVER" : "DXE_SMM_DRIVER", # "BS_DRIVER" : "UEFI_DRIVER", "APPLICATION" : "UEFI_APPLICATION", @@ -2059,11 +2062,11 @@ class WorkspaceDatabase(object): if DbPath != ':memory:': DbDir = os.path.split(DbPath)[0] if not os.path.exists(DbDir): - os.makedirs(DbDir) - - # remove db file in case inconsistency between db and file in file system - if self._CheckWhetherDbNeedRenew(RenewDb, DbPath): - os.remove(DbPath) + os.makedirs(DbDir) + + # remove db file in case inconsistency between db and file in file system + if self._CheckWhetherDbNeedRenew(RenewDb, DbPath): + os.remove(DbPath) # create db with optimized parameters self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED') @@ -2084,60 +2087,95 @@ class WorkspaceDatabase(object): # conversion object for build or file format conversion purpose self.BuildObject = WorkspaceDatabase.BuildObjectFactory(self) self.TransformObject = WorkspaceDatabase.TransformObjectFactory(self) - - ## Check whether workspace database need to be renew. - # The renew reason maybe: - # 1) If user force to renew; - # 2) If user do not force renew, and - # a) If the time of last modified python source is newer than database file; - # b) If the time of last modified frozen executable file is newer than database file; - # - # @param force User force renew database - # @param DbPath The absolute path of workspace database file - # - # @return Bool value for whether need renew workspace databse - # - def _CheckWhetherDbNeedRenew (self, force, DbPath): - # if database does not exist, we need do nothing - if not os.path.exists(DbPath): return False - - # if user force to renew database, then not check whether database is out of date - if force: return True - - # - # Check the time of last modified source file or build.exe - # if is newer than time of database, then database need to be re-created. - # - timeOfToolModified = 0 - if hasattr(sys, "frozen"): - exePath = os.path.abspath(sys.executable) - timeOfToolModified = os.stat(exePath).st_mtime - else: - curPath = os.path.dirname(__file__) # curPath is the path of WorkspaceDatabase.py - rootPath = os.path.split(curPath)[0] # rootPath is root path of python source, such as /BaseTools/Source/Python - if rootPath == "" or rootPath == None: - EdkLogger.verbose("\nFail to find the root path of build.exe or python sources, so can not \ -determine whether database file is out of date!\n") - - # walk the root path of source or build's binary to get the time last modified. - - for root, dirs, files in os.walk (rootPath): - for dir in dirs: - # bypass source control folder - if dir.lower() in [".svn", "_svn", "cvs"]: - dirs.remove(dir) - - for file in files: - ext = os.path.splitext(file)[1] - if ext.lower() == ".py": # only check .py files - fd = os.stat(os.path.join(root, file)) - if timeOfToolModified < fd.st_mtime: - timeOfToolModified = fd.st_mtime - if timeOfToolModified > os.stat(DbPath).st_mtime: - EdkLogger.verbose("\nWorkspace database is out of data!") - return True - - return False + + ## Check whether workspace database need to be renew. + # The renew reason maybe: + # 1) If user force to renew; + # 2) If user do not force renew, and + # a) If the time of last modified python source is newer than database file; + # b) If the time of last modified frozen executable file is newer than database file; + # + # @param force User force renew database + # @param DbPath The absolute path of workspace database file + # + # @return Bool value for whether need renew workspace databse + # + def _CheckWhetherDbNeedRenew (self, force, DbPath): + DbDir = os.path.split(DbPath)[0] + MacroFilePath = os.path.normpath(os.path.join(DbDir, "build.mac")) + MacroMatch = False + if os.path.exists(MacroFilePath) and os.path.isfile(MacroFilePath): + LastMacros = None + try: + f = open(MacroFilePath,'r') + LastMacros = pickle.load(f) + f.close() + except IOError: + pass + except: + f.close() + + if LastMacros != None and type(LastMacros) is DictType: + if LastMacros == self._GlobalMacros: + MacroMatch = True + for Macro in LastMacros.keys(): + if not (Macro in self._GlobalMacros and LastMacros[Macro] == self._GlobalMacros[Macro]): + MacroMatch = False; + break; + + if not MacroMatch: + # save command line macros to file + try: + f = open(MacroFilePath,'w') + pickle.dump(self._GlobalMacros, f, 2) + f.close() + except IOError: + pass + except: + f.close() + + force = True + + # if database does not exist, we need do nothing + if not os.path.exists(DbPath): return False + + # if user force to renew database, then not check whether database is out of date + if force: return True + + # + # Check the time of last modified source file or build.exe + # if is newer than time of database, then database need to be re-created. + # + timeOfToolModified = 0 + if hasattr(sys, "frozen"): + exePath = os.path.abspath(sys.executable) + timeOfToolModified = os.stat(exePath).st_mtime + else: + curPath = os.path.dirname(__file__) # curPath is the path of WorkspaceDatabase.py + rootPath = os.path.split(curPath)[0] # rootPath is root path of python source, such as /BaseTools/Source/Python + if rootPath == "" or rootPath == None: + EdkLogger.verbose("\nFail to find the root path of build.exe or python sources, so can not \ +determine whether database file is out of date!\n") + + # walk the root path of source or build's binary to get the time last modified. + + for root, dirs, files in os.walk (rootPath): + for dir in dirs: + # bypass source control folder + if dir.lower() in [".svn", "_svn", "cvs"]: + dirs.remove(dir) + + for file in files: + ext = os.path.splitext(file)[1] + if ext.lower() == ".py": # only check .py files + fd = os.stat(os.path.join(root, file)) + if timeOfToolModified < fd.st_mtime: + timeOfToolModified = fd.st_mtime + if timeOfToolModified > os.stat(DbPath).st_mtime: + EdkLogger.verbose("\nWorkspace database is out of data!") + return True + + return False ## Initialize build database def InitDatabase(self): diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index c92b442615..7d14e15420 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -158,13 +158,6 @@ def CheckEnvVariable(): EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Environment variable not found", ExtraData="PATH") - # for macro replacement in R9 DSC/DEC/INF file - GlobalData.gGlobalDefines["WORKSPACE"] = "" - - # for macro replacement in R8 INF file - GlobalData.gGlobalDefines["EFI_SOURCE"] = EfiSourceDir - GlobalData.gGlobalDefines["EDK_SOURCE"] = EdkSourceDir - GlobalData.gWorkspace = WorkspaceDir GlobalData.gEfiSource = EfiSourceDir GlobalData.gEdkSource = EdkSourceDir @@ -705,8 +698,8 @@ class Build(): self.TargetTxt = TargetTxtClassObject() self.ToolDef = ToolDefClassObject() - #self.Db = WorkspaceDatabase(None, GlobalData.gGlobalDefines, self.Reparse) - self.Db = WorkspaceDatabase(None, {}, self.Reparse) + self.Db = WorkspaceDatabase(None, GlobalData.gGlobalDefines, self.Reparse) + #self.Db = WorkspaceDatabase(None, {}, self.Reparse) self.BuildDatabase = self.Db.BuildObject self.Platform = None @@ -1258,6 +1251,7 @@ def MyOptionParser(): "including library instances selected, final dependency expression, "\ "and warning messages, etc.") Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.") + Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".") (Opt, Args)=Parser.parse_args() return (Opt, Args) @@ -1321,7 +1315,7 @@ def Main(): EdkLogger.error("build", OPTION_NOT_SUPPORTED, "Not supported target [%s]." % Target, ExtraData="Please select one of: %s" %(' '.join(gSupportedTarget))) - # GlobalData.gGlobalDefines = ParseDefines(Option.Defines) + GlobalData.gGlobalDefines = ParseDefines(Option.Macros) # # Check environment variable: EDK_TOOLS_PATH, WORKSPACE, PATH # diff --git a/BaseTools/Tests/CheckPythonSyntax.py b/BaseTools/Tests/CheckPythonSyntax.py index 67d2ca4756..47eb81fce8 100644 --- a/BaseTools/Tests/CheckPythonSyntax.py +++ b/BaseTools/Tests/CheckPythonSyntax.py @@ -29,8 +29,8 @@ class Tests(TestTools.BaseToolsTest): def SingleFileTest(self, filename): try: py_compile.compile(filename, doraise=True) - except: - self.fail('syntax error: ' + filename) + except Exception, e: + self.fail('syntax error: %s, Error is %s' % (filename, str(e))) def MakePythonSyntaxCheckTests(): def GetAllPythonSourceFiles(): diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat index 525bffa7cf..36cd9d2491 100755 --- a/BaseTools/toolsetup.bat +++ b/BaseTools/toolsetup.bat @@ -3,7 +3,7 @@ @REM however it may be executed directly from the BaseTools project folder @REM if the file is not executed within a WORKSPACE\BaseTools folder. @REM -@REM Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved. +@REM Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved. @REM @REM This program and the accompanying materials are licensed and made available @REM under the terms and conditions of the BSD Licensewhich accompanies this @@ -261,7 +261,7 @@ goto end set PYTHON_HOME=%PYTHONHOME% ) else ( echo. - echo !!! ERROR !!! PYTHON is required to build or execute the tools !!! + echo !!! ERROR !!! PYTHON_HOME is required to build or execute the tools, please set it. !!! echo. goto end ) -- cgit v1.2.3