]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiFirmwareFile.h
Reviewed the description in the FatBinPkg .dec file.
[mirror_edk2.git] / MdePkg / Include / Pi / PiFirmwareFile.h
1 /** @file
2 The firmware file related definitions in PI.
3
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 @par Revision Reference:
14 PI Version 1.0
15
16 **/
17
18
19 #ifndef __PI_FIRMWARE_FILE_H__
20 #define __PI_FIRMWARE_FILE_H__
21
22 #pragma pack(1)
23 ///
24 /// Used to verify the integrity of the file.
25 ///
26 typedef union {
27 struct {
28 ///
29 /// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file
30 /// header. The State and IntegrityCheck.Checksum.File fields are assumed
31 /// to be zero and the checksum is calculated such that the entire header sums to zero.
32 ///
33 UINT8 Header;
34 ///
35 /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes
36 /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit
37 /// checksum of the entire file The State field and the file tail are assumed to be zero
38 /// and the checksum is calculated such that the entire file sums to zero.
39 /// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,
40 /// the IntegrityCheck.Checksum.File field must be initialized with a value of
41 /// 0x55AA. The IntegrityCheck.Checksum.File field is valid any time the
42 /// EFI_FILE_DATA_VALID bit is set in the State field.
43 ///
44 UINT8 File;
45 } Checksum;
46 ///
47 /// This is the full 16 bits of the IntegrityCheck field.
48 ///
49 UINT16 Checksum16;
50 } EFI_FFS_INTEGRITY_CHECK;
51
52 typedef UINT8 EFI_FV_FILETYPE;
53 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
54 typedef UINT8 EFI_FFS_FILE_STATE;
55
56 ///
57 /// File Types Definitions
58 ///
59 #define EFI_FV_FILETYPE_ALL 0x00
60 #define EFI_FV_FILETYPE_RAW 0x01
61 #define EFI_FV_FILETYPE_FREEFORM 0x02
62 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
63 #define EFI_FV_FILETYPE_PEI_CORE 0x04
64 #define EFI_FV_FILETYPE_DXE_CORE 0x05
65 #define EFI_FV_FILETYPE_PEIM 0x06
66 #define EFI_FV_FILETYPE_DRIVER 0x07
67 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
68 #define EFI_FV_FILETYPE_APPLICATION 0x09
69 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
70 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
71 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
72 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
73 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
74 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
75 #define EFI_FV_FILETYPE_FFS_MAX 0xff
76 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
77 ///
78 /// FFS File Attributes.
79 ///
80 #define FFS_ATTRIB_FIXED 0x04
81 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
82 #define FFS_ATTRIB_CHECKSUM 0x40
83
84 ///
85 /// FFS File State Bits.
86 ///
87 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
88 #define EFI_FILE_HEADER_VALID 0x02
89 #define EFI_FILE_DATA_VALID 0x04
90 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
91 #define EFI_FILE_DELETED 0x10
92 #define EFI_FILE_HEADER_INVALID 0x20
93
94
95 ///
96 /// Each file begins with the header that describe the
97 /// contents and state of the files.
98 ///
99 typedef struct {
100 ///
101 /// This GUID is the file name. It is used to uniquely identify the file.
102 ///
103 EFI_GUID Name;
104 ///
105 /// Used to verify the integrity of the file.
106 ///
107 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
108 ///
109 /// Identifies the type of file.
110 ///
111 EFI_FV_FILETYPE Type;
112 ///
113 /// Declares various file attribute bits.
114 ///
115 EFI_FFS_FILE_ATTRIBUTES Attributes;
116 ///
117 /// The length of the file in bytes, including the FFS header.
118 ///
119 UINT8 Size[3];
120 ///
121 /// Used to track the state of the file throughout the life of the file from creation to deletion.
122 ///
123 EFI_FFS_FILE_STATE State;
124 } EFI_FFS_FILE_HEADER;
125
126
127 typedef UINT8 EFI_SECTION_TYPE;
128
129 ///
130 /// Pseudo type. It is
131 /// used as a wild card when retrieving sections. The section
132 /// type EFI_SECTION_ALL matches all section types.
133 ///
134 #define EFI_SECTION_ALL 0x00
135
136 ///
137 /// Encapsulation section Type values
138 ///
139 #define EFI_SECTION_COMPRESSION 0x01
140
141 #define EFI_SECTION_GUID_DEFINED 0x02
142
143 ///
144 /// Leaf section Type values
145 ///
146 #define EFI_SECTION_PE32 0x10
147 #define EFI_SECTION_PIC 0x11
148 #define EFI_SECTION_TE 0x12
149 #define EFI_SECTION_DXE_DEPEX 0x13
150 #define EFI_SECTION_VERSION 0x14
151 #define EFI_SECTION_USER_INTERFACE 0x15
152 #define EFI_SECTION_COMPATIBILITY16 0x16
153 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
154 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
155 #define EFI_SECTION_RAW 0x19
156 #define EFI_SECTION_PEI_DEPEX 0x1B
157
158 ///
159 /// Common section header
160 ///
161 typedef struct {
162 ///
163 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
164 /// including the EFI_COMMON_SECTION_HEADER.
165 ///
166 UINT8 Size[3];
167 EFI_SECTION_TYPE Type;
168 ///
169 /// Declares the section type.
170 ///
171 } EFI_COMMON_SECTION_HEADER;
172
173 ///
174 /// Leaf section type that contains an
175 /// IA-32 16-bit executable image.
176 ///
177 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
178
179 ///
180 /// CompressionType of EFI_COMPRESSION_SECTION.
181 ///
182 #define EFI_NOT_COMPRESSED 0x00
183 #define EFI_STANDARD_COMPRESSION 0x01
184 ///
185 /// An encapsulation section type in which the
186 /// section data is compressed.
187 ///
188 typedef struct {
189 ///
190 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
191 ///
192 EFI_COMMON_SECTION_HEADER CommonHeader;
193 ///
194 /// UINT32 that indicates the size of the section data after decompression.
195 ///
196 UINT32 UncompressedLength;
197 ///
198 /// Indicates which compression algorithm is used.
199 ///
200 UINT8 CompressionType;
201 } EFI_COMPRESSION_SECTION;
202
203 ///
204 /// Leaf section which could be used to determine the dispatch order of DXEs.
205 ///
206 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
207
208 ///
209 /// Leaf section which contains a PI FV.
210 ///
211 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
212
213 ///
214 /// Leaf section which contains a single GUID.
215 ///
216 typedef struct {
217 ///
218 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
219 ///
220 EFI_COMMON_SECTION_HEADER CommonHeader;
221 ///
222 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
223 ///
224 EFI_GUID SubTypeGuid;
225 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
226
227 ///
228 /// Attributes of EFI_GUID_DEFINED_SECTION
229 ///
230 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
231 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
232 ///
233 /// Leaf section which is encapsulation defined by specific GUID
234 ///
235 typedef struct {
236 ///
237 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
238 ///
239 EFI_COMMON_SECTION_HEADER CommonHeader;
240 ///
241 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
242 ///
243 EFI_GUID SectionDefinitionGuid;
244 ///
245 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
246 ///
247 UINT16 DataOffset;
248 ///
249 /// Bit field that declares some specific characteristics of the section contents.
250 ///
251 UINT16 Attributes;
252 } EFI_GUID_DEFINED_SECTION;
253
254 ///
255 /// Leaf section which contains PE32+ image.
256 ///
257 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
258
259
260 ///
261 /// Leaf section which used to determine the dispatch order of PEIMs.
262 ///
263 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
264
265 ///
266 /// Leaf section which constains the position-independent-code image.
267 ///
268 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
269
270 ///
271 /// Leaf section which contains an array of zero or more bytes.
272 ///
273 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
274
275 ///
276 /// Leaf section which contains a unicode string that
277 /// is human readable file name.
278 ///
279 typedef struct {
280 EFI_COMMON_SECTION_HEADER CommonHeader;
281
282 ///
283 /// Array of unicode string.
284 ///
285 CHAR16 FileNameString[1];
286 } EFI_USER_INTERFACE_SECTION;
287
288
289 ///
290 /// Leaf section which contains a numeric build number and
291 /// an optional unicode string that represents the file revision.
292 ///
293 typedef struct {
294 EFI_COMMON_SECTION_HEADER CommonHeader;
295 UINT16 BuildNumber;
296
297 ///
298 /// Array of unicode string.
299 ///
300 CHAR16 VersionString[1];
301 } EFI_VERSION_SECTION;
302
303
304 #define SECTION_SIZE(SectionHeaderPtr) \
305 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
306
307 #pragma pack()
308
309 #endif
310