File: FfsFileHeader.py

package info (click to toggle)
edk2 2025.08.01-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 338,148 kB
  • sloc: ansic: 2,159,989; asm: 275,189; perl: 235,301; python: 149,743; sh: 35,024; cpp: 23,915; makefile: 3,474; pascal: 1,465; xml: 806; lisp: 35; ruby: 16; sed: 6; tcl: 4
file content (66 lines) | stat: -rw-r--r-- 1,883 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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