X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFfsInfStatement.py;h=cd3b0f647793da01772e6fee4a98e3c576a6026d;hp=43b9c90b776a28fb9103f5494331f71bbf6459f5;hb=04797875d1d53e53e31eca4fa01bc3cf6929f39c;hpb=487062c048809420de1b008bc9d17815a8c4fbdb diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 43b9c90b77..cd3b0f6477 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -4,24 +4,19 @@ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# Copyright (c) 2014-2016 Hewlett-Packard Development Company, L.P.
# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php -# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# SPDX-License-Identifier: BSD-2-Clause-Patent # ## # Import Modules # +from __future__ import absolute_import from . import Rule import Common.LongFilePathOs as os from io import BytesIO from struct import * from .GenFdsGlobalVariable import GenFdsGlobalVariable -from . import Ffs +from .Ffs import SectionSuffix,FdfFvFileTypeToFileType import subprocess import sys from . import Section @@ -29,6 +24,7 @@ from . import RuleSimpleFile from . import RuleComplexFile from CommonDataClass.FdfClass import FfsInfStatementClassObject from Common.MultipleWorkspace import MultipleWorkspace as mws +from Common.DataType import SUP_MODULE_USER_DEFINED from Common.StringUtils import * from Common.Misc import PathClass from Common.Misc import GuidStructureByteArrayToGuidString @@ -93,7 +89,7 @@ class FfsInfStatement(FfsInfStatementClassObject): ModuleType = self.InfModule.ModuleType PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] - if ModuleType != DataType.SUP_MODULE_USER_DEFINED: + if ModuleType != SUP_MODULE_USER_DEFINED: for LibraryClass in PlatformDataBase.LibraryClasses.GetKeys(): if LibraryClass.startswith("NULL") and PlatformDataBase.LibraryClasses[LibraryClass, ModuleType]: self.InfModule.LibraryClasses[LibraryClass] = PlatformDataBase.LibraryClasses[LibraryClass, ModuleType] @@ -151,7 +147,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @param self The object pointer # @param Dict dictionary contains macro and value pair # - def __InfParse__(self, Dict = {}): + def __InfParse__(self, Dict = None, IsGenFfs=False): GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName) @@ -188,7 +184,7 @@ class FfsInfStatement(FfsInfStatementClassObject): Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag] # - # Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath + # Set Ffs BaseName, ModuleGuid, ModuleType, Version, OutputPath # self.BaseName = Inf.BaseName self.ModuleGuid = Inf.Guid @@ -350,9 +346,12 @@ class FfsInfStatement(FfsInfStatementClassObject): GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" % self.InfFileName) # - # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\ + # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${ModuleName}\ # - + if IsGenFfs: + Rule = self.__GetRule__() + if GlobalData.gGuidPatternEnd.match(Rule.NameGuid): + self.ModuleGuid = Rule.NameGuid self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \ self.ModuleGuid + self.BaseName) if not os.path.exists(self.OutputPath) : @@ -442,7 +441,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # Parse Inf file get Module related information # - self.__InfParse__(Dict) + self.__InfParse__(Dict, IsGenFfs=True) Arch = self.GetCurrentArch() SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName); DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs') @@ -759,7 +758,7 @@ class FfsInfStatement(FfsInfStatementClassObject): SecNum = '%d' %Index GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \ - Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum + SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum Index = Index + 1 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile) File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch) @@ -770,9 +769,9 @@ class FfsInfStatement(FfsInfStatementClassObject): if ImageObj.SectionAlignment < 0x400: self.Alignment = str (ImageObj.SectionAlignment) elif ImageObj.SectionAlignment < 0x100000: - self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' + self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K' else: - self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' + self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M' if not NoStrip: FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc') @@ -802,7 +801,7 @@ class FfsInfStatement(FfsInfStatementClassObject): else: SecNum = '%d' %Index GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \ - Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum + SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum OutputFile = os.path.join(self.OutputPath, GenSecOutputFile) GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch) @@ -812,9 +811,9 @@ class FfsInfStatement(FfsInfStatementClassObject): if ImageObj.SectionAlignment < 0x400: self.Alignment = str (ImageObj.SectionAlignment) elif ImageObj.SectionAlignment < 0x100000: - self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K' + self.Alignment = str (ImageObj.SectionAlignment // 0x400) + 'K' else: - self.Alignment = str (ImageObj.SectionAlignment / 0x100000) + 'M' + self.Alignment = str (ImageObj.SectionAlignment // 0x100000) + 'M' if not NoStrip: FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc') @@ -881,7 +880,7 @@ class FfsInfStatement(FfsInfStatementClassObject): self.ModuleGuid = RegistryGuidStr GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection, - Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType], + FdfFvFileTypeToFileType[Rule.FvFileType], self.ModuleGuid, Fixed=Rule.Fixed, CheckSum=Rule.CheckSum, Align=Rule.Alignment, SectionAlign=SectionAlignments, @@ -900,7 +899,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval string File name of the generated section file # def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False): - if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM): + if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE): if Rule.KeepReloc is not None: self.KeepRelocFromRule = Rule.KeepReloc SectFiles = [] @@ -1054,7 +1053,7 @@ class FfsInfStatement(FfsInfStatementClassObject): FfsOutput = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs') GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile, - Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType], + FdfFvFileTypeToFileType[Rule.FvFileType], self.ModuleGuid, Fixed=Rule.Fixed, CheckSum=Rule.CheckSum, Align=Rule.Alignment, SectionAlign=Alignments, @@ -1073,7 +1072,7 @@ class FfsInfStatement(FfsInfStatementClassObject): def __GetBuildOutputMapFileVfrUniInfo(self, VfrUniBaseName): MapFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".map") EfiFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".efi") - return GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values()) + return GetVariableOffset(MapFileName, EfiFileName, list(VfrUniBaseName.values())) ## __GenUniVfrOffsetFile() method # @@ -1086,7 +1085,7 @@ class FfsInfStatement(FfsInfStatementClassObject): def __GenUniVfrOffsetFile(VfrUniOffsetList, UniVfrOffsetFileName): # Use a instance of StringIO to cache data - fStringIO = BytesIO('') + fStringIO = BytesIO() for Item in VfrUniOffsetList: if (Item[0].find("Strings") != -1): @@ -1095,9 +1094,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # GUID + Offset # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } } # - UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66] - UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid] - fStringIO.write(''.join(UniGuid)) + UniGuid = b'\xe0\xc5\x13\x89\xf63\x86M\x9b\xf1C\xef\x89\xfc\x06f' + fStringIO.write(UniGuid) UniValue = pack ('Q', int (Item[1], 16)) fStringIO.write (UniValue) else: @@ -1106,9 +1104,8 @@ class FfsInfStatement(FfsInfStatementClassObject): # GUID + Offset # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } }; # - VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2] - VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid] - fStringIO.write(''.join(VfrGuid)) + VfrGuid = b'\xb4|\xbc\xd0Gj_I\xaa\x11q\x07F\xda\x06\xa2' + fStringIO.write(VfrGuid) type (Item[1]) VfrValue = pack ('Q', int (Item[1], 16)) fStringIO.write (VfrValue)