* [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) @ 2018-04-11 23:08 Jaben 2018-04-11 23:08 ` [PATCH v1 1/4] BaseTools: remove duplicate function name Jaben ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Jaben @ 2018-04-11 23:08 UTC (permalink / raw) To: edk2-devel refactor to reduce duplication remove a duplicate function name (I presume this branch never executes as it would have had exception) Jaben (4): BaseTools: remove duplicate function name BaseTools: replace 'UINT8','UINT16','UINT32','UINT64','VOID*' with shared constants. BaseTools: Remove un-needed list comprehension BaseTools: merge towards minimum PCD MAX <something> methods BaseTools/Source/Python/AutoGen/AutoGen.py | 26 +++--- BaseTools/Source/Python/AutoGen/GenC.py | 94 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 23 ++--- BaseTools/Source/Python/AutoGen/GenVar.py | 29 +++--- BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py | 9 +- BaseTools/Source/Python/Common/DataType.py | 16 ++-- BaseTools/Source/Python/Common/Expression.py | 61 ++++++------- BaseTools/Source/Python/Common/Misc.py | 12 +-- BaseTools/Source/Python/Common/RangeExpression.py | 25 ++---- BaseTools/Source/Python/Common/VpdInfoFile.py | 9 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 2 +- BaseTools/Source/Python/Eot/FvImage.py | 4 +- BaseTools/Source/Python/GenFds/FdfParser.py | 15 ++-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 11 ++- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 21 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 69 ++++++-------- BaseTools/Source/Python/build/BuildReport.py | 4 +- 18 files changed, 211 insertions(+), 223 deletions(-) -- 2.16.2.windows.1 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/4] BaseTools: remove duplicate function name 2018-04-11 23:08 [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) Jaben @ 2018-04-11 23:08 ` Jaben 2018-04-18 8:37 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants Jaben ` (2 subsequent siblings) 3 siblings, 1 reply; 9+ messages in thread From: Jaben @ 2018-04-11 23:08 UTC (permalink / raw) To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Eot/FvImage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py index 472ae400506d..39c31d768d5d 100644 --- a/BaseTools/Source/Python/Eot/FvImage.py +++ b/BaseTools/Source/Python/Eot/FvImage.py @@ -1,7 +1,7 @@ ## @file # Parse FV image # -# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2008 - 2018, 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 @@ -363,7 +363,7 @@ class FirmwareVolume(Image): NewFfs = self.UnDispatchedFfsDict.pop(FfsID) NewFfs.Depex = DepexString if FileDepex is not None: - ScheduleList.insert.insert(FileDepex[1], FfsID, NewFfs, FileDepex[0]) + ScheduleList.insert(FileDepex[1], FfsID, NewFfs, FileDepex[0]) else: ScheduleList[FfsID] = NewFfs else: -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/4] BaseTools: remove duplicate function name 2018-04-11 23:08 ` [PATCH v1 1/4] BaseTools: remove duplicate function name Jaben @ 2018-04-18 8:37 ` Zhu, Yonghong 0 siblings, 0 replies; 9+ messages in thread From: Zhu, Yonghong @ 2018-04-18 8:37 UTC (permalink / raw) To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben Sent: Thursday, April 12, 2018 7:08 AM To: edk2-devel@lists.01.org Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com> Subject: [PATCH v1 1/4] BaseTools: remove duplicate function name Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Eot/FvImage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/Python/Eot/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py index 472ae400506d..39c31d768d5d 100644 --- a/BaseTools/Source/Python/Eot/FvImage.py +++ b/BaseTools/Source/Python/Eot/FvImage.py @@ -1,7 +1,7 @@ ## @file # Parse FV image # -# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2008 - 2018, 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 @@ -363,7 +363,7 @@ class FirmwareVolume(Image): NewFfs = self.UnDispatchedFfsDict.pop(FfsID) NewFfs.Depex = DepexString if FileDepex is not None: - ScheduleList.insert.insert(FileDepex[1], FfsID, NewFfs, FileDepex[0]) + ScheduleList.insert(FileDepex[1], FfsID, + NewFfs, FileDepex[0]) else: ScheduleList[FfsID] = NewFfs else: -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants. 2018-04-11 23:08 [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) Jaben 2018-04-11 23:08 ` [PATCH v1 1/4] BaseTools: remove duplicate function name Jaben @ 2018-04-11 23:08 ` Jaben 2018-04-17 13:32 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension Jaben 2018-04-11 23:08 ` [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods Jaben 3 siblings, 1 reply; 9+ messages in thread From: Jaben @ 2018-04-11 23:08 UTC (permalink / raw) To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 26 +++--- BaseTools/Source/Python/AutoGen/GenC.py | 94 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 23 ++--- BaseTools/Source/Python/AutoGen/GenVar.py | 29 +++--- BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py | 9 +- BaseTools/Source/Python/Common/DataType.py | 6 +- BaseTools/Source/Python/Common/Expression.py | 61 ++++++------- BaseTools/Source/Python/Common/Misc.py | 12 +-- BaseTools/Source/Python/Common/RangeExpression.py | 9 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 7 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 15 ++-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 7 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 21 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 48 +++++----- BaseTools/Source/Python/build/BuildReport.py | 4 +- 17 files changed, 191 insertions(+), 186 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index dbc9f893c2f1..8f663b8318f9 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1401,7 +1401,7 @@ class PlatformAutoGen(AutoGen): for PcdFromModule in M.ModulePcdList + M.LibraryPcdList: # make sure that the "VOID*" kind of datum has MaxDatumSize set - if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F)) # Check the PCD from Binary INF or Source INF @@ -1483,7 +1483,7 @@ class PlatformAutoGen(AutoGen): ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n" % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName)) # make sure that the "VOID*" kind of datum has MaxDatumSize set - if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName)) if M.ModuleType in ["PEIM", "PEI_CORE"]: PcdFromModule.Phase = "PEI" @@ -1548,7 +1548,7 @@ class PlatformAutoGen(AutoGen): for item in self._PlatformPcds: if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - self._PlatformPcds[item].DatumType = "VOID*" + self._PlatformPcds[item].DatumType = TAB_VOID if (self.Workspace.ArchList[-1] == self.Arch): for Pcd in self._DynamicPcdList: @@ -1557,7 +1557,7 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset = Sku.VpdOffset.strip() if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType = "VOID*" + Pcd.DatumType = TAB_VOID # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex # if found HII type PCD then insert to right of UnicodeIndex @@ -1709,7 +1709,7 @@ class PlatformAutoGen(AutoGen): SkuValueMap[PcdValue].append(Sku) if not NeedProcessVpdMapFile and Sku.VpdOffset == "*": NeedProcessVpdMapFile = True - if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"): + if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"): UnicodePcdArray.add(DscPcdEntry) elif len(Sku.VariableName) > 0: HiiPcdArray.add(DscPcdEntry) @@ -1756,10 +1756,10 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset = Sku.VpdOffset.strip() if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType = "VOID*" + Pcd.DatumType = TAB_VOID PcdValue = Sku.DefaultValue - if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"): + if Pcd.DatumType == TAB_VOID and PcdValue.startswith("L"): # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex UnicodePcdArray.add(Pcd) elif len(Sku.VariableName) > 0: @@ -2381,7 +2381,7 @@ class PlatformAutoGen(AutoGen): ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions - if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]: + if FromPcd is not None and ToPcd.DatumType == TAB_VOID and ToPcd.MaxDatumSize in ['', None]: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue @@ -2457,7 +2457,7 @@ class PlatformAutoGen(AutoGen): # use PCD value to calculate the MaxDatumSize when it is not specified for Name, Guid in Pcds: Pcd = Pcds[Name, Guid] - if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]: + if Pcd.DatumType == TAB_VOID and Pcd.MaxDatumSize in ['', None]: Pcd.MaxSizeUserSet = None Value = Pcd.DefaultValue if Value in [None, '']: @@ -4125,13 +4125,13 @@ class ModuleAutoGen(AutoGen): elif BoolValue == 'FALSE': Pcd.DefaultValue = '0' - if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: + if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: HexFormat = '0x%02x' - if Pcd.DatumType == 'UINT16': + if Pcd.DatumType == TAB_UINT16: HexFormat = '0x%04x' - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: HexFormat = '0x%08x' - elif Pcd.DatumType == 'UINT64': + elif Pcd.DatumType == TAB_UINT64: HexFormat = '0x%016x' PcdValue = HexFormat % int(Pcd.DefaultValue, 0) else: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 58da9e6b1784..31446104fd64 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -41,8 +41,6 @@ gItemTypeStringDatabase = { TAB_PCDS_DYNAMIC_EX_HII : '', } -_NumericDataTypesList = ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] - ## Dynamic PCD types gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII] @@ -50,9 +48,9 @@ gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] ## Datum size -gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOLEAN','VOID*':'8'} -gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'} -gDatumSizeStringDatabaseLib = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'} +gDatumSizeStringDatabase = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'BOOLEAN',TAB_VOID:'8'} +gDatumSizeStringDatabaseH = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'BOOL',TAB_VOID:'PTR'} +gDatumSizeStringDatabaseLib = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'Bool',TAB_VOID:'Ptr'} ## AutoGen File Header Templates gAutoGenHeaderString = TemplateString("""\ @@ -871,7 +869,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): TokenCNameList.append(TokenCName) def GetPcdSize(Pcd): - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: Value = Pcd.DefaultValue if Value in [None, '']: return 1 @@ -881,13 +879,13 @@ def GetPcdSize(Pcd): return len(Value.split(',')) else: return len(Value) - 1 - if Pcd.DatumType == 'UINT64': + if Pcd.DatumType == TAB_UINT64: return 8 - if Pcd.DatumType == 'UINT32': + if Pcd.DatumType == TAB_UINT32: return 4 - if Pcd.DatumType == 'UINT16': + if Pcd.DatumType == TAB_UINT16: return 2 - if Pcd.DatumType == 'UINT8': + if Pcd.DatumType == TAB_UINT8: return 1 if Pcd.DatumType == 'BOOLEAN': return 1 @@ -955,11 +953,11 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) - DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*'] - GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName + DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_VOID] + GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName PcdExCNameList = [] @@ -979,7 +977,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -989,7 +987,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1008,7 +1006,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: @@ -1032,7 +1030,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): elif BoolValue == 'FALSE' or BoolValue == '0': Value = '0U' - if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']: + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: try: if Value.upper().endswith('L'): Value = Value[:-1] @@ -1041,7 +1039,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): EdkLogger.error("build", AUTOGEN_ERROR, "PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) - if Pcd.DatumType == 'UINT64': + if Pcd.DatumType == TAB_UINT64: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1052,7 +1050,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('ULL'): Value += 'ULL' - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1063,7 +1061,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - elif Pcd.DatumType == 'UINT16': + elif Pcd.DatumType == TAB_UINT16: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1074,7 +1072,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - elif Pcd.DatumType == 'UINT8': + elif Pcd.DatumType == TAB_UINT8: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1085,7 +1083,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName), @@ -1123,10 +1121,10 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): # skip casting for fixed at build since it breaks ARM assembly. # Long term we need PCD macros that work in assembly # - elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: + elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Value = "((%s)%s)" % (Pcd.DatumType, Value) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: # handle structure PCD if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': EdkLogger.error("build", AUTOGEN_ERROR, @@ -1141,7 +1139,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): else: PcdValueName = '_PCD_VALUE_' + TokenCName - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: # # For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed. # @@ -1188,7 +1186,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) else: @@ -1251,16 +1249,16 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) DatumType = Pcd.DatumType - DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*'] - GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName + DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_VOID] + GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName Type = '' Array = '' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.DefaultValue[0]== '{': Type = '(VOID *)' Array = '[]' @@ -1285,7 +1283,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1295,7 +1293,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1316,7 +1314,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) - if DatumType not in _NumericDataTypesList: + if DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: @@ -1325,17 +1323,17 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE: GetModeMaxSizeName = '_PCD_GET_MODE_MAXSIZE' + '_' + TokenCName PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName - if DatumType not in _NumericDataTypesList: - if DatumType == 'VOID*' and Array == '[]': - DatumType = ['UINT8', 'UINT16'][Pcd.DefaultValue[0] == 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES: + if DatumType == TAB_VOID and Array == '[]': + DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] else: - DatumType = 'UINT8' + DatumType = TAB_UINT8 AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array)) else: AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array)) AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName)) PcdDataSize = GetPcdSize(Pcd) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) AutoGenH.Append('#define %s %s\n' % (GetModeMaxSizeName, PatchPcdMaxSizeVariable)) @@ -1351,10 +1349,10 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG: key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName - if DatumType == 'VOID*' and Array == '[]': - DatumType = ['UINT8', 'UINT16'][Pcd.DefaultValue[0] == 'L'] - if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: - DatumType = 'UINT8' + if DatumType == TAB_VOID and Array == '[]': + DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: + DatumType = TAB_UINT8 AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName)) AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) @@ -1364,13 +1362,13 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ConstFixedPcd = True if key in Info.ConstPcd: Pcd.DefaultValue = Info.ConstPcd[key] - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) else: AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue)) PcdDataSize = GetPcdSize(Pcd) if PcdItemType == TAB_PCDS_FIXED_AT_BUILD: - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if ConstFixedPcd: AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index e415cae29054..5e59712eca23 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -20,6 +20,7 @@ from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY from Common.VariableAttributes import VariableAttributes import copy from struct import unpack +from Common.DataType import * DATABASE_VERSION = 7 @@ -1023,7 +1024,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): new_pcd = copy.deepcopy(pcd) new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]} new_pcd.isinit = 'INIT' - if new_pcd.DatumType in ['UINT8','UINT16','UINT32','UINT64']: + if new_pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: for skuobj in pcd.SkuInfoList.values(): if skuobj.DefaultValue: defaultvalue = int(skuobj.DefaultValue,16) if skuobj.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10) @@ -1102,7 +1103,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Dict['PCD_INFO_FLAG'] = Platform.Platform.PcdInfoFlag - for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]: + for DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Dict['VARDEF_CNAME_' + DatumType] = [] Dict['VARDEF_GUID_' + DatumType] = [] Dict['VARDEF_SKUID_' + DatumType] = [] @@ -1174,7 +1175,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): ReorderedDynPcdList = GetOrderedDynamicPcdList(DynamicPcdList, Platform.PcdTokenNumber) for item in ReorderedDynPcdList: if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - item.DatumType = "VOID*" + item.DatumType = TAB_VOID for Pcd in ReorderedDynPcdList: VoidStarTypeCurrSize = [] i += 1 @@ -1215,7 +1216,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): VariableDbValueList = [] Pcd.InitString = 'UNINIT' - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]: Pcd.TokenTypeList = ['PCD_TYPE_STRING'] else: @@ -1319,9 +1320,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue) - if Pcd.DatumType == "UINT64": + if Pcd.DatumType == TAB_UINT64: Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL") - elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"): + elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8): Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U") elif Pcd.DatumType == "BOOLEAN": if eval(Sku.HiiDefaultValue) in [1,0]: @@ -1352,13 +1353,13 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U') VpdDbOffsetList.append(Sku.VpdOffset) # Also add the VOID* string of VPD PCD to SizeTable - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: NumberOfSizeItems += 1 # For VPD type of PCD, its current size is equal to its MAX size. VoidStarTypeCurrSize = [str(Pcd.MaxDatumSize) + 'U'] continue - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: Pcd.TokenTypeList += ['PCD_TYPE_STRING'] Pcd.InitString = 'INIT' if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '': @@ -1417,9 +1418,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # For UNIT64 type PCD's value, ULL should be append to avoid # warning under linux building environment. # - if Pcd.DatumType == "UINT64": + if Pcd.DatumType == TAB_UINT64: ValueList.append(Sku.DefaultValue + "ULL") - elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"): + elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8): ValueList.append(Sku.DefaultValue + "U") elif Pcd.DatumType == "BOOLEAN": if Sku.DefaultValue in ["1", "0"]: @@ -1430,7 +1431,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): DbValueList.append(Sku.DefaultValue) Pcd.TokenTypeList = list(set(Pcd.TokenTypeList)) - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: Dict['SIZE_TABLE_CNAME'].append(CName) Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid) Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U') diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index d222e6ed5e7e..803ab9772b51 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017 - 2018, 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 @@ -20,6 +20,7 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections +from Common.DataType import * var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") NvStorageHeaderSize = 28 @@ -90,14 +91,14 @@ class VariableMgr(object): for item in sku_var_info_offset_list: data_type = item.data_type value_list = item.default_value.strip("{").strip("}").split(",") - if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT64"]: - if data_type == ["BOOLEAN","UINT8"]: + if data_type in TAB_PCD_NUMERIC_TYPES: + if data_type == ["BOOLEAN",TAB_UINT8]: data_flag = "=B" - elif data_type == "UINT16": + elif data_type == TAB_UINT16: data_flag = "=H" - elif data_type == "UINT32": + elif data_type == TAB_UINT32: data_flag = "=L" - elif data_type == "UINT64": + elif data_type == TAB_UINT64: data_flag = "=Q" data = value_list[0] value_list = [] @@ -109,7 +110,7 @@ class VariableMgr(object): except: EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_info_offset_list]))) n = sku_var_info_offset_list[0] - indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , "VOID*")] + indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , TAB_VOID)] self.VarInfo = [item[0] for item in indexedvarinfo.values()] def assemble_variable(self, valuelist): @@ -143,7 +144,7 @@ class VariableMgr(object): tail = None default_sku_default = indexedvarinfo.get(index).get(("DEFAULT","STANDARD")) - if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TYPES: var_max_len = max([len(var_item.default_value.split(",")) for var_item in sku_var_info.values()]) if len(default_sku_default.default_value.split(",")) < var_max_len: tail = ",".join([ "0x00" for i in range(var_max_len-len(default_sku_default.default_value.split(",")))]) @@ -164,7 +165,7 @@ class VariableMgr(object): continue other_sku_other = indexedvarinfo.get(index).get((skuid,defaultstoragename)) - if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TYPES: if len(other_sku_other.default_value.split(",")) < var_max_len: tail = ",".join([ "0x00" for i in range(var_max_len-len(other_sku_other.default_value.split(",")))]) @@ -313,7 +314,7 @@ class VariableMgr(object): def PACK_VARIABLES_DATA(self, var_value,data_type, tail = None): Buffer = "" data_len = 0 - if data_type == "VOID*": + if data_type == TAB_VOID: for value_char in var_value.strip("{").strip("}").split(","): Buffer += pack("=B",int(value_char,16)) data_len += len(var_value.split(",")) @@ -324,16 +325,16 @@ class VariableMgr(object): elif data_type == "BOOLEAN": Buffer += pack("=B",True) if var_value.upper() == "TRUE" else pack("=B",False) data_len += 1 - elif data_type == "UINT8": + elif data_type == TAB_UINT8: Buffer += pack("=B",GetIntegerValue(var_value)) data_len += 1 - elif data_type == "UINT16": + elif data_type == TAB_UINT16: Buffer += pack("=H",GetIntegerValue(var_value)) data_len += 2 - elif data_type == "UINT32": + elif data_type == TAB_UINT32: Buffer += pack("=L",GetIntegerValue(var_value)) data_len += 4 - elif data_type == "UINT64": + elif data_type == TAB_UINT64: Buffer += pack("=Q",GetIntegerValue(var_value)) data_len += 8 diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py index 92ede7a82324..3c6f0e2c39af 100644 --- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py +++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py @@ -19,6 +19,7 @@ from Common.RangeExpression import RangeExpression from Common.Misc import * from StringIO import StringIO from struct import pack +from Common.DataType import * class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): def __init__(self): @@ -250,13 +251,13 @@ class VAR_CHECK_PCD_VALID_OBJ(object): self.ValidData = True self.updateStorageWidth() def updateStorageWidth(self): - if self.PcdDataType == "UINT8" or self.PcdDataType == "BOOLEAN": + if self.PcdDataType == TAB_UINT8 or self.PcdDataType == "BOOLEAN": self.StorageWidth = 1 - elif self.PcdDataType == "UINT16": + elif self.PcdDataType == TAB_UINT16: self.StorageWidth = 2 - elif self.PcdDataType == "UINT32": + elif self.PcdDataType == TAB_UINT32: self.StorageWidth = 4 - elif self.PcdDataType == "UINT64": + elif self.PcdDataType == TAB_UINT64: self.StorageWidth = 8 else: self.StorageWidth = 0 diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 0bc2306ea61a..f0d8f52354e0 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -1,7 +1,7 @@ ## @file # This file is used to define common static strings used by INF/DEC/DSC files # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR> # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -41,6 +41,10 @@ TAB_UINT32 = 'UINT32' TAB_UINT64 = 'UINT64' TAB_VOID = 'VOID*' +TAB_PCD_CLEAN_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64} +TAB_PCD_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN'} +TAB_PCD_NUMERIC_TYPES_VOID = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN', TAB_VOID} + TAB_EDK_SOURCE = '$(EDK_SOURCE)' TAB_EFI_SOURCE = '$(EFI_SOURCE)' TAB_WORKSPACE = '$(WORKSPACE)' diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 462e8f93f883..efedff89a40a 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -18,6 +18,7 @@ from CommonDataClass.Exceptions import WrnExpression from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray import Common.EdkLogger as EdkLogger import copy +from Common.DataType import * ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -136,7 +137,7 @@ def BuildOptionValue(PcdValue, GuidDict): InputValue = PcdValue if IsFieldValueAnArray(InputValue): try: - PcdValue = ValueExpressionEx(InputValue, 'VOID*', GuidDict)(True) + PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True) except: pass return PcdValue @@ -800,20 +801,20 @@ class ValueExpressionEx(ValueExpression): PcdValue = self.PcdValue try: PcdValue = ValueExpression.__call__(self, RealValue, Depth) - if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or PcdValue.startswith("L'")): + if self.PcdType == TAB_VOID and (PcdValue.startswith("'") or PcdValue.startswith("L'")): PcdValue, Size = ParseFieldValue(PcdValue) PcdValueList = [] for I in range(Size): PcdValueList.append('0x%02X'%(PcdValue & 0xff)) PcdValue = PcdValue >> 8 PcdValue = '{' + ','.join(PcdValueList) + '}' - elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ + elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.startswith("'") or \ PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): raise BadExpression except WrnExpression, Value: PcdValue = Value.result except BadExpression, Value: - if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: + if self.PcdType in TAB_PCD_NUMERIC_TYPES: PcdValue = PcdValue.strip() if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): PcdValue = SplitPcdValueString(PcdValue[1:-1]) @@ -823,24 +824,24 @@ class ValueExpressionEx(ValueExpression): ValueType = '' for Item in PcdValue: Item = Item.strip() - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize = 1 - ValueType = 'UINT8' - elif Item.startswith('UINT16'): + ValueType = TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize = 2 - ValueType = 'UINT16' - elif Item.startswith('UINT32'): + ValueType = TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize = 4 - ValueType = 'UINT32' - elif Item.startswith('UINT64'): + ValueType = TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize = 8 - ValueType = 'UINT64' + ValueType = TAB_UINT64 elif Item[0] in ['"',"'",'L']: ItemSize = 0 - ValueType = 'VOID*' + ValueType = TAB_VOID else: ItemSize = 0 - ValueType = 'UINT8' + ValueType = TAB_UINT8 Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) if ItemSize == 0: @@ -875,13 +876,13 @@ class ValueExpressionEx(ValueExpression): PcdValue = '0x%0{}X'.format(Size) % (TmpValue) if TmpValue < 0: raise BadExpression('Type %s PCD Value is negative' % self.PcdType) - if self.PcdType == 'UINT8' and Size > 1: + if self.PcdType == TAB_UINT8 and Size > 1: raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType) - if self.PcdType == 'UINT16' and Size > 2: + if self.PcdType == TAB_UINT16 and Size > 2: raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType) - if self.PcdType == 'UINT32' and Size > 4: + if self.PcdType == TAB_UINT32 and Size > 4: raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType) - if self.PcdType == 'UINT64' and Size > 8: + if self.PcdType == TAB_UINT64 and Size > 8: raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType) else: try: @@ -910,13 +911,13 @@ class ValueExpressionEx(ValueExpression): raise BadExpression('%s is not a valid c variable name' % Label) if Label not in LabelDict.keys(): LabelDict[Label] = str(LabelOffset) - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): LabelOffset = LabelOffset + 1 - elif Item.startswith('UINT16'): + elif Item.startswith(TAB_UINT16): LabelOffset = LabelOffset + 2 - elif Item.startswith('UINT32'): + elif Item.startswith(TAB_UINT32): LabelOffset = LabelOffset + 4 - elif Item.startswith('UINT64'): + elif Item.startswith(TAB_UINT64): LabelOffset = LabelOffset + 8 else: try: @@ -971,18 +972,18 @@ class ValueExpressionEx(ValueExpression): continue else: ValueType = "" - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize = 1 - ValueType = "UINT8" - elif Item.startswith('UINT16'): + ValueType = TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize = 2 - ValueType = "UINT16" - elif Item.startswith('UINT32'): + ValueType = TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize = 4 - ValueType = "UINT32" - elif Item.startswith('UINT64'): + ValueType = TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize = 8 - ValueType = "UINT64" + ValueType = TAB_UINT64 else: ItemSize = 0 if ValueType: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 23c1a4a0b236..fbea6d99b6a3 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1288,22 +1288,22 @@ def ParseFieldValue (Value): if type(Value) <> type(''): raise BadExpression('Type %s is %s' %(Value, type(Value))) Value = Value.strip() - if Value.startswith('UINT8') and Value.endswith(')'): + if Value.startswith(TAB_UINT8) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 1: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 1 - if Value.startswith('UINT16') and Value.endswith(')'): + if Value.startswith(TAB_UINT16) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 2: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 2 - if Value.startswith('UINT32') and Value.endswith(')'): + if Value.startswith(TAB_UINT32) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 4: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 4 - if Value.startswith('UINT64') and Value.endswith(')'): + if Value.startswith(TAB_UINT64) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 8: raise BadExpression('Value (%s) Size larger than %d' % (Value, Size)) @@ -1490,7 +1490,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD): VpdOffset = FieldList[0] Value = Size = '' - if not DataType == 'VOID*': + if not DataType == TAB_VOID: if len(FieldList) > 1: Value = FieldList[1] else: @@ -1558,7 +1558,7 @@ def AnalyzePcdData(Setting): # For PCD value setting # def CheckPcdDatum(Type, Value): - if Type == "VOID*": + if Type == TAB_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('}')) or (Value.startswith("L'") or Value.startswith("'") and Value.endswith("'")) diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py index 5ee59184e66e..78bb13988eff 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -17,6 +17,7 @@ from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression import uuid from Common.Expression import PcdPattern +from Common.DataType import TAB_UINT8 ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -40,13 +41,13 @@ ERR_EMPTY_EXPR = 'Empty expression is not allowed.' ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' def MaxOfType(DataType): - if DataType == 'UINT8': + if DataType == TAB_UINT8: return int('0xFF', 16) - if DataType == 'UINT16': + if DataType == TAB_UINT16: return int('0xFFFF', 16) - if DataType == 'UINT32': + if DataType == TAB_UINT32: return int('0xFFFFFFFF', 16) - if DataType == 'UINT64': + if DataType == TAB_UINT64: return int('0xFFFFFFFFFFFFFFFF', 16) class RangeObject(object): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index b1baf06b9ccd..b8c8907ac91b 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -23,6 +23,7 @@ import subprocess import Common.GlobalData as GlobalData from Common.LongFilePathSupport import OpenLongFilePath as open from Common.Misc import SaveFileOnChange +from Common.DataType import * FILE_COMMENT_TEMPLATE = \ """ @@ -69,7 +70,7 @@ FILE_COMMENT_TEMPLATE = \ class VpdInfoFile: ## The mapping dictionary from datum type to size string. - _MAX_SIZE_TYPE = {"BOOLEAN":"1", "UINT8":"1", "UINT16":"2", "UINT32":"4", "UINT64":"8"} + _MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_UINT32:"4", TAB_UINT64:"8"} _rVpdPcdLine = None ## Constructor def __init__(self): @@ -95,11 +96,11 @@ class VpdInfoFile: if not (Offset >= 0 or Offset == "*"): EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset) - if Vpd.DatumType == "VOID*": + if Vpd.DatumType == TAB_VOID: if Vpd.MaxDatumSize <= 0: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) - elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64"]: + elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES: if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "": Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType] else: diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 237cf5acfea1..96f726d44926 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1433,7 +1433,7 @@ class DscParser(MetaFileParser): # # PCD value can be an expression # - if len(ValueList) > 1 and ValueList[1] == 'VOID*': + if len(ValueList) > 1 and ValueList[1] == TAB_VOID: PcdValue = ValueList[0] try: ValueList[0] = ValueExpression(PcdValue, self._Macros)(True) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 0427b80b2460..50a843335ebd 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -61,6 +61,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open from Capsule import EFI_CERT_TYPE_PKCS7_GUID from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID from Common.RangeExpression import RangeExpression +from Common.DataType import TAB_UINT8 ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' @@ -1132,7 +1133,7 @@ class FdfParser: return False def __Verify(self, Name, Value, Scope): - if Scope in ['UINT64', 'UINT8']: + if Scope in [TAB_UINT64, TAB_UINT8]: ValueNumber = 0 try: ValueNumber = int (Value, 0) @@ -1140,10 +1141,10 @@ class FdfParser: EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name) if ValueNumber < 0: EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be set to negative value for %s." % Name) - if Scope == 'UINT64': + if Scope == TAB_UINT64: if ValueNumber >= 0x10000000000000000: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name) - if Scope == 'UINT8': + if Scope == TAB_UINT8: if ValueNumber >= 0x100: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name) return True @@ -3201,16 +3202,16 @@ class FdfParser: raise Warning("expected value of %s" % Name, self.FileName, self.CurrentLineNumber) Value = self.__Token if Name == 'IMAGE_HEADER_INIT_VERSION': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.Version = Value elif Name == 'IMAGE_INDEX': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.ImageIndex = Value elif Name == 'HARDWARE_INSTANCE': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.HardwareInstance = Value elif Name == 'MONOTONIC_COUNT': - if self.__Verify(Name, Value, 'UINT64'): + if self.__Verify(Name, Value, TAB_UINT64): FmpData.MonotonicCount = Value if FmpData.MonotonicCount.upper().startswith('0X'): FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16) diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 5364569b96d7..ab2b58de5d89 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -47,13 +47,14 @@ import Common.GlobalData as GlobalData from DepexSection import DepexSection from Common.Misc import SaveFileOnChange from Common.Expression import * +from Common.DataType import TAB_UINT8 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): ## The mapping dictionary from datum type to its maximum number. - _MAX_SIZE_TYPE = {"BOOLEAN":0x01, "UINT8":0xFF, "UINT16":0xFFFF, "UINT32":0xFFFFFFFF, "UINT64":0xFFFFFFFFFFFFFFFF} + _MAX_SIZE_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} ## The constructor # # @param self The object pointer @@ -297,7 +298,7 @@ class FfsInfStatement(FfsInfStatementClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName) # Check value, if value are equal, no need to patch - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']: continue # Get the string size from FDF or DSC @@ -327,7 +328,7 @@ class FfsInfStatement(FfsInfStatementClassObject): except: continue # Check the Pcd size and data type - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if int(MaxDatumSize) > int(Pcd.MaxDatumSize): EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2f9d58f6bf37..e17957f91421 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -811,7 +811,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace): if PcdObj.Type != 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType != 'VOID*': + if PcdObj.DatumType != TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) PcdValue = PcdObj.DefaultValue @@ -827,7 +827,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace): if PcdObj.Type != 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType != 'VOID*': + if PcdObj.DatumType != TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) PcdValue = PcdObj.DefaultValue diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py index 0664d6a90fa1..cf2fc7c4f70a 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -1,7 +1,7 @@ ## @file # Patch value into the binary file. # -# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2010 - 2018, 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 @@ -25,6 +25,7 @@ from Common.BuildToolError import * import Common.EdkLogger as EdkLogger from Common.BuildVersion import gBUILD_VERSION import array +from Common.DataType import * # Version and Copyright __version_number__ = ("0.10" + " " + gBUILD_VERSION) @@ -62,15 +63,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): ValueLength = 0 if TypeName == 'BOOLEAN': ValueLength = 1 - elif TypeName == 'UINT8': + elif TypeName == TAB_UINT8: ValueLength = 1 - elif TypeName == 'UINT16': + elif TypeName == TAB_UINT16: ValueLength = 2 - elif TypeName == 'UINT32': + elif TypeName == TAB_UINT32: ValueLength = 4 - elif TypeName == 'UINT64': + elif TypeName == TAB_UINT64: ValueLength = 8 - elif TypeName == 'VOID*': + elif TypeName == TAB_VOID: if MaxSize == 0: return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD." ValueLength = int(MaxSize) @@ -119,7 +120,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): # Set PCD value into binary data # ByteList[ValueOffset] = ValueNumber - elif TypeName in ['UINT8', 'UINT16', 'UINT32', 'UINT64']: + elif TypeName in TAB_PCD_CLEAN_NUMERIC_TYPES: # # Get PCD value for UINT* data type # @@ -133,7 +134,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): for Index in range(ValueLength): ByteList[ValueOffset + Index] = ValueNumber % 0x100 ValueNumber = ValueNumber / 0x100 - elif TypeName == 'VOID*': + elif TypeName == TAB_VOID: ValueString = SavedStr if ValueString.startswith('L"'): # @@ -264,10 +265,10 @@ def Main(): if CommandOptions.PcdOffset is None or CommandOptions.PcdValue is None or CommandOptions.PcdTypeName is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdOffset or PcdValue of PcdTypeName is not specified.") return 1 - if CommandOptions.PcdTypeName.upper() not in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64", "VOID*"]: + if CommandOptions.PcdTypeName.upper() not in TAB_PCD_NUMERIC_TYPES_VOID: EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData="PCD type %s is not valid." % (CommandOptions.PcdTypeName)) return 1 - if CommandOptions.PcdTypeName.upper() == "VOID*" and CommandOptions.PcdMaxSize is None: + if CommandOptions.PcdTypeName.upper() == TAB_VOID and CommandOptions.PcdMaxSize is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdMaxSize is not specified for VOID* type PCD.") return 1 # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6766f059b0f7..e71f19750a56 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -41,13 +41,7 @@ from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject from collections import OrderedDict -# -# Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs -# PcdValueInitName = 'PcdValueInit' -PcdSupportedBaseTypes = ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'CHAR16'] -PcdSupportedBaseTypeWidth = {'BOOLEAN':8, 'UINT8':8, 'UINT16':16, 'UINT32':32, 'UINT64':64} -PcdUnsupportedBaseTypes = ['INT8', 'INT16', 'INT32', 'INT64', 'CHAR8', 'UINTN', 'INTN', 'VOID'] PcdMainCHeader = ''' /** @@ -1058,7 +1052,7 @@ class DscBuildData(PlatformBuildClassObject): TokenCName += '.' + FieldName if PcdValue.startswith('H'): if FieldName and IsFieldValueAnArray(PcdValue[1:]): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1069,7 +1063,7 @@ class DscBuildData(PlatformBuildClassObject): (TokenSpaceGuidCName, TokenCName, PcdValue, Value)) elif PcdValue.startswith("L'") or PcdValue.startswith("'"): if FieldName and IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1081,7 +1075,7 @@ class DscBuildData(PlatformBuildClassObject): elif PcdValue.startswith('L'): PcdValue = 'L"' + PcdValue[1:] + '"' if FieldName and IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1096,7 +1090,7 @@ class DscBuildData(PlatformBuildClassObject): if PcdValue.upper() == 'TRUE': PcdValue = str(1) if not FieldName: - if PcdDatumType not in ['UINT8','UINT16','UINT32','UINT64','BOOLEAN']: + if PcdDatumType not in TAB_PCD_NUMERIC_TYPES: PcdValue = '"' + PcdValue + '"' else: IsArray = False @@ -1108,7 +1102,7 @@ class DscBuildData(PlatformBuildClassObject): except: PcdValue = '"' + PcdValue + '"' if IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if not IsArray: return PcdValue @@ -1255,7 +1249,7 @@ class DscBuildData(PlatformBuildClassObject): for defaultstore in SkuInfo.DefaultStoreDict: SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII]]: - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if not Pcd.MaxDatumSize: Pcd.MaxDatumSize = '0' CurrentSize = int(Pcd.MaxDatumSize,16) if Pcd.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize) @@ -1572,7 +1566,7 @@ class DscBuildData(PlatformBuildClassObject): def GetPcdMaxSize(self,Pcd): MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 - if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.PcdValueFromComm: if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) @@ -1582,13 +1576,13 @@ class DscBuildData(PlatformBuildClassObject): MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) else: MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize]) - elif Pcd.DatumType not in ['BOOLEAN','UINT8']: + elif Pcd.DatumType not in ['BOOLEAN',TAB_UINT8]: MaxSize = 1 - elif Pcd.DatumType == 'UINT16': + elif Pcd.DatumType == TAB_UINT16: MaxSize = 2 - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: MaxSize = 4 - elif Pcd.DatumType == 'UINT64': + elif Pcd.DatumType == TAB_UINT64: MaxSize = 8 return MaxSize def GenerateSizeFunction(self,Pcd): @@ -1602,7 +1596,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) @@ -1632,7 +1626,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) @@ -1656,7 +1650,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) @@ -1689,7 +1683,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: - DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) + DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec)) @@ -1710,7 +1704,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2])) @@ -1760,7 +1754,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList = ValueExpressionEx(FieldList, "VOID*")(True) + FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) @@ -1790,7 +1784,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2])) @@ -1831,7 +1825,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList = ValueExpressionEx(FieldList, "VOID*")(True) + FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from Command: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) @@ -1850,7 +1844,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2])) @@ -2517,7 +2511,7 @@ class DscBuildData(PlatformBuildClassObject): MaxSize = int(pcd.MaxDatumSize, 0) else: MaxSize = 0 - if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']: + if pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: for (_, skuobj) in pcd.SkuInfoList.items(): datalen = 0 skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index f333279a5875..5f246e58f986 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1007,7 +1007,7 @@ class PcdReport(object): First = False - if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: PcdValueNumber = int(PcdValue.strip(), 0) if DecDefaultValue is None: DecMatch = True @@ -1112,7 +1112,7 @@ class PcdReport(object): ModuleOverride = self.ModulePcdOverride.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName), {}) for ModulePath in ModuleOverride: ModuleDefault = ModuleOverride[ModulePath] - if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: ModulePcdDefaultValueNumber = int(ModuleDefault.strip(), 0) Match = (ModulePcdDefaultValueNumber == PcdValueNumber) else: -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants. 2018-04-11 23:08 ` [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants Jaben @ 2018-04-17 13:32 ` Zhu, Yonghong 0 siblings, 0 replies; 9+ messages in thread From: Zhu, Yonghong @ 2018-04-17 13:32 UTC (permalink / raw) To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong Hi Jaben, In GenFdsGlobalVariable.py file, it should use DataType.TAB_VOID because current the import statement in this file is " import Common.DataType as DataType". Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben Sent: Thursday, April 12, 2018 7:08 AM To: edk2-devel@lists.01.org Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com> Subject: [PATCH v1 2/4] BaseTools: replace 'UINT8','UINT16','UINT32','UINT64','VOID*' with shared constants. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/AutoGen/AutoGen.py | 26 +++--- BaseTools/Source/Python/AutoGen/GenC.py | 94 ++++++++++---------- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 23 ++--- BaseTools/Source/Python/AutoGen/GenVar.py | 29 +++--- BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py | 9 +- BaseTools/Source/Python/Common/DataType.py | 6 +- BaseTools/Source/Python/Common/Expression.py | 61 ++++++------- BaseTools/Source/Python/Common/Misc.py | 12 +-- BaseTools/Source/Python/Common/RangeExpression.py | 9 +- BaseTools/Source/Python/Common/VpdInfoFile.py | 7 +- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 15 ++-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 7 +- BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 4 +- BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py | 21 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 48 +++++----- BaseTools/Source/Python/build/BuildReport.py | 4 +- 17 files changed, 191 insertions(+), 186 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index dbc9f893c2f1..8f663b8318f9 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1401,7 +1401,7 @@ class PlatformAutoGen(AutoGen): for PcdFromModule in M.ModulePcdList + M.LibraryPcdList: # make sure that the "VOID*" kind of datum has MaxDatumSize set - if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F)) # Check the PCD from Binary INF or Source INF @@ -1483,7 +1483,7 @@ class PlatformAutoGen(AutoGen): ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n" % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName)) # make sure that the "VOID*" kind of datum has MaxDatumSize set - if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType == TAB_VOID and PcdFromModule.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName)) if M.ModuleType in ["PEIM", "PEI_CORE"]: PcdFromModule.Phase = "PEI" @@ -1548,7 +1548,7 @@ class PlatformAutoGen(AutoGen): for item in self._PlatformPcds: if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - self._PlatformPcds[item].DatumType = "VOID*" + self._PlatformPcds[item].DatumType = TAB_VOID if (self.Workspace.ArchList[-1] == self.Arch): for Pcd in self._DynamicPcdList: @@ -1557,7 +1557,7 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset = Sku.VpdOffset.strip() if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType = "VOID*" + Pcd.DatumType = TAB_VOID # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex # if found HII type PCD then insert to right of UnicodeIndex @@ -1709,7 +1709,7 @@ class PlatformAutoGen(AutoGen): SkuValueMap[PcdValue].append(Sku) if not NeedProcessVpdMapFile and Sku.VpdOffset == "*": NeedProcessVpdMapFile = True - if DscPcdEntry.DatumType == 'VOID*' and PcdValue.startswith("L"): + if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"): UnicodePcdArray.add(DscPcdEntry) elif len(Sku.VariableName) > 0: HiiPcdArray.add(DscPcdEntry) @@ -1756,10 +1756,10 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset = Sku.VpdOffset.strip() if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType = "VOID*" + Pcd.DatumType = TAB_VOID PcdValue = Sku.DefaultValue - if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"): + if Pcd.DatumType == TAB_VOID and PcdValue.startswith("L"): # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex UnicodePcdArray.add(Pcd) elif len(Sku.VariableName) > 0: @@ -2381,7 +2381,7 @@ class PlatformAutoGen(AutoGen): ToPcd.validlists = FromPcd.validlists ToPcd.expressions = FromPcd.expressions - if FromPcd is not None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]: + if FromPcd is not None and ToPcd.DatumType == TAB_VOID and ToPcd.MaxDatumSize in ['', None]: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value = ToPcd.DefaultValue @@ -2457,7 +2457,7 @@ class PlatformAutoGen(AutoGen): # use PCD value to calculate the MaxDatumSize when it is not specified for Name, Guid in Pcds: Pcd = Pcds[Name, Guid] - if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]: + if Pcd.DatumType == TAB_VOID and Pcd.MaxDatumSize in ['', None]: Pcd.MaxSizeUserSet = None Value = Pcd.DefaultValue if Value in [None, '']: @@ -4125,13 +4125,13 @@ class ModuleAutoGen(AutoGen): elif BoolValue == 'FALSE': Pcd.DefaultValue = '0' - if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: + if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: HexFormat = '0x%02x' - if Pcd.DatumType == 'UINT16': + if Pcd.DatumType == TAB_UINT16: HexFormat = '0x%04x' - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: HexFormat = '0x%08x' - elif Pcd.DatumType == 'UINT64': + elif Pcd.DatumType == TAB_UINT64: HexFormat = '0x%016x' PcdValue = HexFormat % int(Pcd.DefaultValue, 0) else: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index 58da9e6b1784..31446104fd64 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -41,8 +41,6 @@ gItemTypeStringDatabase = { TAB_PCDS_DYNAMIC_EX_HII : '', } -_NumericDataTypesList = ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] - ## Dynamic PCD types gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_HII] @@ -50,9 +48,9 @@ gDynamicPcd = [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNAMIC_VPD, gDynamicExPcd = [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_PCDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] ## Datum size -gDatumSizeStringDatabase = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOLEAN','VOID*':'8'} -gDatumSizeStringDatabaseH = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'} -gDatumSizeStringDatabaseLib = {'UINT8':'8','UINT16':'16','UINT32':'32','UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'} +gDatumSizeStringDatabase = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'BOOLEAN',TAB_VOID:'8'} +gDatumSizeStringDatabaseH = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'BOOL',TAB_VOID:'PTR'} +gDatumSizeStringDatabaseLib = {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32',TAB_UINT64:'64','BOOLEAN':'Bool',TAB_VOID:'Ptr'} ## AutoGen File Header Templates gAutoGenHeaderString = TemplateString("""\ @@ -871,7 +869,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): TokenCNameList.append(TokenCName) def GetPcdSize(Pcd): - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: Value = Pcd.DefaultValue if Value in [None, '']: return 1 @@ -881,13 +879,13 @@ def GetPcdSize(Pcd): return len(Value.split(',')) else: return len(Value) - 1 - if Pcd.DatumType == 'UINT64': + if Pcd.DatumType == TAB_UINT64: return 8 - if Pcd.DatumType == 'UINT32': + if Pcd.DatumType == TAB_UINT32: return 4 - if Pcd.DatumType == 'UINT16': + if Pcd.DatumType == TAB_UINT16: return 2 - if Pcd.DatumType == 'UINT8': + if Pcd.DatumType == TAB_UINT8: return 1 if Pcd.DatumType == 'BOOLEAN': return 1 @@ -955,11 +953,11 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): "Unknown PCD type [%s] of PCD %s.%s" % (Pcd.Type, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) - DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*'] - GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName + DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_VOID] + GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName PcdExCNameList = [] @@ -979,7 +977,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -989,7 +987,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1008,7 +1006,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: @@ -1032,7 +1030,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): elif BoolValue == 'FALSE' or BoolValue == '0': Value = '0U' - if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']: + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: try: if Value.upper().endswith('L'): Value = Value[:-1] @@ -1041,7 +1039,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): EdkLogger.error("build", AUTOGEN_ERROR, "PCD value is not valid dec or hex number for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), ExtraData="[%s]" % str(Info)) - if Pcd.DatumType == 'UINT64': + if Pcd.DatumType == TAB_UINT64: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1052,7 +1050,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('ULL'): Value += 'ULL' - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1063,7 +1061,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - elif Pcd.DatumType == 'UINT16': + elif Pcd.DatumType == TAB_UINT16: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1074,7 +1072,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - elif Pcd.DatumType == 'UINT8': + elif Pcd.DatumType == TAB_UINT8: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, TokenCName), @@ -1085,7 +1083,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) if not Value.endswith('U'): Value += 'U' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName), @@ -1123,10 +1121,10 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): # skip casting for fixed at build since it breaks ARM assembly. # Long term we need PCD macros that work in assembly # - elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: + elif Pcd.Type != TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Value = "((%s)%s)" % (Pcd.DatumType, Value) - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: # handle structure PCD if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '': EdkLogger.error("build", AUTOGEN_ERROR, @@ -1141,7 +1139,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): else: PcdValueName = '_PCD_VALUE_' + TokenCName - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: # # For unicode, UINT16 array will be generated, so the alignment of unicode is guaranteed. # @@ -1188,7 +1186,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, PcdVariableName)) if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE: - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s, (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) else: @@ -1251,16 +1249,16 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ExtraData="[%s]" % str(Info)) DatumType = Pcd.DatumType - DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOID*'] - GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + TokenCName + DatumSize = gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib = gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.DatumType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_VOID] + GetModeName = '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName = '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + TokenCName GetModeSizeName = '_PCD_GET_MODE_SIZE' + '_' + TokenCName Type = '' Array = '' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.DefaultValue[0]== '{': Type = '(VOID *)' Array = '[]' @@ -1285,7 +1283,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1295,7 +1293,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExTokenName)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (GetModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1316,7 +1314,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSizeName, PcdTokenName)) - if DatumType not in _NumericDataTypesList: + if DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdSet%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, PcdTokenName)) else: @@ -1325,17 +1323,17 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdItemType == TAB_PCDS_PATCHABLE_IN_MODULE: GetModeMaxSizeName = '_PCD_GET_MODE_MAXSIZE' + '_' + TokenCName PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PATCHABLE_IN_MODULE] + '_' + TokenCName - if DatumType not in _NumericDataTypesList: - if DatumType == 'VOID*' and Array == '[]': - DatumType = ['UINT8', 'UINT16'][Pcd.DefaultValue[0] == 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES: + if DatumType == TAB_VOID and Array == '[]': + DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] else: - DatumType = 'UINT8' + DatumType = TAB_UINT8 AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumType, TokenCName, Array)) else: AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, PcdVariableName, Array)) AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeName, Type, TokenCName)) PcdDataSize = GetPcdSize(Pcd) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSizeVariable)) AutoGenH.Append('#define %s %s\n' % (GetModeMaxSizeName, PatchPcdMaxSizeVariable)) @@ -1351,10 +1349,10 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): if PcdItemType == TAB_PCDS_FIXED_AT_BUILD or PcdItemType == TAB_PCDS_FEATURE_FLAG: key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) PcdVariableName = '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] + '_' + TokenCName - if DatumType == 'VOID*' and Array == '[]': - DatumType = ['UINT8', 'UINT16'][Pcd.DefaultValue[0] == 'L'] - if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: - DatumType = 'UINT8' + if DatumType == TAB_VOID and Array == '[]': + DatumType = [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] == 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: + DatumType = TAB_UINT8 AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(DatumType, TokenCName, Array)) AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeName, Type, TokenCName)) AutoGenH.Append('//#define %s ASSERT(FALSE) // It is not allowed to set value for a FIXED_AT_BUILD PCD\n' % SetModeName) @@ -1364,13 +1362,13 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd): ConstFixedPcd = True if key in Info.ConstPcd: Pcd.DefaultValue = Info.ConstPcd[key] - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define _PCD_VALUE_%s %s%s\n' %(TokenCName, Type, PcdVariableName)) else: AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName, Pcd.DefaultValue)) PcdDataSize = GetPcdSize(Pcd) if PcdItemType == TAB_PCDS_FIXED_AT_BUILD: - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if ConstFixedPcd: AutoGenH.Append('#define %s %s\n' % (FixPcdSizeTokenName, PcdDataSize)) AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,FixPcdSizeTokenName)) diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index e415cae29054..5e59712eca23 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py @@ -20,6 +20,7 @@ from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY from Common.VariableAttributes import VariableAttributes import copy from struct import unpack +from Common.DataType import * DATABASE_VERSION = 7 @@ -1023,7 +1024,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase): new_pcd = copy.deepcopy(pcd) new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]} new_pcd.isinit = 'INIT' - if new_pcd.DatumType in ['UINT8','UINT16','UINT32','UINT64']: + if new_pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: for skuobj in pcd.SkuInfoList.values(): if skuobj.DefaultValue: defaultvalue = int(skuobj.DefaultValue,16) if skuobj.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10) @@ -1102,7 +1103,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): Dict['PCD_INFO_FLAG'] = Platform.Platform.PcdInfoFlag - for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]: + for DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Dict['VARDEF_CNAME_' + DatumType] = [] Dict['VARDEF_GUID_' + DatumType] = [] Dict['VARDEF_SKUID_' + DatumType] = [] @@ -1174,7 +1175,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): ReorderedDynPcdList = GetOrderedDynamicPcdList(DynamicPcdList, Platform.PcdTokenNumber) for item in ReorderedDynPcdList: if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]: - item.DatumType = "VOID*" + item.DatumType = TAB_VOID for Pcd in ReorderedDynPcdList: VoidStarTypeCurrSize = [] i += 1 @@ -1215,7 +1216,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): VariableDbValueList = [] Pcd.InitString = 'UNINIT' - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]: Pcd.TokenTypeList = ['PCD_TYPE_STRING'] else: @@ -1319,9 +1320,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue) - if Pcd.DatumType == "UINT64": + if Pcd.DatumType == TAB_UINT64: Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL") - elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"): + elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8): Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U") elif Pcd.DatumType == "BOOLEAN": if eval(Sku.HiiDefaultValue) in [1,0]: @@ -1352,13 +1353,13 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U') VpdDbOffsetList.append(Sku.VpdOffset) # Also add the VOID* string of VPD PCD to SizeTable - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: NumberOfSizeItems += 1 # For VPD type of PCD, its current size is equal to its MAX size. VoidStarTypeCurrSize = [str(Pcd.MaxDatumSize) + 'U'] continue - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: Pcd.TokenTypeList += ['PCD_TYPE_STRING'] Pcd.InitString = 'INIT' if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '': @@ -1417,9 +1418,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): # For UNIT64 type PCD's value, ULL should be append to avoid # warning under linux building environment. # - if Pcd.DatumType == "UINT64": + if Pcd.DatumType == TAB_UINT64: ValueList.append(Sku.DefaultValue + "ULL") - elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"): + elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8): ValueList.append(Sku.DefaultValue + "U") elif Pcd.DatumType == "BOOLEAN": if Sku.DefaultValue in ["1", "0"]: @@ -1430,7 +1431,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase): DbValueList.append(Sku.DefaultValue) Pcd.TokenTypeList = list(set(Pcd.TokenTypeList)) - if Pcd.DatumType == 'VOID*': + if Pcd.DatumType == TAB_VOID: Dict['SIZE_TABLE_CNAME'].append(CName) Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid) Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U') diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index d222e6ed5e7e..803ab9772b51 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2017 - 2018, 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 @@ -20,6 +20,7 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections +from Common.DataType import * var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type") NvStorageHeaderSize = 28 @@ -90,14 +91,14 @@ class VariableMgr(object): for item in sku_var_info_offset_list: data_type = item.data_type value_list = item.default_value.strip("{").strip("}").split(",") - if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT64"]: - if data_type == ["BOOLEAN","UINT8"]: + if data_type in TAB_PCD_NUMERIC_TYPES: + if data_type == ["BOOLEAN",TAB_UINT8]: data_flag = "=B" - elif data_type == "UINT16": + elif data_type == TAB_UINT16: data_flag = "=H" - elif data_type == "UINT32": + elif data_type == TAB_UINT32: data_flag = "=L" - elif data_type == "UINT64": + elif data_type == TAB_UINT64: data_flag = "=Q" data = value_list[0] value_list = [] @@ -109,7 +110,7 @@ class VariableMgr(object): except: EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset conflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_info_offset_list]))) n = sku_var_info_offset_list[0] - indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , "VOID*")] + indexedvarinfo[key] = [var_info(n.pcdindex,n.pcdname,n.defaultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,newvaluestr , newvaluestr , TAB_VOID)] self.VarInfo = [item[0] for item in indexedvarinfo.values()] def assemble_variable(self, valuelist): @@ -143,7 +144,7 @@ class VariableMgr(object): tail = None default_sku_default = indexedvarinfo.get(index).get(("DEFAULT","STANDARD")) - if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TYPES: var_max_len = max([len(var_item.default_value.split(",")) for var_item in sku_var_info.values()]) if len(default_sku_default.default_value.split(",")) < var_max_len: tail = ",".join([ "0x00" for i in range(var_max_len-len(default_sku_default.default_value.split(",")))]) @@ -164,7 +165,7 @@ class VariableMgr(object): continue other_sku_other = indexedvarinfo.get(index).get((skuid,defaultstoragename)) - if default_sku_default.data_type not in ["UINT8","UINT16","UINT32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TYPES: if len(other_sku_other.default_value.split(",")) < var_max_len: tail = ",".join([ "0x00" for i in range(var_max_len-len(other_sku_other.default_value.split(",")))]) @@ -313,7 +314,7 @@ class VariableMgr(object): def PACK_VARIABLES_DATA(self, var_value,data_type, tail = None): Buffer = "" data_len = 0 - if data_type == "VOID*": + if data_type == TAB_VOID: for value_char in var_value.strip("{").strip("}").split(","): Buffer += pack("=B",int(value_char,16)) data_len += len(var_value.split(",")) @@ -324,16 +325,16 @@ class VariableMgr(object): elif data_type == "BOOLEAN": Buffer += pack("=B",True) if var_value.upper() == "TRUE" else pack("=B",False) data_len += 1 - elif data_type == "UINT8": + elif data_type == TAB_UINT8: Buffer += pack("=B",GetIntegerValue(var_value)) data_len += 1 - elif data_type == "UINT16": + elif data_type == TAB_UINT16: Buffer += pack("=H",GetIntegerValue(var_value)) data_len += 2 - elif data_type == "UINT32": + elif data_type == TAB_UINT32: Buffer += pack("=L",GetIntegerValue(var_value)) data_len += 4 - elif data_type == "UINT64": + elif data_type == TAB_UINT64: Buffer += pack("=Q",GetIntegerValue(var_value)) data_len += 8 diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py index 92ede7a82324..3c6f0e2c39af 100644 --- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py +++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py @@ -19,6 +19,7 @@ from Common.RangeExpression import RangeExpression from Common.Misc import * from StringIO import StringIO from struct import pack +from Common.DataType import * class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): def __init__(self): @@ -250,13 +251,13 @@ class VAR_CHECK_PCD_VALID_OBJ(object): self.ValidData = True self.updateStorageWidth() def updateStorageWidth(self): - if self.PcdDataType == "UINT8" or self.PcdDataType == "BOOLEAN": + if self.PcdDataType == TAB_UINT8 or self.PcdDataType == "BOOLEAN": self.StorageWidth = 1 - elif self.PcdDataType == "UINT16": + elif self.PcdDataType == TAB_UINT16: self.StorageWidth = 2 - elif self.PcdDataType == "UINT32": + elif self.PcdDataType == TAB_UINT32: self.StorageWidth = 4 - elif self.PcdDataType == "UINT64": + elif self.PcdDataType == TAB_UINT64: self.StorageWidth = 8 else: self.StorageWidth = 0 diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 0bc2306ea61a..f0d8f52354e0 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -1,7 +1,7 @@ ## @file # This file is used to define common static strings used by INF/DEC/DSC files # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR> # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -41,6 +41,10 @@ TAB_UINT32 = 'UINT32' TAB_UINT64 = 'UINT64' TAB_VOID = 'VOID*' +TAB_PCD_CLEAN_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64} +TAB_PCD_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN'} +TAB_PCD_NUMERIC_TYPES_VOID = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN', TAB_VOID} + TAB_EDK_SOURCE = '$(EDK_SOURCE)' TAB_EFI_SOURCE = '$(EFI_SOURCE)' TAB_WORKSPACE = '$(WORKSPACE)' diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 462e8f93f883..efedff89a40a 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -18,6 +18,7 @@ from CommonDataClass.Exceptions import WrnExpression from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray import Common.EdkLogger as EdkLogger import copy +from Common.DataType import * ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -136,7 +137,7 @@ def BuildOptionValue(PcdValue, GuidDict): InputValue = PcdValue if IsFieldValueAnArray(InputValue): try: - PcdValue = ValueExpressionEx(InputValue, 'VOID*', GuidDict)(True) + PcdValue = ValueExpressionEx(InputValue, TAB_VOID, GuidDict)(True) except: pass return PcdValue @@ -800,20 +801,20 @@ class ValueExpressionEx(ValueExpression): PcdValue = self.PcdValue try: PcdValue = ValueExpression.__call__(self, RealValue, Depth) - if self.PcdType == 'VOID*' and (PcdValue.startswith("'") or PcdValue.startswith("L'")): + if self.PcdType == TAB_VOID and (PcdValue.startswith("'") or PcdValue.startswith("L'")): PcdValue, Size = ParseFieldValue(PcdValue) PcdValueList = [] for I in range(Size): PcdValueList.append('0x%02X'%(PcdValue & 0xff)) PcdValue = PcdValue >> 8 PcdValue = '{' + ','.join(PcdValueList) + '}' - elif self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN'] and (PcdValue.startswith("'") or \ + elif self.PcdType in TAB_PCD_NUMERIC_TYPES and (PcdValue.startswith("'") or \ PcdValue.startswith('"') or PcdValue.startswith("L'") or PcdValue.startswith('L"') or PcdValue.startswith('{')): raise BadExpression except WrnExpression, Value: PcdValue = Value.result except BadExpression, Value: - if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN']: + if self.PcdType in TAB_PCD_NUMERIC_TYPES: PcdValue = PcdValue.strip() if type(PcdValue) == type('') and PcdValue.startswith('{') and PcdValue.endswith('}'): PcdValue = SplitPcdValueString(PcdValue[1:-1]) @@ -823,24 +824,24 @@ class ValueExpressionEx(ValueExpression): ValueType = '' for Item in PcdValue: Item = Item.strip() - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize = 1 - ValueType = 'UINT8' - elif Item.startswith('UINT16'): + ValueType = TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize = 2 - ValueType = 'UINT16' - elif Item.startswith('UINT32'): + ValueType = TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize = 4 - ValueType = 'UINT32' - elif Item.startswith('UINT64'): + ValueType = TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize = 8 - ValueType = 'UINT64' + ValueType = TAB_UINT64 elif Item[0] in ['"',"'",'L']: ItemSize = 0 - ValueType = 'VOID*' + ValueType = TAB_VOID else: ItemSize = 0 - ValueType = 'UINT8' + ValueType = TAB_UINT8 Item = ValueExpressionEx(Item, ValueType, self._Symb)(True) if ItemSize == 0: @@ -875,13 +876,13 @@ class ValueExpressionEx(ValueExpression): PcdValue = '0x%0{}X'.format(Size) % (TmpValue) if TmpValue < 0: raise BadExpression('Type %s PCD Value is negative' % self.PcdType) - if self.PcdType == 'UINT8' and Size > 1: + if self.PcdType == TAB_UINT8 and Size > 1: raise BadExpression('Type %s PCD Value Size is Larger than 1 byte' % self.PcdType) - if self.PcdType == 'UINT16' and Size > 2: + if self.PcdType == TAB_UINT16 and Size > 2: raise BadExpression('Type %s PCD Value Size is Larger than 2 byte' % self.PcdType) - if self.PcdType == 'UINT32' and Size > 4: + if self.PcdType == TAB_UINT32 and Size > 4: raise BadExpression('Type %s PCD Value Size is Larger than 4 byte' % self.PcdType) - if self.PcdType == 'UINT64' and Size > 8: + if self.PcdType == TAB_UINT64 and Size > 8: raise BadExpression('Type %s PCD Value Size is Larger than 8 byte' % self.PcdType) else: try: @@ -910,13 +911,13 @@ class ValueExpressionEx(ValueExpression): raise BadExpression('%s is not a valid c variable name' % Label) if Label not in LabelDict.keys(): LabelDict[Label] = str(LabelOffset) - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): LabelOffset = LabelOffset + 1 - elif Item.startswith('UINT16'): + elif Item.startswith(TAB_UINT16): LabelOffset = LabelOffset + 2 - elif Item.startswith('UINT32'): + elif Item.startswith(TAB_UINT32): LabelOffset = LabelOffset + 4 - elif Item.startswith('UINT64'): + elif Item.startswith(TAB_UINT64): LabelOffset = LabelOffset + 8 else: try: @@ -971,18 +972,18 @@ class ValueExpressionEx(ValueExpression): continue else: ValueType = "" - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize = 1 - ValueType = "UINT8" - elif Item.startswith('UINT16'): + ValueType = TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize = 2 - ValueType = "UINT16" - elif Item.startswith('UINT32'): + ValueType = TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize = 4 - ValueType = "UINT32" - elif Item.startswith('UINT64'): + ValueType = TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize = 8 - ValueType = "UINT64" + ValueType = TAB_UINT64 else: ItemSize = 0 if ValueType: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 23c1a4a0b236..fbea6d99b6a3 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -1288,22 +1288,22 @@ def ParseFieldValue (Value): if type(Value) <> type(''): raise BadExpression('Type %s is %s' %(Value, type(Value))) Value = Value.strip() - if Value.startswith('UINT8') and Value.endswith(')'): + if Value.startswith(TAB_UINT8) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 1: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 1 - if Value.startswith('UINT16') and Value.endswith(')'): + if Value.startswith(TAB_UINT16) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 2: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 2 - if Value.startswith('UINT32') and Value.endswith(')'): + if Value.startswith(TAB_UINT32) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 4: raise BadExpression('Value (%s) Size larger than %d' %(Value, Size)) return Value, 4 - if Value.startswith('UINT64') and Value.endswith(')'): + if Value.startswith(TAB_UINT64) and Value.endswith(')'): Value, Size = ParseFieldValue(Value.split('(', 1)[1][:-1]) if Size > 8: raise BadExpression('Value (%s) Size larger than %d' % (Value, Size)) @@ -1490,7 +1490,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''): elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD): VpdOffset = FieldList[0] Value = Size = '' - if not DataType == 'VOID*': + if not DataType == TAB_VOID: if len(FieldList) > 1: Value = FieldList[1] else: @@ -1558,7 +1558,7 @@ def AnalyzePcdData(Setting): # For PCD value setting # def CheckPcdDatum(Type, Value): - if Type == "VOID*": + if Type == TAB_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('}')) or (Value.startswith("L'") or Value.startswith("'") and Value.endswith("'")) diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py index 5ee59184e66e..78bb13988eff 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -17,6 +17,7 @@ from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression import uuid from Common.Expression import PcdPattern +from Common.DataType import TAB_UINT8 ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -40,13 +41,13 @@ ERR_EMPTY_EXPR = 'Empty expression is not allowed.' ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' def MaxOfType(DataType): - if DataType == 'UINT8': + if DataType == TAB_UINT8: return int('0xFF', 16) - if DataType == 'UINT16': + if DataType == TAB_UINT16: return int('0xFFFF', 16) - if DataType == 'UINT32': + if DataType == TAB_UINT32: return int('0xFFFFFFFF', 16) - if DataType == 'UINT64': + if DataType == TAB_UINT64: return int('0xFFFFFFFFFFFFFFFF', 16) class RangeObject(object): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index b1baf06b9ccd..b8c8907ac91b 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -23,6 +23,7 @@ import subprocess import Common.GlobalData as GlobalData from Common.LongFilePathSupport import OpenLongFilePath as open from Common.Misc import SaveFileOnChange +from Common.DataType import * FILE_COMMENT_TEMPLATE = \ """ @@ -69,7 +70,7 @@ FILE_COMMENT_TEMPLATE = \ class VpdInfoFile: ## The mapping dictionary from datum type to size string. - _MAX_SIZE_TYPE = {"BOOLEAN":"1", "UINT8":"1", "UINT16":"2", "UINT32":"4", "UINT64":"8"} + _MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_UINT32:"4", TAB_UINT64:"8"} _rVpdPcdLine = None ## Constructor def __init__(self): @@ -95,11 +96,11 @@ class VpdInfoFile: if not (Offset >= 0 or Offset == "*"): EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid offset parameter: %s." % Offset) - if Vpd.DatumType == "VOID*": + if Vpd.DatumType == TAB_VOID: if Vpd.MaxDatumSize <= 0: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) - elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64"]: + elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES: if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "": Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType] else: diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 237cf5acfea1..96f726d44926 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -1433,7 +1433,7 @@ class DscParser(MetaFileParser): # # PCD value can be an expression # - if len(ValueList) > 1 and ValueList[1] == 'VOID*': + if len(ValueList) > 1 and ValueList[1] == TAB_VOID: PcdValue = ValueList[0] try: ValueList[0] = ValueExpression(PcdValue, self._Macros)(True) diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 0427b80b2460..50a843335ebd 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -61,6 +61,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open from Capsule import EFI_CERT_TYPE_PKCS7_GUID from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID from Common.RangeExpression import RangeExpression +from Common.DataType import TAB_UINT8 ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' @@ -1132,7 +1133,7 @@ class FdfParser: return False def __Verify(self, Name, Value, Scope): - if Scope in ['UINT64', 'UINT8']: + if Scope in [TAB_UINT64, TAB_UINT8]: ValueNumber = 0 try: ValueNumber = int (Value, 0) @@ -1140,10 +1141,10 @@ class FdfParser: EdkLogger.error("FdfParser", FORMAT_INVALID, "The value is not valid dec or hex number for %s." % Name) if ValueNumber < 0: EdkLogger.error("FdfParser", FORMAT_INVALID, "The value can't be set to negative value for %s." % Name) - if Scope == 'UINT64': + if Scope == TAB_UINT64: if ValueNumber >= 0x10000000000000000: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name) - if Scope == 'UINT8': + if Scope == TAB_UINT8: if ValueNumber >= 0x100: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too large value for %s." % Name) return True @@ -3201,16 +3202,16 @@ class FdfParser: raise Warning("expected value of %s" % Name, self.FileName, self.CurrentLineNumber) Value = self.__Token if Name == 'IMAGE_HEADER_INIT_VERSION': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.Version = Value elif Name == 'IMAGE_INDEX': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.ImageIndex = Value elif Name == 'HARDWARE_INSTANCE': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.HardwareInstance = Value elif Name == 'MONOTONIC_COUNT': - if self.__Verify(Name, Value, 'UINT64'): + if self.__Verify(Name, Value, TAB_UINT64): FmpData.MonotonicCount = Value if FmpData.MonotonicCount.upper().startswith('0X'): FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16) diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 5364569b96d7..ab2b58de5d89 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -47,13 +47,14 @@ import Common.GlobalData as GlobalData from DepexSection import DepexSection from Common.Misc import SaveFileOnChange from Common.Expression import * +from Common.DataType import TAB_UINT8 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): ## The mapping dictionary from datum type to its maximum number. - _MAX_SIZE_TYPE = {"BOOLEAN":0x01, "UINT8":0xFF, "UINT16":0xFFFF, "UINT32":0xFFFFFFFF, "UINT64":0xFFFFFFFFFFFFFFFF} + _MAX_SIZE_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} ## The constructor # # @param self The object pointer @@ -297,7 +298,7 @@ class FfsInfStatement(FfsInfStatementClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, 'PCD [%s.%s] Value "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),File=self.InfFileName) # Check value, if value are equal, no need to patch - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if Pcd.InfDefaultValue == DefaultValue or DefaultValue in [None, '']: continue # Get the string size from FDF or DSC @@ -327,7 +328,7 @@ class FfsInfStatement(FfsInfStatementClassObject): except: continue # Check the Pcd size and data type - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if int(MaxDatumSize) > int(Pcd.MaxDatumSize): EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2f9d58f6bf37..e17957f91421 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -811,7 +811,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace): if PcdObj.Type != 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType != 'VOID*': + if PcdObj.DatumType != TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) PcdValue = PcdObj.DefaultValue @@ -827,7 +827,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName == TokenCName) and (PcdObj.TokenSpaceGuidCName == TokenSpace): if PcdObj.Type != 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType != 'VOID*': + if PcdObj.DatumType != TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not VOID* datum type." % PcdPattern) PcdValue = PcdObj.DefaultValue diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py index 0664d6a90fa1..cf2fc7c4f70a 100644 --- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py +++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py @@ -1,7 +1,7 @@ ## @file # Patch value into the binary file. # -# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2010 - 2018, 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 @@ -25,6 +25,7 @@ from Common.BuildToolError import * import Common.EdkLogger as EdkLogger from Common.BuildVersion import gBUILD_VERSION import array +from Common.DataType import * # Version and Copyright __version_number__ = ("0.10" + " " + gBUILD_VERSION) @@ -62,15 +63,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): ValueLength = 0 if TypeName == 'BOOLEAN': ValueLength = 1 - elif TypeName == 'UINT8': + elif TypeName == TAB_UINT8: ValueLength = 1 - elif TypeName == 'UINT16': + elif TypeName == TAB_UINT16: ValueLength = 2 - elif TypeName == 'UINT32': + elif TypeName == TAB_UINT32: ValueLength = 4 - elif TypeName == 'UINT64': + elif TypeName == TAB_UINT64: ValueLength = 8 - elif TypeName == 'VOID*': + elif TypeName == TAB_VOID: if MaxSize == 0: return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD." ValueLength = int(MaxSize) @@ -119,7 +120,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): # Set PCD value into binary data # ByteList[ValueOffset] = ValueNumber - elif TypeName in ['UINT8', 'UINT16', 'UINT32', 'UINT64']: + elif TypeName in TAB_PCD_CLEAN_NUMERIC_TYPES: # # Get PCD value for UINT* data type # @@ -133,7 +134,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0): for Index in range(ValueLength): ByteList[ValueOffset + Index] = ValueNumber % 0x100 ValueNumber = ValueNumber / 0x100 - elif TypeName == 'VOID*': + elif TypeName == TAB_VOID: ValueString = SavedStr if ValueString.startswith('L"'): # @@ -264,10 +265,10 @@ def Main(): if CommandOptions.PcdOffset is None or CommandOptions.PcdValue is None or CommandOptions.PcdTypeName is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdOffset or PcdValue of PcdTypeName is not specified.") return 1 - if CommandOptions.PcdTypeName.upper() not in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64", "VOID*"]: + if CommandOptions.PcdTypeName.upper() not in TAB_PCD_NUMERIC_TYPES_VOID: EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData="PCD type %s is not valid." % (CommandOptions.PcdTypeName)) return 1 - if CommandOptions.PcdTypeName.upper() == "VOID*" and CommandOptions.PcdMaxSize is None: + if CommandOptions.PcdTypeName.upper() == TAB_VOID and CommandOptions.PcdMaxSize is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdMaxSize is not specified for VOID* type PCD.") return 1 # diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 6766f059b0f7..e71f19750a56 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -41,13 +41,7 @@ from Common.Misc import SaveFileOnChange from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject from collections import OrderedDict -# -# Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs -# PcdValueInitName = 'PcdValueInit' -PcdSupportedBaseTypes = ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'CHAR16'] -PcdSupportedBaseTypeWidth = {'BOOLEAN':8, 'UINT8':8, 'UINT16':16, 'UINT32':32, 'UINT64':64} -PcdUnsupportedBaseTypes = ['INT8', 'INT16', 'INT32', 'INT64', 'CHAR8', 'UINTN', 'INTN', 'VOID'] PcdMainCHeader = ''' /** @@ -1058,7 +1052,7 @@ class DscBuildData(PlatformBuildClassObject): TokenCName += '.' + FieldName if PcdValue.startswith('H'): if FieldName and IsFieldValueAnArray(PcdValue[1:]): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1069,7 +1063,7 @@ class DscBuildData(PlatformBuildClassObject): (TokenSpaceGuidCName, TokenCName, PcdValue, Value)) elif PcdValue.startswith("L'") or PcdValue.startswith("'"): if FieldName and IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1081,7 +1075,7 @@ class DscBuildData(PlatformBuildClassObject): elif PcdValue.startswith('L'): PcdValue = 'L"' + PcdValue[1:] + '"' if FieldName and IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if FieldName and not IsArray: return PcdValue @@ -1096,7 +1090,7 @@ class DscBuildData(PlatformBuildClassObject): if PcdValue.upper() == 'TRUE': PcdValue = str(1) if not FieldName: - if PcdDatumType not in ['UINT8','UINT16','UINT32','UINT64','BOOLEAN']: + if PcdDatumType not in TAB_PCD_NUMERIC_TYPES: PcdValue = '"' + PcdValue + '"' else: IsArray = False @@ -1108,7 +1102,7 @@ class DscBuildData(PlatformBuildClassObject): except: PcdValue = '"' + PcdValue + '"' if IsFieldValueAnArray(PcdValue): - PcdDatumType = 'VOID*' + PcdDatumType = TAB_VOID IsArray = True if not IsArray: return PcdValue @@ -1255,7 +1249,7 @@ class DscBuildData(PlatformBuildClassObject): for defaultstore in SkuInfo.DefaultStoreDict: SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII]]: - if Pcd.DatumType == "VOID*": + if Pcd.DatumType == TAB_VOID: if not Pcd.MaxDatumSize: Pcd.MaxDatumSize = '0' CurrentSize = int(Pcd.MaxDatumSize,16) if Pcd.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize) @@ -1572,7 +1566,7 @@ class DscBuildData(PlatformBuildClassObject): def GetPcdMaxSize(self,Pcd): MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 - if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.PcdValueFromComm: if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) @@ -1582,13 +1576,13 @@ class DscBuildData(PlatformBuildClassObject): MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) else: MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize]) - elif Pcd.DatumType not in ['BOOLEAN','UINT8']: + elif Pcd.DatumType not in ['BOOLEAN',TAB_UINT8]: MaxSize = 1 - elif Pcd.DatumType == 'UINT16': + elif Pcd.DatumType == TAB_UINT16: MaxSize = 2 - elif Pcd.DatumType == 'UINT32': + elif Pcd.DatumType == TAB_UINT32: MaxSize = 4 - elif Pcd.DatumType == 'UINT64': + elif Pcd.DatumType == TAB_UINT64: MaxSize = 8 return MaxSize def GenerateSizeFunction(self,Pcd): @@ -1602,7 +1596,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) @@ -1632,7 +1626,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2])) @@ -1656,7 +1650,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0].endswith('}')): try: - Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value = ValueExpressionEx(Pcd.PcdFieldValueFromComm[FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.strip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) @@ -1689,7 +1683,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: - DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True) + DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec)) @@ -1710,7 +1704,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2])) @@ -1760,7 +1754,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList = ValueExpressionEx(FieldList, "VOID*")(True) + FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) @@ -1790,7 +1784,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2])) @@ -1831,7 +1825,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList = ValueExpressionEx(FieldList, "VOID*")(True) + FieldList = ValueExpressionEx(FieldList, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from Command: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList)) @@ -1850,7 +1844,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray = IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2])) @@ -2517,7 +2511,7 @@ class DscBuildData(PlatformBuildClassObject): MaxSize = int(pcd.MaxDatumSize, 0) else: MaxSize = 0 - if pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT64']: + if pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: for (_, skuobj) in pcd.SkuInfoList.items(): datalen = 0 skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py index f333279a5875..5f246e58f986 100644 --- a/BaseTools/Source/Python/build/BuildReport.py +++ b/BaseTools/Source/Python/build/BuildReport.py @@ -1007,7 +1007,7 @@ class PcdReport(object): First = False - if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: PcdValueNumber = int(PcdValue.strip(), 0) if DecDefaultValue is None: DecMatch = True @@ -1112,7 +1112,7 @@ class PcdReport(object): ModuleOverride = self.ModulePcdOverride.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName), {}) for ModulePath in ModuleOverride: ModuleDefault = ModuleOverride[ModulePath] - if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UINT64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: ModulePcdDefaultValueNumber = int(ModuleDefault.strip(), 0) Match = (ModulePcdDefaultValueNumber == PcdValueNumber) else: -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension 2018-04-11 23:08 [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) Jaben 2018-04-11 23:08 ` [PATCH v1 1/4] BaseTools: remove duplicate function name Jaben 2018-04-11 23:08 ` [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants Jaben @ 2018-04-11 23:08 ` Jaben 2018-04-18 8:38 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods Jaben 3 siblings, 1 reply; 9+ messages in thread From: Jaben @ 2018-04-11 23:08 UTC (permalink / raw) To: edk2-devel; +Cc: Liming Gao, Yonghong Zhu Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Common/DataType.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index f0d8f52354e0..58fe82583c41 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -80,7 +80,7 @@ SUP_MODULE_MM_CORE_STANDALONE = 'MM_CORE_STANDALONE' SUP_MODULE_LIST = [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, \ SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \ SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE] -SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(l for l in SUP_MODULE_LIST) +SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST) EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY' EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE' -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension 2018-04-11 23:08 ` [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension Jaben @ 2018-04-18 8:38 ` Zhu, Yonghong 0 siblings, 0 replies; 9+ messages in thread From: Zhu, Yonghong @ 2018-04-18 8:38 UTC (permalink / raw) To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Zhu, Yonghong Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben Sent: Thursday, April 12, 2018 7:08 AM To: edk2-devel@lists.01.org Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com> Subject: [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Common/DataType.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index f0d8f52354e0..58fe82583c41 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -80,7 +80,7 @@ SUP_MODULE_MM_CORE_STANDALONE = 'MM_CORE_STANDALONE' SUP_MODULE_LIST = [SUP_MODULE_BASE, SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PEIM, SUP_MODULE_DXE_CORE, SUP_MODULE_DXE_DRIVER, \ SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_DXE_SMM_DRIVER, SUP_MODULE_UEFI_DRIVER, \ SUP_MODULE_UEFI_APPLICATION, SUP_MODULE_USER_DEFINED, SUP_MODULE_SMM_CORE, SUP_MODULE_MM_STANDALONE, SUP_MODULE_MM_CORE_STANDALONE] -SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(l for l in SUP_MODULE_LIST) +SUP_MODULE_LIST_STRING = TAB_VALUE_SPLIT.join(SUP_MODULE_LIST) EDK_COMPONENT_TYPE_LIBRARY = 'LIBRARY' EDK_COMPONENT_TYPE_SECUARITY_CORE = 'SECUARITY_CORE' -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods 2018-04-11 23:08 [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) Jaben ` (2 preceding siblings ...) 2018-04-11 23:08 ` [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension Jaben @ 2018-04-11 23:08 ` Jaben 2018-04-12 0:40 ` Feng, Bob C 3 siblings, 1 reply; 9+ messages in thread From: Jaben @ 2018-04-11 23:08 UTC (permalink / raw) To: edk2-devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu we have 5 different max val or max byte for PCDs. refactor and remove 2 methods. we need 3, as one computes for VOID* PCDs. Cc: Bob Feng <bob.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Common/DataType.py | 8 +++-- BaseTools/Source/Python/Common/RangeExpression.py | 26 +++++----------- BaseTools/Source/Python/Common/VpdInfoFile.py | 4 +-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 8 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 ++++++++------------ 5 files changed, 30 insertions(+), 47 deletions(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 58fe82583c41..2a58cba44552 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -45,6 +45,11 @@ TAB_PCD_CLEAN_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64} TAB_PCD_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN'} TAB_PCD_NUMERIC_TYPES_VOID = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN', TAB_VOID} +## The mapping dictionary from datum type to its maximum number. +MAX_VAL_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} +## The mapping dictionary from datum type to size string. +MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_UINT32:"4", TAB_UINT64:"8"} + TAB_EDK_SOURCE = '$(EDK_SOURCE)' TAB_EFI_SOURCE = '$(EFI_SOURCE)' TAB_WORKSPACE = '$(WORKSPACE)' @@ -58,9 +63,6 @@ TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' TAB_ARCH_AARCH64 = 'AARCH64' -ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64] -ARCH_LIST_FULL = [TAB_ARCH_COMMON] + ARCH_LIST - SUP_MODULE_BASE = 'BASE' SUP_MODULE_SEC = 'SEC' SUP_MODULE_PEI_CORE = 'PEI_CORE' diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py index 78bb13988eff..4d07bd752330 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -17,7 +17,7 @@ from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression import uuid from Common.Expression import PcdPattern -from Common.DataType import TAB_UINT8 +from Common.DataType import * ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -40,16 +40,6 @@ ERR_ARRAY_ELE = 'This must be HEX value for NList or Array: [%s].' ERR_EMPTY_EXPR = 'Empty expression is not allowed.' ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' -def MaxOfType(DataType): - if DataType == TAB_UINT8: - return int('0xFF', 16) - if DataType == TAB_UINT16: - return int('0xFFFF', 16) - if DataType == TAB_UINT32: - return int('0xFFFFFFFF', 16) - if DataType == TAB_UINT64: - return int('0xFFFFFFFFFFFFFFFF', 16) - class RangeObject(object): def __init__(self, start, end, empty = False): @@ -112,7 +102,7 @@ class XOROperatorObject(object): rangeId = str(uuid.uuid1()) rangeContainer = RangeContainer() rangeContainer.push(RangeObject(0, int(Operand) - 1)) - rangeContainer.push(RangeObject(int(Operand) + 1, MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand) + 1, MAX_VAL_TYPE[DataType])) SymbolTable[rangeId] = rangeContainer return rangeId @@ -150,7 +140,7 @@ class GEOperatorObject(object): raise BadExpression(ERR_SNYTAX % Expr) rangeId1 = str(uuid.uuid1()) rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(int(Operand), MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand), MAX_VAL_TYPE[DataType])) SymbolTable[rangeId1] = rangeContainer return rangeId1 @@ -163,7 +153,7 @@ class GTOperatorObject(object): raise BadExpression(ERR_SNYTAX % Expr) rangeId1 = str(uuid.uuid1()) rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(int(Operand) + 1, MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand) + 1, MAX_VAL_TYPE[DataType])) SymbolTable[rangeId1] = rangeContainer return rangeId1 @@ -308,18 +298,18 @@ class RangeExpression(object): rangeContainer = RangeContainer() rangeid = str(uuid.uuid1()) if rangeobj.empty: - rangeContainer.push(RangeObject(0, MaxOfType(self.PcdDataType))) + rangeContainer.push(RangeObject(0, MAX_VAL_TYPE[self.PcdDataType])) else: if rangeobj.start > 0: rangeContainer.push(RangeObject(0, rangeobj.start - 1)) - if rangeobj.end < MaxOfType(self.PcdDataType): - rangeContainer.push(RangeObject(rangeobj.end + 1, MaxOfType(self.PcdDataType))) + if rangeobj.end < MAX_VAL_TYPE[self.PcdDataType]: + rangeContainer.push(RangeObject(rangeobj.end + 1, MAX_VAL_TYPE[self.PcdDataType])) self.operanddict[rangeid] = rangeContainer rangeids.append(rangeid) if len(rangeids) == 0: rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(0, MaxOfType(self.PcdDataType))) + rangeContainer.push(RangeObject(0, MAX_VAL_TYPE[self.PcdDataType])) rangeid = str(uuid.uuid1()) self.operanddict[rangeid] = rangeContainer return rangeid diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index b8c8907ac91b..e1ea844eb7fd 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -69,8 +69,6 @@ FILE_COMMENT_TEMPLATE = \ # class VpdInfoFile: - ## The mapping dictionary from datum type to size string. - _MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_UINT32:"4", TAB_UINT64:"8"} _rVpdPcdLine = None ## Constructor def __init__(self): @@ -102,7 +100,7 @@ class VpdInfoFile: "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES: if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "": - Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType] + Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType] else: if Vpd.MaxDatumSize <= 0: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index ab2b58de5d89..6542b44398d3 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -47,14 +47,12 @@ import Common.GlobalData as GlobalData from DepexSection import DepexSection from Common.Misc import SaveFileOnChange from Common.Expression import * -from Common.DataType import TAB_UINT8 +from Common.DataType import * ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): - ## The mapping dictionary from datum type to its maximum number. - _MAX_SIZE_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} ## The constructor # # @param self The object pointer @@ -333,8 +331,8 @@ class FfsInfStatement(FfsInfStatementClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) else: - if PcdValueInDscOrFdf > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType] \ - or PcdValueInImg > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType]: + if PcdValueInDscOrFdf > MAX_VAL_TYPE[Pcd.DatumType] \ + or PcdValueInImg > MAX_VAL_TYPE[Pcd.DatumType]: EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %s type PCD '%s.%s' doesn't match its data type." \ % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) self.PatchPcds.append((Pcd, DefaultValue)) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e71f19750a56..c214e14398b6 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1565,26 +1565,21 @@ class DscBuildData(PlatformBuildClassObject): return Result def GetPcdMaxSize(self,Pcd): + if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: + return MAX_SIZE_TYPE[Pcd.DatumType] + MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 - if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - if Pcd.PcdValueFromComm: - if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): - MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) - elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"): - MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize]) - elif Pcd.PcdValueFromComm.startswith("L\""): - MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) - else: - MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize]) - elif Pcd.DatumType not in ['BOOLEAN',TAB_UINT8]: - MaxSize = 1 - elif Pcd.DatumType == TAB_UINT16: - MaxSize = 2 - elif Pcd.DatumType == TAB_UINT32: - MaxSize = 4 - elif Pcd.DatumType == TAB_UINT64: - MaxSize = 8 + if Pcd.PcdValueFromComm: + if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): + return max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) + elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"): + return max([len(Pcd.PcdValueFromComm)-2+1,MaxSize]) + elif Pcd.PcdValueFromComm.startswith("L\""): + return max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) + else: + return max([len(Pcd.PcdValueFromComm),MaxSize]) return MaxSize + def GenerateSizeFunction(self,Pcd): CApp = "// Default Value in Dec \n" CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) -- 2.16.2.windows.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods 2018-04-11 23:08 ` [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods Jaben @ 2018-04-12 0:40 ` Feng, Bob C 0 siblings, 0 replies; 9+ messages in thread From: Feng, Bob C @ 2018-04-12 0:40 UTC (permalink / raw) To: Carsey, Jaben, edk2-devel@lists.01.org; +Cc: Gao, Liming, Feng, Bob C Reviewed-by: Feng, Bob C <bob.c.feng@intel.com> -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Jaben Sent: Thursday, April 12, 2018 7:08 AM To: edk2-devel@lists.01.org Cc: Feng, Bob <bob.feng@intel.com>; Gao, Liming <liming.gao@intel.com> Subject: [edk2] [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods we have 5 different max val or max byte for PCDs. refactor and remove 2 methods. we need 3, as one computes for VOID* PCDs. Cc: Bob Feng <bob.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> --- BaseTools/Source/Python/Common/DataType.py | 8 +++-- BaseTools/Source/Python/Common/RangeExpression.py | 26 +++++----------- BaseTools/Source/Python/Common/VpdInfoFile.py | 4 +-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 8 ++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 31 ++++++++------------ 5 files changed, 30 insertions(+), 47 deletions(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 58fe82583c41..2a58cba44552 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -45,6 +45,11 @@ TAB_PCD_CLEAN_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64} TAB_PCD_NUMERIC_TYPES = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN'} TAB_PCD_NUMERIC_TYPES_VOID = {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN', TAB_VOID} +## The mapping dictionary from datum type to its maximum number. +MAX_VAL_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, +TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} ## The mapping dictionary from datum type to size string. +MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", +TAB_UINT32:"4", TAB_UINT64:"8"} + TAB_EDK_SOURCE = '$(EDK_SOURCE)' TAB_EFI_SOURCE = '$(EFI_SOURCE)' TAB_WORKSPACE = '$(WORKSPACE)' @@ -58,9 +63,6 @@ TAB_ARCH_ARM = 'ARM' TAB_ARCH_EBC = 'EBC' TAB_ARCH_AARCH64 = 'AARCH64' -ARCH_LIST = [TAB_ARCH_IA32, TAB_ARCH_X64, TAB_ARCH_IPF, TAB_ARCH_ARM, TAB_ARCH_EBC, TAB_ARCH_AARCH64] -ARCH_LIST_FULL = [TAB_ARCH_COMMON] + ARCH_LIST - SUP_MODULE_BASE = 'BASE' SUP_MODULE_SEC = 'SEC' SUP_MODULE_PEI_CORE = 'PEI_CORE' diff --git a/BaseTools/Source/Python/Common/RangeExpression.py b/BaseTools/Source/Python/Common/RangeExpression.py index 78bb13988eff..4d07bd752330 100644 --- a/BaseTools/Source/Python/Common/RangeExpression.py +++ b/BaseTools/Source/Python/Common/RangeExpression.py @@ -17,7 +17,7 @@ from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression import uuid from Common.Expression import PcdPattern -from Common.DataType import TAB_UINT8 +from Common.DataType import * ERR_STRING_EXPR = 'This operator cannot be used in string expression: [%s].' ERR_SNYTAX = 'Syntax error, the rest of expression cannot be evaluated: [%s].' @@ -40,16 +40,6 @@ ERR_ARRAY_ELE = 'This must be HEX value for NList or Array: [%s].' ERR_EMPTY_EXPR = 'Empty expression is not allowed.' ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' -def MaxOfType(DataType): - if DataType == TAB_UINT8: - return int('0xFF', 16) - if DataType == TAB_UINT16: - return int('0xFFFF', 16) - if DataType == TAB_UINT32: - return int('0xFFFFFFFF', 16) - if DataType == TAB_UINT64: - return int('0xFFFFFFFFFFFFFFFF', 16) - class RangeObject(object): def __init__(self, start, end, empty = False): @@ -112,7 +102,7 @@ class XOROperatorObject(object): rangeId = str(uuid.uuid1()) rangeContainer = RangeContainer() rangeContainer.push(RangeObject(0, int(Operand) - 1)) - rangeContainer.push(RangeObject(int(Operand) + 1, MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand) + 1, + MAX_VAL_TYPE[DataType])) SymbolTable[rangeId] = rangeContainer return rangeId @@ -150,7 +140,7 @@ class GEOperatorObject(object): raise BadExpression(ERR_SNYTAX % Expr) rangeId1 = str(uuid.uuid1()) rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(int(Operand), MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand), + MAX_VAL_TYPE[DataType])) SymbolTable[rangeId1] = rangeContainer return rangeId1 @@ -163,7 +153,7 @@ class GTOperatorObject(object): raise BadExpression(ERR_SNYTAX % Expr) rangeId1 = str(uuid.uuid1()) rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(int(Operand) + 1, MaxOfType(DataType))) + rangeContainer.push(RangeObject(int(Operand) + 1, + MAX_VAL_TYPE[DataType])) SymbolTable[rangeId1] = rangeContainer return rangeId1 @@ -308,18 +298,18 @@ class RangeExpression(object): rangeContainer = RangeContainer() rangeid = str(uuid.uuid1()) if rangeobj.empty: - rangeContainer.push(RangeObject(0, MaxOfType(self.PcdDataType))) + rangeContainer.push(RangeObject(0, + MAX_VAL_TYPE[self.PcdDataType])) else: if rangeobj.start > 0: rangeContainer.push(RangeObject(0, rangeobj.start - 1)) - if rangeobj.end < MaxOfType(self.PcdDataType): - rangeContainer.push(RangeObject(rangeobj.end + 1, MaxOfType(self.PcdDataType))) + if rangeobj.end < MAX_VAL_TYPE[self.PcdDataType]: + rangeContainer.push(RangeObject(rangeobj.end + 1, + MAX_VAL_TYPE[self.PcdDataType])) self.operanddict[rangeid] = rangeContainer rangeids.append(rangeid) if len(rangeids) == 0: rangeContainer = RangeContainer() - rangeContainer.push(RangeObject(0, MaxOfType(self.PcdDataType))) + rangeContainer.push(RangeObject(0, + MAX_VAL_TYPE[self.PcdDataType])) rangeid = str(uuid.uuid1()) self.operanddict[rangeid] = rangeContainer return rangeid diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Source/Python/Common/VpdInfoFile.py index b8c8907ac91b..e1ea844eb7fd 100644 --- a/BaseTools/Source/Python/Common/VpdInfoFile.py +++ b/BaseTools/Source/Python/Common/VpdInfoFile.py @@ -69,8 +69,6 @@ FILE_COMMENT_TEMPLATE = \ # class VpdInfoFile: - ## The mapping dictionary from datum type to size string. - _MAX_SIZE_TYPE = {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_UINT32:"4", TAB_UINT64:"8"} _rVpdPcdLine = None ## Constructor def __init__(self): @@ -102,7 +100,7 @@ class VpdInfoFile: "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES: if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "": - Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType] + Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType] else: if Vpd.MaxDatumSize <= 0: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID, diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index ab2b58de5d89..6542b44398d3 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -47,14 +47,12 @@ import Common.GlobalData as GlobalData from DepexSection import DepexSection from Common.Misc import SaveFileOnChange from Common.Expression import * -from Common.DataType import TAB_UINT8 +from Common.DataType import * ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): - ## The mapping dictionary from datum type to its maximum number. - _MAX_SIZE_TYPE = {"BOOLEAN":0x01, TAB_UINT8:0xFF, TAB_UINT16:0xFFFF, TAB_UINT32:0xFFFFFFFF, TAB_UINT64:0xFFFFFFFFFFFFFFFF} ## The constructor # # @param self The object pointer @@ -333,8 +331,8 @@ class FfsInfStatement(FfsInfStatementClassObject): EdkLogger.error("GenFds", GENFDS_ERROR, "The size of VOID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) else: - if PcdValueInDscOrFdf > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType] \ - or PcdValueInImg > FfsInfStatement._MAX_SIZE_TYPE[Pcd.DatumType]: + if PcdValueInDscOrFdf > MAX_VAL_TYPE[Pcd.DatumType] \ + or PcdValueInImg > MAX_VAL_TYPE[Pcd.DatumType]: EdkLogger.error("GenFds", GENFDS_ERROR, "The size of %s type PCD '%s.%s' doesn't match its data type." \ % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)) self.PatchPcds.append((Pcd, DefaultValue)) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index e71f19750a56..c214e14398b6 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -1565,26 +1565,21 @@ class DscBuildData(PlatformBuildClassObject): return Result def GetPcdMaxSize(self,Pcd): + if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: + return MAX_SIZE_TYPE[Pcd.DatumType] + MaxSize = int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 - if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: - if Pcd.PcdValueFromComm: - if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): - MaxSize = max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) - elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"): - MaxSize = max([len(Pcd.PcdValueFromComm)-2+1,MaxSize]) - elif Pcd.PcdValueFromComm.startswith("L\""): - MaxSize = max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) - else: - MaxSize = max([len(Pcd.PcdValueFromComm),MaxSize]) - elif Pcd.DatumType not in ['BOOLEAN',TAB_UINT8]: - MaxSize = 1 - elif Pcd.DatumType == TAB_UINT16: - MaxSize = 2 - elif Pcd.DatumType == TAB_UINT32: - MaxSize = 4 - elif Pcd.DatumType == TAB_UINT64: - MaxSize = 8 + if Pcd.PcdValueFromComm: + if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFromComm.endswith("}"): + return max([len(Pcd.PcdValueFromComm.split(",")),MaxSize]) + elif Pcd.PcdValueFromComm.startswith("\"") or Pcd.PcdValueFromComm.startswith("\'"): + return max([len(Pcd.PcdValueFromComm)-2+1,MaxSize]) + elif Pcd.PcdValueFromComm.startswith("L\""): + return max([2*(len(Pcd.PcdValueFromComm)-3+1),MaxSize]) + else: + return max([len(Pcd.PcdValueFromComm),MaxSize]) return MaxSize + def GenerateSizeFunction(self,Pcd): CApp = "// Default Value in Dec \n" CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) -- 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-04-18 8:38 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-04-11 23:08 [PATCH v1 0/4] BaseTools: refactoring (and one bug fix) Jaben 2018-04-11 23:08 ` [PATCH v1 1/4] BaseTools: remove duplicate function name Jaben 2018-04-18 8:37 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 2/4] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants Jaben 2018-04-17 13:32 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 3/4] BaseTools: Remove un-needed list comprehension Jaben 2018-04-18 8:38 ` Zhu, Yonghong 2018-04-11 23:08 ` [PATCH v1 4/4] BaseTools: merge towards minimum PCD MAX <something> methods Jaben 2018-04-12 0:40 ` Feng, Bob C
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox