]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
BaseTools: replace 'UINT8','UINT16','UINT32','UINT64','VOID*' with shared constants.
[mirror_edk2.git] / BaseTools / Source / Python / PatchPcdValue / PatchPcdValue.py
index 0664d6a90fa14ca9a11dadfd644698aa55816467..cf2fc7c4f70a471210c031390f1325162fce4d57 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Patch value into the binary file.\r
 #\r
-# Copyright (c) 2010 - 2014, 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
@@ -25,6 +25,7 @@ from Common.BuildToolError import *
 import Common.EdkLogger as EdkLogger\r
 from Common.BuildVersion import gBUILD_VERSION\r
 import array\r
+from Common.DataType import *\r
 \r
 # Version and Copyright\r
 __version_number__ = ("0.10" + " " + gBUILD_VERSION)\r
@@ -62,15 +63,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
     ValueLength = 0\r
     if TypeName == 'BOOLEAN':\r
         ValueLength = 1\r
-    elif TypeName == 'UINT8':\r
+    elif TypeName == TAB_UINT8:\r
         ValueLength = 1\r
-    elif TypeName == 'UINT16':\r
+    elif TypeName == TAB_UINT16:\r
         ValueLength = 2\r
-    elif TypeName == 'UINT32':\r
+    elif TypeName == TAB_UINT32:\r
         ValueLength = 4\r
-    elif TypeName == 'UINT64':\r
+    elif TypeName == TAB_UINT64:\r
         ValueLength = 8\r
-    elif TypeName == 'VOID*':\r
+    elif TypeName == TAB_VOID:\r
         if MaxSize == 0:\r
             return OPTION_MISSING, "PcdMaxSize is not specified for VOID* type PCD."\r
         ValueLength = int(MaxSize)\r
@@ -119,7 +120,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
         # Set PCD value into binary data\r
         #\r
         ByteList[ValueOffset] = ValueNumber\r
-    elif TypeName in ['UINT8', 'UINT16', 'UINT32', 'UINT64']:\r
+    elif TypeName in TAB_PCD_CLEAN_NUMERIC_TYPES:\r
         #\r
         # Get PCD value for UINT* data type\r
         #\r
@@ -133,7 +134,7 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
         for Index in range(ValueLength):\r
             ByteList[ValueOffset + Index] = ValueNumber % 0x100\r
             ValueNumber = ValueNumber / 0x100\r
-    elif TypeName == 'VOID*':\r
+    elif TypeName == TAB_VOID:\r
         ValueString = SavedStr\r
         if ValueString.startswith('L"'):\r
             #\r
@@ -264,10 +265,10 @@ def Main():
         if CommandOptions.PcdOffset is None or CommandOptions.PcdValue is None or CommandOptions.PcdTypeName is None:\r
             EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdOffset or PcdValue of PcdTypeName is not specified.")\r
             return 1\r
-        if CommandOptions.PcdTypeName.upper() not in ["BOOLEAN", "UINT8", "UINT16", "UINT32", "UINT64", "VOID*"]:\r
+        if CommandOptions.PcdTypeName.upper() not in TAB_PCD_NUMERIC_TYPES_VOID:\r
             EdkLogger.error("PatchPcdValue", PARAMETER_INVALID, ExtraData="PCD type %s is not valid." % (CommandOptions.PcdTypeName))\r
             return 1\r
-        if CommandOptions.PcdTypeName.upper() == "VOID*" and CommandOptions.PcdMaxSize is None:\r
+        if CommandOptions.PcdTypeName.upper() == TAB_VOID and CommandOptions.PcdMaxSize is None:\r
             EdkLogger.error("PatchPcdValue", OPTION_MISSING, ExtraData="PcdMaxSize is not specified for VOID* type PCD.")\r
             return 1\r
         #\r