import RuleComplexFile\r
from CommonDataClass.FdfClass import FfsInfStatementClassObject\r
from Common.MultipleWorkspace import MultipleWorkspace as mws\r
-from Common.String import *\r
+from Common.StringUtils import *\r
from Common.Misc import PathClass\r
from Common.Misc import GuidStructureByteArrayToGuidString\r
from Common.Misc import ProcessDuplicatedInf\r
from DepexSection import DepexSection\r
from Common.Misc import SaveFileOnChange\r
from Common.Expression import *\r
+from Common.DataType import *\r
\r
## generate FFS from INF\r
#\r
#\r
class FfsInfStatement(FfsInfStatementClassObject):\r
- ## The mapping dictionary from datum type to its maximum number.\r
- _MAX_SIZE_TYPE = {"BOOLEAN":0x01, "UINT8":0xFF, "UINT16":0xFFFF, "UINT32":0xFFFFFFFF, "UINT64":0xFFFFFFFFFFFFFFFF}\r
## The constructor\r
#\r
# @param self The object pointer\r
self.FinalTargetSuffixMap.setdefault(os.path.splitext(File)[1], []).append(File)\r
\r
# Check if current INF module has DEPEX\r
- if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != "USER_DEFINED" \\r
+ if '.depex' not in self.FinalTargetSuffixMap and self.InfModule.ModuleType != SUP_MODULE_USER_DEFINED \\r
and not self.InfModule.DxsFile and not self.InfModule.LibraryClass:\r
ModuleType = self.InfModule.ModuleType\r
PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, self.CurrentArch, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
self.ShadowFromInfFile = Inf.Shadow\r
\r
else:\r
- Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON', GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
+ Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
self.BaseName = Inf.BaseName\r
self.ModuleGuid = Inf.Guid\r
self.ModuleType = Inf.ModuleType\r
if len(self.SourceFileList) != 0 and not self.InDsc:\r
EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))\r
\r
- if self.ModuleType == 'SMM_CORE' and int(self.PiSpecVersion, 16) < 0x0001000A:\r
+ if self.ModuleType == SUP_MODULE_SMM_CORE and int(self.PiSpecVersion, 16) < 0x0001000A:\r
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) \r
\r
- if self.ModuleType == 'MM_CORE_STANDALONE' and int(self.PiSpecVersion, 16) < 0x00010032:\r
+ if self.ModuleType == SUP_MODULE_MM_CORE_STANDALONE and int(self.PiSpecVersion, 16) < 0x00010032:\r
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "MM_CORE_STANDALONE module type can't be used in the module with PI_SPECIFICATION_VERSION less than 0x00010032", File=self.InfFileName)\r
\r
if Inf._Defs is not None and len(Inf._Defs) > 0:\r
Pcd = InfPcds[PcdKey]\r
if not hasattr(Pcd, 'Offset'):\r
continue\r
- if Pcd.Type != 'PatchableInModule':\r
+ if Pcd.Type != TAB_PCDS_PATCHABLE_IN_MODULE:\r
continue\r
# Override Patchable PCD value by the value from DSC\r
PatchPcd = None\r
try:\r
Pcd.InfDefaultValue = ValueExpressionEx(Pcd.InfDefaultValue, Pcd.DatumType, Platform._GuidDict)(True)\r
except BadExpression:\r
- EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName)\r
+ EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue), File=self.InfFileName)\r
\r
# Check value, if value are equal, no need to patch\r
- if Pcd.DatumType == "VOID*":\r
- if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']:\r
+ if Pcd.DatumType == TAB_VOID:\r
+ if Pcd.InfDefaultValue == DefaultValue or not DefaultValue:\r
continue\r
# Get the string size from FDF or DSC\r
if DefaultValue[0] == 'L':\r
if DscOverride:\r
Pcd.MaxDatumSize = PatchPcd.MaxDatumSize\r
# If no defined the maximum size in DSC, try to get current size from INF\r
- if Pcd.MaxDatumSize in ['', None]:\r
+ if not Pcd.MaxDatumSize:\r
Pcd.MaxDatumSize = str(len(Pcd.InfDefaultValue.split(',')))\r
else:\r
Base1 = Base2 = 10\r
except:\r
continue\r
# Check the Pcd size and data type\r
- if Pcd.DatumType == "VOID*":\r
+ if Pcd.DatumType == TAB_VOID:\r
if int(MaxDatumSize) > int(Pcd.MaxDatumSize):\r
EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \\r
% (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize)))\r
else:\r
- if PcdValueInDscOrFdf > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType] \\r
- or PcdValueInImg > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType]:\r
+ if PcdValueInDscOrFdf > MAX_VAL_TYPE[Pcd.DatumType] \\r
+ or PcdValueInImg > MAX_VAL_TYPE[Pcd.DatumType]:\r
EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %s type PCD '%s.%s' doesn't match its data type." \\r
% (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
self.PatchPcds.append((Pcd, DefaultValue))\r
#\r
# Only patch file if FileType is PE32 or ModuleType is USER_DEFINED\r
# \r
- if FileType != 'PE32' and self.ModuleType != "USER_DEFINED":\r
+ if FileType != BINARY_FILE_TYPE_PE32 and self.ModuleType != SUP_MODULE_USER_DEFINED:\r
return EfiFile\r
\r
#\r
\r
self.__InfParse__(Dict)\r
Arch = self.GetCurrentArch()\r
- SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir , self.InfFileName);\r
+ SrcFile = mws.join( GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName);\r
DestFile = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')\r
\r
SrcFileDir = "."\r
#\r
# Convert Fv File Type for PI1.1 SMM driver.\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
if Rule.FvFileType == 'DRIVER':\r
Rule.FvFileType = 'SMM'\r
#\r
# Framework SMM Driver has no SMM FV file type\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:\r
- if Rule.FvFileType == 'SMM' or Rule.FvFileType == 'SMM_CORE':\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:\r
+ if Rule.FvFileType == 'SMM' or Rule.FvFileType == SUP_MODULE_SMM_CORE:\r
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM or SMM_CORE FV file type", File=self.InfFileName)\r
#\r
# For the rule only has simpleFile\r
\r
RuleName = 'RULE' + \\r
'.' + \\r
- 'COMMON' + \\r
+ TAB_COMMON + \\r
'.' + \\r
self.ModuleType.upper()\r
\r
# the file name FILE_GUIDmodule.inf, then PlatformDataBase.Modules use FILE_GUIDmodule.inf as key,\r
# but the path (self.MetaFile.Path) is the real path\r
#\r
- for key in PlatformDataBase.Modules.keys():\r
+ for key in PlatformDataBase.Modules:\r
if InfFileKey == str((PlatformDataBase.Modules[key]).MetaFile.Path):\r
DscArchList.append (Arch)\r
break\r
Arch = self.CurrentArch\r
\r
OutputPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],\r
- Arch ,\r
+ Arch,\r
ModulePath,\r
FileName,\r
'OUTPUT'\r
)\r
DebugPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],\r
- Arch ,\r
+ Arch,\r
ModulePath,\r
FileName,\r
'DEBUG'\r
#\r
# Convert Fv Section Type for PI1.1 SMM driver.\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
- if SectionType == 'DXE_DEPEX':\r
- SectionType = 'SMM_DEPEX'\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
+ if SectionType == BINARY_FILE_TYPE_DXE_DEPEX:\r
+ SectionType = BINARY_FILE_TYPE_SMM_DEPEX\r
#\r
# Framework SMM Driver has no SMM_DEPEX section type\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:\r
- if SectionType == 'SMM_DEPEX':\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:\r
+ if SectionType == BINARY_FILE_TYPE_SMM_DEPEX:\r
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)\r
NoStrip = True\r
- if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):\r
+ if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):\r
if self.KeepReloc is not None:\r
NoStrip = self.KeepReloc\r
elif Rule.KeepReloc is not None:\r
\r
SecNum = '%d' %Index\r
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \\r
- Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum\r
+ Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum\r
Index = Index + 1\r
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
File = GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)\r
\r
#Get PE Section alignment when align is set to AUTO\r
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):\r
ImageObj = PeImageClass (File)\r
if ImageObj.SectionAlignment < 0x400:\r
self.Alignment = str (ImageObj.SectionAlignment)\r
)\r
File = StrippedFile\r
\r
- if SectionType == 'TE':\r
+ if SectionType == BINARY_FILE_TYPE_TE:\r
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
GenFdsGlobalVariable.GenerateFirmwareImage(\r
TeFile,\r
else:\r
SecNum = '%d' %Index\r
GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \\r
- Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum\r
+ Ffs.Ffs.SectionSuffix[SectionType] + SUP_MODULE_SEC + SecNum\r
OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
GenSecInputFile = GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)\r
\r
#Get PE Section alignment when align is set to AUTO\r
- if self.Alignment == 'Auto' and (SectionType == 'PE32' or SectionType == 'TE'):\r
+ if self.Alignment == 'Auto' and (SectionType == BINARY_FILE_TYPE_PE32 or SectionType == BINARY_FILE_TYPE_TE):\r
ImageObj = PeImageClass (GenSecInputFile)\r
if ImageObj.SectionAlignment < 0x400:\r
self.Alignment = str (ImageObj.SectionAlignment)\r
)\r
GenSecInputFile = StrippedFile\r
\r
- if SectionType == 'TE':\r
+ if SectionType == BINARY_FILE_TYPE_TE:\r
TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
GenFdsGlobalVariable.GenerateFirmwareImage(\r
TeFile,\r
# @retval string File name of the generated section file\r
#\r
def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, IsMakefile = False):\r
- if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):\r
+ if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM):\r
if Rule.KeepReloc is not None:\r
self.KeepRelocFromRule = Rule.KeepReloc\r
SectFiles = []\r
#\r
# Convert Fv Section Type for PI1.1 SMM driver.\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
- if Sect.SectionType == 'DXE_DEPEX':\r
- Sect.SectionType = 'SMM_DEPEX'\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:\r
+ if Sect.SectionType == BINARY_FILE_TYPE_DXE_DEPEX:\r
+ Sect.SectionType = BINARY_FILE_TYPE_SMM_DEPEX\r
#\r
# Framework SMM Driver has no SMM_DEPEX section type\r
#\r
- if self.ModuleType == 'DXE_SMM_DRIVER' and int(self.PiSpecVersion, 16) < 0x0001000A:\r
- if Sect.SectionType == 'SMM_DEPEX':\r
+ if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) < 0x0001000A:\r
+ if Sect.SectionType == BINARY_FILE_TYPE_SMM_DEPEX:\r
EdkLogger.error("GenFds", FORMAT_NOT_SUPPORTED, "Framework SMM module doesn't support SMM_DEPEX section type", File=self.InfFileName)\r
#\r
# process the inside FvImage from FvSection or GuidSection\r
Sect.FvParentAddr = FvParentAddr\r
\r
if Rule.KeyStringList != []:\r
- SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile = IsMakefile)\r
+ SectList, Align = Sect.GenSection(self.OutputPath, self.ModuleGuid, SecIndex, Rule.KeyStringList, self, IsMakefile = IsMakefile)\r
else :\r
- SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile = IsMakefile)\r
+ SectList, Align = Sect.GenSection(self.OutputPath, self.ModuleGuid, SecIndex, self.KeyStringList, self, IsMakefile = IsMakefile)\r
\r
if not HasGeneratedFlag:\r
UniVfrOffsetFileSection = "" \r
)\r
return FfsOutput\r
\r
- ## __GetGenFfsCmdParameter__() method\r
- #\r
- # Create parameter string for GenFfs\r
- #\r
- # @param Rule The rule object used to generate section\r
- # @retval tuple (FileType, Fixed, CheckSum, Alignment)\r
- #\r
- @staticmethod\r
- def __GetGenFfsCmdParameter__(Rule):\r
- result = tuple()\r
- result += ('-t', Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType])\r
- if Rule.Fixed != False:\r
- result += ('-x',)\r
- if Rule.CheckSum != False:\r
- result += ('-s',)\r
-\r
- if Rule.Alignment is not None and Rule.Alignment != '':\r
- result += ('-a', Rule.Alignment)\r
-\r
- return result\r
- \r
## __GetBuildOutputMapFileVfrUniInfo() method\r
#\r
# Find the offset of UNI/INF object offset in the EFI image file.\r
try :\r
SaveFileOnChange(UniVfrOffsetFileName, fStringIO.getvalue())\r
except:\r
- 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)\r
+ 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)\r
\r
fStringIO.close ()\r
\r