Sync EDKII BaseTools to BaseTools project r1903.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10123 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2010-02-28 23:39:39 +00:00
parent fe35c03635
commit 52302d4dee
169 changed files with 48396 additions and 14798 deletions

View File

@ -1,7 +1,7 @@
## @file
# process FFS generation from INF statement
#
# Copyright (c) 2007, Intel Corporation
# Copyright (c) 2007 - 2010, 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
@ -31,6 +31,9 @@ from Common.Misc import PathClass
from Common.Misc import GuidStructureByteArrayToGuidString
from Common import EdkLogger
from Common.BuildToolError import *
from GuidSection import GuidSection
from FvImageSection import FvImageSection
from Common.Misc import PeImageClass
## generate FFS from INF
#
@ -90,7 +93,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.BaseName = Inf.BaseName
self.ModuleGuid = Inf.Guid
self.ModuleType = Inf.ModuleType
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
if Inf.AutoGenVersion < 0x00010005:
self.ModuleType = Inf.ComponentType
@ -105,7 +108,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.BaseName = Inf.BaseName
self.ModuleGuid = Inf.Guid
self.ModuleType = Inf.ModuleType
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
if Inf.Specification != None and 'PI_SPECIFICATION_VERSION' in Inf.Specification:
self.PiSpecVersion = Inf.Specification['PI_SPECIFICATION_VERSION']
self.VersionString = Inf.Version
self.BinFileList = Inf.Binaries
@ -118,7 +121,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
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 self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A:
if self.ModuleType == 'SMM_CORE' and self.PiSpecVersion < 0x0001000A:
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "SMM_CORE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x0001000A", File=self.InfFileName)
if Inf._Defs != None and len(Inf._Defs) > 0:
@ -146,11 +149,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
# Generate FFS
#
# @param self The object pointer
# @param Dict dictionary contains macro and value pair
# @retval string Generated FFS file name
# @param self The object pointer
# @param Dict dictionary contains macro and value pair
# @param FvChildAddr Array of the inside FvImage base address
# @param FvParentAddr Parent Fv base address
# @retval string Generated FFS file name
#
def GenFfs(self, Dict = {}):
def GenFfs(self, Dict = {}, FvChildAddr = [], FvParentAddr=None):
#
# Parse Inf file get Module related information
#
@ -184,7 +189,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
# For Rule has ComplexFile
#
elif isinstance(Rule, RuleComplexFile.RuleComplexFile):
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule)
InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule, FvChildAddr, FvParentAddr)
FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)
return FfsOutput
@ -393,8 +398,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
FileList = []
OutputFileList = []
GenSecInputFile = None
if Rule.FileName != None:
GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
if os.path.isabs(GenSecInputFile):
GenSecInputFile = os.path.normpath(GenSecInputFile)
else:
GenSecInputFile = os.path.normpath(os.path.join(self.EfiOutputPath, GenSecInputFile))
else:
FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)
@ -429,6 +439,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
Index = Index + 1
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)
#Get PE Section alignment when align is set to AUTO
if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
ImageObj = PeImageClass (File)
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
else:
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
@ -438,7 +457,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
GenFdsGlobalVariable.GenerateFirmwareImage(
StrippedFile,
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
[File],
Strip=True
)
File = StrippedFile
@ -447,7 +466,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
[File],
Type='te'
)
File = TeFile
@ -459,6 +478,15 @@ class FfsInfStatement(FfsInfStatementClassObject):
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \
Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)
GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)
#Get PE Section alignment when align is set to AUTO
if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):
ImageObj = PeImageClass (GenSecInputFile)
if ImageObj.SectionAlignment < 0x400:
self.Alignment = str (ImageObj.SectionAlignment)
else:
self.Alignment = str (ImageObj.SectionAlignment / 0x400) + 'K'
if not NoStrip:
FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')
@ -468,7 +496,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')
GenFdsGlobalVariable.GenerateFirmwareImage(
StrippedFile,
[GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)],
[GenSecInputFile],
Strip=True
)
GenSecInputFile = StrippedFile
@ -477,7 +505,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')
GenFdsGlobalVariable.GenerateFirmwareImage(
TeFile,
[GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],
[GenSecInputFile],
Type='te'
)
GenSecInputFile = TeFile
@ -507,7 +535,7 @@ class FfsInfStatement(FfsInfStatementClassObject):
SectionAlignments = []
for InputFile in InputFileList:
InputSection.append(InputFile)
SectionAlignments.append(Rule.Alignment)
SectionAlignments.append(Rule.SectAlignment)
if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):
PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)
@ -534,11 +562,13 @@ class FfsInfStatement(FfsInfStatementClassObject):
#
# 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
# @param self The object pointer
# @param Rule The rule object used to generate section
# @param FvChildAddr Array of the inside FvImage base address
# @param FvParentAddr Parent Fv base address
# @retval string File name of the generated section file
#
def __GenComplexFileSection__(self, Rule):
def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr):
if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):
if Rule.KeepReloc != None:
self.KeepRelocFromRule = Rule.KeepReloc
@ -560,6 +590,17 @@ class FfsInfStatement(FfsInfStatementClassObject):
if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
if Sect.SectionType == 'SMM_DEPEX':
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
#
# process the inside FvImage from FvSection or GuidSection
#
if FvChildAddr != []:
if isinstance(Sect, FvImageSection):
Sect.FvAddr = FvChildAddr.pop(0)
elif isinstance(Sect, GuidSection):
Sect.FvAddr = FvChildAddr
if FvParentAddr != None and isinstance(Sect, GuidSection):
Sect.FvParentAddr = FvParentAddr
if Rule.KeyStringList != []:
SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)
else :