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