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