from DscClassObject import *\r
from String import *\r
from ClassObjects.CommonClassObject import *\r
-from GenFds.FdfParser import *\r
+#from FdfParser import *\r
from BuildToolError import *\r
-from GenFds.Region import *\r
+#from Region import *\r
\r
class ModuleSourceFilesClassObject(object):\r
def __init__(self, SourceFile = '', PcdFeatureFlag = '', TagName = '', ToolCode = '', ToolChainFamily = '', String = ''):\r
\r
compStatement.CompLoc = ""\r
if self.__GetNextWord():\r
- compStatement.CompLoc = self.__Token\r
+ compStatement.CompLoc = self.__Token\r
if self.__IsToken('|'):\r
if not self.__GetNextWord():\r
raise Warning("Expected Region Name At Line %d" % self.CurrentLineNumber)\r
import Section\r
import RuleSimpleFile\r
import RuleComplexFile\r
-from String import *\r
+#from String import *\r
\r
class FfsInfStatement(Ffs.Ffs):\r
def __init__(self):\r
import os\r
import FdfParser\r
from GenFdsGlobalVariable import GenFdsGlobalVariable\r
-import EdkIIWorkspaceBuild\r
+import Common.EdkIIWorkspaceBuild\r
import RuleComplexFile\r
from EfiSection import EfiSection\r
import StringIO\r
\r
"""call workspace build create database"""\r
os.environ["WORKSPACE"] = workspace\r
- buildWorkSpace = EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)\r
+ buildWorkSpace = Common.EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)\r
\r
"""Call GenFds"""\r
GenFds.GenFd(outputDir, fdfParser, buildWorkSpace, archList)\r
\r
class DataSection (Section.Section):\r
def __init__(self):\r
- self.Alignemnt = None\r
+ self.Alignment = None\r
self.SecType = None\r
self.SectFileName = None\r
self.SectionList = []\r
\r
print GenSectionCmd\r
GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed!")\r
- return OutputFile, self.Alignemnt\r
+ return OutputFile, self.Alignment\r
#\r
print GenSectionCmd\r
GenFdsGlobalVariable.CallExternalTool(GenSectionCmd, "GenSection Failed !")\r
-## if self.Alignment == None:\r
-## print "#####################################"\r
-## print "Align is none"\r
- \r
- \r
return OutputFile , self.Alignment\r
# SetVarDict[var] = value\r
self.SetVarDict = {}\r
self.RegionList = []\r
- \r
+ self.vtfRawDict = {}\r
\r
##\r
# Create Fd file\r
for item in GenFdsGlobalVariable.FdfParser.profile.FvDict:\r
print item\r
\r
+ self.GenVtfFile()\r
+ \r
FdBuffer = StringIO.StringIO('')\r
for Regions in self.RegionList :\r
#\r
# Call each region's AddToBuffer function \r
#\r
- Regions.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict)\r
+ Regions.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict)\r
#\r
# Create a empty Fd file\r
#\r
##\r
def GenFlashMap ():\r
pass\r
+ \r
+ def GenVtfFile (self) :\r
+ #\r
+ # Get this Fd's all Fv name\r
+ #\r
+ fvAddDict ={}\r
+ fvList = []\r
+ for region in self.RegionList:\r
+ if region.RegionType == 'FV':\r
+ fvList.append(region.RegionData.upper())\r
+ fvAddDict[region.RegionData.upper()] = (int(self.BaseAddress,16) + \\r
+ region.Offset, region.Size)\r
+ #\r
+ # Check whether this Fd need VTF\r
+ #\r
+ flag = False\r
+ for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:\r
+ compLocList = vtf.GetFvList()\r
+ if set(compLocList).issubset(fvList):\r
+ flag = True\r
+ break\r
+ if flag == True:\r
+ self.vtfRawDict = vtf.GenVtf(fvAddDict)\r
+\r
+ \r
+\r
+ \r
+\r
+\r
+ \r
+ \r
+ \r
StartPos = self.CurrentOffsetWithinLine\r
while not self.__EndOfLine():\r
TempChar = self.__CurrentChar()\r
- if not str(TempChar).isspace() and TempChar not in ('=', '|', ',', '}'):\r
+ if not str(TempChar).isspace() and TempChar not in ('=', '|', ',', '{', '}'):\r
+ self.__GetOneChar()\r
+ elif StartPos == self.CurrentOffsetWithinLine and TempChar in ('=', '|', ',', '{', '}'):\r
self.__GetOneChar()\r
else:\r
break\r
if not self.__IsToken("="):\r
raise Warning("expected '=' At Line %d" % self.CurrentLineNumber)\r
\r
- if not self.__GetNextWord():\r
- raise Warning("expected Component location At Line %d" % self.CurrentLineNumber)\r
- if self.__Token not in ("F", "N", "S", "H", "L", "PH", "PL"):\r
- raise Warning("Unknown location type At line %d" % self.CurrentLineNumber)\r
- compStatement.CompLoc = self.__Token\r
+ compStatement.CompLoc = ""\r
+ if self.__GetNextWord():\r
+ compStatement.CompLoc = self.__Token\r
+ if self.__IsToken('|'):\r
+ if not self.__GetNextWord():\r
+ raise Warning("Expected Region Name At Line %d" % self.CurrentLineNumber)\r
+ \r
+ if self.__Token not in ("F", "N", "S", "H", "L", "PH", "PL"):\r
+ raise Warning("Unknown location type At line %d" % self.CurrentLineNumber)\r
+ compStatement.CompLoc += "|"\r
+ compStatement.CompLoc += self.__Token\r
+ else:\r
+ self.CurrentLineNumber += 1\r
+ self.CurrentOffsetWithinLine = 0\r
\r
if not self.__IsKeyword("COMP_TYPE"):\r
raise Warning("expected COMP_TYPE At Line %d" % self.CurrentLineNumber)\r
sect\r
if align != None:\r
SectionFiles = SectionFiles + \\r
- ' -o ' + \\r
+ ' -n ' + \\r
align\r
\r
#\r
import Section\r
import RuleSimpleFile\r
import RuleComplexFile\r
-from Common.String import *\r
+#from String import *\r
\r
class FfsInfStatement(Ffs.Ffs):\r
def __init__(self):\r
\r
self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \\r
self.ModuleGuid + self.BaseName)\r
- self.OutputPath = os.path.normcase(self.OutputPath)\r
if not os.path.exists(self.OutputPath) :\r
os.makedirs(self.OutputPath)\r
\r
'.' + \\r
self.ModuleType.upper()\r
\r
-\r
Rule = GenFdsGlobalVariable.FdfParser.profile.RuleDict.get(RuleName)\r
if Rule == None :\r
RuleName = 'RULE' + \\r
'COMMON' + \\r
'.' + \\r
self.ModuleType.upper()\r
- \r
+ print "Want To Find Rule Name is : " + RuleName\r
Rule = GenFdsGlobalVariable.FdfParser.profile.RuleDict.get(RuleName)\r
if Rule == None :\r
print 'Dont Find Related Rule, Using Default Rule !!!'\r
def __GenComplexFileSection__(self, Rule):\r
SectFiles = ''\r
for Sect in Rule.SectionList:\r
- print 'GenSection: %s %s :' %(self.OutputPath ,self.ModuleGuid)\r
+ #print 'GenSection: %s %s :' %(self.OutputPath ,self.ModuleGuid)\r
secName = ''\r
secName, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, self.KeyStringList, self)\r
if secName != '':\r
else :\r
Alignment = ''\r
\r
- return FileType, Fixed, CheckSum, Alignment\r
+ return FileType, Fixed, CheckSum, Alignment
\ No newline at end of file
#\r
# Generate Fv and add it to the Buffer\r
#\r
- def AddToBuffer (self, Buffer, BaseAddress= None, BlockSize= None, BlockNum=None, ErasePloarity='1') :\r
- self.__InitialInf__(BaseAddress, BlockSize, BlockNum)\r
+ def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None) :\r
+ self.__InitialInf__(BaseAddress, BlockSize, BlockNum, ErasePloarity, VtfDict)\r
#\r
# First Process the Apriori section\r
#\r
fv.close\r
return FvOutputFile\r
\r
- def __InitialInf__ (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1') :\r
+ def __InitialInf__ (self, BaseAddress = None, BlockSize= None, BlockNum = None, ErasePloarity='1', VtfDict=None) :\r
self.InfFileName = os.path.join(GenFdsGlobalVariable.FvDir,\r
self.UiFvName + '.inf')\r
self.FvInfFile = open (self.InfFileName, 'w+')\r
+ \r
#\r
# Add [Options]\r
#\r
#\r
\r
self.FvInfFile.writelines("[files]" + T_CHAR_LF)\r
+ if VtfDict != None and self.UiFvName in VtfDict.keys():\r
+ self.FvInfFile.writelines("EFI_FILE_NAME = " + \\r
+ VtfDict.get(self.UiFvName) + \\r
+ T_CHAR_LF)\r
+ \r
\r
\r
\r
\r
"""call workspace build create database"""\r
os.environ["WORKSPACE"] = workspace\r
- buildWorkSpace = EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)\r
+ buildWorkSpace = Common.EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)\r
\r
"""Call GenFds"""\r
GenFds.GenFd(outputDir, fdfParser, buildWorkSpace, archList)\r
fv = GenFdsGlobalVariable.FdfParser.profile.FvDict[FvName]\r
fv.AddToBuffer(Buffer)\r
Buffer.close()\r
+ \r
+ #print "######### Gen Capsule ####################"\r
for capsule in GenFdsGlobalVariable.FdfParser.profile.CapsuleList:\r
capsule.GenCapsule()\r
\r
- for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:\r
- vtf.GenVtf()\r
+## for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:\r
+## vtf.GenVtf()\r
\r
#Finish GenFd()\r
- \r
+ def GenVTFList() :\r
+ for item in GenFdsGlobalVariable.FdfParser.profile.VtfList:\r
+ for comp in item.ComponentStatementList:\r
+ if comp.CompLoc != None :\r
+ compList.append(comp.Loc)\r
+ GenFdsGlobalVariable.VtfDict[item.UiName] = compList\r
#\r
# Define GenFd as static function\r
#\r
RuleDict = {}\r
DefaultRule = None\r
ArchList = None\r
+ VtfDict = {}\r
\r
def ExtendMarco (String):\r
return String\r
GenFdsGlobalVariable.WorkSpaceDir = GenFdsGlobalVariable.WorkSpace.Workspace.WorkspaceDir\r
if ArchList != None:\r
GenFdsGlobalVariable.ArchList = ArchList\r
- \r
+ \r
+ if not os.path.exists(GenFdsGlobalVariable.FvDir) :\r
+ os.makedirs(GenFdsGlobalVariable.FvDir)\r
+ \r
def SetDefaultRule (Rule) :\r
GenFdsGlobalVariable.DefaultRule = Rule\r
\r
def CallExternalTool (cmd, errorMess):\r
PopenObject = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr= subprocess.PIPE)\r
(out, error) = PopenObject.communicate()\r
+\r
+ while PopenObject.returncode == None :\r
+ PopenObject.wait()\r
if PopenObject.returncode != 0:\r
+ print "Return Value = %d" %PopenObject.returncode\r
print out\r
print error\r
raise Exception(errorMess)\r
TempFile = os.path.normpath(TempFile)\r
\r
ExternalToolCmd = ExternalTool + \\r
+ ' -e ' + \\r
' -o ' + \\r
TempFile + \\r
' ' + \\r
-import GenFds\r
from struct import *\r
from GenFdsGlobalVariable import GenFdsGlobalVariable\r
import StringIO\r
##\r
# Add RegionData to Fd file\r
##\r
- def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, FvBinDict):\r
+ def AddToBuffer(self, Buffer, BaseAddress, BlockSizeList, ErasePolarity, FvBinDict, vtfDict = None):\r
Size = self.Size\r
print "Fv Size = %d" %Size\r
\r
BlockSize = self.__BlockSizeOfRegion__(BlockSizeList)\r
BlockNum = self.__BlockNumOfRegion__(BlockSize)\r
FvBaseAddress = '0x%x' %self.FvAddress\r
- FileName = fv.AddToBuffer(Buffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity)\r
+ FileName = fv.AddToBuffer(Buffer, FvBaseAddress, BlockSize, BlockNum, ErasePolarity, vtfDict)\r
FvBinDict[self.RegionData.upper()] = FileName\r
\r
if self.RegionType == 'FILE':\r
self.ResetBin = None\r
self.ComponentStatementList = []\r
\r
- \r
\r
- def GenVtf(self) :\r
+ def GenVtf(self, fdAddDict) :\r
self.GenBsfInf()\r
- OutputFile = os.path.join(GenFdsGlobalVariabel.FvDir, self.UiName + '.Vtf')\r
- BaseAddArg = ''\r
- for item in self.BaseAddressList :\r
- BaseAddArg = BaseAddArg + \\r
- ' -a ' + \\r
- item[0] + \\r
- ' -s ' + \\r
- item[1]\r
- cmd = "GenVtf -i " + \\r
- ' -o ' + \\r
- OutputFile + \\r
+ OutputFile = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.Vtf')\r
+ BaseAddArg = self.GetBaseAddArg(fdAddDict)\r
+ outputArg, VtfRawDict = self.GenOutputArg()\r
+ \r
+ cmd = "GenVtf " + \\r
+ outputArg + \\r
+ ' -f ' + \\r
self.BsfInfName + \\r
- BaseAddArg\r
+ ' ' + \\r
+ BaseAddArg \r
\r
print cmd\r
GenFdsGlobalVariable.CallExternalTool(cmd, "GenFv -Vtf Failed!")\r
- \r
+ return VtfRawDict\r
\r
def GenBsfInf (self):\r
- self.BaseAddressList = []\r
+ fvList = self.GetFvList()\r
self.BsfInfName = os.path.join(GenFdsGlobalVariable.FvDir, self.UiName + '.inf')\r
BsfInf = open (self.BsfInfName, 'w+')\r
BsfInf.writelines ("[COMPONENTS]" + T_CHAR_LF)\r
" = " + \\r
component.CompName + \\r
T_CHAR_LF )\r
- BsfInf.writelines ("COMP_LOC" + \\r
- " = " + \\r
- component.CompLoc + \\r
- T_CHAR_LF )\r
+ if component.CompLoc.supper() == 'NONE' :\r
+ BsfInf.writelines ("COMP_LOC" + \\r
+ " = " + \\r
+ 'N' + \\r
+ T_CHAR_LF )\r
+ else:\r
+ index = fvList.index(component.CompLoc.upper())\r
+ if index == 0:\r
+ BsfInf.writelines ("COMP_LOC" + \\r
+ " = " + \\r
+ 'F' + \\r
+ T_CHAR_LF )\r
+ elif index == 1:\r
+ BsfInf.writelines ("COMP_LOC" + \\r
+ " = " + \\r
+ S + \\r
+ T_CHAR_LF )\r
+ \r
BsfInf.writelines ("COMP_TYPE" + \\r
" = " + \\r
component.CompType + \\r
T_CHAR_LF )\r
BsfInf.writelines ("COMP_BIN" + \\r
" = " + \\r
- component.CompBin + \\r
+ GenFdsGlobalVariable.ReplaceWorkspaceMarco(component.CompBin) + \\r
T_CHAR_LF )\r
BsfInf.writelines ("COMP_SYM" + \\r
" = " + \\r
- component.CompSym + \\r
+ GenFdsGlobalVariable.ReplaceWorkspaceMarco(component.CompSym) + \\r
T_CHAR_LF )\r
BsfInf.writelines ("COMP_SIZE" + \\r
" = " + \\r
T_CHAR_LF )\r
BsfInf.writelines (T_CHAR_LF )\r
\r
- if component[1] == 'F' :\r
- for fd in GenFdsGlobalVariable.FdfParser.profile.FdDict :\r
- BaseAddress = fd.RegionList[0].Offset\r
- Size = fd.RegionList[0].Size\r
- elif component[1] == 'S':\r
- for fd in GenFdsGlobalVariable.FdfParser.profile.FdDict :\r
- BaseAddress = fd.RegionList[1].Offset\r
- Size = fd.RegionList[1].Size\r
- self.BaseAddressList.append(BaseAddress, Size)\r
BsfInf.close()\r
+\r
+ def GetFvList(self):\r
+ fvList = []\r
+ for component in self.ComponentStatementList :\r
+ if component.CompLoc != None and not (component.CompLoc in fvList):\r
+ fvList.append(component.CompLoc.upper())\r
+ \r
+ return fvList\r
+\r
+ def GetBaseAddArg(self, fdAddDict):\r
+ fvList = self.GetFvList()\r
+ cmdStr = ''\r
+ for i in fvList:\r
+ (baseAdd, size) = fdAddDict.get(i)\r
+ cmdStr = cmdStr + \\r
+ ' -r 0x%x' %baseAdd + \\r
+ ' -s 0x%x' %size\r
+ return cmdStr\r
+ \r
+ def GenOutputArg(self):\r
+ fvVtfDict = {}\r
+ outPutFileName = ''\r
+ fvList = self.GetFvList()\r
+ index = 0\r
+ arg = ''\r
+ for fv in fvList:\r
+ index = index +1\r
+ outputFileName = 'Vtf%d.raw' %index\r
+ outPutFileName = os.path.join(GenFdsGlobalVariable.FvDir, outputFileName)\r
+ arg = arg + \\r
+ ' -o ' + \\r
+ outPutFileName\r
+ fvVtfDict[fv.upper()] = outPutFileName\r
+ \r
+ return arg, fvVtfDict\r
+ \r
TempFile = os.path.normpath(TempFile)\r
\r
ExternalToolCmd = ExternalTool + \\r
+ ' -e ' + \\r
' -o ' + \\r
TempFile + \\r
' ' + \\r
-import GenFds\r
from struct import *\r
from GenFdsGlobalVariable import GenFdsGlobalVariable\r
import StringIO\r
" = " + \\r
component.CompName + \\r
T_CHAR_LF )\r
- if component.CompLoc == None or component.CompLoc == '' :\r
+ if component.CompLoc.supper() == 'NONE' :\r
BsfInf.writelines ("COMP_LOC" + \\r
" = " + \\r
'N' + \\r