## @file\r
# Common routines used by all tools\r
#\r
-# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
# which accompanies this distribution. The full text of the license may be found at\r
status = 0\r
sections = []\r
varoffset = []\r
- for line in lines:\r
+ for index, line in enumerate(lines):\r
line = line.strip()\r
# status machine transection\r
if status == 0 and line == "Memory Configuration":\r
continue\r
\r
# status handler\r
- if status == 2:\r
+ if status == 3:\r
m = re.match('^([\w_\.]+) +([\da-fA-Fx]+) +([\da-fA-Fx]+)$', line)\r
if m != None:\r
sections.append(m.groups(0))\r
for varname in varnames:\r
- m = re.match("^([\da-fA-Fx]+) +[_]*(%s)$" % varname, line)\r
+ Str = ''\r
+ m = re.match("^.data.(%s)" % varname, line)\r
if m != None:\r
- varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
+ m = re.match(".data.(%s)$" % varname, line)\r
+ if m != None:\r
+ Str = lines[index + 1]\r
+ else:\r
+ Str = line[len(".data.%s" % varname):]\r
+ if Str:\r
+ m = re.match('^([\da-fA-Fx]+) +([\da-fA-Fx]+)', Str.strip())\r
+ if m != None:\r
+ varoffset.append((varname, int(m.groups(0)[0], 16) , int(sections[-1][1], 16), sections[-1][0]))\r
\r
if not varoffset:\r
return []\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def GuidValue(CName, PackageList):\r
+def GuidValue(CName, PackageList, Inffile = None):\r
for P in PackageList:\r
- if CName in P.Guids:\r
+ GuidKeys = P.Guids.keys()\r
+ if Inffile and P._PrivateGuids:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ GuidKeys = (dict.fromkeys(x for x in P.Guids if x not in P._PrivateGuids)).keys()\r
+ if CName in GuidKeys:\r
return P.Guids[CName]\r
return None\r
\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def ProtocolValue(CName, PackageList):\r
+def ProtocolValue(CName, PackageList, Inffile = None):\r
for P in PackageList:\r
- if CName in P.Protocols:\r
+ ProtocolKeys = P.Protocols.keys()\r
+ if Inffile and P._PrivateProtocols:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ ProtocolKeys = (dict.fromkeys(x for x in P.Protocols if x not in P._PrivateProtocols)).keys()\r
+ if CName in ProtocolKeys:\r
return P.Protocols[CName]\r
return None\r
\r
#\r
# @param CName The CName of the GUID\r
# @param PackageList List of packages looking-up in\r
+# @param Inffile The driver file\r
#\r
# @retval GuidValue if the CName is found in any given package\r
# @retval None if the CName is not found in all given packages\r
#\r
-def PpiValue(CName, PackageList):\r
+def PpiValue(CName, PackageList, Inffile = None):\r
for P in PackageList:\r
- if CName in P.Ppis:\r
+ PpiKeys = P.Ppis.keys()\r
+ if Inffile and P._PrivatePpis:\r
+ if not Inffile.startswith(P.MetaFile.Dir):\r
+ PpiKeys = (dict.fromkeys(x for x in P.Ppis if x not in P._PrivatePpis)).keys()\r
+ if CName in PpiKeys:\r
return P.Ppis[CName]\r
return None\r
\r
Opr.close()\r
Opw.close()\r
\r
-## AnalyzeDscPcd\r
-#\r
-# Analyze DSC PCD value, since there is no data type info in DSC\r
-# This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcdData, AnalyzeVpdPcdData) used for retrieving PCD value from database\r
-# 1. Feature flag: TokenSpace.PcdCName|PcdValue\r
-# 2. Fix and Patch:TokenSpace.PcdCName|PcdValue[|MaxSize]\r
-# 3. Dynamic default:\r
-# TokenSpace.PcdCName|PcdValue[|VOID*[|MaxSize]]\r
-# TokenSpace.PcdCName|PcdValue\r
-# 4. Dynamic VPD:\r
-# TokenSpace.PcdCName|VpdOffset[|VpdValue]\r
-# TokenSpace.PcdCName|VpdOffset[|MaxSize[|VpdValue]]\r
-# 5. Dynamic HII:\r
-# TokenSpace.PcdCName|HiiString|VaiableGuid|VariableOffset[|HiiValue]\r
-# PCD value needs to be located in such kind of string, and the PCD value might be an expression in which\r
-# there might have "|" operator, also in string value.\r
-#\r
-# @param Setting: String contain information described above with "TokenSpace.PcdCName|" stripped\r
-# @param PcdType: PCD type: feature, fixed, dynamic default VPD HII\r
-# @param DataType: The datum type of PCD: VOID*, UNIT, BOOL\r
-# @retval:\r
-# ValueList: A List contain fields described above\r
-# IsValid: True if conforming EBNF, otherwise False\r
-# Index: The index where PcdValue is in ValueList\r
-#\r
-def AnalyzeDscPcd(Setting, PcdType, DataType=''):\r
+def AnalyzePcdExpression(Setting):\r
Setting = Setting.strip()\r
# There might be escaped quote in a string: \", \\\"\r
Data = Setting.replace('\\\\', '//').replace('\\\"', '\\\'')\r
FieldList.append(Setting[StartPos:Pos].strip())\r
StartPos = Pos + 1\r
\r
+ return FieldList\r
+\r
+## AnalyzeDscPcd\r
+#\r
+# Analyze DSC PCD value, since there is no data type info in DSC\r
+# This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcdData, AnalyzeVpdPcdData) used for retrieving PCD value from database\r
+# 1. Feature flag: TokenSpace.PcdCName|PcdValue\r
+# 2. Fix and Patch:TokenSpace.PcdCName|PcdValue[|MaxSize]\r
+# 3. Dynamic default:\r
+# TokenSpace.PcdCName|PcdValue[|VOID*[|MaxSize]]\r
+# TokenSpace.PcdCName|PcdValue\r
+# 4. Dynamic VPD:\r
+# TokenSpace.PcdCName|VpdOffset[|VpdValue]\r
+# TokenSpace.PcdCName|VpdOffset[|MaxSize[|VpdValue]]\r
+# 5. Dynamic HII:\r
+# TokenSpace.PcdCName|HiiString|VaiableGuid|VariableOffset[|HiiValue]\r
+# PCD value needs to be located in such kind of string, and the PCD value might be an expression in which\r
+# there might have "|" operator, also in string value.\r
+#\r
+# @param Setting: String contain information described above with "TokenSpace.PcdCName|" stripped\r
+# @param PcdType: PCD type: feature, fixed, dynamic default VPD HII\r
+# @param DataType: The datum type of PCD: VOID*, UNIT, BOOL\r
+# @retval:\r
+# ValueList: A List contain fields described above\r
+# IsValid: True if conforming EBNF, otherwise False\r
+# Index: The index where PcdValue is in ValueList\r
+#\r
+def AnalyzeDscPcd(Setting, PcdType, DataType=''):\r
+ FieldList = AnalyzePcdExpression(Setting)\r
+\r
IsValid = True\r
if PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG):\r
Value = FieldList[0]\r