diff options
Diffstat (limited to 'BaseTools/Source/Python/GenFds')
-rw-r--r-- | BaseTools/Source/Python/GenFds/FdfParser.py | 55 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/FfsInfStatement.py | 185 | ||||
-rw-r--r-- | BaseTools/Source/Python/GenFds/Section.py | 4 |
3 files changed, 208 insertions, 36 deletions
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 52d32a9e98..9e7771dc7d 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -564,7 +564,17 @@ class FdfParser: self.Rewind()
-
+ def __GetIfListCurrentItemStat(self, IfList):
+ if len(IfList) == 0:
+ return True
+
+ for Item in IfList:
+ if Item[1] == False:
+ return False
+
+ return True
+
+
## PreprocessConditionalStatement() method
#
# Preprocess conditional statement.
@@ -577,27 +587,28 @@ class FdfParser: IfList = []
while self.__GetNextToken():
if self.__Token == 'DEFINE':
- DefineLine = self.CurrentLineNumber - 1
- DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
- if not self.__GetNextToken():
- raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber)
- Macro = self.__Token
- if not self.__IsToken( "="):
- raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
-
- if not self.__GetNextToken():
- raise Warning("expected value", self.FileName, self.CurrentLineNumber)
-
- if self.__GetStringData():
- pass
- Value = self.__Token
- if not Macro in InputMacroDict:
- FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1)
- MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
- MacProfile.MacroName = Macro
- MacProfile.MacroValue = Value
- AllMacroList.append(MacProfile)
- self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
+ if self.__GetIfListCurrentItemStat(IfList):
+ DefineLine = self.CurrentLineNumber - 1
+ DefineOffset = self.CurrentOffsetWithinLine - len('DEFINE')
+ if not self.__GetNextToken():
+ raise Warning("expected Macro name", self.FileName, self.CurrentLineNumber)
+ Macro = self.__Token
+ if not self.__IsToken( "="):
+ raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
+
+ if not self.__GetNextToken():
+ raise Warning("expected value", self.FileName, self.CurrentLineNumber)
+
+ if self.__GetStringData():
+ pass
+ Value = self.__Token
+ if not Macro in InputMacroDict:
+ FileLineTuple = GetRealFileLine(self.FileName, DefineLine + 1)
+ MacProfile = MacroProfile(FileLineTuple[0], FileLineTuple[1])
+ MacProfile.MacroName = Macro
+ MacProfile.MacroValue = Value
+ AllMacroList.append(MacProfile)
+ self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif self.__Token in ('!ifdef', '!ifndef', '!if'):
IfStartPos = (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len(self.__Token))
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index d2397e07da..2b556135d2 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -1,7 +1,7 @@ ## @file
# process FFS generation from INF statement
#
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,8 @@ import Rule
import os
import shutil
+import StringIO
+from struct import *
from GenFdsGlobalVariable import GenFdsGlobalVariable
import Ffs
import subprocess
@@ -50,7 +52,7 @@ class FfsInfStatement(FfsInfStatementClassObject): self.KeepRelocFromRule = None
self.InDsc = True
self.OptRomDefs = {}
- self.PiSpecVersion = 0
+ self.PiSpecVersion = '0x00000000'
## __InfParse() method
#
@@ -121,7 +123,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 int(self.PiSpecVersion, 16) < 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:
@@ -177,13 +179,13 @@ class FfsInfStatement(FfsInfStatementClassObject): #
# Convert Fv File Type for PI1.1 SMM driver.
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
if Rule.FvFileType == 'DRIVER':
Rule.FvFileType = 'SMM'
#
# Framework SMM Driver has no SMM FV file type
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE':
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)
#
@@ -409,9 +411,9 @@ class FfsInfStatement(FfsInfStatementClassObject): GenSecInputFile = None
if Rule.FileName != None:
GenSecInputFile = self.__ExtendMacro__(Rule.FileName)
- if os.path.isabs(GenSecInputFile): - GenSecInputFile = os.path.normpath(GenSecInputFile) - else: + 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)
@@ -421,13 +423,13 @@ class FfsInfStatement(FfsInfStatementClassObject): #
# Convert Fv Section Type for PI1.1 SMM driver.
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
if SectionType == 'DXE_DEPEX':
SectionType = 'SMM_DEPEX'
#
# Framework SMM Driver has no SMM_DEPEX section type
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:
if SectionType == 'SMM_DEPEX':
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)
NoStrip = True
@@ -583,19 +585,20 @@ class FfsInfStatement(FfsInfStatementClassObject): SectFiles = []
SectAlignments = []
Index = 1
+ HasGneratedFlag = False
for Sect in Rule.SectionList:
SecIndex = '%d' %Index
SectList = []
#
# Convert Fv Section Type for PI1.1 SMM driver.
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion >= 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:
if Sect.SectionType == 'DXE_DEPEX':
Sect.SectionType = 'SMM_DEPEX'
#
# Framework SMM Driver has no SMM_DEPEX section type
#
- if self.ModuleType == 'DXE_SMM_DRIVER' and self.PiSpecVersion < 0x0001000A:
+ if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 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)
#
@@ -613,6 +616,51 @@ class FfsInfStatement(FfsInfStatementClassObject): 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)
+
+ if not HasGneratedFlag:
+ UniVfrOffsetFileSection = ""
+ ModuleFileName = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName)
+ InfData = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClass(ModuleFileName), self.CurrentArch]
+ #
+ # Search the source list in InfData to find if there are .vfr file exist.
+ #
+ VfrUniBaseName = {}
+ VfrUniOffsetList = []
+ for SourceFile in InfData.Sources:
+ if SourceFile.Type.upper() == ".VFR" :
+ #
+ # search the .map file to find the offset of vfr binary in the PE32+/TE file.
+ #
+ VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin")
+ if SourceFile.Type.upper() == ".UNI" :
+ #
+ # search the .map file to find the offset of Uni strings binary in the PE32+/TE file.
+ #
+ VfrUniBaseName["UniOffsetName"] = (self.BaseName + "Strings")
+
+
+ if len(VfrUniBaseName) > 0:
+ VfrUniOffsetList = self.__GetBuildOutputMapFileVfrUniInfo(VfrUniBaseName)
+ #
+ # Generate the Raw data of raw section
+ #
+ os.path.join( self.OutputPath, self.BaseName + '.offset')
+ UniVfrOffsetFileName = os.path.join( self.OutputPath, self.BaseName + '.offset')
+ UniVfrOffsetFileSection = os.path.join( self.OutputPath, self.BaseName + 'Offset' + '.raw')
+
+ self.__GenUniVfrOffsetFile (VfrUniOffsetList, UniVfrOffsetFileName)
+
+ UniVfrOffsetFileNameList = []
+ UniVfrOffsetFileNameList.append(UniVfrOffsetFileName)
+ """Call GenSection"""
+ GenFdsGlobalVariable.GenerateSection(UniVfrOffsetFileSection,
+ UniVfrOffsetFileNameList,
+ "EFI_SECTION_RAW"
+ )
+ os.remove(UniVfrOffsetFileName)
+ SectList.append(UniVfrOffsetFileSection)
+ HasGneratedFlag = True
+
for SecName in SectList :
SectFiles.append(SecName)
SectAlignments.append(Align)
@@ -672,3 +720,116 @@ class FfsInfStatement(FfsInfStatementClassObject): result += ('-a', Rule.Alignment)
return result
+
+ ## __GetBuildOutputMapFileVfrUniInfo() method
+ #
+ # Find the offset of UNI/INF object offset in the EFI image file.
+ #
+ # @param self The object pointer
+ # @param VfrUniBaseName A name list contain the UNI/INF object name.
+ # @retval RetValue A list contain offset of UNI/INF object.
+ #
+ def __GetBuildOutputMapFileVfrUniInfo(self, VfrUniBaseName):
+
+ RetValue = []
+
+ MapFileName = os.path.join(self.EfiOutputPath, self.BaseName + ".map")
+ try:
+ fInputfile = open(MapFileName, "r", 0)
+ try:
+ FileLinesList = fInputfile.readlines()
+ except:
+ EdkLogger.error("GenFds", FILE_READ_FAILURE, "File read failed for %s" %MapFileName,None)
+ finally:
+ fInputfile.close()
+ except:
+ EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed for %s" %MapFileName,None)
+
+ IsHex = False
+ for eachLine in FileLinesList:
+ for eachName in VfrUniBaseName.values():
+ if eachLine.find(eachName) != -1:
+ eachLine = eachLine.strip()
+ Element = eachLine.split()
+ #
+ # MSFT/ICC/EBC map file
+ #
+ if (len(Element) == 4):
+ try:
+ int (Element[2], 16)
+ IsHex = True
+ except:
+ IsHex = False
+
+ if IsHex:
+ RetValue.append((eachName, Element[2]))
+ IsHex = False
+ #
+ # GCC map file
+ #
+ elif (len(Element) == 2) and Element[0].startswith("0x"):
+ RetValue.append((eachName, Element[0]))
+
+ return RetValue
+
+ ## __GenUniVfrOffsetFile() method
+ #
+ # Generate the offset file for the module which contain VFR or UNI file.
+ #
+ # @param self The object pointer
+ # @param VfrUniOffsetList A list contain the VFR/UNI offsets in the EFI image file.
+ # @param UniVfrOffsetFileName The output offset file name.
+ #
+ def __GenUniVfrOffsetFile(self, VfrUniOffsetList, UniVfrOffsetFileName):
+
+ try:
+ fInputfile = open(UniVfrOffsetFileName, "wb+", 0)
+ except:
+ EdkLogger.error("GenFds", FILE_OPEN_FAILURE, "File open failed for %s" %UniVfrOffsetFileName,None)
+
+ # Use a instance of StringIO to cache data
+ fStringIO = StringIO.StringIO('')
+
+ for Item in VfrUniOffsetList:
+ if (Item[0].find("Strings") != -1):
+ #
+ # UNI offset in image.
+ # GUID + Offset
+ # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }
+ #
+ UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]
+ UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]
+ fStringIO.write(''.join(UniGuid))
+ UniValue = pack ('Q', int (Item[1], 16))
+ fStringIO.write (UniValue)
+ else:
+ #
+ # VFR binary offset in image.
+ # GUID + Offset
+ # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };
+ #
+ VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]
+ VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]
+ fStringIO.write(''.join(VfrGuid))
+ type (Item[1])
+ VfrValue = pack ('Q', int (Item[1], 16))
+ fStringIO.write (VfrValue)
+
+ #
+ # write data into file.
+ #
+ try :
+ fInputfile.write (fStringIO.getvalue())
+ except:
+ EdkLogger.error("GenFds", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the file been locked or using by other applications." %UniVfrOffsetFileName,None)
+
+ fStringIO.close ()
+ fInputfile.close ()
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index 8c884b6e10..a6d3c6319d 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -1,7 +1,7 @@ ## @file
# section base class
#
-# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -129,7 +129,7 @@ class Section (SectionClassObject): if FileType != None:
for File in FfsInf.BinFileList:
if File.Arch == "COMMON" or FfsInf.CurrentArch == File.Arch:
- if File.Type == FileType or (FfsInf.PiSpecVersion >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'):
+ if File.Type == FileType or (int(FfsInf.PiSpecVersion, 16) >= 0x0001000A and FileType == 'DXE_DPEX'and File.Type == 'SMM_DEPEX'):
if '*' in FfsInf.TargetOverrideList or File.Target == '*' or File.Target in FfsInf.TargetOverrideList or FfsInf.TargetOverrideList == []:
FileList.append(File.Path)
else:
|