From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ml01.01.org (Postfix) with ESMTP id A7AA41A1E05 for ; Thu, 18 Aug 2016 22:41:08 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP; 18 Aug 2016 22:41:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,543,1464678000"; d="scan'208";a="868061083" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 18 Aug 2016 22:41:08 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 18 Aug 2016 22:41:07 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.248.2; Thu, 18 Aug 2016 22:41:07 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.181]) with mapi id 14.03.0248.002; Fri, 19 Aug 2016 13:41:06 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch 3/3] BaseTools: FMP capsule add the support to generate auth info Thread-Index: AQHR9s2SZZVzATKQ/UuopJN8MqKMpKBPyujw Date: Fri, 19 Aug 2016 05:41:05 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155ECE77@shsmsx102.ccr.corp.intel.com> References: <1471249059-95652-1-git-send-email-yonghong.zhu@intel.com> <1471249059-95652-4-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1471249059-95652-4-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch 3/3] BaseTools: FMP capsule add the support to generate auth info X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2016 05:41:09 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhu, Yonghong > Sent: Monday, August 15, 2016 4:18 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [Patch 3/3] BaseTools: FMP capsule add the support to generate > auth info >=20 > Current BaseTools cannot generate > EFI_FIRMWARE_IMAGE_AUTHENTICATION > for FMP capsule. this patch fix it by FDF spec's update to add the > definition for CERTIFICATE_GUID and MONOTONIC_COUNT. BaseTools call > the tool by CERTIFICATE_GUID to generate the certdata and fill the header > info. >=20 > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Yonghong Zhu > --- > BaseTools/Source/Python/GenFds/Capsule.py | 80 > +++++++++++++++++++++++++-- > BaseTools/Source/Python/GenFds/CapsuleData.py | 4 +- > BaseTools/Source/Python/GenFds/FdfParser.py | 64 > ++++++++++++++++++--- > BaseTools/Source/Python/GenFds/GenFds.py | 59 > +++++++++++++++++++- > BaseTools/Source/Python/GenFds/GuidSection.py | 59 +------------------- > 5 files changed, 194 insertions(+), 72 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/GenFds/Capsule.py > b/BaseTools/Source/Python/GenFds/Capsule.py > index 1683433..f8af12a 100644 > --- a/BaseTools/Source/Python/GenFds/Capsule.py > +++ b/BaseTools/Source/Python/GenFds/Capsule.py > @@ -1,9 +1,9 @@ > ## @file > # generate capsule > # > -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved. > +# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved. > # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the > BSD License > # which accompanies this distribution. The full text of the license ma= y be > found at > # http://opensource.org/licenses/bsd-license.php > @@ -23,13 +23,20 @@ import StringIO > from Common.Misc import SaveFileOnChange > from GenFds import GenFds > from Common.Misc import PackRegistryFormatGuid > import uuid > from struct import pack > +from GenFds import FindExtendTool > +from Common import EdkLogger > +from Common.BuildToolError import * >=20 >=20 > T_CHAR_LF =3D '\n' > +WIN_CERT_REVISION =3D 0x0200 > +WIN_CERT_TYPE_EFI_GUID =3D 0x0EF1 > +EFI_CERT_TYPE_PKCS7_GUID =3D uuid.UUID('{4aafd29d-68df-49ee-8aa9- > 347d375665a7}') > +EFI_CERT_TYPE_RSA2048_SHA256_GUID =3D uuid.UUID('{a7717414-c616- > 4977-9420-844712a735bf}') >=20 > ## create inf file describes what goes into capsule and call GenFv to > generate capsule > # > # > class Capsule (CapsuleClassObject) : > @@ -96,24 +103,87 @@ class Capsule (CapsuleClassObject) : > else: > FwMgrHdr.write(pack('=3DI', 0x00000001)) > FwMgrHdr.write(pack('=3DHH', len(self.CapsuleDataList), > len(self.FmpPayloadList))) > FwMgrHdrSize =3D > 4+2+2+8*(len(self.CapsuleDataList)+len(self.FmpPayloadList)) >=20 > + # > + # typedef struct _WIN_CERTIFICATE { > + # UINT32 dwLength; > + # UINT16 wRevision; > + # UINT16 wCertificateType; > + # //UINT8 bCertificate[ANYSIZE_ARRAY]; > + # } WIN_CERTIFICATE; > + # > + # typedef struct _WIN_CERTIFICATE_UEFI_GUID { > + # WIN_CERTIFICATE Hdr; > + # EFI_GUID CertType; > + # //UINT8 CertData[ANYSIZE_ARRAY]; > + # } WIN_CERTIFICATE_UEFI_GUID; > + # > + # typedef struct { > + # UINT64 MonotonicCount; > + # WIN_CERTIFICATE_UEFI_GUID AuthInfo; > + # } EFI_FIRMWARE_IMAGE_AUTHENTICATION; > + # > + # typedef struct _EFI_CERT_BLOCK_RSA_2048_SHA256 { > + # EFI_GUID HashType; > + # UINT8 PublicKey[256]; > + # UINT8 Signature[256]; > + # } EFI_CERT_BLOCK_RSA_2048_SHA256; > + # > + > PreSize =3D FwMgrHdrSize > Content =3D StringIO.StringIO() > for driver in self.CapsuleDataList: > FileName =3D driver.GenCapsuleSubItem() > FwMgrHdr.write(pack('=3DQ', PreSize)) > PreSize +=3D os.path.getsize(FileName) > File =3D open(FileName, 'rb') > Content.write(File.read()) > File.close() > for fmp in self.FmpPayloadList: > - payload =3D fmp.GenCapsuleSubItem() > - FwMgrHdr.write(pack('=3DQ', PreSize)) > - PreSize +=3D len(payload) > - Content.write(payload) > + if fmp.Certificate_Guid: > + ExternalTool, ExternalOption =3D FindExtendTool([], > GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) > + CmdOption =3D '' > + CapInputFile =3D fmp.ImageFile > + if not os.path.isabs(fmp.ImageFile): > + CapInputFile =3D os.path.join(GenFdsGlobalVariable.W= orkSpaceDir, > fmp.ImageFile) > + CapOutputTmp =3D os.path.join(GenFdsGlobalVariable.FvDir= , > self.UiCapsuleName) + '.tmp' > + if ExternalTool =3D=3D None: > + EdkLogger.error("GenFds", GENFDS_ERROR, "No tool fou= nd with > GUID %s" % fmp.Certificate_Guid) > + else: > + CmdOption +=3D ExternalTool > + if ExternalOption: > + CmdOption =3D CmdOption + ' ' + ExternalOption > + CmdOption +=3D ' -e ' + ' --monotonic-count ' + > str(fmp.MonotonicCount) + ' -o ' + CapOutputTmp + ' ' + CapInputFile > + CmdList =3D CmdOption.split() > + GenFdsGlobalVariable.CallExternalTool(CmdList, "Failed t= o generate > FMP auth capsule") > + if uuid.UUID(fmp.Certificate_Guid) =3D=3D > EFI_CERT_TYPE_PKCS7_GUID: > + dwLength =3D 4 + 2 + 2 + 16 + os.path.getsize(CapOut= putTmp) - > os.path.getsize(CapInputFile) > + else: > + dwLength =3D 4 + 2 + 2 + 16 + 16 + 256 + 256 > + Buffer =3D pack('Q', fmp.MonotonicCount) > + Buffer +=3D pack('I', dwLength) > + Buffer +=3D pack('H', WIN_CERT_REVISION) > + Buffer +=3D pack('H', WIN_CERT_TYPE_EFI_GUID) > + Buffer +=3D uuid.UUID(fmp.Certificate_Guid).get_bytes_le= () > + if os.path.exists(CapOutputTmp): > + TmpFile =3D open(CapOutputTmp, 'rb') > + Buffer +=3D TmpFile.read() > + TmpFile.close() > + if fmp.VendorCodeFile: > + VendorFile =3D open(fmp.VendorCodeFile, 'rb') > + Buffer +=3D VendorFile.read() > + VendorFile.close() > + FwMgrHdr.write(pack('=3DQ', PreSize)) > + PreSize +=3D len(Buffer) > + Content.write(Buffer) > + else: > + payload =3D fmp.GenCapsuleSubItem() > + FwMgrHdr.write(pack('=3DQ', PreSize)) > + PreSize +=3D len(payload) > + Content.write(payload) > BodySize =3D len(FwMgrHdr.getvalue()) + len(Content.getvalue()) > Header.write(pack('=3DI', HdrSize + BodySize)) > # > # The real capsule header structure is 28 bytes > # > diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py > b/BaseTools/Source/Python/GenFds/CapsuleData.py > index efc2812..2a5c454 100644 > --- a/BaseTools/Source/Python/GenFds/CapsuleData.py > +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py > @@ -1,9 +1,9 @@ > ## @file > # generate capsule > # > -# Copyright (c) 2007-2013, Intel Corporation. All rights reserved.
> +# Copyright (c) 2007-2016, Intel Corporation. All rights reserved.
> # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the > BSD License > # which accompanies this distribution. The full text of the license ma= y be > found at > # http://opensource.org/licenses/bsd-license.php > @@ -178,10 +178,12 @@ class CapsulePayload(CapsuleData): > self.ImageTypeId =3D None > self.ImageIndex =3D None > self.HardwareInstance =3D None > self.ImageFile =3D None > self.VendorCodeFile =3D None > + self.Certificate_Guid =3D None > + self.MonotonicCount =3D None >=20 > def GenCapsuleSubItem(self): > if not self.Version: > self.Version =3D 0x00000002 > ImageFileSize =3D os.path.getsize(self.ImageFile) > diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py > b/BaseTools/Source/Python/GenFds/FdfParser.py > index 8709cfc..02ae7c9 100644 > --- a/BaseTools/Source/Python/GenFds/FdfParser.py > +++ b/BaseTools/Source/Python/GenFds/FdfParser.py > @@ -50,15 +50,17 @@ from Common.Misc import PathClass > from Common.String import NormPath > import Common.GlobalData as GlobalData > from Common.Expression import * > from Common import GlobalData > from Common.String import ReplaceMacro > - > +import uuid > from Common.Misc import tdict >=20 > import Common.LongFilePathOs as os > from Common.LongFilePathSupport import OpenLongFilePath as open > +from Capsule import EFI_CERT_TYPE_PKCS7_GUID > +from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID >=20 > ##define T_CHAR_SPACE ' ' > ##define T_CHAR_NULL '\0' > ##define T_CHAR_CR '\r' > ##define T_CHAR_TAB '\t' > @@ -1122,10 +1124,30 @@ class FdfParser: > return True > else: > self.__UndoToken() > return False >=20 > + def __Verify(self, Name, Value, Scope): > + if Scope in ['UINT64', 'UINT8']: > + ValueNumber =3D 0 > + try: > + if Value.upper().startswith('0X'): > + ValueNumber =3D int (Value, 16) > + else: > + ValueNumber =3D int (Value) > + except: > + EdkLogger.error("FdfParser", FORMAT_INVALID, "The value = is not > valid dec or hex number for %s." % Name) > + if ValueNumber < 0: > + EdkLogger.error("FdfParser", FORMAT_INVALID, "The value = can't > be set to negative value for %s." % Name) > + if Scope =3D=3D 'UINT64': > + if ValueNumber >=3D 0x10000000000000000: > + EdkLogger.error("FdfParser", FORMAT_INVALID, "Too la= rge value > for %s." % Name) > + if Scope =3D=3D 'UINT8': > + if ValueNumber >=3D 0x100: > + EdkLogger.error("FdfParser", FORMAT_INVALID, "Too la= rge value > for %s." % Name) > + return True > + > ## __UndoToken() method > # > # Go back one token unit in file buffer > # > # @param self The object pointer > @@ -3185,44 +3207,70 @@ class FdfParser: > if not self.__IsToken( "]"): > raise Warning("expected ']'", self.FileName, self.CurrentLin= eNumber) >=20 > if not self.__GetNextToken(): > raise Warning("The FMP payload section is empty!", self.File= Name, > self.CurrentLineNumber) > - FmpKeyList =3D ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', > 'IMAGE_INDEX', 'HARDWARE_INSTANCE'] > + FmpKeyList =3D ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', > 'IMAGE_INDEX', 'HARDWARE_INSTANCE', 'CERTIFICATE_GUID', > 'MONOTONIC_COUNT'] > while self.__Token in FmpKeyList: > Name =3D self.__Token > FmpKeyList.remove(Name) > if not self.__IsToken("=3D"): > raise Warning("expected '=3D'", self.FileName, > self.CurrentLineNumber) > if Name =3D=3D 'IMAGE_TYPE_ID': > if not self.__GetNextGuid(): > - raise Warning("expected GUID value for IMAGE_TYPE_ID= ", > self.FileName, self.CurrentLineNumber) > + raise Warning("expected GUID value for IMAGE_TYPE_ID= .", > self.FileName, self.CurrentLineNumber) > FmpData.ImageTypeId =3D self.__Token > + elif Name =3D=3D 'CERTIFICATE_GUID': > + if not self.__GetNextGuid(): > + raise Warning("expected GUID value for CERTIFICATE_G= UID.", > self.FileName, self.CurrentLineNumber) > + FmpData.Certificate_Guid =3D self.__Token > + if uuid.UUID(FmpData.Certificate_Guid) !=3D > EFI_CERT_TYPE_RSA2048_SHA256_GUID and > uuid.UUID(FmpData.Certificate_Guid) !=3D EFI_CERT_TYPE_PKCS7_GUID: > + raise Warning("Only support > EFI_CERT_TYPE_RSA2048_SHA256_GUID or EFI_CERT_TYPE_PKCS7_GUID for > CERTIFICATE_GUID.", self.FileName, self.CurrentLineNumber) > else: > if not self.__GetNextToken(): > raise Warning("expected value of %s" % Name, self.Fi= leName, > self.CurrentLineNumber) > Value =3D self.__Token > if Name =3D=3D 'IMAGE_HEADER_INIT_VERSION': > - FmpData.Version =3D Value > + if self.__Verify(Name, Value, 'UINT8'): > + FmpData.Version =3D Value > elif Name =3D=3D 'IMAGE_INDEX': > - FmpData.ImageIndex =3D Value > + if self.__Verify(Name, Value, 'UINT8'): > + FmpData.ImageIndex =3D Value > elif Name =3D=3D 'HARDWARE_INSTANCE': > - FmpData.HardwareInstance =3D Value > + if self.__Verify(Name, Value, 'UINT8'): > + FmpData.HardwareInstance =3D Value > + elif Name =3D=3D 'MONOTONIC_COUNT': > + if self.__Verify(Name, Value, 'UINT64'): > + FmpData.MonotonicCount =3D Value > + if FmpData.MonotonicCount.upper().startswith('0X= '): > + FmpData.MonotonicCount =3D > (long)(FmpData.MonotonicCount, 16) > + else: > + FmpData.MonotonicCount =3D > (long)(FmpData.MonotonicCount) > if not self.__GetNextToken(): > break > else: > self.__UndoToken() >=20 > + if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or > (not FmpData.MonotonicCount and FmpData.Certificate_Guid): > + EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GU= ID > and MONOTONIC_COUNT must be work as a pair.") > + # remove CERTIFICATE_GUID and MONOTONIC_COUNT from > FmpKeyList, since these keys are optional > + if 'CERTIFICATE_GUID' in FmpKeyList: > + FmpKeyList.remove('CERTIFICATE_GUID') > + if 'MONOTONIC_COUNT' in FmpKeyList: > + FmpKeyList.remove('MONOTONIC_COUNT') > if FmpKeyList: > - raise Warning("Missing keywords %s in FMP payload section" %= ', > '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) > + raise Warning("Missing keywords %s in FMP payload section." = % ', > '.join(FmpKeyList), self.FileName, self.CurrentLineNumber) > ImageFile =3D self.__ParseRawFileStatement() > if not ImageFile: > - raise Warning("Missing image file in FMP payload section", > self.FileName, self.CurrentLineNumber) > + raise Warning("Missing image file in FMP payload section.", > self.FileName, self.CurrentLineNumber) > FmpData.ImageFile =3D ImageFile > VendorCodeFile =3D self.__ParseRawFileStatement() > if VendorCodeFile: > FmpData.VendorCodeFile =3D VendorCodeFile > + AdditionalFile =3D self.__ParseRawFileStatement() > + if AdditionalFile: > + raise Warning("At most one Image file and one Vendor code fi= le are > allowed in FMP payload section.", self.FileName, self.CurrentLineNumber) > self.Profile.FmpPayloadDict[FmpUiName] =3D FmpData > return True >=20 > ## __GetCapsule() method > # > diff --git a/BaseTools/Source/Python/GenFds/GenFds.py > b/BaseTools/Source/Python/GenFds/GenFds.py > index 68232c5..1a0ec7a 100644 > --- a/BaseTools/Source/Python/GenFds/GenFds.py > +++ b/BaseTools/Source/Python/GenFds/GenFds.py > @@ -410,11 +410,68 @@ def > BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, > PcdDatumType, Val > Value =3D '1' > elif Value =3D=3D 'FALSE' or Value =3D=3D '0': > Value =3D '0' > return Value >=20 > - > +## FindExtendTool() > +# > +# Find location of tools to process data > +# > +# @param KeyStringList Filter for inputs of section generation > +# @param CurrentArchList Arch list > +# @param NameGuid The Guid name > +# > +def FindExtendTool(KeyStringList, CurrentArchList, NameGuid): > + # if user not specify filter, try to deduce it from global data. > + if KeyStringList =3D=3D None or KeyStringList =3D=3D []: > + Target =3D GenFdsGlobalVariable.TargetName > + ToolChain =3D GenFdsGlobalVariable.ToolChainTag > + ToolDb =3D > ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxt > Database > + if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: > + EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find extern= al > tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) > + KeyStringList =3D [Target + '_' + ToolChain + '_' + CurrentArchL= ist[0]] > + for Arch in CurrentArchList: > + if Target + '_' + ToolChain + '_' + Arch not in KeyStringLis= t: > + KeyStringList.append(Target + '_' + ToolChain + '_' + Ar= ch) > + > + if GenFdsGlobalVariable.GuidToolDefinition: > + if NameGuid in GenFdsGlobalVariable.GuidToolDefinition.keys(): > + return GenFdsGlobalVariable.GuidToolDefinition[NameGuid] > + > + ToolDefinition =3D > ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxt > Dictionary > + ToolPathTmp =3D None > + ToolOption =3D None > + for ToolDef in ToolDefinition.items(): > + if NameGuid =3D=3D ToolDef[1]: > + KeyList =3D ToolDef[0].split('_') > + Key =3D KeyList[0] + \ > + '_' + \ > + KeyList[1] + \ > + '_' + \ > + KeyList[2] > + if Key in KeyStringList and KeyList[4] =3D=3D 'GUID': > + > + ToolPath =3D ToolDefinition.get(Key + \ > + '_' + \ > + KeyList[3] + \ > + '_' + \ > + 'PATH') > + > + ToolOption =3D ToolDefinition.get(Key + \ > + '_' + \ > + KeyList[3] + \ > + '_' + \ > + 'FLAGS') > + if ToolPathTmp =3D=3D None: > + ToolPathTmp =3D ToolPath > + else: > + if ToolPathTmp !=3D ToolPath: > + EdkLogger.error("GenFds", GENFDS_ERROR, "Don't k= now which > tool to use, %s or %s ?" % (ToolPathTmp, ToolPath)) > + > + GenFdsGlobalVariable.GuidToolDefinition[NameGuid] =3D (ToolPathTmp, > ToolOption) > + return ToolPathTmp, ToolOption > + > ## Parse command line options > # > # Using standard Python module optparse to parse command line option of > this tool. > # > # @retval Opt A optparse.Values object containing the parsed options > diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py > b/BaseTools/Source/Python/GenFds/GuidSection.py > index ac5ae58..f199dcd 100644 > --- a/BaseTools/Source/Python/GenFds/GuidSection.py > +++ b/BaseTools/Source/Python/GenFds/GuidSection.py > @@ -25,10 +25,11 @@ from Common import ToolDefClassObject > import sys > from Common import EdkLogger > from Common.BuildToolError import * > from FvImageSection import FvImageSection > from Common.LongFilePathSupport import OpenLongFilePath as open > +from GenFds import FindExtendTool >=20 > ## generate GUIDed section > # > # > class GuidSection(GuidSectionClassObject) : > @@ -126,11 +127,11 @@ class GuidSection(GuidSectionClassObject) : > OutputFile =3D os.path.normpath(OutputFile) >=20 > ExternalTool =3D None > ExternalOption =3D None > if self.NameGuid !=3D None: > - ExternalTool, ExternalOption =3D self.__FindExtendTool__() > + ExternalTool, ExternalOption =3D FindExtendTool(self.KeyStri= ngList, > self.CurrentArchList, self.NameGuid) >=20 > # > # If not have GUID , call default > # GENCRC32 section > # > @@ -247,63 +248,7 @@ class GuidSection(GuidSectionClassObject) : > self.Alignment =3D None > self.IncludeFvSection =3D False > self.ProcessRequired =3D "TRUE" > return OutputFileList, self.Alignment >=20 > - ## __FindExtendTool() > - # > - # Find location of tools to process section data > - # > - # @param self The object pointer > - # > - def __FindExtendTool__(self): > - # if user not specify filter, try to deduce it from global data. > - if self.KeyStringList =3D=3D None or self.KeyStringList =3D=3D [= ]: > - Target =3D GenFdsGlobalVariable.TargetName > - ToolChain =3D GenFdsGlobalVariable.ToolChainTag > - ToolDb =3D > ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxt > Database > - if ToolChain not in ToolDb['TOOL_CHAIN_TAG']: > - EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find ex= ternal > tool because tool tag %s is not defined in tools_def.txt!" % ToolChain) > - self.KeyStringList =3D [Target + '_' + ToolChain + '_' + > self.CurrentArchList[0]] > - for Arch in self.CurrentArchList: > - if Target + '_' + ToolChain + '_' + Arch not in self.Key= StringList: > - self.KeyStringList.append(Target + '_' + ToolChain += '_' + Arch) > - > - if GenFdsGlobalVariable.GuidToolDefinition: > - if self.NameGuid in GenFdsGlobalVariable.GuidToolDefinition.= keys(): > - return GenFdsGlobalVariable.GuidToolDefinition[self.Name= Guid] > - > - ToolDefinition =3D > ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxt > Dictionary > - ToolPathTmp =3D None > - ToolOption =3D None > - for ToolDef in ToolDefinition.items(): > - if self.NameGuid =3D=3D ToolDef[1]: > - KeyList =3D ToolDef[0].split('_') > - Key =3D KeyList[0] + \ > - '_' + \ > - KeyList[1] + \ > - '_' + \ > - KeyList[2] > - if Key in self.KeyStringList and KeyList[4] =3D=3D 'GUID= ': > - > - ToolPath =3D ToolDefinition.get(Key + \ > - '_' + \ > - KeyList[3] + \ > - '_' + \ > - 'PATH') > - > - ToolOption =3D ToolDefinition.get(Key + \ > - '_' + \ > - KeyList[3] + \ > - '_' + \ > - 'FLAGS') > - if ToolPathTmp =3D=3D None: > - ToolPathTmp =3D ToolPath > - else: > - if ToolPathTmp !=3D ToolPath: > - EdkLogger.error("GenFds", GENFDS_ERROR, "Don= 't know > which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath)) > - > - GenFdsGlobalVariable.GuidToolDefinition[self.NameGuid] =3D > (ToolPathTmp, ToolOption) > - return ToolPathTmp, ToolOption > - >=20 >=20 > -- > 2.6.1.windows.1