|
From: <xf...@us...> - 2012-05-31 03:07:11
|
Revision: 2529
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2529&view=rev
Author: xfzyr
Date: 2012-05-31 03:07:05 +0000 (Thu, 31 May 2012)
Log Message:
-----------
Add the check for PCD string value and the Maximum size value.
Signed-off-by: Yurui Zeng <yur...@in...>
Reviewed-by: Boyer, Donna J <don...@in...>
Modified Paths:
--------------
trunk/BaseTools/Source/Python/Common/DataType.py
trunk/BaseTools/Source/Python/Common/Misc.py
trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
Modified: trunk/BaseTools/Source/Python/Common/DataType.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/DataType.py 2012-05-29 08:21:34 UTC (rev 2528)
+++ trunk/BaseTools/Source/Python/Common/DataType.py 2012-05-31 03:07:05 UTC (rev 2529)
@@ -31,6 +31,9 @@
TAB_SLASH = '\\'
TAB_BACK_SLASH = '/'
TAB_LINE_BREAK = '\n'
+TAB_PRINTCHAR_VT = '\x0b'
+TAB_PRINTCHAR_BS = '\b'
+TAB_PRINTCHAR_NUL = '\0'
TAB_UINT8 = 'UINT8'
TAB_UINT16 = 'UINT16'
TAB_UINT32 = 'UINT32'
Modified: trunk/BaseTools/Source/Python/Common/Misc.py
===================================================================
--- trunk/BaseTools/Source/Python/Common/Misc.py 2012-05-29 08:21:34 UTC (rev 2528)
+++ trunk/BaseTools/Source/Python/Common/Misc.py 2012-05-31 03:07:05 UTC (rev 2529)
@@ -1236,12 +1236,12 @@
## AnalyzeVpdPcdData
#
-# Analyze the vpd pcd Value, Datum type and TokenNumber.
+# Analyze the vpd pcd VpdOffset, MaxDatumSize and InitialValue.
# Used to avoid split issue while the value string contain "|" character
#
-# @param[in] Setting: A String contain value/datum type/token number information;
+# @param[in] Setting: A String contain VpdOffset/MaxDatumSize/InitialValue information;
#
-# @retval ValueList: A List contain value, datum type and toke number.
+# @retval ValueList: A List contain VpdOffset, MaxDatumSize and InitialValue.
#
def AnalyzeVpdPcdData(Setting):
ValueList = ['', '', '']
@@ -1269,11 +1269,26 @@
#
def CheckPcdDatum(Type, Value):
if Type == "VOID*":
+ ValueRe = re.compile(r'\s*L?\".*\"\s*$')
if not (((Value.startswith('L"') or Value.startswith('"')) and Value.endswith('"'))
or (Value.startswith('{') and Value.endswith('}'))
):
return False, "Invalid value [%s] of type [%s]; must be in the form of {...} for array"\
- ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)
+ ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)
+ elif ValueRe.match(Value):
+ # Check the chars in UnicodeString or CString is printable
+ if Value.startswith("L"):
+ Value = Value[2:-1]
+ else:
+ Value = Value[1:-1]
+ Printset = set(string.printable)
+ Printset.remove(TAB_PRINTCHAR_VT)
+ Printset.add(TAB_PRINTCHAR_BS)
+ Printset.add(TAB_PRINTCHAR_NUL)
+ if not set(Value).issubset(Printset):
+ PrintList = list(Printset)
+ PrintList.sort()
+ return False, "Invalid PCD string value of type [%s]; must be printable chars %s." % (Type, PrintList)
elif Type == 'BOOLEAN':
if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 'False', 'false', '0x0', '0x00', '0']:
return False, "Invalid value [%s] of type [%s]; must be one of TRUE, True, true, 0x1, 0x01, 1"\
Modified: trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py
===================================================================
--- trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2012-05-29 08:21:34 UTC (rev 2528)
+++ trunk/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py 2012-05-31 03:07:05 UTC (rev 2529)
@@ -856,6 +856,20 @@
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):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|