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