]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/FirmwareStorageFormat/FfsFileHeader.py
BaseTools: Add FMMT Python Tool
[mirror_edk2.git] / BaseTools / Source / Python / FirmwareStorageFormat / FfsFileHeader.py
CommitLineData
a64b9449
CC
1## @file\r
2# This file is used to define the Ffs Header C Struct.\r
3#\r
4# Copyright (c) 2021-, Intel Corporation. All rights reserved.<BR>\r
5# SPDX-License-Identifier: BSD-2-Clause-Patent\r
6##\r
7from struct import *\r
8from ctypes import *\r
9from FirmwareStorageFormat.Common import *\r
10\r
11EFI_FFS_FILE_HEADER_LEN = 24\r
12EFI_FFS_FILE_HEADER2_LEN = 32\r
13\r
14class CHECK_SUM(Structure):\r
15 _pack_ = 1\r
16 _fields_ = [\r
17 ('Header', c_uint8),\r
18 ('File', c_uint8),\r
19 ]\r
20\r
21class EFI_FFS_INTEGRITY_CHECK(Union):\r
22 _pack_ = 1\r
23 _fields_ = [\r
24 ('Checksum', CHECK_SUM),\r
25 ('Checksum16', c_uint16),\r
26 ]\r
27\r
28\r
29class EFI_FFS_FILE_HEADER(Structure):\r
30 _pack_ = 1\r
31 _fields_ = [\r
32 ('Name', GUID),\r
33 ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),\r
34 ('Type', c_uint8),\r
35 ('Attributes', c_uint8),\r
36 ('Size', ARRAY(c_uint8, 3)),\r
37 ('State', c_uint8),\r
38 ]\r
39\r
40 @property\r
41 def FFS_FILE_SIZE(self) -> int:\r
42 return self.Size[0] | self.Size[1] << 8 | self.Size[2] << 16\r
43\r
44 @property\r
45 def HeaderLength(self) -> int:\r
46 return 24\r
47\r
48class EFI_FFS_FILE_HEADER2(Structure):\r
49 _pack_ = 1\r
50 _fields_ = [\r
51 ('Name', GUID),\r
52 ('IntegrityCheck', EFI_FFS_INTEGRITY_CHECK),\r
53 ('Type', c_uint8),\r
54 ('Attributes', c_uint8),\r
55 ('Size', ARRAY(c_uint8, 3)),\r
56 ('State', c_uint8),\r
57 ('ExtendedSize', c_uint64),\r
58 ]\r
59\r
60 @property\r
61 def FFS_FILE_SIZE(self) -> int:\r
62 return self.ExtendedSize\r
63\r
64 @property\r
65 def HeaderLength(self) -> int:\r
66 return 32\r