From nobody Sun Apr 28 21:29:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1511964155030223.8637467348343; Wed, 29 Nov 2017 06:02:35 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A720A20359E8C; Wed, 29 Nov 2017 05:58:08 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 51AE7203564DB for ; Wed, 29 Nov 2017 05:58:07 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2017 06:02:11 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2017 06:02:11 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,473,1505804400"; d="scan'208";a="154377135" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Wed, 29 Nov 2017 22:02:03 +0800 Message-Id: <1511964126-6716-2-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> References: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> Subject: [edk2] [Patch 1/4 V3] BaseTools: GenFfs support to get alignment value from SectionFile X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update GenFfs tool to get alignment value from SectionFile when use the new option -n 0. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Reviewed-by: Liming Gao --- BaseTools/Source/C/GenFfs/GenFfs.c | 135 +++++++++++++++++++++++++++++++++= +++- 1 file changed, 132 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs= /GenFfs.c index cb16f38..e2fb3e0 100644 --- a/BaseTools/Source/C/GenFfs/GenFfs.c +++ b/BaseTools/Source/C/GenFfs/GenFfs.c @@ -10,10 +10,17 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, = =20 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLI= ED. =20 =20 **/ =20 +#ifndef __GNUC__ +#include +#include +#include +#include +#endif + #include #include #include =20 #include @@ -22,10 +29,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. #include =20 #include "CommonLib.h" #include "ParseInf.h" #include "EfiUtilityMsgs.h" +#include "FvLib.h" +#include "PeCoffLib.h" =20 #define UTILITY_NAME "GenFfs" #define UTILITY_MAJOR_VERSION 0 #define UTILITY_MINOR_VERSION 1 =20 @@ -151,12 +160,14 @@ Returns: 128K,256K,512K,1M,2M,4M,8M,16M\n"); fprintf (stdout, " -i SectionFile, --sectionfile SectionFile\n\ Section file will be contained in this FFS file.\n= "); fprintf (stdout, " -n SectionAlign, --sectionalign SectionAlign\n\ SectionAlign points to section alignment, which su= pport\n\ - the alignment scope 1~16M. It is specified togethe= r\n\ - with sectionfile to point its alignment in FFS fil= e.\n"); + the alignment scope 0~16M. If SectionAlign is spec= ified\n\ + as 0, tool get alignment value from SectionFile. I= t is\n\ + specified together with sectionfile to point its\n\ + alignment in FFS file.\n"); fprintf (stdout, " -v, --verbose Turn on verbose output with in= formational messages.\n"); fprintf (stdout, " -q, --quiet Disable all messages except ke= y message and fatal error\n"); fprintf (stdout, " -d, --debug level Enable debug messages, at inpu= t debug level.\n"); fprintf (stdout, " --version Show program's version number = and exit.\n"); fprintf (stdout, " -h, --help Show this help message and exi= t.\n"); @@ -455,10 +466,106 @@ Returns: *BufferLength =3D Size; return EFI_SUCCESS; } } =20 +EFI_STATUS +FfsRebaseImageRead ( + IN VOID *FileHandle, + IN UINTN FileOffset, + IN OUT UINT32 *ReadSize, + OUT VOID *Buffer + ) + /*++ + + Routine Description: + + Support routine for the PE/COFF Loader that reads a buffer from a PE/C= OFF file + + Arguments: + + FileHandle - The handle to the PE/COFF file + + FileOffset - The offset, in bytes, into the file to read + + ReadSize - The number of bytes to read from the file starting at File= Offset + + Buffer - A pointer to the buffer to read the data into. + + Returns: + + EFI_SUCCESS - ReadSize bytes of data were read into Buffer from the PE/= COFF file starting at FileOffset + + --*/ +{ + CHAR8 *Destination8; + CHAR8 *Source8; + UINT32 Length; + + Destination8 =3D Buffer; + Source8 =3D (CHAR8 *) ((UINTN) FileHandle + FileOffset); + Length =3D *ReadSize; + while (Length--) { + *(Destination8++) =3D *(Source8++); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + /*++ + InFile is input file for getting alignment + return the alignment + --*/ +{ + FILE *InFileHandle; + UINT8 *PeFileBuffer; + UINTN PeFileSize; + UINT32 CurSecHdrSize; + PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; + EFI_COMMON_SECTION_HEADER *CommonHeader; + EFI_STATUS Status; + + InFileHandle =3D NULL; + PeFileBuffer =3D NULL; + + memset (&ImageContext, 0, sizeof (ImageContext)); + + InFileHandle =3D fopen(LongFilePath(InFile), "rb"); + if (InFileHandle =3D=3D NULL){ + Error (NULL, 0, 0001, "Error opening file", InFile); + return EFI_ABORTED; + } + PeFileSize =3D _filelength (fileno(InFileHandle)); + PeFileBuffer =3D (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer =3D=3D NULL) { + fclose (InFileHandle); + Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", = InFileHandle); + return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); + fclose (InFileHandle); + CommonHeader =3D (EFI_COMMON_SECTION_HEADER *) PeFileBuffer; + CurSecHdrSize =3D GetSectionHeaderLength(CommonHeader); + ImageContext.Handle =3D (VOID *) ((UINTN)PeFileBuffer + CurSecHdrSize); + ImageContext.ImageRead =3D (PE_COFF_LOADER_READ_FILE)FfsRebaseImageRead; + Status =3D PeCoffLoaderGetImageInfo(&ImageContext); + if (EFI_ERROR (Status)) { + Error (NULL, 0, 3000, "Invalid PeImage", "The input file is %s and ret= urn status is %x", InFile, (int) Status); + return Status; + } + *Alignment =3D ImageContext.SectionAlignment; + // Free the allocated memory resource + if (PeFileBuffer !=3D NULL) { + free (PeFileBuffer); + PeFileBuffer =3D NULL; + } + return EFI_SUCCESS; +} + int main ( int argc, CHAR8 *argv[] ) @@ -495,10 +602,12 @@ Returns: FILE *FfsFile; UINT32 Index; UINT64 LogLevel; UINT8 PeSectionNum; UINT32 HeaderSize; + UINT32 Alignment; + CHAR8 AlignmentBuffer[8]; =20 // // Init local variables // LogLevel =3D 0; @@ -688,11 +797,31 @@ Returns: =20 // // Section File alignment requirement // if ((stricmp (argv[0], "-n") =3D=3D 0) || (stricmp (argv[0], "--sect= ionalign") =3D=3D 0)) { - Status =3D StringtoAlignment (argv[1], &(InputFileAlign[InputFileN= um])); + if ((argv[1] !=3D NULL) && (stricmp("0", argv[1]) =3D=3D 0)) { + Status =3D GetAlignmentFromFile(InputFileName[InputFileNum], &Al= ignment); + if (EFI_ERROR(Status)) { + Error (NULL, 0, 1003, "Fail to get Alignment from %s", InputFi= leName[InputFileNum]); + goto Finish; + } + if (Alignment < 0x400){ + sprintf (AlignmentBuffer, "%d", Alignment); + } + else if (Alignment >=3D 0x400) { + if (Alignment >=3D 0x100000) { + sprintf (AlignmentBuffer, "%dM", Alignment/0x100000); + } else { + sprintf (AlignmentBuffer, "%dK", Alignment/0x400); + } + } + Status =3D StringtoAlignment (AlignmentBuffer, &(InputFileAlign[= InputFileNum])); + } + else { + Status =3D StringtoAlignment (argv[1], &(InputFileAlign[InputFil= eNum])); + } if (EFI_ERROR (Status)) { Error (NULL, 0, 1003, "Invalid option value", "%s =3D %s", argv[= 0], argv[1]); goto Finish; } argc -=3D 2; --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 21:29:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1511964156093151.74800523464387; Wed, 29 Nov 2017 06:02:36 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E317420359E97; Wed, 29 Nov 2017 05:58:10 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6903B203564DC for ; Wed, 29 Nov 2017 05:58:08 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2017 06:02:13 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2017 06:02:12 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,473,1505804400"; d="scan'208";a="154377150" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Wed, 29 Nov 2017 22:02:04 +0800 Message-Id: <1511964126-6716-3-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> References: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> Subject: [edk2] [Patch 2/4 V3] BaseTools: Update Trim to generate VfrBinOffset Binary X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Its usage is "Trim --Vfr-Uni-Offset -o $(OUTPUT_DIR)(+)$(MODULE_NAME)VfrOffset.sec --ModuleName=3D$(MODULE_NAME) --DebugDir=3D$(DEBUG_DIR)" Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Reviewed-by: Liming Gao --- BaseTools/Source/Python/Trim/Trim.py | 81 ++++++++++++++++++++++++++++++++= ++-- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/Trim/Trim.py b/BaseTools/Source/Python= /Trim/Trim.py index 9ccc027..d1e40b0 100644 --- a/BaseTools/Source/Python/Trim/Trim.py +++ b/BaseTools/Source/Python/Trim/Trim.py @@ -1,9 +1,9 @@ ## @file # Trim files preprocessed by compiler # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e found at # http://opensource.org/licenses/bsd-license.php # @@ -15,10 +15,11 @@ # Import Modules # import Common.LongFilePathOs as os import sys import re +import StringIO =20 from optparse import OptionParser from optparse import make_option from Common.BuildToolError import * from Common.Misc import * @@ -27,11 +28,11 @@ import Common.EdkLogger as EdkLogger from Common.LongFilePathSupport import OpenLongFilePath as open =20 # Version and Copyright __version_number__ =3D ("0.10" + " " + gBUILD_VERSION) __version__ =3D "%prog Version " + __version_number__ -__copyright__ =3D "Copyright (c) 2007-2016, Intel Corporation. All rights = reserved." +__copyright__ =3D "Copyright (c) 2007-2017, Intel Corporation. All rights = reserved." =20 ## Regular expression for matching Line Control directive like "#line xxx" gLineControlDirective =3D re.compile('^\s*#(?:line)?\s+([0-9]+)\s+"*([^"]*= )"') ## Regular expression for matching "typedef struct" gTypedefPattern =3D re.compile("^\s*typedef\s+struct(\s+\w+)?\s*[{]*$", re= .MULTILINE) @@ -428,10 +429,72 @@ def TrimAslFile(Source, Target, IncludePathFile): EdkLogger.error("Trim", FILE_OPEN_FAILURE, ExtraData=3DTarget) =20 f.writelines(Lines) f.close() =20 +def GenerateVfrBinSec(ModuleName, DebugDir, OutputFile): + VfrNameList =3D [] + if os.path.isdir(DebugDir): + for CurrentDir, Dirs, Files in os.walk(DebugDir): + for FileName in Files: + Name, Ext =3D os.path.splitext(FileName) + if Ext =3D=3D '.lst': + VfrNameList.append (Name + 'Bin') + + VfrNameList.append (ModuleName + 'Strings') + + EfiFileName =3D os.path.join(DebugDir, ModuleName + '.efi') + MapFileName =3D os.path.join(DebugDir, ModuleName + '.map') + VfrUniOffsetList =3D GetVariableOffset(MapFileName, EfiFileName, VfrNa= meList) + + if not VfrUniOffsetList: + return + + try: + fInputfile =3D open(OutputFile, "wb+", 0) + except: + EdkLogger.error("Trim", FILE_OPEN_FAILURE, "File open failed for %= s" %OutputFile, None) + + # Use a instance of StringIO to cache data + fStringIO =3D StringIO.StringIO('') + + for Item in VfrUniOffsetList: + if (Item[0].find("Strings") !=3D -1): + # + # UNI offset in image. + # GUID + Offset + # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89= , 0xfc, 0x6, 0x66 } } + # + UniGuid =3D [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0= x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66] + UniGuid =3D [chr(ItemGuid) for ItemGuid in UniGuid] + fStringIO.write(''.join(UniGuid)) + UniValue =3D pack ('Q', int (Item[1], 16)) + fStringIO.write (UniValue) + else: + # + # VFR binary offset in image. + # GUID + Offset + # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46,= 0xda, 0x6, 0xa2 } }; + # + VfrGuid =3D [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0= xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2] + VfrGuid =3D [chr(ItemGuid) for ItemGuid in VfrGuid] + fStringIO.write(''.join(VfrGuid)) + type (Item[1]) + VfrValue =3D pack ('Q', int (Item[1], 16)) + fStringIO.write (VfrValue) + + # + # write data into file. + # + try : + fInputfile.write (fStringIO.getvalue()) + except: + EdkLogger.error("Trim", FILE_WRITE_FAILURE, "Write data to file %s= failed, please check whether the file been locked or using by other applic= ations." %OutputFile, None) + + fStringIO.close () + fInputfile.close () + ## Trim EDK source code file(s) # # # @param Source File or directory to be trimmed # @param Target File or directory to store the trimmed content @@ -533,10 +596,12 @@ def Options(): OptionList =3D [ make_option("-s", "--source-code", dest=3D"FileType", const=3D"Sou= rceCode", action=3D"store_const", help=3D"The input file is preprocessed source co= de, including C or assembly code"), make_option("-r", "--vfr-file", dest=3D"FileType", const=3D"Vfr", = action=3D"store_const", help=3D"The input file is preprocessed VFR file"= ), + make_option("--Vfr-Uni-Offset", dest=3D"FileType", const=3D"VfrOff= setBin", action=3D"store_const", + help=3D"The input file is EFI image"), make_option("-a", "--asl-file", dest=3D"FileType", const=3D"Asl", = action=3D"store_const", help=3D"The input file is ASL file"), make_option("-8", "--Edk-source-code", dest=3D"FileType", const=3D= "EdkSourceCode", action=3D"store_const", help=3D"The input file is source code for Edk to= be trimmed for ECP"), =20 @@ -547,30 +612,38 @@ def Options(): help=3D"Remove postfix of long number"), make_option("-i", "--include-path-file", dest=3D"IncludePathFile", help=3D"The input file is include path list to s= earch for ASL include file"), make_option("-o", "--output", dest=3D"OutputFile", help=3D"File to store the trimmed content"), + make_option("--ModuleName", dest=3D"ModuleName", help=3D"The modul= e's BASE_NAME"), + make_option("--DebugDir", dest=3D"DebugDir", + help=3D"Debug Output directory to store the outp= ut files"), make_option("-v", "--verbose", dest=3D"LogLevel", action=3D"store_= const", const=3DEdkLogger.VERBOSE, help=3D"Run verbosely"), make_option("-d", "--debug", dest=3D"LogLevel", type=3D"int", help=3D"Run with debug information"), make_option("-q", "--quiet", dest=3D"LogLevel", action=3D"store_co= nst", const=3DEdkLogger.QUIET, help=3D"Run quietly"), make_option("-?", action=3D"help", help=3D"show this help message = and exit"), ] =20 # use clearer usage to override default usage message - UsageString =3D "%prog [-s|-r|-a] [-c] [-v|-d |-q] [-i ] [-o ] " + UsageString =3D "%prog [-s|-r|-a|--Vfr-Uni-Offset] [-c] [-v|-d |-q] [-i ] [-o ] [--ModuleName ] [--DebugDir ] []" =20 Parser =3D OptionParser(description=3D__copyright__, version=3D__versi= on__, option_list=3DOptionList, usage=3DUsageString) Parser.set_defaults(FileType=3D"Vfr") Parser.set_defaults(ConvertHex=3DFalse) Parser.set_defaults(LogLevel=3DEdkLogger.INFO) =20 Options, Args =3D Parser.parse_args() =20 # error check + if Options.FileType =3D=3D 'VfrOffsetBin': + if len(Args) =3D=3D 0: + return Options, '' + elif len(Args) > 1: + EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, ExtraData=3DPars= er.get_usage()) if len(Args) =3D=3D 0: EdkLogger.error("Trim", OPTION_MISSING, ExtraData=3DParser.get_usa= ge()) if len(Args) > 1: EdkLogger.error("Trim", OPTION_NOT_SUPPORTED, ExtraData=3DParser.g= et_usage()) =20 @@ -606,10 +679,12 @@ def Main(): if CommandOptions.OutputFile =3D=3D None: CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' TrimAslFile(InputFile, CommandOptions.OutputFile, CommandOptio= ns.IncludePathFile) elif CommandOptions.FileType =3D=3D "EdkSourceCode": TrimEdkSources(InputFile, CommandOptions.OutputFile) + elif CommandOptions.FileType =3D=3D "VfrOffsetBin": + GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.De= bugDir, CommandOptions.OutputFile) else : if CommandOptions.OutputFile =3D=3D None: CommandOptions.OutputFile =3D os.path.splitext(InputFile)[= 0] + '.iii' TrimPreprocessedFile(InputFile, CommandOptions.OutputFile, Com= mandOptions.ConvertHex, CommandOptions.TrimLong) except FatalError, X: --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 21:29:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1511964159008808.95943421735; Wed, 29 Nov 2017 06:02:39 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2B53820359E9A; Wed, 29 Nov 2017 05:58:11 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 12100203564DB for ; Wed, 29 Nov 2017 05:58:09 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2017 06:02:15 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2017 06:02:14 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,473,1505804400"; d="scan'208";a="154377156" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Wed, 29 Nov 2017 22:02:05 +0800 Message-Id: <1511964126-6716-4-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> References: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> Subject: [edk2] [Patch 3/4 V3] BaseTools: Update Gensec to set PROCESSING_REQUIRED value X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch add new option --dummy file, and we compare the dummpy file with input file to decide whether we need to set PROCESSING_REQUIRED value. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng Reviewed-by: Liming Gao --- BaseTools/Source/C/GenSec/GenSec.c | 74 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 74 insertions(+) diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec= /GenSec.c index d9cdc1f..904926c 100644 --- a/BaseTools/Source/C/GenSec/GenSec.c +++ b/BaseTools/Source/C/GenSec/GenSec.c @@ -185,10 +185,13 @@ Returns: used in Ver section.\n"); fprintf (stdout, " --sectionalign SectionAlign\n\ SectionAlign points to section alignment, which su= pport\n\ the alignment scope 1~16M. It is specified in same= \n\ order that the section file is input.\n"); + fprintf (stdout, " --dummy dummyfile\n\ + compare dummpyfile with input_file to decide wheth= er\n\ + need to set PROCESSING_REQUIRED attribute.\n"); fprintf (stdout, " -v, --verbose Turn on verbose output with in= formational messages.\n"); fprintf (stdout, " -q, --quiet Disable all messages except ke= y message and fatal error\n"); fprintf (stdout, " -d, --debug level Enable debug messages, at inpu= t debug level.\n"); fprintf (stdout, " --version Show program's version number = and exit.\n"); fprintf (stdout, " -h, --help Show this help message and exi= t.\n"); @@ -1026,10 +1029,17 @@ Returns: EFI_STATUS Status; UINT64 LogLevel; UINT32 *InputFileAlign; UINT32 InputFileAlignNum; EFI_COMMON_SECTION_HEADER *SectionHeader; + CHAR8 *DummyFileName; + FILE *DummyFile; + UINTN DummyFileSize; + UINT8 *DummyFileBuffer; + FILE *InFile; + UINT8 *InFileBuffer; + UINTN InFileSize; =20 InputFileAlign =3D NULL; InputFileAlignNum =3D 0; InputFileName =3D NULL; OutputFileName =3D NULL; @@ -1047,10 +1057,17 @@ Returns: Status =3D STATUS_SUCCESS; LogLevel =3D 0; SectGuidHeaderLength =3D 0; VersionSect =3D NULL; UiSect =3D NULL; + DummyFileSize =3D 0; + DummyFileName =3D NULL; + DummyFile =3D NULL; + DummyFileBuffer =3D NULL; + InFile =3D NULL; + InFileSize =3D 0; + InFileBuffer =3D NULL; =20 SetUtilityName (UTILITY_NAME); =20 if (argc =3D=3D 1) { Error (NULL, 0, 1001, "Missing options", "No options input"); @@ -1117,10 +1134,20 @@ Returns: } argc -=3D 2; argv +=3D 2; continue; } + if (stricmp (argv[0], "--dummy") =3D=3D 0) { + DummyFileName =3D argv[1]; + if (DummyFileName =3D=3D NULL) { + Error (NULL, 0, 1003, "Invalid option value", "Dummy file can't be= NULL"); + goto Finish; + } + argc -=3D 2; + argv +=3D 2; + continue; + } =20 if ((stricmp (argv[0], "-r") =3D=3D 0) || (stricmp (argv[0], "--attrib= utes") =3D=3D 0)) { if (argv[1] =3D=3D NULL) { Error (NULL, 0, 1003, "Invalid option value", "Guid section attrib= utes can't be NULL"); goto Finish; @@ -1290,10 +1317,57 @@ Returns: goto Finish; } =20 VerboseMsg ("%s tool start.", UTILITY_NAME); =20 + if (DummyFileName !=3D NULL) { + // + // Open file and read contents + // + DummyFile =3D fopen (LongFilePath (DummyFileName), "rb"); + if (DummyFile =3D=3D NULL) { + Error (NULL, 0, 0001, "Error opening file", DummyFileName); + return EFI_ABORTED; + } + + fseek (DummyFile, 0, SEEK_END); + DummyFileSize =3D ftell (DummyFile); + fseek (DummyFile, 0, SEEK_SET); + DummyFileBuffer =3D (UINT8 *) malloc (DummyFileSize); + fread(DummyFileBuffer, 1, DummyFileSize, DummyFile); + fclose(DummyFile); + DebugMsg (NULL, 0, 9, "Dummy files", "the dummy file name is %s and = the size is %u bytes", DummyFileName, (unsigned) DummyFileSize); + + InFile =3D fopen(LongFilePath(InputFileName[0]), "rb"); + if (InFile =3D=3D NULL) { + Error (NULL, 0, 0001, "Error opening file", InputFileName[0]); + return EFI_ABORTED; + } + + fseek (InFile, 0, SEEK_END); + InFileSize =3D ftell (InFile); + fseek (InFile, 0, SEEK_SET); + InFileBuffer =3D (UINT8 *) malloc (InFileSize); + fread(InFileBuffer, 1, InFileSize, InFile); + fclose(InFile); + DebugMsg (NULL, 0, 9, "Input files", "the input file name is %s and = the size is %u bytes", InputFileName[0], (unsigned) InFileSize); + if (InFileSize > DummyFileSize){ + if (stricmp(DummyFileBuffer, InFileBuffer + (InFileSize - DummyFil= eSize)) =3D=3D 0){ + SectGuidHeaderLength =3D InFileSize - DummyFileSize; + } + } + if (SectGuidHeaderLength =3D=3D 0) { + SectGuidAttribute |=3D EFI_GUIDED_SECTION_PROCESSING_REQUIRED; + } + if (DummyFileBuffer !=3D NULL) { + free (DummyFileBuffer); + } + if (InFileBuffer !=3D NULL) { + free (InFileBuffer); + } + } + // // Parse all command line parameters to get the corresponding section ty= pe. // VerboseMsg ("Section type is %s", SectionName); if (SectionName =3D=3D NULL) { --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Sun Apr 28 21:29:09 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 151196416175044.96548696104719; Wed, 29 Nov 2017 06:02:41 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6B8C421CEB124; Wed, 29 Nov 2017 05:58:11 -0800 (PST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C69E6203564DB for ; Wed, 29 Nov 2017 05:58:09 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2017 06:02:18 -0800 Received: from shwdeopenpsi168.ccr.corp.intel.com ([10.239.158.129]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2017 06:02:16 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,473,1505804400"; d="scan'208";a="154377163" From: Yonghong Zhu To: edk2-devel@lists.01.org Date: Wed, 29 Nov 2017 22:02:06 +0800 Message-Id: <1511964126-6716-5-git-send-email-yonghong.zhu@intel.com> X-Mailer: git-send-email 2.6.1.windows.1 In-Reply-To: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> References: <1511964126-6716-1-git-send-email-yonghong.zhu@intel.com> Subject: [edk2] [Patch 4/4 V3] BaseTools: Update Makefile to support FFS file generation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yunhua Feng , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Update Makefile to support FFS file generation with new build option --genfds-multi-thread. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu Signed-off-by: Yunhua Feng Reviewed-by: Liming Gao --- BaseTools/Source/Python/AutoGen/AutoGen.py | 23 ++- BaseTools/Source/Python/AutoGen/GenMake.py | 90 ++++++++- BaseTools/Source/Python/Common/GlobalData.py | 1 + BaseTools/Source/Python/GenFds/AprioriSection.py | 14 +- BaseTools/Source/Python/GenFds/CompressSection.py | 10 +- BaseTools/Source/Python/GenFds/DataSection.py | 37 ++-- BaseTools/Source/Python/GenFds/DepexSection.py | 6 +- BaseTools/Source/Python/GenFds/EfiSection.py | 78 +++++--- BaseTools/Source/Python/GenFds/Fd.py | 24 ++- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 4 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 202 ++++++++++++-----= ---- BaseTools/Source/Python/GenFds/Fv.py | 189 ++++++++++-------= -- BaseTools/Source/Python/GenFds/FvImageSection.py | 8 +- BaseTools/Source/Python/GenFds/GenFds.py | 20 ++ .../Source/Python/GenFds/GenFdsGlobalVariable.py | 174 ++++++++++++++---- BaseTools/Source/Python/GenFds/GuidSection.py | 168 +++++++++-------- .../Source/Python/GenFds/OptRomFileStatement.py | 4 +- .../Source/Python/GenFds/OptRomInfStatement.py | 12 +- BaseTools/Source/Python/GenFds/OptionRom.py | 25 +-- BaseTools/Source/Python/GenFds/Region.py | 49 +++-- BaseTools/Source/Python/GenFds/Section.py | 4 +- BaseTools/Source/Python/GenFds/UiSection.py | 5 +- BaseTools/Source/Python/GenFds/VerSection.py | 9 +- BaseTools/Source/Python/build/build.py | 48 ++++- 24 files changed, 793 insertions(+), 411 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/= Python/AutoGen/AutoGen.py index 008ad8e..1c4c395 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1305,16 +1305,19 @@ class PlatformAutoGen(AutoGen): ## Create makefile for the platform and mdoules in it # # @param CreateModuleMakeFile Flag indicating if the makefil= e for # modules will be created as well # - def CreateMakeFile(self, CreateModuleMakeFile=3DFalse): + def CreateMakeFile(self, CreateModuleMakeFile=3DFalse, FfsCommand =3D = {}): if CreateModuleMakeFile: for ModuleFile in self.Platform.Modules: Ma =3D ModuleAutoGen(self.Workspace, ModuleFile, self.Buil= dTarget, self.ToolChain, self.Arch, self.MetaFil= e) - Ma.CreateMakeFile(True) + if (ModuleFile.File, self.Arch) in FfsCommand: + Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, se= lf.Arch]) + else: + Ma.CreateMakeFile(True) #Ma.CreateAsBuiltInf() =20 # no need to create makefile for the platform more than once if self.IsMakeFileCreated: return @@ -2758,10 +2761,11 @@ class ModuleAutoGen(AutoGen): self._CustomMakefile =3D None self._Macro =3D None =20 self._BuildDir =3D None self._OutputDir =3D None + self._FfsOutputDir =3D None self._DebugDir =3D None self._MakeFileDir =3D None =20 self._IncludePathList =3D None self._IncludePathLength =3D 0 @@ -2874,10 +2878,11 @@ class ModuleAutoGen(AutoGen): self._Macro["PLATFORM_GUID" ] =3D self.PlatformInfo.Gu= id self._Macro["PLATFORM_VERSION" ] =3D self.PlatformInfo.Ve= rsion self._Macro["PLATFORM_RELATIVE_DIR" ] =3D self.PlatformInfo.So= urceDir self._Macro["PLATFORM_DIR" ] =3D mws.join(self.Worksp= aceDir, self.PlatformInfo.SourceDir) self._Macro["PLATFORM_OUTPUT_DIR" ] =3D self.PlatformInfo.Ou= tputDir + self._Macro["FFS_OUTPUT_DIR" ] =3D self.FfsOutputDir return self._Macro =20 ## Return the module build data object def _GetModule(self): if self._Module =3D=3D None: @@ -2964,10 +2969,19 @@ class ModuleAutoGen(AutoGen): if self._OutputDir =3D=3D None: self._OutputDir =3D path.join(self.BuildDir, "OUTPUT") CreateDirectory(self._OutputDir) return self._OutputDir =20 + ## Return the directory to store ffs file + def _GetFfsOutputDir(self): + if self._FfsOutputDir =3D=3D None: + if GlobalData.gFdfParser !=3D None: + self._FfsOutputDir =3D path.join(self.PlatformInfo.BuildDi= r, "FV", "Ffs", self.Guid + self.Name) + else: + self._FfsOutputDir =3D '' + return self._FfsOutputDir + ## Return the directory to store auto-gened source files of the mdoule def _GetDebugDir(self): if self._DebugDir =3D=3D None: self._DebugDir =3D path.join(self.BuildDir, "DEBUG") CreateDirectory(self._DebugDir) @@ -4220,18 +4234,18 @@ class ModuleAutoGen(AutoGen): ## Create makefile for the module and its dependent libraries # # @param CreateLibraryMakeFile Flag indicating if or not the = makefiles of # dependent libraries will be cr= eated # - def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue): + def CreateMakeFile(self, CreateLibraryMakeFile=3DTrue, GenFfsList =3D = []): # Ignore generating makefile when it is a binary module if self.IsBinaryModule: return =20 if self.IsMakeFileCreated: return - + self.GenFfsList =3D GenFfsList if not self.IsLibrary and CreateLibraryMakeFile: for LibraryAutoGen in self.LibraryAutoGenList: LibraryAutoGen.CreateMakeFile() =20 if self.CanSkip(): @@ -4455,10 +4469,11 @@ class ModuleAutoGen(AutoGen): =20 IsLibrary =3D property(_IsLibrary) IsBinaryModule =3D property(_IsBinaryModule) BuildDir =3D property(_GetBuildDir) OutputDir =3D property(_GetOutputDir) + FfsOutputDir =3D property(_GetFfsOutputDir) DebugDir =3D property(_GetDebugDir) MakeFileDir =3D property(_GetMakeFileDir) CustomMakefile =3D property(_GetCustomMakefile) =20 IncludePathList =3D property(_GetIncludePathList) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 942eb44..2abfdb3 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -141,10 +141,15 @@ class BuildFile(object): ## directory removal template _RD_TEMPLATE_ =3D { "nmake" : 'if exist %(dir)s $(RD) %(dir)s', "gmake" : "$(RD) %(dir)s" } + ## cp if exist + _CP_TEMPLATE_ =3D { + "nmake" : 'if exist %(Src)s $(CP) %(Src)s %(Dst)s', + "gmake" : "test -f %(Src)s && $(CP) %(Src)s %(Dst)s" + } =20 _CD_TEMPLATE_ =3D { "nmake" : 'if exist %(dir)s cd %(dir)s', "gmake" : "test -e %(dir)s && cd %(dir)s" } @@ -209,10 +214,12 @@ class BuildFile(object): else: PathLength =3D len(Path) for MacroName in MacroDefinitions: MacroValue =3D MacroDefinitions[MacroName] MacroValueLength =3D len(MacroValue) + if MacroValueLength =3D=3D 0: + continue if MacroValueLength <=3D PathLength and Path.startswith(Ma= croValue): Path =3D "$(%s)%s" % (MacroName, Path[MacroValueLength= :]) break return Path =20 @@ -248,10 +255,11 @@ MODULE_FILE =3D ${module_file} MODULE_FILE_BASE_NAME =3D ${module_file_base_name} BASE_NAME =3D $(MODULE_NAME) MODULE_RELATIVE_DIR =3D ${module_relative_directory} PACKAGE_RELATIVE_DIR =3D ${package_relative_directory} MODULE_DIR =3D ${module_dir} +FFS_OUTPUT_DIR =3D ${ffs_output_directory} =20 MODULE_ENTRY_POINT =3D ${module_entry_point} ARCH_ENTRY_POINT =3D ${arch_entry_point} IMAGE_ENTRY_POINT =3D ${image_entry_point} =20 @@ -439,10 +447,14 @@ cleanlib: self.Macros["DEBUG_DIR" ] =3D self._AutoGenObject.Macros["DE= BUG_DIR"] self.Macros["MODULE_BUILD_DIR"] =3D self._AutoGenObject.Macros["MO= DULE_BUILD_DIR"] self.Macros["BIN_DIR" ] =3D self._AutoGenObject.Macros["BI= N_DIR"] self.Macros["BUILD_DIR" ] =3D self._AutoGenObject.Macros["BU= ILD_DIR"] self.Macros["WORKSPACE" ] =3D self._AutoGenObject.Macros["WO= RKSPACE"] + self.Macros["FFS_OUTPUT_DIR" ] =3D self._AutoGenObject.Macros["FF= S_OUTPUT_DIR"] + self.GenFfsList =3D ModuleAutoGen.GenFfsList + self.MacroList =3D ['FFS_OUTPUT_DIR', 'MODULE_GUID', 'OUTPUT_DIR'] + self.FfsOutputFileList =3D [] =20 # Compose a dict object containing information used to do replacement = in template def _CreateTemplateDict(self): if self._FileType not in self._SEP_: EdkLogger.error("build", PARAMETER_INVALID, "Invalid Makefile = type [%s]" % self._FileType, @@ -553,10 +565,11 @@ cleanlib: if len(self.ResultFileList) =3D=3D 0 and len(self._AutoGenObject.S= ourceFileList) <> 0: EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build", ExtraData=3D"[%s]" % str(self._AutoGenObject)) =20 self.ProcessBuildTargetList() + self.ParserGenerateFfsCmd() =20 # Generate macros used to represent input files FileMacroList =3D [] # macro name =3D file list for FileListMacro in self.FileListMacros: FileMacro =3D self._FILE_MACRO_TEMPLATE.Replace( @@ -625,10 +638,11 @@ cleanlib: "platform_name" : self.PlatformInfo.Name, "platform_guid" : self.PlatformInfo.Guid, "platform_version" : self.PlatformInfo.Version, "platform_relative_directory": self.PlatformInfo.SourceDir, "platform_output_directory" : self.PlatformInfo.OutputDir, + "ffs_output_directory" : self._AutoGenObject.Macros["FFS_= OUTPUT_DIR"], "platform_dir" : self._AutoGenObject.Macros["PLAT= FORM_DIR"], =20 "module_name" : self._AutoGenObject.Name, "module_guid" : self._AutoGenObject.Guid, "module_name_guid" : self._AutoGenObject._GetUniqueBa= seName(), @@ -671,10 +685,83 @@ cleanlib: "backward_compatible_target": BcTargetList, } =20 return MakefileTemplateDict =20 + def ParserGenerateFfsCmd(self): + #Add Ffs cmd to self.BuildTargetList + OutputFile =3D '' + DepsFileList =3D [] + + for Cmd in self.GenFfsList: + if Cmd[2]: + for CopyCmd in Cmd[2]: + Src, Dst =3D CopyCmd + Src =3D self.ReplaceMacro(Src) + Dst =3D self.ReplaceMacro(Dst) + if Dst not in self.ResultFileList: + self.ResultFileList.append('%s' % Dst) + if '%s :' %(Dst) not in self.BuildTargetList: + self.BuildTargetList.append("%s :" %(Dst)) + self.BuildTargetList.append('\t' + self._CP_TEMPLA= TE_[self._FileType] %{'Src': Src, 'Dst': Dst}) + + FfsCmdList =3D Cmd[0] + for index, Str in enumerate(FfsCmdList): + if '-o' =3D=3D Str: + OutputFile =3D FfsCmdList[index + 1] + if '-i' =3D=3D Str: + if DepsFileList =3D=3D []: + DepsFileList =3D [FfsCmdList[index + 1]] + else: + DepsFileList.append(FfsCmdList[index + 1]) + DepsFileString =3D ' '.join(DepsFileList).strip() + if DepsFileString =3D=3D '': + continue + OutputFile =3D self.ReplaceMacro(OutputFile) + self.ResultFileList.append('%s' % OutputFile) + DepsFileString =3D self.ReplaceMacro(DepsFileString) + self.BuildTargetList.append('%s : %s' % (OutputFile, DepsFileS= tring)) + CmdString =3D ' '.join(FfsCmdList).strip() + CmdString =3D self.ReplaceMacro(CmdString) + self.BuildTargetList.append('\t%s' % CmdString) + + self.ParseSecCmd(DepsFileList, Cmd[1]) + for SecOutputFile, SecDepsFile, SecCmd in self.FfsOutputFileLi= st : + self.BuildTargetList.append('%s : %s' % (self.ReplaceMacro= (SecOutputFile), self.ReplaceMacro(SecDepsFile))) + self.BuildTargetList.append('\t%s' % self.ReplaceMacro(Sec= Cmd)) + self.FfsOutputFileList =3D [] + + def ParseSecCmd(self, OutputFileList, CmdTuple): + for OutputFile in OutputFileList: + for SecCmdStr in CmdTuple: + SecDepsFileList =3D [] + SecCmdList =3D SecCmdStr.split() + CmdName =3D SecCmdList[0] + for index, CmdItem in enumerate(SecCmdList): + if '-o' =3D=3D CmdItem and OutputFile =3D=3D SecCmdLis= t[index + 1]: + index =3D index + 1 + while index + 1 < len(SecCmdList): + if not SecCmdList[index+1].startswith('-'): + SecDepsFileList.append(SecCmdList[index + = 1]) + index =3D index + 1 + if CmdName =3D=3D 'Trim': + SecDepsFileList.append(os.path.join('$(DEBUG_D= IR)', os.path.basename(OutputFile).replace('offset', 'efi'))) + if OutputFile.endswith('.ui') or OutputFile.endswi= th('.ver'): + SecDepsFileList.append(os.path.join('$(MODULE_= DIR)','$(MODULE_FILE)')) + self.FfsOutputFileList.append((OutputFile, ' '.joi= n(SecDepsFileList), SecCmdStr)) + if len(SecDepsFileList) > 0: + self.ParseSecCmd(SecDepsFileList, CmdTuple) + break + else: + continue + + def ReplaceMacro(self, str): + for Macro in self.MacroList: + if self._AutoGenObject.Macros[Macro] and self._AutoGenObject.M= acros[Macro] in str: + str =3D str.replace(self._AutoGenObject.Macros[Macro], '$(= ' + Macro + ')') + return str + def CommandExceedLimit(self): FlagDict =3D { 'CC' : { 'Macro' : '$(CC_FLAGS)', 'Value' : Fal= se}, 'PP' : { 'Macro' : '$(PP_FLAGS)', 'Value' : Fal= se}, 'APP' : { 'Macro' : '$(APP_FLAGS)', 'Value' : Fal= se}, @@ -1451,11 +1538,12 @@ class TopLevelMakefile(BuildFile): elif LogLevel =3D=3D EdkLogger.QUIET: ExtraOption +=3D " -q" =20 if GlobalData.gCaseInsensitive: ExtraOption +=3D " -c" - + if GlobalData.gEnableGenfdsMultiThread: + ExtraOption +=3D " --genfds-multi-thread" if GlobalData.gIgnoreSource: ExtraOption +=3D " --ignore-sources" =20 if GlobalData.BuildOptionPcd: for index, option in enumerate(GlobalData.gCommand): diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index e348e9a..8b7562d 100644 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -93,5 +93,6 @@ gUseHashCache =3D None gBinCacheDest =3D None gBinCacheSource =3D None gPlatformHash =3D None gPackageHash =3D {} gModuleHash =3D {} +gEnableGenfdsMultiThread =3D False diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/S= ource/Python/GenFds/AprioriSection.py index a2306d0..70e2e5a 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -1,9 +1,9 @@ ## @file # process APRIORI file data and generate PEI/DXE APRIORI file # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -45,11 +45,11 @@ class AprioriSection (AprioriSectionClassObject): # @param self The object pointer # @param FvName for whom apriori file generated # @param Dict dictionary contains macro and its value # @retval string Generated file name # - def GenFfs (self, FvName, Dict =3D {}): + def GenFfs (self, FvName, Dict =3D {}, IsMakefile =3D False): DXE_GUID =3D "FC510EE7-FFDC-11D4-BD41-0080C73C8881" PEI_GUID =3D "1B45CC0A-156A-428A-AF62-49864DA0E6E6" Buffer =3D StringIO.StringIO('') AprioriFileGuid =3D DXE_GUID if self.AprioriType =3D=3D "PEI": @@ -64,10 +64,11 @@ class AprioriSection (AprioriSectionClassObject): AprioriFileGuid + FvName + '.Apri' ) AprFfsFileName =3D os.path.join (OutputAprFilePath,\ AprioriFileGuid + FvName + '.Ffs') =20 Dict.update(self.DefineVarDict) + InfFileName =3D None for FfsObj in self.FfsList : Guid =3D "" if isinstance(FfsObj, FfsFileStatement.FileStatement): Guid =3D FfsObj.NameGuid else: @@ -108,11 +109,16 @@ class AprioriSection (AprioriSectionClassObject): =20 SaveFileOnChange(OutputAprFileName, Buffer.getvalue()) =20 RawSectionFileName =3D os.path.join( OutputAprFilePath, \ AprioriFileGuid + FvName + '.raw' ) - GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAp= rFileName], 'EFI_SECTION_RAW') + MakefilePath =3D None + if IsMakefile: + if not InfFileName: + return None + MakefilePath =3D InfFileName, Arch + GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAp= rFileName], 'EFI_SECTION_RAW', IsMakefile=3DIsMakefile) GenFdsGlobalVariable.GenerateFfs(AprFfsFileName, [RawSectionFileNa= me], - 'EFI_FV_FILETYPE_FREEFORM', Aprio= riFileGuid) + 'EFI_FV_FILETYPE_FREEFORM', Aprior= iFileGuid, MakefilePath=3DMakefilePath) =20 return AprFfsFileName =20 diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/= Source/Python/GenFds/CompressSection.py index fac58d1..64ad275 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -1,9 +1,9 @@ ## @file # process compress section generation # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -51,25 +51,25 @@ class CompressSection (CompressSectionClassObject) : # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False): =20 if FfsInf !=3D None: self.CompType =3D FfsInf.__ExtendMacro__(self.CompType) self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) =20 SectFiles =3D tuple() Index =3D 0 for Sect in self.SectionList: Index =3D Index + 1 SecIndex =3D '%s.%d' %(SecNum, Index) - ReturnSectList, AlignValue =3D Sect.GenSection(OutputPath, Mod= uleName, SecIndex, KeyStringList, FfsInf, Dict) + ReturnSectList, AlignValue =3D Sect.GenSection(OutputPath, Mod= uleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) if ReturnSectList !=3D []: for FileData in ReturnSectList: - SectFiles +=3D (FileData,) + SectFiles +=3D (FileData,) =20 =20 OutputFile =3D OutputPath + \ os.sep + \ ModuleName + \ @@ -77,11 +77,11 @@ class CompressSection (CompressSectionClassObject) : SecNum + \ Ffs.SectionSuffix['COMPRESS'] OutputFile =3D os.path.normpath(OutputFile) =20 GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Sectio= n.Section.SectionType['COMPRESS'], - CompressionType=3Dself.CompTy= peDict[self.CompType]) + CompressionType=3Dself.CompTy= peDict[self.CompType], IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment =20 =20 diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Sour= ce/Python/GenFds/DataSection.py index 78c0af4..2d2975f 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -46,11 +46,11 @@ class DataSection (DataSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsFile !=3D None: self.SectFileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMac= ro(self.SectFileName) @@ -67,14 +67,20 @@ class DataSection (DataSectionClassObject): =20 """Copy Map file to Ffs output""" Filename =3D GenFdsGlobalVariable.MacroExtend(self.SectFileName) if Filename[(len(Filename)-4):] =3D=3D '.efi': MapFile =3D Filename.replace('.efi', '.map') - if os.path.exists(MapFile): - CopyMapFile =3D os.path.join(OutputPath, ModuleName + '.ma= p') - if not os.path.exists(CopyMapFile) or (os.path.getmtime(Ma= pFile) > os.path.getmtime(CopyMapFile)): - CopyLongFilePath(MapFile, CopyMapFile) + CopyMapFile =3D os.path.join(OutputPath, ModuleName + '.map') + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(MapFile, CopyMapFi= le)] + else: + GenFdsGlobalVariable.CopyList.append((MapFile, CopyMap= File)) + else: + if os.path.exists(MapFile): + if not os.path.exists(CopyMapFile) or (os.path.getmtim= e(MapFile) > os.path.getmtime(CopyMapFile)): + CopyLongFilePath(MapFile, CopyMapFile) =20 #Get PE Section alignment when align is set to AUTO if self.Alignment =3D=3D 'Auto' and self.SecType in ('TE', 'PE32'): ImageObj =3D PeImageClass (Filename) if ImageObj.SectionAlignment < 0x400: @@ -94,26 +100,27 @@ class DataSection (DataSectionClassObject): if not os.path.exists(FileBeforeStrip) or \ (os.path.getmtime(self.SectFileName) > os.path.getmtime(Fi= leBeforeStrip)): CopyLongFilePath(self.SectFileName, FileBeforeStrip) StrippedFile =3D os.path.join(OutputPath, ModuleName + '.strip= ped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenFdsGlobalVariable.MacroExtend(self= .SectFileName, Dict)], - Strip=3DTrue - ) + StrippedFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], + Strip=3DTrue, + IsMakefile =3D IsMakefile + ) self.SectFileName =3D StrippedFile =20 if self.SecType =3D=3D 'TE': TeFile =3D os.path.join( OutputPath, ModuleName + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenFdsGlobalVariable.MacroExtend(self= .SectFileName, Dict)], - Type=3D'te' - ) + TeFile, + [GenFdsGlobalVariable.MacroExtend(self.SectFileName, D= ict)], + Type=3D'te', + IsMakefile =3D IsMakefile + ) self.SectFileName =3D TeFile =20 OutputFile =3D os.path.join (OutputPath, ModuleName + 'SEC' + SecN= um + Ffs.SectionSuffix.get(self.SecType)) OutputFile =3D os.path.normpath(OutputFile) - - GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], Section.Section.SectionType.get(self.SecType)) + GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileNam= e], Section.Section.SectionType.get(self.SecType), IsMakefile =3D IsMakefil= e) FileList =3D [OutputFile] return FileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Sou= rce/Python/GenFds/DepexSection.py index 8f78c0f..1992d2a 100644 --- a/BaseTools/Source/Python/GenFds/DepexSection.py +++ b/BaseTools/Source/Python/GenFds/DepexSection.py @@ -1,9 +1,9 @@ ## @file # process depex section generation # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -74,11 +74,11 @@ class DepexSection (DepexSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, Ff= sFile =3D None, Dict =3D {}, IsMakefile =3D False): =20 if self.ExpressionProcessed =3D=3D False: self.Expression =3D self.Expression.replace("\n", " ").replace= ("\r", " ") ExpList =3D self.Expression.split() ExpGuidDict =3D {} @@ -117,8 +117,8 @@ class DepexSection (DepexSectionClassObject): Depex.Generate(InputFile) =20 OutputFile =3D os.path.join (OutputPath, ModuleName + 'SEC' + SecN= um + '.dpx') OutputFile =3D os.path.normpath(OutputFile) =20 - GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Sect= ion.Section.SectionType.get (SecType)) + GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Sect= ion.Section.SectionType.get (SecType), IsMakefile=3DIsMakefile) FileList =3D [OutputFile] return FileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Sourc= e/Python/GenFds/EfiSection.py index 7da3c1e..7b3b717 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -51,11 +51,11 @@ class EfiSection (EfiSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name list, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}) : + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False) : =20 if self.FileName !=3D None and self.FileName.startswith('PCD('): self.FileName =3D GenFdsGlobalVariable.GetPcdValue(self.FileNa= me) """Prepare the parameter of GenSection""" if FfsInf !=3D None : @@ -89,10 +89,12 @@ class EfiSection (EfiSectionClassObject): =20 if not self.Optional: FileList.append(Filename) elif os.path.exists(Filename): FileList.append(Filename) + elif '.depex' in FfsInf.FinalTargetSuffixMap or FfsInf.Depex: + FileList.append(Filename) else: FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FileType, self.FileExtension, Dict) if IsSect : return FileList, self.Alignment =20 @@ -117,12 +119,13 @@ class EfiSection (EfiSectionClassObject): BuildNumTuple =3D tuple() =20 Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DStringData,=20 - Ver=3DBuildNum) + #Ui=3DStringData, + Ver=3DBuildNum, + IsMakefile=3DIsMakefil= e) OutputFileList.append(OutputFile) =20 elif FileList !=3D []: for File in FileList: Index =3D Index + 1 @@ -133,12 +136,13 @@ class EfiSection (EfiSectionClassObject): f.close() BuildNum =3D VerString if BuildNum !=3D None and BuildNum !=3D '': BuildNumTuple =3D ('-j', BuildNum) GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_VERSION', - #Ui=3DVerString,=20 - Ver=3DBuildNum) + #Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMak= efile) OutputFileList.append(OutputFile) =20 else: BuildNum =3D StringData if BuildNum !=3D None and BuildNum !=3D '': @@ -155,12 +159,13 @@ class EfiSection (EfiSectionClassObject): else: EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss Version Section value" %InfFileName) Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_VERSION', - #Ui=3DVerString,=20 - Ver=3DBuildNum) + #Ui=3DVerString, + Ver=3DBuildNum, + IsMakefile=3DIsMakefil= e) OutputFileList.append(OutputFile) =20 # # If Section Type is 'UI' # @@ -173,11 +178,11 @@ class EfiSection (EfiSectionClassObject): =20 if InfOverrideUiString: Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', - Ui=3DStringData) + Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 elif FileList !=3D []: for File in FileList: Index =3D Index + 1 @@ -185,11 +190,11 @@ class EfiSection (EfiSectionClassObject): OutputFile =3D os.path.join(OutputPath, ModuleName + '= SEC' + Num + Ffs.SectionSuffix.get(SectionType)) f =3D open(File, 'r') UiString =3D f.read() f.close() GenFdsGlobalVariable.GenerateSection(OutputFile, [], '= EFI_SECTION_USER_INTERFACE', - Ui=3DUiString) + Ui=3DUiString, IsM= akefile=3DIsMakefile) OutputFileList.append(OutputFile) else: if StringData !=3D None and len(StringData) > 0: UiTuple =3D ('-n', '"' + StringData + '"') else: @@ -202,11 +207,11 @@ class EfiSection (EfiSectionClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s = miss UI Section value" %InfFileName) =20 Num =3D SecNum OutputFile =3D os.path.join( OutputPath, ModuleName + 'SEC= ' + str(Num) + Ffs.SectionSuffix.get(SectionType)) GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_= SECTION_USER_INTERFACE', - Ui=3DStringData) + Ui=3DStringData, IsMa= kefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 =20 else: """If File List is empty""" @@ -236,43 +241,58 @@ class EfiSection (EfiSectionClassObject): else: Align =3D str (ImageObj.SectionAlignment / 0x1= 00000) + 'M' =20 if File[(len(File)-4):] =3D=3D '.efi': MapFile =3D File.replace('.efi', '.map') - if os.path.exists(MapFile): - CopyMapFile =3D os.path.join(OutputPath, Modul= eName + '.map') - if not os.path.exists(CopyMapFile) or \ - (os.path.getmtime(MapFile) > os.path.ge= tmtime(CopyMapFile)): - CopyLongFilePath(MapFile, CopyMapFile) + CopyMapFile =3D os.path.join(OutputPath, ModuleNam= e + '.map') + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(MapFil= e, CopyMapFile)] + else: + GenFdsGlobalVariable.CopyList.append((MapF= ile, CopyMapFile)) + else: + if os.path.exists(MapFile): + if not os.path.exists(CopyMapFile) or \ + (os.path.getmtime(MapFile) > os.pat= h.getmtime(CopyMapFile)): + CopyLongFilePath(MapFile, CopyMapFile) =20 if not NoStrip: FileBeforeStrip =3D os.path.join(OutputPath, Modul= eName + '.efi') - if not os.path.exists(FileBeforeStrip) or \ - (os.path.getmtime(File) > os.path.getmtime(Fil= eBeforeStrip)): - CopyLongFilePath(File, FileBeforeStrip) + if IsMakefile: + if GenFdsGlobalVariable.CopyList =3D=3D []: + GenFdsGlobalVariable.CopyList =3D [(File, = FileBeforeStrip)] + else: + GenFdsGlobalVariable.CopyList.append((File= , FileBeforeStrip)) + else: + if not os.path.exists(FileBeforeStrip) or \ + (os.path.getmtime(File) > os.path.getmtime= (FileBeforeStrip)): + CopyLongFilePath(File, FileBeforeStrip) StrippedFile =3D os.path.join(OutputPath, ModuleNa= me + '.stripped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile =3D IsMakefile + ) File =3D StrippedFile =20 """For TE Section call GenFw to generate TE image""" =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( OutputPath, ModuleName + = 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te' - ) + TeFile, + [File], + Type=3D'te', + IsMakefile =3D IsMakefile + ) File =3D TeFile =20 """Call GenSection""" GenFdsGlobalVariable.GenerateSection(OutputFile, - [File], - Section.Section.S= ectionType.get (SectionType) - ) + [File], + Section.Section.Se= ctionType.get (SectionType), + IsMakefile=3DIsMak= efile + ) OutputFileList.append(OutputFile) =20 return OutputFileList, Align diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python= /GenFds/Fd.py index f330a7e..f735d3b 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -43,19 +43,20 @@ class FD(FDClassObject): # # Generate FD # # @retval string Generated FD file name # - def GenFd (self): + def GenFd (self, Flag =3D False): if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =20 # # Print Information # FdFileName =3D os.path.join(GenFdsGlobalVariable.FvDir, self.FdUiN= ame + '.fd') - GenFdsGlobalVariable.InfLogger("Fd File Name:%s (%s)" %(self.FdUiN= ame, FdFileName)) + if not Flag: + GenFdsGlobalVariable.InfLogger("\nFd File Name:%s (%s)" %(self= .FdUiName, FdFileName)) =20 Offset =3D 0x00 for item in self.BlockSizeList: Offset =3D Offset + item[0] * item[1] if Offset !=3D self.Size: @@ -83,15 +84,17 @@ class FD(FDClassObject): if RegionObj.Offset + RegionObj.Size <=3D PreviousRegionSt= art: pass elif RegionObj.Offset <=3D PreviousRegionStart or (RegionO= bj.Offset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStar= t + PreviousRegionSize): pass elif RegionObj.Offset > PreviousRegionStart + PreviousRegi= onSize: - GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionS= ize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + if not Flag: + GenFdsGlobalVariable.InfLogger('Padding region sta= rting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousReg= ionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousReg= ionSize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset - PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddress, = self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDic= t, self.DefineVarDict) + if not Flag: + PadRegion.AddToBuffer(TempFdBuffer, self.BaseAddre= ss, self.BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRa= wDict, self.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # # Call each region's AddToBuffer function # @@ -111,15 +114,17 @@ class FD(FDClassObject): elif RegionObj.Offset <=3D PreviousRegionStart or (RegionObj.O= ffset >=3DPreviousRegionStart and RegionObj.Offset < PreviousRegionStart + = PreviousRegionSize): EdkLogger.error("GenFds", GENFDS_ERROR, 'Region offset 0x%X overlaps with Region s= tarting from 0x%X, size 0x%X' \ % (RegionObj.Offset, PreviousRegionStart, = PreviousRegionSize)) elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSi= ze: - GenFdsGlobalVariable.InfLogger('Padding region starting fr= om offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize,= RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) + if not Flag: + GenFdsGlobalVariable.InfLogger('Padding region startin= g from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionS= ize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize))) PadRegion =3D Region.Region() PadRegion.Offset =3D PreviousRegionStart + PreviousRegionS= ize PadRegion.Size =3D RegionObj.Offset - PadRegion.Offset - PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.Blo= ckSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.= DefineVarDict) + if not Flag: + PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self= .BlockSizeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, s= elf.DefineVarDict) PreviousRegionStart =3D RegionObj.Offset PreviousRegionSize =3D RegionObj.Size # # Verify current region fits within allocated FD section Size # @@ -129,17 +134,18 @@ class FD(FDClassObject): % (self.FdUiName, PreviousRegionStart, Pre= viousRegionSize)) # # Call each region's AddToBuffer function # GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToB= uffer function') - RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.Def= ineVarDict) + RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockS= izeList, self.ErasePolarity, GenFds.ImageBinDict, self.vtfRawDict, self.Def= ineVarDict,Flag=3DFlag) # # Write the buffer contents to Fd file # GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to F= d file') - SaveFileOnChange(FdFileName, FdBuffer.getvalue()) - FdBuffer.close(); + if not Flag: + SaveFileOnChange(FdFileName, FdBuffer.getvalue()) + FdBuffer.close() GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] =3D FdFileName return FdFileName =20 ## generate VTF # diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools= /Source/Python/GenFds/FfsFileStatement.py index f76ddf4..edb1312 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -1,9 +1,9 @@ ## @file # process FFS generation from FILE statement # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -55,11 +55,11 @@ class FileStatement (FileStatementClassObject) : # @param Dict dictionary contains macro and value pair # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}, FvChildAddr=3D[], FvParentAddr=3DNone): + def GenFfs(self, Dict =3D {}, FvChildAddr=3D[], FvParentAddr=3DNone, I= sMakefile=3DFalse): =20 if self.NameGuid !=3D None and self.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(self.NameGuid) if len(PcdValue) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index 958cecf..4b47817 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -42,10 +42,12 @@ from Common.Misc import PeImageClass from AutoGen.GenDepex import DependencyExpression from PatchPcdValue.PatchPcdValue import PatchBinaryFile from Common.LongFilePathSupport import CopyLongFilePath from Common.LongFilePathSupport import OpenLongFilePath as open import Common.GlobalData as GlobalData +from DepexSection import DepexSection +from Common.Misc import SaveFileOnChange =20 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): @@ -70,10 +72,11 @@ class FfsInfStatement(FfsInfStatementClassObject): self.FileName =3D None self.InfFileName =3D None self.OverrideGuid =3D None self.PatchedBinFile =3D '' self.MacroDict =3D {} + self.Depex =3D False =20 ## GetFinalTargetSuffixMap() method # # Get final build target list def GetFinalTargetSuffixMap(self): @@ -318,10 +321,15 @@ class FfsInfStatement(FfsInfStatementClassObject): self.PatchPcds.append((Pcd, DefaultValue)) =20 self.InfModule =3D Inf self.PcdIsDriver =3D Inf.PcdIsDriver self.IsBinaryModule =3D Inf.IsBinaryModule + Inf._GetDepex() + Inf._GetDepexExpression() + if len(Inf._Depex.data) > 0 and len(Inf._DepexExpression.data) > 0: + self.Depex =3D True + GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName) GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" % self.Module= Guid) GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" % self.Module= Type) GenFdsGlobalVariable.VerboseLogger("VersionString : %s" % self.Ver= sionString) GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" % self.InfFil= eName) @@ -333,11 +341,11 @@ class FfsInfStatement(FfsInfStatementClassObject): self.OutputPath =3D os.path.join(GenFdsGlobalVariable.FfsDir, \ self.ModuleGuid + self.BaseName) if not os.path.exists(self.OutputPath) : os.makedirs(self.OutputPath) =20 - self.EfiOutputPath =3D self.__GetEFIOutPutPath__() + self.EfiOutputPath, self.EfiDebugPath =3D self.__GetEFIOutPutPath_= _() GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOu= tputPath) =20 ## PatchEfiFile # # Patch EFI file with patch PCD @@ -412,16 +420,17 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param Dict dictionary contains macro and value pair # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}, FvChildAddr =3D [], FvParentAddr=3DNone): + def GenFfs(self, Dict =3D {}, FvChildAddr =3D [], FvParentAddr=3DNone,= IsMakefile=3DFalse): # # Parse Inf file get Module related information # =20 self.__InfParse__(Dict) + Arch =3D self.GetCurrentArch() SrcFile =3D mws.join( GenFdsGlobalVariable.WorkSpaceDir , self.Inf= FileName); DestFile =3D os.path.join( self.OutputPath, self.ModuleGuid + '.ff= s') =20 SrcFileDir =3D "." SrcPath =3D os.path.dirname(SrcFile) @@ -449,11 +458,13 @@ class FfsInfStatement(FfsInfStatementClassObject): # Allow binary type module not specify override rule in FDF file. #=20 if len(self.BinFileList) > 0: if self.Rule =3D=3D None or self.Rule =3D=3D "": self.Rule =3D "BINARY" - =20 + + if not IsMakefile and GenFdsGlobalVariable.EnableGenfdsMultiThread= and self.Rule !=3D 'BINARY': + IsMakefile =3D True # # Get the rule of how to generate Ffs file # Rule =3D self.__GetRule__() GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf fil= e : %s" %self.InfFileName) @@ -470,21 +481,23 @@ class FfsInfStatement(FfsInfStatementClassObject): if Rule.FvFileType =3D=3D 'SMM' or Rule.FvFileType =3D=3D 'SMM= _CORE': EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework= SMM module doesn't support SMM or SMM_CORE FV file type", File=3Dself.InfF= ileName) # # For the rule only has simpleFile # + MakefilePath =3D None + if IsMakefile: + MakefilePath =3D self.InfFileName, Arch if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) : - SectionOutputList =3D self.__GenSimpleFileSection__(Rule) - FfsOutput =3D self.__GenSimpleFileFfs__(Rule, SectionOutputLis= t) + SectionOutputList =3D self.__GenSimpleFileSection__(Rule, IsMa= kefile=3DIsMakefile) + FfsOutput =3D self.__GenSimpleFileFfs__(Rule, SectionOutputLis= t, MakefilePath=3DMakefilePath) return FfsOutput # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__(Rule, FvChildAddr, FvParentAddr) - FfsOutput =3D self.__GenComplexFileFfs__(Rule, InputSectList, = InputSectAlignments) - + InputSectList, InputSectAlignments =3D self.__GenComplexFileSe= ction__(Rule, FvChildAddr, FvParentAddr, IsMakefile=3DIsMakefile) + FfsOutput =3D self.__GenComplexFileFfs__(Rule, InputSectList, = InputSectAlignments, MakefilePath=3DMakefilePath) return FfsOutput =20 ## __ExtendMacro__() method # # Replace macro with its value @@ -649,10 +662,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval string Path that output files from this INF go to # def __GetEFIOutPutPath__(self): Arch =3D '' OutputPath =3D '' + DebugPath =3D '' (ModulePath, FileName) =3D os.path.split(self.InfFileName) Index =3D FileName.rfind('.') FileName =3D FileName[0:Index] if self.OverrideGuid: FileName =3D self.OverrideGuid @@ -664,22 +678,29 @@ class FfsInfStatement(FfsInfStatementClassObject): Arch , ModulePath, FileName, 'OUTPUT' ) + DebugPath =3D os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch= ], + Arch , + ModulePath, + FileName, + 'DEBUG' + ) OutputPath =3D os.path.realpath(OutputPath) - return OutputPath + DebugPath =3D os.path.realpath(DebugPath) + return OutputPath, DebugPath =20 ## __GenSimpleFileSection__() method # # Generate section by specified file name or a list of files with fi= le extension # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule): + def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): # # Prepare the parameter of GenSection # FileList =3D [] OutputFileList =3D [] @@ -741,26 +762,27 @@ class FfsInfStatement(FfsInfStatementClassObject): if not os.path.exists(FileBeforeStrip) or \ (os.path.getmtime(File) > os.path.getmtime(File= BeforeStrip)): CopyLongFilePath(File, FileBeforeStrip) StrippedFile =3D os.path.join(self.OutputPath, ModuleN= ame + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [File], - Strip=3DTrue - ) + StrippedFile, + [File], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) File =3D StrippedFile =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( self.OutputPath, self.ModuleG= uid + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [File], - Type=3D'te' - ) + TeFile, + [File], + Type=3D'te', + IsMakefile=3DIsMakefile + ) File =3D TeFile - - GenFdsGlobalVariable.GenerateSection(OutputFile, [File], S= ection.Section.SectionType[SectionType]) + GenFdsGlobalVariable.GenerateSection(OutputFile, [File], S= ection.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) else: SecNum =3D '%d' %Index GenSecOutputFile=3D self.__ExtendMacro__(Rule.NameGuid) + \ Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' += SecNum @@ -783,26 +805,27 @@ class FfsInfStatement(FfsInfStatementClassObject): (os.path.getmtime(GenSecInputFile) > os.path.getmti= me(FileBeforeStrip)): CopyLongFilePath(GenSecInputFile, FileBeforeStrip) =20 StrippedFile =3D os.path.join(self.OutputPath, ModuleName = + '.stipped') GenFdsGlobalVariable.GenerateFirmwareImage( - StrippedFile, - [GenSecInputFile], - Strip=3DTrue - ) + StrippedFile, + [GenSecInputFile], + Strip=3DTrue, + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D StrippedFile =20 if SectionType =3D=3D 'TE': TeFile =3D os.path.join( self.OutputPath, self.ModuleGuid = + 'Te.raw') GenFdsGlobalVariable.GenerateFirmwareImage( - TeFile, - [GenSecInputFile], - Type=3D'te' - ) + TeFile, + [GenSecInputFile], + Type=3D'te', + IsMakefile=3DIsMakefile + ) GenSecInputFile =3D TeFile - - GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputF= ile], Section.Section.SectionType[SectionType]) + GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputF= ile], Section.Section.SectionType[SectionType], IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList =20 ## __GenSimpleFileFfs__() method @@ -812,11 +835,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param Rule The rule object used to generate section # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenSimpleFileFfs__(self, Rule, InputFileList): + def __GenSimpleFileFfs__(self, Rule, InputFileList, MakefilePath =3D N= one): FfsOutput =3D self.OutputPath + \ os.sep + \ self.__ExtendMacro__(Rule.NameGuid) + \ '.ffs' =20 @@ -838,16 +861,17 @@ class FfsInfStatement(FfsInfStatementClassObject): if len(RegistryGuidStr) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s= in wrong format.' \ % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 - GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, - Ffs.Ffs.FdfFvFileTypeToFileType[R= ule.FvFileType], - self.ModuleGuid, Fixed=3DRule.Fix= ed, - CheckSum=3DRule.CheckSum, Align= =3DRule.Alignment, - SectionAlign=3DSectionAlignments - ) + GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, + Ffs.Ffs.FdfFvFileTypeToFileTy= pe[Rule.FvFileType], + self.ModuleGuid, Fixed=3DRule= .Fixed, + CheckSum=3DRule.CheckSum, Ali= gn=3DRule.Alignment, + SectionAlign=3DSectionAlignme= nts, + MakefilePath=3DMakefilePath + ) return FfsOutput =20 ## __GenComplexFileSection__() method # # Generate section by sections in Rule @@ -856,40 +880,42 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param Rule The rule object used to generate section # @param FvChildAddr Array of the inside FvImage base address # @param FvParentAddr Parent Fv base address # @retval string File name of the generated section file # - def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr): + def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, I= sMakefile =3D False): if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'): if Rule.KeepReloc !=3D None: self.KeepRelocFromRule =3D Rule.KeepReloc SectFiles =3D [] SectAlignments =3D [] Index =3D 1 - HasGneratedFlag =3D False + HasGeneratedFlag =3D False if self.PcdIsDriver =3D=3D 'PEI_PCD_DRIVER': if self.IsBinaryModule: PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "PEIPcdDataBase.raw") else: PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "PEIP= cdDataBase.raw") PcdExDbSecName =3D os.path.join(self.OutputPath, "PEIPcdDataBa= seSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, [PcdExDbFileName], "EFI_SECTION_RAW", + IsMakefile =3D IsMakefile ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) elif self.PcdIsDriver =3D=3D 'DXE_PCD_DRIVER': if self.IsBinaryModule: PcdExDbFileName =3D os.path.join(GenFdsGlobalVariable.FvDi= r, "DXEPcdDataBase.raw") else: PcdExDbFileName =3D os.path.join(self.EfiOutputPath, "DXEP= cdDataBase.raw") PcdExDbSecName =3D os.path.join(self.OutputPath, "DXEPcdDataBa= seSec.raw") GenFdsGlobalVariable.GenerateSection(PcdExDbSecName, - [PcdExDbFileName], - "EFI_SECTION_RAW", - ) + [PcdExDbFileName], + "EFI_SECTION_RAW", + IsMakefile =3D IsMakefile + ) SectFiles.append(PcdExDbSecName) SectAlignments.append(None) for Sect in Rule.SectionList: SecIndex =3D '%d' %Index SectList =3D [] @@ -915,15 +941,15 @@ class FfsInfStatement(FfsInfStatementClassObject): Sect.FvAddr =3D FvChildAddr if FvParentAddr !=3D None and isinstance(Sect, GuidSection): Sect.FvParentAddr =3D FvParentAddr =20 if Rule.KeyStringList !=3D []: - SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, Rule.KeyStringList, self) + SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile =3D IsMakefile) else : - SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, self.KeyStringList, self) + SectList, Align =3D Sect.GenSection(self.OutputPath , self= .ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile =3D IsMakefile) =20 - if not HasGneratedFlag: + if not HasGeneratedFlag: UniVfrOffsetFileSection =3D "" =20 ModuleFileName =3D mws.join(GenFdsGlobalVariable.WorkSpace= Dir, self.InfFileName) InfData =3D GenFdsGlobalVariable.WorkSpace.BuildObject[Pat= hClass(ModuleFileName), self.CurrentArch] # # Search the source list in InfData to find if there are .= vfr file exist. @@ -942,31 +968,44 @@ class FfsInfStatement(FfsInfStatementClassObject): # VfrUniBaseName["UniOffsetName"] =3D (self.BaseName= + "Strings") =20 =20 if len(VfrUniBaseName) > 0: - VfrUniOffsetList =3D self.__GetBuildOutputMapFileVfrUn= iInfo(VfrUniBaseName) - # - # Generate the Raw data of raw section - # - if VfrUniOffsetList: - os.path.join( self.OutputPath, self.BaseName + '.o= ffset') - UniVfrOffsetFileName =3D os.path.join( self.Ou= tputPath, self.BaseName + '.offset') - UniVfrOffsetFileSection =3D os.path.join( self.Ou= tputPath, self.BaseName + 'Offset' + '.raw') - - self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniV= frOffsetFileName) - - UniVfrOffsetFileNameList =3D [] - UniVfrOffsetFileNameList.append(UniVfrOffsetFileNa= me) - """Call GenSection""" - GenFdsGlobalVariable.GenerateSection(UniVfrOffsetF= ileSection, - UniVfrOffsetF= ileNameList, - "EFI_SECTION_= RAW" - ) - os.remove(UniVfrOffsetFileName) + if IsMakefile: + if InfData.BuildType !=3D 'UEFI_HII': + UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') + UniVfrOffsetFileNameList =3D [] + UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) + TrimCmd =3D "Trim --Vfr-Uni-Offset -o %s --Mod= uleName=3D%s --DebugDir=3D%s " % (UniVfrOffsetFileName, self.BaseName, self= .EfiDebugPath) + GenFdsGlobalVariable.SecCmdList.append(TrimCmd) + GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, + [UniVfrOff= setFileName], + "EFI_SECTI= ON_RAW", + IsMakefile= =3D True + ) + else: + VfrUniOffsetList =3D self.__GetBuildOutputMapFileV= frUniInfo(VfrUniBaseName) + # + # Generate the Raw data of raw section + # + if VfrUniOffsetList: + UniVfrOffsetFileName =3D os.path.join(self.Out= putPath, self.BaseName + '.offset') + UniVfrOffsetFileSection =3D os.path.join(self.= OutputPath, self.BaseName + 'Offset' + '.raw') + self.__GenUniVfrOffsetFile (VfrUniOffsetList, = UniVfrOffsetFileName) + UniVfrOffsetFileNameList =3D [] + UniVfrOffsetFileNameList.append(UniVfrOffsetFi= leName) + """Call GenSection""" + + GenFdsGlobalVariable.GenerateSection(UniVfrOff= setFileSection, + UniVfrOff= setFileNameList, + "EFI_SECT= ION_RAW" + ) + #os.remove(UniVfrOffsetFileName) + if UniVfrOffsetFileSection: SectList.append(UniVfrOffsetFileSection) - HasGneratedFlag =3D True + HasGeneratedFlag =3D True =20 for SecName in SectList : SectFiles.append(SecName) SectAlignments.append(Align) Index =3D Index + 1 @@ -979,11 +1018,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param Rule The rule object used to generate section # @param InputFileList The output file list from GenSection # @retval string Generated FFS file name # - def __GenComplexFileFfs__(self, Rule, InputFile, Alignments): + def __GenComplexFileFfs__(self, Rule, InputFile, Alignments, MakefileP= ath =3D None): =20 if Rule.NameGuid !=3D None and Rule.NameGuid.startswith('PCD('): PcdValue =3D GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid) if len(PcdValue) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \ @@ -996,15 +1035,16 @@ class FfsInfStatement(FfsInfStatementClassObject): % (Rule.NameGuid)) self.ModuleGuid =3D RegistryGuidStr =20 FfsOutput =3D os.path.join( self.OutputPath, self.ModuleGuid + '.f= fs') GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile, - Ffs.Ffs.FdfFvFileTypeToFileType[R= ule.FvFileType], - self.ModuleGuid, Fixed=3DRule.Fix= ed, - CheckSum=3DRule.CheckSum, Align= =3DRule.Alignment, - SectionAlign=3DAlignments - ) + Ffs.Ffs.FdfFvFileTypeToFileTy= pe[Rule.FvFileType], + self.ModuleGuid, Fixed=3DRule= .Fixed, + CheckSum=3DRule.CheckSum, Ali= gn=3DRule.Alignment, + SectionAlign=3DAlignments, + MakefilePath=3DMakefilePath + ) return FfsOutput =20 ## __GetGenFfsCmdParameter__() method # # Create parameter string for GenFfs @@ -1046,16 +1086,11 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param VfrUniOffsetList A list contain the VFR/UNI offsets= in the EFI image file. # @param UniVfrOffsetFileName The output offset file name. # def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName= ): - =20 - try: - fInputfile =3D open(UniVfrOffsetFileName, "wb+", 0) - except: - EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed= for %s" %UniVfrOffsetFileName,None) - =20 + # Use a instance of StringIO to cache data fStringIO =3D StringIO.StringIO('') =20 =20 for Item in VfrUniOffsetList: if (Item[0].find("Strings") !=3D -1): @@ -1083,20 +1118,13 @@ class FfsInfStatement(FfsInfStatementClassObject): fStringIO.write (VfrValue) =20 # # write data into file. # - try : =20 - fInputfile.write (fStringIO.getvalue()) + try : + SaveFileOnChange(UniVfrOffsetFileName, fStringIO.getvalue()) except: EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to f= ile %s failed, please check whether the file been locked or using by other = applications." %UniVfrOffsetFileName,None) =20 fStringIO.close () - fInputfile.close () - =20 - =20 - =20 - =20 - =20 - =20 - =20 + =20 diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python= /GenFds/Fv.py index 45f6696..3953756 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -20,10 +20,11 @@ import subprocess import StringIO from struct import * =20 import Ffs import AprioriSection +import FfsFileStatement from GenFdsGlobalVariable import GenFdsGlobalVariable from GenFds import GenFds from CommonDataClass.FdfClass import FvClassObject from Common.Misc import SaveFileOnChange from Common.LongFilePathSupport import CopyLongFilePath @@ -65,11 +66,11 @@ class FV (FvClassObject): # @param ErasePolarity Flash erase polarity # @param VtfDict VTF objects # @param MacroDict macro value pair # @retval string Generated FV file path # - def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}) : + def AddToBuffer (self, Buffer, BaseAddress=3DNone, BlockSize=3D None, = BlockNum=3DNone, ErasePloarity=3D'1', VtfDict=3DNone, MacroDict =3D {}, Fla= g=3DFalse) : =20 if BaseAddress =3D=3D None and self.UiFvName.upper() + 'fv' in Gen= Fds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =20 # @@ -86,135 +87,145 @@ class FV (FvClassObject): continue elif RegionData.upper() + 'fv' in GenFds.Image= BinDict.keys(): continue elif self.UiFvName.upper() =3D=3D RegionData.u= pper(): GenFdsGlobalVariable.ErrorLogger("Capsule = %s in FD region can't contain a FV %s in FD region." % (self.CapsuleName, s= elf.UiFvName.upper())) - - GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiFvNam= e) + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV" %self.UiF= vName) GenFdsGlobalVariable.LargeFileInFvFlags.append(False) FFSGuid =3D None =20 if self.FvBaseAddress !=3D None: BaseAddress =3D self.FvBaseAddress - - self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloa= rity, VtfDict) + if not Flag: + self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, Erase= Ploarity, VtfDict) # # First Process the Apriori section # MacroDict.update(self.DefineVarDict) =20 GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !') FfsFileList =3D [] for AprSection in self.AprioriSectionList: - FileName =3D AprSection.GenFfs (self.UiFvName, MacroDict) + FileName =3D AprSection.GenFfs (self.UiFvName, MacroDict, IsMa= kefile=3DFlag) FfsFileList.append(FileName) # Add Apriori file name to Inf file - self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ - FileName + \ - T_CHAR_LF) + if not Flag: + self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ + FileName + \ + T_CHAR_LF) =20 # Process Modules in FfsList for FfsFile in self.FfsList : - FileName =3D FfsFile.GenFfs(MacroDict, FvParentAddr=3DBaseAddr= ess) + if Flag: + if isinstance(FfsFile, FfsFileStatement.FileStatement): + continue + if GenFdsGlobalVariable.EnableGenfdsMultiThread and GenFdsGlob= alVariable.ModuleFile and GenFdsGlobalVariable.ModuleFile.Path.find(os.path= .normpath(FfsFile.InfFileName)) =3D=3D -1: + continue + FileName =3D FfsFile.GenFfs(MacroDict, FvParentAddr=3DBaseAddr= ess, IsMakefile=3DFlag) FfsFileList.append(FileName) - self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ - FileName + \ - T_CHAR_LF) - - SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), Fals= e) - self.FvInfFile.close() + if not Flag: + self.FvInfFile.writelines("EFI_FILE_NAME =3D " + \ + FileName + \ + T_CHAR_LF) + if not Flag: + SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), = False) + self.FvInfFile.close() # # Call GenFv tool # FvOutputFile =3D os.path.join(GenFdsGlobalVariable.FvDir, self.UiF= vName) FvOutputFile =3D FvOutputFile + '.Fv' # BUGBUG: FvOutputFile could be specified from FDF file (FV sectio= n, CreateFile statement) if self.CreateFileName !=3D None: FvOutputFile =3D self.CreateFileName =20 + if Flag: + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOutput= File + return FvOutputFile + FvInfoFileName =3D os.path.join(GenFdsGlobalVariable.FfsDir, self.= UiFvName + '.inf') - CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInfoFil= eName) - OrigFvInfo =3D None - if os.path.exists (FvInfoFileName): - OrigFvInfo =3D open(FvInfoFileName, 'r').read() - if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: - FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3_GUI= D; - GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileName, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForceRebase, - FileSystemGuid=3DFFSGuid - ) + if not Flag: + CopyLongFilePath(GenFdsGlobalVariable.FvAddressFileName, FvInf= oFileName) + OrigFvInfo =3D None + if os.path.exists (FvInfoFileName): + OrigFvInfo =3D open(FvInfoFileName, 'r').read() + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYSTEM3= _GUID + GenFdsGlobalVariable.GenerateFirmwareVolume( + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileName, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForceRebase, + FileSystemGuid=3DFFSGuid + ) =20 - NewFvInfo =3D None - if os.path.exists (FvInfoFileName): - NewFvInfo =3D open(FvInfoFileName, 'r').read() - if NewFvInfo !=3D None and NewFvInfo !=3D OrigFvInfo: - FvChildAddr =3D [] - AddFileObj =3D open(FvInfoFileName, 'r') - AddrStrings =3D AddFileObj.readlines() - AddrKeyFound =3D False - for AddrString in AddrStrings: - if AddrKeyFound: - #get base address for the inside FvImage - FvChildAddr.append (AddrString) - elif AddrString.find ("[FV_BASE_ADDRESS]") !=3D -1: - AddrKeyFound =3D True - AddFileObj.close() + NewFvInfo =3D None + if os.path.exists (FvInfoFileName): + NewFvInfo =3D open(FvInfoFileName, 'r').read() + if NewFvInfo !=3D None and NewFvInfo !=3D OrigFvInfo: + FvChildAddr =3D [] + AddFileObj =3D open(FvInfoFileName, 'r') + AddrStrings =3D AddFileObj.readlines() + AddrKeyFound =3D False + for AddrString in AddrStrings: + if AddrKeyFound: + #get base address for the inside FvImage + FvChildAddr.append (AddrString) + elif AddrString.find ("[FV_BASE_ADDRESS]") !=3D -1: + AddrKeyFound =3D True + AddFileObj.close() =20 - if FvChildAddr !=3D []: - # Update Ffs again - for FfsFile in self.FfsList : - FileName =3D FfsFile.GenFfs(MacroDict, FvChildAddr, Ba= seAddress) - =20 - if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: - FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE_SYS= TEM3_GUID; - #Update GenFv again - GenFdsGlobalVariable.GenerateFirmwareVolume( - FvOutputFile, - [self.InfFileName], - AddressFile=3DFvInfoFileName, - FfsList=3DFfsFileList, - ForceRebase=3Dself.FvForceRebase, - FileSystemGuid=3DFFSGuid - ) + if FvChildAddr !=3D []: + # Update Ffs again + for FfsFile in self.FfsList : + FileName =3D FfsFile.GenFfs(MacroDict, FvChildAddr= , BaseAddress, IsMakefile=3DFlag) =20 - # - # Write the Fv contents to Buffer - # - if os.path.isfile(FvOutputFile): - FvFileObj =3D open ( FvOutputFile,'rb') + if GenFdsGlobalVariable.LargeFileInFvFlags[-1]: + FFSGuid =3D GenFdsGlobalVariable.EFI_FIRMWARE_FILE= _SYSTEM3_GUID; + #Update GenFv again + GenFdsGlobalVariable.GenerateFirmwareVolume( + FvOutputFile, + [self.InfFileName], + AddressFile=3DFvInfoFileNa= me, + FfsList=3DFfsFileList, + ForceRebase=3Dself.FvForce= Rebase, + FileSystemGuid=3DFFSGuid + ) =20 - GenFdsGlobalVariable.VerboseLogger( "\nGenerate %s FV Successf= ully" %self.UiFvName) - GenFdsGlobalVariable.SharpCounter =3D 0 + # + # Write the Fv contents to Buffer + # + if os.path.isfile(FvOutputFile): + FvFileObj =3D open(FvOutputFile, 'rb') + GenFdsGlobalVariable.VerboseLogger("\nGenerate %s FV Succe= ssfully" % self.UiFvName) + GenFdsGlobalVariable.SharpCounter =3D 0 =20 - Buffer.write(FvFileObj.read()) - FvFileObj.seek(0) - # PI FvHeader is 0x48 byte - FvHeaderBuffer =3D FvFileObj.read(0x48) - # FV alignment position. - FvAlignmentValue =3D 1 << (ord (FvHeaderBuffer[0x2E]) & 0x1F) - # FvAlignmentValue is larger than or equal to 1K - if FvAlignmentValue >=3D 0x400: - if FvAlignmentValue >=3D 0x100000: - #The max alignment supported by FFS is 16M. - if FvAlignmentValue >=3D 0x1000000: - self.FvAlignment =3D "16M" + Buffer.write(FvFileObj.read()) + FvFileObj.seek(0) + # PI FvHeader is 0x48 byte + FvHeaderBuffer =3D FvFileObj.read(0x48) + # FV alignment position. + FvAlignmentValue =3D 1 << (ord(FvHeaderBuffer[0x2E]) & 0x1= F) + if FvAlignmentValue >=3D 0x400: + if FvAlignmentValue >=3D 0x100000: + if FvAlignmentValue >=3D 0x1000000: + #The max alignment supported by FFS is 16M. + self.FvAlignment =3D "16M" + else: + self.FvAlignment =3D str(FvAlignmentValue / 0x= 100000) + "M" else: - self.FvAlignment =3D str(FvAlignmentValue / 0x1000= 00) + "M" + self.FvAlignment =3D str(FvAlignmentValue / 0x400)= + "K" else: - self.FvAlignment =3D str (FvAlignmentValue / 0x400) + = "K" + # FvAlignmentValue is less than 1K + self.FvAlignment =3D str (FvAlignmentValue) + FvFileObj.close() + GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOu= tputFile + GenFdsGlobalVariable.LargeFileInFvFlags.pop() else: - # FvAlignmentValue is less than 1K - self.FvAlignment =3D str (FvAlignmentValue) - FvFileObj.close() - GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] =3D FvOutput= File - GenFdsGlobalVariable.LargeFileInFvFlags.pop() - else: - GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV fil= e." %self.UiFvName) + GenFdsGlobalVariable.ErrorLogger("Failed to generate %s FV= file." %self.UiFvName) return FvOutputFile =20 ## _GetBlockSize() # # Calculate FV's block size diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/S= ource/Python/GenFds/FvImageSection.py index 68f17c3..916ff91 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -48,11 +48,11 @@ class FvImageSection(FvImageSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf =3D None, Dict =3D {}, IsMakefile =3D False): =20 OutputFileList =3D [] if self.FvFileType !=3D None: FileList, IsSect =3D Section.Section.GetFileList(FfsInf, self.= FvFileType, self.FvFileExtension) if IsSect : @@ -73,11 +73,11 @@ class FvImageSection(FvImageSectionClassObject): FvFileObj.close() if FvAlignmentValue > MaxFvAlignment: MaxFvAlignment =3D FvAlignmentValue =20 OutputFile =3D os.path.join(OutputPath, ModuleName + 'SEC'= + Num + Ffs.SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileNa= me], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE') + GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileNa= me], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 # MaxFvAlignment is larger than or equal to 1K if MaxFvAlignment >=3D 0x400: if MaxFvAlignment >=3D 0x100000: @@ -99,11 +99,11 @@ class FvImageSection(FvImageSectionClassObject): if self.FvName !=3D None: Buffer =3D StringIO.StringIO('') Fv =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.= FvName) if Fv !=3D None: self.Fv =3D Fv - FvFileName =3D Fv.AddToBuffer(Buffer, self.FvAddr, MacroDi= ct =3D Dict) + FvFileName =3D Fv.AddToBuffer(Buffer, self.FvAddr, MacroDi= ct =3D Dict, Flag=3DIsMakefile) if Fv.FvAlignment !=3D None: if self.Alignment =3D=3D None: self.Alignment =3D Fv.FvAlignment else: if GenFdsGlobalVariable.GetAlignment (Fv.FvAlignme= nt) > GenFdsGlobalVariable.GetAlignment (self.Alignment): @@ -137,9 +137,9 @@ class FvImageSection(FvImageSectionClassObject): =20 # # Prepare the parameter of GenSection # OutputFile =3D os.path.join(OutputPath, ModuleName + 'SEC' + S= ecNum + Ffs.SectionSuffix.get("FV_IMAGE")) - GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],= 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE') + GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName],= 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE', IsMakefile=3DIsMakefile) OutputFileList.append(OutputFile) =20 return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Py= thon/GenFds/GenFds.py index c19dc40..4a5d6f4 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -97,10 +97,12 @@ def main(): GenFdsGlobalVariable.WorkSpaceDir =3D Workspace if 'EDK_SOURCE' in os.environ.keys(): GenFdsGlobalVariable.EdkSourceDir =3D os.path.normcase(os.= environ['EDK_SOURCE']) if (Options.debug): GenFdsGlobalVariable.VerboseLogger("Using Workspace:" + Wo= rkspace) + if Options.GenfdsMultiThread: + GenFdsGlobalVariable.EnableGenfdsMultiThread =3D True os.chdir(GenFdsGlobalVariable.WorkSpaceDir) =20 # set multiple workspace PackagesPath =3D os.getenv("PACKAGES_PATH") mws.setWs(GenFdsGlobalVariable.WorkSpaceDir, PackagesPath) @@ -536,10 +538,11 @@ def myOptionParser(): Parser.add_option("-D", "--define", action=3D"append", type=3D"string"= , dest=3D"Macros", help=3D"Macro: \"Name [=3D Value]\".") Parser.add_option("-s", "--specifyaddress", dest=3D"FixedAddress", act= ion=3D"store_true", type=3DNone, help=3D"Specify driver load address.") Parser.add_option("--conf", action=3D"store", type=3D"string", dest=3D= "ConfDirectory", help=3D"Specify the customized Conf directory.") Parser.add_option("--ignore-sources", action=3D"store_true", dest=3D"I= gnoreSources", default=3DFalse, help=3D"Focus to a binary build and ignore = all source files") Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", help= =3D"Set PCD value by command line. Format: \"PcdName=3DValue\" ") + Parser.add_option("--genfds-multi-thread", action=3D"store_true", dest= =3D"GenfdsMultiThread", default=3DFalse, help=3D"Enable GenFds multi thread= to generate ffs file.") =20 (Options, args) =3D Parser.parse_args() return Options =20 ## The class implementing the EDK2 flash image generation process @@ -609,10 +612,27 @@ class GenFds : if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: GenFdsGlobalVariable.VerboseLogger("\n Generate all Option= ROM!") for DriverName in GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict.keys(): OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.O= ptRomDict[DriverName] OptRomObj.AddToBuffer(None) + @staticmethod + def GenFfsMakefile(OutputDir, FdfParser, WorkSpace, ArchList, GlobalDa= ta): + GenFdsGlobalVariable.SetEnv(FdfParser, WorkSpace, ArchList, Global= Data) + for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys(): + FdObj =3D GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName] + FdObj.GenFd(Flag=3DTrue) + + for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys(): + FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName] + FvObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) + + if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict !=3D {}: + for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict.keys(): + OptRomObj =3D GenFdsGlobalVariable.FdfParser.Profile.OptRo= mDict[DriverName] + OptRomObj.AddToBuffer(Buffer=3DNone, Flag=3DTrue) + + return GenFdsGlobalVariable.FfsCmdDict =20 ## GetFvBlockSize() # # @param FvObj Whose block size to get # @retval int Block size value diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 83996be..371d5a8 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -67,10 +67,15 @@ class GenFdsGlobalVariable: =20 BuildRuleFamily =3D "MSFT" ToolChainFamily =3D "MSFT" __BuildRuleDatabase =3D None GuidToolDefinition =3D {} + FfsCmdDict =3D {} + SecCmdList =3D [] + CopyList =3D [] + ModuleFile =3D '' + EnableGenfdsMultiThread =3D False =20 # # The list whose element are flags to indicate if large FFS or SECTION= files exist in FV. # At the beginning of each generation of FV, false flag is appended to= the list, # after the call to GenerateSection returns, check the size of the out= put file, @@ -262,10 +267,14 @@ class GenFdsGlobalVariable: =20 RuleChain.append(FileType) SourceList.extend(Target.Outputs) LastTarget =3D Target FileType =3D DataType.TAB_UNKNOWN_FILE + for Cmd in Target.Commands: + if "$(CP)" =3D=3D Cmd.split()[0]: + CpTarget =3D Cmd.split()[2] + TargetList.add(CpTarget) =20 return list(TargetList) =20 ## SetDir() # @@ -315,10 +324,77 @@ class GenFdsGlobalVariable: RtAddress + \ T_CHAR_LF) =20 FvAddressFile.close() =20 + def SetEnv(FdfParser, WorkSpace, ArchList, GlobalData): + GenFdsGlobalVariable.ModuleFile =3D WorkSpace.ModuleFile + GenFdsGlobalVariable.FdfParser =3D FdfParser + GenFdsGlobalVariable.WorkSpace =3D WorkSpace.Db + GenFdsGlobalVariable.ArchList =3D ArchList + GenFdsGlobalVariable.ToolChainTag =3D GlobalData.gGlobalDefines["T= OOL_CHAIN_TAG"] + GenFdsGlobalVariable.TargetName =3D GlobalData.gGlobalDefines["TAR= GET"] + GenFdsGlobalVariable.ActivePlatform =3D GlobalData.gActivePlatform + GenFdsGlobalVariable.EdkSourceDir =3D GlobalData.gGlobalDefines["E= DK_SOURCE"] + GenFdsGlobalVariable.ConfDir =3D GlobalData.gConfDirectory + GenFdsGlobalVariable.EnableGenfdsMultiThread =3D GlobalData.gEnabl= eGenfdsMultiThread + for Arch in ArchList: + GenFdsGlobalVariable.OutputDirDict[Arch] =3D os.path.normpath( + os.path.join(GlobalData.gWorkspace, + WorkSpace.Db.BuildObject[GenFdsGlobalVariable= .ActivePlatform, Arch,GlobalData.gGlobalDefines['TARGET'], + GlobalData.gGlobalDefines['TOOLCHAIN']].Outpu= tDirectory, + GlobalData.gGlobalDefines['TARGET'] +'_' + Gl= obalData.gGlobalDefines['TOOLCHAIN'])) + GenFdsGlobalVariable.OutputDirFromDscDict[Arch] =3D os.path.no= rmpath( + WorkSpace.Db.BuildObject[GenFdsGlobalVariable= .ActivePlatform, Arch, + GlobalData.gGlobalDefines['TARGET'], GlobalDa= ta.gGlobalDefines['TOOLCHAIN']].OutputDirectory) + GenFdsGlobalVariable.PlatformName =3D WorkSpace.Db.BuildObject= [GenFdsGlobalVariable.ActivePlatform, Arch, + Glob= alData.gGlobalDefines['TARGET'], + Glob= alData.gGlobalDefines['TOOLCHAIN']].PlatformName + GenFdsGlobalVariable.FvDir =3D os.path.join(GenFdsGlobalVariable.O= utputDirDict[ArchList[0]], 'FV') + if not os.path.exists(GenFdsGlobalVariable.FvDir): + os.makedirs(GenFdsGlobalVariable.FvDir) + GenFdsGlobalVariable.FfsDir =3D os.path.join(GenFdsGlobalVariable.= FvDir, 'Ffs') + if not os.path.exists(GenFdsGlobalVariable.FfsDir): + os.makedirs(GenFdsGlobalVariable.FfsDir) + + T_CHAR_LF =3D '\n' + # + # Create FV Address inf file + # + GenFdsGlobalVariable.FvAddressFileName =3D os.path.join(GenFdsGlob= alVariable.FfsDir, 'FvAddress.inf') + FvAddressFile =3D open(GenFdsGlobalVariable.FvAddressFileName, 'w') + # + # Add [Options] + # + FvAddressFile.writelines("[options]" + T_CHAR_LF) + BsAddress =3D '0' + for Arch in ArchList: + BsAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[GenFd= sGlobalVariable.ActivePlatform, Arch, + GlobalD= ata.gGlobalDefines['TARGET'], + GlobalD= ata.gGlobalDefines["TOOL_CHAIN_TAG"]].BsBaseAddress + if BsAddress: + break + + FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS =3D " + \ + BsAddress + \ + T_CHAR_LF) + + RtAddress =3D '0' + for Arch in ArchList: + if GenFdsGlobalVariable.WorkSpace.BuildObject[ + GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.gGlo= balDefines['TARGET'], + GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAddress: + RtAddress =3D GenFdsGlobalVariable.WorkSpace.BuildObject[ + GenFdsGlobalVariable.ActivePlatform, Arch, GlobalData.= gGlobalDefines['TARGET'], + GlobalData.gGlobalDefines["TOOL_CHAIN_TAG"]].RtBaseAdd= ress + + FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS =3D " + \ + RtAddress + \ + T_CHAR_LF) + + FvAddressFile.close() + ## ReplaceWorkspaceMacro() # # @param String String that may contain macro # def ReplaceWorkspaceMacro(String): @@ -361,18 +437,20 @@ class GenFdsGlobalVariable: return True return False =20 @staticmethod def GenerateSection(Output, Input, Type=3DNone, CompressionType=3DNone= , Guid=3DNone, - GuidHdrLen=3DNone, GuidAttr=3D[], Ui=3DNone, Ver= =3DNone, InputAlign=3DNone, BuildNumber=3DNone): + GuidHdrLen=3DNone, GuidAttr=3D[], Ui=3DNone, Ver= =3DNone, InputAlign=3DNone, BuildNumber=3DNone, DummyFile=3DNone, IsMakefil= e=3DFalse): Cmd =3D ["GenSec"] if Type not in [None, '']: Cmd +=3D ["-s", Type] if CompressionType not in [None, '']: Cmd +=3D ["-c", CompressionType] if Guid !=3D None: Cmd +=3D ["-g", Guid] + if DummyFile !=3D None: + Cmd +=3D ["--dummy", DummyFile] if GuidHdrLen not in [None, '']: Cmd +=3D ["-l", GuidHdrLen] if len(GuidAttr) !=3D 0: #Add each guided attribute for Attr in GuidAttr: @@ -383,40 +461,53 @@ class GenFdsGlobalVariable: Cmd +=3D ["--sectionalign", SecAlign] =20 CommandFile =3D Output + '.txt' if Ui not in [None, '']: #Cmd +=3D ["-n", '"' + Ui + '"'] - SectionData =3D array.array('B', [0, 0, 0, 0]) - SectionData.fromstring(Ui.encode("utf_16_le")) - SectionData.append(0) - SectionData.append(0) - Len =3D len(SectionData) - GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, L= en & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) - SaveFileOnChange(Output, SectionData.tostring()) + if IsMakefile: + Cmd +=3D ["-n", "$(MODULE_NAME)"] + Cmd +=3D ["-o", Output] + #SaveFileOnChange(CommandFile, ' '.join(Cmd), False) + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + else: + SectionData =3D array.array('B', [0, 0, 0, 0]) + SectionData.fromstring(Ui.encode("utf_16_le")) + SectionData.append(0) + SectionData.append(0) + Len =3D len(SectionData) + GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, = 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x15) + SaveFileOnChange(Output, SectionData.tostring()) + elif Ver not in [None, '']: Cmd +=3D ["-n", Ver] if BuildNumber: Cmd +=3D ["-j", BuildNumber] Cmd +=3D ["-o", Output] =20 SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + = [CommandFile]): - return - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= section") + if IsMakefile: + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + else: + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input= ) + [CommandFile]): + return + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") else: Cmd +=3D ["-o", Output] Cmd +=3D Input =20 SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [Com= mandFile]): + if IsMakefile: + if ' '.join(Cmd).strip() not in GenFdsGlobalVariable.SecCm= dList: + GenFdsGlobalVariable.SecCmdList.append(' '.join(Cmd).s= trip()) + elif GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s ne= eds update because of newer %s" % (Output, Input)) GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to gene= rate section") - - if (os.path.getsize(Output) >=3D GenFdsGlobalVariable.LARGE_FI= LE_SIZE and - GenFdsGlobalVariable.LargeFileInFvFlags): - GenFdsGlobalVariable.LargeFileInFvFlags[-1] =3D True=20 + if (os.path.getsize(Output) >=3D GenFdsGlobalVariable.LARG= E_FILE_SIZE and + GenFdsGlobalVariable.LargeFileInFvFlags): + GenFdsGlobalVariable.LargeFileInFvFlags[-1] =3D True =20 @staticmethod def GetAlignment (AlignString): if AlignString =3D=3D None: return 0 @@ -427,11 +518,11 @@ class GenFdsGlobalVariable: else: return int (AlignString) =20 @staticmethod def GenerateFfs(Output, Input, Type, Guid, Fixed=3DFalse, CheckSum=3DF= alse, Align=3DNone, - SectionAlign=3DNone): + SectionAlign=3DNone, MakefilePath=3DNone): Cmd =3D ["GenFfs", "-t", Type, "-g", Guid] mFfsValidAlign =3D ["0", "8", "16", "128", "512", "1K", "4K", "32K= ", "64K", "128K", "256K", "512K", "1M", "2M", "4M", "8M", "16M"] if Fixed =3D=3D True: Cmd +=3D ["-x"] if CheckSum: @@ -451,15 +542,21 @@ class GenFdsGlobalVariable: if SectionAlign not in [None, '', []] and SectionAlign[I] not = in [None, '']: Cmd +=3D ("-n", SectionAlign[I]) =20 CommandFile =3D Output + '.txt' SaveFileOnChange(CommandFile, ' '.join(Cmd), False) - if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input) + [Com= mandFile]): - return - GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS= ") + GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) + if MakefilePath: + if (tuple(Cmd),tuple(GenFdsGlobalVariable.SecCmdList),tuple(Ge= nFdsGlobalVariable.CopyList)) not in GenFdsGlobalVariable.FfsCmdDict.keys(): + GenFdsGlobalVariable.FfsCmdDict[tuple(Cmd), tuple(GenFdsGl= obalVariable.SecCmdList), tuple(GenFdsGlobalVariable.CopyList)] =3D Makefil= ePath + GenFdsGlobalVariable.SecCmdList =3D [] + GenFdsGlobalVariable.CopyList =3D [] + else: + if not GenFdsGlobalVariable.NeedsUpdate(Output, list(Input)): + return + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= FFS") =20 @staticmethod def GenerateFirmwareVolume(Output, Input, BaseAddress=3DNone, ForceReb= ase=3DNone, Capsule=3DFalse, Dump=3DFalse, AddressFile=3DNone, MapFile=3DNone, FfsList= =3D[], FileSystemGuid=3DNone): if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList): @@ -509,12 +606,12 @@ class GenFdsGlobalVariable: GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate VTF= ") =20 @staticmethod def GenerateFirmwareImage(Output, Input, Type=3D"efi", SubType=3DNone,= Zero=3DFalse, Strip=3DFalse, Replace=3DFalse, TimeStamp=3D= None, Join=3DFalse, - Align=3DNone, Padding=3DNone, Convert=3DFals= e): - if not GenFdsGlobalVariable.NeedsUpdate(Output, Input): + Align=3DNone, Padding=3DNone, Convert=3DFals= e, IsMakefile=3DFalse): + if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 Cmd =3D ["GenFw"] if Type.lower() =3D=3D "te": @@ -537,16 +634,19 @@ class GenFdsGlobalVariable: Cmd +=3D ["-j"] if Convert: Cmd +=3D ["-m"] Cmd +=3D ["-o", Output] Cmd +=3D Input - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate fir= mware image") + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= firmware image") =20 @staticmethod def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=3DFalse,= ClassCode=3DNone, - Revision=3DNone, DeviceId=3DNone, VendorId=3DNone): + Revision=3DNone, DeviceId=3DNone, VendorId=3DNone,= IsMakefile=3DFalse): InputList =3D [] =20 Cmd =3D ["EfiRom"] if len(EfiInput) > 0: =20 if Compress: @@ -563,11 +663,11 @@ class GenFdsGlobalVariable: for BinFile in BinaryInput: Cmd +=3D [BinFile] InputList.append (BinFile) =20 # Check List - if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList): + if not GenFdsGlobalVariable.NeedsUpdate(Output, InputList) and not= IsMakefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, InputList)) =20 if ClassCode !=3D None: Cmd +=3D ["-l", ClassCode] @@ -577,24 +677,31 @@ class GenFdsGlobalVariable: Cmd +=3D ["-i", DeviceId] if VendorId !=3D None: Cmd +=3D ["-f", VendorId] =20 Cmd +=3D ["-o", Output] - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate opt= ion rom") + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate= option rom") =20 @staticmethod - def GuidTool(Output, Input, ToolPath, Options=3D'', returnValue=3D[]): - if not GenFdsGlobalVariable.NeedsUpdate(Output, Input): + def GuidTool(Output, Input, ToolPath, Options=3D'', returnValue=3D[], = IsMakefile=3DFalse): + if not GenFdsGlobalVariable.NeedsUpdate(Output, Input) and not IsM= akefile: return GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs upda= te because of newer %s" % (Output, Input)) =20 Cmd =3D [ToolPath, ] Cmd +=3D Options.split(' ') Cmd +=3D ["-o", Output] Cmd +=3D Input - - GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + Too= lPath, returnValue) + if IsMakefile: + if " ".join(Cmd).strip() not in GenFdsGlobalVariable.SecCmdLis= t: + GenFdsGlobalVariable.SecCmdList.append(" ".join(Cmd).strip= ()) + else: + GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " += ToolPath, returnValue) =20 def CallExternalTool (cmd, errorMess, returnValue=3D[]): =20 if type(cmd) not in (tuple, list): GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid paramete= r type in call to CallExternalTool") @@ -725,10 +832,11 @@ class GenFdsGlobalVariable: return PcdValue =20 return PcdValue =20 SetDir =3D staticmethod(SetDir) + SetEnv =3D staticmethod(SetEnv) ReplaceWorkspaceMacro =3D staticmethod(ReplaceWorkspaceMacro) CallExternalTool =3D staticmethod(CallExternalTool) VerboseLogger =3D staticmethod(VerboseLogger) InfLogger =3D staticmethod(InfLogger) ErrorLogger =3D staticmethod(ErrorLogger) diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Sour= ce/Python/GenFds/GuidSection.py index f199dcd..ea737bb 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -1,9 +1,9 @@ ## @file # process GUIDed section generation # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -52,11 +52,11 @@ class GuidSection(GuidSectionClassObject) : # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile=3DFalse): # # Generate all section # self.KeyStringList =3D KeyStringList self.CurrentArchList =3D GenFdsGlobalVariable.ArchList @@ -92,11 +92,11 @@ class GuidSection(GuidSectionClassObject) : Sect.FvAddr =3D self.FvAddr.pop(0) self.IncludeFvSection =3D True elif isinstance(Sect, GuidSection): Sect.FvAddr =3D self.FvAddr Sect.FvParentAddr =3D self.FvParentAddr - ReturnSectList, align =3D Sect.GenSection(OutputPath, ModuleNa= me, SecIndex, KeyStringList, FfsInf, Dict) + ReturnSectList, align =3D Sect.GenSection(OutputPath, ModuleNa= me, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=3DIsMakefile) if isinstance(Sect, GuidSection): if Sect.IncludeFvSection: self.IncludeFvSection =3D Sect.IncludeFvSection =20 if align !=3D None: @@ -135,11 +135,11 @@ class GuidSection(GuidSectionClassObject) : # If not have GUID , call default # GENCRC32 section # if self.NameGuid =3D=3D None : GenFdsGlobalVariable.VerboseLogger("Use GenSection function Ge= nerate CRC32 Section") - GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Sec= tion.Section.SectionType[self.SectionType], InputAlign=3DSectAlign) + GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Sec= tion.Section.SectionType[self.SectionType], InputAlign=3DSectAlign, IsMakef= ile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment #or GUID not in External Tool List elif ExternalTool =3D=3D None: @@ -147,11 +147,11 @@ class GuidSection(GuidSectionClassObject) : else: DummyFile =3D OutputFile + ".dummy" # # Call GenSection with DUMMY section type. # - GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, Inpu= tAlign=3DSectAlign) + GenFdsGlobalVariable.GenerateSection(DummyFile, SectFile, Inpu= tAlign=3DSectAlign, IsMakefile=3DIsMakefile) # # Use external tool process the Output # TempFile =3D OutputPath + \ os.sep + \ @@ -170,79 +170,103 @@ class GuidSection(GuidSectionClassObject) : =20 FirstCall =3D False CmdOption =3D '-e' if ExternalOption !=3D None: CmdOption =3D CmdOption + ' ' + ExternalOption - if self.ProcessRequired not in ("TRUE", "1") and self.IncludeF= vSection and not FvAddrIsSet and self.FvParentAddr !=3D None: - #FirstCall is only set for the encapsulated flash FV image= without process required attribute. - FirstCall =3D True - # - # Call external tool - # - ReturnValue =3D [1] - if FirstCall: - #first try to call the guided tool with -z option and CmdO= ption for the no process required guided tool. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, '-z' + ' ' + CmdOption, ReturnValue) + if not GenFdsGlobalVariable.EnableGenfdsMultiThread: + if self.ProcessRequired not in ("TRUE", "1") and self.Incl= udeFvSection and not FvAddrIsSet and self.FvParentAddr !=3D None: + #FirstCall is only set for the encapsulated flash FV i= mage without process required attribute. + FirstCall =3D True + # + # Call external tool + # + ReturnValue =3D [1] + if FirstCall: + #first try to call the guided tool with -z option and = CmdOption for the no process required guided tool. + GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, '-z' + ' ' + CmdOption, ReturnValue) =20 - # - # when no call or first call failed, ReturnValue are not 1. - # Call the guided tool with CmdOption - # - if ReturnValue[0] !=3D 0: - FirstCall =3D False - ReturnValue[0] =3D 0 - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption) - # - # There is external tool which does not follow standard rule w= hich return nonzero if tool fails - # The output file has to be checked - # - if not os.path.exists(TempFile): - EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %= s, no output file was generated' % ExternalTool) - - FileHandleIn =3D open(DummyFile, 'rb') - FileHandleIn.seek(0, 2) - InputFileSize =3D FileHandleIn.tell() - - FileHandleOut =3D open(TempFile, 'rb') - FileHandleOut.seek(0, 2) - TempFileSize =3D FileHandleOut.tell() - - Attribute =3D [] - HeaderLength =3D None - if self.ExtraHeaderSize !=3D -1: - HeaderLength =3D str(self.ExtraHeaderSize) - - if self.ProcessRequired =3D=3D "NONE" and HeaderLength =3D=3D = None: - if TempFileSize > InputFileSize: - FileHandleIn.seek(0) - BufferIn =3D FileHandleIn.read() - FileHandleOut.seek(0) - BufferOut =3D FileHandleOut.read() - if BufferIn =3D=3D BufferOut[TempFileSize - InputFileS= ize:]: - HeaderLength =3D str(TempFileSize - InputFileSize) - #auto sec guided attribute with process required - if HeaderLength =3D=3D None: - Attribute.append('PROCESSING_REQUIRED') - - FileHandleIn.close() - FileHandleOut.close() - - if FirstCall and 'PROCESSING_REQUIRED' in Attribute: - # Guided data by -z option on first call is the process re= quired data. Call the guided tool with the real option. - GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption) + # + # when no call or first call failed, ReturnValue are not 1. + # Call the guided tool with CmdOption + # + if ReturnValue[0] !=3D 0: + FirstCall =3D False + ReturnValue[0] =3D 0 + GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, CmdOption) + # + # There is external tool which does not follow standard ru= le which return nonzero if tool fails + # The output file has to be checked + # + + if not os.path.exists(TempFile) : + EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to ca= ll %s, no output file was generated' % ExternalTool) + + FileHandleIn =3D open(DummyFile, 'rb') + FileHandleIn.seek(0, 2) + InputFileSize =3D FileHandleIn.tell() + + FileHandleOut =3D open(TempFile, 'rb') + FileHandleOut.seek(0, 2) + TempFileSize =3D FileHandleOut.tell() + + Attribute =3D [] + HeaderLength =3D None + if self.ExtraHeaderSize !=3D -1: + HeaderLength =3D str(self.ExtraHeaderSize) + + if self.ProcessRequired =3D=3D "NONE" and HeaderLength =3D= =3D None: + if TempFileSize > InputFileSize: + FileHandleIn.seek(0) + BufferIn =3D FileHandleIn.read() + FileHandleOut.seek(0) + BufferOut =3D FileHandleOut.read() + if BufferIn =3D=3D BufferOut[TempFileSize - InputF= ileSize:]: + HeaderLength =3D str(TempFileSize - InputFileS= ize) + #auto sec guided attribute with process required + if HeaderLength =3D=3D None: + Attribute.append('PROCESSING_REQUIRED') + + FileHandleIn.close() + FileHandleOut.close() + + if FirstCall and 'PROCESSING_REQUIRED' in Attribute: + # Guided data by -z option on first call is the proces= s required data. Call the guided tool with the real option. + GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], E= xternalTool, CmdOption) + + # + # Call Gensection Add Section Header + # + if self.ProcessRequired in ("TRUE", "1"): + if 'PROCESSING_REQUIRED' not in Attribute: + Attribute.append('PROCESSING_REQUIRED') + + if self.AuthStatusValid in ("TRUE", "1"): + Attribute.append('AUTH_STATUS_VALID') + GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile= ], Section.Section.SectionType['GUIDED'], + Guid=3Dself.NameGuid,= GuidAttr=3DAttribute, GuidHdrLen=3DHeaderLength) + + else: + #add input file for GenSec get PROCESSING_REQUIRED + GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], Exter= nalTool, CmdOption, IsMakefile=3DIsMakefile) + Attribute =3D [] + HeaderLength =3D None + if self.ExtraHeaderSize !=3D -1: + HeaderLength =3D str(self.ExtraHeaderSize) + if self.AuthStatusValid in ("TRUE", "1"): + Attribute.append('AUTH_STATUS_VALID') + if self.ProcessRequired =3D=3D "NONE" and HeaderLength =3D= =3D None: + GenFdsGlobalVariable.GenerateSection(OutputFile, [Temp= File], Section.Section.SectionType['GUIDED'], + Guid=3Dself.NameG= uid, GuidAttr=3DAttribute, + GuidHdrLen=3DHead= erLength, DummyFile=3DDummyFile, IsMakefile=3DIsMakefile) + else: + if self.ProcessRequired in ("TRUE", "1"): + if 'PROCESSING_REQUIRED' not in Attribute: + Attribute.append('PROCESSING_REQUIRED') + GenFdsGlobalVariable.GenerateSection(OutputFile, [Temp= File], Section.Section.SectionType['GUIDED'], + Guid=3Dself.NameG= uid, GuidAttr=3DAttribute, + GuidHdrLen=3DHead= erLength, IsMakefile=3DIsMakefile) =20 - # - # Call Gensection Add Section Header - # - if self.ProcessRequired in ("TRUE", "1"): - if 'PROCESSING_REQUIRED' not in Attribute: - Attribute.append('PROCESSING_REQUIRED') - - if self.AuthStatusValid in ("TRUE", "1"): - Attribute.append('AUTH_STATUS_VALID') - GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], S= ection.Section.SectionType['GUIDED'], - Guid=3Dself.NameGuid, Gui= dAttr=3DAttribute, GuidHdrLen=3DHeaderLength) OutputFileList =3D [] OutputFileList.append(OutputFile) if 'PROCESSING_REQUIRED' in Attribute: # reset guided section alignment to none for the processed= required guided data self.Alignment =3D None diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTo= ols/Source/Python/GenFds/OptRomFileStatement.py index 5e3273d..ab4fae6 100644 --- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation from FILE statement # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -37,11 +37,11 @@ class OptRomFileStatement: # # @param self The object pointer # @param Dict dictionary contains macro and value pair # @retval string Generated FFS file name # - def GenFfs(self, Dict =3D {}): + def GenFfs(self, Dict =3D {}, IsMakefile=3DFalse): =20 if self.FileName !=3D None: self.FileName =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(s= elf.FileName) =20 return self.FileName diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseToo= ls/Source/Python/GenFds/OptRomInfStatement.py index 069414d..80c4bba 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation from INF statement # -# Copyright (c) 2007, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -79,11 +79,11 @@ class OptRomInfStatement (FfsInfStatement): # Generate FFS # # @param self The object pointer # @retval string Generated .efi file name # - def GenFfs(self): + def GenFfs(self, IsMakefile=3DFalse): # # Parse Inf file get Module related information # =20 self.__InfParse__() @@ -96,28 +96,28 @@ class OptRomInfStatement (FfsInfStatement): #FileType =3D Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType] # # For the rule only has simpleFile # if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) : - EfiOutputList =3D self.__GenSimpleFileSection__(Rule) + EfiOutputList =3D self.__GenSimpleFileSection__(Rule, IsMakefi= le=3DIsMakefile) return EfiOutputList # # For Rule has ComplexFile # elif isinstance(Rule, RuleComplexFile.RuleComplexFile): - EfiOutputList =3D self.__GenComplexFileSection__(Rule) + EfiOutputList =3D self.__GenComplexFileSection__(Rule, IsMakef= ile=3DIsMakefile) return EfiOutputList =20 ## __GenSimpleFileSection__() method # # Get .efi files according to simple rule. # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenSimpleFileSection__(self, Rule): + def __GenSimpleFileSection__(self, Rule, IsMakefile =3D False): # # Prepare the parameter of GenSection # =20 OutputFileList =3D [] @@ -136,11 +136,11 @@ class OptRomInfStatement (FfsInfStatement): # # @param self The object pointer # @param Rule The rule object used to generate section # @retval string File name of the generated section file # - def __GenComplexFileSection__(self, Rule): + def __GenComplexFileSection__(self, Rule, IsMakefile=3DFalse): =20 OutputFileList =3D [] for Sect in Rule.SectionList: if Sect.SectionType =3D=3D 'PE32': if Sect.FileName !=3D None: diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source= /Python/GenFds/OptionRom.py index 7886a7c..2e61a38 100644 --- a/BaseTools/Source/Python/GenFds/OptionRom.py +++ b/BaseTools/Source/Python/GenFds/OptionRom.py @@ -1,9 +1,9 @@ ## @file # process OptionROM generation # -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -47,22 +47,22 @@ class OPTIONROM (OptionRomClassObject): # # @param self The object pointer # @param Buffer The buffer generated OptROM data will be put # @retval string Generated OptROM file path # - def AddToBuffer (self, Buffer) : - - GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..." %= self.DriverName) + def AddToBuffer (self, Buffer, Flag=3DFalse) : + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerating %s Option ROM ..= ." %self.DriverName) =20 EfiFileList =3D [] BinFileList =3D [] =20 # Process Modules in FfsList for FfsFile in self.FfsList : =20 if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement): - FilePathNameList =3D FfsFile.GenFfs() + FilePathNameList =3D FfsFile.GenFfs(IsMakefile=3DFlag) if len(FilePathNameList) =3D=3D 0: EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not= produce .efi files, so NO file could be put into option ROM." % (FfsFile.I= nfFileName)) if FfsFile.OverrideAttribs =3D=3D None: EfiFileList.extend(FilePathNameList) else: @@ -77,14 +77,15 @@ class OPTIONROM (OptionRomClassObject): [],=20 FfsFile.Overrid= eAttribs.NeedCompress,=20 FfsFile.Overrid= eAttribs.PciClassCode,=20 FfsFile.Overrid= eAttribs.PciRevision,=20 FfsFile.Overrid= eAttribs.PciDeviceId,=20 - FfsFile.Overrid= eAttribs.PciVendorId) + FfsFile.Overrid= eAttribs.PciVendorId, + IsMakefile =3D = Flag) BinFileList.append(TmpOutputFile) else: - FilePathName =3D FfsFile.GenFfs() + FilePathName =3D FfsFile.GenFfs(IsMakefile=3DFlag) if FfsFile.OverrideAttribs !=3D None: FileName =3D os.path.basename(FilePathName) TmpOutputDir =3D os.path.join(GenFdsGlobalVariable.FvD= ir, self.DriverName, FfsFile.CurrentArch) if not os.path.exists(TmpOutputDir) : os.makedirs(TmpOutputDir) @@ -95,11 +96,12 @@ class OPTIONROM (OptionRomClassObject): [],=20 FfsFile.Overrid= eAttribs.NeedCompress,=20 FfsFile.Overrid= eAttribs.PciClassCode,=20 FfsFile.Overrid= eAttribs.PciRevision,=20 FfsFile.Overrid= eAttribs.PciDeviceId,=20 - FfsFile.Overrid= eAttribs.PciVendorId) + FfsFile.Overrid= eAttribs.PciVendorId, + IsMakefile=3DFl= ag) BinFileList.append(TmpOutputFile) else: if FfsFile.FileType =3D=3D 'EFI': EfiFileList.append(FilePathName) else: @@ -112,14 +114,15 @@ class OPTIONROM (OptionRomClassObject): OutputFile =3D OutputFile + '.rom' =20 GenFdsGlobalVariable.GenerateOptionRom( OutputFile, EfiFileList, - BinFileList - ) + BinFileList, + IsMakefile=3DFlag) =20 - GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successf= ully" %self.DriverName) + if not Flag: + GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Succ= essfully" %self.DriverName) GenFdsGlobalVariable.SharpCounter =3D 0 =20 return OutputFile =20 class OverrideAttribs: diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Py= thon/GenFds/Region.py index 945c548..c946758 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -1,9 +1,9 @@ ## @file # process FD Region generation # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -72,15 +72,18 @@ class Region(RegionClassObject): # @param VtfDict VTF objects # @param MacroDict macro value pair # @retval string Generated FV file path # =20 - def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarit= y, ImageBinDict, vtfDict=3DNone, MacroDict=3D{}): + def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarit= y, ImageBinDict, vtfDict=3DNone, MacroDict=3D{}, Flag=3DFalse): Size =3D self.Size - GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x%X' = % self.Offset) - GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Size) + if not Flag: + GenFdsGlobalVariable.InfLogger('\nGenerate Region at Offset 0x= %X' % self.Offset) + GenFdsGlobalVariable.InfLogger(" Region Size =3D 0x%X" % Siz= e) GenFdsGlobalVariable.SharpCounter =3D 0 + if Flag and (self.RegionType !=3D 'FV'): + return =20 if self.RegionType =3D=3D 'FV': # # Get Fv from FvDict # @@ -89,30 +92,33 @@ class Region(RegionClassObject): FvOffset =3D 0 for RegionData in self.RegionDataList: FileName =3D None if RegionData.endswith(".fv"): RegionData =3D GenFdsGlobalVariable.MacroExtend(Region= Data, MacroDict) - GenFdsGlobalVariable.InfLogger(' Region FV File Name= =3D .fv : %s' % RegionData) + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region FV File = Name =3D .fv : %s' % RegionData) if RegionData[1] !=3D ':' : RegionData =3D mws.join (GenFdsGlobalVariable.Work= SpaceDir, RegionData) if not os.path.exists(RegionData): EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraDat= a=3DRegionData) =20 FileName =3D RegionData elif RegionData.upper() + 'fv' in ImageBinDict.keys(): - GenFdsGlobalVariable.InfLogger(' Region Name =3D FV') + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region Name =3D= FV') FileName =3D ImageBinDict[RegionData.upper() + 'fv'] else: # # Generate FvImage. # FvObj =3D None if RegionData.upper() in GenFdsGlobalVariable.FdfParse= r.Profile.FvDict.keys(): FvObj =3D GenFdsGlobalVariable.FdfParser.Profile.F= vDict.get(RegionData.upper()) =20 if FvObj !=3D None : - GenFdsGlobalVariable.InfLogger(' Region Name =3D= FV') + if not Flag: + GenFdsGlobalVariable.InfLogger(' Region Name= =3D FV') # # Call GenFv tool # self.BlockInfoOfRegion(BlockSizeList, FvObj) self.FvAddress =3D self.FvAddress + FvOffset @@ -122,11 +128,14 @@ class Region(RegionClassObject): "FV (%s) is NOT %s Aligned!" %= (FvObj.UiFvName, FvObj.FvAlignment)) FvBuffer =3D StringIO.StringIO('') FvBaseAddress =3D '0x%X' % self.FvAddress BlockSize =3D None BlockNum =3D None - FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSi= ze, BlockNum, ErasePolarity, vtfDict) + FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSi= ze, BlockNum, ErasePolarity, vtfDict, Flag=3DFlag) + if Flag: + continue + if FvBuffer.len > Size: FvBuffer.close() EdkLogger.error("GenFds", GENFDS_ERROR, "Size of FV (%s) is larger tha= n Region Size 0x%X specified." % (RegionData, Size)) # @@ -140,24 +149,26 @@ class Region(RegionClassObject): else: EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) i= s NOT described in FDF file!" % (RegionData)) # # Add the exist Fv image into FD buffer # - if FileName !=3D None: - FileLength =3D os.stat(FileName)[ST_SIZE] - if FileLength > Size: - EdkLogger.error("GenFds", GENFDS_ERROR, - "Size of FV File (%s) is larger th= an Region Size 0x%X specified." \ - % (RegionData, Size)) - BinFile =3D open(FileName, 'rb') - Buffer.write(BinFile.read()) - BinFile.close() - Size =3D Size - FileLength + if not Flag: + if FileName !=3D None: + FileLength =3D os.stat(FileName)[ST_SIZE] + if FileLength > Size: + EdkLogger.error("GenFds", GENFDS_ERROR, + "Size of FV File (%s) is large= r than Region Size 0x%X specified." \ + % (RegionData, Size)) + BinFile =3D open(FileName, 'rb') + Buffer.write(BinFile.read()) + BinFile.close() + Size =3D Size - FileLength # # Pad the left buffer # - self.PadBuffer(Buffer, ErasePolarity, Size) + if not Flag: + self.PadBuffer(Buffer, ErasePolarity, Size) =20 if self.RegionType =3D=3D 'CAPSULE': # # Get Capsule from Capsule Dict # diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/P= ython/GenFds/Section.py index 942dd5c..4c1aaac 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,9 +1,9 @@ ## @file # section base class # -# Copyright (c) 2007-2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007-2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -139,11 +139,11 @@ class Section (SectionClassObject): else: GenFdsGlobalVariable.VerboseLogger ("\nFile Type \= '%s\' of File %s in %s is not same with file type \'%s\' from Rule in FDF" = %(File.Type, File.File, FfsInf.InfFileName, FileType)) else: GenFdsGlobalVariable.InfLogger ("\nCurrent ARCH \'%s\'= of File %s is not in the Support Arch Scope of %s specified by INF %s in F= DF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName)) =20 - if Suffix !=3D None and os.path.exists(FfsInf.EfiOutputPath): + if Suffix !=3D None: # # Get Makefile path and time stamp # MakefileDir =3D FfsInf.EfiOutputPath[:-len('OUTPUT')] Makefile =3D os.path.join(MakefileDir, 'Makefile') diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source= /Python/GenFds/UiSection.py index 419e1ee..4f6926f 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -46,11 +46,11 @@ class UiSection (UiSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsInf !=3D None: self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) @@ -67,11 +67,10 @@ class UiSection (UiSectionClassObject): FileObj =3D open(FileNameStr, 'r') NameString =3D FileObj.read() FileObj.close() else: NameString =3D '' - - GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTIO= N_USER_INTERFACE', Ui=3DNameString) + GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTIO= N_USER_INTERFACE', Ui=3DNameString, IsMakefile=3DIsMakefile) =20 OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Sourc= e/Python/GenFds/VerSection.py index ad995d3..e290299 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -1,9 +1,9 @@ ## @file # process Version section generation # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License # which accompanies this distribution. The full text of the license may = be found at # http://opensource.org/licenses/bsd-license.php @@ -46,11 +46,11 @@ class VerSection (VerSectionClassObject): # @param KeyStringList Filter for inputs of section generation # @param FfsInf FfsInfStatement object that contains this sect= ion data # @param Dict dictionary contains macro and its value # @retval tuple (Generated file name, section alignment) # - def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}): + def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, Ff= sInf=3DNone, Dict=3D{}, IsMakefile =3D False): # # Prepare the parameter of GenSection # if FfsInf !=3D None: self.Alignment =3D FfsInf.__ExtendMacro__(self.Alignment) @@ -63,21 +63,20 @@ class VerSection (VerSectionClassObject): OutputFile =3D os.path.normpath(OutputFile) =20 # Get String Data StringData =3D '' if self.StringData !=3D None: - StringData =3D self.StringData + StringData =3D self.StringData elif self.FileName !=3D None: FileNameStr =3D GenFdsGlobalVariable.ReplaceWorkspaceMacro(sel= f.FileName) FileNameStr =3D GenFdsGlobalVariable.MacroExtend(FileNameStr, = Dict) FileObj =3D open(FileNameStr, 'r') StringData =3D FileObj.read() StringData =3D '"' + StringData + '"' FileObj.close() else: StringData =3D '' - GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_= VERSION', - Ver=3DStringData, BuildNumber= =3Dself.BuildNum) + Ver=3DStringData, BuildNumber= =3Dself.BuildNum, IsMakefile=3DIsMakefile) OutputFileList =3D [] OutputFileList.append(OutputFile) return OutputFileList, self.Alignment diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 53f1245..f94285a 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -48,10 +48,11 @@ from BuildReport import BuildReport from GenPatchPcdTable.GenPatchPcdTable import * from PatchPcdValue.PatchPcdValue import * =20 import Common.EdkLogger import Common.GlobalData as GlobalData +from GenFds.GenFds import GenFds =20 # Version and Copyright VersionNumber =3D "0.60" + ' ' + gBUILD_VERSION __version__ =3D "%prog Version " + VersionNumber __copyright__ =3D "Copyright (c) 2007 - 2017, Intel Corporation All right= s reserved." @@ -772,10 +773,11 @@ class Build(): #Set global flag for build mode GlobalData.gIgnoreSource =3D BuildOptions.IgnoreSources GlobalData.gUseHashCache =3D BuildOptions.UseHashCache GlobalData.gBinCacheDest =3D BuildOptions.BinCacheDest GlobalData.gBinCacheSource =3D BuildOptions.BinCacheSource + GlobalData.gEnableGenfdsMultiThread =3D BuildOptions.GenfdsMultiTh= read =20 if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache: EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--= binary-destination must be used together with --hash.") =20 if GlobalData.gBinCacheSource and not GlobalData.gUseHashCache: @@ -1206,11 +1208,11 @@ class Build(): # @param CreateDepModuleCodeFile Flag used to indicate creating= code # for dependent modules/Libraries # @param CreateDepModuleMakeFile Flag used to indicate creating= makefile # for dependent modules/Libraries # - def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=3DTrue, C= reateDepsMakeFile=3DTrue, BuildModule=3DFalse): + def _BuildPa(self, Target, AutoGenObject, CreateDepsCodeFile=3DTrue, C= reateDepsMakeFile=3DTrue, BuildModule=3DFalse, FfsCommand=3D{}): if AutoGenObject =3D=3D None: return False =20 # skip file generation for cleanxxx targets, run and fds target if Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']: @@ -1222,11 +1224,11 @@ class Build(): if Target =3D=3D "genc": return True =20 if not self.SkipAutoGen or Target =3D=3D 'genmake': self.Progress.Start("Generating makefile") - AutoGenObject.CreateMakeFile(CreateDepsMakeFile) + AutoGenObject.CreateMakeFile(CreateDepsMakeFile, FfsComman= d) self.Progress.Stop("done!") if Target =3D=3D "genmake": return True else: # always recreate top/platform makefile when clean, just in ca= se of inconsistency @@ -1729,20 +1731,26 @@ class Build(): ) self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) self.Progress.Stop("done!") + + # Add ffs build to makefile + CmdListDict =3D {} + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict =3D self._GenFfsCmd() + for Arch in Wa.ArchList: GlobalData.gGlobalDefines['ARCH'] =3D Arch Pa =3D PlatformAutoGen(Wa, self.PlatformFile, BuildTar= get, ToolChain, Arch) for Module in Pa.Platform.Modules: # Get ModuleAutoGen object to generate C code file= and makefile Ma =3D ModuleAutoGen(Wa, Module, BuildTarget, Tool= Chain, Arch, self.PlatformFile) if Ma =3D=3D None: continue self.BuildModules.append(Ma) - self._BuildPa(self.Target, Pa) + self._BuildPa(self.Target, Pa, FfsCommand=3DCmdListDic= t) =20 # Create MAP file when Load Fix Address is enabled. if self.Target in ["", "all", "fds"]: for Arch in Wa.ArchList: GlobalData.gGlobalDefines['ARCH'] =3D Arch @@ -1817,10 +1825,14 @@ class Build(): self.ModuleFile ) self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress Wa.CreateMakeFile(False) + # Add ffs build to makefile + CmdListDict =3D None + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict =3D self._GenFfsCmd() self.Progress.Stop("done!") MaList =3D [] ExitFlag =3D threading.Event() ExitFlag.clear() self.AutoGenTime +=3D int(round((time.time() - WorkspaceAu= toGenTime))) @@ -1836,11 +1848,15 @@ class Build(): if self.Target not in ['clean', 'cleanlib', 'c= leanall', 'run', 'fds']: # for target which must generate AutoGen c= ode and makefile if not self.SkipAutoGen or self.Target =3D= =3D 'genc': Ma.CreateCodeFile(True) if not self.SkipAutoGen or self.Target =3D= =3D 'genmake': - Ma.CreateMakeFile(True) + if CmdListDict and self.Fdf and (Modul= e.File, Arch) in CmdListDict: + Ma.CreateMakeFile(True, CmdListDic= t[Module.File, Arch]) + del CmdListDict[Module.File, Arch] + else: + Ma.CreateMakeFile(True) MaList.append(Ma) self.BuildModules.append(Ma) self.AutoGenTime +=3D int(round((time.time() - AutoGen= Start))) MakeStart =3D time.time() for Ma in self.BuildModules: @@ -1920,10 +1936,21 @@ class Build(): # # Save MAP buffer into MAP file. # self._SaveMapFile (MapBuffer, Wa) =20 + def _GenFfsCmd(self): + CmdListDict =3D {} + GenFfsDict =3D GenFds.GenFfsMakefile('', GlobalData.gFdfParser, se= lf, self.ArchList, GlobalData) + for Cmd in GenFfsDict: + tmpInf, tmpArch =3D GenFfsDict[Cmd] + if (tmpInf, tmpArch) not in CmdListDict.keys(): + CmdListDict[tmpInf, tmpArch] =3D [Cmd] + else: + CmdListDict[tmpInf, tmpArch].append(Cmd) + return CmdListDict + ## Build a platform in multi-thread mode # def _MultiThreadBuildPlatform(self): SaveFileOnChange(self.PlatformBuildPath, '# DO NOT EDIT \n# FILE a= uto-generated\n', False) for BuildTarget in self.BuildTargetList: @@ -1955,10 +1982,15 @@ class Build(): self.Fdf =3D Wa.FdfFile self.LoadFixAddress =3D Wa.Platform.LoadFixAddress self.BuildReport.AddPlatformReport(Wa) Wa.CreateMakeFile(False) =20 + # Add ffs build to makefile + CmdListDict =3D None + if GlobalData.gEnableGenfdsMultiThread and self.Fdf: + CmdListDict =3D self._GenFfsCmd() + # multi-thread exit flag ExitFlag =3D threading.Event() ExitFlag.clear() self.AutoGenTime +=3D int(round((time.time() - WorkspaceAu= toGenTime))) for Arch in Wa.ArchList: @@ -1993,11 +2025,15 @@ class Build(): Ma.CreateCodeFile(True) if self.Target =3D=3D "genc": continue =20 if not self.SkipAutoGen or self.Target =3D=3D = 'genmake': - Ma.CreateMakeFile(True) + if CmdListDict and self.Fdf and (Module.Fi= le, Arch) in CmdListDict: + Ma.CreateMakeFile(True, CmdListDict[Mo= dule.File, Arch]) + del CmdListDict[Module.File, Arch] + else: + Ma.CreateMakeFile(True) if self.Target =3D=3D "genmake": continue self.BuildModules.append(Ma) self.Progress.Stop("done!") self.AutoGenTime +=3D int(round((time.time() - AutoGen= Start))) @@ -2309,11 +2345,11 @@ def MyOptionParser(): Parser.add_option("--pcd", action=3D"append", dest=3D"OptionPcd", help= =3D"Set PCD value by command line. Format: \"PcdName=3DValue\" ") Parser.add_option("-l", "--cmd-len", action=3D"store", type=3D"int", d= est=3D"CommandLength", help=3D"Specify the maximum line length of build com= mand. Default is 4096.") Parser.add_option("--hash", action=3D"store_true", dest=3D"UseHashCach= e", default=3DFalse, help=3D"Enable hash-based caching during build process= .") Parser.add_option("--binary-destination", action=3D"store", type=3D"st= ring", dest=3D"BinCacheDest", help=3D"Generate a cache of binary files in t= he specified directory.") Parser.add_option("--binary-source", action=3D"store", type=3D"string"= , dest=3D"BinCacheSource", help=3D"Consume a cache of binary files from the= specified directory.") - + Parser.add_option("--genfds-multi-thread", action=3D"store_true", dest= =3D"GenfdsMultiThread", default=3DFalse, help=3D"Enable GenFds multi thread= to generate ffs file.") (Opt, Args) =3D Parser.parse_args() return (Opt, Args) =20 ## Tool entrance method # --=20 2.6.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel