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