From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=hesheng.chen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 0B34A21168235 for ; Mon, 15 Oct 2018 14:34:02 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Oct 2018 14:34:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,385,1534834800"; d="scan'208";a="78244135" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 15 Oct 2018 14:34:02 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 15 Oct 2018 14:34:01 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.48]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Tue, 16 Oct 2018 05:33:58 +0800 From: "Chen, Hesheng" To: "Carsey, Jaben" , "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH] BaseTools/EOT: Change to call a program instead of calling Python API. Thread-Index: AQHUZHFRigMIEX5T4EqUbuCCFtAQkqUgDrQAgADEIGA= Date: Mon, 15 Oct 2018 21:33:57 +0000 Message-ID: <3A06C110936C5348AEB96EBC072758C34D1B4E55@SHSMSX104.ccr.corp.intel.com> References: <1539599042-11740-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTAyODRiZGEtMjQ4MC00Mjk3LTk5ZmQtYTZjOGNjOTI3OGQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiK0VsZ3dES1h6SzZjSys1WEtvcXNZdW83SGJxVmwydGRpTXVPZFZPd3V6Y05wXC9rSStvUkF4ZENFc1p3RGVwSDIifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools/EOT: Change to call a program instead of calling Python API. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Oct 2018 21:34:03 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello Jaben, The API is provided by C code and we want Python tool to use it. The tool u= sed to call Python API from DLL files and now we need run Python tools from= source so we can't build a specific version of DLL binary for it. The DLL = file may be different for different version of Python. So now we just call = the C program directly for the API. Best Regards, Chen, Hess Intel China Software Center Tel: +86-21-6116-6740 Email: hesheng.chen@intel.com -----Original Message----- From: Carsey, Jaben=20 Sent: Tuesday, October 16, 2018 1:45 AM To: Zhu, Yonghong ; edk2-devel@lists.01.org Cc: Chen, Hesheng Subject: RE: [edk2] [PATCH] BaseTools/EOT: Change to call a program instead= of calling Python API. > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Yonghong Zhu > Sent: Monday, October 15, 2018 3:24 AM > To: edk2-devel@lists.01.org > Cc: Chen, Hesheng > Subject: [edk2] [PATCH] BaseTools/EOT: Change to call a program=20 > instead of calling Python API. >=20 > From: hchen30 >=20 > Update the EOT tool to call the program itself instead of calling the=20 > Python API when parsing FV images. Why do we prefer to launch the separate python program instead of calling t= he APIs? >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hess Chen > --- > BaseTools/Source/Python/Eot/{Eot.py =3D> EotMain.py} | 465=20 > +++-------------- > ---- > BaseTools/Source/Python/Eot/InfParserLite.py | 26 +- > BaseTools/Source/Python/Eot/Parser.py | 28 +- > BaseTools/Source/Python/Eot/Report.py | 6 +- > BaseTools/Source/Python/build/BuildReport.py | 2 +- > 5 files changed, 84 insertions(+), 443 deletions(-) rename=20 > BaseTools/Source/Python/Eot/{Eot.py =3D> EotMain.py} (75%) >=20 > diff --git a/BaseTools/Source/Python/Eot/Eot.py > b/BaseTools/Source/Python/Eot/EotMain.py > similarity index 75% > rename from BaseTools/Source/Python/Eot/Eot.py > rename to BaseTools/Source/Python/Eot/EotMain.py > index ce83da1495..49a1494126 100644 > --- a/BaseTools/Source/Python/Eot/Eot.py > +++ b/BaseTools/Source/Python/Eot/EotMain.py > @@ -17,18 +17,20 @@ > from __future__ import absolute_import import Common.LongFilePathOs=20 > as os, time, glob import Common.EdkLogger as EdkLogger -from . import=20 > EotGlobalData > +import Eot.EotGlobalData as EotGlobalData > from optparse import OptionParser > from Common.StringUtils import NormPath from Common import=20 > BuildToolError from Common.Misc import=20 > GuidStructureStringToGuidString, sdict -from .InfParserLite import *=20 > -from . import c -from . import Database > +from Eot.Parser import * > +from Eot.InfParserLite import EdkInfParser from Common.StringUtils=20 > +import GetSplitValueList from Eot import c from Eot import Database > from array import array > -from .Report import Report > +from Eot.Report import Report > from Common.BuildVersion import gBUILD_VERSION -from .Parser import=20 > ConvertGuid > +from Eot.Parser import ConvertGuid > from Common.LongFilePathSupport import OpenLongFilePath as open =20 > import struct import uuid @@ -58,14 +60,14 @@ class Image(array): >=20 > self._SubImages =3D sdict() # {offset: Image()} >=20 > - array.__init__(self, 'B') > + array.__init__(self) >=20 > def __repr__(self): > return self._ID_ >=20 > def __len__(self): > Len =3D array.__len__(self) > - for Offset in self._SubImages: > + for Offset in self._SubImages.keys(): > Len +=3D len(self._SubImages[Offset]) > return Len >=20 > @@ -154,19 +156,11 @@ class CompressedImage(Image): >=20 > def _GetSections(self): > try: > - from . import EfiCompressor > - TmpData =3D EfiCompressor.FrameworkDecompress( > - self[self._HEADER_SIZE_:], > - len(self) - self._HEADER_SIZE_ > - ) > + TmpData =3D DeCompress('Efi', self[self._HEADER_SIZE_:]) > DecData =3D array('B') > DecData.fromstring(TmpData) > except: > - from . import EfiCompressor > - TmpData =3D EfiCompressor.UefiDecompress( > - self[self._HEADER_SIZE_:], > - len(self) - self._HEADER_SIZE_ > - ) > + TmpData =3D DeCompress('Framework',=20 > + self[self._HEADER_SIZE_:]) > DecData =3D array('B') > DecData.fromstring(TmpData) >=20 > @@ -297,7 +291,7 @@ class Depex(Image): >=20 > Expression =3D property(_GetExpression) >=20 > -## FirmwareVolume() class > +# # FirmwareVolume() class > # > # A class for Firmware Volume > # > @@ -308,12 +302,12 @@ class FirmwareVolume(Image): >=20 > _FfsGuid =3D "8C8CE578-8A3D-4F1C-9935-896185C32DD3" >=20 > - _GUID_ =3D struct.Struct("16x 1I2H8B") > - _LENGTH_ =3D struct.Struct("16x 16x 1Q") > - _SIG_ =3D struct.Struct("16x 16x 8x 1I") > - _ATTR_ =3D struct.Struct("16x 16x 8x 4x 1I") > - _HLEN_ =3D struct.Struct("16x 16x 8x 4x 4x 1H") > - _CHECKSUM_ =3D struct.Struct("16x 16x 8x 4x 4x 2x 1H") > + _GUID_ =3D struct.Struct("16x 1I2H8B") > + _LENGTH_ =3D struct.Struct("16x 16x 1Q") > + _SIG_ =3D struct.Struct("16x 16x 8x 1I") > + _ATTR_ =3D struct.Struct("16x 16x 8x 4x 1I") > + _HLEN_ =3D struct.Struct("16x 16x 8x 4x 4x 1H") > + _CHECKSUM_ =3D struct.Struct("16x 16x 8x 4x 4x 2x 1H") >=20 > def __init__(self, Name=3D''): > Image.__init__(self) > @@ -387,7 +381,7 @@ class FirmwareVolume(Image): > DepexString =3D DepexList[0].strip() > return (CouldBeLoaded, DepexString, FileDepex) >=20 > - def Dispatch(self, Db =3D None): > + def Dispatch(self, Db=3DNone): > if Db is None: > return False > self.UnDispatchedFfsDict =3D copy.copy(self.FfsDict) @@ -397,7=20 > +391,7 @@ class FirmwareVolume(Image): > FfsDxeCoreGuid =3D None > FfsPeiPrioriGuid =3D None > FfsDxePrioriGuid =3D None > - for FfsID in self.UnDispatchedFfsDict: > + for FfsID in self.UnDispatchedFfsDict.keys(): > Ffs =3D self.UnDispatchedFfsDict[FfsID] > if Ffs.Type =3D=3D 0x03: > FfsSecCoreGuid =3D FfsID @@ -439,6 +433,7 @@ class=20 > FirmwareVolume(Image): > if GuidString in self.UnDispatchedFfsDict: > self.OrderedFfsDict[GuidString] =3D > self.UnDispatchedFfsDict.pop(GuidString) > self.LoadPpi(Db, GuidString) > + > self.DisPatchPei(Db) >=20 > # Parse DXE then > @@ -460,6 +455,7 @@ class FirmwareVolume(Image): > if GuidString in self.UnDispatchedFfsDict: > self.OrderedFfsDict[GuidString] =3D > self.UnDispatchedFfsDict.pop(GuidString) > self.LoadProtocol(Db, GuidString) > + > self.DisPatchDxe(Db) >=20 > def LoadProtocol(self, Db, ModuleGuid): > @@ -501,7 +497,7 @@ class FirmwareVolume(Image): > def DisPatchDxe(self, Db): > IsInstalled =3D False > ScheduleList =3D sdict() > - for FfsID in self.UnDispatchedFfsDict: > + for FfsID in self.UnDispatchedFfsDict.keys(): > CouldBeLoaded =3D False > DepexString =3D '' > FileDepex =3D None > @@ -548,7 +544,7 @@ class FirmwareVolume(Image): > else: > self.UnDispatchedFfsDict[FfsID].Depex =3D=20 > DepexString >=20 > - for FfsID in ScheduleList: > + for FfsID in ScheduleList.keys(): > NewFfs =3D ScheduleList.pop(FfsID) > FfsName =3D 'UnKnown' > self.OrderedFfsDict[FfsID] =3D NewFfs @@ -560,12 +556,13 @@= =20 > class FirmwareVolume(Image): > RecordSet =3D Db.TblReport.Exec(SqlCommand) > if RecordSet !=3D []: > FfsName =3D RecordSet[0][0] > + > if IsInstalled: > self.DisPatchDxe(Db) >=20 > def DisPatchPei(self, Db): > IsInstalled =3D False > - for FfsID in self.UnDispatchedFfsDict: > + for FfsID in self.UnDispatchedFfsDict.keys(): > CouldBeLoaded =3D True > DepexString =3D '' > FileDepex =3D None > @@ -576,7 +573,6 @@ class FirmwareVolume(Image): > if Section.Type =3D=3D 0x1B: > CouldBeLoaded, DepexString, FileDepex =3D=20 > self.ParseDepex(Section._SubImages[4], 'Ppi') > break > - > if Section.Type =3D=3D 0x01: > CompressSections =3D Section._SubImages[4] > for CompressSection in CompressSections.Sections= : > @@ -603,11 +599,12 @@ class FirmwareVolume(Image): > if IsInstalled: > self.DisPatchPei(Db) >=20 > + > def __str__(self): > global gIndention > gIndention +=3D 4 > FvInfo =3D '\n' + ' ' * gIndention > - FvInfo +=3D "[FV:%s] file_system=3D%s size=3D%x checksum=3D%s\n= " % > (self.Name, self.FileSystemGuid, self.Size, self.Checksum) > + FvInfo +=3D "[FV:%s] file_system=3D%s size=3D%x checksum=3D%s\n"= % > (self.Name, self.FileSystemGuid, self.Size, self.Checksum) > FfsInfo =3D "\n".join([str(self.FfsDict[FfsId]) for FfsId in sel= f.FfsDict]) > gIndention -=3D 4 > return FvInfo + FfsInfo > @@ -615,7 +612,7 @@ class FirmwareVolume(Image): > def _Unpack(self): > Size =3D self._LENGTH_.unpack_from(self._BUF_, self._OFF_)[0] > self.empty() > - self.extend(self._BUF_[self._OFF_:self._OFF_+Size]) > + self.extend(self._BUF_[self._OFF_:self._OFF_ + Size]) >=20 > # traverse the FFS > EndOfFv =3D Size > @@ -743,10 +740,9 @@ class GuidDefinedImage(Image): > SectionList.append(Sec) > elif Guid =3D=3D self.TIANO_COMPRESS_GUID: > try: > - from . import EfiCompressor > # skip the header > Offset =3D self.DataOffset - 4 > - TmpData =3D EfiCompressor.FrameworkDecompress(self[Offse= t:], > len(self)-Offset) > + TmpData =3D DeCompress('Framework', self[self.Offset:]) > DecData =3D array('B') > DecData.fromstring(TmpData) > Offset =3D 0 > @@ -764,10 +760,10 @@ class GuidDefinedImage(Image): > pass > elif Guid =3D=3D self.LZMA_COMPRESS_GUID: > try: > - from . import LzmaCompressor > # skip the header > Offset =3D self.DataOffset - 4 > - TmpData =3D LzmaCompressor.LzmaDecompress(self[Offset:], > len(self)-Offset) > + > + TmpData =3D DeCompress('Lzma', self[self.Offset:]) > DecData =3D array('B') > DecData.fromstring(TmpData) > Offset =3D 0 > @@ -848,7 +844,7 @@ class Section(Image): > SectionInfo +=3D "[SECTION:%s] offset=3D%x size=3D%x" %=20 > (self._TypeName[self.Type], self._OFF_, self.Size) > else: > SectionInfo +=3D "[SECTION:%x] offset=3D%x size=3D%= x "=20 > % (self.Type, self._OFF_, self.Size) > - for Offset in self._SubImages: > + for Offset in self._SubImages.keys(): > SectionInfo +=3D ", " + str(self._SubImages[Offset]) > gIndention -=3D 4 > return SectionInfo > @@ -982,7 +978,7 @@ class Ffs(Image): > FfsInfo =3D Indention > FfsInfo +=3D "[FFS:%s] offset=3D%x size=3D%x guid=3D%s free_spa= ce=3D%x=20 > alignment=3D%s\n" % \ > (Ffs._TypeName[self.Type], self._OFF_, self.Size,=20 > self.Guid, self.FreeSpace, self.Alignment) > - SectionInfo =3D '\n'.join([str(self.Sections[Offset]) for Offset= in > self.Sections]) > + SectionInfo =3D '\n'.join([str(self.Sections[Offset]) for=20 > + Offset in > self.Sections.keys()]) > gIndention -=3D 4 > return FfsInfo + SectionInfo + "\n" >=20 > @@ -1087,379 +1083,6 @@ class Ffs(Image): > Alignment =3D property(_GetAlignment) > State =3D property(_GetState, _SetState) >=20 > -## FirmwareVolume() class > -# > -# A class for Firmware Volume > -# > -class FirmwareVolume(Image): > - # Read FvLength, Attributes, HeaderLength, Checksum > - _HEADER_ =3D struct.Struct("16x 1I2H8B 1Q 4x 1I 1H 1H") > - _HEADER_SIZE_ =3D _HEADER_.size > - > - _FfsGuid =3D "8C8CE578-8A3D-4F1C-9935-896185C32DD3" > - > - _GUID_ =3D struct.Struct("16x 1I2H8B") > - _LENGTH_ =3D struct.Struct("16x 16x 1Q") > - _SIG_ =3D struct.Struct("16x 16x 8x 1I") > - _ATTR_ =3D struct.Struct("16x 16x 8x 4x 1I") > - _HLEN_ =3D struct.Struct("16x 16x 8x 4x 4x 1H") > - _CHECKSUM_ =3D struct.Struct("16x 16x 8x 4x 4x 2x 1H") > - > - def __init__(self, Name=3D''): > - Image.__init__(self) > - self.Name =3D Name > - self.FfsDict =3D sdict() > - self.OrderedFfsDict =3D sdict() > - self.UnDispatchedFfsDict =3D sdict() > - self.ProtocolList =3D sdict() > - > - def CheckArchProtocol(self): > - for Item in EotGlobalData.gArchProtocolGuids: > - if Item.lower() not in EotGlobalData.gProtocolList: > - return False > - return True > - > - def ParseDepex(self, Depex, Type): > - List =3D None > - if Type =3D=3D 'Ppi': > - List =3D EotGlobalData.gPpiList > - if Type =3D=3D 'Protocol': > - List =3D EotGlobalData.gProtocolList > - DepexStack =3D [] > - DepexList =3D [] > - DepexString =3D '' > - FileDepex =3D None > - CouldBeLoaded =3D True > - for Index in range(0, len(Depex.Expression)): > - Item =3D Depex.Expression[Index] > - if Item =3D=3D 0x00: > - Index =3D Index + 1 > - Guid =3D gGuidStringFormat % Depex.Expression[Index] > - if Guid in self.OrderedFfsDict and Depex.Expression[Inde= x + 1] =3D=3D > 0x08: > - return (True, 'BEFORE %s' % Guid, [Guid, 'BEFORE']) > - elif Item =3D=3D 0x01: > - Index =3D Index + 1 > - Guid =3D gGuidStringFormat % Depex.Expression[Index] > - if Guid in self.OrderedFfsDict and Depex.Expression[Inde= x + 1] =3D=3D > 0x08: > - return (True, 'AFTER %s' % Guid, [Guid, 'AFTER']) > - elif Item =3D=3D 0x02: > - Index =3D Index + 1 > - Guid =3D gGuidStringFormat % Depex.Expression[Index] > - if Guid.lower() in List: > - DepexStack.append(True) > - DepexList.append(Guid) > - else: > - DepexStack.append(False) > - DepexList.append(Guid) > - continue > - elif Item =3D=3D 0x03 or Item =3D=3D 0x04: > - DepexStack.append(eval(str(DepexStack.pop()) + ' ' + > Depex._OPCODE_STRING_[Item].lower() + ' ' + str(DepexStack.pop()))) > - DepexList.append(str(DepexList.pop()) + ' ' + > Depex._OPCODE_STRING_[Item].upper() + ' ' + str(DepexList.pop())) > - elif Item =3D=3D 0x05: > - DepexStack.append(eval(Depex._OPCODE_STRING_[Item].lower= () > + ' ' + str(DepexStack.pop()))) > - DepexList.append(Depex._OPCODE_STRING_[Item].lower() + '= ' + > str(DepexList.pop())) > - elif Item =3D=3D 0x06: > - DepexStack.append(True) > - DepexList.append('TRUE') > - DepexString =3D DepexString + 'TRUE' + ' ' > - elif Item =3D=3D 0x07: > - DepexStack.append(False) > - DepexList.append('False') > - DepexString =3D DepexString + 'FALSE' + ' ' > - elif Item =3D=3D 0x08: > - if Index !=3D len(Depex.Expression) - 1: > - CouldBeLoaded =3D False > - else: > - CouldBeLoaded =3D DepexStack.pop() > - else: > - CouldBeLoaded =3D False > - if DepexList !=3D []: > - DepexString =3D DepexList[0].strip() > - return (CouldBeLoaded, DepexString, FileDepex) > - > - def Dispatch(self, Db =3D None): > - if Db is None: > - return False > - self.UnDispatchedFfsDict =3D copy.copy(self.FfsDict) > - # Find PeiCore, DexCore, PeiPriori, DxePriori first > - FfsSecCoreGuid =3D None > - FfsPeiCoreGuid =3D None > - FfsDxeCoreGuid =3D None > - FfsPeiPrioriGuid =3D None > - FfsDxePrioriGuid =3D None > - for FfsID in self.UnDispatchedFfsDict: > - Ffs =3D self.UnDispatchedFfsDict[FfsID] > - if Ffs.Type =3D=3D 0x03: > - FfsSecCoreGuid =3D FfsID > - continue > - if Ffs.Type =3D=3D 0x04: > - FfsPeiCoreGuid =3D FfsID > - continue > - if Ffs.Type =3D=3D 0x05: > - FfsDxeCoreGuid =3D FfsID > - continue > - if Ffs.Guid.lower() =3D=3D gPeiAprioriFileNameGuid: > - FfsPeiPrioriGuid =3D FfsID > - continue > - if Ffs.Guid.lower() =3D=3D gAprioriGuid: > - FfsDxePrioriGuid =3D FfsID > - continue > - > - # Parse SEC_CORE first > - if FfsSecCoreGuid is not None: > - self.OrderedFfsDict[FfsSecCoreGuid] =3D > self.UnDispatchedFfsDict.pop(FfsSecCoreGuid) > - self.LoadPpi(Db, FfsSecCoreGuid) > - > - # Parse PEI first > - if FfsPeiCoreGuid is not None: > - self.OrderedFfsDict[FfsPeiCoreGuid] =3D > self.UnDispatchedFfsDict.pop(FfsPeiCoreGuid) > - self.LoadPpi(Db, FfsPeiCoreGuid) > - if FfsPeiPrioriGuid is not None: > - # Load PEIM described in priori file > - FfsPeiPriori =3D self.UnDispatchedFfsDict.pop(FfsPeiPrio= riGuid) > - if len(FfsPeiPriori.Sections) =3D=3D 1: > - Section =3D FfsPeiPriori.Sections.popitem()[1] > - if Section.Type =3D=3D 0x19: > - GuidStruct =3D struct.Struct('1I2H8B') > - Start =3D 4 > - while len(Section) > Start: > - Guid =3D GuidStruct.unpack_from(Section[Star= t : Start + 16]) > - GuidString =3D gGuidStringFormat % Guid > - Start =3D Start + 16 > - if GuidString in self.UnDispatchedFfsDict: > - self.OrderedFfsDict[GuidString] =3D > self.UnDispatchedFfsDict.pop(GuidString) > - self.LoadPpi(Db, GuidString) > - > - self.DisPatchPei(Db) > - > - # Parse DXE then > - if FfsDxeCoreGuid is not None: > - self.OrderedFfsDict[FfsDxeCoreGuid] =3D > self.UnDispatchedFfsDict.pop(FfsDxeCoreGuid) > - self.LoadProtocol(Db, FfsDxeCoreGuid) > - if FfsDxePrioriGuid is not None: > - # Load PEIM described in priori file > - FfsDxePriori =3D self.UnDispatchedFfsDict.pop(FfsDxePrio= riGuid) > - if len(FfsDxePriori.Sections) =3D=3D 1: > - Section =3D FfsDxePriori.Sections.popitem()[1] > - if Section.Type =3D=3D 0x19: > - GuidStruct =3D struct.Struct('1I2H8B') > - Start =3D 4 > - while len(Section) > Start: > - Guid =3D GuidStruct.unpack_from(Section[Star= t : Start + 16]) > - GuidString =3D gGuidStringFormat % Guid > - Start =3D Start + 16 > - if GuidString in self.UnDispatchedFfsDict: > - self.OrderedFfsDict[GuidString] =3D > self.UnDispatchedFfsDict.pop(GuidString) > - self.LoadProtocol(Db, GuidString) > - > - self.DisPatchDxe(Db) > - > - def LoadProtocol(self, Db, ModuleGuid): > - SqlCommand =3D """select GuidValue from Report > - where SourceFileFullPath in > - (select Value1 from Inf where BelongsToFile =3D > - (select BelongsToFile from Inf > - where Value1 =3D 'FILE_GUID' and Value2 like '%s= ' and Model =3D > %s) > - and Model =3D %s) > - and ItemType =3D 'Protocol' and ItemMode =3D 'Pr= oduced'""" \ > - % (ModuleGuid, 5001, 3007) > - RecordSet =3D Db.TblReport.Exec(SqlCommand) > - for Record in RecordSet: > - SqlCommand =3D """select Value2 from Inf where BelongsToFile= =3D > - (select DISTINCT BelongsToFile from Inf > - where Value1 =3D > - (select SourceFileFullPath from Report > - where GuidValue like '%s' and ItemMode =3D '= Callback')) > - and Value1 =3D 'FILE_GUID'""" % Record[0] > - CallBackSet =3D Db.TblReport.Exec(SqlCommand) > - if CallBackSet !=3D []: > - EotGlobalData.gProtocolList[Record[0].lower()] =3D Modul= eGuid > - else: > - EotGlobalData.gProtocolList[Record[0].lower()] =3D Modul= eGuid > - > - def LoadPpi(self, Db, ModuleGuid): > - SqlCommand =3D """select GuidValue from Report > - where SourceFileFullPath in > - (select Value1 from Inf where BelongsToFile =3D > - (select BelongsToFile from Inf > - where Value1 =3D 'FILE_GUID' and Value2 like '%s= ' and Model =3D > %s) > - and Model =3D %s) > - and ItemType =3D 'Ppi' and ItemMode =3D 'Produce= d'""" \ > - % (ModuleGuid, 5001, 3007) > - RecordSet =3D Db.TblReport.Exec(SqlCommand) > - for Record in RecordSet: > - EotGlobalData.gPpiList[Record[0].lower()] =3D ModuleGuid > - > - def DisPatchDxe(self, Db): > - IsInstalled =3D False > - ScheduleList =3D sdict() > - for FfsID in self.UnDispatchedFfsDict: > - CouldBeLoaded =3D False > - DepexString =3D '' > - FileDepex =3D None > - Ffs =3D self.UnDispatchedFfsDict[FfsID] > - if Ffs.Type =3D=3D 0x07: > - # Get Depex > - IsFoundDepex =3D False > - for Section in Ffs.Sections.values(): > - # Find Depex > - if Section.Type =3D=3D 0x13: > - IsFoundDepex =3D True > - CouldBeLoaded, DepexString, FileDepex =3D > self.ParseDepex(Section._SubImages[4], 'Protocol') > - break > - if Section.Type =3D=3D 0x01: > - CompressSections =3D Section._SubImages[4] > - for CompressSection in CompressSections.Sections= : > - if CompressSection.Type =3D=3D 0x13: > - IsFoundDepex =3D True > - CouldBeLoaded, DepexString, FileDepex = =3D > self.ParseDepex(CompressSection._SubImages[4], 'Protocol') > - break > - if CompressSection.Type =3D=3D 0x02: > - NewSections =3D CompressSection._SubImag= es[4] > - for NewSection in NewSections.Sections: > - if NewSection.Type =3D=3D 0x13: > - IsFoundDepex =3D True > - CouldBeLoaded, DepexString, File= Depex =3D > self.ParseDepex(NewSection._SubImages[4], 'Protocol') > - break > - > - # Not find Depex > - if not IsFoundDepex: > - CouldBeLoaded =3D self.CheckArchProtocol() > - DepexString =3D '' > - FileDepex =3D None > - > - # Append New Ffs > - if CouldBeLoaded: > - IsInstalled =3D True > - NewFfs =3D self.UnDispatchedFfsDict.pop(FfsID) > - NewFfs.Depex =3D DepexString > - if FileDepex is not None: > - ScheduleList.insert(FileDepex[1], FfsID, NewFfs,= FileDepex[0]) > - else: > - ScheduleList[FfsID] =3D NewFfs > - else: > - self.UnDispatchedFfsDict[FfsID].Depex =3D DepexStrin= g > - > - for FfsID in ScheduleList: > - NewFfs =3D ScheduleList.pop(FfsID) > - FfsName =3D 'UnKnown' > - self.OrderedFfsDict[FfsID] =3D NewFfs > - self.LoadProtocol(Db, FfsID) > - > - SqlCommand =3D """select Value2 from Inf > - where BelongsToFile =3D (select BelongsToFil= e from Inf where > Value1 =3D 'FILE_GUID' and lower(Value2) =3D lower('%s') and Model =3D %s= ) > - and Model =3D %s and Value1=3D'BASE_NAME'"""= % (FfsID, 5001, > 5001) > - RecordSet =3D Db.TblReport.Exec(SqlCommand) > - if RecordSet !=3D []: > - FfsName =3D RecordSet[0][0] > - > - if IsInstalled: > - self.DisPatchDxe(Db) > - > - def DisPatchPei(self, Db): > - IsInstalled =3D False > - for FfsID in self.UnDispatchedFfsDict: > - CouldBeLoaded =3D True > - DepexString =3D '' > - FileDepex =3D None > - Ffs =3D self.UnDispatchedFfsDict[FfsID] > - if Ffs.Type =3D=3D 0x06 or Ffs.Type =3D=3D 0x08: > - # Get Depex > - for Section in Ffs.Sections.values(): > - if Section.Type =3D=3D 0x1B: > - CouldBeLoaded, DepexString, FileDepex =3D > self.ParseDepex(Section._SubImages[4], 'Ppi') > - break > - if Section.Type =3D=3D 0x01: > - CompressSections =3D Section._SubImages[4] > - for CompressSection in CompressSections.Sections= : > - if CompressSection.Type =3D=3D 0x1B: > - CouldBeLoaded, DepexString, FileDepex = =3D > self.ParseDepex(CompressSection._SubImages[4], 'Ppi') > - break > - if CompressSection.Type =3D=3D 0x02: > - NewSections =3D CompressSection._SubImag= es[4] > - for NewSection in NewSections.Sections: > - if NewSection.Type =3D=3D 0x1B: > - CouldBeLoaded, DepexString, File= Depex =3D > self.ParseDepex(NewSection._SubImages[4], 'Ppi') > - break > - > - # Append New Ffs > - if CouldBeLoaded: > - IsInstalled =3D True > - NewFfs =3D self.UnDispatchedFfsDict.pop(FfsID) > - NewFfs.Depex =3D DepexString > - self.OrderedFfsDict[FfsID] =3D NewFfs > - self.LoadPpi(Db, FfsID) > - else: > - self.UnDispatchedFfsDict[FfsID].Depex =3D DepexStrin= g > - > - if IsInstalled: > - self.DisPatchPei(Db) > - > - > - def __str__(self): > - global gIndention > - gIndention +=3D 4 > - FvInfo =3D '\n' + ' ' * gIndention > - FvInfo +=3D "[FV:%s] file_system=3D%s size=3D%x checksum=3D%s\n= " % > (self.Name, self.FileSystemGuid, self.Size, self.Checksum) > - FfsInfo =3D "\n".join([str(self.FfsDict[FfsId]) for FfsId in sel= f.FfsDict]) > - gIndention -=3D 4 > - return FvInfo + FfsInfo > - > - def _Unpack(self): > - Size =3D self._LENGTH_.unpack_from(self._BUF_, self._OFF_)[0] > - self.empty() > - self.extend(self._BUF_[self._OFF_:self._OFF_+Size]) > - > - # traverse the FFS > - EndOfFv =3D Size > - FfsStartAddress =3D self.HeaderSize > - LastFfsObj =3D None > - while FfsStartAddress < EndOfFv: > - FfsObj =3D Ffs() > - FfsObj.frombuffer(self, FfsStartAddress) > - FfsId =3D repr(FfsObj) > - if ((self.Attributes & 0x00000800) !=3D 0 and len(FfsObj) = =3D=3D 0xFFFFFF) \ > - or ((self.Attributes & 0x00000800) =3D=3D 0 and len(FfsO= bj) =3D=3D 0): > - if LastFfsObj is not None: > - LastFfsObj.FreeSpace =3D EndOfFv - LastFfsObj._OFF_ = - > len(LastFfsObj) > - else: > - if FfsId in self.FfsDict: > - EdkLogger.error("FV", 0, "Duplicate GUID in FFS", > - ExtraData=3D"\t%s @ %s\n\t%s @ %s" \ > - % (FfsObj.Guid, FfsObj.Offset, > - self.FfsDict[FfsId].Guid, self.Ff= sDict[FfsId].Offset)) > - self.FfsDict[FfsId] =3D FfsObj > - if LastFfsObj is not None: > - LastFfsObj.FreeSpace =3D FfsStartAddress - LastFfsOb= j._OFF_ - > len(LastFfsObj) > - > - FfsStartAddress +=3D len(FfsObj) > - # > - # align to next 8-byte aligned address: A =3D (A + 8 - 1) & = (~(8 - 1)) > - # The next FFS must be at the latest next 8-byte aligned add= ress > - # > - FfsStartAddress =3D (FfsStartAddress + 7) & (~7) > - LastFfsObj =3D FfsObj > - > - def _GetAttributes(self): > - return self.GetField(self._ATTR_, 0)[0] > - > - def _GetSize(self): > - return self.GetField(self._LENGTH_, 0)[0] > - > - def _GetChecksum(self): > - return self.GetField(self._CHECKSUM_, 0)[0] > - > - def _GetHeaderLength(self): > - return self.GetField(self._HLEN_, 0)[0] > - > - def _GetFileSystemGuid(self): > - return gGuidStringFormat % self.GetField(self._GUID_, 0) > - > - Attributes =3D property(_GetAttributes) > - Size =3D property(_GetSize) > - Checksum =3D property(_GetChecksum) > - HeaderSize =3D property(_GetHeaderLength) > - FileSystemGuid =3D property(_GetFileSystemGuid) >=20 > ## MultipleFv() class > # > @@ -1470,8 +1093,10 @@ class MultipleFv(FirmwareVolume): > FirmwareVolume.__init__(self) > self.BasicInfo =3D [] > for FvPath in FvList: > + Fd =3D None > FvName =3D os.path.splitext(os.path.split(FvPath)[1])[0] > - Fd =3D open(FvPath, 'rb') > + if FvPath.strip(): > + Fd =3D open(FvPath, 'rb') > Buf =3D array('B') > try: > Buf.fromfile(Fd, os.path.getsize(FvPath)) @@ -1632,8=20 > +1257,9 @@ class Eot(object): > Path =3D os.path.join(EotGlobalData.gWORKSPACE, GuidList) > if os.path.isfile(Path): > for Line in open(Path): > - (GuidName, GuidValue) =3D Line.split() > - EotGlobalData.gGuidDict[GuidName] =3D GuidValue > + if Line.strip(): > + (GuidName, GuidValue) =3D Line.split() > + EotGlobalData.gGuidDict[GuidName] =3D GuidValue >=20 > ## ConvertLogFile() method > # > @@ -1694,7 +1320,7 @@ class Eot(object): > mCurrentSourceFileList =3D [] >=20 > if SourceFileList: > - sfl =3D open(SourceFileList, 'rb') > + sfl =3D open(SourceFileList, 'r') > for line in sfl: > line =3D=20 > os.path.normpath(os.path.join(EotGlobalData.gWORKSPACE, > line.strip())) > if line[-2:].upper() =3D=3D '.C' or line[-2:].upper() = =3D=3D '.H': > @@ -1970,6 +1596,8 @@ class Eot(object): > def BuildMetaDataFileDatabase(self, Inf_Files): > EdkLogger.quiet("Building database for meta data files ...") > for InfFile in Inf_Files: > + if not InfFile: > + continue > EdkLogger.quiet("Parsing %s ..." % str(InfFile)) > EdkInfParser(InfFile, EotGlobalData.gDb,=20 > Inf_Files[InfFile], '') >=20 > @@ -2083,7 +1711,10 @@ if __name__ =3D=3D '__main__': > EdkLogger.quiet(time.strftime("%H:%M:%S, %b.%d %Y ",=20 > time.localtime()) > + "[00:00]" + "\n") >=20 > StartTime =3D time.clock() > - Eot =3D Eot() > + Eot =3D Eot(CommandLineOption=3DFalse, > + SourceFileList=3Dr'C:\TestEot\Source.txt', > + GuidList=3Dr'C:\TestEot\Guid.txt', > + FvFileList=3Dr'C:\TestEot\FVRECOVERY.Fv') > FinishTime =3D time.clock() >=20 > BuildDuration =3D time.strftime("%M:%S",=20 > time.gmtime(int(round(FinishTime - StartTime)))) diff --git=20 > a/BaseTools/Source/Python/Eot/InfParserLite.py > b/BaseTools/Source/Python/Eot/InfParserLite.py > index 88d7e7d58e..c910c129a7 100644 > --- a/BaseTools/Source/Python/Eot/InfParserLite.py > +++ b/BaseTools/Source/Python/Eot/InfParserLite.py > @@ -1,7 +1,7 @@ > ## @file > # This file is used to parse INF file of EDK project # -# Copyright=20 > (c) 2008 - 2014, Intel Corporation. All rights reserved.
> +# Copyright (c) 2008 - 2018, Intel Corporation. All rights=20 > +reserved.
> # This program and the accompanying materials # are licensed and=20 > made available under the terms and conditions of the BSD License #=20 > which accompanies this distribution. The full text of the license may=20 > be found at @@ -22,8 +22,9 @@ from Common.DataType import * from=20 > CommonDataClass.DataClass import * from Common.Identification import=20 > * from Common.StringUtils import * -from .Parser import * -from .=20 > import Database > +from Eot.Parser import * > +from Eot import Database > +from Eot import EotGlobalData >=20 > ## EdkInfParser() class > # > @@ -153,21 +154,4 @@ class EdkInfParser(object): > self.ParserSource(CurrentSection, SectionItemList, ArchList, Thi= rdList) > #End of For >=20 > -## > -# > -# This acts like the main() function for the script, unless it is=20 > 'import'ed into another -# script. > -# > -if __name__ =3D=3D '__main__': > - EdkLogger.Initialize() > - EdkLogger.SetLevel(EdkLogger.QUIET) > - > - Db =3D Database.Database('Inf.db') > - Db.InitDatabase() > - P =3D > EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32 > \Dxe\PlatformBds\PlatformBds.inf"), Db, '', '') > - for Inf in P.Sources: > - print(Inf) > - for Item in P.Macros: > - print(Item, P.Macros[Item]) > - > - Db.Close() > + > diff --git a/BaseTools/Source/Python/Eot/Parser.py > b/BaseTools/Source/Python/Eot/Parser.py > index e01a9770be..673088d41d 100644 > --- a/BaseTools/Source/Python/Eot/Parser.py > +++ b/BaseTools/Source/Python/Eot/Parser.py > @@ -2,7 +2,7 @@ > # This file is used to define common parsing related functions used=20 > in parsing # Inf/Dsc/Makefile process # -# Copyright (c) 2008 -=20 > 2014, Intel Corporation. All rights reserved.
> +# Copyright (c) 2008 - 2018, Intel Corporation. All rights=20 > +reserved.
> # This program and the accompanying materials # are licensed and=20 > made available under the terms and conditions of the BSD License #=20 > which accompanies this distribution. The full text of the license may=20 > be found at @@ -25,6 +25,32 @@ from . import EotGlobalData from=20 > Common.StringUtils import GetSplitList from=20 > Common.LongFilePathSupport import OpenLongFilePath as open >=20 > +import subprocess > + > +## DeCompress > +# > +# Call external decompress tool to decompress the fv section # def=20 > +DeCompress(Method, Input): > + # Write the input to a temp file > + open('_Temp.bin', 'wb').write(Input) > + cmd =3D '' > + if Method =3D=3D 'Lzma': > + cmd =3D r'LzmaCompress -o _New.bin -d _Temp.bin' > + if Method =3D=3D 'Efi': > + cmd =3D r'TianoCompress -d --uefi -o _New.bin _Temp.bin' > + if Method =3D=3D 'Framework': > + cmd =3D r'TianoCompress -d -o _New.bin _Temp.bin' > + > + # Call tool to create the decompressed output file > + Process =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE, > stderr=3Dsubprocess.STDOUT) > + Process.communicate()[0] > + > + # Return the beffer of New.bin > + if os.path.exists('_New.bin'): > + return open('_New.bin', 'rb').read() > + > + > ## PreProcess() method > # > # Pre process a file > diff --git a/BaseTools/Source/Python/Eot/Report.py > b/BaseTools/Source/Python/Eot/Report.py > index 4ddddb1034..01ad86ad3e 100644 > --- a/BaseTools/Source/Python/Eot/Report.py > +++ b/BaseTools/Source/Python/Eot/Report.py > @@ -77,7 +77,7 @@ class Report(object): > def GenerateUnDispatchedList(self): > FvObj =3D self.FvObj > EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % FvObj.Name) > - for Item in FvObj.UnDispatchedFfsDict: > + for Item in FvObj.UnDispatchedFfsDict.keys(): > EotGlobalData.gOP_UN_DISPATCHED.write('%s\n' % > FvObj.UnDispatchedFfsDict[Item]) >=20 > ## GenerateFv() method > @@ -112,7 +112,7 @@ class Report(object): > self.WriteLn(Content) >=20 > EotGlobalData.gOP_DISPATCH_ORDER.write('Dispatched:\n') > - for FfsId in FvObj.OrderedFfsDict: > + for FfsId in FvObj.OrderedFfsDict.keys(): > self.GenerateFfs(FvObj.OrderedFfsDict[FfsId]) > Content =3D """ > """ > @@ -125,7 +125,7 @@ class Report(object): > self.WriteLn(Content) >=20 > EotGlobalData.gOP_DISPATCH_ORDER.write('\nUnDispatched:\n') > - for FfsId in FvObj.UnDispatchedFfsDict: > + for FfsId in FvObj.UnDispatchedFfsDict.keys(): > self.GenerateFfs(FvObj.UnDispatchedFfsDict[FfsId]) > Content =3D """ > """ > diff --git a/BaseTools/Source/Python/build/BuildReport.py > b/BaseTools/Source/Python/build/BuildReport.py > index 50db503780..14143b3396 100644 > --- a/BaseTools/Source/Python/build/BuildReport.py > +++ b/BaseTools/Source/Python/build/BuildReport.py > @@ -1626,7 +1626,7 @@ class PredictionReport(object): > TempFile.close() >=20 > try: > - from Eot.Eot import Eot > + from Eot.EotMain import Eot >=20 > # > # Invoke EOT tool and echo its runtime performance > -- > 2.14.2.windows.2 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel