7 from GenFdsGlobalVariable import GenFdsGlobalVariable
\r
9 from CommonDataClass.FdfClassObject import FDClassObject
\r
11 class FD(FDClassObject):
\r
13 ## self.FdUiName = ''
\r
14 ## self.CreateFileName = None
\r
15 ## self.BaseAddress = None
\r
16 ## self.BaseAddressPcd = None
\r
18 ## self.SizePcd = None
\r
19 ## self.ErasePolarity = '1'
\r
20 ## # 3-tuple list (blockSize, numBlocks, pcd)
\r
21 ## self.BlockSizeList = []
\r
22 ## # DefineVarDict[var] = value
\r
23 ## self.DefineVarDict = {}
\r
24 ## # SetVarDict[var] = value
\r
25 ## self.SetVarDict = {}
\r
26 ## self.RegionList = []
\r
27 ## self.vtfRawDict = {}
\r
28 FDClassObject.__init__(self)
\r
32 def GenFd (self, FvBinDict):
\r
36 print 'Following Region will be add to Fd !!!'
\r
37 for item in GenFdsGlobalVariable.FdfParser.profile.FvDict:
\r
42 FdBuffer = StringIO.StringIO('')
\r
43 for Regions in self.RegionList :
\r
45 # Call each region's AddToBuffer function
\r
47 Regions.AddToBuffer (FdBuffer, self.BaseAddress, self.BlockSizeList, self.ErasePolarity, FvBinDict, self.vtfRawDict)
\r
49 # Create a empty Fd file
\r
51 FdFileName = os.path.join(GenFdsGlobalVariable.FvDir,
\r
52 self.FdUiName + '.fd')
\r
53 fd = open(FdFileName, 'w+b')
\r
56 # Write the buffer contents to Fd file
\r
58 print "Fd File Name:%s" %FdFileName
\r
59 fd.write(FdBuffer.getvalue());
\r
63 def GenVtfFile (self) :
\r
65 # Get this Fd's all Fv name
\r
69 for region in self.RegionList:
\r
70 if region.RegionType == 'FV':
\r
71 fvList.append(region.RegionData.upper())
\r
72 fvAddDict[region.RegionData.upper()] = (int(self.BaseAddress,16) + \
\r
73 region.Offset, region.Size)
\r
75 # Check whether this Fd need VTF
\r
78 for vtf in GenFdsGlobalVariable.FdfParser.profile.VtfList:
\r
79 compLocList = vtf.GetFvList()
\r
80 if set(compLocList).issubset(fvList):
\r
84 self.vtfRawDict = vtf.GenVtf(fvAddDict)
\r
88 # Create Flash Map file
\r
92 ## FlashFile = open( os.path.join(GenFdsGlobalVariable.FvDir, 'FalshMap.h'), 'w+b')
\r
93 ## FlashFile.writelines ("#ifndef _FLASH_MAP_H_" + T_CHAR_LF)
\r
94 ## FlashFile.writelines ("#define _FLASH_MAP_H_" + T_CHAR_LF)
\r