]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiFirmwareFile.h
Add new FFS file types defined for SMM introduced since PI 1.1.
[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.2
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_SMM 0x0A
70 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
71 #define EFI_FV_FILETYPE_COMBINED_SMM_DXE 0x0C
72 #define EFI_FV_FILETYPE_SMM_CORE 0x0D
73 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
74 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
75 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
76 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
77 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
78 #define EFI_FV_FILETYPE_FFS_MAX 0xff
79 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
80 ///
81 /// FFS File Attributes.
82 ///
83 #define FFS_ATTRIB_LARGE_FILE 0x01
84 #define FFS_ATTRIB_FIXED 0x04
85 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
86 #define FFS_ATTRIB_CHECKSUM 0x40
87
88 ///
89 /// FFS File State Bits.
90 ///
91 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
92 #define EFI_FILE_HEADER_VALID 0x02
93 #define EFI_FILE_DATA_VALID 0x04
94 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
95 #define EFI_FILE_DELETED 0x10
96 #define EFI_FILE_HEADER_INVALID 0x20
97
98
99 ///
100 /// Each file begins with the header that describe the
101 /// contents and state of the files.
102 ///
103 typedef struct {
104 ///
105 /// This GUID is the file name. It is used to uniquely identify the file.
106 ///
107 EFI_GUID Name;
108 ///
109 /// Used to verify the integrity of the file.
110 ///
111 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
112 ///
113 /// Identifies the type of file.
114 ///
115 EFI_FV_FILETYPE Type;
116 ///
117 /// Declares various file attribute bits.
118 ///
119 EFI_FFS_FILE_ATTRIBUTES Attributes;
120 ///
121 /// The length of the file in bytes, including the FFS header.
122 ///
123 UINT8 Size[3];
124 ///
125 /// Used to track the state of the file throughout the life of the file from creation to deletion.
126 ///
127 EFI_FFS_FILE_STATE State;
128 } EFI_FFS_FILE_HEADER;
129
130 typedef struct {
131 ///
132 /// This GUID is the file name. It is used to uniquely identify the file. There may be only
133 /// one instance of a file with the file name GUID of Name in any given firmware
134 /// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD.
135 ///
136 EFI_GUID Name;
137
138 ///
139 /// Used to verify the integrity of the file.
140 ///
141 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
142
143 ///
144 /// Identifies the type of file.
145 ///
146 EFI_FV_FILETYPE Type;
147
148 ///
149 /// Declares various file attribute bits.
150 ///
151 EFI_FFS_FILE_ATTRIBUTES Attributes;
152
153 ///
154 /// The length of the file in bytes, including the FFS header.
155 /// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a
156 /// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).
157 /// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is
158 /// located at the next 8-byte aligned firmware volume offset following the last byte of the file F.
159 ///
160 UINT8 Size[3];
161
162 ///
163 /// Used to track the state of the file throughout the life of the file from creation to deletion.
164 ///
165 EFI_FFS_FILE_STATE State;
166
167 ///
168 /// If FFS_ATTRIB_LARGE_FILE is set in Attributes then ExtendedSize exists and Size must be set to zero.
169 /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.
170 ///
171 EFI_FFS_FILE_STATE ExtendedSize;
172 } EFI_FFS_FILE_HEADER2;
173
174 typedef UINT8 EFI_SECTION_TYPE;
175
176 ///
177 /// Pseudo type. It is
178 /// used as a wild card when retrieving sections. The section
179 /// type EFI_SECTION_ALL matches all section types.
180 ///
181 #define EFI_SECTION_ALL 0x00
182
183 ///
184 /// Encapsulation section Type values
185 ///
186 #define EFI_SECTION_COMPRESSION 0x01
187
188 #define EFI_SECTION_GUID_DEFINED 0x02
189
190 #define EFI_SECTION_DISPOSABLE 0x03
191
192 ///
193 /// Leaf section Type values
194 ///
195 #define EFI_SECTION_PE32 0x10
196 #define EFI_SECTION_PIC 0x11
197 #define EFI_SECTION_TE 0x12
198 #define EFI_SECTION_DXE_DEPEX 0x13
199 #define EFI_SECTION_VERSION 0x14
200 #define EFI_SECTION_USER_INTERFACE 0x15
201 #define EFI_SECTION_COMPATIBILITY16 0x16
202 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
203 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
204 #define EFI_SECTION_RAW 0x19
205 #define EFI_SECTION_PEI_DEPEX 0x1B
206 #define EFI_SECTION_SMM_DEPEX 0x1C
207
208 ///
209 /// Common section header
210 ///
211 typedef struct {
212 ///
213 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
214 /// including the EFI_COMMON_SECTION_HEADER.
215 ///
216 UINT8 Size[3];
217 EFI_SECTION_TYPE Type;
218 ///
219 /// Declares the section type.
220 ///
221 } EFI_COMMON_SECTION_HEADER;
222
223 typedef struct {
224 ///
225 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
226 /// including the EFI_COMMON_SECTION_HEADER.
227 ///
228 UINT8 Size[3];
229
230 EFI_SECTION_TYPE Type;
231
232 ///
233 /// If Size is 0xFFFFFF then ExtendedSize contains the size of the section. If
234 /// Size is not equal to 0xFFFFFF then this field does not exist.
235 ///
236 UINT32 ExtendedSize;
237 } EFI_COMMON_SECTION_HEADER2;
238
239 ///
240 /// Leaf section type that contains an
241 /// IA-32 16-bit executable image.
242 ///
243 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
244 typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;
245
246 ///
247 /// CompressionType of EFI_COMPRESSION_SECTION.
248 ///
249 #define EFI_NOT_COMPRESSED 0x00
250 #define EFI_STANDARD_COMPRESSION 0x01
251 ///
252 /// An encapsulation section type in which the
253 /// section data is compressed.
254 ///
255 typedef struct {
256 ///
257 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
258 ///
259 EFI_COMMON_SECTION_HEADER CommonHeader;
260 ///
261 /// UINT32 that indicates the size of the section data after decompression.
262 ///
263 UINT32 UncompressedLength;
264 ///
265 /// Indicates which compression algorithm is used.
266 ///
267 UINT8 CompressionType;
268 } EFI_COMPRESSION_SECTION;
269
270 typedef struct {
271 ///
272 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
273 ///
274 EFI_COMMON_SECTION_HEADER2 CommonHeader;
275 ///
276 /// UINT32 that indicates the size of the section data after decompression.
277 ///
278 UINT32 UncompressedLength;
279 ///
280 /// Indicates which compression algorithm is used.
281 ///
282 UINT8 CompressionType;
283 } EFI_COMPRESSION_SECTION2;
284
285 ///
286 /// An encapsulation section type in which the section data is disposable.
287 /// A disposable section is an encapsulation section in which the section data may be disposed of during
288 /// the process of creating or updating a firmware image without significant impact on the usefulness of
289 /// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This
290 /// allows optional or descriptive data to be included with the firmware file which can be removed in
291 /// order to conserve space. The contents of this section are implementation specific, but might contain
292 /// debug data or detailed integration instructions.
293 ///
294 typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION;
295 typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2;
296
297 ///
298 /// Leaf section which could be used to determine the dispatch order of DXEs.
299 ///
300 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
301 typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;
302
303 ///
304 /// Leaf section which contains a PI FV.
305 ///
306 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
307 typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;
308
309 ///
310 /// Leaf section which contains a single GUID.
311 ///
312 typedef struct {
313 ///
314 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
315 ///
316 EFI_COMMON_SECTION_HEADER CommonHeader;
317 ///
318 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
319 ///
320 EFI_GUID SubTypeGuid;
321 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
322
323 typedef struct {
324 ///
325 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
326 ///
327 EFI_COMMON_SECTION_HEADER2 CommonHeader;
328 ///
329 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
330 ///
331 EFI_GUID SubTypeGuid;
332 } EFI_FREEFORM_SUBTYPE_GUID_SECTION2;
333
334 ///
335 /// Attributes of EFI_GUID_DEFINED_SECTION
336 ///
337 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
338 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
339 ///
340 /// Leaf section which is encapsulation defined by specific GUID
341 ///
342 typedef struct {
343 ///
344 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
345 ///
346 EFI_COMMON_SECTION_HEADER CommonHeader;
347 ///
348 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
349 ///
350 EFI_GUID SectionDefinitionGuid;
351 ///
352 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
353 ///
354 UINT16 DataOffset;
355 ///
356 /// Bit field that declares some specific characteristics of the section contents.
357 ///
358 UINT16 Attributes;
359 } EFI_GUID_DEFINED_SECTION;
360
361 typedef struct {
362 ///
363 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
364 ///
365 EFI_COMMON_SECTION_HEADER2 CommonHeader;
366 ///
367 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
368 ///
369 EFI_GUID SectionDefinitionGuid;
370 ///
371 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
372 ///
373 UINT16 DataOffset;
374 ///
375 /// Bit field that declares some specific characteristics of the section contents.
376 ///
377 UINT16 Attributes;
378 } EFI_GUID_DEFINED_SECTION2;
379
380 ///
381 /// Leaf section which contains PE32+ image.
382 ///
383 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
384 typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;
385
386 ///
387 /// Leaf section which used to determine the dispatch order of PEIMs.
388 ///
389 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
390 typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;
391
392 ///
393 /// A leaf section type that contains a position-independent-code (PIC) image.
394 /// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.
395 /// In addition to normal PE32+ images that contain relocation information, PEIM executables may be
396 /// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all
397 /// relocation information has been stripped from the image and the image can be moved and will
398 /// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must
399 /// be used if the section is 16MB or larger.
400 ///
401 typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;
402 typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;
403
404 ///
405 /// Leaf section which constains the position-independent-code image.
406 ///
407 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
408 typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;
409
410 ///
411 /// Leaf section which contains an array of zero or more bytes.
412 ///
413 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
414 typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;
415
416 ///
417 /// The SMM dependency expression section is a leaf section that contains a dependency expression that
418 /// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the
419 /// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform
420 /// Initialization Specification, Volume 2for details regarding the format of the dependency expression.
421 /// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol
422 /// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger.
423 ///
424 typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION;
425 typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2;
426
427 ///
428 /// Leaf section which contains a unicode string that
429 /// is human readable file name.
430 ///
431 typedef struct {
432 EFI_COMMON_SECTION_HEADER CommonHeader;
433
434 ///
435 /// Array of unicode string.
436 ///
437 CHAR16 FileNameString[1];
438 } EFI_USER_INTERFACE_SECTION;
439
440 typedef struct {
441 EFI_COMMON_SECTION_HEADER2 CommonHeader;
442 CHAR16 FileNameString[1];
443 } EFI_USER_INTERFACE_SECTION2;
444
445 ///
446 /// Leaf section which contains a numeric build number and
447 /// an optional unicode string that represents the file revision.
448 ///
449 typedef struct {
450 EFI_COMMON_SECTION_HEADER CommonHeader;
451 UINT16 BuildNumber;
452
453 ///
454 /// Array of unicode string.
455 ///
456 CHAR16 VersionString[1];
457 } EFI_VERSION_SECTION;
458
459 typedef struct {
460 EFI_COMMON_SECTION_HEADER2 CommonHeader;
461 ///
462 /// A UINT16 that represents a particular build. Subsequent builds have monotonically
463 /// increasing build numbers relative to earlier builds.
464 ///
465 UINT16 BuildNumber;
466 CHAR16 VersionString[1];
467 } EFI_VERSION_SECTION2;
468
469 #define SECTION_SIZE(SectionHeaderPtr) \
470 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
471
472 #pragma pack()
473
474 #endif
475