diff options
author | Carsey, Jaben <jaben.carsey@intel.com> | 2018-04-28 06:32:48 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-05-04 13:07:34 +0800 |
commit | d0a0c52c221e5dcf82f24d4346c1cf52109d6dfb (patch) | |
tree | 093b255c1d0235ab8cbbea57be4ccbd0a37fecff /BaseTools/Source/Python/Common/Misc.py | |
parent | 31ff1c443e25d6bff758bdcd9a248a907cff651b (diff) | |
download | edk2-d0a0c52c221e5dcf82f24d4346c1cf52109d6dfb.tar.gz edk2-d0a0c52c221e5dcf82f24d4346c1cf52109d6dfb.tar.bz2 edk2-d0a0c52c221e5dcf82f24d4346c1cf52109d6dfb.zip |
BaseTools: standardize GUID and pack size
currently GUID packing and pack size determination is spread
throughout the code. This introduces a shared function and dict and
routes all code paths through them.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Common/Misc.py')
-rw-r--r-- | BaseTools/Source/Python/Common/Misc.py | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 3d205197ab..fe5a0b8101 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -2087,20 +2087,7 @@ class SkuClass(): # Pack a registry format GUID
#
def PackRegistryFormatGuid(Guid):
- Guid = Guid.split('-')
- return 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 PackGUID(Guid.split('-'))
## Get the integer value from string like "14U" or integer like 2
#
@@ -2126,6 +2113,42 @@ def GetIntegerValue(Input): else:
return int(String)
+#
+# Pack a GUID (registry format) list into a buffer and return it
+#
+def PackGUID(Guid):
+ return pack(PACK_PATTERN_GUID,
+ 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)
+ )
+
+#
+# Pack a GUID (byte) list into a buffer and return it
+#
+def PackByteFormatGUID(Guid):
+ return pack(PACK_PATTERN_GUID,
+ Guid[0],
+ Guid[1],
+ Guid[2],
+ Guid[3],
+ Guid[4],
+ Guid[5],
+ Guid[6],
+ Guid[7],
+ Guid[8],
+ Guid[9],
+ Guid[10],
+ )
+
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
|