summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/AutoGen')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenPcdDb.py45
-rw-r--r--BaseTools/Source/Python/AutoGen/GenVar.py25
-rw-r--r--BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py26
3 files changed, 8 insertions, 88 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index aee722d146..d2d42fe9d0 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -21,7 +21,6 @@ from Common.VariableAttributes import VariableAttributes
import copy
from struct import unpack
from Common.DataType import *
-from GenVar import PackGUID
DATABASE_VERSION = 7
@@ -290,22 +289,7 @@ class DbItemList:
GuidString = GuidStructureStringToGuidString(GuidStructureValue)
return PackGUID(GuidString.split('-'))
- if self.ItemSize == 8:
- PackStr = "=Q"
- elif self.ItemSize == 4:
- PackStr = "=L"
- elif self.ItemSize == 2:
- PackStr = "=H"
- elif self.ItemSize == 1:
- PackStr = "=B"
- elif self.ItemSize == 0:
- PackStr = "=B"
- elif self.ItemSize == 16:
- # pack Guid
- PackStr = ''
- else:
- # should not reach here
- assert(False)
+ PackStr = PACK_CODE_BY_SIZE[self.ItemSize]
Buffer = ''
for Datas in self.RawDataList:
@@ -379,18 +363,7 @@ class DbComItemList (DbItemList):
return self.ListSize
def PackData(self):
- if self.ItemSize == 8:
- PackStr = "=Q"
- elif self.ItemSize == 4:
- PackStr = "=L"
- elif self.ItemSize == 2:
- PackStr = "=H"
- elif self.ItemSize == 1:
- PackStr = "=B"
- elif self.ItemSize == 0:
- PackStr = "=B"
- else:
- assert(False)
+ PackStr = PACK_CODE_BY_SIZE[self.ItemSize]
Buffer = ''
for DataList in self.RawDataList:
@@ -818,19 +791,7 @@ def BuildExDataBase(Dict):
# Construct the database buffer
Guid = "{0x3c7d193c, 0x682c, 0x4c14, 0xa6, 0x8f, 0x55, 0x2d, 0xea, 0x4f, 0x43, 0x7e}"
Guid = StringArrayToList(Guid)
- Buffer = pack('=LHHBBBBBBBB',
- Guid[0],
- Guid[1],
- Guid[2],
- Guid[3],
- Guid[4],
- Guid[5],
- Guid[6],
- Guid[7],
- Guid[8],
- Guid[9],
- Guid[10],
- )
+ Buffer = PackByteFormatGUID(Guid)
b = pack("=L", DATABASE_VERSION)
Buffer += b
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index e3595bb623..5660cf1348 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -26,22 +26,6 @@ var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragena
NvStorageHeaderSize = 28
VariableHeaderSize = 32
-def PackGUID(Guid):
- GuidBuffer = pack('=LHHBBBBBBBB',
- int(Guid[0], 16),
- int(Guid[1], 16),
- int(Guid[2], 16),
- int(Guid[3][-4:-2], 16),
- int(Guid[3][-2:], 16),
- int(Guid[4][-12:-10], 16),
- int(Guid[4][-10:-8], 16),
- int(Guid[4][-8:-6], 16),
- int(Guid[4][-6:-4], 16),
- int(Guid[4][-4:-2], 16),
- int(Guid[4][-2:], 16)
- )
- return GuidBuffer
-
class VariableMgr(object):
def __init__(self, DefaultStoreMap,SkuIdMap):
self.VarInfo = []
@@ -87,14 +71,7 @@ class VariableMgr(object):
data_type = item.data_type
value_list = item.default_value.strip("{").strip("}").split(",")
if data_type in DataType.TAB_PCD_NUMERIC_TYPES:
- if data_type == ["BOOLEAN", DataType.TAB_UINT8]:
- data_flag = "=B"
- elif data_type == DataType.TAB_UINT16:
- data_flag = "=H"
- elif data_type == DataType.TAB_UINT32:
- data_flag = "=L"
- elif data_type == DataType.TAB_UINT64:
- data_flag = "=Q"
+ data_flag = DataType.PACK_CODE_BY_SIZE[MAX_SIZE_TYPE[data_type]]
data = value_list[0]
value_list = []
for data_byte in pack(data_flag,int(data,16) if data.upper().startswith('0X') else int(data)):
diff --git a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
index 92c8fe2df9..64d4965e96 100644
--- a/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
+++ b/BaseTools/Source/Python/AutoGen/ValidCheckingInfoObject.py
@@ -35,12 +35,6 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
def dump(self, dest, Phase):
- FormatMap = {}
- FormatMap[1] = "=B"
- FormatMap[2] = "=H"
- FormatMap[4] = "=L"
- FormatMap[8] = "=Q"
-
if not os.path.isabs(dest):
return
if not os.path.exists(dest):
@@ -106,19 +100,7 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
realLength += 4
Guid = var_check_tab.Guid
- b = pack('=LHHBBBBBBBB',
- Guid[0],
- Guid[1],
- Guid[2],
- Guid[3],
- Guid[4],
- Guid[5],
- Guid[6],
- Guid[7],
- Guid[8],
- Guid[9],
- Guid[10],
- )
+ b = PackByteFormatGUID(Guid)
Buffer += b
realLength += 16
@@ -156,14 +138,14 @@ class VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER(object):
realLength += 1
for v_data in item.data:
if type(v_data) in (int, long):
- b = pack(FormatMap[item.StorageWidth], v_data)
+ b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data)
Buffer += b
realLength += item.StorageWidth
else:
- b = pack(FormatMap[item.StorageWidth], v_data[0])
+ b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data[0])
Buffer += b
realLength += item.StorageWidth
- b = pack(FormatMap[item.StorageWidth], v_data[1])
+ b = pack(PACK_CODE_BY_SIZE[item.StorageWidth], v_data[1])
Buffer += b
realLength += item.StorageWidth