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