Check In tool source code based on Build tool project revision r1655.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8964 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
118
BaseTools/Source/Python/GenFds/AprioriSection.py
Normal file
118
BaseTools/Source/Python/GenFds/AprioriSection.py
Normal file
@@ -0,0 +1,118 @@
|
||||
## @file
|
||||
# process APRIORI file data and generate PEI/DXE APRIORI file
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from struct import *
|
||||
import os
|
||||
import StringIO
|
||||
import FfsFileStatement
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import AprioriSectionClassObject
|
||||
from Common.String import *
|
||||
from Common.Misc import SaveFileOnChange,PathClass
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## process APRIORI file data and generate PEI/DXE APRIORI file
|
||||
#
|
||||
#
|
||||
class AprioriSection (AprioriSectionClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
AprioriSectionClassObject.__init__(self)
|
||||
self.AprioriType = ""
|
||||
|
||||
## GenFfs() method
|
||||
#
|
||||
# Generate FFS for APRIORI file
|
||||
#
|
||||
# @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 = {}):
|
||||
DXE_GUID = "FC510EE7-FFDC-11D4-BD41-0080C73C8881"
|
||||
PEI_GUID = "1B45CC0A-156A-428A-AF62-49864DA0E6E6"
|
||||
Buffer = StringIO.StringIO('')
|
||||
AprioriFileGuid = DXE_GUID
|
||||
if self.AprioriType == "PEI":
|
||||
AprioriFileGuid = PEI_GUID
|
||||
OutputAprFilePath = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, \
|
||||
GenFdsGlobalVariable.FfsDir,\
|
||||
AprioriFileGuid + FvName)
|
||||
if not os.path.exists(OutputAprFilePath) :
|
||||
os.makedirs(OutputAprFilePath)
|
||||
|
||||
OutputAprFileName = os.path.join( OutputAprFilePath, \
|
||||
AprioriFileGuid + FvName + '.Apri' )
|
||||
AprFfsFileName = os.path.join (OutputAprFilePath,\
|
||||
AprioriFileGuid + FvName + '.Ffs')
|
||||
|
||||
Dict.update(self.DefineVarDict)
|
||||
for FfsObj in self.FfsList :
|
||||
Guid = ""
|
||||
if isinstance(FfsObj, FfsFileStatement.FileStatement):
|
||||
Guid = FfsObj.NameGuid
|
||||
else:
|
||||
InfFileName = NormPath(FfsObj.InfFileName)
|
||||
Arch = FfsObj.GetCurrentArch()
|
||||
|
||||
if Arch != None:
|
||||
Dict['$(ARCH)'] = Arch
|
||||
InfFileName = GenFdsGlobalVariable.MacroExtend(InfFileName, Dict, Arch)
|
||||
|
||||
if Arch != None:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), Arch]
|
||||
Guid = Inf.Guid
|
||||
|
||||
else:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(InfFileName, GenFdsGlobalVariable.WorkSpaceDir), 'COMMON']
|
||||
Guid = Inf.Guid
|
||||
|
||||
self.BinFileList = Inf.Module.Binaries
|
||||
if self.BinFileList == []:
|
||||
EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
|
||||
"INF %s not found in build ARCH %s!" \
|
||||
% (InfFileName, GenFdsGlobalVariable.ArchList))
|
||||
|
||||
|
||||
GuidPart = Guid.split('-')
|
||||
Buffer.write(pack('I', long(GuidPart[0], 16)))
|
||||
Buffer.write(pack('H', int(GuidPart[1], 16)))
|
||||
Buffer.write(pack('H', int(GuidPart[2], 16)))
|
||||
|
||||
for Num in range(2):
|
||||
Char = GuidPart[3][Num*2:Num*2+2]
|
||||
Buffer.write(pack('B', int(Char, 16)))
|
||||
|
||||
for Num in range(6):
|
||||
Char = GuidPart[4][Num*2:Num*2+2]
|
||||
Buffer.write(pack('B', int(Char, 16)))
|
||||
|
||||
SaveFileOnChange(OutputAprFileName, Buffer.getvalue())
|
||||
|
||||
RawSectionFileName = os.path.join( OutputAprFilePath, \
|
||||
AprioriFileGuid + FvName + '.raw' )
|
||||
GenFdsGlobalVariable.GenerateSection(RawSectionFileName, [OutputAprFileName], 'EFI_SECTION_RAW')
|
||||
GenFdsGlobalVariable.GenerateFfs(AprFfsFileName, [RawSectionFileName],
|
||||
'EFI_FV_FILETYPE_FREEFORM', AprioriFileGuid)
|
||||
|
||||
return AprFfsFileName
|
||||
|
28
BaseTools/Source/Python/GenFds/Attribute.py
Normal file
28
BaseTools/Source/Python/GenFds/Attribute.py
Normal file
@@ -0,0 +1,28 @@
|
||||
## @file
|
||||
# name value pair
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
|
||||
## name value pair
|
||||
#
|
||||
#
|
||||
class Attribute:
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
def __init__(self):
|
||||
self.Name = None
|
||||
self.Value = None
|
89
BaseTools/Source/Python/GenFds/Capsule.py
Normal file
89
BaseTools/Source/Python/GenFds/Capsule.py
Normal file
@@ -0,0 +1,89 @@
|
||||
## @file
|
||||
# generate capsule
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import CapsuleClassObject
|
||||
import os
|
||||
import subprocess
|
||||
import StringIO
|
||||
from Common.Misc import SaveFileOnChange
|
||||
|
||||
|
||||
T_CHAR_LF = '\n'
|
||||
|
||||
## create inf file describes what goes into capsule and call GenFv to generate capsule
|
||||
#
|
||||
#
|
||||
class Capsule (CapsuleClassObject) :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
CapsuleClassObject.__init__(self)
|
||||
# For GenFv
|
||||
self.BlockSize = None
|
||||
# For GenFv
|
||||
self.BlockNum = None
|
||||
|
||||
## Generate capsule
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GenCapsule(self):
|
||||
CapInfFile = self.GenCapInf()
|
||||
CapInfFile.writelines("[files]" + T_CHAR_LF)
|
||||
|
||||
for CapsuleDataObj in self.CapsuleDataList :
|
||||
FileName = CapsuleDataObj.GenCapsuleSubItem()
|
||||
CapInfFile.writelines("EFI_FILE_NAME = " + \
|
||||
FileName + \
|
||||
T_CHAR_LF)
|
||||
SaveFileOnChange(self.CapInfFileName, CapInfFile.getvalue(), False)
|
||||
CapInfFile.close()
|
||||
#
|
||||
# Call GenFv tool to generate capsule
|
||||
#
|
||||
CapOutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiCapsuleName)
|
||||
CapOutputFile = CapOutputFile + '.Cap'
|
||||
GenFdsGlobalVariable.GenerateFirmwareVolume(
|
||||
CapOutputFile,
|
||||
[self.CapInfFileName],
|
||||
Capsule=True
|
||||
)
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
## Generate inf file for capsule
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval file inf file object
|
||||
#
|
||||
def GenCapInf(self):
|
||||
self.CapInfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
||||
self.UiCapsuleName + "_Cap" + '.inf')
|
||||
CapInfFile = StringIO.StringIO() #open (self.CapInfFileName , 'w+')
|
||||
|
||||
CapInfFile.writelines("[options]" + T_CHAR_LF)
|
||||
|
||||
for Item in self.TokensDict.keys():
|
||||
CapInfFile.writelines("EFI_" + \
|
||||
Item + \
|
||||
' = ' + \
|
||||
self.TokensDict.get(Item) + \
|
||||
T_CHAR_LF)
|
||||
|
||||
return CapInfFile
|
84
BaseTools/Source/Python/GenFds/CapsuleData.py
Normal file
84
BaseTools/Source/Python/GenFds/CapsuleData.py
Normal file
@@ -0,0 +1,84 @@
|
||||
## @file
|
||||
# generate capsule
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Ffs
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import StringIO
|
||||
|
||||
## base class for capsule data
|
||||
#
|
||||
#
|
||||
class CapsuleData:
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
## generate capsule data
|
||||
#
|
||||
# @param self The object pointer
|
||||
def GenCapsuleSubItem(self):
|
||||
pass
|
||||
|
||||
## FFS class for capsule data
|
||||
#
|
||||
#
|
||||
class CapsuleFfs (CapsuleData):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init_(self) :
|
||||
self.Ffs = None
|
||||
|
||||
## generate FFS capsule data
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval string Generated file name
|
||||
#
|
||||
def GenCapsuleSubItem(self):
|
||||
FfsFile = self.Ffs.GenFfs()
|
||||
return FfsFile
|
||||
|
||||
## FV class for capsule data
|
||||
#
|
||||
#
|
||||
class CapsuleFv (CapsuleData):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self) :
|
||||
self.FvName = None
|
||||
|
||||
## generate FV capsule data
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval string Generated file name
|
||||
#
|
||||
def GenCapsuleSubItem(self):
|
||||
if self.FvName.find('.fv') == -1:
|
||||
if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
|
||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
|
||||
FdBuffer = StringIO.StringIO('')
|
||||
FvFile = FvObj.AddToBuffer(FdBuffer)
|
||||
return FvFile
|
||||
|
||||
else:
|
||||
FvFile = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvName)
|
||||
return FvFile
|
29
BaseTools/Source/Python/GenFds/ComponentStatement.py
Normal file
29
BaseTools/Source/Python/GenFds/ComponentStatement.py
Normal file
@@ -0,0 +1,29 @@
|
||||
## @file
|
||||
# VTF components
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from CommonDataClass.FdfClass import ComponentStatementClassObject
|
||||
|
||||
## VTF components
|
||||
#
|
||||
#
|
||||
class ComponentStatement (ComponentStatementClassObject) :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
ComponentStatementClassObject.__init__(self)
|
87
BaseTools/Source/Python/GenFds/CompressSection.py
Normal file
87
BaseTools/Source/Python/GenFds/CompressSection.py
Normal file
@@ -0,0 +1,87 @@
|
||||
## @file
|
||||
# process compress section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from Ffs import Ffs
|
||||
import Section
|
||||
import subprocess
|
||||
import os
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import CompressSectionClassObject
|
||||
|
||||
## generate compress section
|
||||
#
|
||||
#
|
||||
class CompressSection (CompressSectionClassObject) :
|
||||
|
||||
## compress types: PI standard and non PI standard
|
||||
CompTypeDict = {
|
||||
'PI_STD' : 'PI_STD',
|
||||
'NON_PI_STD' : 'NON_PI_STD'
|
||||
}
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
CompressSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate compressed section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
|
||||
|
||||
if FfsInf != None:
|
||||
self.CompType = FfsInf.__ExtendMacro__(self.CompType)
|
||||
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
|
||||
|
||||
SectFiles = tuple()
|
||||
Index = 0
|
||||
for Sect in self.SectionList:
|
||||
Index = Index + 1
|
||||
SecIndex = '%s.%d' %(SecNum, Index)
|
||||
ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict)
|
||||
if ReturnSectList != []:
|
||||
for FileData in ReturnSectList:
|
||||
SectFiles += (FileData,)
|
||||
|
||||
|
||||
OutputFile = OutputPath + \
|
||||
os.sep + \
|
||||
ModuleName + \
|
||||
'SEC' + \
|
||||
SecNum + \
|
||||
Ffs.SectionSuffix['COMPRESS']
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],
|
||||
CompressionType=self.CompTypeDict[self.CompType])
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
||||
|
||||
|
109
BaseTools/Source/Python/GenFds/DataSection.py
Normal file
109
BaseTools/Source/Python/GenFds/DataSection.py
Normal file
@@ -0,0 +1,109 @@
|
||||
## @file
|
||||
# process data section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import subprocess
|
||||
from Ffs import Ffs
|
||||
import os
|
||||
from CommonDataClass.FdfClass import DataSectionClassObject
|
||||
import shutil
|
||||
|
||||
## generate data section
|
||||
#
|
||||
#
|
||||
class DataSection (DataSectionClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
DataSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate compressed section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
if FfsFile != None:
|
||||
self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)
|
||||
self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict, FfsFile.CurrentArch)
|
||||
else:
|
||||
self.SectFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.SectFileName)
|
||||
self.SectFileName = GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)
|
||||
|
||||
"""Check Section file exist or not !"""
|
||||
|
||||
if not os.path.exists(self.SectFileName):
|
||||
self.SectFileName = os.path.join (GenFdsGlobalVariable.WorkSpaceDir,
|
||||
self.SectFileName)
|
||||
|
||||
"""Copy Map file to Ffs output"""
|
||||
Filename = GenFdsGlobalVariable.MacroExtend(self.SectFileName)
|
||||
if Filename[(len(Filename)-4):] == '.efi':
|
||||
MapFile = Filename.replace('.efi', '.map')
|
||||
if os.path.exists(MapFile):
|
||||
CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
|
||||
if not os.path.exists(CopyMapFile) or \
|
||||
(os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):
|
||||
shutil.copyfile(MapFile, CopyMapFile)
|
||||
|
||||
NoStrip = True
|
||||
if self.SecType in ('TE', 'PE32'):
|
||||
if self.KeepReloc != None:
|
||||
NoStrip = self.KeepReloc
|
||||
|
||||
if not NoStrip:
|
||||
FileBeforeStrip = os.path.join(OutputPath, ModuleName + '.efi')
|
||||
if not os.path.exists(FileBeforeStrip) or \
|
||||
(os.path.getmtime(self.SectFileName) > os.path.getmtime(FileBeforeStrip)):
|
||||
shutil.copyfile(self.SectFileName, FileBeforeStrip)
|
||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],
|
||||
Strip=True
|
||||
)
|
||||
self.SectFileName = StrippedFile
|
||||
|
||||
if self.SecType == 'TE':
|
||||
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(self.SectFileName, Dict)],
|
||||
Type='te'
|
||||
)
|
||||
self.SectFileName = TeFile
|
||||
|
||||
OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get(self.SecType))
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [self.SectFileName], Section.Section.SectionType.get(self.SecType))
|
||||
FileList = [OutputFile]
|
||||
return FileList, self.Alignment
|
102
BaseTools/Source/Python/GenFds/DepexSection.py
Normal file
102
BaseTools/Source/Python/GenFds/DepexSection.py
Normal file
@@ -0,0 +1,102 @@
|
||||
## @file
|
||||
# process depex section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import subprocess
|
||||
from Ffs import Ffs
|
||||
import os
|
||||
from CommonDataClass.FdfClass import DepexSectionClassObject
|
||||
from AutoGen.GenDepex import DependencyExpression
|
||||
import shutil
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## generate data section
|
||||
#
|
||||
#
|
||||
class DepexSection (DepexSectionClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
DepexSectionClassObject.__init__(self)
|
||||
|
||||
def __FindGuidValue(self, CName):
|
||||
for Arch in GenFdsGlobalVariable.ArchList:
|
||||
for PkgDb in GenFdsGlobalVariable.WorkSpace.PackageList:
|
||||
if CName in PkgDb.Ppis:
|
||||
return PkgDb.Ppis[CName]
|
||||
if CName in PkgDb.Protocols:
|
||||
return PkgDb.Protocols[CName]
|
||||
if CName in PkgDb.Guids:
|
||||
return PkgDb.Guids[CName]
|
||||
return None
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate compressed section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, keyStringList, FfsFile = None, Dict = {}):
|
||||
|
||||
self.Expression = self.Expression.replace("\n", " ").replace("\r", " ")
|
||||
ExpList = self.Expression.split()
|
||||
ExpGuidDict = {}
|
||||
|
||||
for Exp in ExpList:
|
||||
if Exp.upper() not in ('AND', 'OR', 'NOT', 'TRUE', 'FALSE', 'SOR', 'BEFORE', 'AFTER', 'END'):
|
||||
GuidStr = self.__FindGuidValue(Exp)
|
||||
if GuidStr == None:
|
||||
EdkLogger.error("GenFds", RESOURCE_NOT_AVAILABLE,
|
||||
"Depex GUID %s could not be found in build DB! (ModuleName: %s)" % (Exp, ModuleName))
|
||||
|
||||
ExpGuidDict[Exp] = GuidStr
|
||||
|
||||
for Item in ExpGuidDict:
|
||||
self.Expression = self.Expression.replace(Item, ExpGuidDict[Item])
|
||||
|
||||
self.Expression = self.Expression.strip()
|
||||
ModuleType = (self.DepexType.startswith('PEI') and ['PEIM'] or ['DXE_DRIVER'])[0]
|
||||
if self.DepexType.startswith('SMM'):
|
||||
ModuleType = 'SMM_DRIVER'
|
||||
InputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.dpx')
|
||||
InputFile = os.path.normpath(InputFile)
|
||||
|
||||
Dpx = DependencyExpression(self.Expression, ModuleType)
|
||||
Dpx.Generate(InputFile)
|
||||
|
||||
OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.depex')
|
||||
if self.DepexType.startswith('SMM'):
|
||||
OutputFile = os.path.join (OutputPath, ModuleName + 'SEC' + SecNum + '.smm')
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
SecType = (self.DepexType.startswith('PEI') and ['PEI_DEPEX'] or ['DXE_DEPEX'])[0]
|
||||
if self.DepexType.startswith('SMM'):
|
||||
SecType = 'SMM_DEPEX'
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [InputFile], Section.Section.SectionType.get (SecType))
|
||||
FileList = [OutputFile]
|
||||
return FileList, self.Alignment
|
262
BaseTools/Source/Python/GenFds/EfiSection.py
Normal file
262
BaseTools/Source/Python/GenFds/EfiSection.py
Normal file
@@ -0,0 +1,262 @@
|
||||
## @file
|
||||
# process rule section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import subprocess
|
||||
from Ffs import Ffs
|
||||
import os
|
||||
from CommonDataClass.FdfClass import EfiSectionClassObject
|
||||
import shutil
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## generate rule section
|
||||
#
|
||||
#
|
||||
class EfiSection (EfiSectionClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
EfiSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate rule section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name list, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}) :
|
||||
|
||||
if self.FileName != None and self.FileName.startswith('PCD('):
|
||||
self.FileName = GenFdsGlobalVariable.GetPcdValue(self.FileName)
|
||||
"""Prepare the parameter of GenSection"""
|
||||
if FfsInf != None :
|
||||
InfFileName = FfsInf.InfFileName
|
||||
SectionType = FfsInf.__ExtendMacro__(self.SectionType)
|
||||
Filename = FfsInf.__ExtendMacro__(self.FileName)
|
||||
BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
|
||||
StringData = FfsInf.__ExtendMacro__(self.StringData)
|
||||
NoStrip = True
|
||||
if FfsInf.ModuleType in ('SEC', 'PEI_CORE', 'PEIM') and SectionType in ('TE', 'PE32'):
|
||||
if FfsInf.KeepReloc != None:
|
||||
NoStrip = FfsInf.KeepReloc
|
||||
elif FfsInf.KeepRelocFromRule != None:
|
||||
NoStrip = FfsInf.KeepRelocFromRule
|
||||
elif self.KeepReloc != None:
|
||||
NoStrip = self.KeepReloc
|
||||
elif FfsInf.ShadowFromInfFile != None:
|
||||
NoStrip = FfsInf.ShadowFromInfFile
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s apply rule for None!" %ModuleName)
|
||||
|
||||
"""If the file name was pointed out, add it in FileList"""
|
||||
FileList = []
|
||||
if Filename != None:
|
||||
Filename = GenFdsGlobalVariable.MacroExtend(Filename, Dict)
|
||||
if not self.Optional:
|
||||
FileList.append(Filename)
|
||||
elif os.path.exists(Filename):
|
||||
FileList.append(Filename)
|
||||
else:
|
||||
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FileType, self.FileExtension, Dict)
|
||||
if IsSect :
|
||||
return FileList, self.Alignment
|
||||
|
||||
Index = 0
|
||||
|
||||
""" If Section type is 'VERSION'"""
|
||||
OutputFileList = []
|
||||
if SectionType == 'VERSION':
|
||||
|
||||
InfOverrideVerString = False
|
||||
if FfsInf.Version != None:
|
||||
#StringData = FfsInf.Version
|
||||
BuildNum = FfsInf.Version
|
||||
InfOverrideVerString = True
|
||||
|
||||
if InfOverrideVerString:
|
||||
#VerTuple = ('-n', '"' + StringData + '"')
|
||||
if BuildNum != None and BuildNum != '':
|
||||
BuildNumTuple = ('-j', BuildNum)
|
||||
else:
|
||||
BuildNumTuple = tuple()
|
||||
|
||||
Num = SecNum
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
|
||||
#Ui=StringData,
|
||||
Ver=BuildNum)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
elif FileList != []:
|
||||
for File in FileList:
|
||||
Index = Index + 1
|
||||
Num = '%s.%d' %(SecNum , Index)
|
||||
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
|
||||
f = open(File, 'r')
|
||||
VerString = f.read()
|
||||
f.close()
|
||||
# VerTuple = ('-n', '"' + VerString + '"')
|
||||
BuildNum = VerString
|
||||
if BuildNum != None and BuildNum != '':
|
||||
BuildNumTuple = ('-j', BuildNum)
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
|
||||
#Ui=VerString,
|
||||
Ver=BuildNum)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
else:
|
||||
# if StringData != None and len(StringData) > 0:
|
||||
# VerTuple = ('-n', '"' + StringData + '"')
|
||||
# else:
|
||||
# VerTuple = tuple()
|
||||
# VerString = ' ' + ' '.join(VerTuple)
|
||||
BuildNum = StringData
|
||||
if BuildNum != None and BuildNum != '':
|
||||
BuildNumTuple = ('-j', BuildNum)
|
||||
else:
|
||||
BuildNumTuple = tuple()
|
||||
BuildNumString = ' ' + ' '.join(BuildNumTuple)
|
||||
|
||||
#if VerString == '' and
|
||||
if BuildNumString == '':
|
||||
if self.Optional == True :
|
||||
GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!")
|
||||
return [], None
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss Version Section value" %InfFileName)
|
||||
Num = SecNum
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_VERSION',
|
||||
#Ui=VerString,
|
||||
Ver=BuildNum)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
#
|
||||
# If Section Type is 'UI'
|
||||
#
|
||||
elif SectionType == 'UI':
|
||||
|
||||
InfOverrideUiString = False
|
||||
if FfsInf.Ui != None:
|
||||
StringData = FfsInf.Ui
|
||||
InfOverrideUiString = True
|
||||
|
||||
if InfOverrideUiString:
|
||||
Num = SecNum
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
|
||||
Ui=StringData)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
elif FileList != []:
|
||||
for File in FileList:
|
||||
Index = Index + 1
|
||||
Num = '%s.%d' %(SecNum , Index)
|
||||
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
|
||||
f = open(File, 'r')
|
||||
UiString = f.read()
|
||||
f.close()
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
|
||||
Ui=UiString)
|
||||
OutputFileList.append(OutputFile)
|
||||
else:
|
||||
if StringData != None and len(StringData) > 0:
|
||||
UiTuple = ('-n', '"' + StringData + '"')
|
||||
else:
|
||||
UiTuple = tuple()
|
||||
|
||||
if self.Optional == True :
|
||||
GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!")
|
||||
return '', None
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "File: %s miss UI Section value" %InfFileName)
|
||||
|
||||
Num = SecNum
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + str(Num) + Ffs.SectionSuffix.get(SectionType))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [], 'EFI_SECTION_USER_INTERFACE',
|
||||
Ui=StringData)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
|
||||
else:
|
||||
"""If File List is empty"""
|
||||
if FileList == [] :
|
||||
if self.Optional == True:
|
||||
GenFdsGlobalVariable.VerboseLogger( "Optional Section don't exist!")
|
||||
return [], None
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Output file for %s section could not be found for %s" % (SectionType, InfFileName))
|
||||
|
||||
else:
|
||||
"""Convert the File to Section file one by one """
|
||||
for File in FileList:
|
||||
""" Copy Map file to FFS output path """
|
||||
Index = Index + 1
|
||||
Num = '%s.%d' %(SecNum , Index)
|
||||
OutputFile = os.path.join( OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get(SectionType))
|
||||
File = GenFdsGlobalVariable.MacroExtend(File, Dict)
|
||||
if File[(len(File)-4):] == '.efi':
|
||||
MapFile = File.replace('.efi', '.map')
|
||||
if os.path.exists(MapFile):
|
||||
CopyMapFile = os.path.join(OutputPath, ModuleName + '.map')
|
||||
if not os.path.exists(CopyMapFile) or \
|
||||
(os.path.getmtime(MapFile) > os.path.getmtime(CopyMapFile)):
|
||||
shutil.copyfile(MapFile, CopyMapFile)
|
||||
|
||||
if not NoStrip:
|
||||
FileBeforeStrip = os.path.join(OutputPath, ModuleName + '.efi')
|
||||
if not os.path.exists(FileBeforeStrip) or \
|
||||
(os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
|
||||
shutil.copyfile(File, FileBeforeStrip)
|
||||
StrippedFile = os.path.join(OutputPath, ModuleName + '.stripped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict)],
|
||||
Strip=True
|
||||
)
|
||||
File = StrippedFile
|
||||
"""For TE Section call GenFw to generate TE image"""
|
||||
|
||||
if SectionType == 'TE':
|
||||
TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict)],
|
||||
Type='te'
|
||||
)
|
||||
File = TeFile
|
||||
|
||||
"""Call GenSection"""
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File)],
|
||||
Section.Section.SectionType.get (SectionType)
|
||||
)
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
return OutputFileList, self.Alignment
|
169
BaseTools/Source/Python/GenFds/Fd.py
Normal file
169
BaseTools/Source/Python/GenFds/Fd.py
Normal file
@@ -0,0 +1,169 @@
|
||||
## @file
|
||||
# process FD generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Region
|
||||
import Fv
|
||||
import os
|
||||
import StringIO
|
||||
import sys
|
||||
from struct import *
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import FDClassObject
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from Common.Misc import SaveFileOnChange
|
||||
|
||||
## generate FD
|
||||
#
|
||||
#
|
||||
class FD(FDClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FDClassObject.__init__(self)
|
||||
|
||||
## GenFd() method
|
||||
#
|
||||
# Generate FD
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param FvBinDict dictionary contains generated FV name and its file name
|
||||
# @retval string Generated FD file name
|
||||
#
|
||||
def GenFd (self, FvBinDict):
|
||||
#
|
||||
# Print Information
|
||||
#
|
||||
GenFdsGlobalVariable.InfLogger("Fd File Name:%s" %self.FdUiName)
|
||||
Offset = 0x00
|
||||
for item in self.BlockSizeList:
|
||||
Offset = Offset + item[0] * item[1]
|
||||
if Offset != self.Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s Size not consistent with block array' % self.FdUiName)
|
||||
GenFdsGlobalVariable.VerboseLogger('Following Fv will be add to Fd !!!')
|
||||
for FvObj in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
|
||||
GenFdsGlobalVariable.VerboseLogger(FvObj)
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger('################### Gen VTF ####################')
|
||||
self.GenVtfFile()
|
||||
|
||||
FdBuffer = StringIO.StringIO('')
|
||||
PreviousRegionStart = -1
|
||||
PreviousRegionSize = 1
|
||||
for RegionObj in self.RegionList :
|
||||
if RegionObj.Offset + RegionObj.Size <= PreviousRegionStart:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
'Region offset 0x%X in wrong order with Region starting from 0x%X, size 0x%X\nRegions in FDF must have offsets appear in ascending order.'\
|
||||
% (RegionObj.Offset, PreviousRegionStart, PreviousRegionSize))
|
||||
elif RegionObj.Offset <= PreviousRegionStart or (RegionObj.Offset >=PreviousRegionStart and RegionObj.Offset < PreviousRegionStart + PreviousRegionSize):
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
'Region offset 0x%X overlaps with Region starting from 0x%X, size 0x%X' \
|
||||
% (RegionObj.Offset, PreviousRegionStart, PreviousRegionSize))
|
||||
elif RegionObj.Offset > PreviousRegionStart + PreviousRegionSize:
|
||||
GenFdsGlobalVariable.InfLogger('Padding region starting from offset 0x%X, with size 0x%X' %(PreviousRegionStart + PreviousRegionSize, RegionObj.Offset - (PreviousRegionStart + PreviousRegionSize)))
|
||||
PadRegion = Region.Region()
|
||||
PadRegion.Offset = PreviousRegionStart + PreviousRegionSize
|
||||
PadRegion.Size = RegionObj.Offset - PadRegion.Offset
|
||||
PadRegion.AddToBuffer(FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||
PreviousRegionStart = RegionObj.Offset
|
||||
PreviousRegionSize = RegionObj.Size
|
||||
#
|
||||
# Call each region's AddToBuffer function
|
||||
#
|
||||
if PreviousRegionSize > self.Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'FD %s size too small' % self.FdUiName)
|
||||
GenFdsGlobalVariable.VerboseLogger('Call each region\'s AddToBuffer function')
|
||||
RegionObj.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict, self.DefineVarDict)
|
||||
#
|
||||
# Create a empty Fd file
|
||||
#
|
||||
GenFdsGlobalVariable.VerboseLogger ('Create an empty Fd file')
|
||||
FdFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
||||
self.FdUiName + '.fd')
|
||||
#FdFile = open(FdFileName, 'wb')
|
||||
|
||||
#
|
||||
# Write the buffer contents to Fd file
|
||||
#
|
||||
GenFdsGlobalVariable.VerboseLogger('Write the buffer contents to Fd file')
|
||||
SaveFileOnChange(FdFileName, FdBuffer.getvalue())
|
||||
#FdFile.write(FdBuffer.getvalue());
|
||||
#FdFile.close();
|
||||
FdBuffer.close();
|
||||
return FdFileName
|
||||
|
||||
## generate VTF
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GenVtfFile (self) :
|
||||
#
|
||||
# Get this Fd's all Fv name
|
||||
#
|
||||
FvAddDict ={}
|
||||
FvList = []
|
||||
for RegionObj in self.RegionList:
|
||||
if RegionObj.RegionType == 'FV':
|
||||
if len(RegionObj.RegionDataList) == 1:
|
||||
RegionData = RegionObj.RegionDataList[0]
|
||||
FvList.append(RegionData.upper())
|
||||
FvAddDict[RegionData.upper()] = (int(self.BaseAddress,16) + \
|
||||
RegionObj.Offset, RegionObj.Size)
|
||||
else:
|
||||
Offset = RegionObj.Offset
|
||||
for RegionData in RegionObj.RegionDataList:
|
||||
FvList.append(RegionData.upper())
|
||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())
|
||||
if len(FvObj.BlockSizeList) < 1:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
'FV.%s must point out FVs blocksize and Fv BlockNum' \
|
||||
% FvObj.UiFvName)
|
||||
else:
|
||||
Size = 0
|
||||
for blockStatement in FvObj.BlockSizeList:
|
||||
Size = Size + blockStatement[0] * blockStatement[1]
|
||||
FvAddDict[RegionData.upper()] = (int(self.BaseAddress,16) + \
|
||||
Offset, Size)
|
||||
Offset = Offset + Size
|
||||
#
|
||||
# Check whether this Fd need VTF
|
||||
#
|
||||
Flag = False
|
||||
for VtfObj in GenFdsGlobalVariable.FdfParser.Profile.VtfList:
|
||||
compLocList = VtfObj.GetFvList()
|
||||
if set(compLocList).issubset(FvList):
|
||||
Flag = True
|
||||
break
|
||||
if Flag == True:
|
||||
self.vtfRawDict = VtfObj.GenVtf(FvAddDict)
|
||||
|
||||
## generate flash map file
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GenFlashMap (self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
3778
BaseTools/Source/Python/GenFds/FdfParser.py
Normal file
3778
BaseTools/Source/Python/GenFds/FdfParser.py
Normal file
File diff suppressed because it is too large
Load Diff
81
BaseTools/Source/Python/GenFds/Ffs.py
Normal file
81
BaseTools/Source/Python/GenFds/Ffs.py
Normal file
@@ -0,0 +1,81 @@
|
||||
## @file
|
||||
# process FFS generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from CommonDataClass.FdfClass import FDClassObject
|
||||
|
||||
## generate FFS
|
||||
#
|
||||
#
|
||||
class Ffs(FDClassObject):
|
||||
|
||||
# mapping between MODULE type in FDF (from INF) and file type for GenFfs
|
||||
ModuleTypeToFileType = {
|
||||
'SEC' : 'EFI_FV_FILETYPE_SECURITY_CORE',
|
||||
'PEI_CORE' : 'EFI_FV_FILETYPE_PEI_CORE',
|
||||
'PEIM' : 'EFI_FV_FILETYPE_PEIM',
|
||||
'DXE_CORE' : 'EFI_FV_FILETYPE_DXE_CORE',
|
||||
'DXE_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
|
||||
'DXE_SAL_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
|
||||
'DXE_SMM_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
|
||||
'DXE_RUNTIME_DRIVER': 'EFI_FV_FILETYPE_DRIVER',
|
||||
'UEFI_DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
|
||||
'UEFI_APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION',
|
||||
'SMM_DRIVER' : 'EFI_FV_FILETYPE_SMM',
|
||||
'SMM_CORE' : 'EFI_FV_FILETYPE_SMM_CORE'
|
||||
}
|
||||
|
||||
# mapping between FILE type in FDF and file type for GenFfs
|
||||
FdfFvFileTypeToFileType = {
|
||||
'SEC' : 'EFI_FV_FILETYPE_SECURITY_CORE',
|
||||
'PEI_CORE' : 'EFI_FV_FILETYPE_PEI_CORE',
|
||||
'PEIM' : 'EFI_FV_FILETYPE_PEIM',
|
||||
'DXE_CORE' : 'EFI_FV_FILETYPE_DXE_CORE',
|
||||
'FREEFORM' : 'EFI_FV_FILETYPE_FREEFORM',
|
||||
'DRIVER' : 'EFI_FV_FILETYPE_DRIVER',
|
||||
'APPLICATION' : 'EFI_FV_FILETYPE_APPLICATION',
|
||||
'FV_IMAGE' : 'EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE',
|
||||
'RAW' : 'EFI_FV_FILETYPE_RAW',
|
||||
'PEI_DXE_COMBO' : 'EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER',
|
||||
'SMM_DXE_COMBO' : 'EFI_FV_FILETYPE_COMBINED_SMM_DXE',
|
||||
'SMM' : 'EFI_FV_FILETYPE_SMM',
|
||||
'SMM_CORE' : 'EFI_FV_FILETYPE_SMM_CORE'
|
||||
}
|
||||
|
||||
# mapping between section type in FDF and file suffix
|
||||
SectionSuffix = {
|
||||
'PE32' : '.pe32',
|
||||
'PIC' : '.pic',
|
||||
'TE' : '.te',
|
||||
'DXE_DEPEX' : '.dpx',
|
||||
'VERSION' : '.ver',
|
||||
'UI' : '.ui',
|
||||
'COMPAT16' : '.com16',
|
||||
'RAW' : '.raw',
|
||||
'FREEFORM_SUBTYPE_GUID': '.guid',
|
||||
'FV_IMAGE' : 'fv.sec',
|
||||
'COMPRESS' : '.com',
|
||||
'GUIDED' : '.guided',
|
||||
'PEI_DEPEX' : '.dpx',
|
||||
'SMM_DEPEX' : '.smm'
|
||||
}
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FfsClassObject.__init__(self)
|
118
BaseTools/Source/Python/GenFds/FfsFileStatement.py
Normal file
118
BaseTools/Source/Python/GenFds/FfsFileStatement.py
Normal file
@@ -0,0 +1,118 @@
|
||||
## @file
|
||||
# process FFS generation from FILE statement
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Ffs
|
||||
import Rule
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import os
|
||||
import StringIO
|
||||
import subprocess
|
||||
from CommonDataClass.FdfClass import FileStatementClassObject
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
from Common.Misc import GuidStructureByteArrayToGuidString
|
||||
|
||||
## generate FFS from FILE
|
||||
#
|
||||
#
|
||||
class FileStatement (FileStatementClassObject) :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FileStatementClassObject.__init__(self)
|
||||
|
||||
## GenFfs() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}):
|
||||
|
||||
if self.NameGuid != None and self.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
|
||||
if len(PcdValue) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
|
||||
% (self.NameGuid))
|
||||
if PcdValue.startswith('{'):
|
||||
PcdValue = GuidStructureByteArrayToGuidString(PcdValue)
|
||||
RegistryGuidStr = PcdValue
|
||||
if len(RegistryGuidStr) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \
|
||||
% (self.NameGuid))
|
||||
self.NameGuid = RegistryGuidStr
|
||||
|
||||
OutputDir = os.path.join(GenFdsGlobalVariable.FfsDir, self.NameGuid)
|
||||
if not os.path.exists(OutputDir):
|
||||
os.makedirs(OutputDir)
|
||||
|
||||
Dict.update(self.DefineVarDict)
|
||||
SectionAlignments = None
|
||||
if self.FvName != None :
|
||||
Buffer = StringIO.StringIO('')
|
||||
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
|
||||
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
|
||||
FileName = Fv.AddToBuffer(Buffer)
|
||||
SectionFiles = [FileName]
|
||||
|
||||
elif self.FdName != None:
|
||||
if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
|
||||
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
|
||||
FvBin = {}
|
||||
FileName = Fd.GenFd(FvBin)
|
||||
SectionFiles = [FileName]
|
||||
|
||||
elif self.FileName != None:
|
||||
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
SectionFiles = [GenFdsGlobalVariable.MacroExtend(self.FileName, Dict)]
|
||||
|
||||
else:
|
||||
SectionFiles = []
|
||||
Index = 0
|
||||
SectionAlignments = []
|
||||
for section in self.SectionList :
|
||||
Index = Index + 1
|
||||
SecIndex = '%d' %Index
|
||||
sectList, align = section.GenSection(OutputDir, self.NameGuid, SecIndex, self.KeyStringList, None, Dict)
|
||||
if sectList != []:
|
||||
for sect in sectList:
|
||||
SectionFiles.append(sect)
|
||||
SectionAlignments.append(align)
|
||||
|
||||
#
|
||||
# Prepare the parameter
|
||||
#
|
||||
FfsFileOutput = os.path.join(OutputDir, self.NameGuid + '.ffs')
|
||||
GenFdsGlobalVariable.GenerateFfs(FfsFileOutput, SectionFiles,
|
||||
Ffs.Ffs.FdfFvFileTypeToFileType.get(self.FvFileType),
|
||||
self.NameGuid,
|
||||
Fixed=self.Fixed,
|
||||
CheckSum=self.CheckSum,
|
||||
Align=self.Alignment,
|
||||
SectionAlign=SectionAlignments
|
||||
)
|
||||
|
||||
return FfsFileOutput
|
||||
|
||||
|
||||
|
582
BaseTools/Source/Python/GenFds/FfsInfStatement.py
Normal file
582
BaseTools/Source/Python/GenFds/FfsInfStatement.py
Normal file
@@ -0,0 +1,582 @@
|
||||
## @file
|
||||
# process FFS generation from INF statement
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Rule
|
||||
import os
|
||||
import shutil
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import Ffs
|
||||
import subprocess
|
||||
import sys
|
||||
import Section
|
||||
import RuleSimpleFile
|
||||
import RuleComplexFile
|
||||
from CommonDataClass.FdfClass import FfsInfStatementClassObject
|
||||
from Common.String import *
|
||||
from Common.Misc import PathClass
|
||||
from Common.Misc import GuidStructureByteArrayToGuidString
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## generate FFS from INF
|
||||
#
|
||||
#
|
||||
class FfsInfStatement(FfsInfStatementClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FfsInfStatementClassObject.__init__(self)
|
||||
self.TargetOverrideList = []
|
||||
self.ShadowFromInfFile = None
|
||||
self.KeepRelocFromRule = None
|
||||
self.InDsc = True
|
||||
self.OptRomDefs = {}
|
||||
|
||||
## __InfParse() method
|
||||
#
|
||||
# Parse inf file to get module information
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
#
|
||||
def __InfParse__(self, Dict = {}):
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)
|
||||
|
||||
self.InfFileName = self.InfFileName.replace('$(WORKSPACE)', '')
|
||||
if self.InfFileName[0] == '\\' or self.InfFileName[0] == '/' :
|
||||
self.InfFileName = self.InfFileName[1:]
|
||||
|
||||
if self.InfFileName.find('$') == -1:
|
||||
InfPath = NormPath(self.InfFileName)
|
||||
if not os.path.exists(InfPath):
|
||||
InfPath = GenFdsGlobalVariable.ReplaceWorkspaceMacro(InfPath)
|
||||
if not os.path.exists(InfPath):
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Non-existant Module %s !" % (self.InfFileName))
|
||||
|
||||
self.CurrentArch = self.GetCurrentArch()
|
||||
#
|
||||
# Get the InfClass object
|
||||
#
|
||||
|
||||
PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)
|
||||
ErrorCode, ErrorInfo = PathClassObj.Validate()
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
|
||||
|
||||
if self.CurrentArch != None:
|
||||
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch]
|
||||
#
|
||||
# Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath
|
||||
#
|
||||
self.BaseName = Inf.BaseName
|
||||
self.ModuleGuid = Inf.Guid
|
||||
self.ModuleType = Inf.ModuleType
|
||||
if Inf.AutoGenVersion < 0x00010005:
|
||||
self.ModuleType = Inf.ComponentType
|
||||
self.VersionString = Inf.Version
|
||||
self.BinFileList = Inf.Binaries
|
||||
self.SourceFileList = Inf.Sources
|
||||
if self.KeepReloc == None and Inf.Shadow:
|
||||
self.ShadowFromInfFile = Inf.Shadow
|
||||
|
||||
else:
|
||||
Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON']
|
||||
self.BaseName = Inf.BaseName
|
||||
self.ModuleGuid = Inf.Guid
|
||||
self.ModuleType = Inf.ModuleType
|
||||
self.VersionString = Inf.Version
|
||||
self.BinFileList = Inf.Binaries
|
||||
self.SourceFileList = Inf.Sources
|
||||
if self.BinFileList == []:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"INF %s specified in FDF could not be found in build ARCH %s!" \
|
||||
% (self.InfFileName, GenFdsGlobalVariable.ArchList))
|
||||
|
||||
if len(self.SourceFileList) != 0 and not self.InDsc:
|
||||
EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))
|
||||
|
||||
if Inf._Defs != None and len(Inf._Defs) > 0:
|
||||
self.OptRomDefs.update(Inf._Defs)
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger( "BaseName : %s" %self.BaseName)
|
||||
GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" %self.ModuleGuid)
|
||||
GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" %self.ModuleType)
|
||||
GenFdsGlobalVariable.VerboseLogger("VersionString : %s" %self.VersionString)
|
||||
GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" %self.InfFileName)
|
||||
|
||||
#
|
||||
# Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\
|
||||
#
|
||||
|
||||
self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \
|
||||
self.ModuleGuid + self.BaseName)
|
||||
if not os.path.exists(self.OutputPath) :
|
||||
os.makedirs(self.OutputPath)
|
||||
|
||||
self.EfiOutputPath = self.__GetEFIOutPutPath__()
|
||||
GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)
|
||||
|
||||
## GenFfs() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}):
|
||||
#
|
||||
# Parse Inf file get Module related information
|
||||
#
|
||||
|
||||
self.__InfParse__(Dict)
|
||||
#
|
||||
# Get the rule of how to generate Ffs file
|
||||
#
|
||||
Rule = self.__GetRule__()
|
||||
GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
|
||||
#FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]
|
||||
#
|
||||
# For the rule only has simpleFile
|
||||
#
|
||||
if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
|
||||
SectionOutputList = self.__GenSimpleFileSection__(Rule)
|
||||
FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList)
|
||||
return FfsOutput
|
||||
#
|
||||
# For Rule has ComplexFile
|
||||
#
|
||||
elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
|
||||
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule)
|
||||
FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)
|
||||
|
||||
return FfsOutput
|
||||
|
||||
## __ExtendMacro__() method
|
||||
#
|
||||
# Replace macro with its value
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param String The string to be replaced
|
||||
# @retval string Macro replaced string
|
||||
#
|
||||
def __ExtendMacro__ (self, String):
|
||||
MacroDict = {
|
||||
'$(INF_OUTPUT)' : self.EfiOutputPath,
|
||||
'$(MODULE_NAME)' : self.BaseName,
|
||||
'$(BUILD_NUMBER)': self.BuildNum,
|
||||
'$(INF_VERSION)' : self.VersionString,
|
||||
'$(NAMED_GUID)' : self.ModuleGuid
|
||||
}
|
||||
String = GenFdsGlobalVariable.MacroExtend(String, MacroDict)
|
||||
return String
|
||||
|
||||
## __GetRule__() method
|
||||
#
|
||||
# Get correct rule for generating FFS for this INF
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval Rule Rule object
|
||||
#
|
||||
def __GetRule__ (self) :
|
||||
CurrentArchList = []
|
||||
if self.CurrentArch == None:
|
||||
CurrentArchList = ['common']
|
||||
else:
|
||||
CurrentArchList.append(self.CurrentArch)
|
||||
|
||||
for CurrentArch in CurrentArchList:
|
||||
RuleName = 'RULE' + \
|
||||
'.' + \
|
||||
CurrentArch.upper() + \
|
||||
'.' + \
|
||||
self.ModuleType.upper()
|
||||
if self.Rule != None:
|
||||
RuleName = RuleName + \
|
||||
'.' + \
|
||||
self.Rule.upper()
|
||||
|
||||
Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)
|
||||
if Rule != None:
|
||||
GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)
|
||||
return Rule
|
||||
|
||||
RuleName = 'RULE' + \
|
||||
'.' + \
|
||||
'COMMON' + \
|
||||
'.' + \
|
||||
self.ModuleType.upper()
|
||||
|
||||
if self.Rule != None:
|
||||
RuleName = RuleName + \
|
||||
'.' + \
|
||||
self.Rule.upper()
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger ('Trying to apply common rule %s for INF %s' % (RuleName, self.InfFileName))
|
||||
|
||||
Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)
|
||||
if Rule != None:
|
||||
GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)
|
||||
return Rule
|
||||
|
||||
if Rule == None :
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'Don\'t Find common rule %s for INF %s' \
|
||||
% (RuleName, self.InfFileName))
|
||||
|
||||
## __GetPlatformArchList__() method
|
||||
#
|
||||
# Get Arch list this INF built under
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval list Arch list
|
||||
#
|
||||
def __GetPlatformArchList__(self):
|
||||
|
||||
InfFileKey = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName))
|
||||
DscArchList = []
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32']
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in PlatformDataBase.Modules:
|
||||
DscArchList.append ('IA32')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'X64']
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in PlatformDataBase.Modules:
|
||||
DscArchList.append ('X64')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IPF']
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('IPF')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'ARM']
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('ARM')
|
||||
|
||||
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'EBC']
|
||||
if PlatformDataBase != None:
|
||||
if InfFileKey in (PlatformDataBase.Modules):
|
||||
DscArchList.append ('EBC')
|
||||
|
||||
return DscArchList
|
||||
|
||||
## GetCurrentArch() method
|
||||
#
|
||||
# Get Arch list of the module from this INF is to be placed into flash
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval list Arch list
|
||||
#
|
||||
def GetCurrentArch(self) :
|
||||
|
||||
TargetArchList = GenFdsGlobalVariable.ArchList
|
||||
|
||||
PlatformArchList = self.__GetPlatformArchList__()
|
||||
|
||||
CurArchList = TargetArchList
|
||||
if PlatformArchList != []:
|
||||
CurArchList = list(set (TargetArchList) & set (PlatformArchList))
|
||||
GenFdsGlobalVariable.VerboseLogger ("Valid target architecture(s) is : " + " ".join(CurArchList))
|
||||
|
||||
ArchList = []
|
||||
if self.KeyStringList != []:
|
||||
for Key in self.KeyStringList:
|
||||
Key = GenFdsGlobalVariable.MacroExtend(Key)
|
||||
Target, Tag, Arch = Key.split('_')
|
||||
if Arch in CurArchList:
|
||||
ArchList.append(Arch)
|
||||
if Target not in self.TargetOverrideList:
|
||||
self.TargetOverrideList.append(Target)
|
||||
else:
|
||||
ArchList = CurArchList
|
||||
|
||||
UseArchList = TargetArchList
|
||||
if self.UseArch != None:
|
||||
UseArchList = []
|
||||
UseArchList.append(self.UseArch)
|
||||
ArchList = list(set (UseArchList) & set (ArchList))
|
||||
|
||||
self.InfFileName = NormPath(self.InfFileName)
|
||||
if len(PlatformArchList) == 0:
|
||||
self.InDsc = False
|
||||
PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)
|
||||
ErrorCode, ErrorInfo = PathClassObj.Validate()
|
||||
if ErrorCode != 0:
|
||||
EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)
|
||||
if len(ArchList) == 1:
|
||||
Arch = ArchList[0]
|
||||
return Arch
|
||||
elif len(ArchList) > 1:
|
||||
if len(PlatformArchList) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "GenFds command line option has multiple ARCHs %s. Not able to determine which ARCH is valid for Module %s !" % (str(ArchList), self.InfFileName))
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Module built under multiple ARCHs %s. Not able to determine which output to put into flash for Module %s !" % (str(ArchList), self.InfFileName))
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s appears under ARCH %s in platform %s, but current deduced ARCH is %s, so NO build output could be put into flash." \
|
||||
% (self.InfFileName, str(PlatformArchList), GenFdsGlobalVariable.ActivePlatform, str(set (UseArchList) & set (TargetArchList))))
|
||||
|
||||
## __GetEFIOutPutPath__() method
|
||||
#
|
||||
# Get the output path for generated files
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval string Path that output files from this INF go to
|
||||
#
|
||||
def __GetEFIOutPutPath__(self):
|
||||
Arch = ''
|
||||
OutputPath = ''
|
||||
(ModulePath, FileName) = os.path.split(self.InfFileName)
|
||||
Index = FileName.find('.')
|
||||
FileName = FileName[0:Index]
|
||||
Arch = "NoneArch"
|
||||
if self.CurrentArch != None:
|
||||
Arch = self.CurrentArch
|
||||
|
||||
OutputPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],
|
||||
Arch ,
|
||||
ModulePath,
|
||||
FileName,
|
||||
'OUTPUT'
|
||||
)
|
||||
OutputPath = os.path.realpath(OutputPath)
|
||||
return OutputPath
|
||||
|
||||
## __GenSimpleFileSection__() method
|
||||
#
|
||||
# Generate section by specified file name or a list of files with file 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):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
FileList = []
|
||||
OutputFileList = []
|
||||
if Rule.FileName != None:
|
||||
GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
|
||||
else:
|
||||
FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
|
||||
|
||||
Index = 1
|
||||
SectionType = Rule.SectionType
|
||||
NoStrip = True
|
||||
if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
|
||||
if self.KeepReloc != None:
|
||||
NoStrip = self.KeepReloc
|
||||
elif Rule.KeepReloc != None:
|
||||
NoStrip = Rule.KeepReloc
|
||||
elif self.ShadowFromInfFile != None:
|
||||
NoStrip = self.ShadowFromInfFile
|
||||
|
||||
if FileList != [] :
|
||||
for File in FileList:
|
||||
|
||||
SecNum = '%d' %Index
|
||||
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
|
||||
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
|
||||
Index = Index + 1
|
||||
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
|
||||
|
||||
if not NoStrip:
|
||||
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
|
||||
if not os.path.exists(FileBeforeStrip) or \
|
||||
(os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):
|
||||
shutil.copyfile(File, FileBeforeStrip)
|
||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
Strip=True
|
||||
)
|
||||
File = StrippedFile
|
||||
|
||||
if SectionType == 'TE':
|
||||
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
Type='te'
|
||||
)
|
||||
File = TeFile
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [File], Section.Section.SectionType[SectionType])
|
||||
OutputFileList.append(OutputFile)
|
||||
else:
|
||||
SecNum = '%d' %Index
|
||||
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
|
||||
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
|
||||
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
|
||||
|
||||
if not NoStrip:
|
||||
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
|
||||
if not os.path.exists(FileBeforeStrip) or \
|
||||
(os.path.getmtime(GenSecInputFile) > os.path.getmtime(FileBeforeStrip)):
|
||||
shutil.copyfile(GenSecInputFile, FileBeforeStrip)
|
||||
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
StrippedFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)],
|
||||
Strip=True
|
||||
)
|
||||
GenSecInputFile = StrippedFile
|
||||
|
||||
if SectionType == 'TE':
|
||||
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
|
||||
GenFdsGlobalVariable.GenerateFirmwareImage(
|
||||
TeFile,
|
||||
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
|
||||
Type='te'
|
||||
)
|
||||
GenSecInputFile = TeFile
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputFile], Section.Section.SectionType[SectionType])
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
return OutputFileList
|
||||
|
||||
## __GenSimpleFileFfs__() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @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):
|
||||
FfsOutput = self.OutputPath + \
|
||||
os.sep + \
|
||||
self.__ExtendMacro__(Rule.NameGuid) + \
|
||||
'.ffs'
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger(self.__ExtendMacro__(Rule.NameGuid))
|
||||
InputSection = []
|
||||
SectionAlignments = []
|
||||
for InputFile in InputFileList:
|
||||
InputSection.append(InputFile)
|
||||
SectionAlignments.append(Rule.Alignment)
|
||||
|
||||
if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
|
||||
if len(PcdValue) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
|
||||
% (Rule.NameGuid))
|
||||
if PcdValue.startswith('{'):
|
||||
PcdValue = GuidStructureByteArrayToGuidString(PcdValue)
|
||||
RegistryGuidStr = PcdValue
|
||||
if len(RegistryGuidStr) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \
|
||||
% (Rule.NameGuid))
|
||||
self.ModuleGuid = RegistryGuidStr
|
||||
|
||||
GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection,
|
||||
Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],
|
||||
self.ModuleGuid, Fixed=Rule.Fixed,
|
||||
CheckSum=Rule.CheckSum, Align=Rule.Alignment,
|
||||
SectionAlign=SectionAlignments
|
||||
)
|
||||
return FfsOutput
|
||||
|
||||
## __GenComplexFileSection__() method
|
||||
#
|
||||
# Generate section by sections in 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 __GenComplexFileSection__(self, Rule):
|
||||
if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
|
||||
if Rule.KeepReloc != None:
|
||||
self.KeepRelocFromRule = Rule.KeepReloc
|
||||
SectFiles = []
|
||||
SectAlignments = []
|
||||
Index = 1
|
||||
for Sect in Rule.SectionList:
|
||||
SecIndex = '%d' %Index
|
||||
SectList = []
|
||||
if Rule.KeyStringList != []:
|
||||
SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)
|
||||
else :
|
||||
SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self)
|
||||
for SecName in SectList :
|
||||
SectFiles.append(SecName)
|
||||
SectAlignments.append(Align)
|
||||
Index = Index + 1
|
||||
return SectFiles, SectAlignments
|
||||
|
||||
## __GenComplexFileFfs__() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @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):
|
||||
|
||||
if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
|
||||
PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
|
||||
if len(PcdValue) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
|
||||
% (Rule.NameGuid))
|
||||
if PcdValue.startswith('{'):
|
||||
PcdValue = GuidStructureByteArrayToGuidString(PcdValue)
|
||||
RegistryGuidStr = PcdValue
|
||||
if len(RegistryGuidStr) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \
|
||||
% (Rule.NameGuid))
|
||||
self.ModuleGuid = RegistryGuidStr
|
||||
|
||||
FfsOutput = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')
|
||||
GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile,
|
||||
Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],
|
||||
self.ModuleGuid, Fixed=Rule.Fixed,
|
||||
CheckSum=Rule.CheckSum, Align=Rule.Alignment,
|
||||
SectionAlign=Alignments
|
||||
)
|
||||
return FfsOutput
|
||||
|
||||
## __GetGenFfsCmdParameter__() method
|
||||
#
|
||||
# Create parameter string for GenFfs
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Rule The rule object used to generate section
|
||||
# @retval tuple (FileType, Fixed, CheckSum, Alignment)
|
||||
#
|
||||
def __GetGenFfsCmdParameter__(self, Rule):
|
||||
result = tuple()
|
||||
result += ('-t', Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType])
|
||||
if Rule.Fixed != False:
|
||||
result += ('-x',)
|
||||
if Rule.CheckSum != False:
|
||||
result += ('-s',)
|
||||
|
||||
if Rule.Alignment != None and Rule.Alignment != '':
|
||||
result += ('-a', Rule.Alignment)
|
||||
|
||||
return result
|
215
BaseTools/Source/Python/GenFds/Fv.py
Normal file
215
BaseTools/Source/Python/GenFds/Fv.py
Normal file
@@ -0,0 +1,215 @@
|
||||
## @file
|
||||
# process FV generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import StringIO
|
||||
|
||||
import Ffs
|
||||
import AprioriSection
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from GenFds import GenFds
|
||||
from CommonDataClass.FdfClass import FvClassObject
|
||||
from Common.Misc import SaveFileOnChange
|
||||
|
||||
T_CHAR_LF = '\n'
|
||||
|
||||
## generate FV
|
||||
#
|
||||
#
|
||||
class FV (FvClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FvClassObject.__init__(self)
|
||||
self.FvInfFile = None
|
||||
self.FvAddressFile = None
|
||||
self.BaseAddress = None
|
||||
self.InfFileName = None
|
||||
self.FvAddressFileName = None
|
||||
|
||||
## AddToBuffer()
|
||||
#
|
||||
# Generate Fv and add it to the Buffer
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Buffer The buffer generated FV data will be put
|
||||
# @param BaseAddress base address of FV
|
||||
# @param BlockSize block size of FV
|
||||
# @param BlockNum How many blocks in FV
|
||||
# @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=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}) :
|
||||
|
||||
if self.UiFvName.upper() in GenFds.FvBinDict.keys():
|
||||
return GenFds.FvBinDict[self.UiFvName.upper()]
|
||||
|
||||
GenFdsGlobalVariable.InfLogger( "\nGenerating %s FV ..." %self.UiFvName)
|
||||
|
||||
self.__InitializeInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)
|
||||
#
|
||||
# First Process the Apriori section
|
||||
#
|
||||
MacroDict.update(self.DefineVarDict)
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger('First generate Apriori file !')
|
||||
FfsFileList = []
|
||||
for AprSection in self.AprioriSectionList:
|
||||
FileName = AprSection.GenFfs (self.UiFvName, MacroDict)
|
||||
FfsFileList.append(FileName)
|
||||
# Add Apriori file name to Inf file
|
||||
self.FvInfFile.writelines("EFI_FILE_NAME = " + \
|
||||
FileName + \
|
||||
T_CHAR_LF)
|
||||
|
||||
# Process Modules in FfsList
|
||||
for FfsFile in self.FfsList :
|
||||
FileName = FfsFile.GenFfs(MacroDict)
|
||||
FfsFileList.append(FileName)
|
||||
self.FvInfFile.writelines("EFI_FILE_NAME = " + \
|
||||
FileName + \
|
||||
T_CHAR_LF)
|
||||
|
||||
SaveFileOnChange(self.InfFileName, self.FvInfFile.getvalue(), False)
|
||||
self.FvInfFile.close()
|
||||
#
|
||||
# Call GenFv tool
|
||||
#
|
||||
FvOutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiFvName)
|
||||
FvOutputFile = FvOutputFile + '.Fv'
|
||||
# BUGBUG: FvOutputFile could be specified from FDF file (FV section, CreateFile statement)
|
||||
if self.CreateFileName != None:
|
||||
FvOutputFile = self.CreateFileName
|
||||
|
||||
FvInfoFileName = os.path.join(GenFdsGlobalVariable.FfsDir, self.UiFvName + '.inf')
|
||||
shutil.copy(GenFdsGlobalVariable.FvAddressFileName, FvInfoFileName)
|
||||
GenFdsGlobalVariable.GenerateFirmwareVolume(
|
||||
FvOutputFile,
|
||||
[self.InfFileName],
|
||||
AddressFile=FvInfoFileName,
|
||||
FfsList=FfsFileList
|
||||
)
|
||||
|
||||
#
|
||||
# Write the Fv contents to Buffer
|
||||
#
|
||||
FvFileObj = open ( FvOutputFile,'r+b')
|
||||
|
||||
GenFdsGlobalVariable.InfLogger( "\nGenerate %s FV Successfully" %self.UiFvName)
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
Buffer.write(FvFileObj.read())
|
||||
FvFileObj.close()
|
||||
GenFds.FvBinDict[self.UiFvName.upper()] = FvOutputFile
|
||||
return FvOutputFile
|
||||
|
||||
## __InitializeInf__()
|
||||
#
|
||||
# Initilize the inf file to create FV
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param BaseAddress base address of FV
|
||||
# @param BlockSize block size of FV
|
||||
# @param BlockNum How many blocks in FV
|
||||
# @param ErasePolarity Flash erase polarity
|
||||
# @param VtfDict VTF objects
|
||||
#
|
||||
def __InitializeInf__ (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1', VtfDict=None) :
|
||||
#
|
||||
# Create FV inf file
|
||||
#
|
||||
self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,
|
||||
self.UiFvName + '.inf')
|
||||
self.FvInfFile = StringIO.StringIO()
|
||||
|
||||
#
|
||||
# Add [Options]
|
||||
#
|
||||
self.FvInfFile.writelines("[options]" + T_CHAR_LF)
|
||||
if BaseAddress != None :
|
||||
self.FvInfFile.writelines("EFI_BASE_ADDRESS = " + \
|
||||
BaseAddress + \
|
||||
T_CHAR_LF)
|
||||
|
||||
if BlockSize != None:
|
||||
self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \
|
||||
'0x%X' %BlockSize + \
|
||||
T_CHAR_LF)
|
||||
if BlockNum != None:
|
||||
self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \
|
||||
' 0x%X' %BlockNum + \
|
||||
T_CHAR_LF)
|
||||
else:
|
||||
for BlockSize in self.BlockSizeList :
|
||||
if BlockSize[0] != None:
|
||||
self.FvInfFile.writelines("EFI_BLOCK_SIZE = " + \
|
||||
'0x%X' %BlockSize[0] + \
|
||||
T_CHAR_LF)
|
||||
|
||||
if BlockSize[1] != None:
|
||||
self.FvInfFile.writelines("EFI_NUM_BLOCKS = " + \
|
||||
' 0x%X' %BlockSize[1] + \
|
||||
T_CHAR_LF)
|
||||
|
||||
if self.BsBaseAddress != None:
|
||||
self.FvInfFile.writelines('EFI_BOOT_DRIVER_BASE_ADDRESS = ' + \
|
||||
'0x%X' %self.BsBaseAddress)
|
||||
if self.RtBaseAddress != None:
|
||||
self.FvInfFile.writelines('EFI_RUNTIME_DRIVER_BASE_ADDRESS = ' + \
|
||||
'0x%X' %self.RtBaseAddress)
|
||||
#
|
||||
# Add attribute
|
||||
#
|
||||
self.FvInfFile.writelines("[attributes]" + T_CHAR_LF)
|
||||
|
||||
self.FvInfFile.writelines("EFI_ERASE_POLARITY = " + \
|
||||
' %s' %ErasePloarity + \
|
||||
T_CHAR_LF)
|
||||
if not (self.FvAttributeDict == None):
|
||||
for FvAttribute in self.FvAttributeDict.keys() :
|
||||
self.FvInfFile.writelines("EFI_" + \
|
||||
FvAttribute + \
|
||||
' = ' + \
|
||||
self.FvAttributeDict[FvAttribute] + \
|
||||
T_CHAR_LF )
|
||||
if self.FvAlignment != None:
|
||||
self.FvInfFile.writelines("EFI_FVB2_ALIGNMENT_" + \
|
||||
self.FvAlignment.strip() + \
|
||||
" = TRUE" + \
|
||||
T_CHAR_LF)
|
||||
|
||||
if self.FvNameGuid != None:
|
||||
self.FvInfFile.writelines("EFI_FVNAME_GUID" + \
|
||||
" = %s" % self.FvNameGuid + \
|
||||
T_CHAR_LF)
|
||||
#
|
||||
# Add [Files]
|
||||
#
|
||||
|
||||
self.FvInfFile.writelines("[files]" + T_CHAR_LF)
|
||||
if VtfDict != None and self.UiFvName in VtfDict.keys():
|
||||
self.FvInfFile.writelines("EFI_FILE_NAME = " + \
|
||||
VtfDict.get(self.UiFvName) + \
|
||||
T_CHAR_LF)
|
||||
|
||||
|
90
BaseTools/Source/Python/GenFds/FvImageSection.py
Normal file
90
BaseTools/Source/Python/GenFds/FvImageSection.py
Normal file
@@ -0,0 +1,90 @@
|
||||
## @file
|
||||
# process FV image section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
import StringIO
|
||||
from Ffs import Ffs
|
||||
import subprocess
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import os
|
||||
from CommonDataClass.FdfClass import FvImageSectionClassObject
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## generate FV image section
|
||||
#
|
||||
#
|
||||
class FvImageSection(FvImageSectionClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FvImageSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate FV image section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
|
||||
|
||||
OutputFileList = []
|
||||
if self.FvFileType != None:
|
||||
FileList, IsSect = Section.Section.GetFileList(FfsInf, self.FvFileType, self.FvFileExtension)
|
||||
if IsSect :
|
||||
return FileList, self.Alignment
|
||||
|
||||
Num = SecNum
|
||||
|
||||
for FileName in FileList:
|
||||
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + Num + Ffs.SectionSuffix.get("FV_IMAGE"))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
||||
#
|
||||
# Generate Fv
|
||||
#
|
||||
if self.FvName != None:
|
||||
Buffer = StringIO.StringIO('')
|
||||
Fv = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName)
|
||||
if Fv != None:
|
||||
self.Fv = Fv
|
||||
FvFileName = self.Fv.AddToBuffer(Buffer, MacroDict = Dict)
|
||||
else:
|
||||
if self.FvFileName != None:
|
||||
FvFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvFileName)
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FvImageSection Failed! %s NOT found in FDF" % self.FvName)
|
||||
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get("FV_IMAGE"))
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [FvFileName], 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE')
|
||||
OutputFileList.append(OutputFile)
|
||||
|
||||
return OutputFileList, self.Alignment
|
486
BaseTools/Source/Python/GenFds/GenFds.py
Normal file
486
BaseTools/Source/Python/GenFds/GenFds.py
Normal file
@@ -0,0 +1,486 @@
|
||||
## @file
|
||||
# generate flash image
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from optparse import OptionParser
|
||||
import sys
|
||||
import os
|
||||
import linecache
|
||||
import FdfParser
|
||||
from Common.BuildToolError import *
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from Workspace.WorkspaceDatabase import WorkspaceDatabase
|
||||
from Workspace.BuildClassObject import PcdClassObject
|
||||
from Workspace.BuildClassObject import ModuleBuildClassObject
|
||||
import RuleComplexFile
|
||||
from EfiSection import EfiSection
|
||||
import StringIO
|
||||
import Common.TargetTxtClassObject as TargetTxtClassObject
|
||||
import Common.ToolDefClassObject as ToolDefClassObject
|
||||
import Common.DataType
|
||||
import Common.GlobalData as GlobalData
|
||||
from Common import EdkLogger
|
||||
from Common.String import *
|
||||
from Common.Misc import DirCache,PathClass
|
||||
|
||||
## Version and Copyright
|
||||
versionNumber = "1.0"
|
||||
__version__ = "%prog Version " + versionNumber
|
||||
__copyright__ = "Copyright (c) 2007, Intel Corporation All rights reserved."
|
||||
|
||||
## Tool entrance method
|
||||
#
|
||||
# This method mainly dispatch specific methods per the command line options.
|
||||
# If no error found, return zero value so the caller of this tool can know
|
||||
# if it's executed successfully or not.
|
||||
#
|
||||
# @retval 0 Tool was successful
|
||||
# @retval 1 Tool failed
|
||||
#
|
||||
def main():
|
||||
global Options
|
||||
Options = myOptionParser()
|
||||
|
||||
global Workspace
|
||||
Workspace = ""
|
||||
ArchList = None
|
||||
ReturnCode = 0
|
||||
|
||||
EdkLogger.Initialize()
|
||||
try:
|
||||
if Options.verbose != None:
|
||||
EdkLogger.SetLevel(EdkLogger.VERBOSE)
|
||||
GenFdsGlobalVariable.VerboseMode = True
|
||||
|
||||
if Options.FixedAddress != None:
|
||||
GenFdsGlobalVariable.FixedLoadAddress = True
|
||||
|
||||
if Options.quiet != None:
|
||||
EdkLogger.SetLevel(EdkLogger.QUIET)
|
||||
if Options.debug != None:
|
||||
EdkLogger.SetLevel(Options.debug + 1)
|
||||
GenFdsGlobalVariable.DebugLevel = Options.debug
|
||||
else:
|
||||
EdkLogger.SetLevel(EdkLogger.INFO)
|
||||
|
||||
if (Options.Workspace == None):
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "WORKSPACE not defined",
|
||||
ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.")
|
||||
elif not os.path.exists(Options.Workspace):
|
||||
EdkLogger.error("GenFds", BuildToolError.PARAMETER_INVALID, "WORKSPACE is invalid",
|
||||
ExtraData="Please use '-w' switch to pass it or set the WORKSPACE environment variable.")
|
||||
else:
|
||||
Workspace = os.path.normcase(Options.Workspace)
|
||||
GenFdsGlobalVariable.WorkSpaceDir = Workspace
|
||||
if 'EDK_SOURCE' in os.environ.keys():
|
||||
GenFdsGlobalVariable.EdkSourceDir = os.path.normcase(os.environ['EDK_SOURCE'])
|
||||
if (Options.debug):
|
||||
GenFdsGlobalVariable.VerboseLogger( "Using Workspace:" + Workspace)
|
||||
os.chdir(GenFdsGlobalVariable.WorkSpaceDir)
|
||||
|
||||
if (Options.filename):
|
||||
FdfFilename = Options.filename
|
||||
FdfFilename = GenFdsGlobalVariable.ReplaceWorkspaceMacro(FdfFilename)
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing FDF filename")
|
||||
|
||||
if (Options.BuildTarget):
|
||||
GenFdsGlobalVariable.TargetName = Options.BuildTarget
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing build target")
|
||||
|
||||
if (Options.ToolChain):
|
||||
GenFdsGlobalVariable.ToolChainTag = Options.ToolChain
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing tool chain tag")
|
||||
|
||||
if FdfFilename[0:2] == '..':
|
||||
FdfFilename = os.path.realpath(FdfFilename)
|
||||
if FdfFilename[1] != ':':
|
||||
FdfFilename = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, FdfFilename)
|
||||
|
||||
if not os.path.exists(FdfFilename):
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=FdfFilename)
|
||||
GenFdsGlobalVariable.FdfFile = FdfFilename
|
||||
GenFdsGlobalVariable.FdfFileTimeStamp = os.path.getmtime(FdfFilename)
|
||||
|
||||
if (Options.activePlatform):
|
||||
ActivePlatform = Options.activePlatform
|
||||
ActivePlatform = GenFdsGlobalVariable.ReplaceWorkspaceMacro(ActivePlatform)
|
||||
|
||||
if ActivePlatform[0:2] == '..':
|
||||
ActivePlatform = os.path.realpath(ActivePlatform)
|
||||
|
||||
if ActivePlatform[1] != ':':
|
||||
ActivePlatform = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, ActivePlatform)
|
||||
|
||||
if not os.path.exists(ActivePlatform) :
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
|
||||
|
||||
if ActivePlatform.find(Workspace) == -1:
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist in Workspace!")
|
||||
|
||||
ActivePlatform = ActivePlatform.replace(Workspace, '')
|
||||
if len(ActivePlatform) > 0 :
|
||||
if ActivePlatform[0] == '\\' or ActivePlatform[0] == '/':
|
||||
ActivePlatform = ActivePlatform[1:]
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, "ActivePlatform doesn't exist!")
|
||||
else :
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing active platform")
|
||||
|
||||
GenFdsGlobalVariable.ActivePlatform = PathClass(NormPath(ActivePlatform), Workspace)
|
||||
|
||||
BuildConfigurationFile = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, "Conf/target.txt"))
|
||||
if os.path.isfile(BuildConfigurationFile) == True:
|
||||
TargetTxtClassObject.TargetTxtClassObject(BuildConfigurationFile)
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=BuildConfigurationFile)
|
||||
|
||||
if Options.Macros:
|
||||
for Pair in Options.Macros:
|
||||
Pair.strip('"')
|
||||
List = Pair.split('=')
|
||||
if len(List) == 2:
|
||||
FdfParser.InputMacroDict[List[0].strip()] = List[1].strip()
|
||||
if List[0].strip() == "EFI_SOURCE":
|
||||
GlobalData.gEfiSource = List[1].strip()
|
||||
elif List[0].strip() == "EDK_SOURCE":
|
||||
GlobalData.gEdkSource = List[1].strip()
|
||||
else:
|
||||
GlobalData.gEdkGlobal[List[0].strip()] = List[1].strip()
|
||||
else:
|
||||
FdfParser.InputMacroDict[List[0].strip()] = None
|
||||
|
||||
"""call Workspace build create database"""
|
||||
os.environ["WORKSPACE"] = Workspace
|
||||
BuildWorkSpace = WorkspaceDatabase(':memory:', GlobalData.gGlobalDefines)
|
||||
BuildWorkSpace.InitDatabase()
|
||||
|
||||
#
|
||||
# Get files real name in workspace dir
|
||||
#
|
||||
GlobalData.gAllFiles = DirCache(Workspace)
|
||||
GlobalData.gWorkspace = Workspace
|
||||
|
||||
if (Options.archList) :
|
||||
ArchList = Options.archList.split(',')
|
||||
else:
|
||||
# EdkLogger.error("GenFds", BuildToolError.OPTION_MISSING, "Missing build ARCH")
|
||||
ArchList = BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList
|
||||
|
||||
TargetArchList = set(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList) & set(ArchList)
|
||||
if len(TargetArchList) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Target ARCH %s not in platform supported ARCH %s" % (str(ArchList), str(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'COMMON'].SupArchList)))
|
||||
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirFromDscDict[Arch] = NormPath(BuildWorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].OutputDirectory)
|
||||
|
||||
if (Options.outputDir):
|
||||
OutputDirFromCommandLine = GenFdsGlobalVariable.ReplaceWorkspaceMacro(Options.outputDir)
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirDict[Arch] = OutputDirFromCommandLine
|
||||
else:
|
||||
for Arch in ArchList:
|
||||
GenFdsGlobalVariable.OutputDirDict[Arch] = os.path.join(GenFdsGlobalVariable.OutputDirFromDscDict[Arch], GenFdsGlobalVariable.TargetName + '_' + GenFdsGlobalVariable.ToolChainTag)
|
||||
|
||||
for Key in GenFdsGlobalVariable.OutputDirDict:
|
||||
OutputDir = GenFdsGlobalVariable.OutputDirDict[Key]
|
||||
if OutputDir[0:2] == '..':
|
||||
OutputDir = os.path.realpath(OutputDir)
|
||||
|
||||
if OutputDir[1] != ':':
|
||||
OutputDir = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, OutputDir)
|
||||
|
||||
if not os.path.exists(OutputDir):
|
||||
EdkLogger.error("GenFds", BuildToolError.FILE_NOT_FOUND, ExtraData=OutputDir)
|
||||
GenFdsGlobalVariable.OutputDirDict[Key] = OutputDir
|
||||
|
||||
""" Parse Fdf file, has to place after build Workspace as FDF may contain macros from DSC file """
|
||||
FdfParserObj = FdfParser.FdfParser(FdfFilename)
|
||||
FdfParserObj.ParseFile()
|
||||
|
||||
if FdfParserObj.CycleReferenceCheck():
|
||||
EdkLogger.error("GenFds", BuildToolError.FORMAT_NOT_SUPPORTED, "Cycle Reference Detected in FDF file")
|
||||
|
||||
if (Options.uiFdName) :
|
||||
if Options.uiFdName.upper() in FdfParserObj.Profile.FdDict.keys():
|
||||
GenFds.OnlyGenerateThisFd = Options.uiFdName
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_VALUE_INVALID,
|
||||
"No such an FD in FDF file: %s" % Options.uiFdName)
|
||||
|
||||
if (Options.uiFvName) :
|
||||
if Options.uiFvName.upper() in FdfParserObj.Profile.FvDict.keys():
|
||||
GenFds.OnlyGenerateThisFv = Options.uiFvName
|
||||
else:
|
||||
EdkLogger.error("GenFds", BuildToolError.OPTION_VALUE_INVALID,
|
||||
"No such an FV in FDF file: %s" % Options.uiFvName)
|
||||
|
||||
"""Modify images from build output if the feature of loading driver at fixed address is on."""
|
||||
if GenFdsGlobalVariable.FixedLoadAddress:
|
||||
GenFds.PreprocessImage(BuildWorkSpace, GenFdsGlobalVariable.ActivePlatform)
|
||||
"""Call GenFds"""
|
||||
GenFds.GenFd('', FdfParserObj, BuildWorkSpace, ArchList)
|
||||
|
||||
"""Display FV space info."""
|
||||
GenFds.DisplayFvSpaceInfo(FdfParserObj)
|
||||
|
||||
except FdfParser.Warning, X:
|
||||
EdkLogger.error(X.ToolName, BuildToolError.FORMAT_INVALID, File=X.FileName, Line=X.LineNumber, ExtraData=X.Message, RaiseError = False)
|
||||
ReturnCode = BuildToolError.FORMAT_INVALID
|
||||
except FatalError, X:
|
||||
if Options.debug != None:
|
||||
import traceback
|
||||
EdkLogger.quiet(traceback.format_exc())
|
||||
ReturnCode = X.args[0]
|
||||
except:
|
||||
import traceback
|
||||
EdkLogger.error(
|
||||
"\nPython",
|
||||
CODE_ERROR,
|
||||
"Tools code failure",
|
||||
ExtraData="Please submit bug report in www.TianoCore.org, attaching following call stack trace!\n",
|
||||
RaiseError=False
|
||||
)
|
||||
EdkLogger.quiet(traceback.format_exc())
|
||||
ReturnCode = CODE_ERROR
|
||||
return ReturnCode
|
||||
|
||||
gParamCheck = []
|
||||
def SingleCheckCallback(option, opt_str, value, parser):
|
||||
if option not in gParamCheck:
|
||||
setattr(parser.values, option.dest, value)
|
||||
gParamCheck.append(option)
|
||||
else:
|
||||
parser.error("Option %s only allows one instance in command line!" % option)
|
||||
|
||||
## 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
|
||||
# @retval Args Target of build command
|
||||
#
|
||||
def myOptionParser():
|
||||
usage = "%prog [options] -f input_file -a arch_list -b build_target -p active_platform -t tool_chain_tag -D \"MacroName [= MacroValue]\""
|
||||
Parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber))
|
||||
Parser.add_option("-f", "--file", dest="filename", type="string", help="Name of FDF file to convert", action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-a", "--arch", dest="archList", help="comma separated list containing one or more of: IA32, X64, IPF, ARM or EBC which should be built, overrides target.txt?s TARGET_ARCH")
|
||||
Parser.add_option("-q", "--quiet", action="store_true", type=None, help="Disable all messages except FATAL ERRORS.")
|
||||
Parser.add_option("-v", "--verbose", action="store_true", type=None, help="Turn on verbose output with informational messages printed.")
|
||||
Parser.add_option("-d", "--debug", action="store", type="int", help="Enable debug messages at specified level.")
|
||||
Parser.add_option("-p", "--platform", type="string", dest="activePlatform", help="Set the ACTIVE_PLATFORM, overrides target.txt ACTIVE_PLATFORM setting.",
|
||||
action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-w", "--workspace", type="string", dest="Workspace", default=os.environ.get('WORKSPACE'), help="Set the WORKSPACE",
|
||||
action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-o", "--outputDir", type="string", dest="outputDir", help="Name of Build Output directory",
|
||||
action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-r", "--rom_image", dest="uiFdName", help="Build the image using the [FD] section named by FdUiName.")
|
||||
Parser.add_option("-i", "--FvImage", dest="uiFvName", help="Buld the FV image using the [FV] section named by UiFvName")
|
||||
Parser.add_option("-b", "--buildtarget", type="choice", choices=['DEBUG','RELEASE'], dest="BuildTarget", help="Build TARGET is one of list: DEBUG, RELEASE.",
|
||||
action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-t", "--tagname", type="string", dest="ToolChain", help="Using the tools: TOOL_CHAIN_TAG name to build the platform.",
|
||||
action="callback", callback=SingleCheckCallback)
|
||||
Parser.add_option("-D", "--define", action="append", type="string", dest="Macros", help="Macro: \"Name [= Value]\".")
|
||||
Parser.add_option("-s", "--specifyaddress", dest="FixedAddress", action="store_true", type=None, help="Specify driver load address.")
|
||||
(Options, args) = Parser.parse_args()
|
||||
return Options
|
||||
|
||||
## The class implementing the EDK2 flash image generation process
|
||||
#
|
||||
# This process includes:
|
||||
# 1. Collect workspace information, includes platform and module information
|
||||
# 2. Call methods of Fd class to generate FD
|
||||
# 3. Call methods of Fv class to generate FV that not belong to FD
|
||||
#
|
||||
class GenFds :
|
||||
FdfParsef = None
|
||||
# FvName in FDF, FvBinFile name
|
||||
FvBinDict = {}
|
||||
OnlyGenerateThisFd = None
|
||||
OnlyGenerateThisFv = None
|
||||
|
||||
## GenFd()
|
||||
#
|
||||
# @param OutputDir Output directory
|
||||
# @param FdfParser FDF contents parser
|
||||
# @param Workspace The directory of workspace
|
||||
# @param ArchList The Arch list of platform
|
||||
#
|
||||
def GenFd (OutputDir, FdfParser, WorkSpace, ArchList):
|
||||
GenFdsGlobalVariable.SetDir ('', FdfParser, WorkSpace, ArchList)
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger(" Gen Fd !")
|
||||
if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
|
||||
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(GenFds.OnlyGenerateThisFd.upper())
|
||||
if FdObj != None:
|
||||
FdObj.GenFd(GenFds.FvBinDict)
|
||||
elif GenFds.OnlyGenerateThisFv == None:
|
||||
for FdName in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
|
||||
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[FdName]
|
||||
FdObj.GenFd(GenFds.FvBinDict)
|
||||
|
||||
GenFdsGlobalVariable.VerboseLogger(" Gen FV ! ")
|
||||
if GenFds.OnlyGenerateThisFv != None and GenFds.OnlyGenerateThisFv.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
|
||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(GenFds.OnlyGenerateThisFv.upper())
|
||||
if FvObj != None:
|
||||
Buffer = StringIO.StringIO()
|
||||
# Get FV base Address
|
||||
FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj))
|
||||
Buffer.close()
|
||||
return
|
||||
elif GenFds.OnlyGenerateThisFd == None:
|
||||
for FvName in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
|
||||
Buffer = StringIO.StringIO('')
|
||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict[FvName]
|
||||
# Get FV base Address
|
||||
FvObj.AddToBuffer(Buffer, None, GenFds.GetFvBlockSize(FvObj))
|
||||
Buffer.close()
|
||||
|
||||
if GenFds.OnlyGenerateThisFv == None and GenFds.OnlyGenerateThisFd == None:
|
||||
GenFdsGlobalVariable.VerboseLogger(" Gen Capsule !")
|
||||
for CapsuleObj in GenFdsGlobalVariable.FdfParser.Profile.CapsuleList:
|
||||
CapsuleObj.GenCapsule()
|
||||
|
||||
if GenFdsGlobalVariable.FdfParser.Profile.OptRomDict != {}:
|
||||
GenFdsGlobalVariable.VerboseLogger(" Gen Option ROM !")
|
||||
for DriverName in GenFdsGlobalVariable.FdfParser.Profile.OptRomDict.keys():
|
||||
OptRomObj = GenFdsGlobalVariable.FdfParser.Profile.OptRomDict[DriverName]
|
||||
OptRomObj.AddToBuffer(None)
|
||||
|
||||
## GetFvBlockSize()
|
||||
#
|
||||
# @param FvObj Whose block size to get
|
||||
# @retval int Block size value
|
||||
#
|
||||
def GetFvBlockSize(FvObj):
|
||||
DefaultBlockSize = 0x10000
|
||||
FdObj = None
|
||||
if GenFds.OnlyGenerateThisFd != None and GenFds.OnlyGenerateThisFd.upper() in GenFdsGlobalVariable.FdfParser.Profile.FdDict.keys():
|
||||
FdObj = GenFdsGlobalVariable.FdfParser.Profile.FdDict[GenFds.OnlyGenerateThisFd.upper()]
|
||||
if FdObj == None:
|
||||
for ElementFd in GenFdsGlobalVariable.FdfParser.Profile.FdDict.values():
|
||||
for ElementRegion in ElementFd.RegionList:
|
||||
if ElementRegion.RegionType == 'FV':
|
||||
for ElementRegionData in ElementRegion.RegionDataList:
|
||||
if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName:
|
||||
if FvObj.BlockSizeList != []:
|
||||
return FvObj.BlockSizeList[0][0]
|
||||
else:
|
||||
return ElementRegion.BlockSizeOfRegion(ElementFd.BlockSizeList)
|
||||
if FvObj.BlockSizeList != []:
|
||||
return FvObj.BlockSizeList[0][0]
|
||||
return DefaultBlockSize
|
||||
else:
|
||||
for ElementRegion in FdObj.RegionList:
|
||||
if ElementRegion.RegionType == 'FV':
|
||||
for ElementRegionData in ElementRegion.RegionDataList:
|
||||
if ElementRegionData != None and ElementRegionData.upper() == FvObj.UiFvName:
|
||||
if FvObj.BlockSizeList != []:
|
||||
return FvObj.BlockSizeList[0][0]
|
||||
else:
|
||||
return ElementRegion.BlockSizeOfRegion(ElementFd.BlockSizeList)
|
||||
return DefaultBlockSize
|
||||
|
||||
## DisplayFvSpaceInfo()
|
||||
#
|
||||
# @param FvObj Whose block size to get
|
||||
# @retval None
|
||||
#
|
||||
def DisplayFvSpaceInfo(FdfParser):
|
||||
|
||||
FvSpaceInfoList = []
|
||||
MaxFvNameLength = 0
|
||||
for FvName in FdfParser.Profile.FvDict:
|
||||
if len(FvName) > MaxFvNameLength:
|
||||
MaxFvNameLength = len(FvName)
|
||||
FvSpaceInfoFileName = os.path.join(GenFdsGlobalVariable.FvDir, FvName.upper() + '.Fv.map')
|
||||
if os.path.exists(FvSpaceInfoFileName):
|
||||
FileLinesList = linecache.getlines(FvSpaceInfoFileName)
|
||||
TotalFound = False
|
||||
Total = ''
|
||||
UsedFound = False
|
||||
Used = ''
|
||||
FreeFound = False
|
||||
Free = ''
|
||||
for Line in FileLinesList:
|
||||
NameValue = Line.split('=')
|
||||
if len(NameValue) == 2:
|
||||
if NameValue[0].strip() == 'EFI_FV_TOTAL_SIZE':
|
||||
TotalFound = True
|
||||
Total = NameValue[1].strip()
|
||||
if NameValue[0].strip() == 'EFI_FV_TAKEN_SIZE':
|
||||
UsedFound = True
|
||||
Used = NameValue[1].strip()
|
||||
if NameValue[0].strip() == 'EFI_FV_SPACE_SIZE':
|
||||
FreeFound = True
|
||||
Free = NameValue[1].strip()
|
||||
|
||||
if TotalFound and UsedFound and FreeFound:
|
||||
FvSpaceInfoList.append((FvName, Total, Used, Free))
|
||||
|
||||
GenFdsGlobalVariable.InfLogger('\nFV Space Information')
|
||||
for FvSpaceInfo in FvSpaceInfoList:
|
||||
Name = FvSpaceInfo[0]
|
||||
TotalSizeValue = long(FvSpaceInfo[1], 0)
|
||||
UsedSizeValue = long(FvSpaceInfo[2], 0)
|
||||
FreeSizeValue = long(FvSpaceInfo[3], 0)
|
||||
GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + str((UsedSizeValue+0.0)/TotalSizeValue)[0:4].lstrip('0.') + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
|
||||
|
||||
## PreprocessImage()
|
||||
#
|
||||
# @param BuildDb Database from build meta data files
|
||||
# @param DscFile modules from dsc file will be preprocessed
|
||||
# @retval None
|
||||
#
|
||||
def PreprocessImage(BuildDb, DscFile):
|
||||
PcdDict = BuildDb.BuildObject[DscFile, 'COMMON'].Pcds
|
||||
PcdValue = ''
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if PcdObj.TokenCName == 'PcdBsBaseAddress':
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
break
|
||||
|
||||
if PcdValue == '':
|
||||
return
|
||||
|
||||
Int64PcdValue = long(PcdValue, 0)
|
||||
if Int64PcdValue == 0 or Int64PcdValue < -1:
|
||||
return
|
||||
|
||||
TopAddress = 0
|
||||
if Int64PcdValue > 0:
|
||||
TopAddress = Int64PcdValue
|
||||
|
||||
ModuleDict = BuildDb.BuildObject[DscFile, 'COMMON'].Modules
|
||||
for Key in ModuleDict:
|
||||
ModuleObj = BuildDb.BuildObject[Key, 'COMMON']
|
||||
print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
|
||||
|
||||
##Define GenFd as static function
|
||||
GenFd = staticmethod(GenFd)
|
||||
GetFvBlockSize = staticmethod(GetFvBlockSize)
|
||||
DisplayFvSpaceInfo = staticmethod(DisplayFvSpaceInfo)
|
||||
PreprocessImage = staticmethod(PreprocessImage)
|
||||
|
||||
if __name__ == '__main__':
|
||||
r = main()
|
||||
## 0-127 is a safe return range, and 1 is a standard default error
|
||||
if r < 0 or r > 127: r = 1
|
||||
sys.exit(r)
|
||||
|
472
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
Normal file
472
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
Normal file
@@ -0,0 +1,472 @@
|
||||
## @file
|
||||
# Global variables for GenFds
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import struct
|
||||
import array
|
||||
|
||||
from Common.BuildToolError import *
|
||||
from Common import EdkLogger
|
||||
from Common.Misc import SaveFileOnChange
|
||||
|
||||
## Global variables
|
||||
#
|
||||
#
|
||||
class GenFdsGlobalVariable:
|
||||
FvDir = ''
|
||||
OutputDirDict = {}
|
||||
BinDir = ''
|
||||
# will be FvDir + os.sep + 'Ffs'
|
||||
FfsDir = ''
|
||||
FdfParser = None
|
||||
LibDir = ''
|
||||
WorkSpace = None
|
||||
WorkSpaceDir = ''
|
||||
EdkSourceDir = ''
|
||||
OutputDirFromDscDict = {}
|
||||
TargetName = ''
|
||||
ToolChainTag = ''
|
||||
RuleDict = {}
|
||||
ArchList = None
|
||||
VtfDict = {}
|
||||
ActivePlatform = None
|
||||
FvAddressFileName = ''
|
||||
VerboseMode = False
|
||||
DebugLevel = -1
|
||||
SharpCounter = 0
|
||||
SharpNumberPerLine = 40
|
||||
FdfFile = ''
|
||||
FdfFileTimeStamp = 0
|
||||
FixedLoadAddress = False
|
||||
|
||||
SectionHeader = struct.Struct("3B 1B")
|
||||
|
||||
## SetDir()
|
||||
#
|
||||
# @param OutputDir Output directory
|
||||
# @param FdfParser FDF contents parser
|
||||
# @param Workspace The directory of workspace
|
||||
# @param ArchList The Arch list of platform
|
||||
#
|
||||
def SetDir (OutputDir, FdfParser, WorkSpace, ArchList):
|
||||
GenFdsGlobalVariable.VerboseLogger( "GenFdsGlobalVariable.OutputDir :%s" %OutputDir)
|
||||
# GenFdsGlobalVariable.OutputDirDict = OutputDir
|
||||
GenFdsGlobalVariable.FdfParser = FdfParser
|
||||
GenFdsGlobalVariable.WorkSpace = WorkSpace
|
||||
GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OutputDirDict[ArchList[0]], 'FV')
|
||||
if not os.path.exists(GenFdsGlobalVariable.FvDir) :
|
||||
os.makedirs(GenFdsGlobalVariable.FvDir)
|
||||
GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')
|
||||
if not os.path.exists(GenFdsGlobalVariable.FfsDir) :
|
||||
os.makedirs(GenFdsGlobalVariable.FfsDir)
|
||||
if ArchList != None:
|
||||
GenFdsGlobalVariable.ArchList = ArchList
|
||||
|
||||
T_CHAR_LF = '\n'
|
||||
#
|
||||
# Create FV Address inf file
|
||||
#
|
||||
GenFdsGlobalVariable.FvAddressFileName = os.path.join(GenFdsGlobalVariable.FfsDir, 'FvAddress.inf')
|
||||
FvAddressFile = open (GenFdsGlobalVariable.FvAddressFileName, 'w')
|
||||
#
|
||||
# Add [Options]
|
||||
#
|
||||
FvAddressFile.writelines("[options]" + T_CHAR_LF)
|
||||
BsAddress = '0'
|
||||
for Arch in ArchList:
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].BsBaseAddress:
|
||||
BsAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].BsBaseAddress
|
||||
break
|
||||
|
||||
FvAddressFile.writelines("EFI_BOOT_DRIVER_BASE_ADDRESS = " + \
|
||||
BsAddress + \
|
||||
T_CHAR_LF)
|
||||
|
||||
RtAddress = '0'
|
||||
for Arch in ArchList:
|
||||
if GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].RtBaseAddress:
|
||||
RtAddress = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, Arch].RtBaseAddress
|
||||
|
||||
FvAddressFile.writelines("EFI_RUNTIME_DRIVER_BASE_ADDRESS = " + \
|
||||
RtAddress + \
|
||||
T_CHAR_LF)
|
||||
|
||||
FvAddressFile.close()
|
||||
|
||||
## ReplaceWorkspaceMacro()
|
||||
#
|
||||
# @param String String that may contain macro
|
||||
#
|
||||
def ReplaceWorkspaceMacro(String):
|
||||
Str = String.replace('$(WORKSPACE)', GenFdsGlobalVariable.WorkSpaceDir)
|
||||
if os.path.exists(Str):
|
||||
if not os.path.isabs(Str):
|
||||
Str = os.path.abspath(Str)
|
||||
else:
|
||||
Str = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, String)
|
||||
return os.path.normpath(Str)
|
||||
|
||||
## Check if the input files are newer than output files
|
||||
#
|
||||
# @param Output Path of output file
|
||||
# @param Input Path list of input files
|
||||
#
|
||||
# @retval True if Output doesn't exist, or any Input is newer
|
||||
# @retval False if all Input is older than Output
|
||||
#
|
||||
@staticmethod
|
||||
def NeedsUpdate(Output, Input):
|
||||
if not os.path.exists(Output):
|
||||
return True
|
||||
# always update "Output" if no "Input" given
|
||||
if Input == None or len(Input) == 0:
|
||||
return True
|
||||
|
||||
# if fdf file is changed after the 'Output" is generated, update the 'Output'
|
||||
OutputTime = os.path.getmtime(Output)
|
||||
if GenFdsGlobalVariable.FdfFileTimeStamp > OutputTime:
|
||||
return True
|
||||
|
||||
for F in Input:
|
||||
# always update "Output" if any "Input" doesn't exist
|
||||
if not os.path.exists(F):
|
||||
return True
|
||||
# always update "Output" if any "Input" is newer than "Output"
|
||||
if os.path.getmtime(F) > OutputTime:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def GenerateSection(Output, Input, Type=None, CompressionType=None, Guid=None,
|
||||
GuidHdrLen=None, GuidAttr=None, Ui=None, Ver=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenSec"]
|
||||
if Type not in [None, '']:
|
||||
Cmd += ["-s", Type]
|
||||
if CompressionType not in [None, '']:
|
||||
Cmd += ["-c", CompressionType]
|
||||
if Guid != None:
|
||||
Cmd += ["-g", Guid]
|
||||
if GuidHdrLen not in [None, '']:
|
||||
Cmd += ["-l", GuidHdrLen]
|
||||
if GuidAttr not in [None, '']:
|
||||
Cmd += ["-r", GuidAttr]
|
||||
|
||||
if Ui not in [None, '']:
|
||||
#Cmd += ["-n", '"' + Ui + '"']
|
||||
SectionData = array.array('B', [0,0,0,0])
|
||||
SectionData.fromstring(Ui.encode("utf_16_le"))
|
||||
SectionData.append(0)
|
||||
SectionData.append(0)
|
||||
Len = 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 += ["-j", Ver]
|
||||
SectionData = array.array('B', [0,0,0,0])
|
||||
SectionData.fromstring(Ver.encode("utf_16_le"))
|
||||
SectionData.append(0)
|
||||
SectionData.append(0)
|
||||
Len = len(SectionData)
|
||||
GenFdsGlobalVariable.SectionHeader.pack_into(SectionData, 0, Len & 0xff, (Len >> 8) & 0xff, (Len >> 16) & 0xff, 0x14)
|
||||
SaveFileOnChange(Output, SectionData.tostring())
|
||||
else:
|
||||
Cmd += ["-o", Output]
|
||||
Cmd += Input
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate section")
|
||||
|
||||
@staticmethod
|
||||
def GenerateFfs(Output, Input, Type, Guid, Fixed=False, CheckSum=False, Align=None,
|
||||
SectionAlign=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenFfs", "-t", Type, "-g", Guid]
|
||||
if Fixed == True:
|
||||
Cmd += ["-x"]
|
||||
if CheckSum:
|
||||
Cmd += ["-s"]
|
||||
if Align not in [None, '']:
|
||||
Cmd += ["-a", Align]
|
||||
|
||||
Cmd += ["-o", Output]
|
||||
for I in range(0, len(Input)):
|
||||
Cmd += ("-i", Input[I])
|
||||
if SectionAlign not in [None, '', []] and SectionAlign[I] not in [None, '']:
|
||||
Cmd += ("-n", SectionAlign[I])
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FFS")
|
||||
|
||||
@staticmethod
|
||||
def GenerateFirmwareVolume(Output, Input, BaseAddress=None, Capsule=False, Dump=False,
|
||||
AddressFile=None, MapFile=None, FfsList=[]):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input+FfsList):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenFv"]
|
||||
if BaseAddress not in [None, '']:
|
||||
Cmd += ["-r", BaseAddress]
|
||||
if Capsule:
|
||||
Cmd += ["-c"]
|
||||
if Dump:
|
||||
Cmd += ["-p"]
|
||||
if AddressFile not in [None, '']:
|
||||
Cmd += ["-a", AddressFile]
|
||||
if MapFile not in [None, '']:
|
||||
Cmd += ["-m", MapFile]
|
||||
Cmd += ["-o", Output]
|
||||
for I in Input:
|
||||
Cmd += ["-i", I]
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate FV")
|
||||
|
||||
@staticmethod
|
||||
def GenerateVtf(Output, Input, BaseAddress=None, FvSize=None):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenVtf"]
|
||||
if BaseAddress not in [None, ''] and FvSize not in [None, ''] \
|
||||
and len(BaseAddress) == len(FvSize):
|
||||
for I in range(0, len(BaseAddress)):
|
||||
Cmd += ["-r", BaseAddress[I], "-s", FvSize[I]]
|
||||
Cmd += ["-o", Output]
|
||||
for F in Input:
|
||||
Cmd += ["-f", F]
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate VTF")
|
||||
|
||||
@staticmethod
|
||||
def GenerateFirmwareImage(Output, Input, Type="efi", SubType=None, Zero=False,
|
||||
Strip=False, Replace=False, TimeStamp=None, Join=False,
|
||||
Align=None, Padding=None, Convert=False):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["GenFw"]
|
||||
if Type.lower() == "te":
|
||||
Cmd += ["-t"]
|
||||
if SubType not in [None, '']:
|
||||
Cmd += ["-e", SubType]
|
||||
if TimeStamp not in [None, '']:
|
||||
Cmd += ["-s", TimeStamp]
|
||||
if Align not in [None, '']:
|
||||
Cmd += ["-a", Align]
|
||||
if Padding not in [None, '']:
|
||||
Cmd += ["-p", Padding]
|
||||
if Zero:
|
||||
Cmd += ["-z"]
|
||||
if Strip:
|
||||
Cmd += ["-l"]
|
||||
if Replace:
|
||||
Cmd += ["-r"]
|
||||
if Join:
|
||||
Cmd += ["-j"]
|
||||
if Convert:
|
||||
Cmd += ["-m"]
|
||||
Cmd += ["-o", Output]
|
||||
Cmd += Input
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate firmware image")
|
||||
|
||||
@staticmethod
|
||||
def GenerateOptionRom(Output, EfiInput, BinaryInput, Compress=False, ClassCode=None,
|
||||
Revision=None, DeviceId=None, VendorId=None):
|
||||
# if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
# return
|
||||
# GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = ["EfiRom"]
|
||||
if len(EfiInput) > 0:
|
||||
|
||||
if Compress:
|
||||
Cmd += ["-ec"]
|
||||
else:
|
||||
Cmd += ["-e"]
|
||||
|
||||
for EfiFile in EfiInput:
|
||||
Cmd += [EfiFile]
|
||||
|
||||
if len(BinaryInput) > 0:
|
||||
Cmd += ["-b"]
|
||||
for BinFile in BinaryInput:
|
||||
Cmd += [BinFile]
|
||||
|
||||
if ClassCode != None:
|
||||
Cmd += ["-l", ClassCode]
|
||||
if Revision != None:
|
||||
Cmd += ["-r", Revision]
|
||||
if DeviceId != None:
|
||||
Cmd += ["-i", DeviceId]
|
||||
if VendorId != None:
|
||||
Cmd += ["-f", VendorId]
|
||||
|
||||
Cmd += ["-o", Output]
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to generate option rom")
|
||||
|
||||
@staticmethod
|
||||
def GuidTool(Output, Input, ToolPath, Options=''):
|
||||
if not GenFdsGlobalVariable.NeedsUpdate(Output, Input):
|
||||
return
|
||||
GenFdsGlobalVariable.DebugLogger(EdkLogger.DEBUG_5, "%s needs update because of newer %s" % (Output, Input))
|
||||
|
||||
Cmd = [ToolPath, Options]
|
||||
Cmd += ["-o", Output]
|
||||
Cmd += Input
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "Failed to call " + ToolPath)
|
||||
|
||||
def CallExternalTool (cmd, errorMess):
|
||||
|
||||
if type(cmd) not in (tuple, list):
|
||||
GenFdsGlobalVariable.ErrorLogger("ToolError! Invalid parameter type in call to CallExternalTool")
|
||||
|
||||
if GenFdsGlobalVariable.DebugLevel != -1:
|
||||
cmd += ('--debug', str(GenFdsGlobalVariable.DebugLevel))
|
||||
GenFdsGlobalVariable.InfLogger (cmd)
|
||||
|
||||
if GenFdsGlobalVariable.VerboseMode:
|
||||
cmd += ('-v',)
|
||||
GenFdsGlobalVariable.InfLogger (cmd)
|
||||
else:
|
||||
sys.stdout.write ('#')
|
||||
sys.stdout.flush()
|
||||
GenFdsGlobalVariable.SharpCounter = GenFdsGlobalVariable.SharpCounter + 1
|
||||
if GenFdsGlobalVariable.SharpCounter % GenFdsGlobalVariable.SharpNumberPerLine == 0:
|
||||
sys.stdout.write('\n')
|
||||
|
||||
try:
|
||||
PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE)
|
||||
except Exception, X:
|
||||
EdkLogger.error("GenFds", BuildToolError.COMMAND_FAILURE, ExtraData="%s: %s" % (str(X), cmd[0]))
|
||||
(out, error) = PopenObject.communicate()
|
||||
|
||||
while PopenObject.returncode == None :
|
||||
PopenObject.wait()
|
||||
if PopenObject.returncode != 0 or GenFdsGlobalVariable.VerboseMode or GenFdsGlobalVariable.DebugLevel != -1:
|
||||
GenFdsGlobalVariable.InfLogger ("Return Value = %d" %PopenObject.returncode)
|
||||
GenFdsGlobalVariable.InfLogger (out)
|
||||
GenFdsGlobalVariable.InfLogger (error)
|
||||
if PopenObject.returncode != 0:
|
||||
print "###", cmd
|
||||
EdkLogger.error("GenFds", BuildToolError.COMMAND_FAILURE, errorMess)
|
||||
|
||||
def VerboseLogger (msg):
|
||||
EdkLogger.verbose(msg)
|
||||
|
||||
def InfLogger (msg):
|
||||
EdkLogger.info(msg)
|
||||
|
||||
def ErrorLogger (msg, File = None, Line = None, ExtraData = None):
|
||||
EdkLogger.error('GenFds', BuildToolError.GENFDS_ERROR, msg, File, Line, ExtraData)
|
||||
|
||||
def DebugLogger (Level, msg):
|
||||
EdkLogger.debug(Level, msg)
|
||||
|
||||
## ReplaceWorkspaceMacro()
|
||||
#
|
||||
# @param Str String that may contain macro
|
||||
# @param MacroDict Dictionary that contains macro value pair
|
||||
#
|
||||
def MacroExtend (Str, MacroDict = {}, Arch = 'COMMON'):
|
||||
if Str == None :
|
||||
return None
|
||||
|
||||
Dict = {'$(WORKSPACE)' : GenFdsGlobalVariable.WorkSpaceDir,
|
||||
'$(EDK_SOURCE)' : GenFdsGlobalVariable.EdkSourceDir,
|
||||
# '$(OUTPUT_DIRECTORY)': GenFdsGlobalVariable.OutputDirFromDsc,
|
||||
'$(TARGET)' : GenFdsGlobalVariable.TargetName,
|
||||
'$(TOOL_CHAIN_TAG)' : GenFdsGlobalVariable.ToolChainTag
|
||||
}
|
||||
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[GenFdsGlobalVariable.ArchList[0]]
|
||||
if Arch != 'COMMON' and Arch in GenFdsGlobalVariable.ArchList:
|
||||
OutputDir = GenFdsGlobalVariable.OutputDirFromDscDict[Arch]
|
||||
|
||||
Dict['$(OUTPUT_DIRECTORY)'] = OutputDir
|
||||
|
||||
if MacroDict != None and len (MacroDict) != 0:
|
||||
Dict.update(MacroDict)
|
||||
|
||||
for key in Dict.keys():
|
||||
if Str.find(key) >= 0 :
|
||||
Str = Str.replace (key, Dict[key])
|
||||
|
||||
if Str.find('$(ARCH)') >= 0:
|
||||
if len(GenFdsGlobalVariable.ArchList) == 1:
|
||||
Str = Str.replace('$(ARCH)', GenFdsGlobalVariable.ArchList[0])
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "No way to determine $(ARCH) for %s" % Str)
|
||||
|
||||
return Str
|
||||
|
||||
## GetPcdValue()
|
||||
#
|
||||
# @param PcdPattern pattern that labels a PCD.
|
||||
#
|
||||
def GetPcdValue (PcdPattern):
|
||||
if PcdPattern == None :
|
||||
return None
|
||||
PcdPair = PcdPattern.lstrip('PCD(').rstrip(')').strip().split('.')
|
||||
TokenSpace = PcdPair[0]
|
||||
TokenCName = PcdPair[1]
|
||||
|
||||
PcdValue = ''
|
||||
for Platform in GenFdsGlobalVariable.WorkSpace.PlatformList:
|
||||
PcdDict = Platform.Pcds
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
|
||||
if PcdObj.Type != 'FixedAtBuild':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
|
||||
if PcdObj.DatumType != 'VOID*':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
|
||||
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
return PcdValue
|
||||
|
||||
for Package in GenFdsGlobalVariable.WorkSpace.PackageList:
|
||||
PcdDict = Package.Pcds
|
||||
for Key in PcdDict:
|
||||
PcdObj = PcdDict[Key]
|
||||
if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace):
|
||||
if PcdObj.Type != 'FixedAtBuild':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern)
|
||||
if PcdObj.DatumType != 'VOID*':
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern)
|
||||
|
||||
PcdValue = PcdObj.DefaultValue
|
||||
return PcdValue
|
||||
|
||||
return PcdValue
|
||||
|
||||
SetDir = staticmethod(SetDir)
|
||||
ReplaceWorkspaceMacro = staticmethod(ReplaceWorkspaceMacro)
|
||||
CallExternalTool = staticmethod(CallExternalTool)
|
||||
VerboseLogger = staticmethod(VerboseLogger)
|
||||
InfLogger = staticmethod(InfLogger)
|
||||
ErrorLogger = staticmethod(ErrorLogger)
|
||||
DebugLogger = staticmethod(DebugLogger)
|
||||
MacroExtend = staticmethod (MacroExtend)
|
||||
GetPcdValue = staticmethod(GetPcdValue)
|
190
BaseTools/Source/Python/GenFds/GuidSection.py
Normal file
190
BaseTools/Source/Python/GenFds/GuidSection.py
Normal file
@@ -0,0 +1,190 @@
|
||||
## @file
|
||||
# process GUIDed section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
import subprocess
|
||||
from Ffs import Ffs
|
||||
import os
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import GuidSectionClassObject
|
||||
from Common import ToolDefClassObject
|
||||
import sys
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## generate GUIDed section
|
||||
#
|
||||
#
|
||||
class GuidSection(GuidSectionClassObject) :
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
GuidSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate GUIDed section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
|
||||
#
|
||||
# Generate all section
|
||||
#
|
||||
self.KeyStringList = KeyStringList
|
||||
self.CurrentArchList = GenFdsGlobalVariable.ArchList
|
||||
if FfsInf != None:
|
||||
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
|
||||
self.NameGuid = FfsInf.__ExtendMacro__(self.NameGuid)
|
||||
self.SectionType = FfsInf.__ExtendMacro__(self.SectionType)
|
||||
self.CurrentArchList = [FfsInf.CurrentArch]
|
||||
|
||||
SectFile = tuple()
|
||||
Index = 0
|
||||
for Sect in self.SectionList:
|
||||
Index = Index + 1
|
||||
SecIndex = '%s.%d' %(SecNum,Index)
|
||||
ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf, Dict)
|
||||
if ReturnSectList != []:
|
||||
for file in ReturnSectList:
|
||||
SectFile += (file,)
|
||||
|
||||
|
||||
OutputFile = OutputPath + \
|
||||
os.sep + \
|
||||
ModuleName + \
|
||||
'SEC' + \
|
||||
SecNum + \
|
||||
Ffs.SectionSuffix['GUIDED']
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
|
||||
ExternalTool = None
|
||||
if self.NameGuid != None:
|
||||
ExternalTool = self.__FindExtendTool__()
|
||||
#
|
||||
# If not have GUID , call default
|
||||
# GENCRC32 section
|
||||
#
|
||||
if self.NameGuid == None :
|
||||
GenFdsGlobalVariable.VerboseLogger( "Use GenSection function Generate CRC32 Section")
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType])
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
||||
#or GUID not in External Tool List
|
||||
elif ExternalTool == None:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % self.NameGuid)
|
||||
else:
|
||||
#
|
||||
# Call GenSection with DUMMY section type.
|
||||
#
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile+".dummy", SectFile)
|
||||
#
|
||||
# Use external tool process the Output
|
||||
#
|
||||
InputFile = OutputFile+".dummy"
|
||||
TempFile = OutputPath + \
|
||||
os.sep + \
|
||||
ModuleName + \
|
||||
'SEC' + \
|
||||
SecNum + \
|
||||
'.tmp'
|
||||
TempFile = os.path.normpath(TempFile)
|
||||
|
||||
ExternalToolCmd = (
|
||||
ExternalTool,
|
||||
'-e',
|
||||
'-o', TempFile,
|
||||
InputFile,
|
||||
)
|
||||
|
||||
#
|
||||
# Call external tool
|
||||
#
|
||||
GenFdsGlobalVariable.GuidTool(TempFile, [InputFile], ExternalTool, '-e')
|
||||
|
||||
#
|
||||
# Call Gensection Add Secntion Header
|
||||
#
|
||||
Attribute = None
|
||||
if self.ProcessRequired == True:
|
||||
Attribute = 'PROCSSING_REQUIRED'
|
||||
if self.AuthStatusValid == True:
|
||||
Attribute = 'AUTH_STATUS_VALID'
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],
|
||||
Guid=self.NameGuid, GuidAttr=Attribute)
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
||||
|
||||
## __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 == None or self.KeyStringList == []:
|
||||
Target = GenFdsGlobalVariable.TargetName
|
||||
ToolChain = GenFdsGlobalVariable.ToolChainTag
|
||||
ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDatabase
|
||||
if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)
|
||||
self.KeyStringList = [Target+'_'+ToolChain+'_'+self.CurrentArchList[0]]
|
||||
for Arch in self.CurrentArchList:
|
||||
if Target+'_'+ToolChain+'_'+Arch not in self.KeyStringList:
|
||||
self.KeyStringList.append(Target+'_'+ToolChain+'_'+Arch)
|
||||
|
||||
ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDictionary
|
||||
ToolPathTmp = None
|
||||
for ToolDef in ToolDefinition.items():
|
||||
if self.NameGuid == ToolDef[1]:
|
||||
KeyList = ToolDef[0].split('_')
|
||||
Key = KeyList[0] + \
|
||||
'_' + \
|
||||
KeyList[1] + \
|
||||
'_' + \
|
||||
KeyList[2]
|
||||
if Key in self.KeyStringList and KeyList[4] == 'GUID':
|
||||
|
||||
ToolPath = ToolDefinition.get( Key + \
|
||||
'_' + \
|
||||
KeyList[3] + \
|
||||
'_' + \
|
||||
'PATH')
|
||||
if ToolPathTmp == None:
|
||||
ToolPathTmp = ToolPath
|
||||
else:
|
||||
if ToolPathTmp != ToolPath:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))
|
||||
|
||||
|
||||
return ToolPathTmp
|
||||
|
||||
|
||||
|
50
BaseTools/Source/Python/GenFds/OptRomFileStatement.py
Normal file
50
BaseTools/Source/Python/GenFds/OptRomFileStatement.py
Normal file
@@ -0,0 +1,50 @@
|
||||
## @file
|
||||
# process OptionROM generation from FILE statement
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
##
|
||||
#
|
||||
#
|
||||
class OptRomFileStatement:
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
self.FileName = None
|
||||
self.FileType = None
|
||||
self.OverrideAttribs = None
|
||||
|
||||
## GenFfs() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Dict dictionary contains macro and value pair
|
||||
# @retval string Generated FFS file name
|
||||
#
|
||||
def GenFfs(self, Dict = {}):
|
||||
|
||||
if self.FileName != None:
|
||||
self.FileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
|
||||
return self.FileName
|
||||
|
||||
|
||||
|
147
BaseTools/Source/Python/GenFds/OptRomInfStatement.py
Normal file
147
BaseTools/Source/Python/GenFds/OptRomInfStatement.py
Normal file
@@ -0,0 +1,147 @@
|
||||
## @file
|
||||
# process OptionROM generation from INF statement
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import RuleSimpleFile
|
||||
import RuleComplexFile
|
||||
import Section
|
||||
import OptionRom
|
||||
import Common.GlobalData as GlobalData
|
||||
|
||||
from Common.DataType import *
|
||||
from Common.String import *
|
||||
from FfsInfStatement import FfsInfStatement
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
|
||||
##
|
||||
#
|
||||
#
|
||||
class OptRomInfStatement (FfsInfStatement):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
FfsInfStatement.__init__(self)
|
||||
self.OverrideAttribs = None
|
||||
|
||||
## __GetOptRomParams() method
|
||||
#
|
||||
# Parse inf file to get option ROM related parameters
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __GetOptRomParams(self):
|
||||
|
||||
if self.OverrideAttribs == None:
|
||||
self.OverrideAttribs = OptionRom.OverrideAttribs()
|
||||
|
||||
if self.OverrideAttribs.PciVendorId == None:
|
||||
self.OverrideAttribs.PciVendorId = self.OptRomDefs.get ('PCI_VENDOR_ID')
|
||||
|
||||
if self.OverrideAttribs.PciClassCode == None:
|
||||
self.OverrideAttribs.PciClassCode = self.OptRomDefs.get ('PCI_CLASS_CODE')
|
||||
|
||||
if self.OverrideAttribs.PciDeviceId == None:
|
||||
self.OverrideAttribs.PciDeviceId = self.OptRomDefs.get ('PCI_DEVICE_ID')
|
||||
|
||||
if self.OverrideAttribs.PciRevision == None:
|
||||
self.OverrideAttribs.PciRevision = self.OptRomDefs.get ('PCI_REVISION')
|
||||
|
||||
# InfObj = GenFdsGlobalVariable.WorkSpace.BuildObject[self.PathClassObj, self.CurrentArch]
|
||||
# RecordList = InfObj._RawData[MODEL_META_DATA_HEADER, InfObj._Arch, InfObj._Platform]
|
||||
# for Record in RecordList:
|
||||
# Record = ReplaceMacros(Record, GlobalData.gEdkGlobal, False)
|
||||
# Name = Record[0]
|
||||
## GenFfs() method
|
||||
#
|
||||
# Generate FFS
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @retval string Generated .efi file name
|
||||
#
|
||||
def GenFfs(self):
|
||||
#
|
||||
# Parse Inf file get Module related information
|
||||
#
|
||||
|
||||
self.__InfParse__()
|
||||
self.__GetOptRomParams()
|
||||
#
|
||||
# Get the rule of how to generate Ffs file
|
||||
#
|
||||
Rule = self.__GetRule__()
|
||||
GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
|
||||
#FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]
|
||||
#
|
||||
# For the rule only has simpleFile
|
||||
#
|
||||
if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :
|
||||
EfiOutputList = self.__GenSimpleFileSection__(Rule)
|
||||
return EfiOutputList
|
||||
#
|
||||
# For Rule has ComplexFile
|
||||
#
|
||||
elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
|
||||
EfiOutputList = self.__GenComplexFileSection__(Rule)
|
||||
return EfiOutputList
|
||||
|
||||
## __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):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
|
||||
OutputFileList = []
|
||||
if Rule.FileName != None:
|
||||
GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
|
||||
OutputFileList.append(GenSecInputFile)
|
||||
else:
|
||||
OutputFileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
|
||||
|
||||
return OutputFileList
|
||||
|
||||
|
||||
## __GenComplexFileSection__() method
|
||||
#
|
||||
# Get .efi by sections in complex 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 __GenComplexFileSection__(self, Rule):
|
||||
|
||||
OutputFileList = []
|
||||
for Sect in Rule.SectionList:
|
||||
if Sect.SectionType == 'PE32':
|
||||
if Sect.FileName != None:
|
||||
GenSecInputFile = self.__ExtendMacro__(Sect.FileName)
|
||||
OutputFileList.append(GenSecInputFile)
|
||||
else:
|
||||
FileList, IsSect = Section.Section.GetFileList(self, '', Sect.FileExtension)
|
||||
OutputFileList.extend(FileList)
|
||||
|
||||
return OutputFileList
|
||||
|
||||
|
140
BaseTools/Source/Python/GenFds/OptionRom.py
Normal file
140
BaseTools/Source/Python/GenFds/OptionRom.py
Normal file
@@ -0,0 +1,140 @@
|
||||
## @file
|
||||
# process OptionROM generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import StringIO
|
||||
|
||||
import OptRomInfStatement
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from GenFds import GenFds
|
||||
from CommonDataClass.FdfClass import OptionRomClassObject
|
||||
from Common.Misc import SaveFileOnChange
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
T_CHAR_LF = '\n'
|
||||
|
||||
##
|
||||
#
|
||||
#
|
||||
class OPTIONROM (OptionRomClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
OptionRomClassObject.__init__(self)
|
||||
|
||||
|
||||
## AddToBuffer()
|
||||
#
|
||||
# Generate Option ROM
|
||||
#
|
||||
# @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)
|
||||
|
||||
EfiFileList = []
|
||||
BinFileList = []
|
||||
|
||||
# Process Modules in FfsList
|
||||
for FfsFile in self.FfsList :
|
||||
|
||||
if isinstance(FfsFile, OptRomInfStatement.OptRomInfStatement):
|
||||
FilePathNameList = FfsFile.GenFfs()
|
||||
if len(FilePathNameList) == 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s not produce .efi files, so NO file could be put into option ROM." % (FfsFile.InfFileName))
|
||||
if FfsFile.OverrideAttribs == None:
|
||||
EfiFileList.extend(FilePathNameList)
|
||||
else:
|
||||
FileName = os.path.basename(FilePathNameList[0])
|
||||
TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)
|
||||
if not os.path.exists(TmpOutputDir) :
|
||||
os.makedirs(TmpOutputDir)
|
||||
TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')
|
||||
|
||||
GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,
|
||||
FilePathNameList,
|
||||
[],
|
||||
FfsFile.OverrideAttribs.NeedCompress,
|
||||
FfsFile.OverrideAttribs.PciClassCode,
|
||||
FfsFile.OverrideAttribs.PciRevision,
|
||||
FfsFile.OverrideAttribs.PciDeviceId,
|
||||
FfsFile.OverrideAttribs.PciVendorId)
|
||||
BinFileList.append(TmpOutputFile)
|
||||
else:
|
||||
FilePathName = FfsFile.GenFfs()
|
||||
if FfsFile.OverrideAttribs != None:
|
||||
FileName = os.path.basename(FilePathName)
|
||||
TmpOutputDir = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)
|
||||
if not os.path.exists(TmpOutputDir) :
|
||||
os.makedirs(TmpOutputDir)
|
||||
TmpOutputFile = os.path.join(TmpOutputDir, FileName+'.tmp')
|
||||
|
||||
GenFdsGlobalVariable.GenerateOptionRom(TmpOutputFile,
|
||||
[FilePathName],
|
||||
[],
|
||||
FfsFile.OverrideAttribs.NeedCompress,
|
||||
FfsFile.OverrideAttribs.PciClassCode,
|
||||
FfsFile.OverrideAttribs.PciRevision,
|
||||
FfsFile.OverrideAttribs.PciDeviceId,
|
||||
FfsFile.OverrideAttribs.PciVendorId)
|
||||
BinFileList.append(TmpOutputFile)
|
||||
else:
|
||||
if FfsFile.FileType == 'EFI':
|
||||
EfiFileList.append(FilePathName)
|
||||
else:
|
||||
BinFileList.append(FilePathName)
|
||||
|
||||
#
|
||||
# Call EfiRom tool
|
||||
#
|
||||
OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.DriverName)
|
||||
OutputFile = OutputFile + '.rom'
|
||||
|
||||
GenFdsGlobalVariable.GenerateOptionRom(
|
||||
OutputFile,
|
||||
EfiFileList,
|
||||
BinFileList
|
||||
)
|
||||
|
||||
GenFdsGlobalVariable.InfLogger( "\nGenerate %s Option ROM Successfully" %self.DriverName)
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
return OutputFile
|
||||
|
||||
class OverrideAttribs:
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
|
||||
self.PciVendorId = None
|
||||
self.PciClassCode = None
|
||||
self.PciDeviceId = None
|
||||
self.PciRevision = None
|
||||
self.NeedCompress = False
|
||||
|
||||
|
240
BaseTools/Source/Python/GenFds/Region.py
Normal file
240
BaseTools/Source/Python/GenFds/Region.py
Normal file
@@ -0,0 +1,240 @@
|
||||
## @file
|
||||
# process FD Region generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from struct import *
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import StringIO
|
||||
from CommonDataClass.FdfClass import RegionClassObject
|
||||
import os
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
|
||||
## generate Region
|
||||
#
|
||||
#
|
||||
class Region(RegionClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
RegionClassObject.__init__(self)
|
||||
|
||||
|
||||
## AddToBuffer()
|
||||
#
|
||||
# Add region data to the Buffer
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param Buffer The buffer generated region data will be put
|
||||
# @param BaseAddress base address of region
|
||||
# @param BlockSize block size of region
|
||||
# @param BlockNum How many blocks in region
|
||||
# @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, BlockSizeList, ErasePolarity, FvBinDict, vtfDict = None, MacroDict = {}):
|
||||
Size = self.Size
|
||||
GenFdsGlobalVariable.InfLogger('Generate Region at Offset 0x%X' % self.Offset)
|
||||
GenFdsGlobalVariable.InfLogger(" Region Size = 0x%X" %Size)
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
if self.RegionType == 'FV':
|
||||
#
|
||||
# Get Fv from FvDict
|
||||
#
|
||||
FvBuffer = StringIO.StringIO('')
|
||||
RegionBlockSize = self.BlockSizeOfRegion(BlockSizeList)
|
||||
RegionBlockNum = self.BlockNumOfRegion(RegionBlockSize)
|
||||
|
||||
self.FvAddress = int(BaseAddress, 16) + self.Offset
|
||||
FvBaseAddress = '0x%X' %self.FvAddress
|
||||
|
||||
for RegionData in self.RegionDataList:
|
||||
|
||||
if RegionData.endswith(".fv"):
|
||||
RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict)
|
||||
GenFdsGlobalVariable.InfLogger(' Region FV File Name = .fv : %s'%RegionData)
|
||||
if RegionData[1] != ':' :
|
||||
RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData)
|
||||
if not os.path.exists(RegionData):
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
|
||||
|
||||
BinFile = open (RegionData, 'r+b')
|
||||
FvBuffer.write(BinFile.read())
|
||||
if FvBuffer.len > Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"Size of FV File (%s) is larger than Region Size 0x%X specified." \
|
||||
% (RegionData, Size))
|
||||
break
|
||||
|
||||
if RegionData.upper() in FvBinDict.keys():
|
||||
continue
|
||||
|
||||
FvObj = None
|
||||
if RegionData.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
|
||||
FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(RegionData.upper())
|
||||
|
||||
if FvObj != None :
|
||||
GenFdsGlobalVariable.InfLogger(' Region Name = FV')
|
||||
#
|
||||
# Call GenFv tool
|
||||
#
|
||||
BlockSize = RegionBlockSize
|
||||
BlockNum = RegionBlockNum
|
||||
if FvObj.BlockSizeList != []:
|
||||
if FvObj.BlockSizeList[0][0] != None:
|
||||
BlockSize = FvObj.BlockSizeList[0][0]
|
||||
if FvObj.BlockSizeList[0][1] != None:
|
||||
BlockNum = FvObj.BlockSizeList[0][1]
|
||||
self.FvAddress = self.FvAddress + FvBuffer.len
|
||||
FvAlignValue = self.GetFvAlignValue(FvObj.FvAlignment)
|
||||
if self.FvAddress % FvAlignValue != 0:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"FV (%s) is NOT %s Aligned!" % (FvObj.UiFvName, FvObj.FvAlignment))
|
||||
FvBaseAddress = '0x%X' %self.FvAddress
|
||||
FileName = FvObj.AddToBuffer(FvBuffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict)
|
||||
|
||||
if FvBuffer.len > Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"Size of FV (%s) is larger than Region Size 0x%X specified." % (RegionData, Size))
|
||||
else:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (RegionData))
|
||||
|
||||
|
||||
if FvBuffer.len > 0:
|
||||
Buffer.write(FvBuffer.getvalue())
|
||||
else:
|
||||
BinFile = open (FileName, 'rb')
|
||||
Buffer.write(BinFile.read())
|
||||
|
||||
FvBuffer.close()
|
||||
|
||||
if self.RegionType == 'FILE':
|
||||
FvBuffer = StringIO.StringIO('')
|
||||
for RegionData in self.RegionDataList:
|
||||
RegionData = GenFdsGlobalVariable.MacroExtend(RegionData, MacroDict)
|
||||
GenFdsGlobalVariable.InfLogger(' Region File Name = FILE: %s'%RegionData)
|
||||
if RegionData[1] != ':' :
|
||||
RegionData = os.path.join (GenFdsGlobalVariable.WorkSpaceDir, RegionData)
|
||||
if not os.path.exists(RegionData):
|
||||
EdkLogger.error("GenFds", FILE_NOT_FOUND, ExtraData=RegionData)
|
||||
|
||||
BinFile = open (RegionData, 'r+b')
|
||||
FvBuffer.write(BinFile.read())
|
||||
if FvBuffer.len > Size :
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"Size of File (%s) large than Region Size " % RegionData)
|
||||
|
||||
#
|
||||
# If File contents less than region size, append "0xff" after it
|
||||
#
|
||||
if FvBuffer.len < Size:
|
||||
for index in range(0, (Size-FvBuffer.len)):
|
||||
if (ErasePolarity == '1'):
|
||||
FvBuffer.write(pack('B', int('0xFF', 16)))
|
||||
else:
|
||||
FvBuffer.write(pack('B', int('0x00', 16)))
|
||||
Buffer.write(FvBuffer.getvalue())
|
||||
FvBuffer.close()
|
||||
|
||||
if self.RegionType == 'DATA' :
|
||||
GenFdsGlobalVariable.InfLogger(' Region Name = DATA')
|
||||
DataSize = 0
|
||||
for RegionData in self.RegionDataList:
|
||||
Data = RegionData.split(',')
|
||||
DataSize = DataSize + len(Data)
|
||||
if DataSize > Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Size of DATA is larger than Region Size ")
|
||||
else:
|
||||
for item in Data :
|
||||
Buffer.write(pack('B', int(item, 16)))
|
||||
if DataSize < Size:
|
||||
if (ErasePolarity == '1'):
|
||||
PadData = 0xFF
|
||||
else:
|
||||
PadData = 0
|
||||
for i in range(Size - DataSize):
|
||||
Buffer.write(pack('B', PadData))
|
||||
|
||||
if self.RegionType == None:
|
||||
GenFdsGlobalVariable.InfLogger(' Region Name = None')
|
||||
if (ErasePolarity == '1') :
|
||||
PadData = 0xFF
|
||||
else :
|
||||
PadData = 0
|
||||
for i in range(0, Size):
|
||||
Buffer.write(pack('B', PadData))
|
||||
|
||||
def GetFvAlignValue(self, Str):
|
||||
AlignValue = 1
|
||||
Granu = 1
|
||||
Str = Str.strip().upper()
|
||||
if Str.endswith('K'):
|
||||
Granu = 1024
|
||||
Str = Str[:-1]
|
||||
elif Str.endswith('M'):
|
||||
Granu = 1024*1024
|
||||
Str = Str[:-1]
|
||||
elif Str.endswith('G'):
|
||||
Granu = 1024*1024*1024
|
||||
Str = Str[:-1]
|
||||
else:
|
||||
pass
|
||||
|
||||
AlignValue = int(Str)*Granu
|
||||
return AlignValue
|
||||
## BlockSizeOfRegion()
|
||||
#
|
||||
# @param BlockSizeList List of block information
|
||||
# @retval int Block size of region
|
||||
#
|
||||
def BlockSizeOfRegion(self, BlockSizeList):
|
||||
Offset = 0x00
|
||||
BlockSize = 0
|
||||
for item in BlockSizeList:
|
||||
Offset = Offset + item[0] * item[1]
|
||||
GenFdsGlobalVariable.VerboseLogger ("Offset = 0x%X" %Offset)
|
||||
GenFdsGlobalVariable.VerboseLogger ("self.Offset 0x%X" %self.Offset)
|
||||
|
||||
if self.Offset < Offset :
|
||||
if Offset - self.Offset < self.Size:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR,
|
||||
"Region at Offset 0x%X can NOT fit into Block array with BlockSize %X" \
|
||||
% (self.Offset, item[0]))
|
||||
BlockSize = item[0]
|
||||
GenFdsGlobalVariable.VerboseLogger ("BlockSize = %X" %BlockSize)
|
||||
return BlockSize
|
||||
return BlockSize
|
||||
|
||||
## BlockNumOfRegion()
|
||||
#
|
||||
# @param BlockSize block size of region
|
||||
# @retval int Block number of region
|
||||
#
|
||||
def BlockNumOfRegion (self, BlockSize):
|
||||
if BlockSize == 0 :
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, "Region: %s is not in the FD address scope!" % self.Offset)
|
||||
BlockNum = self.Size / BlockSize
|
||||
GenFdsGlobalVariable.VerboseLogger ("BlockNum = 0x%X" %BlockNum)
|
||||
return BlockNum
|
||||
|
29
BaseTools/Source/Python/GenFds/Rule.py
Normal file
29
BaseTools/Source/Python/GenFds/Rule.py
Normal file
@@ -0,0 +1,29 @@
|
||||
## @file
|
||||
# Rule object for generating FFS
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from CommonDataClass.FdfClass import RuleClassObject
|
||||
|
||||
## Rule base class
|
||||
#
|
||||
#
|
||||
class Rule(RuleClassObject):
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
RuleClassObject.__init__(self)
|
30
BaseTools/Source/Python/GenFds/RuleComplexFile.py
Normal file
30
BaseTools/Source/Python/GenFds/RuleComplexFile.py
Normal file
@@ -0,0 +1,30 @@
|
||||
## @file
|
||||
# Complex Rule object for generating FFS
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Rule
|
||||
from CommonDataClass.FdfClass import RuleComplexFileClassObject
|
||||
|
||||
## complex rule
|
||||
#
|
||||
#
|
||||
class RuleComplexFile(RuleComplexFileClassObject) :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
RuleComplexFileClassObject.__init__(self)
|
30
BaseTools/Source/Python/GenFds/RuleSimpleFile.py
Normal file
30
BaseTools/Source/Python/GenFds/RuleSimpleFile.py
Normal file
@@ -0,0 +1,30 @@
|
||||
## @file
|
||||
# Simple Rule object for generating FFS
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Rule
|
||||
from CommonDataClass.FdfClass import RuleSimpleFileClassObject
|
||||
|
||||
## simple rule
|
||||
#
|
||||
#
|
||||
class RuleSimpleFile (RuleSimpleFileClassObject) :
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
RuleSimpleFileClassObject.__init__(self)
|
153
BaseTools/Source/Python/GenFds/Section.py
Normal file
153
BaseTools/Source/Python/GenFds/Section.py
Normal file
@@ -0,0 +1,153 @@
|
||||
## @file
|
||||
# section base class
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from CommonDataClass.FdfClass import SectionClassObject
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import os, glob
|
||||
from Common import EdkLogger
|
||||
from Common.BuildToolError import *
|
||||
|
||||
## section base class
|
||||
#
|
||||
#
|
||||
class Section (SectionClassObject):
|
||||
SectionType = {
|
||||
'RAW' : 'EFI_SECTION_RAW',
|
||||
'FREEFORM' : 'EFI_SECTION_FREEFORM_SUBTYPE_GUID',
|
||||
'PE32' : 'EFI_SECTION_PE32',
|
||||
'PIC' : 'EFI_SECTION_PIC',
|
||||
'TE' : 'EFI_SECTION_TE',
|
||||
'FV_IMAGE' : 'EFI_SECTION_FIRMWARE_VOLUME_IMAGE',
|
||||
'DXE_DEPEX' : 'EFI_SECTION_DXE_DEPEX',
|
||||
'PEI_DEPEX' : 'EFI_SECTION_PEI_DEPEX',
|
||||
'GUIDED' : 'EFI_SECTION_GUID_DEFINED',
|
||||
'COMPRESS' : 'EFI_SECTION_COMPRESSION',
|
||||
'UI' : 'EFI_SECTION_USER_INTERFACE',
|
||||
'SMM_DEPEX' : 'EFI_SECTION_SMM_DEPEX'
|
||||
}
|
||||
|
||||
BinFileType = {
|
||||
'GUID' : '.guid',
|
||||
'ACPI' : '.acpi',
|
||||
'ASL' : '.asl' ,
|
||||
'UEFI_APP' : '.app',
|
||||
'LIB' : '.lib',
|
||||
'PE32' : '.pe32',
|
||||
'PIC' : '.pic',
|
||||
'PEI_DEPEX' : '.depex',
|
||||
'SEC_PEI_DEPEX' : '.depex',
|
||||
'TE' : '.te',
|
||||
'UNI_VER' : '.ver',
|
||||
'VER' : '.ver',
|
||||
'UNI_UI' : '.ui',
|
||||
'UI' : '.ui',
|
||||
'BIN' : '.bin',
|
||||
'RAW' : '.raw',
|
||||
'COMPAT16' : '.comp16',
|
||||
'FV' : '.fv'
|
||||
}
|
||||
|
||||
SectFileType = {
|
||||
'SEC_GUID' : '.sec' ,
|
||||
'SEC_PE32' : '.sec' ,
|
||||
'SEC_PIC' : '.sec',
|
||||
'SEC_TE' : '.sec',
|
||||
'SEC_VER' : '.sec',
|
||||
'SEC_UI' : '.sec',
|
||||
'SEC_COMPAT16' : '.sec',
|
||||
'SEC_BIN' : '.sec'
|
||||
}
|
||||
|
||||
ToolGuid = {
|
||||
'0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779' : 'TianoCompress',
|
||||
'0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf' : 'LzmaCompress'
|
||||
}
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
SectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# virtual function
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
#
|
||||
def GenSection(self, OutputPath, GuidName, SecNum, keyStringList, FfsInf = None, Dict = {}):
|
||||
pass
|
||||
|
||||
## GetFileList() method
|
||||
#
|
||||
# Generate compressed section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param FfsInf FfsInfStatement object that contains file list
|
||||
# @param FileType File type to get
|
||||
# @param FileExtension File extension to get
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (File list, boolean)
|
||||
#
|
||||
def GetFileList(FfsInf, FileType, FileExtension, Dict = {}):
|
||||
if FileType in Section.SectFileType.keys() :
|
||||
IsSect = True
|
||||
else :
|
||||
IsSect = False
|
||||
|
||||
if FileExtension != None:
|
||||
Suffix = FileExtension
|
||||
elif IsSect :
|
||||
Suffix = Section.SectionType.get(FileType)
|
||||
else:
|
||||
Suffix = Section.BinFileType.get(FileType)
|
||||
if FfsInf == None:
|
||||
EdkLogger.error("GenFds", GENFDS_ERROR, 'Inf File does not exist!')
|
||||
|
||||
FileList = []
|
||||
if FileType != None:
|
||||
for File in FfsInf.BinFileList:
|
||||
if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
|
||||
if File.Type == FileType:
|
||||
if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
|
||||
FileList.append(File.Path)
|
||||
else:
|
||||
GenFdsGlobalVariable.InfLogger ("\nBuild Target \'%s\' of File %s is not in the Scope of %s specified by INF %s in FDF" %(File.Target, File.File, FfsInf.TargetOverrideList, FfsInf.InfFileName))
|
||||
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 FDF" %(FfsInf.CurrentArch, File.File, File.Arch, FfsInf.InfFileName))
|
||||
|
||||
if Suffix != None and os.path.exists(FfsInf.EfiOutputPath):
|
||||
# FileList.extend(glob.glob(os.path.join(FfsInf.EfiOutputPath, "*" + Suffix)))
|
||||
# Update to search files with suffix in all sub-dirs.
|
||||
Tuple = os.walk(FfsInf.EfiOutputPath)
|
||||
for Dirpath, Dirnames, Filenames in Tuple:
|
||||
for F in Filenames:
|
||||
if os.path.splitext(F)[1] in (Suffix):
|
||||
FullName = os.path.join(Dirpath, F)
|
||||
FileList.append(FullName)
|
||||
|
||||
return FileList, IsSect
|
||||
GetFileList = staticmethod(GetFileList)
|
77
BaseTools/Source/Python/GenFds/UiSection.py
Normal file
77
BaseTools/Source/Python/GenFds/UiSection.py
Normal file
@@ -0,0 +1,77 @@
|
||||
## @file
|
||||
# process UI section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
import Section
|
||||
from Ffs import Ffs
|
||||
import subprocess
|
||||
import os
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import UiSectionClassObject
|
||||
|
||||
## generate UI section
|
||||
#
|
||||
#
|
||||
class UiSection (UiSectionClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
UiSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate UI section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
if FfsInf != None:
|
||||
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
|
||||
self.StringData = FfsInf.__ExtendMacro__(self.StringData)
|
||||
self.FileName = FfsInf.__ExtendMacro__(self.FileName)
|
||||
|
||||
OutputFile = os.path.join(OutputPath, ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('UI'))
|
||||
|
||||
if self.StringData != None :
|
||||
NameString = self.StringData
|
||||
elif self.FileName != None:
|
||||
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
|
||||
FileObj = open(FileNameStr, 'r')
|
||||
NameString = FileObj.read()
|
||||
NameString = '\"' + NameString + "\""
|
||||
FileObj.close()
|
||||
else:
|
||||
NameString = ''
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_USER_INTERFACE', Ui=NameString)
|
||||
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
82
BaseTools/Source/Python/GenFds/VerSection.py
Normal file
82
BaseTools/Source/Python/GenFds/VerSection.py
Normal file
@@ -0,0 +1,82 @@
|
||||
## @file
|
||||
# process Version section generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from Ffs import Ffs
|
||||
import Section
|
||||
import os
|
||||
import subprocess
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
from CommonDataClass.FdfClass import VerSectionClassObject
|
||||
|
||||
## generate version section
|
||||
#
|
||||
#
|
||||
class VerSection (VerSectionClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
VerSectionClassObject.__init__(self)
|
||||
|
||||
## GenSection() method
|
||||
#
|
||||
# Generate version section
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param OutputPath Where to place output file
|
||||
# @param ModuleName Which module this section belongs to
|
||||
# @param SecNum Index of section
|
||||
# @param KeyStringList Filter for inputs of section generation
|
||||
# @param FfsInf FfsInfStatement object that contains this section data
|
||||
# @param Dict dictionary contains macro and its value
|
||||
# @retval tuple (Generated file name, section alignment)
|
||||
#
|
||||
def GenSection(self,OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
|
||||
#
|
||||
# Prepare the parameter of GenSection
|
||||
#
|
||||
if FfsInf != None:
|
||||
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
|
||||
self.BuildNum = FfsInf.__ExtendMacro__(self.BuildNum)
|
||||
self.StringData = FfsInf.__ExtendMacro__(self.StringData)
|
||||
self.FileName = FfsInf.__ExtendMacro__(self.FileName)
|
||||
|
||||
OutputFile = os.path.join(OutputPath,
|
||||
ModuleName + 'SEC' + SecNum + Ffs.SectionSuffix.get('VERSION'))
|
||||
OutputFile = os.path.normpath(OutputFile)
|
||||
|
||||
# Get String Data
|
||||
StringData = ''
|
||||
if self.StringData != None:
|
||||
StringData = self.StringData
|
||||
elif self.FileName != None:
|
||||
FileNameStr = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FileName)
|
||||
FileNameStr = GenFdsGlobalVariable.MacroExtend(FileNameStr, Dict)
|
||||
FileObj = open(FileNameStr, 'r')
|
||||
StringData = FileObj.read()
|
||||
StringData = '"' + StringData + '"'
|
||||
FileObj.close()
|
||||
else:
|
||||
StringData = ''
|
||||
|
||||
GenFdsGlobalVariable.GenerateSection(OutputFile, None, 'EFI_SECTION_VERSION',
|
||||
Ui=StringData, Ver=self.BuildNum)
|
||||
OutputFileList = []
|
||||
OutputFileList.append(OutputFile)
|
||||
return OutputFileList, self.Alignment
|
188
BaseTools/Source/Python/GenFds/Vtf.py
Normal file
188
BaseTools/Source/Python/GenFds/Vtf.py
Normal file
@@ -0,0 +1,188 @@
|
||||
## @file
|
||||
# process VTF generation
|
||||
#
|
||||
# Copyright (c) 2007, 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 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.
|
||||
#
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
#
|
||||
from GenFdsGlobalVariable import GenFdsGlobalVariable
|
||||
import os
|
||||
from CommonDataClass.FdfClass import VtfClassObject
|
||||
T_CHAR_LF = '\n'
|
||||
|
||||
## generate VTF
|
||||
#
|
||||
#
|
||||
class Vtf (VtfClassObject):
|
||||
|
||||
## The constructor
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def __init__(self):
|
||||
VtfClassObject.__init__(self)
|
||||
|
||||
## GenVtf() method
|
||||
#
|
||||
# Generate VTF
|
||||
#
|
||||
# @param self The object pointer
|
||||
# @param FdAddressDict dictionary contains FV name and its base address
|
||||
# @retval Dict FV and corresponding VTF file name
|
||||
#
|
||||
def GenVtf(self, FdAddressDict) :
|
||||
self.GenBsfInf()
|
||||
OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.Vtf')
|
||||
BaseAddArg = self.GetBaseAddressArg(FdAddressDict)
|
||||
OutputArg, VtfRawDict = self.GenOutputArg()
|
||||
|
||||
Cmd = (
|
||||
'GenVtf',
|
||||
) + OutputArg + (
|
||||
'-f', self.BsfInfName,
|
||||
) + BaseAddArg
|
||||
|
||||
GenFdsGlobalVariable.CallExternalTool(Cmd, "GenFv -Vtf Failed!")
|
||||
GenFdsGlobalVariable.SharpCounter = 0
|
||||
|
||||
return VtfRawDict
|
||||
|
||||
## GenBsfInf() method
|
||||
#
|
||||
# Generate inf used to generate VTF
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GenBsfInf (self):
|
||||
FvList = self.GetFvList()
|
||||
self.BsfInfName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.inf')
|
||||
BsfInf = open (self.BsfInfName, 'w+')
|
||||
BsfInf.writelines ("[COMPONENTS]" + T_CHAR_LF)
|
||||
|
||||
for ComponentObj in self.ComponentStatementList :
|
||||
BsfInf.writelines ("COMP_NAME" + \
|
||||
" = " + \
|
||||
ComponentObj.CompName + \
|
||||
T_CHAR_LF )
|
||||
if ComponentObj.CompLoc.upper() == 'NONE':
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'N' + \
|
||||
T_CHAR_LF )
|
||||
|
||||
elif ComponentObj.FilePos != None:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
ComponentObj.FilePos + \
|
||||
T_CHAR_LF )
|
||||
else:
|
||||
Index = FvList.index(ComponentObj.CompLoc.upper())
|
||||
if Index == 0:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'F' + \
|
||||
T_CHAR_LF )
|
||||
elif Index == 1:
|
||||
BsfInf.writelines ("COMP_LOC" + \
|
||||
" = " + \
|
||||
'S' + \
|
||||
T_CHAR_LF )
|
||||
|
||||
BsfInf.writelines ("COMP_TYPE" + \
|
||||
" = " + \
|
||||
ComponentObj.CompType + \
|
||||
T_CHAR_LF )
|
||||
BsfInf.writelines ("COMP_VER" + \
|
||||
" = " + \
|
||||
ComponentObj.CompVer + \
|
||||
T_CHAR_LF )
|
||||
BsfInf.writelines ("COMP_CS" + \
|
||||
" = " + \
|
||||
ComponentObj.CompCs + \
|
||||
T_CHAR_LF )
|
||||
|
||||
BinPath = ComponentObj.CompBin
|
||||
if BinPath != '-':
|
||||
BinPath = GenFdsGlobalVariable.MacroExtend(GenFdsGlobalVariable.ReplaceWorkspaceMacro(BinPath))
|
||||
BsfInf.writelines ("COMP_BIN" + \
|
||||
" = " + \
|
||||
BinPath + \
|
||||
T_CHAR_LF )
|
||||
|
||||
SymPath = ComponentObj.CompSym
|
||||
if SymPath != '-':
|
||||
SymPath = GenFdsGlobalVariable.MacroExtend(GenFdsGlobalVariable.ReplaceWorkspaceMacro(SymPath))
|
||||
BsfInf.writelines ("COMP_SYM" + \
|
||||
" = " + \
|
||||
SymPath + \
|
||||
T_CHAR_LF )
|
||||
BsfInf.writelines ("COMP_SIZE" + \
|
||||
" = " + \
|
||||
ComponentObj.CompSize + \
|
||||
T_CHAR_LF )
|
||||
BsfInf.writelines (T_CHAR_LF )
|
||||
|
||||
BsfInf.close()
|
||||
|
||||
## GenFvList() method
|
||||
#
|
||||
# Get FV list referenced by VTF components
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GetFvList(self):
|
||||
FvList = []
|
||||
for component in self.ComponentStatementList :
|
||||
if component.CompLoc.upper() != 'NONE' and not (component.CompLoc.upper() in FvList):
|
||||
FvList.append(component.CompLoc.upper())
|
||||
|
||||
return FvList
|
||||
|
||||
## GetBaseAddressArg() method
|
||||
#
|
||||
# Get base address arguments for GenVtf
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GetBaseAddressArg(self, FdAddressDict):
|
||||
FvList = self.GetFvList()
|
||||
CmdStr = tuple()
|
||||
for i in FvList:
|
||||
(BaseAddress, Size) = FdAddressDict.get(i)
|
||||
CmdStr += (
|
||||
'-r', '0x%x' % BaseAddress,
|
||||
'-s', '0x%x' %Size,
|
||||
)
|
||||
return CmdStr
|
||||
|
||||
## GenOutputArg() method
|
||||
#
|
||||
# Get output arguments for GenVtf
|
||||
#
|
||||
# @param self The object pointer
|
||||
#
|
||||
def GenOutputArg(self):
|
||||
FvVtfDict = {}
|
||||
OutputFileName = ''
|
||||
FvList = self.GetFvList()
|
||||
Index = 0
|
||||
Arg = tuple()
|
||||
for FvObj in FvList:
|
||||
Index = Index + 1
|
||||
OutputFileName = 'Vtf%d.raw' % Index
|
||||
OutputFileName = os.path.join(GenFdsGlobalVariable.FvDir, OutputFileName)
|
||||
Arg += ('-o', OutputFileName)
|
||||
FvVtfDict[FvObj.upper()] = OutputFileName
|
||||
|
||||
return Arg, FvVtfDict
|
||||
|
0
BaseTools/Source/Python/GenFds/__init__.py
Normal file
0
BaseTools/Source/Python/GenFds/__init__.py
Normal file
Reference in New Issue
Block a user