## @file
# parse FDF file
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import re
import Fd
import Region
import Fv
import AprioriSection
import FfsInfStatement
import FfsFileStatement
import VerSection
import UiSection
import FvImageSection
import DataSection
import DepexSection
import CompressSection
import GuidSection
import Capsule
import CapsuleData
import Rule
import RuleComplexFile
import RuleSimpleFile
import EfiSection
import Vtf
import ComponentStatement
import OptionRom
import OptRomInfStatement
import OptRomFileStatement
from Common.BuildToolError import *
from Common.Expression import *
import re
import os
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
##define T_CHAR_CR '\r'
##define T_CHAR_TAB '\t'
##define T_CHAR_LF '\n'
##define T_CHAR_SLASH '/'
##define T_CHAR_BACKSLASH '\\'
##define T_CHAR_DOUBLE_QUOTE '\"'
##define T_CHAR_SINGLE_QUOTE '\''
##define T_CHAR_STAR '*'
##define T_CHAR_HASH '#'
(' ', '\0', '\r', '\t', '\n', '/', '\\', '\"', '\'', '*', '#')
RegionSizePattern = re.compile("\s*(?P<base>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<size>(?:0x|0X)?[a-fA-F0-9]+)\s*")
ShortcutPcdPattern = re.compile("\s*\w+\s*=\s*(?P<value>(?:0x|0X)?[a-fA-F0-9]+)\s*\|\s*(?P<name>\w+\.\w+)\s*")
IncludeFileList = []
InsertedLines = 0
for Profile in IncludeFileList:
if Line >= Profile.InsertStartLineNumber and Line < Profile.InsertStartLineNumber + Profile.InsertAdjust + len(Profile.FileLinesList):
## The exception class that used to report error messages when parsing FDF
#
# Currently the "ToolName" is set to be "FDF Parser".
#
## The constructor
#
# @param self The object pointer
# @param Str The message to record
# @param File The FDF name
# @param Line The Line number that error occurs
#
## 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
#
self.MacroValue = None
## The Include file content class that used to record file data when parsing include file
#
# May raise Exception when opening file.
#
class IncludeFileProfile :
## The constructor
#
# @param self The object pointer
# @param FileName The file that to be parsed
#
self.FileLinesList = []
try:
try:
finally:
except:
self.InsertStartLineNumber = None
## The FDF content class that used to record file data when parsing FDF
#
# May raise Exception when opening file.
#
class FileProfile :
## The constructor
#
# @param self The object pointer
# @param FileName The file that to be parsed
#
self.FileLinesList = []
try:
try:
finally:
except:
# ECC will use this Dict and List information
self.PcdFileLineDict = {}
self.InfFileLineList = []
self.CapsuleDict = {}
self.OptRomDict = {}
## The syntax parser for FDF
#
# PreprocessFile method should be called prior to ParseFile
# CycleReferenceCheck method can detect cycles in FDF contents
#
# GetNext*** procedures mean these procedures will get next token first, then make judgement.
# Get*** procedures mean these procedures will make judgement on current token only.
#
class FdfParser:
## The constructor
#
# @param self The object pointer
# @param FileName The file that to be parsed
#
self.CurrentFdName = None
self.CurrentFvName = None
# Used to section info
self.__CurSection = []
# Key: [section name, UI name, arch]
# Value: {MACRO_NAME : MACRO_VALUE}
self.__WipeOffArea = []
## __IsWhiteSpace() method
#
# Whether char at current FileBufferPos is whitespace
#
# @param self The object pointer
# @param Char The char to test
# @retval True The char is a kind of white space
# @retval False The char is NOT a kind of white space
#
return True
else:
return False
## __SkipWhiteSpace() method
#
# Skip white spaces from current char, return number of chars skipped
#
# @param self The object pointer
# @retval Count The number of chars skipped
#
Count = 0
while not self.__EndOfFile():
Count += 1
else:
return Count
## __EndOfFile() method
#
# Judge current buffer pos is at file end
#
# @param self The object pointer
# @retval True Current File buffer position is at file end
# @retval False Current File buffer position is NOT at file end
#
return True
return True
else:
return False
## __EndOfLine() method
#
# Judge current buffer pos is at line end
#
# @param self The object pointer
# @retval True Current File buffer position is at line end
# @retval False Current File buffer position is NOT at line end
#
return True
return True
else:
return False
## Rewind() method
#
# Reset file data buffer to the initial state
#
# @param self The object pointer
#
## __UndoOneChar() method
#
# Go back one char in the file buffer
#
# @param self The object pointer
# @retval True Successfully go back one char
# @retval False Not able to go back one char as file beginning reached
#
return False
else:
return True
## __GetOneChar() method
#
# Move forward one char in the file buffer
#
# @param self The object pointer
#
else:
## __CurrentChar() method
#
# Get the char pointed to by the file buffer pointer
#
# @param self The object pointer
# @retval Char Current char
#
## __NextChar() method
#
# Get the one char pass the char pointed to by the file buffer pointer
#
# @param self The object pointer
# @retval Char Next char
#
else:
## __SetCurrentCharValue() method
#
# Modify the value of current char
#
# @param self The object pointer
# @param Value The new value of current char
#
## __CurrentLine() method
#
# Get the list that contains current line contents
#
# @param self The object pointer
# @retval List current line contents
#
Offset += 1
return
Offset += 1
Offset = 0
Offset += 1
Line += 1
Offset = 0
Offset += 1
if not self.__GetNextToken():
raise Warning("Macro name expected(Please use '$(%(Token)s)' if '%(Token)s' is a macro.)" % {"Token" : MacroName},
if not self.__CurSection:
return
MacroDict = {}
else:
# Highest priority
if self.__CurSection:
]
# Lowest priority
return None
# [Defines]
# [FD.UiName]: use dummy instead if UI name is optional
# [FV.UiName]
# [Capsule.UiName]
# [Rule]: don't take rule section into account, macro is not allowed in this section
# [VTF.arch.UiName, arch]
# [OptionRom.DriverName]
self.__CurSection = []
return
if Item == 'DEFINES':
if Pos != -1:
## PreprocessFile() method
#
# Preprocess file contents, replace comments with spaces.
# In the end, rewind the file buffer pointer to the beginning
# BUGBUG: No !include statement processing contained in this procedure
# !include statement should be expanded at the same FileLinesList[CurrentLineNumber - 1]
#
# @param self The object pointer
#
# HashComment in quoted string " " is ignored.
while not self.__EndOfFile():
# meet new line, then no longer in a comment for // and '#'
if InComment and DoubleSlashComment:
if InComment and HashComment:
# check for */ comment end
elif InComment and not DoubleSlashComment and not HashComment and self.__CurrentChar() == T_CHAR_STAR and self.__NextChar() == T_CHAR_SLASH:
# set comments to spaces
elif InComment:
# check for // comment
elif self.__CurrentChar() == T_CHAR_SLASH and self.__NextChar() == T_CHAR_SLASH and not self.__EndOfLine():
# check for '#' comment
# check for /* comment start
else:
# restore from ListOfList to ListOfString
## PreprocessIncludeFile() method
#
# Preprocess file contents, replace !include statements with file contents.
# In the end, rewind the file buffer pointer to the beginning
#
# @param self The object pointer
#
while self.__GetNextToken():
if not self.__GetNextToken():
__IncludeMacros = {}
if MacroVal:
try:
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)",
#
# First search the include file under the same directory as FDF file
#
if ErrorCode != 0:
#
# Then search the include file under the same directory as DSC file
#
PlatformDir = ''
elif GlobalData.gActivePlatform:
if ErrorCode != 0:
#
# Also search file under the WORKSPACE directory
#
if ErrorCode != 0:
raise Warning("The include file does not exist under below directories: \n%s\n%s\n%s\n"%(os.path.dirname(self.FileName), PlatformDir, GlobalData.gWorkspace),
# list index of the insertion, note that line number is 'CurrentLine + 1'
# deal with remaining portions after "!include filename", if exists.
if self.__GetNextToken():
InsertAtLine += 1
# comment out the processed include file statement
return True
return False
return True
## PreprocessConditionalStatement() method
#
# Preprocess conditional statement.
# In the end, rewind the file buffer pointer to the beginning
#
# @param self The object pointer
#
# IfList is a stack of if branches with elements of list [Pos, CondSatisfied, BranchDetermined]
IfList = []
RegionLayoutLine = 0
ReplacedLine = -1
while self.__GetNextToken():
# Determine section name and the location dependent macro
continue
# Replace macros except in RULE section or out of section
PreIndex = 0
while StartPos != -1 and EndPos != -1 and self.__Token not in ['!ifdef', '!ifndef', '!if', '!elseif']:
if MacorValue != None:
else:
else:
continue
if not self.__CurSection:
raise Warning("macro cannot be defined in Rule section or out of section", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
self.__WipeOffArea.append(((DefineLine, DefineOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
self.__WipeOffArea.append(((SetLine, SetOffset), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
if CondLabel == '!if':
else:
if CondLabel == '!ifndef':
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
self.__WipeOffArea.append((ElseStartPos, (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
else:
else:
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
self.__WipeOffArea.append(((self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - len('!endif')), (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
else:
self.__WipeOffArea.append((IfList[-1][0], (self.CurrentLineNumber - 1, self.CurrentOffsetWithinLine - 1)))
elif not IfList: # Don't use PCDs inside conditional directive
# Don't try the same line twice
continue
if SetPcd:
continue
if not RegionSize:
continue
if not RegionSizeGuid:
continue
if IfList:
MacroDict = {}
# PCD macro
# Lowest priority
if self.__CurSection:
# Defines macro
if ScopeMacro:
# Section macro
]
if ScopeMacro:
# Highest priority
return MacroDict
if Op == 'eval':
try:
if Value:
else:
except WrnExpression, Excpt:
#
# Catch expression evaluation warning here. We need to report
# the precise number of line and return the evaluation result
#
raise Warning("Cannot use this PCD (%s) in an expression as"
" it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
" of the DSC file (%s), and it is currently defined in this section:"
else:
raise Warning("PCD (%s) is not defined in DSC file (%s)" % (Excpt.Pcd, GlobalData.gPlatformOtherPcds['DSCFILE']),
else:
else:
return Expression in MacroPcdDict
## __IsToken() method
#
# Check whether input string is found from current char position along
# If found, the string value is put into self.__Token
#
# @param self The object pointer
# @param String The string to search
# @param IgnoreCase Indicate case sensitive/non-sensitive search, default is case sensitive
# @retval True Successfully find string, file buffer pointer moved forward
# @retval False Not able to find string, file buffer pointer not changed
#
# Only consider the same line, no multi-line token allowed
index = -1
if IgnoreCase:
else:
if index == 0:
return True
return False
## __IsKeyword() method
#
# Check whether input keyword is found from current char position along, whole word only!
# If found, the string value is put into self.__Token
#
# @param self The object pointer
# @param Keyword The string to search
# @param IgnoreCase Indicate case sensitive/non-sensitive search, default is case sensitive
# @retval True Successfully find string, file buffer pointer moved forward
# @retval False Not able to find string, file buffer pointer not changed
#
# Only consider the same line, no multi-line token allowed
index = -1
if IgnoreCase:
else:
if index == 0:
return False
return True
return False
Index -= 1
ExpressionString = self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine:Index+1]
return ExpressionString
## __GetNextWord() method
#
# Get next C name from file lines
# If found, the string value is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a C name string, file buffer pointer moved forward
# @retval False Not able to find a C name string, file buffer pointer not changed
#
if self.__EndOfFile():
return False
if (TempChar >= 'a' and TempChar <= 'z') or (TempChar >= 'A' and TempChar <= 'Z') or TempChar == '_':
while not self.__EndOfLine():
else:
break
return True
return False
## __GetNextToken() method
#
# Get next token unit before a seperator
# If found, the string value is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a token unit, file buffer pointer moved forward
# @retval False Not able to find a token unit, file buffer pointer not changed
#
# Skip leading spaces, if exist.
if self.__EndOfFile():
return False
# Record the token start position, the position of the first non-space char.
# Try to find the end char that is not a space and not in seperator tuple.
# That is, when we got a space or any char in the tuple, we got the end of token.
# if we happen to meet a seperator as the first char, we must proceed to get it.
# That is, we get a token that is a seperator char. nomally it is the boundary of other tokens.
break
else:
break
# else:
# return False
return True
else:
return False
# Skip leading spaces, if exist.
if self.__EndOfFile():
return False
# Record the token start position, the position of the first non-space char.
while not self.__EndOfLine():
# Try to find the end char that is not a space
else:
break
else:
return False
return True
else:
return False
## __GetNextGuid() method
#
# Get next token unit before a seperator
# If found, the GUID string is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a registry format GUID, file buffer pointer moved forward
# @retval False Not able to find a registry format GUID, file buffer pointer not changed
#
if not self.__GetNextToken():
return False
return True
else:
return False
## __UndoToken() method
#
# Go back one token unit in file buffer
#
# @param self The object pointer
#
if not self.__UndoOneChar():
return
# Try to find the end char that is not a space and not in seperator tuple.
# That is, when we got a space or any char in the tuple, we got the end of token.
if not self.__UndoOneChar():
return
# if we happen to meet a seperator as the first char, we must proceed to get it.
# That is, we get a token that is a seperator char. nomally it is the boundary of other tokens.
return
else:
break
## __HexDigit() method
#
# Whether char input is a Hex data bit
#
# @param self The object pointer
# @param TempChar The char to test
# @retval True The char is a Hex data bit
# @retval False The char is NOT a Hex data bit
#
return True
else:
return False
return False
return False
return True
else:
return False
## __GetNextHexNumber() method
#
# Get next HEX data before a seperator
# If found, the HEX data is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a HEX data, file buffer pointer moved forward
# @retval False Not able to find a HEX data, file buffer pointer not changed
#
if not self.__GetNextToken():
return False
return True
else:
return False
## __GetNextDecimalNumber() method
#
# Get next decimal data before a seperator
# If found, the decimal data is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a decimal data, file buffer pointer moved forward
# @retval False Not able to find a decimal data, file buffer pointer not changed
#
if not self.__GetNextToken():
return False
return True
else:
return False
## __GetNextPcdName() method
#
# Get next PCD token space C name and PCD C name pair before a seperator
# If found, the decimal data is put into self.__Token
#
# @param self The object pointer
# @retval Tuple PCD C name and PCD token space C name pair
#
if not self.__GetNextWord():
raise Warning("expected format of <PcdTokenSpaceCName>.<PcdCName>", self.FileName, self.CurrentLineNumber)
raise Warning("expected format of <PcdTokenSpaceCName>.<PcdCName>", self.FileName, self.CurrentLineNumber)
if not self.__GetNextWord():
raise Warning("expected format of <PcdTokenSpaceCName>.<PcdCName>", self.FileName, self.CurrentLineNumber)
return (pcdCName, pcdTokenSpaceCName)
## __GetStringData() method
#
# Get string contents quoted in ""
# If found, the decimal data is put into self.__Token
#
# @param self The object pointer
# @retval True Successfully find a string data, file buffer pointer moved forward
# @retval False Not able to find a string data, file buffer pointer not changed
#
return True
return True
else:
return False
## __SkipToToken() method
#
# Search forward in file buffer for the string
# The skipped chars are put into self.__SkippedChars
#
# @param self The object pointer
# @param String The string to search
# @param IgnoreCase Indicate case sensitive/non-sensitive search, default is case sensitive
# @retval True Successfully find the string, file buffer pointer moved forward
# @retval False Not able to find the string, file buffer pointer not changed
#
while not self.__EndOfFile():
index = -1
if IgnoreCase:
else:
if index == 0:
return True
return False
## GetFileBufferPos() method
#
# Return the tuple of current line and offset within the line
#
# @param self The object pointer
# @retval Tuple Line number and offset pair
#
## SetFileBufferPos() method
#
# Restore the file buffer position
#
# @param self The object pointer
# @param Pos The new file buffer position
#
## Preprocess() method
#
# Preprocess comment, conditional directive, include directive, replace macro.
# Exception will be raised if syntax error found
#
# @param self The object pointer
#
while self.__GetDefines():
pass
## ParseFile() method
#
# Parse the file profile buffer to extract fd, fv ... information
# Exception will be raised if syntax error found
#
# @param self The object pointer
#
try:
pass
pass
while self.__GetCapsule():
pass
pass
pass
while self.__GetOptionRom():
pass
except Warning, X:
#'\n\tGot Token: \"%s\" from File %s\n' % (self.__Token, FileLineTuple[0]) + \
X.Message += ' near line %d, column %d: %s' \
% (FileLineTuple[1], self.CurrentOffsetWithinLine + 1, self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :].rstrip('\n').rstrip('\r'))
raise
## __GetDefines() method
#
# Get Defines section contents and store its data into AllMacrosList
#
# @param self The object pointer
# @retval True Successfully find a Defines
# @retval False Not able to find a Defines
#
if not self.__GetNextToken():
return False
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)
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
while self.__GetNextWord():
# handle the SET statement
self.__GetSetStatement(None)
continue
return False
## __GetFd() method
#
# Get FD section contents and store its data into FD dictionary of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a FD
# @retval False Not able to find a FD
#
if not self.__GetNextToken():
return False
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
if FdName == "":
else:
if not Status:
pass
return True
## __GetUiName() method
#
# Return the UI name of a section
#
# @param self The object pointer
# @retval FdName UI name
#
Name = ""
if self.__GetNextWord():
return Name
## __GetCreateFile() method
#
# Return the output file name of object
#
# @param self The object pointer
# @param Obj object whose data will be stored in file
# @retval FdName UI name
#
if not self.__GetNextToken():
return True
## __GetTokenStatements() method
#
# Get token statements
#
# @param self The object pointer
# @param Obj for whom token statement is got
#
if not self.__GetNextHexNumber():
if not self.__GetNextHexNumber():
if not self.__GetNextToken():
## __GetAddressStatements() method
#
# Get address statements
#
# @param self The object pointer
# @param Obj for whom address statement is got
# @retval True Successfully find
# @retval False Not able to find
#
## __GetBlockStatements() method
#
# Get block statements
#
# @param self The object pointer
# @param Obj for whom block statement is got
#
#set default block size is 1
return
pass
## __GetBlockStatement() method
#
# Get block statement
#
# @param self The object pointer
# @param Obj for whom block statement is got
# @retval True Successfully find
# @retval False Not able to find
#
return False
BlockSizePcd = None
BlockNumber = None
return True
## __GetDefineStatements() method
#
# Get define statements
#
# @param self The object pointer
# @param Obj for whom define statement is got
# @retval True Successfully find
# @retval False Not able to find
#
pass
## __GetDefineStatement() method
#
# Get define statement
#
# @param self The object pointer
# @param Obj for whom define statement is got
# @retval True Successfully find
# @retval False Not able to find
#
if not self.__GetNextToken():
return True
return False
## __GetSetStatements() method
#
# Get set statements
#
# @param self The object pointer
# @param Obj for whom set statement is got
# @retval True Successfully find
# @retval False Not able to find
#
pass
## __GetSetStatement() method
#
# Get set statement
#
# @param self The object pointer
# @param Obj for whom set statement is got
# @retval True Successfully find
# @retval False Not able to find
#
if Obj:
return True
return False
## __GetRegionLayout() method
#
# Get region layout for FD
#
# @param self The object pointer
# @param Fd for whom region is got
# @retval True Successfully find
# @retval False Not able to find
#
if not self.__GetNextHexNumber():
return False
if not self.__GetNextHexNumber():
if not self.__GetNextWord():
return True
if not self.__GetNextWord():
return True
if not self.__GetNextWord():
return True
else:
raise Warning("A valid region type was not found. "
"Valid types are [SET, FV, CAPSULE, FILE, DATA]. This error occurred",
return True
## __GetRegionFvType() method
#
# Get region fv data for region
#
# @param self The object pointer
# @param RegionObj for whom region data is got
#
if not self.__GetNextToken():
if not self.__GetNextToken():
## __GetRegionCapType() method
#
# Get region capsule data for region
#
# @param self The object pointer
# @param RegionObj for whom region data is got
#
if not self.__GetNextToken():
if not self.__GetNextToken():
## __GetRegionFileType() method
#
# Get region file data for region
#
# @param self The object pointer
# @param RegionObj for whom region data is got
#
if not self.__GetNextToken():
if not self.__GetNextToken():
## __GetRegionDataType() method
#
# Get region array data for region
#
# @param self The object pointer
# @param RegionObj for whom region data is got
#
if not self.__GetNextHexNumber():
raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)
# convert hex string value to byte hex string array
DataString = ""
while AllStrLen > 4:
# byte value array
if not self.__GetNextHexNumber():
DataString += ","
if not self.__GetNextHexNumber():
raise Warning("Hex string can't be converted to a valid UINT64 value", self.FileName, self.CurrentLineNumber)
# convert hex string value to byte hex string array
DataString = ""
while AllStrLen > 4:
# byte value array
if not self.__GetNextHexNumber():
DataString += ","
## __GetFv() method
#
# Get FV section contents and store its data into FV dictionary of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a FV
# @retval False Not able to find a FV
#
if not self.__GetNextToken():
return False
if not S.startswith("[CAPSULE.") \
raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
if not Status:
pass
FvObj.FvExtEntryTypeValue = []
FvObj.FvExtEntryType = []
FvObj.FvExtEntryData = []
while True:
if not isFvExtEntry:
break
while True:
break
return True
## __GetFvAlignment() method
#
# Get alignment for FV
#
# @param self The object pointer
# @param Obj for whom alignment is got
# @retval True Successfully find a alignment statement
# @retval False Not able to find a alignment statement
#
return False
if not self.__GetNextToken():
"1K", "2K", "4K", "8K", "16K", "32K", "64K", "128K", "256K", "512K", \
"1M", "2M", "4M", "8M", "16M", "32M", "64M", "128M", "256M", "512M", \
"1G", "2G"):
return True
## __GetFvBaseAddress() method
#
# Get BaseAddress for FV
#
# @param self The object pointer
# @param Obj for whom FvBaseAddress is got
# @retval True Successfully find a FvBaseAddress statement
# @retval False Not able to find a FvBaseAddress statement
#
return False
if not self.__GetNextToken():
raise Warning("Unknown FV base address value '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
return True
## __GetFvForceRebase() method
#
# Get FvForceRebase for FV
#
# @param self The object pointer
# @param Obj for whom FvForceRebase is got
# @retval True Successfully find a FvForceRebase statement
# @retval False Not able to find a FvForceRebase statement
#
return False
if not self.__GetNextToken():
raise Warning("Unknown FvForceRebase value '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
else:
Obj.FvForceRebase = None
return True
## __GetFvAttributes() method
#
# Get attributes for FV
#
# @param self The object pointer
# @param Obj for whom attribute is got
# @retval None
#
while self.__GetNextWord():
"STICKY_WRITE", "LOCK_CAP", "LOCK_STATUS", "WRITE_ENABLED_CAP", \
"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"):
return
return
## __GetFvNameGuid() method
#
# Get FV GUID for FV
#
# @param self The object pointer
# @param Obj for whom GUID is got
# @retval None
#
return
if not self.__GetNextGuid():
return
return False
raise Warning("expected Hex FV extension entry type value At Line ", self.FileName, self.CurrentLineNumber)
if not self.__GetNextHexNumber():
DataString += ","
if not self.__GetNextHexNumber():
DataString += ","
if not self.__GetNextToken():
raise Warning("expected FV Extension Entry file path At Line ", self.FileName, self.CurrentLineNumber)
return True
## __GetAprioriSection() method
#
# Get token statements
#
# @param self The object pointer
# @param FvObj for whom apriori is got
# @param MacroDict dictionary used to replace macro
# @retval True Successfully find apriori statement
# @retval False Not able to find apriori statement
#
return False
while True:
break
return True
## __GetInfStatement() method
#
# Get INF statements
#
# @param self The object pointer
# @param Obj for whom inf statement is got
# @param MacroDict dictionary used to replace macro
# @retval True Successfully find inf statement
# @retval False Not able to find inf statement
#
return False
if not self.__GetNextToken():
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
else:
raise Warning("Unknown reloc strip flag '%s'" % self.__Token, self.FileName, self.CurrentLineNumber)
if ForCapsule:
else:
return True
## __GetInfOptions() method
#
# Get options for INF
#
# @param self The object pointer
# @param FfsInfObj for whom option is got
#
if not self.__GetNextToken():
if not self.__GetNextToken():
if self.__GetStringData():
if not self.__GetNextToken():
if self.__GetStringData():
if not self.__GetNextToken():
if self.__GetNextToken():
p = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
return
else:
return
while self.__GetNextToken():
break
## __GetFileStatement() method
#
# Get FILE statements
#
# @param self The object pointer
# @param Obj for whom FILE statement is got
# @param MacroDict dictionary used to replace macro
# @retval True Successfully find FILE statement
# @retval False Not able to find FILE statement
#
return False
if not self.__GetNextWord():
return False
if not self.__GetNextGuid():
if not self.__GetNextWord():
if ForCapsule:
else:
return True
## __FileCouldHaveRelocFlag() method
#
# Check whether reloc strip flag can be set for a file type.
#
# @param self The object pointer
# @param FileType The file type to check with
# @retval True This type could have relocation strip flag
# @retval False No way to have it
#
return True
else:
return False
## __SectionCouldHaveRelocFlag() method
#
# Check whether reloc strip flag can be set for a section type.
#
# @param self The object pointer
# @param SectionType The section type to check with
# @retval True This type could have relocation strip flag
# @retval False No way to have it
#
return True
else:
return False
## __GetFilePart() method
#
# Get components for FILE statement
#
# @param self The object pointer
# @param FfsFileObj for whom component is got
# @param MacroDict dictionary used to replace macro
#
# if self.__IsKeyword('RELOCS_STRIPPED') or self.__IsKeyword('RELOCS_RETAINED'):
# if self.__FileCouldHaveRelocFlag(FfsFileObj.FvFileType):
# if self.__Token == 'RELOCS_STRIPPED':
# FfsFileObj.KeepReloc = False
# else:
# FfsFileObj.KeepReloc = True
# else:
# raise Warning("File type %s could not have reloc strip flag%d" % (FfsFileObj.FvFileType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
#
# if not self.__IsToken("{"):
if not self.__GetNextToken():
if not self.__GetNextToken():
if not self.__GetNextToken():
else:
#
# For file in OUTPUT_DIRECTORY will not check whether it exist or not at AutoGen phase.
#
if not GlobalData.gAutoGenPhase:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
else:
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
## __GetFileOpts() method
#
# Get options for FILE statement
#
# @param self The object pointer
# @param FfsFileObj for whom options is got
#
if self.__GetNextToken():
Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
while self.__GetNextToken():
break
else:
if self.__GetAlignment():
#For FFS, Auto is default option same to ""
## __GetAlignment() method
#
# Return the alignment value
#
# @param self The object pointer
# @retval True Successfully find alignment
# @retval False Not able to find alignment
#
if not self.__GetNextToken():
return True
return False
## __GetFilePart() method
#
# Get section data for FILE statement
#
# @param self The object pointer
# @param FfsFileObj for whom section is got
# @param MacroDict dictionary used to replace macro
#
Dict = {}
while True:
if not IsLeafSection and not IsEncapSection:
break
## __GetLeafSection() method
#
# Get leaf section for Obj
#
# @param self The object pointer
# @param Obj for whom leaf section is got
# @param MacroDict dictionary used to replace macro
# @retval True Successfully find section statement
# @retval False Not able to find section statement
#
else:
return False
AlignValue = None
if self.__GetAlignment():
BuildNum = None
if not self.__GetNextToken():
if AlignValue == 'Auto':
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
if self.__GetStringData():
else:
if AlignValue == 'Auto':
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
if self.__GetStringData():
else:
if AlignValue == 'Auto':
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
FvObj = None
while True:
break
if FvObj != None:
FvImageSectionObj.FvName = None
else:
elif self.__IsKeyword("PEI_DEPEX_EXP") or self.__IsKeyword("DXE_DEPEX_EXP") or self.__IsKeyword("SMM_DEPEX_EXP"):
if AlignValue == 'Auto':
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
else:
if not self.__GetNextWord():
# Encapsulation section appear, UndoToken and return
return False
"UI", "VERSION", "PEI_DEPEX", "SUBTYPE_GUID", "SMM_DEPEX"):
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
# DataSection
if self.__FileCouldHaveRelocFlag(Obj.FvFileType) and self.__SectionCouldHaveRelocFlag(DataSectionObj.SecType):
else:
else:
raise Warning("File type %s, section type %s, could not have reloc strip flag%d" % (Obj.FvFileType, DataSectionObj.SecType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
#do case sensitive check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(DataSectionObj.SectFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
else:
return False
return True
## __GetCglSection() method
#
# Get compressed or GUIDed section for Obj
#
# @param self The object pointer
# @param Obj for whom leaf section is got
# @param AlignValue alignment value for complex section
# @retval True Successfully find section statement
# @retval False Not able to find section statement
#
type = "PI_STD"
# Recursive sections...
while True:
if not IsLeafSection and not IsEncapSection:
break
# else:
# raise Warning("Compress type not known")
return True
GuidValue = None
if self.__GetNextGuid():
# Recursive sections...
while True:
if not IsLeafSection and not IsEncapSection:
break
return True
return False
## __GetGuidAttri() method
#
# Get attributes for GUID section
#
# @param self The object pointer
# @retval AttribDict Dictionary of key-value pair of section attributes
#
AttribDict = {}
if not self.__GetNextToken():
elif AttribKey == "EXTRA_HEADER_SIZE":
Base = 10
Base = 16
try:
continue
except ValueError:
return AttribDict
## __GetEncapsulationSec() method
#
# Get encapsulation section for FILE
#
# @param self The object pointer
# @param FfsFile for whom section is got
# @retval True Successfully find section statement
# @retval False Not able to find section statement
#
else:
return False
AlignValue = None
if self.__GetAlignment():
return False
else:
return True
## __GetCapsule() method
#
# Get capsule section contents and store its data into capsule list of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a capsule
# @retval False Not able to find a capsule
#
if not self.__GetNextToken():
return False
raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
if not CapsuleName:
if not self.__GetNextToken():
return True
## __GetCapsuleStatements() method
#
# Get statements for capsule
#
# @param self The object pointer
# @param Obj for whom statements are got
#
## __GetCapsuleTokens() method
#
# Get token statements for capsule
#
# @param self The object pointer
# @param Obj for whom token statements are got
#
if not self.__GetNextToken():
return False
if not self.__GetNextToken():
if Name == 'CAPSULE_FLAGS':
raise Warning("expected PersistAcrossReset, PopulateSystemTable, or InitiateReset", self.FileName, self.CurrentLineNumber)
Value += ','
if not self.__GetNextToken():
raise Warning("expected PersistAcrossReset, PopulateSystemTable, or InitiateReset", self.FileName, self.CurrentLineNumber)
else:
if not self.__GetNextToken():
return False
## __GetCapsuleData() method
#
# Get capsule data for capsule
#
# @param self The object pointer
# @param Obj for whom capsule data are got
#
while True:
break
## __GetFvStatement() method
#
# Get FV for capsule
#
# @param self The object pointer
# @param CapsuleObj for whom FV is got
# @retval True Successfully find a FV statement
# @retval False Not able to find a FV statement
#
return False
if not self.__GetNextToken():
return True
## __GetFdStatement() method
#
# Get FD for capsule
#
# @param self The object pointer
# @param CapsuleObj for whom FD is got
# @retval True Successfully find a FD statement
# @retval False Not able to find a FD statement
#
return False
if not self.__GetNextToken():
return True
## __GetAnyFileStatement() method
#
# Get AnyFile for capsule
#
# @param self The object pointer
# @param CapsuleObj for whom AnyFile is got
# @retval True Successfully find a Anyfile statement
# @retval False Not able to find a AnyFile statement
#
return False
return False
if not self.__GetNextToken():
return True
## __GetRule() method
#
# Get Rule section contents and store its data into rule list of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a Rule
# @retval False Not able to find a Rule
#
if not self.__GetNextToken():
return False
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)
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
TemplateName = ""
if not self.__GetNextWord():
if TemplateName == '' :
'.' + \
'.' + \
else :
'.' + \
'.' + \
ModuleType.upper() + \
'.' + \
# self.Profile.RuleList.append(rule)
return True
## __GetModuleType() method
#
# Return the module type
#
# @param self The object pointer
# @retval string module type
#
if not self.__GetNextWord():
"DXE_DRIVER", "DXE_SAL_DRIVER", \
"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"):
## __GetFileExtension() method
#
# Return the file extension
#
# @param self The object pointer
# @retval string file name extension
#
Ext = ""
if self.__GetNextToken():
return '.' + Ext
else:
else:
## __GetRuleFileStatement() method
#
# Get rule contents
#
# @param self The object pointer
# @retval Rule Rule object
#
if not self.__GetNextWord():
"PEI_DXE_COMBO", "DRIVER", "DXE_CORE", "APPLICATION", "FV_IMAGE", "SMM", "SMM_CORE"):
if not self.__GetNextWord():
KeepReloc = None
else:
else:
raise Warning("File type %s could not have reloc strip flag%d" % (Type, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
KeyStringList = []
if self.__GetNextToken():
Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
while self.__GetNextToken():
break
else:
AlignValue = ""
if self.__GetAlignment():
#For FFS, Auto is default option same to ""
# Complex file rule expected
if KeepReloc != None:
while True:
if not IsEncapsulate and not IsLeaf:
break
return Rule
else:
# Simple file rule expected
if not self.__GetNextWord():
"UI", "PEI_DEPEX", "VERSION", "SUBTYPE_GUID", "SMM_DEPEX"):
raise Warning("Unknown leaf section name '%s'" % SectionName, self.FileName, self.CurrentLineNumber)
SectAlignment = ""
if self.__GetAlignment():
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
Ext = None
elif not self.__GetNextToken():
if KeepReloc != None:
return Rule
## __GetEfiSection() method
#
# Get section list for Rule
#
# @param self The object pointer
# @param Obj for whom section is got
# @retval True Successfully find section statement
# @retval False Not able to find section statement
#
if not self.__GetNextWord():
return False
"UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
return False
if SectionName == "FV_IMAGE":
pass
while True:
break
FvImageSectionObj.FvName = None
else:
if self.__GetAlignment():
elif self.__GetNextToken():
"UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
else:
else:
return True
if not self.__GetNextToken():
raise Warning("%s section could NOT have string data%d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
if self.__GetStringData():
raise Warning("%s section could NOT have BUILD_NUM%d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
else:
raise Warning("%s section could NOT be optional%d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
raise Warning("%s section could NOT have BUILD_NUM%d" % (EfiSectionObj.SectionType, self.CurrentLineNumber), self.FileName, self.CurrentLineNumber)
if not self.__GetNextToken():
if self.__GetAlignment():
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
else:
raise Warning("Section type %s has reloc strip flag conflict with Rule" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
else:
raise Warning("Section type %s could not have reloc strip flag" % EfiSectionObj.SectionType, self.FileName, self.CurrentLineNumber)
elif self.__GetNextToken():
"UI", "VERSION", "PEI_DEPEX", "GUID", "SMM_DEPEX"):
else:
else:
return True
## __RuleSectionCouldBeOptional() method
#
# Get whether a section could be optional
#
# @param self The object pointer
# @param SectionType The section type to check
# @retval True section could be optional
# @retval False section never optional
#
return True
else:
return False
## __RuleSectionCouldHaveBuildNum() method
#
# Get whether a section could have build number information
#
# @param self The object pointer
# @param SectionType The section type to check
# @retval True section could have build number information
# @retval False section never have build number information
#
if SectionType in ("VERSION"):
return True
else:
return False
## __RuleSectionCouldHaveString() method
#
# Get whether a section could have string
#
# @param self The object pointer
# @param SectionType The section type to check
# @retval True section could have string
# @retval False section never have string
#
return True
else:
return False
## __CheckRuleSectionFileType() method
#
# Get whether a section matches a file type
#
# @param self The object pointer
# @param SectionType The section type to check
# @param FileType The file type to check
#
if SectionType == "COMPAT16":
elif SectionType == "PE32":
elif SectionType == "PIC":
elif SectionType == "TE":
elif SectionType == "RAW":
elif SectionType == "UI":
elif SectionType == "VERSION":
elif SectionType == "PEI_DEPEX":
elif SectionType == "GUID":
## __GetRuleEncapsulationSection() method
#
# Get encapsulation section for Rule
#
# @param self The object pointer
# @param Rule for whom section is got
# @retval True Successfully find section statement
# @retval False Not able to find section statement
#
Type = "PI_STD"
# Recursive sections...
while True:
if not IsEncapsulate and not IsLeaf:
break
return True
GuidValue = None
if self.__GetNextGuid():
# Efi sections...
while True:
if not IsEncapsulate and not IsLeaf:
break
return True
return False
## __GetVtf() method
#
# Get VTF section contents and store its data into VTF list of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a VTF
# @retval False Not able to find a VTF
#
if not self.__GetNextToken():
return False
raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
return False
#print 'Parsing String: %s in File %s, At line: %d, Offset Within Line: %d' \
# % (self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :], FileLineTuple[0], FileLineTuple[1], self.CurrentOffsetWithinLine)
if not self.__GetNextWord():
if not self.__GetNextWord():
if not self.__GetNextToken():
#check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(VtfObj.ResetBin), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
pass
return True
## __GetComponentStatement() method
#
# Get components in VTF
#
# @param self The object pointer
# @param VtfObj for whom component is got
# @retval True Successfully find a component
# @retval False Not able to find a component
#
return False
if not self.__GetNextWord():
if self.__GetNextWord():
if not self.__GetNextWord():
else:
if not self.__GetNextToken():
if not self.__GetNextToken():
if not self.__GetNextToken():
if not self.__GetNextToken():
if CompStatementObj.CompBin != '-' and CompStatementObj.CompBin.replace('$(WORKSPACE)', '').find('$') == -1:
#check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(CompStatementObj.CompBin), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
if not self.__GetNextToken():
if CompStatementObj.CompSym != '-' and CompStatementObj.CompSym.replace('$(WORKSPACE)', '').find('$') == -1:
#check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(CompStatementObj.CompSym), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
elif self.__GetNextDecimalNumber():
elif self.__GetNextHexNumber():
else:
return True
## __GetOptionRom() method
#
# Get OptionROM section contents and store its data into OptionROM list of self.Profile
#
# @param self The object pointer
# @retval True Successfully find a OptionROM
# @retval False Not able to find a OptionROM
#
if not self.__GetNextToken():
return False
raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)
while True:
break
return True
## __GetOptRomInfStatement() method
#
# Get INF statements
#
# @param self The object pointer
# @param Obj for whom inf statement is got
# @retval True Successfully find inf statement
# @retval False Not able to find inf statement
#
return False
if not self.__GetNextToken():
#check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(ffsInf.InfFileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
return True
## __GetOptRomOverrides() method
#
# Get overrides for OptROM INF & FILE
#
# @param self The object pointer
# @param FfsInfObj for whom overrides is got
#
while True:
if not self.__GetNextHexNumber():
continue
if not self.__GetNextHexNumber():
continue
if not self.__GetNextHexNumber():
continue
if not self.__GetNextHexNumber():
continue
if not self.__GetNextToken():
continue
break
else:
## __GetOptRomFileStatement() method
#
# Get FILE statements
#
# @param self The object pointer
# @param Obj for whom FILE statement is got
# @retval True Successfully find FILE statement
# @retval False Not able to find FILE statement
#
return False
if not self.__GetNextToken():
#check for file path
ErrorCode, ErrorInfo = PathClass(NormPath(FfsFileObj.FileName), GenFdsGlobalVariable.WorkSpaceDir).Validate()
if ErrorCode != 0:
return True
## __GetCapInFd() method
#
# Get Cap list contained in FD
#
# @param self The object pointer
# @param FdName FD name
# @retval CapList List of Capsule in FD
#
CapList = []
continue
return CapList
## __GetReferencedFdCapTuple() method
#
# Get FV and FD list referenced by a capsule image
#
# @param self The object pointer
# @param CapObj Capsule section to be searched
# @param RefFdList referenced FD by section
# @param RefFvList referenced FV by section
#
if hasattr(CapsuleDataObj, 'FvName') and CapsuleDataObj.FvName != None and CapsuleDataObj.FvName.upper() not in RefFvList:
elif hasattr(CapsuleDataObj, 'FdName') and CapsuleDataObj.FdName != None and CapsuleDataObj.FdName.upper() not in RefFdList:
elif CapsuleDataObj.Ffs != None:
else:
## __GetFvInFd() method
#
# Get FV list contained in FD
#
# @param self The object pointer
# @param FdName FD name
# @retval FvList list of FV in FD
#
FvList = []
continue
return FvList
## __GetReferencedFdFvTuple() method
#
# Get FD and FV list referenced by a FFS file
#
# @param self The object pointer
# @param FfsFile contains sections to be searched
# @param RefFdList referenced FD by section
# @param RefFvList referenced FV by section
#
else:
## __GetReferencedFdFvTupleFromSection() method
#
# Get FD and FV list referenced by a FFS section
#
# @param self The object pointer
# @param FfsFile contains sections to be searched
# @param FdList referenced FD by section
# @param FvList referenced FV by section
#
SectionStack = []
while SectionStack != []:
if SectionObj.Fv != None and SectionObj.Fv.UiFvName != None and SectionObj.Fv.UiFvName.upper() not in FvList:
if isinstance(SectionObj, CompressSection.CompressSection) or isinstance(SectionObj, GuidSection.GuidSection):
## CycleReferenceCheck() method
#
# Check whether cycle reference exists in FDF
#
# @param self The object pointer
# @retval True cycle reference exists
# @retval False Not exists cycle reference
#
#
# Check the cycle between FV and FD image
#
RefFvStack = []
FdAnalyzedList = []
Index = 0
else:
continue
RefFdList = []
RefFvList = []
if RefFdName in FdAnalyzedList:
continue
if FvInFdList != []:
for FvNameInFd in FvInFdList:
if FvNameInFd not in RefFvStack:
return True
if RefFvName not in RefFvStack:
return True
#
# Check the cycle between Capsule and FD image
#
#
# Capsule image to be checked.
#
RefCapStack = []
FdAnalyzedList = []
FvAnalyzedList = []
Index = 0
else:
continue
RefFvList = []
RefFdList = []
FvListLength = 0
FdListLength = 0
if RefFdName in FdAnalyzedList:
continue
if CapInFdList != []:
for CapNameInFd in CapInFdList:
if CapNameInFd not in RefCapStack:
return True
if FvInFdList != []:
for FvNameInFd in FvInFdList:
if FvNameInFd not in RefFvList:
#
# the number of the parsed FV and FD image
#
if RefFvName in FvAnalyzedList:
continue
else:
continue
return False
if __name__ == "__main__":
import sys
try:
except IndexError, v:
try:
except Warning, X:
print str(X)
else:
print "Success!"