summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/FirmwareStorageFormat
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2024-06-04 06:43:08 +0300
committerkx <kx@radix.pro>2024-06-04 06:43:08 +0300
commit7e2ccccace24636f29ddc210b94606abd4c7e42b (patch)
tree545d43ea12671048956cafeb12303e84d601e571 /BaseTools/Source/Python/FirmwareStorageFormat
parent27b044605cd5f6b33a3d231576003850b3fe305b (diff)
downloadedk2-trunk.tar.xz
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'BaseTools/Source/Python/FirmwareStorageFormat')
-rw-r--r--BaseTools/Source/Python/FirmwareStorageFormat/Common.py170
-rw-r--r--BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py132
-rw-r--r--BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py224
-rw-r--r--BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py220
-rw-r--r--BaseTools/Source/Python/FirmwareStorageFormat/UPLHeader.py488
5 files changed, 617 insertions, 617 deletions
diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/Common.py b/BaseTools/Source/Python/FirmwareStorageFormat/Common.py
index 5082268a00..5c11648def 100644
--- a/BaseTools/Source/Python/FirmwareStorageFormat/Common.py
+++ b/BaseTools/Source/Python/FirmwareStorageFormat/Common.py
@@ -1,85 +1,85 @@
-## @file
-# This file is used to define the common C struct and functions.
-#
-# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-from ctypes import *
-import uuid
-
-# ZeroGuid = uuid.UUID('{00000000-0000-0000-0000-000000000000}')
-# EFI_FIRMWARE_FILE_SYSTEM2_GUID = uuid.UUID('{8C8CE578-8A3D-4f1c-9935-896185C32DD3}')
-# EFI_FIRMWARE_FILE_SYSTEM3_GUID = uuid.UUID('{5473C07A-3DCB-4dca-BD6F-1E9689E7349A}')
-# EFI_FFS_VOLUME_TOP_FILE_GUID = uuid.UUID('{1BA0062E-C779-4582-8566-336AE8F78F09}')
-
-EFI_FIRMWARE_FILE_SYSTEM2_GUID = uuid.UUID("8c8ce578-8a3d-4f1c-9935-896185c32dd3")
-EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE = b'x\xe5\x8c\x8c=\x8a\x1cO\x995\x89a\x85\xc3-\xd3'
-# EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE = EFI_FIRMWARE_FILE_SYSTEM2_GUID.bytes
-EFI_FIRMWARE_FILE_SYSTEM3_GUID = uuid.UUID("5473C07A-3DCB-4dca-BD6F-1E9689E7349A")
-# EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE = b'x\xe5\x8c\x8c=\x8a\x1cO\x995\x89a\x85\xc3-\xd3'
-EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE = b'z\xc0sT\xcb=\xcaM\xbdo\x1e\x96\x89\xe74\x9a'
-EFI_SYSTEM_NVDATA_FV_GUID = uuid.UUID("fff12b8d-7696-4c8b-a985-2747075b4f50")
-EFI_SYSTEM_NVDATA_FV_GUID_BYTE = b"\x8d+\xf1\xff\x96v\x8bL\xa9\x85'G\x07[OP"
-EFI_FFS_VOLUME_TOP_FILE_GUID = uuid.UUID("1ba0062e-c779-4582-8566-336ae8f78f09")
-EFI_FFS_VOLUME_TOP_FILE_GUID_BYTE = b'.\x06\xa0\x1by\xc7\x82E\x85f3j\xe8\xf7\x8f\t'
-ZEROVECTOR_BYTE = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
-PADVECTOR = uuid.UUID("ffffffff-ffff-ffff-ffff-ffffffffffff")
-FVH_SIGNATURE = b'_FVH'
-
-#Alignment
-SECTION_COMMON_ALIGNMENT = 4
-FFS_COMMON_ALIGNMENT = 8
-
-class GUID(Structure):
- _pack_ = 1
- _fields_ = [
- ('Guid1', c_uint32),
- ('Guid2', c_uint16),
- ('Guid3', c_uint16),
- ('Guid4', ARRAY(c_uint8, 8)),
- ]
-
- def from_list(self, listformat: list) -> None:
- self.Guid1 = listformat[0]
- self.Guid2 = listformat[1]
- self.Guid3 = listformat[2]
- for i in range(8):
- self.Guid4[i] = listformat[i+3]
-
- def __cmp__(self, otherguid) -> bool:
- if not isinstance(otherguid, GUID):
- return 'Input is not the GUID instance!'
- rt = False
- if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and self.Guid3 == otherguid.Guid3:
- rt = True
- for i in range(8):
- rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
- return rt
-
-def ModifyGuidFormat(target_guid: str) -> GUID:
- target_guid = target_guid.replace('-', '')
- target_list = []
- start = [0,8,12,16,18,20,22,24,26,28,30]
- end = [8,12,16,18,20,22,24,26,28,30,32]
- num = len(start)
- for pos in range(num):
- new_value = int(target_guid[start[pos]:end[pos]], 16)
- target_list.append(new_value)
- new_format = GUID()
- new_format.from_list(target_list)
- return new_format
-
-
-# Get data from ctypes to bytes.
-def struct2stream(s) -> bytes:
- length = sizeof(s)
- p = cast(pointer(s), POINTER(c_char * length))
- return p.contents.raw
-
-
-
-def GetPadSize(Size: int, alignment: int) -> int:
- if Size % alignment == 0:
- return 0
- Pad_Size = alignment - Size % alignment
- return Pad_Size
+## @file
+# This file is used to define the common C struct and functions.
+#
+# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+from ctypes import *
+import uuid
+
+# ZeroGuid = uuid.UUID('{00000000-0000-0000-0000-000000000000}')
+# EFI_FIRMWARE_FILE_SYSTEM2_GUID = uuid.UUID('{8C8CE578-8A3D-4f1c-9935-896185C32DD3}')
+# EFI_FIRMWARE_FILE_SYSTEM3_GUID = uuid.UUID('{5473C07A-3DCB-4dca-BD6F-1E9689E7349A}')
+# EFI_FFS_VOLUME_TOP_FILE_GUID = uuid.UUID('{1BA0062E-C779-4582-8566-336AE8F78F09}')
+
+EFI_FIRMWARE_FILE_SYSTEM2_GUID = uuid.UUID("8c8ce578-8a3d-4f1c-9935-896185c32dd3")
+EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE = b'x\xe5\x8c\x8c=\x8a\x1cO\x995\x89a\x85\xc3-\xd3'
+# EFI_FIRMWARE_FILE_SYSTEM2_GUID_BYTE = EFI_FIRMWARE_FILE_SYSTEM2_GUID.bytes
+EFI_FIRMWARE_FILE_SYSTEM3_GUID = uuid.UUID("5473C07A-3DCB-4dca-BD6F-1E9689E7349A")
+# EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE = b'x\xe5\x8c\x8c=\x8a\x1cO\x995\x89a\x85\xc3-\xd3'
+EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE = b'z\xc0sT\xcb=\xcaM\xbdo\x1e\x96\x89\xe74\x9a'
+EFI_SYSTEM_NVDATA_FV_GUID = uuid.UUID("fff12b8d-7696-4c8b-a985-2747075b4f50")
+EFI_SYSTEM_NVDATA_FV_GUID_BYTE = b"\x8d+\xf1\xff\x96v\x8bL\xa9\x85'G\x07[OP"
+EFI_FFS_VOLUME_TOP_FILE_GUID = uuid.UUID("1ba0062e-c779-4582-8566-336ae8f78f09")
+EFI_FFS_VOLUME_TOP_FILE_GUID_BYTE = b'.\x06\xa0\x1by\xc7\x82E\x85f3j\xe8\xf7\x8f\t'
+ZEROVECTOR_BYTE = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+PADVECTOR = uuid.UUID("ffffffff-ffff-ffff-ffff-ffffffffffff")
+FVH_SIGNATURE = b'_FVH'
+
+#Alignment
+SECTION_COMMON_ALIGNMENT = 4
+FFS_COMMON_ALIGNMENT = 8
+
+class GUID(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Guid1', c_uint32),
+ ('Guid2', c_uint16),
+ ('Guid3', c_uint16),
+ ('Guid4', ARRAY(c_uint8, 8)),
+ ]
+
+ def from_list(self, listformat: list) -> None:
+ self.Guid1 = listformat[0]
+ self.Guid2 = listformat[1]
+ self.Guid3 = listformat[2]
+ for i in range(8):
+ self.Guid4[i] = listformat[i+3]
+
+ def __cmp__(self, otherguid) -> bool:
+ if not isinstance(otherguid, GUID):
+ return 'Input is not the GUID instance!'
+ rt = False
+ if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and self.Guid3 == otherguid.Guid3:
+ rt = True
+ for i in range(8):
+ rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
+ return rt
+
+def ModifyGuidFormat(target_guid: str) -> GUID:
+ target_guid = target_guid.replace('-', '')
+ target_list = []
+ start = [0,8,12,16,18,20,22,24,26,28,30]
+ end = [8,12,16,18,20,22,24,26,28,30,32]
+ num = len(start)
+ for pos in range(num):
+ new_value = int(target_guid[start[pos]:end[pos]], 16)
+ target_list.append(new_value)
+ new_format = GUID()
+ new_format.from_list(target_list)
+ return new_format
+
+
+# Get data from ctypes to bytes.
+def struct2stream(s) -> bytes:
+ length = sizeof(s)
+ p = cast(pointer(s), POINTER(c_char * length))
+ return p.contents.raw
+
+
+
+def GetPadSize(Size: int, alignment: int) -> int:
+ if Size % alignment == 0:
+ return 0
+ Pad_Size = alignment - Size % alignment
+ return Pad_Size
diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py b/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py
index e9c619d224..b53b5d5008 100644
--- a/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py
+++ b/BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py
@@ -1,66 +1,66 @@
-## @file
-# This file is used to define the Ffs Header C Struct.
-#
-# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-from struct import *
-from ctypes import *
-from FirmwareStorageFormat.Common import *
-
-EFI_FFS_FILE_HEADER_LEN = 24
-EFI_FFS_FILE_HEADER2_LEN = 32
-
-class CHECK_SUM(Structure):
- _pack_ = 1
- _fields_ = [
- ('Header', c_uint8),
- ('File', c_uint8),
- ]
-
-class EFI_FFS_INTEGRITY_CHECK(Union):
- _pack_ = 1
- _fields_ = [
- ('Checksum', CHECK_SUM),
- ('Checksum16', c_uint16),
- ]
-
-
-class EFI_FFS_FILE_HEADER(Structure):
- _pack_ = 1
- _fields_ = [
- ('Name', GUID),
- ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),
- ('Type', c_uint8),
- ('Attributes', c_uint8),
- ('Size', ARRAY(c_uint8, 3)),
- ('State', c_uint8),
- ]
-
- @property
- def FFS_FILE_SIZE(self) -> int:
- return self.Size[0] | self.Size[1] << 8 | self.Size[2] << 16
-
- @property
- def HeaderLength(self) -> int:
- return 24
-
-class EFI_FFS_FILE_HEADER2(Structure):
- _pack_ = 1
- _fields_ = [
- ('Name', GUID),
- ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),
- ('Type', c_uint8),
- ('Attributes', c_uint8),
- ('Size', ARRAY(c_uint8, 3)),
- ('State', c_uint8),
- ('ExtendedSize', c_uint64),
- ]
-
- @property
- def FFS_FILE_SIZE(self) -> int:
- return self.ExtendedSize
-
- @property
- def HeaderLength(self) -> int:
- return 32
+## @file
+# This file is used to define the Ffs Header C Struct.
+#
+# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+from struct import *
+from ctypes import *
+from FirmwareStorageFormat.Common import *
+
+EFI_FFS_FILE_HEADER_LEN = 24
+EFI_FFS_FILE_HEADER2_LEN = 32
+
+class CHECK_SUM(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Header', c_uint8),
+ ('File', c_uint8),
+ ]
+
+class EFI_FFS_INTEGRITY_CHECK(Union):
+ _pack_ = 1
+ _fields_ = [
+ ('Checksum', CHECK_SUM),
+ ('Checksum16', c_uint16),
+ ]
+
+
+class EFI_FFS_FILE_HEADER(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Name', GUID),
+ ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),
+ ('Type', c_uint8),
+ ('Attributes', c_uint8),
+ ('Size', ARRAY(c_uint8, 3)),
+ ('State', c_uint8),
+ ]
+
+ @property
+ def FFS_FILE_SIZE(self) -> int:
+ return self.Size[0] | self.Size[1] << 8 | self.Size[2] << 16
+
+ @property
+ def HeaderLength(self) -> int:
+ return 24
+
+class EFI_FFS_FILE_HEADER2(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Name', GUID),
+ ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),
+ ('Type', c_uint8),
+ ('Attributes', c_uint8),
+ ('Size', ARRAY(c_uint8, 3)),
+ ('State', c_uint8),
+ ('ExtendedSize', c_uint64),
+ ]
+
+ @property
+ def FFS_FILE_SIZE(self) -> int:
+ return self.ExtendedSize
+
+ @property
+ def HeaderLength(self) -> int:
+ return 32
diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py b/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py
index 078beda9e5..b084a3f0d2 100644
--- a/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py
+++ b/BaseTools/Source/Python/FirmwareStorageFormat/FvHeader.py
@@ -1,112 +1,112 @@
-## @file
-# This file is used to define the FV Header C Struct.
-#
-# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-from ast import Str
-from struct import *
-from ctypes import *
-from FirmwareStorageFormat.Common import *
-
-class EFI_FV_BLOCK_MAP_ENTRY(Structure):
- _pack_ = 1
- _fields_ = [
- ('NumBlocks', c_uint32),
- ('Length', c_uint32),
- ]
-
-
-class EFI_FIRMWARE_VOLUME_HEADER(Structure):
- _fields_ = [
- ('ZeroVector', ARRAY(c_uint8, 16)),
- ('FileSystemGuid', GUID),
- ('FvLength', c_uint64),
- ('Signature', c_uint32),
- ('Attributes', c_uint32),
- ('HeaderLength', c_uint16),
- ('Checksum', c_uint16),
- ('ExtHeaderOffset', c_uint16),
- ('Reserved', c_uint8),
- ('Revision', c_uint8),
- ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, 1)),
- ]
-
-def Refine_FV_Header(nums):
- class EFI_FIRMWARE_VOLUME_HEADER(Structure):
- _fields_ = [
- ('ZeroVector', ARRAY(c_uint8, 16)),
- ('FileSystemGuid', GUID),
- ('FvLength', c_uint64),
- ('Signature', c_uint32),
- ('Attributes', c_uint32),
- ('HeaderLength', c_uint16),
- ('Checksum', c_uint16),
- ('ExtHeaderOffset', c_uint16),
- ('Reserved', c_uint8),
- ('Revision', c_uint8),
- ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, nums)),
- ]
- return EFI_FIRMWARE_VOLUME_HEADER
-
-class EFI_FIRMWARE_VOLUME_EXT_HEADER(Structure):
- _fields_ = [
- ('FvName', GUID),
- ('ExtHeaderSize', c_uint32)
- ]
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY(Structure):
- _fields_ = [
- ('ExtEntrySize', c_uint16),
- ('ExtEntryType', c_uint16)
- ]
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE_0(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('TypeMask', c_uint32)
- ]
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('TypeMask', c_uint32),
- ('Types', ARRAY(GUID, 1))
- ]
-
-def Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE:
- class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('TypeMask', c_uint32),
- ('Types', ARRAY(GUID, nums))
- ]
- return EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure)
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE_0(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('FormatType', GUID)
- ]
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('FormatType', GUID),
- ('Data', ARRAY(c_uint8, 1))
- ]
-
-def Refine_FV_EXT_ENTRY_GUID_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE:
- class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('FormatType', GUID),
- ('Data', ARRAY(c_uint8, nums))
- ]
- return EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure)
-
-class EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE(Structure):
- _fields_ = [
- ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
- ('UsedSize', c_uint32)
- ]
+## @file
+# This file is used to define the FV Header C Struct.
+#
+# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+from ast import Str
+from struct import *
+from ctypes import *
+from FirmwareStorageFormat.Common import *
+
+class EFI_FV_BLOCK_MAP_ENTRY(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('NumBlocks', c_uint32),
+ ('Length', c_uint32),
+ ]
+
+
+class EFI_FIRMWARE_VOLUME_HEADER(Structure):
+ _fields_ = [
+ ('ZeroVector', ARRAY(c_uint8, 16)),
+ ('FileSystemGuid', GUID),
+ ('FvLength', c_uint64),
+ ('Signature', c_uint32),
+ ('Attributes', c_uint32),
+ ('HeaderLength', c_uint16),
+ ('Checksum', c_uint16),
+ ('ExtHeaderOffset', c_uint16),
+ ('Reserved', c_uint8),
+ ('Revision', c_uint8),
+ ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, 1)),
+ ]
+
+def Refine_FV_Header(nums):
+ class EFI_FIRMWARE_VOLUME_HEADER(Structure):
+ _fields_ = [
+ ('ZeroVector', ARRAY(c_uint8, 16)),
+ ('FileSystemGuid', GUID),
+ ('FvLength', c_uint64),
+ ('Signature', c_uint32),
+ ('Attributes', c_uint32),
+ ('HeaderLength', c_uint16),
+ ('Checksum', c_uint16),
+ ('ExtHeaderOffset', c_uint16),
+ ('Reserved', c_uint8),
+ ('Revision', c_uint8),
+ ('BlockMap', ARRAY(EFI_FV_BLOCK_MAP_ENTRY, nums)),
+ ]
+ return EFI_FIRMWARE_VOLUME_HEADER
+
+class EFI_FIRMWARE_VOLUME_EXT_HEADER(Structure):
+ _fields_ = [
+ ('FvName', GUID),
+ ('ExtHeaderSize', c_uint32)
+ ]
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY(Structure):
+ _fields_ = [
+ ('ExtEntrySize', c_uint16),
+ ('ExtEntryType', c_uint16)
+ ]
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE_0(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('TypeMask', c_uint32)
+ ]
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('TypeMask', c_uint32),
+ ('Types', ARRAY(GUID, 1))
+ ]
+
+def Refine_FV_EXT_ENTRY_OEM_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE:
+ class EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('TypeMask', c_uint32),
+ ('Types', ARRAY(GUID, nums))
+ ]
+ return EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE(Structure)
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE_0(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('FormatType', GUID)
+ ]
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('FormatType', GUID),
+ ('Data', ARRAY(c_uint8, 1))
+ ]
+
+def Refine_FV_EXT_ENTRY_GUID_TYPE_Header(nums: int) -> EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE:
+ class EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('FormatType', GUID),
+ ('Data', ARRAY(c_uint8, nums))
+ ]
+ return EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE(Structure)
+
+class EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE(Structure):
+ _fields_ = [
+ ('Hdr', EFI_FIRMWARE_VOLUME_EXT_ENTRY),
+ ('UsedSize', c_uint32)
+ ]
diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py b/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py
index ee6a63679d..155a4cd1db 100644
--- a/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py
+++ b/BaseTools/Source/Python/FirmwareStorageFormat/SectionHeader.py
@@ -1,110 +1,110 @@
-## @file
-# This file is used to define the Section Header C Struct.
-#
-# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-from struct import *
-from ctypes import *
-from FirmwareStorageFormat.Common import *
-
-EFI_COMMON_SECTION_HEADER_LEN = 4
-EFI_COMMON_SECTION_HEADER2_LEN = 8
-
-class EFI_COMMON_SECTION_HEADER(Structure):
- _pack_ = 1
- _fields_ = [
- ('Size', ARRAY(c_uint8, 3)),
- ('Type', c_uint8),
- ]
-
- @property
- def SECTION_SIZE(self) -> int:
- return self.Size[0] | self.Size[1] << 8 | self.Size[2] << 16
-
- def Common_Header_Size(self) -> int:
- return 4
-
-class EFI_COMMON_SECTION_HEADER2(Structure):
- _pack_ = 1
- _fields_ = [
- ('Size', ARRAY(c_uint8, 3)),
- ('Type', c_uint8),
- ('ExtendedSize', c_uint32),
- ]
-
- @property
- def SECTION_SIZE(self) -> int:
- return self.ExtendedSize
-
- def Common_Header_Size(self) -> int:
- return 8
-
-class EFI_COMPRESSION_SECTION(Structure):
- _pack_ = 1
- _fields_ = [
- ('UncompressedLength', c_uint32),
- ('CompressionType', c_uint8),
- ]
-
- def ExtHeaderSize(self) -> int:
- return 5
-
-class EFI_FREEFORM_SUBTYPE_GUID_SECTION(Structure):
- _pack_ = 1
- _fields_ = [
- ('SubTypeGuid', GUID),
- ]
-
- def ExtHeaderSize(self) -> int:
- return 16
-
-class EFI_GUID_DEFINED_SECTION(Structure):
- _pack_ = 1
- _fields_ = [
- ('SectionDefinitionGuid', GUID),
- ('DataOffset', c_uint16),
- ('Attributes', c_uint16),
- ]
-
- def ExtHeaderSize(self) -> int:
- return 20
-
-def Get_USER_INTERFACE_Header(nums: int):
- class EFI_SECTION_USER_INTERFACE(Structure):
- _pack_ = 1
- _fields_ = [
- ('FileNameString', ARRAY(c_uint16, nums)),
- ]
-
- def ExtHeaderSize(self) -> int:
- return 2 * nums
-
- def GetUiString(self) -> str:
- UiString = ''
- for i in range(nums):
- if self.FileNameString[i]:
- UiString += chr(self.FileNameString[i])
- return UiString
-
- return EFI_SECTION_USER_INTERFACE
-
-def Get_VERSION_Header(nums: int):
- class EFI_SECTION_VERSION(Structure):
- _pack_ = 1
- _fields_ = [
- ('BuildNumber', c_uint16),
- ('VersionString', ARRAY(c_uint16, nums)),
- ]
-
- def ExtHeaderSize(self) -> int:
- return 2 * (nums+1)
-
- def GetVersionString(self) -> str:
- VersionString = ''
- for i in range(nums):
- if self.VersionString[i]:
- VersionString += chr(self.VersionString[i])
- return VersionString
-
- return EFI_SECTION_VERSION
+## @file
+# This file is used to define the Section Header C Struct.
+#
+# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+from struct import *
+from ctypes import *
+from FirmwareStorageFormat.Common import *
+
+EFI_COMMON_SECTION_HEADER_LEN = 4
+EFI_COMMON_SECTION_HEADER2_LEN = 8
+
+class EFI_COMMON_SECTION_HEADER(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Size', ARRAY(c_uint8, 3)),
+ ('Type', c_uint8),
+ ]
+
+ @property
+ def SECTION_SIZE(self) -> int:
+ return self.Size[0] | self.Size[1] << 8 | self.Size[2] << 16
+
+ def Common_Header_Size(self) -> int:
+ return 4
+
+class EFI_COMMON_SECTION_HEADER2(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Size', ARRAY(c_uint8, 3)),
+ ('Type', c_uint8),
+ ('ExtendedSize', c_uint32),
+ ]
+
+ @property
+ def SECTION_SIZE(self) -> int:
+ return self.ExtendedSize
+
+ def Common_Header_Size(self) -> int:
+ return 8
+
+class EFI_COMPRESSION_SECTION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('UncompressedLength', c_uint32),
+ ('CompressionType', c_uint8),
+ ]
+
+ def ExtHeaderSize(self) -> int:
+ return 5
+
+class EFI_FREEFORM_SUBTYPE_GUID_SECTION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('SubTypeGuid', GUID),
+ ]
+
+ def ExtHeaderSize(self) -> int:
+ return 16
+
+class EFI_GUID_DEFINED_SECTION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('SectionDefinitionGuid', GUID),
+ ('DataOffset', c_uint16),
+ ('Attributes', c_uint16),
+ ]
+
+ def ExtHeaderSize(self) -> int:
+ return 20
+
+def Get_USER_INTERFACE_Header(nums: int):
+ class EFI_SECTION_USER_INTERFACE(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('FileNameString', ARRAY(c_uint16, nums)),
+ ]
+
+ def ExtHeaderSize(self) -> int:
+ return 2 * nums
+
+ def GetUiString(self) -> str:
+ UiString = ''
+ for i in range(nums):
+ if self.FileNameString[i]:
+ UiString += chr(self.FileNameString[i])
+ return UiString
+
+ return EFI_SECTION_USER_INTERFACE
+
+def Get_VERSION_Header(nums: int):
+ class EFI_SECTION_VERSION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('BuildNumber', c_uint16),
+ ('VersionString', ARRAY(c_uint16, nums)),
+ ]
+
+ def ExtHeaderSize(self) -> int:
+ return 2 * (nums+1)
+
+ def GetVersionString(self) -> str:
+ VersionString = ''
+ for i in range(nums):
+ if self.VersionString[i]:
+ VersionString += chr(self.VersionString[i])
+ return VersionString
+
+ return EFI_SECTION_VERSION
diff --git a/BaseTools/Source/Python/FirmwareStorageFormat/UPLHeader.py b/BaseTools/Source/Python/FirmwareStorageFormat/UPLHeader.py
index fd4da939f9..6a614b0aa2 100644
--- a/BaseTools/Source/Python/FirmwareStorageFormat/UPLHeader.py
+++ b/BaseTools/Source/Python/FirmwareStorageFormat/UPLHeader.py
@@ -1,244 +1,244 @@
-## @file
-# This file is used to define the UPL Header C Struct.
-#
-# Copyright (c) 2023-, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-from struct import *
-from ctypes import *
-from FirmwareStorageFormat.Common import *
-
-EFI_COMMON_SECTION_HEADER_LEN = 4
-EFI_COMMON_SECTION_HEADER2_LEN = 8
-
-# ELF header.
-class ELF_HEADER32(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Identification', ARRAY(c_char, 16)), # /* File identification. */
- ('ELF_Type', c_uint16), # Elf32_Half /* File type. */
- ('ELF_Machine', c_uint16), # Elf32_Half /* Machine architecture. */
- ('ELF_Version', c_uint32), # Elf32_Word /* ELF format version. */
- ('ELF_Entry', c_uint32), # Elf32_Addr /* Entry point. */
- ('ELF_PHOff', c_uint32), # Elf32_Off /* Program header file offset. */
- ('ELF_SHOff', c_uint32), # Elf32_Off /* Section header file offset. */
- ('ELF_Flags', c_uint32), # Elf32_Word /* Architecture-specific flags. */
- ('ELF_EFSize', c_uint16), # Elf32_Half /* Size of ELF header in bytes. */
- ('ELF_PHEntSize', c_uint16), # Elf32_Half /* Size of program header entry. */
- ('ELF_PHNum', c_uint16), # Elf32_Half /* Number of program header entries. */
- ('ELF_SHEntSize', c_uint16), # Elf32_Half /* Size of section header entry. */
- ('ELF_SHNum', c_uint16), # Elf32_Half /* Number of section header entries. */
- ('ELF_SNStr', c_uint16), # Elf32_Half /* Section name strings section. */
- ]
-
-class ELF_HEADER64(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Identification', ARRAY(c_char, 16)), # /* File identification. */
- ('ELF_Type', c_uint16), # Elf64_Half /* File type. */
- ('ELF_Machine', c_uint16), # Elf64_Half /* Machine architecture. */
- ('ELF_Version', c_uint32), # Elf64_Word /* ELF format version. */
- ('ELF_Entry', c_uint64), # Elf64_Addr /* Entry point. */
- ('ELF_PHOff', c_uint64), # Elf64_Off /* Program header file offset. */
- ('ELF_SHOff', c_uint64), # Elf64_Off /* Section header file offset. */
- ('ELF_Flags', c_uint32), # Elf64_Word /* Architecture-specific flags. */
- ('ELF_EFSize', c_uint16), # Elf64_Half /* Size of ELF header in bytes. */
- ('ELF_PHEntSize', c_uint16), # Elf64_Half /* Size of program header entry. */
- ('ELF_PHNum', c_uint16), # Elf64_Half /* Number of program header entries. */
- ('ELF_SHEntSize', c_uint16), # Elf64_Half /* Size of section header entry. */
- ('ELF_SHNum', c_uint16), # Elf64_Half /* Number of section header entries. */
- ('ELF_SNStr', c_uint16), # Elf64_Half /* Section name strings section. */
- ]
-
-# Section header.
-class ELF_SECTION_HEADER32(Structure):
- _pack_ = 1
- _fields_ = [
- ('SH_Name', c_uint32), # Elf32_Word /* Section name (index into the section header string table). */
- ('SH_Type', c_uint32), # Elf32_Word /* Section type. */
- ('SH_Flags', c_uint32), # Elf32_Word /* Section flags. */
- ('SH_ADDR', c_uint32), # Elf32_Addr /* Address in memory image. */
- ('SH_Offset', c_uint32), # Elf32_Off /* Offset in file. */
- ('SH_Size', c_uint32), # Elf32_Word /* Size in bytes. */
- ('SH_Link', c_uint32), # Elf32_Word /* Index of a related section. */
- ('SH_Info', c_uint32), # Elf32_Word /* Depends on section type. */
- ('SH_AddrAlign', c_uint32), # Elf32_Word /* Alignment in bytes. */
- ('SH_EntSize', c_uint32), # Elf32_Word /* Size of each entry in section. */
- ]
-
-class ELF_SECTION_HEADER64(Structure):
- _pack_ = 1
- _fields_ = [
- ('SH_Name', c_uint32), # Elf32_Word /* Section name (index into the section header string table). */
- ('SH_Type', c_uint32), # Elf32_Word /* Section type. */
- ('SH_Flags', c_uint64), # Elf32_XWord /* Section flags. */
- ('SH_ADDR', c_uint64), # Elf32_Addr /* Address in memory image. */
- ('SH_Offset', c_uint64), # Elf32_Off /* Offset in file. */
- ('SH_Size', c_uint64), # Elf32_XWord /* Size in bytes. */
- ('SH_Link', c_uint32), # Elf32_Word /* Index of a related section. */
- ('SH_Info', c_uint32), # Elf32_Word /* Depends on section type. */
- ('SH_AddrAlign', c_uint64), # Elf32_XWord /* Alignment in bytes. */
- ('SH_EntSize', c_uint64), # Elf32_XWord /* Size of each entry in section. */
- ]
-
-# Program header.
-class ELF_PROGRAM_HEADER32(Structure):
- _pack_ = 1
- _fields_ = [
- ('PH_Type', c_uint32), # Elf32_Word /* Entry type. */
- ('PH_Offset', c_uint32), # Elf32_Off /* File offset of contents. */
- ('PH_VirAddr', c_uint32), # Elf32_Addr /* Virtual address in memory image. */
- ('PH_PhyAddr', c_uint32), # Elf32_Addr /* Physical address (not used). */
- ('PH_FileSize', c_uint32), # Elf32_Word /* Size of contents in file. */
- ('PH_MemorySize', c_uint32), # Elf32_Word /* Size of contents in memory. */
- ('PH_Flags', c_uint32), # Elf32_Word /* Access permission flags. */
- ('PH_Align', c_uint32), # Elf32_Word /* Alignment in memory and file. */
- ]
-
-class ELF_PROGRAM_HEADER64(Structure):
- _pack_ = 1
- _fields_ = [
- ('PH_Type', c_uint32), # Elf32_Word /* Entry type. */
- ('PH_Flags', c_uint32), # Elf32_Word /* Access permission flags. */
- ('PH_Offset', c_uint64), # Elf32_Off /* File offset of contents. */
- ('PH_VirAddr', c_uint64), # Elf32_Addr /* Virtual address in memory image. */
- ('PH_PhyAddr', c_uint64), # Elf32_Addr /* Physical address (not used). */
- ('PH_FileSize', c_uint64), # Elf32_XWord /* Size of contents in file. */
- ('PH_MemorySize', c_uint64), # Elf32_XWord /* Size of contents in memory. */
- ('PH_Align', c_uint64), # Elf32_XWord /* Alignment in memory and file. */
- ]
-
-# Dynamic union.
-class ELF_DYNAMIC_UNION(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Dynamic_Val', c_uint32), # Elf32_Word /* Integer value. */
- ('ELF_Dynamic_Ptr', c_uint32), # Elf32_Addr /* Address value. */
- ]
-
-
-# Dynamic structure. The ".dynamic" section contains an array of them.
-class ELF_DYNAMIC_STRUCTURE(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Dynamic_Tag', c_int32), # Elf32_Sword /* Entry type. */
- ('ELF_Dynamic_Union', ELF_DYNAMIC_UNION), # Elf32_Off /* Section type. */
- ]
-
-## Relocation entries.
-
-# /* Relocations that don't need an addend field. */
-class ELF_RELOCATION(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_ReOffset', c_uint32), # Elf32_Addr /* Location to be relocated. */
- ('ELF_ReInfo', c_uint32), # Elf32_Word /* Relocation type and symbol index. */
- ]
-
-# /* Relocations that need an addend field. */
-class ELF_RELOCATION(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_ReOffset', c_uint32), # Elf32_Addr /* Location to be relocated. */
- ('ELF_ReInfo', c_uint32), # Elf32_Word /* Relocation type and symbol index. */
- ('ELF_ReAddend', c_int32), # Elf32_SWord /* Addend. */
- ]
-
-# Move Entry
-class ELF_MOVE(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_MValue', c_uint64), # Elf32_Lword /* symbol value */
- ('ELF_MInfo', c_uint32), # Elf32_Word /* size + index */
- ('ELF_MPOffset', c_int32), # Elf32_Word /* symbol offset */
- ('ELF_MRepeat', c_uint16), # Elf32_Half /* repeat count */
- ('ELF_MStride', c_uint16), # Elf32_Half /* stride info */
- ]
-
-## Hardware/Software capabilities entry
-class ELF_CAPA_UNION(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Capa_Val', c_uint32), # Elf32_Word /* Integer value. */
- ('ELF_Capa_Ptr', c_uint32), # Elf32_Addr /* Address value. */
- ]
-
-class ELF_CAPABILITY(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_Capa_Tag', c_uint32), # Elf32_Word /* how to interpret value */
- ('ELF_Capa_Union', ELF_CAPA_UNION), # ELF_CAPA_UNION
- ]
-
-# Symbol table entries.
-class ELF_SYMBOL(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_ST_Name', c_uint32), # Elf32_Word /* String table index of name. */
- ('ELF_ST_Value', c_uint32), # Elf32_Addr /* Symbol value. */
- ('ELF_ST_Size', c_uint32), # Elf32_Word /* Size of associated object. */
- ('ELF_ST_Info', c_char), # /* Type and binding information. */
- ('ELF_ST_Other', c_char), # /* Reserved (not used). */
- ('ELF_ST_Shndx', c_uint16), # Elf32_Half /* Section index of symbol. */
- ]
-
-# Structures used by Sun & GNU symbol versioning.
-class ELF_VERDEF(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_VD_Version', c_uint16), # Elf32_Half
- ('ELF_VD_Flags', c_uint16), # Elf32_Half
- ('ELF_VD_Ndx', c_uint16), # Elf32_Half
- ('ELF_VD_Cnt', c_uint16), # Elf32_Half
- ('ELF_VD_Hash', c_uint32), # Elf32_Word
- ('ELF_VD_Aux', c_uint32), # Elf32_Word
- ('ELF_VD_Next', c_uint32), # Elf32_Word
- ]
-
-class ELF_VERDAUX(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_VDA_Name', c_uint32), # Elf32_Word
- ('ELF_VDA_Next', c_uint32), # Elf32_Word
- ]
-
-class ELF_VERNEED(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_VN_Version', c_uint16), # Elf32_Half
- ('ELF_VN_Cnt', c_uint16), # Elf32_Half
- ('ELF_VN_File', c_uint32), # Elf32_Word
- ('ELF_VN_Aux', c_uint32), # Elf32_Word
- ('ELF_VN_Next', c_uint32), # Elf32_Word
- ]
-
-class ELF_VERNAUX(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_VNA_Hash', c_uint32), # Elf32_Word
- ('ELF_VNA_Flags', c_uint16), # Elf32_Half
- ('ELF_VNA_Other', c_uint16), # Elf32_Half
- ('ELF_VNA_Name', c_uint32), # Elf32_Word
- ('ELF_VNA_Next', c_uint32), # Elf32_Word
- ]
-
-class ELF_SYMINFO(Structure):
- _pack_ = 1
- _fields_ = [
- ('ELF_SI_BoundTo', c_uint16), # Elf32_Half /* direct bindings - symbol bound to */
- ('ELF_SI_Flags', c_uint16), # Elf32_Half /* per symbol flags */
- ]
-
-class UNIVERSAL_PAYLOAD_INFO(Structure):
- _pack_ = 1
- _fields_ = [
- ('Identifier', c_uint32), # ?PLDH? Identifier for the unverial payload info. 0x504c4448
- ('HeaderLength', c_uint32), # Length of the structure in bytes.
- ('SpecRevision', c_uint16), # Indicates compliance with a revision of this specification in the BCD format. 7 : 0 - Minor Version / 15 : 8 - Major Version For revision v0.75 the value will be 0x0075.
- ('Reserved', c_uint16), # Reserved for future use.
- ('Revision', c_uint32), # Revision of the Payload binary. Major.Minor .Revision.Build . The ImageRevision can be decoded as follows: 7 : 0 - Build Number / 15 :8 - Revision / 23 :16 - Minor Version / 31 :24 - Major Version
- ('Attribute', c_uint32), # Length of the structure in bytes.
- ('Capability', c_uint32), # Length of the structure in bytes.
- ('ProducerId', ARRAY(c_uint8, 16)), # Length of the structure in bytes.
- ('ImageId', ARRAY(c_uint8, 16)), # Length of the structure in bytes.
- ]
+## @file
+# This file is used to define the UPL Header C Struct.
+#
+# Copyright (c) 2023-, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+from struct import *
+from ctypes import *
+from FirmwareStorageFormat.Common import *
+
+EFI_COMMON_SECTION_HEADER_LEN = 4
+EFI_COMMON_SECTION_HEADER2_LEN = 8
+
+# ELF header.
+class ELF_HEADER32(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Identification', ARRAY(c_char, 16)), # /* File identification. */
+ ('ELF_Type', c_uint16), # Elf32_Half /* File type. */
+ ('ELF_Machine', c_uint16), # Elf32_Half /* Machine architecture. */
+ ('ELF_Version', c_uint32), # Elf32_Word /* ELF format version. */
+ ('ELF_Entry', c_uint32), # Elf32_Addr /* Entry point. */
+ ('ELF_PHOff', c_uint32), # Elf32_Off /* Program header file offset. */
+ ('ELF_SHOff', c_uint32), # Elf32_Off /* Section header file offset. */
+ ('ELF_Flags', c_uint32), # Elf32_Word /* Architecture-specific flags. */
+ ('ELF_EFSize', c_uint16), # Elf32_Half /* Size of ELF header in bytes. */
+ ('ELF_PHEntSize', c_uint16), # Elf32_Half /* Size of program header entry. */
+ ('ELF_PHNum', c_uint16), # Elf32_Half /* Number of program header entries. */
+ ('ELF_SHEntSize', c_uint16), # Elf32_Half /* Size of section header entry. */
+ ('ELF_SHNum', c_uint16), # Elf32_Half /* Number of section header entries. */
+ ('ELF_SNStr', c_uint16), # Elf32_Half /* Section name strings section. */
+ ]
+
+class ELF_HEADER64(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Identification', ARRAY(c_char, 16)), # /* File identification. */
+ ('ELF_Type', c_uint16), # Elf64_Half /* File type. */
+ ('ELF_Machine', c_uint16), # Elf64_Half /* Machine architecture. */
+ ('ELF_Version', c_uint32), # Elf64_Word /* ELF format version. */
+ ('ELF_Entry', c_uint64), # Elf64_Addr /* Entry point. */
+ ('ELF_PHOff', c_uint64), # Elf64_Off /* Program header file offset. */
+ ('ELF_SHOff', c_uint64), # Elf64_Off /* Section header file offset. */
+ ('ELF_Flags', c_uint32), # Elf64_Word /* Architecture-specific flags. */
+ ('ELF_EFSize', c_uint16), # Elf64_Half /* Size of ELF header in bytes. */
+ ('ELF_PHEntSize', c_uint16), # Elf64_Half /* Size of program header entry. */
+ ('ELF_PHNum', c_uint16), # Elf64_Half /* Number of program header entries. */
+ ('ELF_SHEntSize', c_uint16), # Elf64_Half /* Size of section header entry. */
+ ('ELF_SHNum', c_uint16), # Elf64_Half /* Number of section header entries. */
+ ('ELF_SNStr', c_uint16), # Elf64_Half /* Section name strings section. */
+ ]
+
+# Section header.
+class ELF_SECTION_HEADER32(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('SH_Name', c_uint32), # Elf32_Word /* Section name (index into the section header string table). */
+ ('SH_Type', c_uint32), # Elf32_Word /* Section type. */
+ ('SH_Flags', c_uint32), # Elf32_Word /* Section flags. */
+ ('SH_ADDR', c_uint32), # Elf32_Addr /* Address in memory image. */
+ ('SH_Offset', c_uint32), # Elf32_Off /* Offset in file. */
+ ('SH_Size', c_uint32), # Elf32_Word /* Size in bytes. */
+ ('SH_Link', c_uint32), # Elf32_Word /* Index of a related section. */
+ ('SH_Info', c_uint32), # Elf32_Word /* Depends on section type. */
+ ('SH_AddrAlign', c_uint32), # Elf32_Word /* Alignment in bytes. */
+ ('SH_EntSize', c_uint32), # Elf32_Word /* Size of each entry in section. */
+ ]
+
+class ELF_SECTION_HEADER64(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('SH_Name', c_uint32), # Elf32_Word /* Section name (index into the section header string table). */
+ ('SH_Type', c_uint32), # Elf32_Word /* Section type. */
+ ('SH_Flags', c_uint64), # Elf32_XWord /* Section flags. */
+ ('SH_ADDR', c_uint64), # Elf32_Addr /* Address in memory image. */
+ ('SH_Offset', c_uint64), # Elf32_Off /* Offset in file. */
+ ('SH_Size', c_uint64), # Elf32_XWord /* Size in bytes. */
+ ('SH_Link', c_uint32), # Elf32_Word /* Index of a related section. */
+ ('SH_Info', c_uint32), # Elf32_Word /* Depends on section type. */
+ ('SH_AddrAlign', c_uint64), # Elf32_XWord /* Alignment in bytes. */
+ ('SH_EntSize', c_uint64), # Elf32_XWord /* Size of each entry in section. */
+ ]
+
+# Program header.
+class ELF_PROGRAM_HEADER32(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PH_Type', c_uint32), # Elf32_Word /* Entry type. */
+ ('PH_Offset', c_uint32), # Elf32_Off /* File offset of contents. */
+ ('PH_VirAddr', c_uint32), # Elf32_Addr /* Virtual address in memory image. */
+ ('PH_PhyAddr', c_uint32), # Elf32_Addr /* Physical address (not used). */
+ ('PH_FileSize', c_uint32), # Elf32_Word /* Size of contents in file. */
+ ('PH_MemorySize', c_uint32), # Elf32_Word /* Size of contents in memory. */
+ ('PH_Flags', c_uint32), # Elf32_Word /* Access permission flags. */
+ ('PH_Align', c_uint32), # Elf32_Word /* Alignment in memory and file. */
+ ]
+
+class ELF_PROGRAM_HEADER64(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('PH_Type', c_uint32), # Elf32_Word /* Entry type. */
+ ('PH_Flags', c_uint32), # Elf32_Word /* Access permission flags. */
+ ('PH_Offset', c_uint64), # Elf32_Off /* File offset of contents. */
+ ('PH_VirAddr', c_uint64), # Elf32_Addr /* Virtual address in memory image. */
+ ('PH_PhyAddr', c_uint64), # Elf32_Addr /* Physical address (not used). */
+ ('PH_FileSize', c_uint64), # Elf32_XWord /* Size of contents in file. */
+ ('PH_MemorySize', c_uint64), # Elf32_XWord /* Size of contents in memory. */
+ ('PH_Align', c_uint64), # Elf32_XWord /* Alignment in memory and file. */
+ ]
+
+# Dynamic union.
+class ELF_DYNAMIC_UNION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Dynamic_Val', c_uint32), # Elf32_Word /* Integer value. */
+ ('ELF_Dynamic_Ptr', c_uint32), # Elf32_Addr /* Address value. */
+ ]
+
+
+# Dynamic structure. The ".dynamic" section contains an array of them.
+class ELF_DYNAMIC_STRUCTURE(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Dynamic_Tag', c_int32), # Elf32_Sword /* Entry type. */
+ ('ELF_Dynamic_Union', ELF_DYNAMIC_UNION), # Elf32_Off /* Section type. */
+ ]
+
+## Relocation entries.
+
+# /* Relocations that don't need an addend field. */
+class ELF_RELOCATION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_ReOffset', c_uint32), # Elf32_Addr /* Location to be relocated. */
+ ('ELF_ReInfo', c_uint32), # Elf32_Word /* Relocation type and symbol index. */
+ ]
+
+# /* Relocations that need an addend field. */
+class ELF_RELOCATION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_ReOffset', c_uint32), # Elf32_Addr /* Location to be relocated. */
+ ('ELF_ReInfo', c_uint32), # Elf32_Word /* Relocation type and symbol index. */
+ ('ELF_ReAddend', c_int32), # Elf32_SWord /* Addend. */
+ ]
+
+# Move Entry
+class ELF_MOVE(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_MValue', c_uint64), # Elf32_Lword /* symbol value */
+ ('ELF_MInfo', c_uint32), # Elf32_Word /* size + index */
+ ('ELF_MPOffset', c_int32), # Elf32_Word /* symbol offset */
+ ('ELF_MRepeat', c_uint16), # Elf32_Half /* repeat count */
+ ('ELF_MStride', c_uint16), # Elf32_Half /* stride info */
+ ]
+
+## Hardware/Software capabilities entry
+class ELF_CAPA_UNION(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Capa_Val', c_uint32), # Elf32_Word /* Integer value. */
+ ('ELF_Capa_Ptr', c_uint32), # Elf32_Addr /* Address value. */
+ ]
+
+class ELF_CAPABILITY(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_Capa_Tag', c_uint32), # Elf32_Word /* how to interpret value */
+ ('ELF_Capa_Union', ELF_CAPA_UNION), # ELF_CAPA_UNION
+ ]
+
+# Symbol table entries.
+class ELF_SYMBOL(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_ST_Name', c_uint32), # Elf32_Word /* String table index of name. */
+ ('ELF_ST_Value', c_uint32), # Elf32_Addr /* Symbol value. */
+ ('ELF_ST_Size', c_uint32), # Elf32_Word /* Size of associated object. */
+ ('ELF_ST_Info', c_char), # /* Type and binding information. */
+ ('ELF_ST_Other', c_char), # /* Reserved (not used). */
+ ('ELF_ST_Shndx', c_uint16), # Elf32_Half /* Section index of symbol. */
+ ]
+
+# Structures used by Sun & GNU symbol versioning.
+class ELF_VERDEF(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_VD_Version', c_uint16), # Elf32_Half
+ ('ELF_VD_Flags', c_uint16), # Elf32_Half
+ ('ELF_VD_Ndx', c_uint16), # Elf32_Half
+ ('ELF_VD_Cnt', c_uint16), # Elf32_Half
+ ('ELF_VD_Hash', c_uint32), # Elf32_Word
+ ('ELF_VD_Aux', c_uint32), # Elf32_Word
+ ('ELF_VD_Next', c_uint32), # Elf32_Word
+ ]
+
+class ELF_VERDAUX(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_VDA_Name', c_uint32), # Elf32_Word
+ ('ELF_VDA_Next', c_uint32), # Elf32_Word
+ ]
+
+class ELF_VERNEED(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_VN_Version', c_uint16), # Elf32_Half
+ ('ELF_VN_Cnt', c_uint16), # Elf32_Half
+ ('ELF_VN_File', c_uint32), # Elf32_Word
+ ('ELF_VN_Aux', c_uint32), # Elf32_Word
+ ('ELF_VN_Next', c_uint32), # Elf32_Word
+ ]
+
+class ELF_VERNAUX(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_VNA_Hash', c_uint32), # Elf32_Word
+ ('ELF_VNA_Flags', c_uint16), # Elf32_Half
+ ('ELF_VNA_Other', c_uint16), # Elf32_Half
+ ('ELF_VNA_Name', c_uint32), # Elf32_Word
+ ('ELF_VNA_Next', c_uint32), # Elf32_Word
+ ]
+
+class ELF_SYMINFO(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('ELF_SI_BoundTo', c_uint16), # Elf32_Half /* direct bindings - symbol bound to */
+ ('ELF_SI_Flags', c_uint16), # Elf32_Half /* per symbol flags */
+ ]
+
+class UNIVERSAL_PAYLOAD_INFO(Structure):
+ _pack_ = 1
+ _fields_ = [
+ ('Identifier', c_uint32), # ?PLDH? Identifier for the unverial payload info. 0x504c4448
+ ('HeaderLength', c_uint32), # Length of the structure in bytes.
+ ('SpecRevision', c_uint16), # Indicates compliance with a revision of this specification in the BCD format. 7 : 0 - Minor Version / 15 : 8 - Major Version For revision v0.75 the value will be 0x0075.
+ ('Reserved', c_uint16), # Reserved for future use.
+ ('Revision', c_uint32), # Revision of the Payload binary. Major.Minor .Revision.Build . The ImageRevision can be decoded as follows: 7 : 0 - Build Number / 15 :8 - Revision / 23 :16 - Minor Version / 31 :24 - Major Version
+ ('Attribute', c_uint32), # Length of the structure in bytes.
+ ('Capability', c_uint32), # Length of the structure in bytes.
+ ('ProducerId', ARRAY(c_uint8, 16)), # Length of the structure in bytes.
+ ('ImageId', ARRAY(c_uint8, 16)), # Length of the structure in bytes.
+ ]