From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 45B15226CD620 for ; Sun, 22 Apr 2018 20:12:57 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2018 20:12:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,315,1520924400"; d="scan'208";a="39600963" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga002.fm.intel.com with ESMTP; 22 Apr 2018 20:12:56 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 22 Apr 2018 20:12:55 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Mon, 23 Apr 2018 11:12:52 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v2 2/2] BaseTools: replace 'UINT8','UINT16','UINT32','UINT64','VOID*' with shared constants. Thread-Index: AQHT1lq6lrMuFr2R7UCHJcgcgWm2DKQNtTUA Date: Mon, 23 Apr 2018 03:12:52 +0000 Message-ID: References: <293a01b2dfa36402259a4cd80d83d34d9b008677.1523976280.git.jaben.carsey@intel.com> In-Reply-To: <293a01b2dfa36402259a4cd80d83d34d9b008677.1523976280.git.jaben.carsey@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 2/2] BaseTools: replace 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'VOID*' with shared constants. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Apr 2018 03:12:58 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Tuesday, April 17, 2018 10:45 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v2 2/2] BaseTools: replace 'UINT8','UINT16','UINT32','UINT6= 4','VOID*' with shared constants. From: Jaben v2 fixes yonghongs comment. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- 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): =20 for PcdFromModule in M.ModulePcdList + M.LibraryPcdList: # make sure that the "VOID*" kind of datum has MaxDatumSiz= e set - if PcdFromModule.DatumType =3D=3D "VOID*" and PcdFromModul= e.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType =3D=3D TAB_VOID and PcdFromModu= le.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.T= okenSpaceGuidCName, PcdFromModule.TokenCName, F)) =20 # Check the PCD from Binary INF or Source INF @@ -1483,7 +1483,7 @@ class PlatformAutoGen(AutoGen): ExtraData=3D"\n\tExisted %s PCD %s= in:\n\t\t%s\n" % (PcdFromModule.Type, PcdFromModu= le.TokenCName, InfName)) # make sure that the "VOID*" kind of datum has MaxDatu= mSize set - if PcdFromModule.DatumType =3D=3D "VOID*" and PcdFromM= odule.MaxDatumSize in [None, '']: + if PcdFromModule.DatumType =3D=3D TAB_VOID and PcdFrom= Module.MaxDatumSize in [None, '']: NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModu= le.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName)) if M.ModuleType in ["PEIM", "PEI_CORE"]: PcdFromModule.Phase =3D "PEI" @@ -1548,7 +1548,7 @@ class PlatformAutoGen(AutoGen): =20 for item in self._PlatformPcds: if self._PlatformPcds[item].DatumType and self._PlatformPcds[i= tem].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_V= OID, "BOOLEAN"]: - self._PlatformPcds[item].DatumType =3D "VOID*" + self._PlatformPcds[item].DatumType =3D TAB_VOID =20 if (self.Workspace.ArchList[-1] =3D=3D self.Arch):=20 for Pcd in self._DynamicPcdList: @@ -1557,7 +1557,7 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset =3D Sku.VpdOffset.strip() =20 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32= , TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType =3D "VOID*" + Pcd.DatumType =3D TAB_VOID =20 # 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 Unicod= eIndex @@ -1709,7 +1709,7 @@ class PlatformAutoGen(AutoGen): SkuValueMap[PcdValue].append(Sku) if not NeedProcessVpdMapFile and Sku.VpdOf= fset =3D=3D "*": NeedProcessVpdMapFile =3D True=20 - if DscPcdEntry.DatumType =3D=3D 'VOID*' and Pc= dValue.startswith("L"): + if DscPcdEntry.DatumType =3D=3D TAB_VOID and P= cdValue.startswith("L"): UnicodePcdArray.add(DscPcdEntry) elif len(Sku.VariableName) > 0: HiiPcdArray.add(DscPcdEntry) @@ -1756,10 +1756,10 @@ class PlatformAutoGen(AutoGen): Sku.VpdOffset =3D Sku.VpdOffset.strip() =20 if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32= , TAB_UINT64, TAB_VOID, "BOOLEAN"]: - Pcd.DatumType =3D "VOID*" + Pcd.DatumType =3D TAB_VOID =20 PcdValue =3D Sku.DefaultValue - if Pcd.DatumType =3D=3D 'VOID*' and PcdValue.startswith("L= "): + if Pcd.DatumType =3D=3D 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 =3D FromPcd.validlists ToPcd.expressions =3D FromPcd.expressions =20 - if FromPcd is not None and ToPcd.DatumType =3D=3D "VOID*" and ToPc= d.MaxDatumSize in ['', None]: + if FromPcd is not None and ToPcd.DatumType =3D=3D TAB_VOID and ToP= cd.MaxDatumSize in ['', None]: EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified = for PCD %s.%s" \ % (ToPcd.TokenSpaceGuidCName, TokenCName)) Value =3D ToPcd.DefaultValue @@ -2457,7 +2457,7 @@ class PlatformAutoGen(AutoGen): # use PCD value to calculate the MaxDatumSize when it is not speci= fied for Name, Guid in Pcds: Pcd =3D Pcds[Name, Guid] - if Pcd.DatumType =3D=3D "VOID*" and Pcd.MaxDatumSize in ['', N= one]: + if Pcd.DatumType =3D=3D TAB_VOID and Pcd.MaxDatumSize in ['', = None]: Pcd.MaxSizeUserSet =3D None Value =3D Pcd.DefaultValue if Value in [None, '']: @@ -4125,13 +4125,13 @@ class ModuleAutoGen(AutoGen): elif BoolValue =3D=3D 'FALSE': Pcd.DefaultValue =3D '0' =20 - if Pcd.DatumType in ['UINT8', 'UINT16', 'UINT32', 'UINT64'= , 'BOOLEAN']: + if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES: HexFormat =3D '0x%02x' - if Pcd.DatumType =3D=3D 'UINT16': + if Pcd.DatumType =3D=3D TAB_UINT16: HexFormat =3D '0x%04x' - elif Pcd.DatumType =3D=3D 'UINT32': + elif Pcd.DatumType =3D=3D TAB_UINT32: HexFormat =3D '0x%08x' - elif Pcd.DatumType =3D=3D 'UINT64': + elif Pcd.DatumType =3D=3D TAB_UINT64: HexFormat =3D '0x%016x' PcdValue =3D HexFormat % int(Pcd.DefaultValue, 0) else: diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/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 =3D { TAB_PCDS_DYNAMIC_EX_HII : '', } =20 -_NumericDataTypesList =3D ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN= '] - ## Dynamic PCD types gDynamicPcd =3D [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAULT, TAB_PCDS_DYNA= MIC_VPD, TAB_PCDS_DYNAMIC_HII] =20 @@ -50,9 +48,9 @@ gDynamicPcd =3D [TAB_PCDS_DYNAMIC, TAB_PCDS_DYNAMIC_DEFAU= LT, TAB_PCDS_DYNAMIC_VPD, gDynamicExPcd =3D [TAB_PCDS_DYNAMIC_EX, TAB_PCDS_DYNAMIC_EX_DEFAULT, TAB_P= CDS_DYNAMIC_EX_VPD, TAB_PCDS_DYNAMIC_EX_HII] =20 ## Datum size -gDatumSizeStringDatabase =3D {'UINT8':'8','UINT16':'16','UINT32':'32','UIN= T64':'64','BOOLEAN':'BOOLEAN','VOID*':'8'} -gDatumSizeStringDatabaseH =3D {'UINT8':'8','UINT16':'16','UINT32':'32','UI= NT64':'64','BOOLEAN':'BOOL','VOID*':'PTR'} -gDatumSizeStringDatabaseLib =3D {'UINT8':'8','UINT16':'16','UINT32':'32','= UINT64':'64','BOOLEAN':'Bool','VOID*':'Ptr'} +gDatumSizeStringDatabase =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'32= ',TAB_UINT64:'64','BOOLEAN':'BOOLEAN',TAB_VOID:'8'} +gDatumSizeStringDatabaseH =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:'3= 2',TAB_UINT64:'64','BOOLEAN':'BOOL',TAB_VOID:'PTR'} +gDatumSizeStringDatabaseLib =3D {TAB_UINT8:'8',TAB_UINT16:'16',TAB_UINT32:= '32',TAB_UINT64:'64','BOOLEAN':'Bool',TAB_VOID:'Ptr'} =20 ## AutoGen File Header Templates gAutoGenHeaderString =3D TemplateString("""\ @@ -871,7 +869,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): TokenCNameList.append(TokenCName) =20 def GetPcdSize(Pcd): - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: Value =3D 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 =3D=3D 'UINT64': + if Pcd.DatumType =3D=3D TAB_UINT64: return 8 - if Pcd.DatumType =3D=3D 'UINT32': + if Pcd.DatumType =3D=3D TAB_UINT32: return 4 - if Pcd.DatumType =3D=3D 'UINT16': + if Pcd.DatumType =3D=3D TAB_UINT16: return 2 - if Pcd.DatumType =3D=3D 'UINT8': + if Pcd.DatumType =3D=3D TAB_UINT8: return 1 if Pcd.DatumType =3D=3D '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=3D"[%s]" % str(Info)) =20 - DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOI= D*'] - GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + To= kenCName + DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_= VOID] + GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + T= okenCName GetModeSizeName =3D '_PCD_GET_MODE_SIZE' + '_' + TokenCName =20 PcdExCNameList =3D [] @@ -979,7 +977,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, 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) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -989,7 +987,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, 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' % (GetModeSi= zeName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) else: @@ -1032,7 +1030,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): elif BoolValue =3D=3D 'FALSE' or BoolValue =3D=3D '0': Value =3D '0U' =20 - if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']: + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: try: if Value.upper().endswith('L'): Value =3D 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=3D"[%s]" % str(Info)) - if Pcd.DatumType =3D=3D 'UINT64': + if Pcd.DatumType =3D=3D TAB_UINT64: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value fo= r datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, = TokenCName), @@ -1052,7 +1050,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('ULL'): Value +=3D 'ULL' - elif Pcd.DatumType =3D=3D 'UINT32': + elif Pcd.DatumType =3D=3D TAB_UINT32: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value fo= r datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, = TokenCName), @@ -1063,7 +1061,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('U'): Value +=3D 'U' - elif Pcd.DatumType =3D=3D 'UINT16': + elif Pcd.DatumType =3D=3D TAB_UINT16: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value fo= r datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, = TokenCName), @@ -1074,7 +1072,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('U'): Value +=3D 'U' =20 - elif Pcd.DatumType =3D=3D 'UINT8': + elif Pcd.DatumType =3D=3D TAB_UINT8: if ValueNumber < 0: EdkLogger.error("build", AUTOGEN_ERROR, "PCD can't be set to negative value fo= r datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, = TokenCName), @@ -1085,7 +1083,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): ExtraData=3D"[%s]" % str(Info)) if not Value.endswith('U'): Value +=3D 'U' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize =3D=3D '': EdkLogger.error("build", AUTOGEN_ERROR, "Unknown [MaxDatumSize] of PCD [%s.%s]" % = (Pcd.TokenSpaceGuidCName, TokenCName), @@ -1123,10 +1121,10 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, P= cd): # skip casting for fixed at build since it breaks ARM assembly. # Long term we need PCD macros that work in assembly # - elif Pcd.Type !=3D TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in ['= UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLEAN', 'VOID*']: + elif Pcd.Type !=3D TAB_PCDS_FIXED_AT_BUILD and Pcd.DatumType in TA= B_PCD_NUMERIC_TYPES_VOID: Value =3D "((%s)%s)" % (Pcd.DatumType, Value) =20 - if Pcd.DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'B= OOLEAN', 'VOID*']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: # handle structure PCD if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize =3D=3D '': EdkLogger.error("build", AUTOGEN_ERROR, @@ -1141,7 +1139,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): else: PcdValueName =3D '_PCD_VALUE_' + TokenCName =20 - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: # # For unicode, UINT16 array will be generated, so the alignmen= t of unicode is guaranteed. # @@ -1188,7 +1186,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): AutoGenH.Append('#define %s %s%s\n' % (GetModeName, Type, Pcd= VariableName)) =20 if Pcd.Type =3D=3D 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) LibPatc= hPcdSetPtrAndSize((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) LibPatc= hPcdSetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &_gPcd_BinaryPatch_Size_%s= , (UINTN)_PCD_PATCHABLE_%s_SIZE, (SizeOfBuffer), (Buffer))\n' % (SetModeSta= tusName, Pcd.TokenCName, Pcd.TokenCName, Pcd.TokenCName)) else: @@ -1251,16 +1249,16 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): ExtraData=3D"[%s]" % str(Info)) =20 DatumType =3D Pcd.DatumType - DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase['VOID*'] - DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib['VOI= D*'] - GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_' + TokenCName - SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + To= kenCName + DatumSize =3D gDatumSizeStringDatabase[Pcd.DatumType] if Pcd.DatumType= in gDatumSizeStringDatabase else gDatumSizeStringDatabase[TAB_VOID] + DatumSizeLib =3D gDatumSizeStringDatabaseLib[Pcd.DatumType] if Pcd.Dat= umType in gDatumSizeStringDatabaseLib else gDatumSizeStringDatabaseLib[TAB_= VOID] + GetModeName =3D '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_GET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd.Datum= Type] + '_' + TokenCName if Pcd.DatumType in gDatumSizeStringDatabaseH else= '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_' + TokenCName + SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[TAB_VOID] + '_S_' + T= okenCName GetModeSizeName =3D '_PCD_GET_MODE_SIZE' + '_' + TokenCName =20 Type =3D '' Array =3D '' - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.DefaultValue[0]=3D=3D '{': Type =3D '(VOID *)' Array =3D '[]' @@ -1285,7 +1283,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, 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) LibP= cdSetEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLi= b, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('// #define %s(SizeOfBuffer, Buffer) LibP= cdSetEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, Datu= mSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1295,7 +1293,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): AutoGenH.Append('#define %s %s\n' % (PcdTokenName, PcdExToken= Name)) AutoGenH.Append('#define %s LibPcdGetEx%s(&%s, %s)\n' % (GetM= odeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetExSize(&%s, %s)\n' % (Get= ModeSizeName,Pcd.TokenSpaceGuidCName, PcdTokenName)) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%s(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeName, DatumSizeLib, = Pcd.TokenSpaceGuidCName, PcdTokenName)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= etEx%sS(&%s, %s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSi= zeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) else: @@ -1316,7 +1314,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) AutoGenH.Append('#define %s LibPcdGetSize(%s)\n' % (GetModeSi= zeName, PcdTokenName)) - if DatumType not in _NumericDataTypesList: + if DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%s(%s, (SizeOfBuffer), (Buffer))\n' %(SetModeName, DatumSizeLib, PcdToken= Name)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPcdS= et%sS(%s, (SizeOfBuffer), (Buffer))\n' % (SetModeStatusName, DatumSizeLib, = PcdTokenName)) else: @@ -1325,17 +1323,17 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): if PcdItemType =3D=3D TAB_PCDS_PATCHABLE_IN_MODULE: GetModeMaxSizeName =3D '_PCD_GET_MODE_MAXSIZE' + '_' + TokenCName PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[TAB_PCDS_PA= TCHABLE_IN_MODULE] + '_' + TokenCName - if DatumType not in _NumericDataTypesList: - if DatumType =3D=3D 'VOID*' and Array =3D=3D '[]': - DatumType =3D ['UINT8', 'UINT16'][Pcd.DefaultValue[0] =3D= =3D 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES: + if DatumType =3D=3D TAB_VOID and Array =3D=3D '[]': + DatumType =3D [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] = =3D=3D 'L'] else: - DatumType =3D 'UINT8' + DatumType =3D TAB_UINT8 AutoGenH.Append('extern %s _gPcd_BinaryPatch_%s%s;\n' %(DatumT= ype, TokenCName, Array)) else: AutoGenH.Append('extern volatile %s %s%s;\n' % (DatumType, P= cdVariableName, Array)) AutoGenH.Append('#define %s %s_gPcd_BinaryPatch_%s\n' %(GetModeNa= me, Type, TokenCName)) PcdDataSize =3D GetPcdSize(Pcd) - if Pcd.DatumType not in _NumericDataTypesList: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSize((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buffe= r))\n' % (SetModeName, TokenCName, PatchPcdSizeVariableName, PatchPcdMaxSiz= eVariable)) AutoGenH.Append('#define %s(SizeOfBuffer, Buffer) LibPatchPcd= SetPtrAndSizeS((VOID *)_gPcd_BinaryPatch_%s, &%s, %s, (SizeOfBuffer), (Buff= er))\n' % (SetModeStatusName, TokenCName, PatchPcdSizeVariableName, PatchPc= dMaxSizeVariable)) AutoGenH.Append('#define %s %s\n' % (GetModeMaxSizeName, Patch= PcdMaxSizeVariable)) @@ -1351,10 +1349,10 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): if PcdItemType =3D=3D TAB_PCDS_FIXED_AT_BUILD or PcdItemType =3D=3D TA= B_PCDS_FEATURE_FLAG: key =3D ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) PcdVariableName =3D '_gPcd_' + gItemTypeStringDatabase[Pcd.Type] += '_' + TokenCName - if DatumType =3D=3D 'VOID*' and Array =3D=3D '[]': - DatumType =3D ['UINT8', 'UINT16'][Pcd.DefaultValue[0] =3D=3D '= L'] - if DatumType not in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BOOLE= AN', 'VOID*']: - DatumType =3D 'UINT8' + if DatumType =3D=3D TAB_VOID and Array =3D=3D '[]': + DatumType =3D [TAB_UINT8, TAB_UINT16][Pcd.DefaultValue[0] =3D= =3D 'L'] + if DatumType not in TAB_PCD_NUMERIC_TYPES_VOID: + DatumType =3D TAB_UINT8 AutoGenH.Append('extern const %s _gPcd_FixedAtBuild_%s%s;\n' %(Dat= umType, TokenCName, Array)) AutoGenH.Append('#define %s %s_gPcd_FixedAtBuild_%s\n' %(GetModeN= ame, 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 =3D True if key in Info.ConstPcd: Pcd.DefaultValue =3D 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' %(TokenCNam= e, Type, PcdVariableName)) else: AutoGenH.Append('#define _PCD_VALUE_%s %s\n' %(TokenCName,= Pcd.DefaultValue)) PcdDataSize =3D GetPcdSize(Pcd) if PcdItemType =3D=3D 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' % (FixPcdSizeTokenNa= me, PcdDataSize)) AutoGenH.Append('#define %s %s\n' % (GetModeSizeName,F= ixPcdSizeTokenName)) 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_FACT= ORY from Common.VariableAttributes import VariableAttributes import copy from struct import unpack +from Common.DataType import * =20 DATABASE_VERSION =3D 7 =20 @@ -1023,7 +1024,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform= ,Phase): new_pcd =3D copy.deepcopy(pcd) new_pcd.SkuInfoList =3D {skuname:pcd.SkuInfoList[skuname]} new_pcd.isinit =3D '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 =3D int(skuobj.DefaultValue,16) if skuobj= .DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10) @@ -1102,7 +1103,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): =20 Dict['PCD_INFO_FLAG'] =3D Platform.Platform.PcdInfoFlag =20 - for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*= "]: + for DatumType in TAB_PCD_NUMERIC_TYPES_VOID: Dict['VARDEF_CNAME_' + DatumType] =3D [] Dict['VARDEF_GUID_' + DatumType] =3D [] Dict['VARDEF_SKUID_' + DatumType] =3D [] @@ -1174,7 +1175,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): ReorderedDynPcdList =3D GetOrderedDynamicPcdList(DynamicPcdList, Platf= orm.PcdTokenNumber) for item in ReorderedDynPcdList: if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_U= INT64, TAB_VOID, "BOOLEAN"]: - item.DatumType =3D "VOID*" + item.DatumType =3D TAB_VOID for Pcd in ReorderedDynPcdList: VoidStarTypeCurrSize =3D [] i +=3D 1 @@ -1215,7 +1216,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): VariableDbValueList =3D [] Pcd.InitString =3D 'UNINIT' =20 - if Pcd.DatumType =3D=3D 'VOID*': + if Pcd.DatumType =3D=3D TAB_VOID: if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]: Pcd.TokenTypeList =3D ['PCD_TYPE_STRING'] else: @@ -1319,9 +1320,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): # Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiD= efaultValue) =20 - if Pcd.DatumType =3D=3D "UINT64": + if Pcd.DatumType =3D=3D TAB_UINT64: Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.Hii= DefaultValue + "ULL") - elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"): + elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UIN= T8): Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.Hii= DefaultValue + "U") elif Pcd.DatumType =3D=3D "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=20 - if Pcd.DatumType =3D=3D 'VOID*': + if Pcd.DatumType =3D=3D TAB_VOID: NumberOfSizeItems +=3D 1 # For VPD type of PCD, its current size is equal to it= s MAX size. VoidStarTypeCurrSize =3D [str(Pcd.MaxDatumSize) + 'U']= =20 continue =20 - if Pcd.DatumType =3D=3D 'VOID*': + if Pcd.DatumType =3D=3D TAB_VOID: Pcd.TokenTypeList +=3D ['PCD_TYPE_STRING'] Pcd.InitString =3D 'INIT' if Sku.HiiDefaultValue !=3D '' and Sku.DefaultValue =3D=3D= '': @@ -1417,9 +1418,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): # For UNIT64 type PCD's value, ULL should be append to avo= id # warning under linux building environment. # - if Pcd.DatumType =3D=3D "UINT64": + if Pcd.DatumType =3D=3D 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 =3D=3D "BOOLEAN": if Sku.DefaultValue in ["1", "0"]: @@ -1430,7 +1431,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, = DynamicPcdList, Phase): DbValueList.append(Sku.DefaultValue) =20 Pcd.TokenTypeList =3D list(set(Pcd.TokenTypeList)) - if Pcd.DatumType =3D=3D 'VOID*': =20 + if Pcd.DatumType =3D=3D TAB_VOID: =20 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/P= ython/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.
+# Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e found at @@ -20,6 +20,7 @@ import copy from Common.VariableAttributes import VariableAttributes from Common.Misc import * import collections +from Common.DataType import * =20 var_info =3D collections.namedtuple("uefi_var", "pcdindex,pcdname,defaults= toragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default= _value, default_value, data_type") NvStorageHeaderSize =3D 28 @@ -90,14 +91,14 @@ class VariableMgr(object): for item in sku_var_info_offset_list: data_type =3D item.data_type value_list =3D item.default_value.strip("{").strip("}").sp= lit(",") - if data_type in ["BOOLEAN","UINT8","UINT16","UINT32","UINT= 64"]: - if data_type =3D=3D ["BOOLEAN","UINT8"]: + if data_type in TAB_PCD_NUMERIC_TYPES: + if data_type =3D=3D ["BOOLEAN",TAB_UINT8]: data_flag =3D "=3DB" - elif data_type =3D=3D "UINT16": + elif data_type =3D=3D TAB_UINT16: data_flag =3D "=3DH" - elif data_type =3D=3D "UINT32": + elif data_type =3D=3D TAB_UINT32: data_flag =3D "=3DL" - elif data_type =3D=3D "UINT64": + elif data_type =3D=3D TAB_UINT64: data_flag =3D "=3DQ" data =3D value_list[0] value_list =3D [] @@ -109,7 +110,7 @@ class VariableMgr(object): except: EdkLogger.error("build", AUTOGEN_ERROR, "Variable offset c= onflict in PCDs: %s \n" % (" and ".join([item.pcdname for item in sku_var_i= nfo_offset_list]))) n =3D sku_var_info_offset_list[0] - indexedvarinfo[key] =3D [var_info(n.pcdindex,n.pcdname,n.defa= ultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,new= valuestr , newvaluestr , "VOID*")] + indexedvarinfo[key] =3D [var_info(n.pcdindex,n.pcdname,n.defa= ultstoragename,n.skuname,n.var_name, n.var_guid, "0x00",n.var_attribute,new= valuestr , newvaluestr , TAB_VOID)] self.VarInfo =3D [item[0] for item in indexedvarinfo.values()] =20 def assemble_variable(self, valuelist): @@ -143,7 +144,7 @@ class VariableMgr(object): tail =3D None default_sku_default =3D indexedvarinfo.get(index).get(("DEFAUL= T","STANDARD")) =20 - if default_sku_default.data_type not in ["UINT8","UINT16","UIN= T32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TYPES: var_max_len =3D 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 =3D ",".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 =3D indexedvarinfo.get(index).get((skuid,d= efaultstoragename)) =20 - if default_sku_default.data_type not in ["UINT8","UINT16",= "UINT32","UINT64","BOOLEAN"]: + if default_sku_default.data_type not in TAB_PCD_NUMERIC_TY= PES: if len(other_sku_other.default_value.split(",")) < var= _max_len: tail =3D ",".join([ "0x00" for i in range(var_max_= len-len(other_sku_other.default_value.split(",")))]) =20 @@ -313,7 +314,7 @@ class VariableMgr(object): def PACK_VARIABLES_DATA(self, var_value,data_type, tail =3D None): Buffer =3D "" data_len =3D 0 - if data_type =3D=3D "VOID*": + if data_type =3D=3D TAB_VOID: for value_char in var_value.strip("{").strip("}").split(","): Buffer +=3D pack("=3DB",int(value_char,16)) data_len +=3D len(var_value.split(",")) @@ -324,16 +325,16 @@ class VariableMgr(object): elif data_type =3D=3D "BOOLEAN": Buffer +=3D pack("=3DB",True) if var_value.upper() =3D=3D "TRU= E" else pack("=3DB",False) data_len +=3D 1 - elif data_type =3D=3D "UINT8": + elif data_type =3D=3D TAB_UINT8: Buffer +=3D pack("=3DB",GetIntegerValue(var_value)) data_len +=3D 1 - elif data_type =3D=3D "UINT16": + elif data_type =3D=3D TAB_UINT16: Buffer +=3D pack("=3DH",GetIntegerValue(var_value)) data_len +=3D 2 - elif data_type =3D=3D "UINT32": + elif data_type =3D=3D TAB_UINT32: Buffer +=3D pack("=3DL",GetIntegerValue(var_value)) data_len +=3D 4 - elif data_type =3D=3D "UINT64": + elif data_type =3D=3D TAB_UINT64: Buffer +=3D pack("=3DQ",GetIntegerValue(var_value)) data_len +=3D 8 =20 diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/B= aseTools/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 * =20 class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object): def __init__(self): @@ -250,13 +251,13 @@ class VAR_CHECK_PCD_VALID_OBJ(object): self.ValidData =3D True self.updateStorageWidth() def updateStorageWidth(self): - if self.PcdDataType =3D=3D "UINT8" or self.PcdDataType =3D=3D "BOO= LEAN": + if self.PcdDataType =3D=3D TAB_UINT8 or self.PcdDataType =3D=3D "B= OOLEAN": self.StorageWidth =3D 1 - elif self.PcdDataType =3D=3D "UINT16": + elif self.PcdDataType =3D=3D TAB_UINT16: self.StorageWidth =3D 2 - elif self.PcdDataType =3D=3D "UINT32": + elif self.PcdDataType =3D=3D TAB_UINT32: self.StorageWidth =3D 4 - elif self.PcdDataType =3D=3D "UINT64": + elif self.PcdDataType =3D=3D TAB_UINT64: self.StorageWidth =3D 8 else: self.StorageWidth =3D 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 fi= les # -# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License @@ -41,6 +41,10 @@ TAB_UINT32 =3D 'UINT32' TAB_UINT64 =3D 'UINT64' TAB_VOID =3D 'VOID*' =20 +TAB_PCD_CLEAN_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UI= NT64} +TAB_PCD_NUMERIC_TYPES =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, = 'BOOLEAN'} +TAB_PCD_NUMERIC_TYPES_VOID =3D {TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UIN= T64, 'BOOLEAN', TAB_VOID} + TAB_EDK_SOURCE =3D '$(EDK_SOURCE)' TAB_EFI_SOURCE =3D '$(EFI_SOURCE)' TAB_WORKSPACE =3D '$(WORKSPACE)' diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/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, IsField= ValueAnArray import Common.EdkLogger as EdkLogger import copy +from Common.DataType import * =20 ERR_STRING_EXPR =3D 'This operator cannot be used in string expres= sion: [%s].' ERR_SNYTAX =3D 'Syntax error, the rest of expression cannot b= e evaluated: [%s].' @@ -136,7 +137,7 @@ def BuildOptionValue(PcdValue, GuidDict): InputValue =3D PcdValue if IsFieldValueAnArray(InputValue): try: - PcdValue =3D ValueExpressionEx(InputValue, 'VOID*', GuidDict)(= True) + PcdValue =3D ValueExpressionEx(InputValue, TAB_VOID, GuidDict)= (True) except: pass return PcdValue @@ -800,20 +801,20 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D self.PcdValue try: PcdValue =3D ValueExpression.__call__(self, RealValue, Depth) - if self.PcdType =3D=3D 'VOID*' and (PcdValue.startswith("'") o= r PcdValue.startswith("L'")): + if self.PcdType =3D=3D TAB_VOID and (PcdValue.startswith("'") = or PcdValue.startswith("L'")): PcdValue, Size =3D ParseFieldValue(PcdValue) PcdValueList =3D [] for I in range(Size): PcdValueList.append('0x%02X'%(PcdValue & 0xff)) PcdValue =3D PcdValue >> 8 PcdValue =3D '{' + ','.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.start= swith("'") or \ PcdValue.startswith('"') or PcdValue.startswith("L'"= ) or PcdValue.startswith('L"') or PcdValue.startswith('{')): raise BadExpression except WrnExpression, Value: PcdValue =3D Value.result except BadExpression, Value: - if self.PcdType in ['UINT8', 'UINT16', 'UINT32', 'UINT64', 'BO= OLEAN']: + if self.PcdType in TAB_PCD_NUMERIC_TYPES: PcdValue =3D PcdValue.strip() if type(PcdValue) =3D=3D type('') and PcdValue.startswith(= '{') and PcdValue.endswith('}'): PcdValue =3D SplitPcdValueString(PcdValue[1:-1]) @@ -823,24 +824,24 @@ class ValueExpressionEx(ValueExpression): ValueType =3D '' for Item in PcdValue: Item =3D Item.strip() - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize =3D 1 - ValueType =3D 'UINT8' - elif Item.startswith('UINT16'): + ValueType =3D TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize =3D 2 - ValueType =3D 'UINT16' - elif Item.startswith('UINT32'): + ValueType =3D TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize =3D 4 - ValueType =3D 'UINT32' - elif Item.startswith('UINT64'): + ValueType =3D TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize =3D 8 - ValueType =3D 'UINT64' + ValueType =3D TAB_UINT64 elif Item[0] in ['"',"'",'L']: ItemSize =3D 0 - ValueType =3D 'VOID*' + ValueType =3D TAB_VOID else: ItemSize =3D 0 - ValueType =3D 'UINT8' + ValueType =3D TAB_UINT8 Item =3D ValueExpressionEx(Item, ValueType, self._= Symb)(True) =20 if ItemSize =3D=3D 0: @@ -875,13 +876,13 @@ class ValueExpressionEx(ValueExpression): PcdValue =3D '0x%0{}X'.format(Size) % (TmpValue) if TmpValue < 0: raise BadExpression('Type %s PCD Value is negative' %= self.PcdType) - if self.PcdType =3D=3D 'UINT8' and Size > 1: + if self.PcdType =3D=3D TAB_UINT8 and Size > 1: raise BadExpression('Type %s PCD Value Size is Larger = than 1 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT16' and Size > 2: + if self.PcdType =3D=3D TAB_UINT16 and Size > 2: raise BadExpression('Type %s PCD Value Size is Larger = than 2 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT32' and Size > 4: + if self.PcdType =3D=3D TAB_UINT32 and Size > 4: raise BadExpression('Type %s PCD Value Size is Larger = than 4 byte' % self.PcdType) - if self.PcdType =3D=3D 'UINT64' and Size > 8: + if self.PcdType =3D=3D 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 v= alid c variable name' % Label) if Label not in LabelDict.keys(): LabelDict[Label] =3D str(LabelOffs= et) - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): LabelOffset =3D LabelOffset + 1 - elif Item.startswith('UINT16'): + elif Item.startswith(TAB_UINT16): LabelOffset =3D LabelOffset + 2 - elif Item.startswith('UINT32'): + elif Item.startswith(TAB_UINT32): LabelOffset =3D LabelOffset + 4 - elif Item.startswith('UINT64'): + elif Item.startswith(TAB_UINT64): LabelOffset =3D LabelOffset + 8 else: try: @@ -971,18 +972,18 @@ class ValueExpressionEx(ValueExpression): continue else: ValueType =3D "" - if Item.startswith('UINT8'): + if Item.startswith(TAB_UINT8): ItemSize =3D 1 - ValueType =3D "UINT8" - elif Item.startswith('UINT16'): + ValueType =3D TAB_UINT8 + elif Item.startswith(TAB_UINT16): ItemSize =3D 2 - ValueType =3D "UINT16" - elif Item.startswith('UINT32'): + ValueType =3D TAB_UINT16 + elif Item.startswith(TAB_UINT32): ItemSize =3D 4 - ValueType =3D "UINT32" - elif Item.startswith('UINT64'): + ValueType =3D TAB_UINT32 + elif Item.startswith(TAB_UINT64): ItemSize =3D 8 - ValueType =3D "UINT64" + ValueType =3D TAB_UINT64 else: ItemSize =3D 0 if ValueType: diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/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 =3D Value.strip() - if Value.startswith('UINT8') and Value.endswith(')'): + if Value.startswith(TAB_UINT8) and Value.endswith(')'): Value, Size =3D 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 =3D 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 =3D 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 =3D 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=3D''): elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD): VpdOffset =3D FieldList[0] Value =3D Size =3D '' - if not DataType =3D=3D 'VOID*': + if not DataType =3D=3D TAB_VOID: if len(FieldList) > 1: Value =3D FieldList[1] else: @@ -1558,7 +1558,7 @@ def AnalyzePcdData(Setting): # For PCD value setting # def CheckPcdDatum(Type, Value): - if Type =3D=3D "VOID*": + if Type =3D=3D TAB_VOID: ValueRe =3D re.compile(r'\s*L?\".*\"\s*$') if not (((Value.startswith('L"') or Value.startswith('"')) and Val= ue.endswith('"')) or (Value.startswith('{') and Value.endswith('}')) or (Val= ue.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 =20 ERR_STRING_EXPR =3D 'This operator cannot be used in string expression: [%= s].' ERR_SNYTAX =3D 'Syntax error, the rest of expression cannot be evaluated: = [%s].' @@ -40,13 +41,13 @@ ERR_EMPTY_EXPR =3D 'Empty expression is not allowed.' ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY), $(ARCH= ), $(TOOL_CHAIN_TAG) and $(TARGET).' =20 def MaxOfType(DataType): - if DataType =3D=3D 'UINT8': + if DataType =3D=3D TAB_UINT8: return int('0xFF', 16) - if DataType =3D=3D 'UINT16': + if DataType =3D=3D TAB_UINT16: return int('0xFFFF', 16) - if DataType =3D=3D 'UINT32': + if DataType =3D=3D TAB_UINT32: return int('0xFFFFFFFF', 16) - if DataType =3D=3D 'UINT64': + if DataType =3D=3D TAB_UINT64: return int('0xFFFFFFFFFFFFFFFF', 16) =20 class RangeObject(object): diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py b/BaseTools/Sour= ce/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 * =20 FILE_COMMENT_TEMPLATE =3D \ """ @@ -69,7 +70,7 @@ FILE_COMMENT_TEMPLATE =3D \ class VpdInfoFile: =20 ## The mapping dictionary from datum type to size string. - _MAX_SIZE_TYPE =3D {"BOOLEAN":"1", "UINT8":"1", "UINT16":"2", "UINT32"= :"4", "UINT64":"8"} + _MAX_SIZE_TYPE =3D {"BOOLEAN":"1", TAB_UINT8:"1", TAB_UINT16:"2", TAB_= UINT32:"4", TAB_UINT64:"8"} _rVpdPcdLine =3D None=20 ## Constructor def __init__(self): @@ -95,11 +96,11 @@ class VpdInfoFile: if not (Offset >=3D 0 or Offset =3D=3D "*"): EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALI= D, "Invalid offset parameter: %s." % Offset) =20 - if Vpd.DatumType =3D=3D "VOID*": + if Vpd.DatumType =3D=3D TAB_VOID: if Vpd.MaxDatumSize <=3D 0: EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_IN= VALID,=20 "Invalid max datum size for VPD PCD %s.%s"= % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName)) - elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UI= NT64"]:=20 + elif Vpd.DatumType in TAB_PCD_NUMERIC_TYPES:=20 if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize =3D=3D "": Vpd.MaxDatumSize =3D VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumT= ype] else: diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.p= y 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] =3D=3D 'VOID*': + if len(ValueList) > 1 and ValueList[1] =3D=3D TAB_VOID: PcdValue =3D ValueList[0] =20 try: ValueList[0] =3D ValueExpression(PcdValue, self._Macros)(T= rue) 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 a= s 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 =20 ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' @@ -1132,7 +1133,7 @@ class FdfParser: return False =20 def __Verify(self, Name, Value, Scope): - if Scope in ['UINT64', 'UINT8']: + if Scope in [TAB_UINT64, TAB_UINT8]: ValueNumber =3D 0 try: ValueNumber =3D 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 ca= n't be set to negative value for %s." % Name) - if Scope =3D=3D 'UINT64': + if Scope =3D=3D TAB_UINT64: if ValueNumber >=3D 0x10000000000000000: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too larg= e value for %s." % Name) - if Scope =3D=3D 'UINT8': + if Scope =3D=3D TAB_UINT8: if ValueNumber >=3D 0x100: EdkLogger.error("FdfParser", FORMAT_INVALID, "Too larg= e value for %s." % Name) return True @@ -3201,16 +3202,16 @@ class FdfParser: raise Warning("expected value of %s" % Name, self.File= Name, self.CurrentLineNumber) Value =3D self.__Token if Name =3D=3D 'IMAGE_HEADER_INIT_VERSION': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.Version =3D Value elif Name =3D=3D 'IMAGE_INDEX': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.ImageIndex =3D Value elif Name =3D=3D 'HARDWARE_INSTANCE': - if self.__Verify(Name, Value, 'UINT8'): + if self.__Verify(Name, Value, TAB_UINT8): FmpData.HardwareInstance =3D Value elif Name =3D=3D 'MONOTONIC_COUNT': - if self.__Verify(Name, Value, 'UINT64'): + if self.__Verify(Name, Value, TAB_UINT64): FmpData.MonotonicCount =3D Value if FmpData.MonotonicCount.upper().startswith('0X')= : FmpData.MonotonicCount =3D (long)(FmpData.Mono= tonicCount, 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 =20 ## generate FFS from INF # # class FfsInfStatement(FfsInfStatementClassObject): ## The mapping dictionary from datum type to its maximum number. - _MAX_SIZE_TYPE =3D {"BOOLEAN":0x01, "UINT8":0xFF, "UINT16":0xFFFF, "UI= NT32":0xFFFFFFFF, "UINT64":0xFFFFFFFFFFFFFFFF} + _MAX_SIZE_TYPE =3D {"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] V= alue "%s"' %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DefaultValue),Fil= e=3Dself.InfFileName) =20 # Check value, if value are equal, no need to patch - if Pcd.DatumType =3D=3D "VOID*": + if Pcd.DatumType =3D=3D TAB_VOID: if Pcd.InfDefaultValue =3D=3D 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 =3D=3D "VOID*": + if Pcd.DatumType =3D=3D TAB_VOID: if int(MaxDatumSize) > int(Pcd.MaxDatumSize): EdkLogger.error("GenFds", GENFDS_ERROR, "The size of V= OID* type PCD '%s.%s' exceeds its maximum size %d bytes." \ % (Pcd.TokenSpaceGuidCName, Pcd.TokenC= Name, int(MaxDatumSize) - int(Pcd.MaxDatumSize))) diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseT= ools/Source/Python/GenFds/GenFdsGlobalVariable.py index 2f9d58f6bf37..8ff292ef5030 100644 --- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py +++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py @@ -811,7 +811,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName =3D=3D TokenCName) and (PcdObj.Token= SpaceGuidCName =3D=3D TokenSpace): if PcdObj.Type !=3D 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not= FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType !=3D 'VOID*': + if PcdObj.DatumType !=3D DataType.TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is not= VOID* datum type." % PcdPattern) =20 PcdValue =3D PcdObj.DefaultValue @@ -827,7 +827,7 @@ class GenFdsGlobalVariable: if (PcdObj.TokenCName =3D=3D TokenCName) and (PcdObj.T= okenSpaceGuidCName =3D=3D TokenSpace): if PcdObj.Type !=3D 'FixedAtBuild': EdkLogger.error("GenFds", GENFDS_ERROR, "%s is= not FixedAtBuild type." % PcdPattern) - if PcdObj.DatumType !=3D 'VOID*': + if PcdObj.DatumType !=3D DataType.TAB_VOID: EdkLogger.error("GenFds", GENFDS_ERROR, "%s is= not VOID* datum type." % PcdPattern) =20 PcdValue =3D PcdObj.DefaultValue diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseT= ools/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.
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
# This program and the accompanying materials # are licensed and made available under the terms and conditions of the BS= D License # which accompanies this distribution. The full text of the license may b= e 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 * =20 # Version and Copyright __version_number__ =3D ("0.10" + " " + gBUILD_VERSION) @@ -62,15 +63,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, Va= lueString, MaxSize=3D0): ValueLength =3D 0 if TypeName =3D=3D 'BOOLEAN': ValueLength =3D 1 - elif TypeName =3D=3D 'UINT8': + elif TypeName =3D=3D TAB_UINT8: ValueLength =3D 1 - elif TypeName =3D=3D 'UINT16': + elif TypeName =3D=3D TAB_UINT16: ValueLength =3D 2 - elif TypeName =3D=3D 'UINT32': + elif TypeName =3D=3D TAB_UINT32: ValueLength =3D 4 - elif TypeName =3D=3D 'UINT64': + elif TypeName =3D=3D TAB_UINT64: ValueLength =3D 8 - elif TypeName =3D=3D 'VOID*': + elif TypeName =3D=3D TAB_VOID: if MaxSize =3D=3D 0: return OPTION_MISSING, "PcdMaxSize is not specified for VOID* = type PCD." ValueLength =3D int(MaxSize) @@ -119,7 +120,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, Va= lueString, MaxSize=3D0): # Set PCD value into binary data # ByteList[ValueOffset] =3D 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, Va= lueString, MaxSize=3D0): for Index in range(ValueLength): ByteList[ValueOffset + Index] =3D ValueNumber % 0x100 ValueNumber =3D ValueNumber / 0x100 - elif TypeName =3D=3D 'VOID*': + elif TypeName =3D=3D TAB_VOID: ValueString =3D 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=3D"= 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= =3D"PCD type %s is not valid." % (CommandOptions.PcdTypeName)) return 1 - if CommandOptions.PcdTypeName.upper() =3D=3D "VOID*" and CommandOp= tions.PcdMaxSize is None: + if CommandOptions.PcdTypeName.upper() =3D=3D TAB_VOID and CommandO= ptions.PcdMaxSize is None: EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData=3D"= 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, Structure= Pcd, PcdClassObject, ModuleBuildClassObject from collections import OrderedDict =20 -# -# Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VF= R C structs -# PcdValueInitName =3D 'PcdValueInit' -PcdSupportedBaseTypes =3D ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64= ', 'CHAR16'] -PcdSupportedBaseTypeWidth =3D {'BOOLEAN':8, 'UINT8':8, 'UINT16':16, 'UINT3= 2':32, 'UINT64':64} -PcdUnsupportedBaseTypes =3D ['INT8', 'INT16', 'INT32', 'INT64', 'CHAR8', '= UINTN', 'INTN', 'VOID'] =20 PcdMainCHeader =3D ''' /** @@ -1058,7 +1052,7 @@ class DscBuildData(PlatformBuildClassObject): TokenCName +=3D '.' + FieldName if PcdValue.startswith('H'): if FieldName and IsFieldValueAnArray(PcdValue[1:]): - PcdDatumType =3D 'VOID*' + PcdDatumType =3D TAB_VOID IsArray =3D 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 =3D 'VOID*' + PcdDatumType =3D TAB_VOID IsArray =3D True if FieldName and not IsArray: return PcdValue @@ -1081,7 +1075,7 @@ class DscBuildData(PlatformBuildClassObject): elif PcdValue.startswith('L'): PcdValue =3D 'L"' + PcdValue[1:] + '"' if FieldName and IsFieldValueAnArray(PcdValue): - PcdDatumType =3D 'VOID*' + PcdDatumType =3D TAB_VOID IsArray =3D True if FieldName and not IsArray: return PcdValue @@ -1096,7 +1090,7 @@ class DscBuildData(PlatformBuildClassObject): if PcdValue.upper() =3D=3D 'TRUE': PcdValue =3D str(1) if not FieldName: - if PcdDatumType not in ['UINT8','UINT16','UINT32','UINT64'= ,'BOOLEAN']: + if PcdDatumType not in TAB_PCD_NUMERIC_TYPES: PcdValue =3D '"' + PcdValue + '"' else: IsArray =3D False @@ -1108,7 +1102,7 @@ class DscBuildData(PlatformBuildClassObject): except: PcdValue =3D '"' + PcdValue + '"' if IsFieldValueAnArray(PcdValue): - PcdDatumType =3D 'VOID*' + PcdDatumType =3D TAB_VOID IsArray =3D True if not IsArray: return PcdValue @@ -1255,7 +1249,7 @@ class DscBuildData(PlatformBuildClassObject): for defaultstore in SkuInfo.DefaultStoreDict: SkuInfo.DefaultStoreDict[defaultstore] =3D= NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0] if Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAM= IC_EX_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII]]: - if Pcd.DatumType =3D=3D "VOID*": + if Pcd.DatumType =3D=3D TAB_VOID: if not Pcd.MaxDatumSize: Pcd.MaxDatumSize =3D '0' CurrentSize =3D int(Pcd.MaxDatumSize,16) if Pc= d.MaxDatumSize.upper().startswith("0X") else int(Pcd.MaxDatumSize) @@ -1572,7 +1566,7 @@ class DscBuildData(PlatformBuildClassObject): =20 def GetPcdMaxSize(self,Pcd): MaxSize =3D int(Pcd.MaxDatumSize,10) if Pcd.MaxDatumSize else 0 - if Pcd.DatumType not in ['BOOLEAN','UINT8','UINT16','UINT32','UINT= 64']: + if Pcd.DatumType not in TAB_PCD_NUMERIC_TYPES: if Pcd.PcdValueFromComm: if Pcd.PcdValueFromComm.startswith("{") and Pcd.PcdValueFr= omComm.endswith("}"): MaxSize =3D max([len(Pcd.PcdValueFromComm.split(",")),= MaxSize]) @@ -1582,13 +1576,13 @@ class DscBuildData(PlatformBuildClassObject): MaxSize =3D max([2*(len(Pcd.PcdValueFromComm)-3+1),Max= Size]) else: MaxSize =3D max([len(Pcd.PcdValueFromComm),MaxSize]) - elif Pcd.DatumType not in ['BOOLEAN','UINT8']: + elif Pcd.DatumType not in ['BOOLEAN',TAB_UINT8]: MaxSize =3D 1 - elif Pcd.DatumType =3D=3D 'UINT16': + elif Pcd.DatumType =3D=3D TAB_UINT16: MaxSize =3D 2 - elif Pcd.DatumType =3D=3D 'UINT32': + elif Pcd.DatumType =3D=3D TAB_UINT32: MaxSize =3D 4 - elif Pcd.DatumType =3D=3D 'UINT64': + elif Pcd.DatumType =3D=3D TAB_UINT64: MaxSize =3D 8 return MaxSize def GenerateSizeFunction(self,Pcd): @@ -1602,7 +1596,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(FieldList[FieldName.strip(= ".")][0]) if IsArray and not (FieldList[FieldName.strip(".")][0].sta= rtswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')): try: - Value =3D ValueExpressionEx(FieldList[FieldName.st= rip(".")][0], "VOID*", self._GuidDict)(True) + Value =3D ValueExpressionEx(FieldList[FieldName.st= rip(".")][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 =3D IsFieldValueAnArray(FieldList[FieldNam= e.strip(".")][0]) if IsArray and not (FieldList[FieldName.strip(".")= ][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}= ')): try: - Value =3D ValueExpressionEx(FieldList[Fiel= dName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value =3D ValueExpressionEx(FieldList[Fiel= dName.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.TokenSpaceG= uidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip= (".")][1], FieldList[FieldName.strip(".")][2])) @@ -1656,7 +1650,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(Pcd.PcdFieldValueFromComm[Fiel= dName.strip(".")][0]) if IsArray and not (Pcd.PcdFieldValueFromComm[FieldName.strip(= ".")][0].startswith('{GUID') and Pcd.PcdFieldValueFromComm[FieldName.strip(= ".")][0].endswith('}')): try: - Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromComm[= FieldName.strip(".")][0], "VOID*", self._GuidDict)(True) + Value =3D ValueExpressionEx(Pcd.PcdFieldValueFromComm[= FieldName.strip(".")][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Invalid valu= e format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName, Pc= d.TokenCName, FieldName.strip('.'))), Pcd.PcdFieldValueFromComm[FieldName.s= trip(".")][1], Pcd.PcdFieldValueFromComm[FieldName.strip(".")][2])) @@ -1689,7 +1683,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(Pcd.DefaultValueFromDec) if IsArray: try: - DefaultValueFromDec =3D ValueExpressionEx(Pcd.DefaultValue= FromDec, "VOID*")(True) + DefaultValueFromDec =3D ValueExpressionEx(Pcd.DefaultValue= FromDec, TAB_VOID)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid value fo= rmat for %s.%s, from DEC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, = DefaultValueFromDec)) @@ -1710,7 +1704,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[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 =3D IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList =3D ValueExpressionEx(FieldList, "VOID*"= )(True) + FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from DSC: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) @@ -1790,7 +1784,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0= ]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx(= FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True) except BadExpression: EdkLogger.error('Build', FORMAT_INVALID, "Inva= lid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidC= Name, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[Field= Name][2])) @@ -1831,7 +1825,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(FieldList) if IsArray: try: - FieldList =3D ValueExpressionEx(FieldList, "VOID*"= )(True) + FieldList =3D ValueExpressionEx(FieldList, TAB_VOI= D)(True) except BadExpression: EdkLogger.error("Build", FORMAT_INVALID, "Invalid = value format for %s.%s, from Command: %s" % (Pcd.TokenSpaceGuidCName, Pcd.Toke= nCName, FieldList)) @@ -1850,7 +1844,7 @@ class DscBuildData(PlatformBuildClassObject): IsArray =3D IsFieldValueAnArray(FieldList[FieldName][0]) if IsArray: try: - FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[FieldName][0], "VOID*", self._GuidDict)(True) + FieldList[FieldName][0] =3D ValueExpressionEx(Fiel= dList[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 =3D int(pcd.MaxDatumSize, 0) else: MaxSize =3D 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 =3D 0 skuobj.HiiDefaultValue =3D StringToArray(skuobj.HiiDef= aultValue) diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Sourc= e/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 =3D False =20 =20 - if Pcd.DatumType in ('UINT8', 'UINT16', 'UINT32', 'UIN= T64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES: PcdValueNumber =3D int(PcdValue.strip(), 0) if DecDefaultValue is None: DecMatch =3D True @@ -1112,7 +1112,7 @@ class PcdReport(object): ModuleOverride =3D self.ModulePcdOverride.get(= (Pcd.TokenCName, Pcd.TokenSpaceGuidCName), {}) for ModulePath in ModuleOverride: ModuleDefault =3D ModuleOverride[ModulePat= h] - if Pcd.DatumType in ('UINT8', 'UINT16', 'U= INT32', 'UINT64'): + if Pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_= TYPES: ModulePcdDefaultValueNumber =3D int(Mo= duleDefault.strip(), 0) Match =3D (ModulePcdDefaultValueNumber= =3D=3D PcdValueNumber) else: --=20 2.16.2.windows.1