|
From: <yi...@us...> - 2012-07-03 06:44:51
|
Revision: 2545
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2545&view=rev
Author: yingke
Date: 2012-07-03 06:44:40 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
Fix PCD bugs:
1. The PCD value in DSC does not match the data type declared in DEC files.
2. Cannot evaluate expression which contains "|" in it.
3. The max size of PCD defined in DSC is always ignored.
4. The PCD value defined in DSC cannot be retrieved sometimes.
Reviewed-by: Su Jikui <jik...@in...>
Reviewed-by: Zeng Yurui <yur...@in...>
Signed-off-by: Liu Yingke <yin...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/AutoGen/AutoGen.py
trunk/BaseTools/Source/Python/Common/Misc.py
trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py
trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
Added Paths:
-----------
trunk/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
Modified: trunk/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- trunk/BaseTools/Source/Python/AutoGen/AutoGen.py 2012-07-03 02:53:29 UTC (rev 2544)
+++ trunk/BaseTools/Source/Python/AutoGen/AutoGen.py 2012-07-03 06:44:40 UTC (rev 2545)
@@ -300,7 +300,6 @@
for Pcd in Pkg.Pcds:
DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]
DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2]))
- Platform.IsPlatformPcdDeclared(DecPcds)
Platform.SkuName = self.SkuId
for Name, Guid in PcdSet:
Modified: trunk/BaseTools/Source/Python/Common/Misc.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/Misc.py 2012-07-03 02:53:29 UTC (rev 2544)
+++ trunk/BaseTools/Source/Python/Common/Misc.py 2012-07-03 06:44:40 UTC (rev 2545)
@@ -30,6 +30,7 @@
from Common import GlobalData as GlobalData
from DataType import *
from BuildToolError import *
+from CommonDataClass.DataClass import *
## Regular expression used to find out place holders in string template
gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE)
@@ -1176,6 +1177,113 @@
Opr.close()
Opw.close()
+## AnalyzeDscPcd
+#
+# Analyze DSC PCD value, since there is no data type info in DSC
+# This fuction is used to match functions (AnalyzePcdData, AnalyzeHiiPcdData, AnalyzeVpdPcdData) used for retrieving PCD value from database
+# 1. Feature flag: TokenSpace.PcdCName|PcdValue
+# 2. Fix and Patch:TokenSpace.PcdCName|PcdValue[|MaxSize]
+# 3. Dynamic default:
+# TokenSpace.PcdCName|PcdValue[|VOID*[|MaxSize]]
+# TokenSpace.PcdCName|PcdValue
+# 4. Dynamic VPD:
+# TokenSpace.PcdCName|VpdOffset[|VpdValue]
+# TokenSpace.PcdCName|VpdOffset[|MaxSize[|VpdValue]]
+# 5. Dynamic HII:
+# TokenSpace.PcdCName|HiiString|VaiableGuid|VariableOffset[|HiiValue]
+# PCD value needs to be located in such kind of string, and the PCD value might be an expression in which
+# there might have "|" operator, also in string value.
+#
+# @param Setting: String contain information described above with "TokenSpace.PcdCName|" stripped
+# @param PcdType: PCD type: feature, fixed, dynamic default VPD HII
+# @param DataType: The datum type of PCD: VOID*, UNIT, BOOL
+# @retval:
+# ValueList: A List contain fields described above
+# IsValid: True if conforming EBNF, otherwise False
+# Index: The index where PcdValue is in ValueList
+#
+def AnalyzeDscPcd(Setting, PcdType, DataType=''):
+ Setting = Setting.strip()
+ # There might be escaped quote in a string: \", \\\"
+ Data = Setting.replace('\\\\', '//').replace('\\\"', '\\\'')
+ # There might be '|' in string and in ( ... | ... ), replace it with '-'
+ NewStr = ''
+ InStr = False
+ Pair = 0
+ for ch in Data:
+ if ch == '"':
+ InStr = not InStr
+ elif ch == '(' and not InStr:
+ Pair += 1
+ elif ch == ')' and not InStr:
+ Pair -= 1
+
+ if (Pair > 0 or InStr) and ch == TAB_VALUE_SPLIT:
+ NewStr += '-'
+ else:
+ NewStr += ch
+ FieldList = []
+ StartPos = 0
+ while True:
+ Pos = NewStr.find(TAB_VALUE_SPLIT, StartPos)
+ if Pos < 0:
+ FieldList.append(Setting[StartPos:].strip())
+ break
+ FieldList.append(Setting[StartPos:Pos].strip())
+ StartPos = Pos + 1
+
+ IsValid = True
+ if PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG):
+ Value = FieldList[0]
+ Size = ''
+ if len(FieldList) > 1:
+ Size = FieldList[1]
+ if DataType == 'VOID*':
+ IsValid = (len(FieldList) <= 2)
+ else:
+ IsValid = (len(FieldList) <= 1)
+ return [Value, '', Size], IsValid, 0
+ elif PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT):
+ Value = FieldList[0]
+ Size = Type = ''
+ if len(FieldList) > 1:
+ Type = FieldList[1]
+ if len(FieldList) > 2:
+ Size = FieldList[2]
+ if DataType == 'VOID*':
+ IsValid = (len(FieldList) <= 3)
+ else:
+ IsValid = (len(FieldList) <= 1)
+ return [Value, Type, Size], IsValid, 0
+ elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD):
+ VpdOffset = FieldList[0]
+ Value = Size = ''
+ if not DataType == 'VOID*':
+ if len(FieldList) > 1:
+ Value = FieldList[1]
+ else:
+ if len(FieldList) > 1:
+ Size = FieldList[1]
+ if len(FieldList) > 2:
+ Value = FieldList[2]
+ if DataType == 'VOID*':
+ IsValid = (len(FieldList) <= 3)
+ else:
+ IsValid = (len(FieldList) <= 2)
+ return [VpdOffset, Size, Value], IsValid, 2
+ elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
+ HiiString = FieldList[0]
+ Guid = Offset = Value = ''
+ if len(FieldList) > 1:
+ Guid = FieldList[1]
+ if len(FieldList) > 2:
+ Offset = FieldList[2]
+ if len(FieldList) > 3:
+ Value = FieldList[3]
+ IsValid = (3 <= len(FieldList) <= 4)
+ return [HiiString, Guid, Offset, Value], IsValid, 3
+ return [], False, 0
+
## AnalyzePcdData
#
# Analyze the pcd Value, Datum type and TokenNumber.
Modified: trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py 2012-07-03 02:53:29 UTC (rev 2544)
+++ trunk/BaseTools/Source/Python/Workspace/MetaFileParser.py 2012-07-03 06:44:40 UTC (rev 2545)
@@ -25,7 +25,7 @@
from CommonDataClass.DataClass import *
from Common.DataType import *
from Common.String import *
-from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData
+from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd
from Common.Expression import *
from CommonDataClass.Exceptions import *
@@ -1273,15 +1273,15 @@
def __RetrievePcdValue(self):
Records = self._RawTable.Query(MODEL_PCD_FEATURE_FLAG, BelongsToItem= -1.0)
for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records:
- Value, DatumType, MaxDatumSize = AnalyzePcdData(Value)
Name = TokenSpaceGuid + '.' + PcdName
- self._Symbols[Name] = Value
+ ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FEATURE_FLAG)
+ self._Symbols[Name] = ValList[Index]
Records = self._RawTable.Query(MODEL_PCD_FIXED_AT_BUILD, BelongsToItem= -1.0)
for TokenSpaceGuid, PcdName, Value, Dummy2, Dummy3, ID, Line in Records:
- Value, DatumType, MaxDatumSize = AnalyzePcdData(Value)
Name = TokenSpaceGuid + '.' + PcdName
- self._Symbols[Name] = Value
+ ValList, Valid, Index = AnalyzeDscPcd(Value, MODEL_PCD_FIXED_AT_BUILD)
+ self._Symbols[Name] = ValList[Index]
Content = open(str(self.MetaFile), 'r').readlines()
GlobalData.gPlatformOtherPcds['DSCFILE'] = str(self.MetaFile)
@@ -1448,50 +1448,28 @@
self._ValueList[1] = ReplaceMacro(self._ValueList[1], self._Macros, RaiseError=True)
def __ProcessPcd(self):
- PcdValue = None
- ValueList = GetSplitValueList(self._ValueList[2])
+ if self._ItemType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
+ self._ValueList[2] = ReplaceMacro(self._ValueList[2], self._Macros, RaiseError=True)
+ return
- #
- # PCD value can be an expression
- #
- if len(ValueList) > 1 and ValueList[1] == TAB_VOID:
- PcdValue = ValueList[0]
- try:
- ValueList[0] = ValueExpression(PcdValue, self._Macros)(True)
- except WrnExpression, Value:
- ValueList[0] = Value.result
- PcdValue = ValueList[0]
- else:
- #
- # Int*/Boolean VPD PCD
- # TokenSpace | PcdCName | Offset | [Value]
- #
- # VOID* VPD PCD
- # TokenSpace | PcdCName | Offset | [Size] | [Value]
- #
- if self._ItemType == MODEL_PCD_DYNAMIC_VPD:
- if len(ValueList) >= 4:
- PcdValue = ValueList[-1]
- else:
- PcdValue = ValueList[-1]
- #
- # For the VPD PCD, there may not have PcdValue data in DSC file
- #
- if PcdValue:
- try:
- ValueList[-1] = ValueExpression(PcdValue, self._Macros)(True)
- except WrnExpression, Value:
- ValueList[-1] = Value.result
+ ValList, Valid, Index = AnalyzeDscPcd(self._ValueList[2], self._ItemType)
+ if not Valid:
+ EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self._FileWithError, Line=self._LineIndex+1,
+ ExtraData="%s.%s|%s" % (self._ValueList[0], self._ValueList[1], self._ValueList[2]))
+ PcdValue = ValList[Index]
+ try:
+ ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)
+ except WrnExpression, Value:
+ ValList[Index] = Value.result
- if ValueList[-1] == 'True':
- ValueList[-1] = '1'
- if ValueList[-1] == 'False':
- ValueList[-1] = '0'
- PcdValue = ValueList[-1]
- if PcdValue and self._ItemType in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
- GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue
- self._ValueList[2] = '|'.join(ValueList)
+ if ValList[Index] == 'True':
+ ValList[Index] = '1'
+ if ValList[Index] == 'False':
+ ValList[Index] = '0'
+ GlobalData.gPlatformPcds[TAB_SPLIT.join(self._ValueList[0:2])] = PcdValue
+ self._ValueList[2] = '|'.join(ValList)
+
def __ProcessComponent(self):
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
Added: trunk/BaseTools/Source/Python/Workspace/WorkspaceCommon.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/WorkspaceCommon.py (rev 0)
+++ trunk/BaseTools/Source/Python/Workspace/WorkspaceCommon.py 2012-07-03 06:44:40 UTC (rev 2545)
@@ -0,0 +1,237 @@
+## @file
+# Common routines used by workspace
+#
+# Copyright (c) 2012, 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
+from Common.Misc import sdict
+from Common.DataType import SUP_MODULE_USER_DEFINED
+from BuildClassObject import LibraryClassObject
+
+## Get all packages from platform for specified arch, target and toolchain
+#
+# @param Platform: DscBuildData instance
+# @param BuildDatabase: The database saves all data for all metafiles
+# @param Arch: Current arch
+# @param Target: Current target
+# @param Toolchain: Current toolchain
+# @retval: List of packages which are DecBuildData instances
+#
+def GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain):
+ PkgSet = set()
+ for ModuleFile in Platform.Modules:
+ Data = BuildDatabase[ModuleFile, Arch, Target, Toolchain]
+ PkgSet.update(Data.Packages)
+ for Lib in GetLiabraryInstances(Data, Platform, BuildDatabase, Arch, Target, Toolchain):
+ PkgSet.update(Lib.Packages)
+ return list(PkgSet)
+
+## Get all declared PCD from platform for specified arch, target and toolchain
+#
+# @param Platform: DscBuildData instance
+# @param BuildDatabase: The database saves all data for all metafiles
+# @param Arch: Current arch
+# @param Target: Current target
+# @param Toolchain: Current toolchain
+# @retval: A dictionary contains instances of PcdClassObject with key (PcdCName, TokenSpaceGuid)
+#
+def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target, Toolchain):
+ PkgList = GetPackageList(Platform, BuildDatabase, Arch, Target, Toolchain)
+ DecPcds = {}
+ for Pkg in PkgList:
+ for Pcd in Pkg.Pcds:
+ DecPcds[Pcd[0], Pcd[1]] = Pkg.Pcds[Pcd]
+ return DecPcds
+
+## Get all dependent libraries for a module
+#
+# @param Module: InfBuildData instance
+# @param Platform: DscBuildData instance
+# @param BuildDatabase: The database saves all data for all metafiles
+# @param Arch: Current arch
+# @param Target: Current target
+# @param Toolchain: Current toolchain
+# @retval: List of dependent libraries which are InfBuildData instances
+#
+def GetLiabraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
+ if Module.AutoGenVersion >= 0x00010005:
+ return _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain)
+ else:
+ return _ResolveLibraryReference(Module, Platform)
+
+def _GetModuleLibraryInstances(Module, Platform, BuildDatabase, Arch, Target, Toolchain):
+ ModuleType = Module.ModuleType
+
+ # for overriding library instances with module specific setting
+ PlatformModule = Platform.Modules[str(Module)]
+
+ # add forced library instances (specified under LibraryClasses sections)
+ #
+ # If a module has a MODULE_TYPE of USER_DEFINED,
+ # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
+ #
+ if Module.ModuleType != SUP_MODULE_USER_DEFINED:
+ for LibraryClass in Platform.LibraryClasses.GetKeys():
+ if LibraryClass.startswith("NULL") and Platform.LibraryClasses[LibraryClass, Module.ModuleType]:
+ Module.LibraryClasses[LibraryClass] = Platform.LibraryClasses[LibraryClass, Module.ModuleType]
+
+ # add forced library instances (specified in module overrides)
+ for LibraryClass in PlatformModule.LibraryClasses:
+ if LibraryClass.startswith("NULL"):
+ Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]
+
+ # EdkII module
+ LibraryConsumerList = [Module]
+ Constructor = []
+ ConsumedByList = sdict()
+ LibraryInstance = sdict()
+
+ while len(LibraryConsumerList) > 0:
+ M = LibraryConsumerList.pop()
+ for LibraryClassName in M.LibraryClasses:
+ if LibraryClassName not in LibraryInstance:
+ # override library instance for this module
+ if LibraryClassName in PlatformModule.LibraryClasses:
+ LibraryPath = PlatformModule.LibraryClasses[LibraryClassName]
+ else:
+ LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType]
+ if LibraryPath == None or LibraryPath == "":
+ LibraryPath = M.LibraryClasses[LibraryClassName]
+ if LibraryPath == None or LibraryPath == "":
+ return []
+
+ LibraryModule = BuildDatabase[LibraryPath, Arch, Target, Toolchain]
+ # for those forced library instance (NULL library), add a fake library class
+ if LibraryClassName.startswith("NULL"):
+ LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))
+ elif LibraryModule.LibraryClass == None \
+ or len(LibraryModule.LibraryClass) == 0 \
+ or (ModuleType != 'USER_DEFINED'
+ and ModuleType not in LibraryModule.LibraryClass[0].SupModList):
+ # only USER_DEFINED can link against any library instance despite of its SupModList
+ return []
+
+ LibraryInstance[LibraryClassName] = LibraryModule
+ LibraryConsumerList.append(LibraryModule)
+ else:
+ LibraryModule = LibraryInstance[LibraryClassName]
+
+ if LibraryModule == None:
+ continue
+
+ if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:
+ Constructor.append(LibraryModule)
+
+ if LibraryModule not in ConsumedByList:
+ ConsumedByList[LibraryModule] = []
+ # don't add current module itself to consumer list
+ if M != Module:
+ if M in ConsumedByList[LibraryModule]:
+ continue
+ ConsumedByList[LibraryModule].append(M)
+ #
+ # Initialize the sorted output list to the empty set
+ #
+ SortedLibraryList = []
+ #
+ # Q <- Set of all nodes with no incoming edges
+ #
+ LibraryList = [] #LibraryInstance.values()
+ Q = []
+ for LibraryClassName in LibraryInstance:
+ M = LibraryInstance[LibraryClassName]
+ LibraryList.append(M)
+ if ConsumedByList[M] == []:
+ Q.append(M)
+
+ #
+ # start the DAG algorithm
+ #
+ while True:
+ EdgeRemoved = True
+ while Q == [] and EdgeRemoved:
+ EdgeRemoved = False
+ # for each node Item with a Constructor
+ for Item in LibraryList:
+ if Item not in Constructor:
+ continue
+ # for each Node without a constructor with an edge e from Item to Node
+ for Node in ConsumedByList[Item]:
+ if Node in Constructor:
+ continue
+ # remove edge e from the graph if Node has no constructor
+ ConsumedByList[Item].remove(Node)
+ EdgeRemoved = True
+ if ConsumedByList[Item] == []:
+ # insert Item into Q
+ Q.insert(0, Item)
+ break
+ if Q != []:
+ break
+ # DAG is done if there's no more incoming edge for all nodes
+ if Q == []:
+ break
+
+ # remove node from Q
+ Node = Q.pop()
+ # output Node
+ SortedLibraryList.append(Node)
+
+ # for each node Item with an edge e from Node to Item do
+ for Item in LibraryList:
+ if Node not in ConsumedByList[Item]:
+ continue
+ # remove edge e from the graph
+ ConsumedByList[Item].remove(Node)
+
+ if ConsumedByList[Item] != []:
+ continue
+ # insert Item into Q, if Item has no other incoming edges
+ Q.insert(0, Item)
+
+ #
+ # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
+ #
+ for Item in LibraryList:
+ if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:
+ return []
+ if Item not in SortedLibraryList:
+ SortedLibraryList.append(Item)
+
+ #
+ # Build the list of constructor and destructir names
+ # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
+ #
+ SortedLibraryList.reverse()
+ return SortedLibraryList
+
+def _ResolveLibraryReference(Module, Platform):
+ LibraryConsumerList = [Module]
+
+ # "CompilerStub" is a must for Edk modules
+ if Module.Libraries:
+ Module.Libraries.append("CompilerStub")
+ LibraryList = []
+ while len(LibraryConsumerList) > 0:
+ M = LibraryConsumerList.pop()
+ for LibraryName in M.Libraries:
+ Library = Platform.LibraryClasses[LibraryName, ':dummy:']
+ if Library == None:
+ for Key in Platform.LibraryClasses.data.keys():
+ if LibraryName.upper() == Key.upper():
+ Library = Platform.LibraryClasses[Key, ':dummy:']
+ break
+ if Library == None:
+ continue
+
+ if Library not in LibraryList:
+ LibraryList.append(Library)
+ LibraryConsumerList.append(Library)
+ return LibraryList
Modified: trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2012-07-03 02:53:29 UTC (rev 2544)
+++ trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2012-07-03 06:44:40 UTC (rev 2545)
@@ -34,6 +34,8 @@
from MetaFileTable import *
from MetaFileParser import *
from BuildClassObject import *
+from WorkspaceCommon import GetDeclaredPcd
+from Common.Misc import AnalyzeDscPcd
## Platform build information from DSC file
#
@@ -134,6 +136,7 @@
self._LibraryInstances = None
self._LibraryClasses = None
self._Pcds = None
+ self._DecPcds = None
self._BuildOptions = None
self._LoadFixAddress = None
self._RFCLanguages = None
@@ -613,6 +616,45 @@
self._LibraryClasses[Library.BaseName, ':dummy:'] = Library
return self._LibraryClasses
+ def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo):
+ if self._DecPcds == None:
+ self._DecPcds = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain)
+ if (PcdCName, TokenSpaceGuid) not in self._DecPcds:
+ EdkLogger.error('build', PARSER_ERROR,
+ "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName),
+ File=self.MetaFile, Line=LineNo)
+ ValueList, IsValid, Index = AnalyzeDscPcd(Setting, PcdType, self._DecPcds[PcdCName, TokenSpaceGuid].DatumType)
+ if not IsValid and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
+ EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo,
+ ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))
+ if PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
+ try:
+ ValueList[Index] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True)
+ except WrnExpression, Value:
+ ValueList[Index] = Value.result
+ except EvaluationException, Excpt:
+ if hasattr(Excpt, 'Pcd'):
+ if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"
+ " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
+ " of the DSC file" % Excpt.Pcd,
+ File=self.MetaFile, Line=LineNo)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd,
+ File=self.MetaFile, Line=LineNo)
+ else:
+ EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
+ File=self.MetaFile, Line=LineNo)
+ if ValueList[Index] == 'True':
+ ValueList[Index] = '1'
+ elif ValueList[Index] == 'False':
+ ValueList[Index] = '0'
+ Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index])
+ if not Valid:
+ EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo,
+ ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName))
+ return ValueList
+
## Retrieve all PCD settings in platform
def _GetPcds(self):
if self._Pcds == None:
@@ -663,14 +705,14 @@
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid))
+ PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4))
PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates
- for PcdCName, TokenSpaceGuid in PcdSet:
+ for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet:
Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting)
+ PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -702,15 +744,15 @@
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdList.append((PcdCName, TokenSpaceGuid))
+ PcdList.append((PcdCName, TokenSpaceGuid, Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid in PcdList:
+ for PcdCName, TokenSpaceGuid, Dummy4 in PcdList:
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting)
+ PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', '', PcdValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
@@ -744,14 +786,14 @@
RecordList = self._RawData[Type, self._Arch]
# Find out all possible PCD candidates for self._Arch
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid))
+ PcdSet.add((PcdCName, TokenSpaceGuid, Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid in PcdSet:
+ for PcdCName, TokenSpaceGuid, Dummy4 in PcdSet:
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- VariableName, VariableGuid, VariableOffset, DefaultValue = AnalyzeHiiPcdData(Setting)
+ VariableName, VariableGuid, VariableOffset, DefaultValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
@@ -784,10 +826,10 @@
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdList.append((PcdCName, TokenSpaceGuid))
+ PcdList.append((PcdCName, TokenSpaceGuid, Dummy4))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid in PcdList:
+ for PcdCName, TokenSpaceGuid, Dummy4 in PcdList:
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
@@ -797,7 +839,7 @@
# At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype
# until the DEC parser has been called.
#
- VpdOffset, MaxDatumSize, InitialValue = AnalyzeVpdPcdData(Setting)
+ VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset, InitialValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
@@ -842,46 +884,6 @@
self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None)
self.Pcds[Name, Guid].DefaultValue = Value
- def IsPlatformPcdDeclared(self, DecPcds):
- for PcdType in (MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_FEATURE_FLAG,
- MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_VPD,
- MODEL_PCD_DYNAMIC_EX_DEFAULT, MODEL_PCD_DYNAMIC_EX_HII, MODEL_PCD_DYNAMIC_EX_VPD):
- RecordList = self._RawData[PcdType, self._Arch]
- for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- if (PcdCName, TokenSpaceGuid) not in DecPcds:
- EdkLogger.error('build', PARSER_ERROR,
- "Pcd (%s.%s) defined in DSC is not declared in DEC files." % (TokenSpaceGuid, PcdCName),
- File=self.MetaFile, Line=Dummy4)
- PcdValue = ''
- if PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD):
- if DecPcds[PcdCName, TokenSpaceGuid].DatumType == "VOID*":
- PcdValue = AnalyzeVpdPcdData(Setting)[2]
- PcdMaxDatumSize = AnalyzeVpdPcdData(Setting)[1]
- # Check The MaxDatumSize is valid
- try:
- Value = long(PcdMaxDatumSize, 0)
- except ValueError:
- EdkLogger.error("build", FORMAT_INVALID, "PCD setting error",
- File=self.MetaFile, Line=Dummy4,
- ExtraData="\n\tPCD: The MaxDatumSize [%s] of %s.%s must be a hexadecimal or decimal in C language format in DSC: %s\n\t\t\n"
- % (PcdMaxDatumSize, TokenSpaceGuid, PcdCName, self.MetaFile.Path))
- if Value < 0x00 or Value > 0xFFFFFFFF:
- EdkLogger.error("build", FORMAT_INVALID, "PCD setting error",
- File=self.MetaFile, Line=Dummy4,
- ExtraData="\n\tPCD: The MaxDatumSize [%s] of %s.%s exceed the valid scope(0x0 - 0xFFFFFFFF) in DSC: %s\n\t\t\n"
- % (PcdMaxDatumSize, TokenSpaceGuid, PcdCName, self.MetaFile.Path))
- else:
- PcdValue = AnalyzeVpdPcdData(Setting)[1]
- elif PcdType in (MODEL_PCD_DYNAMIC_HII, MODEL_PCD_DYNAMIC_EX_HII):
- PcdValue = AnalyzeHiiPcdData(Setting)[3]
- else:
- PcdValue = AnalyzePcdData(Setting)[0]
- if PcdValue:
- Valid, ErrStr = CheckPcdDatum(DecPcds[PcdCName, TokenSpaceGuid].DatumType, PcdValue)
- if not Valid:
- EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=Dummy4,
- ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName))
-
_Macros = property(_GetMacros)
Arch = property(_GetArch, _SetArch)
Platform = property(_GetPlatformName)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|