]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools: merge towards minimum PCD MAX <something> methods
[mirror_edk2.git] / BaseTools / Source / Python / Common / VpdInfoFile.py
index b1baf06b9ccd40a4f86b14965b271df980afd7b3..b2ad5235bb3f290417a7dfb850b89c5bd15ae9b2 100644 (file)
@@ -6,7 +6,7 @@
 # is pointed by *_*_*_VPD_TOOL_GUID in conf/tools_def.txt \r
 #\r
 #\r
-# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -23,6 +23,7 @@ import subprocess
 import Common.GlobalData as GlobalData\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 from Common.Misc import SaveFileOnChange\r
+from Common.DataType import *\r
 \r
 FILE_COMMENT_TEMPLATE = \\r
 """\r
@@ -67,9 +68,7 @@ FILE_COMMENT_TEMPLATE = \
 #  <NList>           ::=  <HexNumber> ["," <HexNumber>]*\r
 #\r
 class VpdInfoFile:\r
-    \r
-    ## The mapping dictionary from datum type to size string.\r
-    _MAX_SIZE_TYPE = {"BOOLEAN":"1", "UINT8":"1", "UINT16":"2", "UINT32":"4", "UINT64":"8"}\r
+\r
     _rVpdPcdLine = None \r
     ## Constructor\r
     def __init__(self):\r
@@ -101,13 +100,13 @@ class VpdInfoFile:
                                 "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))\r
         elif Vpd.DatumType in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64"]: \r
             if Vpd.MaxDatumSize is None or Vpd.MaxDatumSize == "":\r
-                Vpd.MaxDatumSize = VpdInfoFile._MAX_SIZE_TYPE[Vpd.DatumType]\r
+                Vpd.MaxDatumSize = MAX_SIZE_TYPE[Vpd.DatumType]\r
         else:\r
             if Vpd.MaxDatumSize <= 0:\r
                 EdkLogger.error("VpdInfoFile", BuildToolError.PARAMETER_INVALID,\r
                                 "Invalid max datum size for VPD PCD %s.%s" % (Vpd.TokenSpaceGuidCName, Vpd.TokenCName))\r
             \r
-        if Vpd not in self._VpdArray.keys():\r
+        if Vpd not in self._VpdArray:\r
             #\r
             # If there is no Vpd instance in dict, that imply this offset for a given SKU is a new one \r
             #\r
@@ -180,12 +179,12 @@ class VpdInfoFile:
             if (TokenSpaceName, PcdTokenName) not in self._VpdInfo:\r
                 self._VpdInfo[(TokenSpaceName, PcdTokenName)] = []\r
             self._VpdInfo[(TokenSpaceName, PcdTokenName)].append((SkuId,Offset, Value))\r
-            for VpdObject in self._VpdArray.keys():\r
+            for VpdObject in self._VpdArray:\r
                 VpdObjectTokenCName = VpdObject.TokenCName\r
                 for PcdItem in GlobalData.MixedPcd:\r
                     if (VpdObject.TokenCName, VpdObject.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
                         VpdObjectTokenCName = PcdItem[0]\r
-                for sku in VpdObject.SkuInfoList.keys():\r
+                for sku in VpdObject.SkuInfoList:\r
                     if VpdObject.TokenSpaceGuidCName == TokenSpaceName and VpdObjectTokenCName == PcdTokenName.strip() and sku == SkuId:\r
                         if self._VpdArray[VpdObject][sku] == "*":\r
                             if Offset == "*":\r