pcd.append(None)\r
SkuName = dscObj.Contents[key].PcdsDynamicDefault[index][1]\r
SkuInfoList = []\r
- if SkuName == None or SkuName == []:\r
+ if SkuName == None or SkuName == [] or SkuName == ['']:\r
SkuName = ['DEFAULT']\r
SkuNameList = map(lambda l: l.strip(), SkuName[0].split(DataType.TAB_VALUE_SPLIT))\r
for Item in SkuNameList:\r
SkuInfo = SkuInfoClass()\r
- SkuInfo.SkuId = pb.SkuIds[Item]\r
+ SkuInfo.SkuId = Item[1]\r
SkuInfo.DefaultValue = pcd[2]\r
SkuInfoList.append(SkuInfo)\r
pb.Pcds[(pcd[0], pcd[1])] = PcdClassObject(pcd[0], pcd[1], DataType.TAB_PCDS_DYNAMIC_DEFAULT, None, None, None, pcd[3], SkuInfoList)\r
if not os.path.exists(self.SectFileName):\r
self.SectFileName = os.path.join (GenFdsGlobalVariable.WorkSpaceDir,\r
self.SectFileName)\r
-\r
- OutputFile = OutputPath + \\r
- os.sep + \\r
- ModuleName + \\r
- Ffs.SectionSuffix.get(self.SecType)\r
+ if self.SecType == 'TE':\r
+ TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
+ GenTeCmd = 'GenFW -t ' + \\r
+ ' -o ' + \\r
+ TeFile + \\r
+ ' ' + \\r
+ GenFdsGlobalVariable.ExtendMarco(self.SectFileName)\r
+ print GenTeCmd\r
+ GenFdsGlobalVariable.CallExternalTool(GenTeCmd, "GenFw Failed !")\r
+ self.SectFileName = TeFile\r
+ \r
+ OutputFile = os.path.join (OutputPath, ModuleName + Ffs.SectionSuffix.get(self.SecType))\r
OutputFile = os.path.normpath(OutputFile)\r
- print "DataSection SectionType: %s" %self.SecType\r
- print "DataSection SectFileName: %s" %self.SectFileName\r
\r
GenSectionCmd = 'GenSec -o ' + \\r
OutputFile + \\r
return '', None\r
else:\r
raise Exception(" %s does't exist" %Filename)\r
+ #\r
+ # For TE Section call GenFw to generate TE image\r
+ #\r
+ if SectionType == 'TE':\r
+ TeFile = os.path.join( OutputPath, ModuleName + 'Te.raw')\r
+ GenTeCmd = 'GenFW -t ' + \\r
+ ' -o ' + \\r
+ TeFile + \\r
+ ' ' + \\r
+ GenFdsGlobalVariable.ExtendMarco(Filename)\r
+ print GenTeCmd\r
+ GenFdsGlobalVariable.CallExternalTool(GenTeCmd, "GenFw Failed !")\r
+ Filename = TeFile\r
+\r
\r
GenSectionCmd = 'GenSec -o ' + \\r
OutputFile + \\r
import Section\r
import RuleSimpleFile\r
import RuleComplexFile\r
+import Common.TargetTxtClassObject\r
+\r
#from String import *\r
\r
class FfsInfStatement(Ffs.Ffs):\r
self.InfFileName = None\r
self.BuildNum = ''\r
self.KeyStringList = []\r
- self.RuleOverride = None\r
\r
def __infParse__(self):\r
#\r
# Get the rule of how to generate Ffs file\r
#\r
Rule = self.__GetRule__()\r
- \r
+\r
FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]\r
#\r
# For the rule only has simpleFile\r
return String\r
\r
def __GetRule__ (self) :\r
- currentArch = 'IA32'\r
+ currentArchList = self.__GetCurrentArch__()\r
+ \r
#for item in GenFdsGlobalVariable.FdfParser.profile.RuleDict :\r
# print item\r
+ for currentArch in currentArchList:\r
+ RuleName = 'RULE' + \\r
+ '.' + \\r
+ currentArch.upper() + \\r
+ '.' + \\r
+ self.ModuleType.upper()\r
+ if self.Rule != None:\r
+ RuleName = RuleName + \\r
+ '.' + \\r
+ self.Rule.upper()\r
+ \r
+ Rule = GenFdsGlobalVariable.FdfParser.profile.RuleDict.get(RuleName)\r
+ if Rule != None:\r
+ print "Want To Find Rule Name is : " + RuleName\r
+ return Rule\r
+ \r
RuleName = 'RULE' + \\r
'.' + \\r
- currentArch + \\r
+ 'COMMON' + \\r
'.' + \\r
self.ModuleType.upper()\r
- \r
+ if self.Rule != None:\r
+ RuleName = RuleName + \\r
+ '.' + \\r
+ self.Rule.upper()\r
+ \r
Rule = GenFdsGlobalVariable.FdfParser.profile.RuleDict.get(RuleName)\r
- if Rule == None :\r
- RuleName = 'RULE' + \\r
- '.' + \\r
- 'COMMON' + \\r
- '.' + \\r
- self.ModuleType.upper()\r
+ if Rule != None:\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
- if GenFdsGlobalVariable.DefaultRule == None:\r
- raise Exception ("Default Rule doesn't exist!!")\r
+ return Rule\r
+\r
+ if Rule == None :\r
+ print 'Dont Find Related Rule, Using Default Rule !!!'\r
+ if GenFdsGlobalVariable.DefaultRule == None:\r
+ raise Exception ("Default Rule doesn't exist!!")\r
+ else:\r
return GenFdsGlobalVariable.DefaultRule\r
- print "Want To Find Rule Name is : " + RuleName\r
- return Rule\r
+\r
+ def __GetCurrentArch__(self):\r
+ Target = Common.TargetTxtClassObject.TargetTxtDict(GenFdsGlobalVariable.WorkSpaceDir)\r
+ targetArchList = Target.TargetTxtDictionary['TARGET_ARCH']\r
+ #targetArchList = GenFdsGlobalVariable.WorkSpace.TargetTxt.TargetTxtDictionary["TARGET_ARCH"]\r
+ if len(targetArchList) == 0:\r
+ targetArchList = GenFdsGlobalVariable.WorkSpace.SupArchList\r
+ else:\r
+ targetArchList = set(GenFdsGlobalVariable.WorkSpace.SupArchList) & set(targetArchList)\r
+ \r
+ #activePlatform = GenFdsGlobalVariable.WorkSpace.TargetTxt.TargetTxtDictionary.get('ACTIVE_PLATFORM')[0]\r
+ dscArchList = []\r
+ if self.InfFileName in (GenFdsGlobalVariable.WorkSpace.Build.get('IA32').PlatformDatabase[GenFdsGlobalVariable.ActivePlatform].Modules):\r
+ dscArchList.append ('IA32')\r
+ if self.InfFileName in (GenFdsGlobalVariable.WorkSpace.Build.get('X64').PlatformDatabase[GenFdsGlobalVariable.ActivePlatform].Modules):\r
+ dscArchList.append ('X64')\r
+ if self.InfFileName in (GenFdsGlobalVariable.WorkSpace.Build.get('IPF').PlatformDatabase[GenFdsGlobalVariable.ActivePlatform].Modules):\r
+ dscArchList.append ('IPF')\r
+\r
+ curArchList = set (targetArchList) & set (dscArchList)\r
+ print "Valid target architecture(s) is", " ".join(curArchList)\r
+ return curArchList\r
\r
def __GetEFIOutPutPath__(self):\r
- Flag = False\r
Arch = ''\r
OutputPath = ''\r
(ModulePath, fileName) = os.path.split(self.InfFileName)\r
index = fileName.find('.')\r
fileName = fileName[0:index]\r
- Platform = os.path.normpath(GenFdsGlobalVariable.WorkSpace.TargetTxt.TargetTxtDictionary["ACTIVE_PLATFORM"][0])\r
- targetArchList = GenFdsGlobalVariable.WorkSpace.TargetTxt.TargetTxtDictionary["TARGET_ARCH"]\r
- if len(targetArchList) == 0:\r
- myArchList = GenFdsGlobalVariable.WorkSpace.SupArchList\r
- else:\r
- myArchList = set(GenFdsGlobalVariable.WorkSpace.SupArchList) & set(targetArchList)\r
- print "Valid target architecture(s) is", " ".join(myArchList)\r
\r
- if len(myArchList) > 1 :\r
+ curArchList = self.__GetCurrentArch__()\r
+ if len(curArchList) > 1 :\r
for Key in self.KeyStringList:\r
Target, Tag, Arch = Key.split('_')\r
ArchList = set (ArchList) & Arch\r
- if ArchList == 1:\r
- Arch = ArchList[0]\r
- else:\r
- raise Exception("Module %s has too many bulid Arch !" %self.InfFileNames)\r
- elif len(myArchList) == 1 :\r
- Arch = myArchList.pop()\r
+ if len(ArchList) == 1:\r
+ Arch = ArchList[0]\r
+ elif len(ArchList) > 1:\r
+ raise Exception("Module %s has too many bulid Arch !" %self.InfFileNames)\r
+ else:\r
+ raise Exception("Don't find legal Arch in Module %s !" %self.InfFileNames)\r
+ elif len(curArchList) == 1 :\r
+ Arch = curArchList.pop()\r
\r
OutputPath = os.path.join(GenFdsGlobalVariable.OuputDir,\r
Arch ,\r
fileName,\r
'OUTPUT'\r
)\r
- OutputPath = os.path.normcase(OutputPath)\r
+ \r
+ OutputPath = os.path.realpath(OutputPath)\r
return OutputPath\r
\r
def __GenSimpleFileSection__(self, Rule):\r
for Sect in Rule.SectionList:\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 Rule.KeyStringList != []:\r
+ secName, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, Rule.KeyStringList, self)\r
+ else :\r
+ secName, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, self.KeyStringList, self)\r
if secName != '':\r
SectFiles = SectFiles + \\r
' -i ' + \\r
#\r
fv = open ( FvOutputFile,'r+b')\r
\r
- print "Write the Fv contents to buffer"\r
+ print "Generate %s Fv Successful" %self.UiFvName\r
\r
Buffer.write(fv.read())\r
fv.close\r
from Ffs import Ffs\r
import subprocess\r
from GenFdsGlobalVariable import GenFdsGlobalVariable\r
+import os\r
\r
class FvImageSection(Section.Section):\r
def __init__(self):\r
FvImageSection both in FvUiName and \\r
FvImageArg!")\r
\r
- self.Fv.AddToBuffer(Buffer)\r
- \r
- FvFileName = OutputPath + \\r
- ModuleName + \\r
- '.fv'\r
- FvFile = open ( FvFileName, 'w+')\r
- FvFile.write(Buffer.getvalue())\r
- FvFile.close()\r
+ FvFileName = self.Fv.AddToBuffer(Buffer)\r
#\r
# Prepare the parameter of GenSection\r
#\r
- OutputFile = OutputPath + \\r
- ModuleName + \\r
- Ffs.SectionSuffix.get("FV_IMAGE")\r
+ OutputFile = os.path.join(OutputPath, ModuleName + Ffs.SectionSuffix.get("FV_IMAGE"))\r
\r
- GenSectionCmd = 'GenSec -o ' + \\r
+ GenSectionCmd = 'GenSec -o ' + \\r
OutputFile + \\r
' -s ' + \\r
'EFI_SECTION_FIRMWARE_VOLUME_IMAGE ' + \\r
import RuleComplexFile\r
from EfiSection import EfiSection\r
import StringIO\r
+import Common.TargetTxtClassObject\r
\r
versionNumber = "1.0"\r
__version__ = "%prog Version " + versionNumber\r
sys.exit(1)\r
else:\r
workspace = options.workspace\r
+ GenFdsGlobalVariable.WorkSpaceDir = workspace\r
if (options.debug):\r
print "Using Workspace:", workspace\r
\r
if (options.activePlatform):\r
activePlatform = options.activePlatform\r
else :\r
- activePlatform = None\r
+ Target = Common.TargetTxtClassObject.TargetTxtDict(GenFdsGlobalVariable.WorkSpaceDir)\r
+ activePlatform = Target.TargetTxtDictionary['ACTIVE_PLATFORM']\r
+ \r
+ GenFdsGlobalVariable.ActivePlatform = activePlatform\r
+\r
\r
if (options.outputDir):\r
outputDir = options.outputDir\r
\r
"""call workspace build create database"""\r
os.environ["WORKSPACE"] = workspace\r
- buildWorkSpace = Common.EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform)\r
+ buildWorkSpace = Common.EdkIIWorkspaceBuild.WorkspaceBuild(activePlatform, workspace)\r
+ buildWorkSpace.GenBuildDatabase()\r
\r
"""Call GenFds"""\r
GenFds.GenFd(outputDir, fdfParser, buildWorkSpace, archList)\r
DefaultRule = None\r
ArchList = None\r
VtfDict = {}\r
- \r
+ ActivePlatform = None\r
def ExtendMarco (String):\r
return String\r
\r
GenFdsGlobalVariable.WorkSpace = WorkSpace\r
GenFdsGlobalVariable.FvDir = os.path.join(GenFdsGlobalVariable.OuputDir, 'Fv')\r
GenFdsGlobalVariable.FfsDir = os.path.join(GenFdsGlobalVariable.FvDir, 'Ffs')\r
- GenFdsGlobalVariable.WorkSpaceDir = GenFdsGlobalVariable.WorkSpace.Workspace.WorkspaceDir\r
if ArchList != None:\r
GenFdsGlobalVariable.ArchList = ArchList\r
\r
if not os.path.exists(GenFdsGlobalVariable.FvDir) :\r
os.makedirs(GenFdsGlobalVariable.FvDir)\r
- \r
+ \r
def SetDefaultRule (Rule) :\r
GenFdsGlobalVariable.DefaultRule = Rule\r
\r
def ReplaceWorkspaceMarco(String):\r
Str = String.replace('$(WORKSPACE)', GenFdsGlobalVariable.WorkSpaceDir)\r
- Str = os.path.realpath(Str)\r
+ if os.path.exists(Str):\r
+ Str = os.path.realpath(Str)\r
+ else:\r
+ Str = os.path.join(GenFdsGlobalVariable.WorkSpaceDir, String)\r
return Str\r
\r
def CallExternalTool (cmd, errorMess):\r
#\r
# Call GenFv tool\r
#\r
+ \r
self.FvAddress = int(BaseAddress, 16) + self.Offset\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, vtfDict)\r
+ BinFile = open (FileName, 'r+b')\r
+ FvBuffer = StringIO.StringIO('')\r
+ FvBuffer.write(BinFile.read())\r
+ if FvBuffer.len > Size:\r
+ raise Exception ("Size of Fv (%s) is large than Region Size ", self.RegionData)\r
+ elif FvBuffer.len < Size :\r
+ raise Exception ("Size of Fv (%s) is less than Region Size ", self.RegionData)\r
+ FvBuffer.close()\r
FvBinDict[self.RegionData.upper()] = FileName\r
\r
if self.RegionType == 'FILE':\r