X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FGenFds%2FFdfParser.py;h=08429cd72affc0fe2af6335fdb5965e90603ec9f;hp=12d4f2bb73738fbbd155e7ad1cb42a62463a0308;hb=4d603daa3a2276d98ac6749d1db8e327ff7c1f5f;hpb=4fa7b3301ef31f2787b9d0bde6694203a67b3ff2
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index 12d4f2bb73..08429cd72a 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -1,7 +1,7 @@
## @file
# parse FDF file
#
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.
#
# This program and the accompanying materials
@@ -52,12 +52,15 @@ import Common.GlobalData as GlobalData
from Common.Expression import *
from Common import GlobalData
from Common.String import ReplaceMacro
-
+import uuid
from Common.Misc import tdict
-
-import re
+from Common.MultipleWorkspace import MultipleWorkspace as mws
import Common.LongFilePathOs as os
from Common.LongFilePathSupport import OpenLongFilePath as open
+from Capsule import EFI_CERT_TYPE_PKCS7_GUID
+from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
+from Common.RangeExpression import RangeExpression
+from Common.FdfParserLite import FileExtensionPattern
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
@@ -106,7 +109,7 @@ def GetRealFileLine (File, Line):
if Profile.IsLineInFile(Line):
return Profile.GetLineInFile(Line)
elif Line >= Profile.InsertStartLineNumber and Profile.Level == 1:
- InsertedLines += Profile.GetTotalLines()
+ InsertedLines += Profile.GetTotalLines()
return (File, Line - InsertedLines)
@@ -134,21 +137,6 @@ class Warning (Exception):
def __str__(self):
return self.Message
-## The MACRO class that used to record macro value data when parsing include file
-#
-#
-class MacroProfile :
- ## The constructor
- #
- # @param self The object pointer
- # @param FileName The file that to be parsed
- #
- def __init__(self, FileName, Line):
- self.FileName = FileName
- self.DefinedAtLine = Line
- self.MacroName = None
- self.MacroValue = None
-
## The Include file content class that used to record file data when parsing include file
#
# May raise Exception when opening file.
@@ -166,6 +154,10 @@ class IncludeFileProfile :
fsock = open(FileName, "rb", 0)
try:
self.FileLinesList = fsock.readlines()
+ for index, line in enumerate(self.FileLinesList):
+ if not line.endswith('\n'):
+ self.FileLinesList[index] += '\n'
+
finally:
fsock.close()
@@ -181,7 +173,7 @@ class IncludeFileProfile :
TotalLines = self.InsertAdjust + len(self.FileLinesList)
for Profile in self.IncludeFileList:
- TotalLines += Profile.GetTotalLines()
+ TotalLines += Profile.GetTotalLines()
return TotalLines
@@ -232,6 +224,7 @@ class FileProfile :
self.PcdDict = {}
self.InfList = []
+ self.InfDict = {'ArchTBD':[]}
# ECC will use this Dict and List information
self.PcdFileLineDict = {}
self.InfFileLineList = []
@@ -618,27 +611,46 @@ class FdfParser:
def PreprocessIncludeFile(self):
# nested include support
Processed = False
+ MacroDict = {}
while self.__GetNextToken():
- if self.__Token == '!include':
+ if self.__Token == '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)
+ Value = self.__GetExpression()
+ MacroDict[Macro] = Value
+
+ elif self.__Token == '!include':
Processed = True
IncludeLine = self.CurrentLineNumber
IncludeOffset = self.CurrentOffsetWithinLine - len('!include')
if not self.__GetNextToken():
raise Warning("expected include file name", self.FileName, self.CurrentLineNumber)
IncFileName = self.__Token
- __IncludeMacros = {}
- for Macro in ['WORKSPACE', 'ECP_SOURCE', 'EFI_SOURCE', 'EDK_SOURCE']:
+ PreIndex = 0
+ StartPos = IncFileName.find('$(', PreIndex)
+ EndPos = IncFileName.find(')', StartPos+2)
+ while StartPos != -1 and EndPos != -1:
+ Macro = IncFileName[StartPos+2 : EndPos]
MacroVal = self.__GetMacroValue(Macro)
- if MacroVal:
- __IncludeMacros[Macro] = MacroVal
+ if not MacroVal:
+ if Macro in MacroDict:
+ MacroVal = MacroDict[Macro]
+ if MacroVal != None:
+ IncFileName = IncFileName.replace('$(' + Macro + ')', MacroVal, 1)
+ if MacroVal.find('$(') != -1:
+ PreIndex = StartPos
+ else:
+ PreIndex = StartPos + len(MacroVal)
+ else:
+ raise Warning("The Macro %s is not defined" %Macro, self.FileName, self.CurrentLineNumber)
+ StartPos = IncFileName.find('$(', PreIndex)
+ EndPos = IncFileName.find(')', StartPos+2)
- try:
- IncludedFile = NormPath(ReplaceMacro(IncFileName, __IncludeMacros, RaiseError=True))
- except:
- raise Warning("only these system environment variables are permitted to start the path of the included file: "
- "$(WORKSPACE), $(ECP_SOURCE), $(EFI_SOURCE), $(EDK_SOURCE)",
- self.FileName, self.CurrentLineNumber)
+ IncludedFile = NormPath(IncFileName)
#
# First search the include file under the same directory as FDF file
#
@@ -900,6 +912,13 @@ class FdfParser:
MacroDict.update(GlobalData.gGlobalDefines)
MacroDict.update(GlobalData.gCommandLineDefines)
+ if GlobalData.BuildOptionPcd:
+ for Item in GlobalData.BuildOptionPcd:
+ if type(Item) is tuple:
+ continue
+ PcdName, TmpValue = Item.split("=")
+ TmpValue = BuildOptionValue(TmpValue, {})
+ MacroDict[PcdName.strip()] = TmpValue
# Highest priority
return MacroDict
@@ -1117,13 +1136,32 @@ class FdfParser:
if not self.__GetNextToken():
return False
- p = re.compile('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')
- if p.match(self.__Token) != None:
+ if RangeExpression.RegGuidPattern.match(self.__Token) != None:
return True
else:
self.__UndoToken()
return False
+ def __Verify(self, Name, Value, Scope):
+ if Scope in ['UINT64', 'UINT8']:
+ ValueNumber = 0
+ try:
+ if Value.upper().startswith('0X'):
+ ValueNumber = int (Value, 16)
+ else:
+ ValueNumber = int (Value)
+ except:
+ EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name)
+ if ValueNumber < 0:
+ EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be set to negative value for %s." % Name)
+ if Scope == 'UINT64':
+ if ValueNumber >= 0x10000000000000000:
+ EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name)
+ if Scope == 'UINT8':
+ if ValueNumber >= 0x100:
+ EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name)
+ return True
+
## __UndoToken() method
#
# Go back one token unit in file buffer
@@ -1363,25 +1401,10 @@ class FdfParser:
try:
self.Preprocess()
- while self.__GetFd():
- pass
-
- while self.__GetFv():
- pass
-
- while self.__GetFmp():
- pass
-
- while self.__GetCapsule():
- pass
-
- while self.__GetVtf():
- pass
-
- while self.__GetRule():
- pass
-
- while self.__GetOptionRom():
+ #
+ # Keep processing sections of the FDF until no new sections or a syntax error is found
+ #
+ while self.__GetFd() or self.__GetFv() or self.__GetFmp() or self.__GetCapsule() or self.__GetVtf() or self.__GetRule() or self.__GetOptionRom():
pass
except Warning, X:
@@ -1398,6 +1421,20 @@ class FdfParser:
% (FileLineTuple[1], self.CurrentOffsetWithinLine + 1, self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :].rstrip('\n').rstrip('\r'))
raise
+ ## SectionParser() method
+ #
+ # Parse the file section info
+ # Exception will be raised if syntax error found
+ #
+ # @param self The object pointer
+ # @param section The section string
+
+ def SectionParser(self, section):
+ S = section.upper()
+ if not S.startswith("[DEFINES") and not S.startswith("[FD.") and not S.startswith("[FV.") and not S.startswith("[CAPSULE.") \
+ and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM.") and not S.startswith('[FMPPAYLOAD.'):
+ raise Warning("Unknown section or section appear sequence error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.], [FMPPAYLOAD.])", self.FileName, self.CurrentLineNumber)
+
## __GetDefines() method
#
# Get Defines section contents and store its data into AllMacrosList
@@ -1413,9 +1450,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[DEFINES"):
- if not S.startswith("[FD.") and not S.startswith("[FV.") and not S.startswith("[CAPSULE.") \
- and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -1931,7 +1966,7 @@ class FdfParser:
raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
RegionObj.RegionType = "FV"
- RegionObj.RegionDataList.append(self.__Token)
+ RegionObj.RegionDataList.append((self.__Token).upper())
while self.__IsKeyword( "FV"):
@@ -1941,7 +1976,7 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected FV name", self.FileName, self.CurrentLineNumber)
- RegionObj.RegionDataList.append(self.__Token)
+ RegionObj.RegionDataList.append((self.__Token).upper())
## __GetRegionCapType() method
#
@@ -2108,9 +2143,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[FV."):
- if not S.startswith('[FMPPAYLOAD.') and not S.startswith("[CAPSULE.") \
- and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -2271,7 +2304,7 @@ class FdfParser:
"WRITE_DISABLED_CAP", "WRITE_STATUS", "READ_ENABLED_CAP", \
"READ_DISABLED_CAP", "READ_STATUS", "READ_LOCK_CAP", \
"READ_LOCK_STATUS", "WRITE_LOCK_CAP", "WRITE_LOCK_STATUS", \
- "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT"):
+ "WRITE_POLICY_RELIABLE", "WEAK_ALIGNMENT", "FvUsedSizeEnable"):
self.__UndoToken()
return False
@@ -2325,7 +2358,7 @@ class FdfParser:
def __GetFvExtEntryStatement(self, FvObj):
- if not self.__IsKeyword( "FV_EXT_ENTRY"):
+ if not (self.__IsKeyword( "FV_EXT_ENTRY") or self.__IsKeyword( "FV_EXT_ENTRY_TYPE")):
return False
if not self.__IsKeyword ("TYPE"):
@@ -2446,6 +2479,8 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("expected INF file path", self.FileName, self.CurrentLineNumber)
ffsInf.InfFileName = self.__Token
+ if not ffsInf.InfFileName.endswith('.inf'):
+ raise Warning("expected .inf file path", self.FileName, self.CurrentLineNumber)
ffsInf.CurrentLineNum = self.CurrentLineNumber
ffsInf.CurrentLineContent = self.__CurrentLine()
@@ -2463,6 +2498,13 @@ class FdfParser:
self.Profile.InfList.append(ffsInf.InfFileName)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.InfFileLineList.append(FileLineTuple)
+ if ffsInf.UseArch:
+ if ffsInf.UseArch not in self.Profile.InfDict:
+ self.Profile.InfDict[ffsInf.UseArch] = [ffsInf.InfFileName]
+ else:
+ self.Profile.InfDict[ffsInf.UseArch].append(ffsInf.InfFileName)
+ else:
+ self.Profile.InfDict['ArchTBD'].append(ffsInf.InfFileName)
if self.__IsToken('|'):
if self.__IsKeyword('RELOCS_STRIPPED'):
@@ -2716,14 +2758,16 @@ class FdfParser:
#
def __GetRAWData(self, FfsFileObj, MacroDict = {}):
FfsFileObj.FileName = []
- FfsFileObj.Alignment = []
- AlignDict = {"Auto":1, "8":8, "16":16, "32":32, "64":64, "128":128, "512":512, "1K":1024, "4K":4096, "32K":32768, "64K":65536}
+ FfsFileObj.SubAlignment = []
while True:
AlignValue = None
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
- AlignValue = AlignValue = AlignDict[self.__Token]
+ #For FFS, Auto is default option same to ""
+ if not self.__Token == "Auto":
+ AlignValue = self.__Token
if not self.__GetNextToken():
raise Warning("expected Filename value", self.FileName, self.CurrentLineNumber)
@@ -2735,14 +2779,14 @@ class FdfParser:
self.__VerifyFile(FileName)
File = PathClass(NormPath(FileName), GenFdsGlobalVariable.WorkSpaceDir)
FfsFileObj.FileName.append(File.Path)
- FfsFileObj.Alignment.append(AlignValue)
+ FfsFileObj.SubAlignment.append(AlignValue)
if self.__IsToken( "}"):
self.__UndoToken()
break
- if len(FfsFileObj.Alignment) == 1:
- FfsFileObj.Alignment = FfsFileObj.Alignment[0]
+ if len(FfsFileObj.SubAlignment) == 1:
+ FfsFileObj.SubAlignment = FfsFileObj.SubAlignment[0]
if len(FfsFileObj.FileName) == 1:
FfsFileObj.FileName = FfsFileObj.FileName[0]
@@ -2778,7 +2822,8 @@ class FdfParser:
FfsFileObj.CheckSum = True
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
#For FFS, Auto is default option same to ""
if not self.__Token == "Auto":
@@ -2849,7 +2894,8 @@ class FdfParser:
AlignValue = None
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
AlignValue = self.__Token
@@ -3138,7 +3184,8 @@ class FdfParser:
AlignValue = None
if self.__GetAlignment():
- if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
AlignValue = self.__Token
@@ -3152,9 +3199,8 @@ class FdfParser:
if not self.__GetNextToken():
return False
S = self.__Token.upper()
- if not S.startswith("[FMPPAYLOAD."):
- if not S.startswith("[CAPSULE.") and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [FmpPayload.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ if S.startswith("[") and not S.startswith("[FMPPAYLOAD."):
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -3172,7 +3218,7 @@ class FdfParser:
if not self.__GetNextToken():
raise Warning("The FMP payload section is empty!", self.FileName, self.CurrentLineNumber)
- FmpKeyList = ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', 'IMAGE_INDEX', 'HARDWARE_INSTANCE']
+ FmpKeyList = ['IMAGE_HEADER_INIT_VERSION', 'IMAGE_TYPE_ID', 'IMAGE_INDEX', 'HARDWARE_INSTANCE', 'CERTIFICATE_GUID', 'MONOTONIC_COUNT']
while self.__Token in FmpKeyList:
Name = self.__Token
FmpKeyList.remove(Name)
@@ -3180,32 +3226,52 @@ class FdfParser:
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if Name == 'IMAGE_TYPE_ID':
if not self.__GetNextGuid():
- raise Warning("expected GUID value for IMAGE_TYPE_ID", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected GUID value for IMAGE_TYPE_ID.", self.FileName, self.CurrentLineNumber)
FmpData.ImageTypeId = self.__Token
+ elif Name == 'CERTIFICATE_GUID':
+ if not self.__GetNextGuid():
+ raise Warning("expected GUID value for CERTIFICATE_GUID.", self.FileName, self.CurrentLineNumber)
+ FmpData.Certificate_Guid = self.__Token
+ if uuid.UUID(FmpData.Certificate_Guid) != EFI_CERT_TYPE_RSA2048_SHA256_GUID and uuid.UUID(FmpData.Certificate_Guid) != EFI_CERT_TYPE_PKCS7_GUID:
+ raise Warning("Only support EFI_CERT_TYPE_RSA2048_SHA256_GUID or EFI_CERT_TYPE_PKCS7_GUID for CERTIFICATE_GUID.", self.FileName, self.CurrentLineNumber)
else:
if not self.__GetNextToken():
raise Warning("expected value of %s" % Name, self.FileName, self.CurrentLineNumber)
Value = self.__Token
if Name == 'IMAGE_HEADER_INIT_VERSION':
- FmpData.Version = Value
+ if self.__Verify(Name, Value, 'UINT8'):
+ FmpData.Version = Value
elif Name == 'IMAGE_INDEX':
- FmpData.ImageIndex = Value
+ if self.__Verify(Name, Value, 'UINT8'):
+ FmpData.ImageIndex = Value
elif Name == 'HARDWARE_INSTANCE':
- FmpData.HardwareInstance = Value
+ if self.__Verify(Name, Value, 'UINT8'):
+ FmpData.HardwareInstance = Value
+ elif Name == 'MONOTONIC_COUNT':
+ if self.__Verify(Name, Value, 'UINT64'):
+ FmpData.MonotonicCount = Value
+ if FmpData.MonotonicCount.upper().startswith('0X'):
+ FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)
+ else:
+ FmpData.MonotonicCount = (long)(FmpData.MonotonicCount)
if not self.__GetNextToken():
break
else:
self.__UndoToken()
- if FmpKeyList:
- raise Warning("Missing keywords %s in FMP payload section" % ', '.join(FmpKeyList), self.FileName, self.CurrentLineNumber)
- ImageFile = self.__ParseRawFileStatement()
- if not ImageFile:
- raise Warning("Missing image file in FMP payload section", self.FileName, self.CurrentLineNumber)
- FmpData.ImageFile = ImageFile
- VendorCodeFile = self.__ParseRawFileStatement()
- if VendorCodeFile:
- FmpData.VendorCodeFile = VendorCodeFile
+ if (FmpData.MonotonicCount and not FmpData.Certificate_Guid) or (not FmpData.MonotonicCount and FmpData.Certificate_Guid):
+ EdkLogger.error("FdfParser", FORMAT_INVALID, "CERTIFICATE_GUID and MONOTONIC_COUNT must be work as a pair.")
+
+ # Only the IMAGE_TYPE_ID is required item
+ if FmpKeyList and 'IMAGE_TYPE_ID' in FmpKeyList:
+ raise Warning("Missing keywords IMAGE_TYPE_ID in FMP payload section.", self.FileName, self.CurrentLineNumber)
+ # get the Image file and Vendor code file
+ self.__GetFMPCapsuleData(FmpData)
+ if not FmpData.ImageFile:
+ raise Warning("Missing image file in FMP payload section.", self.FileName, self.CurrentLineNumber)
+ # check whether more than one Vendor code file
+ if len(FmpData.VendorCodeFile) > 1:
+ raise Warning("At most one Image file and one Vendor code file are allowed in FMP payload section.", self.FileName, self.CurrentLineNumber)
self.Profile.FmpPayloadDict[FmpUiName] = FmpData
return True
@@ -3224,8 +3290,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[CAPSULE."):
- if not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -3338,6 +3403,22 @@ class FdfParser:
if not (IsInf or IsFile or IsFv or IsFd or IsAnyFile or IsAfile or IsFmp):
break
+ ## __GetFMPCapsuleData() method
+ #
+ # Get capsule data for FMP capsule
+ #
+ # @param self The object pointer
+ # @param Obj for whom capsule data are got
+ #
+ def __GetFMPCapsuleData(self, Obj):
+
+ while True:
+ IsFv = self.__GetFvStatement(Obj, True)
+ IsFd = self.__GetFdStatement(Obj, True)
+ IsAnyFile = self.__GetAnyFileStatement(Obj, True)
+ if not (IsFv or IsFd or IsAnyFile):
+ break
+
## __GetFvStatement() method
#
# Get FV for capsule
@@ -3347,7 +3428,7 @@ class FdfParser:
# @retval True Successfully find a FV statement
# @retval False Not able to find a FV statement
#
- def __GetFvStatement(self, CapsuleObj):
+ def __GetFvStatement(self, CapsuleObj, FMPCapsule = False):
if not self.__IsKeyword("FV"):
return False
@@ -3363,7 +3444,13 @@ class FdfParser:
CapsuleFv = CapsuleData.CapsuleFv()
CapsuleFv.FvName = self.__Token
- CapsuleObj.CapsuleDataList.append(CapsuleFv)
+ if FMPCapsule:
+ if not CapsuleObj.ImageFile:
+ CapsuleObj.ImageFile.append(CapsuleFv)
+ else:
+ CapsuleObj.VendorCodeFile.append(CapsuleFv)
+ else:
+ CapsuleObj.CapsuleDataList.append(CapsuleFv)
return True
## __GetFdStatement() method
@@ -3375,7 +3462,7 @@ class FdfParser:
# @retval True Successfully find a FD statement
# @retval False Not able to find a FD statement
#
- def __GetFdStatement(self, CapsuleObj):
+ def __GetFdStatement(self, CapsuleObj, FMPCapsule = False):
if not self.__IsKeyword("FD"):
return False
@@ -3391,22 +3478,29 @@ class FdfParser:
CapsuleFd = CapsuleData.CapsuleFd()
CapsuleFd.FdName = self.__Token
- CapsuleObj.CapsuleDataList.append(CapsuleFd)
+ if FMPCapsule:
+ if not CapsuleObj.ImageFile:
+ CapsuleObj.ImageFile.append(CapsuleFd)
+ else:
+ CapsuleObj.VendorCodeFile.append(CapsuleFd)
+ else:
+ CapsuleObj.CapsuleDataList.append(CapsuleFd)
return True
def __GetFmpStatement(self, CapsuleObj):
- if not self.__IsKeyword("FMP"):
- return False
+ if not self.__IsKeyword("FMP_PAYLOAD"):
+ if not self.__IsKeyword("FMP"):
+ return False
- if not self.__IsKeyword("PAYLOAD"):
- self.__UndoToken()
- return False
+ if not self.__IsKeyword("PAYLOAD"):
+ self.__UndoToken()
+ return False
if not self.__IsToken("="):
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
- raise Warning("expected payload name after FMP PAYLOAD =", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected payload name after FMP_PAYLOAD =", self.FileName, self.CurrentLineNumber)
Payload = self.__Token.upper()
if Payload not in self.Profile.FmpPayloadDict:
raise Warning("This FMP Payload does not exist: %s" % self.__Token, self.FileName, self.CurrentLineNumber)
@@ -3428,9 +3522,11 @@ class FdfParser:
raise Warning("expected File name", self.FileName, self.CurrentLineNumber)
AnyFileName = self.__Token
- AnyFileName = GenFdsGlobalVariable.ReplaceWorkspaceMacro(AnyFileName)
- if not os.path.exists(AnyFileName):
- raise Warning("File %s not exists"%AnyFileName, self.FileName, self.CurrentLineNumber)
+ self.__VerifyFile(AnyFileName)
+
+ if not os.path.isabs(AnyFileName):
+ AnyFileName = mws.join(GenFdsGlobalVariable.WorkSpaceDir, AnyFileName)
+
return AnyFileName
## __GetAnyFileStatement() method
@@ -3442,14 +3538,20 @@ class FdfParser:
# @retval True Successfully find a Anyfile statement
# @retval False Not able to find a AnyFile statement
#
- def __GetAnyFileStatement(self, CapsuleObj):
+ def __GetAnyFileStatement(self, CapsuleObj, FMPCapsule = False):
AnyFileName = self.__ParseRawFileStatement()
if not AnyFileName:
return False
CapsuleAnyFile = CapsuleData.CapsuleAnyFile()
CapsuleAnyFile.FileName = AnyFileName
- CapsuleObj.CapsuleDataList.append(CapsuleAnyFile)
+ if FMPCapsule:
+ if not CapsuleObj.ImageFile:
+ CapsuleObj.ImageFile.append(CapsuleAnyFile)
+ else:
+ CapsuleObj.VendorCodeFile.append(CapsuleAnyFile)
+ else:
+ CapsuleObj.CapsuleDataList.append(CapsuleAnyFile)
return True
## __GetAfileStatement() method
@@ -3508,8 +3610,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[RULE."):
- if not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
self.__UndoToken()
@@ -3574,7 +3675,7 @@ class FdfParser:
"DXE_SMM_DRIVER", "DXE_RUNTIME_DRIVER", \
"UEFI_DRIVER", "UEFI_APPLICATION", "USER_DEFINED", "DEFAULT", "BASE", \
"SECURITY_CORE", "COMBINED_PEIM_DRIVER", "PIC_PEIM", "RELOCATABLE_PEIM", \
- "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE"):
+ "PE32_PEIM", "BS_DRIVER", "RT_DRIVER", "SAL_RT_DRIVER", "APPLICATION", "ACPITABLE", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
raise Warning("Unknown Module type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
return self.__Token
@@ -3587,12 +3688,11 @@ class FdfParser:
#
def __GetFileExtension(self):
if not self.__IsToken("."):
- raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
+ raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)
Ext = ""
if self.__GetNextToken():
- Pattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')
- if Pattern.match(self.__Token):
+ if FileExtensionPattern.match(self.__Token):
Ext = self.__Token
return '.' + Ext
else:
@@ -3618,7 +3718,7 @@ class FdfParser:
Type = self.__Token.strip().upper()
if Type not in ("RAW", "FREEFORM", "SEC", "PEI_CORE", "PEIM",\
- "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM", "SMM_CORE"):
+ "PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM", "SMM_CORE", "MM_STANDALONE", "MM_CORE_STANDALONE"):
raise Warning("Unknown FV type '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
if not self.__IsToken("="):
@@ -3675,7 +3775,8 @@ class FdfParser:
AlignValue = ""
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
#For FFS, Auto is default option same to ""
if not self.__Token == "Auto":
@@ -3724,7 +3825,8 @@ class FdfParser:
SectAlignment = ""
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
@@ -3803,7 +3905,8 @@ class FdfParser:
FvImageSectionObj.FvFileType = self.__Token
if self.__GetAlignment():
- if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
FvImageSectionObj.Alignment = self.__Token
@@ -3870,7 +3973,8 @@ class FdfParser:
EfiSectionObj.BuildNum = self.__Token
if self.__GetAlignment():
- if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K"):
+ if self.__Token not in ("Auto", "8", "16", "32", "64", "128", "512", "1K", "4K", "32K" ,"64K", "128K",
+ "256K", "512K", "1M", "2M", "4M", "8M", "16M"):
raise Warning("Incorrect alignment '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
if self.__Token == 'Auto' and (not SectionName == 'PE32') and (not SectionName == 'TE'):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
@@ -4085,8 +4189,7 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[VTF."):
- if not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
self.__UndoToken()
return False
@@ -4292,7 +4395,9 @@ class FdfParser:
S = self.__Token.upper()
if S.startswith("[") and not S.startswith("[OPTIONROM."):
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
+ self.SectionParser(S)
+ self.__UndoToken()
+ return False
self.__UndoToken()
if not self.__IsToken("[OptionRom.", True):
@@ -4345,6 +4450,13 @@ class FdfParser:
self.Profile.InfList.append(ffsInf.InfFileName)
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)
self.Profile.InfFileLineList.append(FileLineTuple)
+ if ffsInf.UseArch:
+ if ffsInf.UseArch not in self.Profile.InfDict:
+ self.Profile.InfDict[ffsInf.UseArch] = [ffsInf.InfFileName]
+ else:
+ self.Profile.InfDict[ffsInf.UseArch].append(ffsInf.InfFileName)
+ else:
+ self.Profile.InfDict['ArchTBD'].append(ffsInf.InfFileName)
self.__GetOptRomOverrides (ffsInf)
@@ -4691,6 +4803,10 @@ class FdfParser:
return False
+ def GetAllIncludedFile (self):
+ global AllIncludeFileList
+ return AllIncludeFileList
+
if __name__ == "__main__":
import sys
try: