summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
AgeCommit message (Collapse)Author
2016-12-02BaseTools: add error check for "#image" for idf file formatYonghong Zhu
Add new error check for "#image" keyword used in the image definition file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-30BaseTools: fix the bug to add PaletteSize info into AutoGenYonghong Zhu
Fix the bug to add PaletteSize info into AutoGen.c when the flag UEFI_HII_RESOURCE_SECTION is set to FALSE. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-29BaseTools: Fix bug for decimal value of VPDPCD offset display in reportYonghong Zhu
current if we set VPD PCD's offset to a decimal value, eg: 22, this value is displayed incorrectly in the "FD VPD Region" section in the report.txt. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-23BaseTools: report error for same Guid's Private definition conflictYonghong Zhu
Add error check for the same Guid/Protocol/PPIs/Includes defined as both Private and non-Private attribute. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=209 Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-15BaseTools: FILE DATA to support relative path under Multiple workspaceYonghong Zhu
Fix the bug that FILE DATA to support relative path under Multiple workspace. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-15BaseTools: Fix the bug to support generate FFS by Align=AutoYonghong Zhu
FDF spec support to use 'Auto' as <FfsAlignmentValues>, but current Tool report error about -a=Auto is invalid option when we set Align=Auto for RAW File. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-05BaseTools: Add the support for character '<' and '>' in the map fileYonghong Zhu
Current the regex for the symbol in the map file doesn't support the '<' and '>' character, while user use Lambda Expression (C++11 feature), it would generate the something like @V<lambda_xxx>@ in the map file which cause build fail to parse the symbol in map file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-04BaseTools/Pkcs7: Add readme.mdJiewen Yao
Add readme.md to describe the X.509 certificate generation. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Qin Long <qin.long@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Qin Long <qin.long@intel.com>
2016-11-04BaseTools: Fix the Windows GCC Build Failure with too long pathYonghong Zhu
When path is too long, build tool will wrap them into resp.txt, then call gcc @resp.txt. It will cause windows GCC build failure, because resp.txt still uses windows directory separator \. This patch change the \ to /. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-03BaseTool/Pkcs7: Add TestRoot.cer.Jiewen Yao
We add this binary data file for TestRoot.cer. So that a platform may include this default file in FDF, to check if the platform is using default test key, or different production key. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
2016-11-02BaseTools: Fix a bug for tooldef class not include the newly EnvYonghong Zhu
Prebuild script may update os.environ, but the tooldef class not include the new ENV variables. so after the Launch prebuild script, we should re-init the tooldef class to include the new ENV variables. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-02BaseTools: Fix a bug for ExpandMacros to support mixed case ENV varYonghong Zhu
os.environ contains all environment variables uppercase on Windows which cause the key in the self.MacroDictionary is uppercase, but the real variable name maybe mixed case, eg:WINSDK81x86, then we can't find the variable in the self.MacroDictionary. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-11-02BaseTools: Fix the bug for OptionRom generation with different archYonghong Zhu
The GenFds tool uses the same output for the same module with the different arch, IA32 and X64 module will have the same output. The solution is add the arch info in the output directory. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-10-19BaseTools: support PCD value to use expression in the DEC fileYonghong Zhu
This patch add the support for Pcd value to use expression in the DEC file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-10-19BaseTools: Enhance tool to generate EFI_HII_IIBT_DUPLICATE image blockYonghong Zhu
When *.IDF file contains multiple definitions of image which point to the same image, current build tool generates multiple image blocks which contain the same image content. This patch enhance tool to generate EFI_HII_IIBT_DUPLICATE image blocks for non-first images for such case, to save the HII package size. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=145 Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-10-17BaseTools: Update sign tool to make MonotonicCount *after* PayloadYonghong Zhu
The WIN_CERTIFICATE_UEFI_GUID AuthInfo defined in the UEFI spec mentioned that It is a signature across the image data and the Monotonic Count value. After clarification, we do the signature calculation, we put MonotonicCount after Payload. Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Tested-by: Jiewen Yao <jiewen.yao@intel.com>
2016-10-12BaseTools/GenFds: Support FDF sections in any orderMichael Kinney
https://bugzilla.tianocore.org/show_bug.cgi?id=141 This patch updates EDK II FDF parser in GenFds to allow sections to be placed in any order in the FDF file. Cc: Kelly Steele <kelly.steele@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-10-12BaseTools: Extend FMP to support FV statement and FD statementYonghong Zhu
This patch extend the <FmpFileData> to support <FvStatements> and <FdStatenents>, just like the normal [Capsule] section format. In order to fix the bug https://bugzilla.tianocore.org/show_bug.cgi?id=132 Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-09-30BaseTools Build: Fix build break for clean target in LinuxHao Wu
In Linux, Command needs to be String instead of list when Command run as shell with True. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-09-27BaseTools: List missing source python files for Ecc tool in MakefileHao Wu
Add missing python sources files that are dependent for Ecc tool in Makefile. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-09-27BaseTools: support generating image package from BMP/JPEG/PNG filesYonghong Zhu
BaseTools add support to generating image package from BMP/JPEG/PNG files. 1) New file type *.idf Image definition file to describe HII image resource. It is the ASCII text file, and includes one or more "#image IMAGE_ID [TRANSPARENT] ImageFileName". 2) New IMAGE_TOKEN macro is used to refer to IMAGE_ID. 3) New AutoGen header file $(MODULE_NAME)ImgDefs.h to include the generated ImageId definition. 4) New $(MODULE_NAME)Idf.hpk or $(MODULE_NAME)Images are generated as the output binary HII image package. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-09-25BaseTools: handling the case that map file is not existYonghong Zhu
We meet a case that add the library inf file which has the uni file in the [Sources] section, for this case there will no map file exist, it cause build tools report Traceback error. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-09-21BaseTools: Update Python Makefile not to depend on PYTHON_FREEZER_PATHLiming Gao
If PYTHON_FREEZER_PATH is not set, Python tools will not be freeze. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Erik Bjorge <erik.c.bjorge@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
2016-09-21BaseTools: Update python tool to call external tools with shell true modeLiming Gao
Python tool may run from source as the dos batch files. So, update python code to call external tools with shell true mode. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Erik Bjorge <erik.c.bjorge@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
2016-09-20BaseTools: Follow PI1.4a to fix artificial limitation of PCD SkuId rangeYonghong Zhu
Current BaseTools follow previous PI spec to use UINT8 for SkuId, to follow PI1.4a, BaseTools need to be updated to fix artificial limitation of PCD SkuId range. This patch is to update BaseTools to use UINT64 for SkuId, since the PCD database structure needs to be naturally aligned, the PCD database structure layout is adjusted to keep the natural alignment and version is updated to 6. Note: As the PCD database structure layout is adjusted, the structure definition in MdeModulePkg/Include/Guid/PcdDataBaseSignatureGuid.h and PCD drivers also need to be updated. That means the source code and BaseTools need to be upgraded at the same time, and if they are not upgraded at the same time, build error like below will be triggered to help user identify the problem. "Please make sure the version of PCD PEIM Service and the generated PCD PEI Database match." Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-09-15BaseTools: Fix the bug to handle the read-only fileYonghong Zhu
change the 'r+b' to 'rb' for some file's open, since these files we only read it and no need to write. It can fix the bug that the file's attribute had been set to read-only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-09-04BaseTools: Change source files to DOS formatYonghong Zhu
Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-30BaseTools: UpdateImageSize include Image auth info for FMP Auth capsuleYonghong Zhu
Per UEFI spec UpdateImageSize may or may not include Firmware Image Authentication information. so for FMP auth capsule, UpdateImageSize should include the Image auth info. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-23BaseTools: add capsule image header for auth FMP capsule fileYonghong Zhu
in last commit 91ae29, it missed to add the EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER for the auth FMP capsule. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-19BaseTools: Fix a bug use 'COMMON' as CodeBase in BuildOptions sectionYonghong Zhu
Current BaseTools query the BuildOptions not cover the case that use 'COMMON' as CodeBase, while DSC spec allow this usage. This Patch add support for such 'common.DXE_RUNTIME_DRIVER' as the Scope2 in the query Condition. Cc: Liming Gao <liming.gao@intel.com> Cc: Kurt Kennett <Kurt.Kennett@microsoft.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-19BaseTools: FMP capsule add the support to generate auth infoYonghong Zhu
Current BaseTools cannot generate EFI_FIRMWARE_IMAGE_AUTHENTICATION for FMP capsule. this patch fix it by FDF spec's update to add the definition for CERTIFICATE_GUID and MONOTONIC_COUNT. BaseTools call the tool by CERTIFICATE_GUID to generate the certdata and fill the header info. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-19BaseTools: Rsa2048Sha256Sign add new option to support Monotonic countYonghong Zhu
the EFI_FIRMWARE_IMAGE_AUTHENTICATION struct require the AuthInfo which is a signature across the image data and the Monotonic Count value, so we add the new option to support Monotonic count. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-19BaseTools: Add the PKCS7 toolYonghong Zhu
Provide the PKCS7 Tool to support the CertType - EFI_CERT_TYPE_PKCS7_GUID, then user can use this tool to add EFI_FIRMWARE_IMAGE_AUTHENTICATION for a binary. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-19BaseTools: check CONF_PATH env to get the configure filesYonghong Zhu
Add CONF_PATH env check. First priority is user set the conf dir by --conf option, then the CONF_PATH env, the last one is the standard WORKSPACE(PACKAGE_PATH)/Conf. Also print the conf path directory in the build log. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-09BaseTools/UPT: Fix a install issueHess Chen
Fix a corner case issue of installing a module without any files which causes installing UNI file failure Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-08-08BaseTools: Fix the bug when use FILE_GUID override the module in DSCYonghong Zhu
In last commit 2502b73, it doesn't cover the case that in the DSC file use FILE_GUID to override the module. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-08BaseTools: Allow string token identifier to use lower case lettersYonghong Zhu
This patch is to align the code behavior with UNI spec that string token identifier can use upper case and lower case letters. Cc: Liming Gao <liming.gao@intel.com> Cc: Felix <Felixp@ami.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-08-03BaseTool/Upt: Avoid UNI file name conflictHess Chen
When creating a UNI file if there is a name conflict, add an index from 0 to the file name Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-08-03BaseTool/UPT: Not expand macro for UserExtensionHess Chen
All MACRO values defined by the DEFINE statements n any section (except [Userextensions] sections other than TianoCore."ExtraFiles) of the INF or DEC file must be expanded before processing of the file. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-08-03BaseTool/Upt: Add support for PrivateHess Chen
Support new syntax in package DEC file as below: [Includes.Common.Private] [Ppis.Common.Private] [Guids.Common.Private] [Protocols.Common.Private] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-08-03BaseTool/UPT: Add Test InstallHess Chen
Add a new function to test if a DIST file list one by one to see if they can meet the requirement of Dependency. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-08-02BaseTools: Keep the Pcd order in the Asbuilt Inf is same with SourceYonghong Zhu
The original behavior is that in the Asbuilt inf Pcd's order is base on the Pcd's offset. Now we change the order to keep it is same with the Pcd order in the source inf file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-29BaseTools/Ecc: GUID checkpointHess Chen
Fix a bug of checking duplicate GUID Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hess Chen <hesheng.chen@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2016-07-29BaseTools: Add build info for binary modules that only list in FDF fileYonghong Zhu
If the binary module is list in the FDF file but not list in the DSC file, current build report would not include these binary module's info in the report "Module section". The patch fix this issue. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-27BaseTools: report error if source module INF is only list in FDF fileYonghong Zhu
If source module INF is not listed in DSC, it will not be built. And it is listed in FDF, GenFds will fail to find its build output. To reminder user this issue early, build tool should report failure to user in early phase. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-18BaseTools: Fix a bug for FixedPcd value generation in AutoGen fileYonghong Zhu
If the library is listed in [Components] section for build only, its used FixedPcd Value is not generated into AutoGen code. This patch cover this case to generate the FixedPcd Value in AutoGen file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-14BaseTools: Update the FV region name as upper letterYonghong Zhu
Since in the GenFds phase, the FV is generated as upper letter. This patch update the FV region name as upper letter, it can fix the build report generate failure on case sensitive file system. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Andrew Fish <afish@apple.com>
2016-07-12BaseTools/GenFds: unbreak Region.PadBufferLaszlo Ersek
In its current form, Region.PadBuffer() fills every second byte with 0x20, the default separator string of Python's string.join(): https://docs.python.org/2/library/string.html#string.join This corrupts some firmware because (a) 0x20 never corresponds to any ErasePolarity, (b) the PadData produced are actually longer than Size. Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Fixes: bd907fb6386560e621112beca7b7d381d0003967 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2016-07-12BaseTools/GenFds: speed up Region.PadBuffer()Laszlo Ersek
The current implementation calls both pack() and Buffer.write() Size times. The new implementation calls both of these methods only once; the full data to write are constructed locally [1]. The range() function is replaced by xrange() because the latter is supposed to be faster / lighter weight [2]. On my laptop, I tested the change as follows: I pre-built the series at [3] with build -a X64 -p OvmfPkg/OvmfPkgX64.dsc -t GCC48 -b DEBUG \ -D HTTP_BOOT_ENABLE -D SECURE_BOOT_ENABLE (The series at [3] is relevant because it increases the size of one of the padded regions by 8.5 MB, slowing down the build quite a bit.) With all source code already compiled, repeating the above command takes approximately 45 seconds. With the patch applied, it goes down to 29 seconds. [1] http://stackoverflow.com/questions/27384093/fastest-way-to-write-huge-data-in-file [2] https://docs.python.org/2/library/functions.html?highlight=xrange#xrange [3] http://thread.gmane.org/gmane.comp.bios.edk2.devel/14214 We can also measure the impact with a synthetic test: > import timeit > > test_old = """ > import struct, string, StringIO > Size = (8 * 1024 + 512) * 1024 > Buffer = StringIO.StringIO() > PadData = 0xFF > for i in range(0, Size): > Buffer.write(struct.pack('B', PadData)) > """ > > test_new = """ > import struct, string, StringIO > Size = (8 * 1024 + 512) * 1024 > Buffer = StringIO.StringIO() > PadByte = struct.pack('B', 0xFF) > PadData = string.join(PadByte for i in xrange(0, Size)) > Buffer.write(PadData) > """ > > print(timeit.repeat(stmt=test_old, number=1, repeat=3)) > print(timeit.repeat(stmt=test_new, number=1, repeat=3)) The output is [8.231637001037598, 8.81188416481018, 8.948754072189331] [0.5503702163696289, 0.5461571216583252, 0.578315019607544] Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2016-07-12BaseTools/GenFds: factor out Region.PadBuffer() methodLaszlo Ersek
The same logic is used in five places; factor it out to a common method. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com>