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