blob: b7558e5a17fbd051ac6461e10b9f3ee6f142d001 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: Intel */
Bin Meng2922b3e2014-12-12 21:05:28 +08002/*
3 * Copyright (C) 2013, Intel Corporation
4 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Bin Meng2922b3e2014-12-12 21:05:28 +08005 */
6
7#ifndef __FSP_FFS_H__
8#define __FSP_FFS_H__
9
Bin Meng2922b3e2014-12-12 21:05:28 +080010/* Used to verify the integrity of the file */
Bin Mengdb60d862014-12-17 15:50:49 +080011union __packed ffs_integrity {
Bin Meng2922b3e2014-12-12 21:05:28 +080012 struct {
13 /*
14 * The IntegrityCheck.checksum.header field is an 8-bit
15 * checksum of the file header. The State and
16 * IntegrityCheck.checksum.file fields are assumed to be zero
17 * and the checksum is calculated such that the entire header
18 * sums to zero.
19 */
20 u8 header;
21 /*
22 * If the FFS_ATTRIB_CHECKSUM (see definition below) bit of
23 * the Attributes field is set to one, the
24 * IntegrityCheck.checksum.file field is an 8-bit checksum of
25 * the file data. If the FFS_ATTRIB_CHECKSUM bit of the
26 * Attributes field is cleared to zero, the
27 * IntegrityCheck.checksum.file field must be initialized with
28 * a value of 0xAA. The IntegrityCheck.checksum.file field is
29 * valid any time the EFI_FILE_DATA_VALID bit is set in the
30 * State field.
31 */
32 u8 file;
33 } checksum;
34
35 /* This is the full 16 bits of the IntegrityCheck field */
36 u16 checksum16;
37};
38
39/*
40 * Each file begins with the header that describe the
41 * contents and state of the files.
42 */
Bin Mengdb60d862014-12-17 15:50:49 +080043struct __packed ffs_file_header {
Bin Meng2922b3e2014-12-12 21:05:28 +080044 /*
45 * This GUID is the file name.
46 * It is used to uniquely identify the file.
47 */
Park, Aiden0961cf72019-08-03 08:30:20 +000048 efi_guid_t name;
Bin Meng2922b3e2014-12-12 21:05:28 +080049 /* Used to verify the integrity of the file */
Bin Mengdb60d862014-12-17 15:50:49 +080050 union ffs_integrity integrity;
Bin Meng2922b3e2014-12-12 21:05:28 +080051 /* Identifies the type of file */
52 u8 type;
53 /* Declares various file attribute bits */
54 u8 attr;
55 /* The length of the file in bytes, including the FFS header */
56 u8 size[3];
57 /*
58 * Used to track the state of the file throughout the life of
59 * the file from creation to deletion.
60 */
61 u8 state;
62};
63
Bin Mengdb60d862014-12-17 15:50:49 +080064struct __packed ffs_file_header2 {
Bin Meng2922b3e2014-12-12 21:05:28 +080065 /*
66 * This GUID is the file name. It is used to uniquely identify the file.
67 * There may be only one instance of a file with the file name GUID of
68 * Name in any given firmware volume, except if the file type is
69 * EFI_FV_FILE_TYPE_FFS_PAD.
70 */
Park, Aiden0961cf72019-08-03 08:30:20 +000071 efi_guid_t name;
Bin Meng2922b3e2014-12-12 21:05:28 +080072 /* Used to verify the integrity of the file */
Bin Mengdb60d862014-12-17 15:50:49 +080073 union ffs_integrity integrity;
Bin Meng2922b3e2014-12-12 21:05:28 +080074 /* Identifies the type of file */
75 u8 type;
76 /* Declares various file attribute bits */
77 u8 attr;
78 /*
79 * The length of the file in bytes, including the FFS header.
80 * The length of the file data is either
Bin Mengdb60d862014-12-17 15:50:49 +080081 * (size - sizeof(struct ffs_file_header)). This calculation means a
Bin Meng2922b3e2014-12-12 21:05:28 +080082 * zero-length file has a size of 24 bytes, which is
Bin Mengdb60d862014-12-17 15:50:49 +080083 * sizeof(struct ffs_file_header). Size is not required to be a
Bin Meng2922b3e2014-12-12 21:05:28 +080084 * multiple of 8 bytes. Given a file F, the next file header is located
85 * at the next 8-byte aligned firmware volume offset following the last
86 * byte of the file F.
87 */
88 u8 size[3];
89 /*
90 * Used to track the state of the file throughout the life of
91 * the file from creation to deletion.
92 */
93 u8 state;
94 /*
95 * If FFS_ATTRIB_LARGE_FILE is set in attr, then ext_size exists
96 * and size must be set to zero.
97 * If FFS_ATTRIB_LARGE_FILE is not set then
Bin Mengdb60d862014-12-17 15:50:49 +080098 * struct ffs_file_header is used.
Bin Meng2922b3e2014-12-12 21:05:28 +080099 */
100 u32 ext_size;
101};
102
103/*
104 * Pseudo type. It is used as a wild card when retrieving sections.
105 * The section type EFI_SECTION_ALL matches all section types.
106 */
107#define EFI_SECTION_ALL 0x00
108
109/* Encapsulation section Type values */
110#define EFI_SECTION_COMPRESSION 0x01
111#define EFI_SECTION_GUID_DEFINED 0x02
112#define EFI_SECTION_DISPOSABLE 0x03
113
114/* Leaf section Type values */
115#define EFI_SECTION_PE32 0x10
116#define EFI_SECTION_PIC 0x11
117#define EFI_SECTION_TE 0x12
118#define EFI_SECTION_DXE_DEPEX 0x13
119#define EFI_SECTION_VERSION 0x14
120#define EFI_SECTION_USER_INTERFACE 0x15
121#define EFI_SECTION_COMPATIBILITY16 0x16
122#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
123#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
124#define EFI_SECTION_RAW 0x19
125#define EFI_SECTION_PEI_DEPEX 0x1B
126#define EFI_SECTION_SMM_DEPEX 0x1C
127
128/* Common section header */
Bin Mengdb60d862014-12-17 15:50:49 +0800129struct __packed raw_section {
Bin Meng2922b3e2014-12-12 21:05:28 +0800130 /*
131 * A 24-bit unsigned integer that contains the total size of
132 * the section in bytes, including the EFI_COMMON_SECTION_HEADER.
133 */
134 u8 size[3];
135 u8 type;
136};
137
Bin Mengdb60d862014-12-17 15:50:49 +0800138struct __packed raw_section2 {
Bin Meng2922b3e2014-12-12 21:05:28 +0800139 /*
140 * A 24-bit unsigned integer that contains the total size of
141 * the section in bytes, including the EFI_COMMON_SECTION_HEADER.
142 */
143 u8 size[3];
144 u8 type;
145 /*
146 * If size is 0xFFFFFF, then ext_size contains the size of
147 * the section. If size is not equal to 0xFFFFFF, then this
148 * field does not exist.
149 */
150 u32 ext_size;
151};
152
Bin Meng2922b3e2014-12-12 21:05:28 +0800153#endif