2 # This file is used to define the Section Header C Struct.
4 # Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
9 from FirmwareStorageFormat
.Common
import *
11 EFI_COMMON_SECTION_HEADER_LEN
= 4
12 EFI_COMMON_SECTION_HEADER2_LEN
= 8
14 class EFI_COMMON_SECTION_HEADER(Structure
):
17 ('Size', ARRAY(c_uint8
, 3)),
22 def SECTION_SIZE(self
) -> int:
23 return self
.Size
[0] | self
.Size
[1] << 8 | self
.Size
[2] << 16
25 def Common_Header_Size(self
) -> int:
28 class EFI_COMMON_SECTION_HEADER2(Structure
):
31 ('Size', ARRAY(c_uint8
, 3)),
33 ('ExtendedSize', c_uint32
),
37 def SECTION_SIZE(self
) -> int:
38 return self
.ExtendedSize
40 def Common_Header_Size(self
) -> int:
43 class EFI_COMPRESSION_SECTION(Structure
):
46 ('UncompressedLength', c_uint32
),
47 ('CompressionType', c_uint8
),
50 def ExtHeaderSize(self
) -> int:
53 class EFI_FREEFORM_SUBTYPE_GUID_SECTION(Structure
):
56 ('SubTypeGuid', GUID
),
59 def ExtHeaderSize(self
) -> int:
62 class EFI_GUID_DEFINED_SECTION(Structure
):
65 ('SectionDefinitionGuid', GUID
),
66 ('DataOffset', c_uint16
),
67 ('Attributes', c_uint16
),
70 def ExtHeaderSize(self
) -> int:
73 def Get_USER_INTERFACE_Header(nums
: int):
74 class EFI_SECTION_USER_INTERFACE(Structure
):
77 ('FileNameString', ARRAY(c_uint16
, nums
)),
80 def ExtHeaderSize(self
) -> int:
83 def GetUiString(self
) -> str:
86 if self
.FileNameString
[i
]:
87 UiString
+= chr(self
.FileNameString
[i
])
90 return EFI_SECTION_USER_INTERFACE
92 def Get_VERSION_Header(nums
: int):
93 class EFI_SECTION_VERSION(Structure
):
96 ('BuildNumber', c_uint16
),
97 ('VersionString', ARRAY(c_uint16
, nums
)),
100 def ExtHeaderSize(self
) -> int:
103 def GetVersionString(self
) -> str:
105 for i
in range(nums
):
106 if self
.VersionString
[i
]:
107 VersionString
+= chr(self
.VersionString
[i
])
110 return EFI_SECTION_VERSION