]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenPcdDb.py
BaseTools: DataType - cleanup list constants
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenPcdDb.py
index 5937558e7038632bcf7721935a794cb057cb4a8c..e0d1918e98054277a1fccd2e04d2ae1ae3ab09e5 100644 (file)
@@ -20,7 +20,7 @@ from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY
 from Common.VariableAttributes import VariableAttributes\r
 import copy\r
 from struct import unpack\r
-from Common.DataType import TAB_DEFAULT\r
+from Common.DataType import *\r
 \r
 DATABASE_VERSION = 7\r
 \r
@@ -980,7 +980,6 @@ def CreatePcdDatabaseCode (Info, AutoGenC, AutoGenH):
     Changed = SaveFileOnChange(DbFileName, DbFile.getvalue(), True)\r
 def CreatePcdDataBase(PcdDBData):\r
     delta = {}\r
-    basedata = {}\r
     for skuname,skuid in PcdDBData:\r
         if len(PcdDBData[(skuname,skuid)][1]) != len(PcdDBData[(TAB_DEFAULT,"0")][1]):\r
             EdkLogger.ERROR("The size of each sku in one pcd are not same")\r
@@ -988,7 +987,6 @@ def CreatePcdDataBase(PcdDBData):
         if skuname == TAB_DEFAULT:\r
             continue\r
         delta[(skuname,skuid)] = [(index,data,hex(data)) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]\r
-        basedata[(skuname,skuid)] = [(index,PcdDBData[(TAB_DEFAULT,"0")][1][index],hex(PcdDBData[(TAB_DEFAULT,"0")][1][index])) for index,data in enumerate(PcdDBData[(skuname,skuid)][1]) if PcdDBData[(skuname,skuid)][1][index] != PcdDBData[(TAB_DEFAULT,"0")][1][index]]\r
     databasebuff = PcdDBData[(TAB_DEFAULT,"0")][0]\r
 \r
     for skuname,skuid in delta:\r
@@ -1026,7 +1024,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform,Phase):
         new_pcd = copy.deepcopy(pcd)\r
         new_pcd.SkuInfoList = {skuname:pcd.SkuInfoList[skuname]}\r
         new_pcd.isinit = 'INIT'\r
-        if new_pcd.DatumType in ['UINT8','UINT16','UINT32','UINT64']:\r
+        if new_pcd.DatumType in TAB_PCD_CLEAN_NUMERIC_TYPES:\r
             for skuobj in pcd.SkuInfoList.values():\r
                 if skuobj.DefaultValue:\r
                     defaultvalue = int(skuobj.DefaultValue,16) if skuobj.DefaultValue.upper().startswith("0X") else int(skuobj.DefaultValue,10)\r
@@ -1105,7 +1103,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
 \r
     Dict['PCD_INFO_FLAG'] = Platform.Platform.PcdInfoFlag\r
 \r
-    for DatumType in ['UINT64','UINT32','UINT16','UINT8','BOOLEAN', "VOID*"]:\r
+    for DatumType in TAB_PCD_NUMERIC_TYPES_VOID:\r
         Dict['VARDEF_CNAME_' + DatumType] = []\r
         Dict['VARDEF_GUID_' + DatumType]  = []\r
         Dict['VARDEF_SKUID_' + DatumType] = []\r
@@ -1177,7 +1175,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
     ReorderedDynPcdList = GetOrderedDynamicPcdList(DynamicPcdList, Platform.PcdTokenNumber)\r
     for item in ReorderedDynPcdList:\r
         if item.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
-            item.DatumType = "VOID*"\r
+            item.DatumType = TAB_VOID\r
     for Pcd in ReorderedDynPcdList:\r
         VoidStarTypeCurrSize = []\r
         i += 1\r
@@ -1202,7 +1200,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
         #\r
         TokenSpaceGuidStructure = Pcd.TokenSpaceGuidValue\r
         TokenSpaceGuid = GuidStructureStringToGuidValueName(TokenSpaceGuidStructure)\r
-        if Pcd.Type in gDynamicExPcd:\r
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:\r
             if TokenSpaceGuid not in GuidList:\r
                 GuidList += [TokenSpaceGuid]\r
                 Dict['GUID_STRUCTURE'].append(TokenSpaceGuidStructure)\r
@@ -1218,7 +1216,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
         VariableDbValueList = []\r
         Pcd.InitString = 'UNINIT'\r
 \r
-        if Pcd.DatumType == 'VOID*':\r
+        if Pcd.DatumType == TAB_VOID:\r
             if Pcd.Type not in ["DynamicVpd", "DynamicExVpd"]:\r
                 Pcd.TokenTypeList = ['PCD_TYPE_STRING']\r
             else:\r
@@ -1322,9 +1320,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
                     #\r
                     Dict['VARDEF_DB_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue)\r
                     \r
-                    if Pcd.DatumType == "UINT64":\r
+                    if Pcd.DatumType == TAB_UINT64:\r
                         Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "ULL")\r
-                    elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):\r
+                    elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8):\r
                         Dict['VARDEF_VALUE_'+Pcd.DatumType].append(Sku.HiiDefaultValue + "U")\r
                     elif Pcd.DatumType == "BOOLEAN":\r
                         if eval(Sku.HiiDefaultValue) in [1,0]:\r
@@ -1355,13 +1353,13 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
                 VpdHeadOffsetList.append(str(Sku.VpdOffset) + 'U')\r
                 VpdDbOffsetList.append(Sku.VpdOffset)\r
                 # Also add the VOID* string of VPD PCD to SizeTable \r
-                if Pcd.DatumType == 'VOID*':\r
+                if Pcd.DatumType == TAB_VOID:\r
                     NumberOfSizeItems += 1\r
                     # For VPD type of PCD, its current size is equal to its MAX size.\r
                     VoidStarTypeCurrSize = [str(Pcd.MaxDatumSize) + 'U']                 \r
                 continue\r
           \r
-            if Pcd.DatumType == 'VOID*':\r
+            if Pcd.DatumType == TAB_VOID:\r
                 Pcd.TokenTypeList += ['PCD_TYPE_STRING']\r
                 Pcd.InitString = 'INIT'\r
                 if Sku.HiiDefaultValue != '' and Sku.DefaultValue == '':\r
@@ -1420,9 +1418,9 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
                 # For UNIT64 type PCD's value, ULL should be append to avoid\r
                 # warning under linux building environment.\r
                 #\r
-                if Pcd.DatumType == "UINT64":\r
+                if Pcd.DatumType == TAB_UINT64:\r
                     ValueList.append(Sku.DefaultValue + "ULL")\r
-                elif Pcd.DatumType in ("UINT32", "UINT16", "UINT8"):\r
+                elif Pcd.DatumType in (TAB_UINT32, TAB_UINT16, TAB_UINT8):\r
                     ValueList.append(Sku.DefaultValue + "U")\r
                 elif Pcd.DatumType == "BOOLEAN":\r
                     if Sku.DefaultValue in ["1", "0"]:\r
@@ -1433,7 +1431,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
                 DbValueList.append(Sku.DefaultValue)\r
 \r
         Pcd.TokenTypeList = list(set(Pcd.TokenTypeList))\r
-        if Pcd.DatumType == 'VOID*':  \r
+        if Pcd.DatumType == TAB_VOID:\r
             Dict['SIZE_TABLE_CNAME'].append(CName)\r
             Dict['SIZE_TABLE_GUID'].append(TokenSpaceGuid)\r
             Dict['SIZE_TABLE_MAXIMUM_LENGTH'].append(str(Pcd.MaxDatumSize) + 'U')\r
@@ -1570,7 +1568,7 @@ def CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdList, Phase):
             Dict['VARDEF_HEADER'][GeneratedTokenNumber] = ''\r
        \r
         \r
-        if Pcd.Type in gDynamicExPcd:\r
+        if Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:\r
             \r
             if Phase == 'DXE':\r
                 GeneratedTokenNumber += NumberOfPeiLocalTokens\r