X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=IntelFspPkg%2FTools%2FGenCfgOpt.py;h=a38da70212a8cceee328e6b1667ceef6751ef3a9;hp=555099bbd29c4c4b26057fe73231842e78e9a309;hb=fb9819f13dc1e3b13d65840742a4f9ad9e393e7b;hpb=63c05743b481945e729f22554b0916e526e05a3d
diff --git a/IntelFspPkg/Tools/GenCfgOpt.py b/IntelFspPkg/Tools/GenCfgOpt.py
index 555099bbd2..a38da70212 100644
--- a/IntelFspPkg/Tools/GenCfgOpt.py
+++ b/IntelFspPkg/Tools/GenCfgOpt.py
@@ -1,6 +1,6 @@
## @ GenCfgOpt.py
#
-# Copyright (c) 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.
# This program and the accompanying materials are licensed and made available under
# the terms and conditions of the BSD License that accompanies this distribution.
# The full text of the license may be found at
@@ -88,8 +88,248 @@ are permitted provided that the following conditions are met:
**/
"""
+def UpdateMemSiUpdInitOffsetValue (DscFile):
+ DscFd = open(DscFile, "r")
+ DscLines = DscFd.readlines()
+ DscFd.close()
+
+ DscContent = []
+ MemUpdInitOffset = 0
+ SiUpdInitOffset = 0
+ MemUpdInitOffsetValue = 0
+ SiUpdInitOffsetValue = 0
+
+ while len(DscLines):
+ DscLine = DscLines.pop(0)
+ DscContent.append(DscLine)
+ DscLine = DscLine.strip()
+ Match = re.match("^([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
+ if Match:
+ MemUpdInitOffsetValue = int(Match.group(5), 0)
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
+ if Match:
+ SiUpdInitOffsetValue = int(Match.group(5), 0)
+ Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450554D454D24)",DscLine)
+ if Match:
+ MemUpdInitOffset = int(Match.group(3), 0)
+ Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450555F495324)",DscLine)
+ if Match:
+ SiUpdInitOffset = int(Match.group(3), 0)
+
+ if MemUpdInitOffsetValue != MemUpdInitOffset or SiUpdInitOffsetValue != SiUpdInitOffset:
+ MemUpdInitOffsetStr = "0x%08X" % MemUpdInitOffset
+ SiUpdInitOffsetStr = "0x%08X" % SiUpdInitOffset
+ DscFd = open(DscFile,"w")
+ for DscLine in DscContent:
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
+ if Match:
+ DscLine = re.sub(r'(?:[^\s]+\s*$)', MemUpdInitOffsetStr + '\n', DscLine)
+ Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
+ if Match:
+ DscLine = re.sub(r'(?:[^\s]+\s*$)', SiUpdInitOffsetStr + '\n', line)
+ DscFd.writelines(DscLine)
+ DscFd.close()
+
+class CLogicalExpression:
+ def __init__(self):
+ self.index = 0
+ self.string = ''
+
+ def errExit(self, err = ''):
+ print "ERROR: Express parsing for:"
+ print " %s" % self.string
+ print " %s^" % (' ' * self.index)
+ if err:
+ print "INFO : %s" % err
+ raise SystemExit
+
+ def getNonNumber (self, n1, n2):
+ if not n1.isdigit():
+ return n1
+ if not n2.isdigit():
+ return n2
+ return None
+
+ def getCurr(self, lens = 1):
+ try:
+ if lens == -1:
+ return self.string[self.index :]
+ else:
+ if self.index + lens > len(self.string):
+ lens = len(self.string) - self.index
+ return self.string[self.index : self.index + lens]
+ except Exception:
+ return ''
+
+ def isLast(self):
+ return self.index == len(self.string)
+
+ def moveNext(self, len = 1):
+ self.index += len
+
+ def skipSpace(self):
+ while not self.isLast():
+ if self.getCurr() in ' \t':
+ self.moveNext()
+ else:
+ return
+
+ def normNumber (self, val):
+ return True if val else False
+
+ def getNumber(self, var):
+ var = var.strip()
+ if re.match('^0x[a-fA-F0-9]+$', var):
+ value = int(var, 16)
+ elif re.match('^[+-]?\d+$', var):
+ value = int(var, 10)
+ else:
+ value = None
+ return value
+
+ def parseValue(self):
+ self.skipSpace()
+ var = ''
+ while not self.isLast():
+ char = self.getCurr()
+ if re.match('^[\w.]', char):
+ var += char
+ self.moveNext()
+ else:
+ break
+ val = self.getNumber(var)
+ if val is None:
+ value = var
+ else:
+ value = "%d" % val
+ return value
+
+ def parseSingleOp(self):
+ self.skipSpace()
+ if re.match('^NOT\W', self.getCurr(-1)):
+ self.moveNext(3)
+ op = self.parseBrace()
+ val = self.getNumber (op)
+ if val is None:
+ self.errExit ("'%s' is not a number" % op)
+ return "%d" % (not self.normNumber(int(op)))
+ else:
+ return self.parseValue()
+
+ def parseBrace(self):
+ self.skipSpace()
+ char = self.getCurr()
+ if char == '(':
+ self.moveNext()
+ value = self.parseExpr()
+ self.skipSpace()
+ if self.getCurr() != ')':
+ self.errExit ("Expecting closing brace or operator")
+ self.moveNext()
+ return value
+ else:
+ value = self.parseSingleOp()
+ return value
+
+ def parseCompare(self):
+ value = self.parseBrace()
+ while True:
+ self.skipSpace()
+ char = self.getCurr()
+ if char in ['<', '>']:
+ self.moveNext()
+ next = self.getCurr()
+ if next == '=':
+ op = char + next
+ self.moveNext()
+ else:
+ op = char
+ result = self.parseBrace()
+ test = self.getNonNumber(result, value)
+ if test is None:
+ value = "%d" % self.normNumber(eval (value + op + result))
+ else:
+ self.errExit ("'%s' is not a valid number for comparision" % test)
+ elif char in ['=', '!']:
+ op = self.getCurr(2)
+ if op in ['==', '!=']:
+ self.moveNext(2)
+ result = self.parseBrace()
+ test = self.getNonNumber(result, value)
+ if test is None:
+ value = "%d" % self.normNumber((eval (value + op + result)))
+ else:
+ value = "%d" % self.normNumber(eval ("'" + value + "'" + op + "'" + result + "'"))
+ else:
+ break
+ else:
+ break
+ return value
+
+ def parseAnd(self):
+ value = self.parseCompare()
+ while True:
+ self.skipSpace()
+ if re.match('^AND\W', self.getCurr(-1)):
+ self.moveNext(3)
+ result = self.parseCompare()
+ test = self.getNonNumber(result, value)
+ if test is None:
+ value = "%d" % self.normNumber(int(value) & int(result))
+ else:
+ self.errExit ("'%s' is not a valid op number for AND" % test)
+ else:
+ break
+ return value
+
+ def parseOrXor(self):
+ value = self.parseAnd()
+ op = None
+ while True:
+ self.skipSpace()
+ op = None
+ if re.match('^XOR\W', self.getCurr(-1)):
+ self.moveNext(3)
+ op = '^'
+ elif re.match('^OR\W', self.getCurr(-1)):
+ self.moveNext(2)
+ op = '|'
+ else:
+ break
+ if op:
+ result = self.parseAnd()
+ test = self.getNonNumber(result, value)
+ if test is None:
+ value = "%d" % self.normNumber(eval (value + op + result))
+ else:
+ self.errExit ("'%s' is not a valid op number for XOR/OR" % test)
+ return value
+
+ def parseExpr(self):
+ return self.parseOrXor()
+
+ def getResult(self):
+ value = self.parseExpr()
+ self.skipSpace()
+ if not self.isLast():
+ self.errExit ("Unexpected character found '%s'" % self.getCurr())
+ test = self.getNumber(value)
+ if test is None:
+ self.errExit ("Result '%s' is not a number" % value)
+ return int(value)
+
+ def evaluateExpress (self, Expr):
+ self.index = 0
+ self.string = Expr
+ if self.getResult():
+ Result = True
+ else:
+ Result = False
+ return Result
+
class CGenCfgOpt:
def __init__(self):
+ self.Debug = False
self.Error = ''
self._GlobalDataDef = """
@@ -107,7 +347,7 @@ EndList
"""
self._BsfKeyList = ['FIND','NAME','HELP','TYPE','PAGE','OPTION','ORDER']
- self._HdrKeyList = ['HEADER','STRUCT']
+ self._HdrKeyList = ['HEADER','STRUCT', 'EMBED']
self._BuidinOption = {'$EN_DIS' : 'EN_DIS'}
self._MacroDict = {}
@@ -139,12 +379,71 @@ EndList
if Match:
self._MacroDict[Match.group(1)] = ''
if len(self._MacroDict) == 0:
- self.Error = "Invalid MACRO arguments"
Error = 1
else:
Error = 0
+ if self.Debug:
+ print "INFO : Macro dictionary:"
+ for Each in self._MacroDict:
+ print " $(%s) = [ %s ]" % (Each , self._MacroDict[Each])
return Error
+ def EvaulateIfdef (self, Macro):
+ Result = Macro in self._MacroDict
+ if self.Debug:
+ print "INFO : Eval Ifdef [%s] : %s" % (Macro, Result)
+ return Result
+
+ def ExpandMacros (self, Input):
+ Line = Input
+ Match = re.findall("\$\(\w+\)", Input)
+ if Match:
+ for Each in Match:
+ Variable = Each[2:-1]
+ if Variable in self._MacroDict:
+ Line = Line.replace(Each, self._MacroDict[Variable])
+ else:
+ if self.Debug:
+ print "WARN : %s is not defined" % Each
+ Line = Line.replace(Each, Each[2:-1])
+ return Line
+
+ def EvaluateExpress (self, Expr):
+ ExpExpr = self.ExpandMacros(Expr)
+ LogExpr = CLogicalExpression()
+ Result = LogExpr.evaluateExpress (ExpExpr)
+ if self.Debug:
+ print "INFO : Eval Express [%s] : %s" % (Expr, Result)
+ return Result
+
+ def FormatListValue(self, ConfigDict):
+ Struct = ConfigDict['struct']
+ if Struct not in ['UINT8','UINT16','UINT32','UINT64']:
+ return
+
+ dataarray = []
+ binlist = ConfigDict['value'][1:-1].split(',')
+ for each in binlist:
+ each = each.strip()
+ if each.startswith('0x'):
+ value = int(each, 16)
+ else:
+ value = int(each)
+ dataarray.append(value)
+
+ unit = int(Struct[4:]) / 8
+ if int(ConfigDict['length']) != unit * len(dataarray):
+ raise Exception("Array size is not proper for '%s' !" % ConfigDict['cname'])
+
+ bytearray = []
+ for each in dataarray:
+ value = each
+ for loop in xrange(unit):
+ bytearray.append("0x%02X" % (value & 0xFF))
+ value = value >> 8
+ newvalue = '{' + ','.join(bytearray) + '}'
+ ConfigDict['value'] = newvalue
+ return ""
def ParseDscFile (self, DscFile, FvDir):
self._CfgItemList = []
@@ -158,20 +457,19 @@ EndList
IsVpdSect = False
Found = False
- IfStack = [True]
+ IfStack = []
ElifStack = []
Error = 0
+ ConfigDict = {}
DscFd = open(DscFile, "r")
DscLines = DscFd.readlines()
DscFd.close()
- ConfigDict = {}
-
- for DscLine in DscLines:
- Handle = False
- DscLine = DscLine.strip()
- Match = re.match("^\[(.+)\]", DscLine)
+ while len(DscLines):
+ DscLine = DscLines.pop(0).strip()
+ Handle = False
+ Match = re.match("^\[(.+)\]", DscLine)
if Match is not None:
if Match.group(1).lower() == "Defines".lower():
IsDefSect = True
@@ -186,6 +484,7 @@ EndList
ConfigDict['name'] = ''
ConfigDict['find'] = ''
ConfigDict['struct'] = ''
+ ConfigDict['embed'] = ''
ConfigDict['subreg'] = []
IsDefSect = False
IsVpdSect = True
@@ -199,6 +498,7 @@ EndList
ConfigDict['name'] = ''
ConfigDict['find'] = ''
ConfigDict['struct'] = ''
+ ConfigDict['embed'] = ''
ConfigDict['subreg'] = []
IsDefSect = False
IsUpdSect = True
@@ -210,65 +510,77 @@ EndList
IsVpdSect = False
else:
if IsDefSect or IsUpdSect or IsVpdSect:
- if DscLine == "!else":
- IfStack[-1] = not IfStack[-1]
- elif DscLine == "!endif":
- IfStack.pop()
- Level = ElifStack.pop()
- while Level > 0:
+ if re.match("^!else($|\s+#.+)", DscLine):
+ if IfStack:
+ IfStack[-1] = not IfStack[-1]
+ else:
+ print("ERROR: No paired '!if' found for '!else' for line '%s'" % DscLine)
+ raise SystemExit
+ elif re.match("^!endif($|\s+#.+)", DscLine):
+ if IfStack:
IfStack.pop()
- Level = Level - 1
+ Level = ElifStack.pop()
+ if Level > 0:
+ del IfStack[-Level:]
+ else:
+ print("ERROR: No paired '!if' found for '!endif' for line '%s'" % DscLine)
+ raise SystemExit
else:
Result = False
- Match = re.match("!(ifdef|ifndef)\s+\$\((\w+)\)", DscLine)
- if Match is not None:
- if Match.group(2) in self._MacroDict:
- if Match.group(1) == 'ifdef':
- Result = True
- else:
- if Match.group(1) == 'ifndef':
- Result = True
- ElifStack.append(0)
+ Match = re.match("!(ifdef|ifndef)\s+(.+)", DscLine)
+ if Match:
+ Result = self.EvaulateIfdef (Match.group(2))
+ if Match.group(1) == 'ifndef':
+ Result = not Result
IfStack.append(Result)
+ ElifStack.append(0)
else:
- Match = re.match("!(if|elseif)\s+\$\\((\w+)\)\s*==\s*(\w+|\$\(\w+\))", DscLine)
- if Match is not None:
- if Match.group(2) in self._MacroDict:
- MacroName = self._MacroDict[Match.group(2)]
- else:
- MacroName = ''
- Value = Match.group(3)
- if Value.startswith('$'):
- if Value[2:-1] in self._MacroDict:
- Value = self._MacroDict[Value[2:-1]]
- else:
- Value = ''
- if MacroName == Value:
- Result = True
+ Match = re.match("!(if|elseif)\s+(.+)", DscLine)
+ if Match:
+ Result = self.EvaluateExpress(Match.group(2))
if Match.group(1) == "if":
ElifStack.append(0)
IfStack.append(Result)
else: #elseif
- IfStack[-1] = not IfStack[-1]
- IfStack.append(Result)
- ElifStack[-1] = ElifStack[-1] + 1
+ if IfStack:
+ IfStack[-1] = not IfStack[-1]
+ IfStack.append(Result)
+ ElifStack[-1] = ElifStack[-1] + 1
+ else:
+ print("ERROR: No paired '!if' found for '!elif' for line '%s'" % DscLine)
+ raise SystemExit
else:
- if len(DscLine) > 0 and DscLine[0] == '!':
- self.Error = "Invalid DscLine '%s'" % DscLine
- Error = 3
- break;
+ if IfStack:
+ Handle = reduce(lambda x,y: x and y, IfStack)
else:
- if reduce(lambda x,y: x and y, IfStack):
- Handle = True
-
+ Handle = True
+ if Handle:
+ Match = re.match("!include\s+(.+)", DscLine)
+ if Match:
+ IncludeFilePath = Match.group(1)
+ IncludeFilePath = self.ExpandMacros(IncludeFilePath)
+ try:
+ IncludeDsc = open(IncludeFilePath, "r")
+ except:
+ print("ERROR: Cannot open file '%s'" % IncludeFilePath)
+ raise SystemExit
+ NewDscLines = IncludeDsc.readlines()
+ IncludeDsc.close()
+ DscLines = NewDscLines + DscLines
+ else:
+ if DscLine.startswith('!'):
+ print("ERROR: Unrecoginized directive for line '%s'" % DscLine)
+ raise SystemExit
if not Handle:
continue
if IsDefSect:
#DEFINE UPD_TOOL_GUID = 8C3D856A-9BE6-468E-850A-24F7A8D38E09
- Match = re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([-\w]+)", DscLine)
+ Match = re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([-.\w]+)", DscLine)
if Match:
self._MacroDict[Match.group(1)] = Match.group(2)
+ if self.Debug:
+ print "INFO : DEFINE %s = [ %s ]" % (Match.group(1), Match.group(2))
else:
Match = re.match("^\s*#\s+!(BSF|HDR)\s+(.+)", DscLine)
if Match:
@@ -291,7 +603,7 @@ EndList
for Key in self._BsfKeyList:
Match = re.match("(?:^|.+\s+)%s:{(.+?)}" % Key, Remaining)
if Match:
- if Key in ['HELP', 'OPTION'] and Match.group(1).startswith('+'):
+ if Key in ['NAME', 'HELP', 'OPTION'] and Match.group(1).startswith('+'):
ConfigDict[Key.lower()] += Match.group(1)[1:]
else:
ConfigDict[Key.lower()] = Match.group(1)
@@ -303,7 +615,7 @@ EndList
# Check VPD/UPD
if IsUpdSect:
- Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]{4})\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
+ Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)
else:
Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)(?:\s*\|\s*(.+))?", DscLine)
if Match:
@@ -337,9 +649,14 @@ EndList
if Match:
if Match.group(1) in self._MacroDict:
Value = self._MacroDict[Match.group(1)]
+
ConfigDict['value'] = Value
+ if (len(Value) > 0) and (Value[0] == '{'):
+ Value = self.FormatListValue(ConfigDict)
+
if ConfigDict['name'] == '':
# Clear BSF specific items
+ ConfigDict['bsfname'] = ''
ConfigDict['help'] = ''
ConfigDict['type'] = ''
ConfigDict['option'] = ''
@@ -348,6 +665,7 @@ EndList
ConfigDict['name'] = ''
ConfigDict['find'] = ''
ConfigDict['struct'] = ''
+ ConfigDict['embed'] = ''
ConfigDict['order'] = -1
ConfigDict['subreg'] = []
else:
@@ -501,26 +819,31 @@ EndList
TxtFd.close()
return 0
- def CreateField (self, Name, Length, Offset, Struct):
+ def CreateField (self, Item, Name, Length, Offset, Struct, BsfName, Help):
PosName = 28
PosComment = 30
+ NameLine=''
+ HelpLine=''
IsArray = False
- if Length == 1:
- Type = "UINT8"
- elif Length == 2:
- Type = "UINT16"
- elif Length == 4:
- Type = "UINT32"
- elif Length == 8:
- Type = "UINT64"
+ if Length in [1,2,4,8]:
+ Type = "UINT%d" % (Length * 8)
else:
+ IsArray = True
+ Type = "UINT8"
+
+ if Item and Item['value'].startswith('{'):
Type = "UINT8"
IsArray = True
if Struct != '':
- IsArray = False
Type = Struct
+ if Struct in ['UINT8','UINT16','UINT32','UINT64']:
+ IsArray = True
+ Unit = int(Type[4:]) / 8
+ Length = Length / Unit
+ else:
+ IsArray = False
if IsArray:
Name = Name + '[%d]' % Length
@@ -530,22 +853,63 @@ EndList
else:
Space1 = 1
- if len(Name) < PosComment:
- Space2 = PosComment - len(Name)
- else:
- Space2 = 1
+ if BsfName != '':
+ NameLine=" %s\n" % BsfName
- return " %s%s%s;%s/* Offset 0x%04X */\n" % (Type, ' ' * Space1, Name, ' ' * Space2, Offset)
+ if Help != '':
+ HelpLine=" %s\n" % Help
+ if Offset is None:
+ OffsetStr = '????'
+ else:
+ OffsetStr = '0x%04X' % Offset
+
+ return "/** Offset %s\n%s%s**/\n %s%s%s;\n" % (OffsetStr, NameLine, HelpLine, Type, ' ' * Space1, Name,)
+
+ def PostProcessBody (self, TextBody):
+ NewTextBody = []
+ OldTextBody = []
+ IncludeLine = False
+ StructName = ''
+ VariableName = ''
+ for Line in TextBody:
+ Match = re.match("^/\*\sEMBED_STRUCT:(\w+):(\w+):(START|END)\s\*/\s([\s\S]*)", Line)
+ if Match:
+ Line = Match.group(4)
+
+ if Match and Match.group(3) == 'START':
+ NewTextBody.append ('typedef struct {\n')
+ StructName = Match.group(1)
+ VariableName = Match.group(2)
+ MatchOffset = re.search('/\*\*\sOffset\s0x([a-fA-F0-9]+)', Line)
+ if MatchOffset:
+ Offset = int(MatchOffset.group(1), 16)
+ else:
+ Offset = None
+ Line
+ IncludeLine = True
+ OldTextBody.append (self.CreateField (None, VariableName, 0, Offset, StructName, '', ''))
+ if IncludeLine:
+ NewTextBody.append (Line)
+ else:
+ OldTextBody.append (Line)
+
+ if Match and Match.group(3) == 'END':
+ if (StructName != Match.group(1)) or (VariableName != Match.group(2)):
+ print "Unmatched struct name '%s' and '%s' !" % (StructName, Match.group(1))
+ else:
+ NewTextBody.append ('} %s;\n\n' % StructName)
+ IncludeLine = False
+ NewTextBody.extend(OldTextBody)
+ return NewTextBody
def CreateHeaderFile (self, InputHeaderFile, IsInternal):
- Error = 0
FvDir = self._FvDir
if IsInternal:
- HeaderFile = os.path.join(FvDir, 'VpdHeader.h')
+ HeaderFile = os.path.join(FvDir, 'FspUpdVpdInternal.h')
else:
- HeaderFile = os.path.join(FvDir, 'fsp_vpd.h')
+ HeaderFile = os.path.join(FvDir, 'FspUpdVpd.h')
# Check if header needs to be recreated
ReCreate = False
@@ -566,36 +930,22 @@ EndList
self.Error = "No DSC or input header file is changed, skip the header file generating"
return 256
- HeaderFd = open(HeaderFile, "w")
- FileBase = os.path.basename(HeaderFile)
- FileName = FileBase.replace(".", "_").upper()
- HeaderFd.write("%s\n" % (__copyright_h__ % date.today().year))
- HeaderFd.write("#ifndef __%s__\n" % FileName)
- HeaderFd.write("#define __%s__\n\n" % FileName)
- HeaderFd.write("#pragma pack(1)\n\n")
-
- if InputHeaderFile != '':
- if not os.path.exists(InputHeaderFile):
- self.Error = "Input header file '%s' does not exist" % InputHeaderFile
- return 2
-
- InFd = open(InputHeaderFile, "r")
- IncLines = InFd.readlines()
- InFd.close()
-
- Export = False
- for Line in IncLines:
- Match = re.search ("!EXPORT\s+EXTERNAL_BOOTLOADER_STRUCT_(BEGIN|END)\s+", Line)
- if Match:
- if Match.group(1) == "BEGIN":
- Export = True
- continue
- else:
- Export = False
- continue
- if Export:
- HeaderFd.write(Line)
- HeaderFd.write("\n\n")
+ TxtBody = []
+ for Item in self._CfgItemList:
+ if str(Item['cname']) == 'Signature' and Item['length'] == 8:
+ Value = int(Item['value'], 16)
+ Chars = []
+ while Value != 0x0:
+ Chars.append(chr(Value & 0xFF))
+ Value = Value >> 8
+ SignatureStr = ''.join(Chars)
+ if int(Item['offset']) == 0:
+ TxtBody.append("#define FSP_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))
+ elif 'MEM' in SignatureStr:
+ TxtBody.append("#define FSP_MEMORY_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))
+ else:
+ TxtBody.append("#define FSP_SILICON_INIT_UPD_SIGNATURE %s /* '%s' */\n" % (Item['value'], SignatureStr))
+ TxtBody.append("\n")
for Region in ['UPD', 'VPD']:
@@ -603,14 +953,12 @@ EndList
if Region[0] == 'V':
if 'VPD_TOOL_GUID' not in self._MacroDict:
self.Error = "VPD_TOOL_GUID definition is missing in DSC file"
- Error = 1
- break
+ return 1
BinFile = os.path.join(FvDir, self._MacroDict['VPD_TOOL_GUID'] + ".bin")
if not os.path.exists(BinFile):
self.Error = "VPD binary file '%s' does not exist" % BinFile
- Error = 2
- break
+ return 2
BinFd = open(BinFile, "rb")
IdStr = BinFd.read(0x08)
@@ -618,10 +966,10 @@ EndList
ImageRev = struct.unpack(' 0:
HelpLines = Item['help'].split('\\n\\r')
FirstLine = True
@@ -825,6 +1234,8 @@ def Main():
print "ERROR: Cannot open DSC file '%s' !" % DscFile
return 2
+ UpdateMemSiUpdInitOffsetValue(DscFile)
+
OutFile = ''
if argc > 4:
if sys.argv[4][0] == '-':
@@ -833,7 +1244,7 @@ def Main():
OutFile = sys.argv[4]
Start = 5
if GenCfgOpt.ParseMacros(sys.argv[Start:]) != 0:
- print "ERROR: %s !" % GenCfgOpt.Error
+ print "ERROR: Macro parsing failed !"
return 3
FvDir = sys.argv[3]
@@ -845,7 +1256,6 @@ def Main():
print "ERROR: %s !" % GenCfgOpt.Error
return 5
-
if GenCfgOpt.UpdateVpdSizeField() != 0:
print "ERROR: %s !" % GenCfgOpt.Error
return 6