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 
17 #pragma pack(1)
18 ///
19 /// Used to verify the integrity of the file.
20 ///
21 typedef union {
22  struct {
23  ///
24  /// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file
25  /// header. The State and IntegrityCheck.Checksum.File fields are assumed
26  /// to be zero and the checksum is calculated such that the entire header sums to zero.
27  ///
29  ///
30  /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes
31  /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit
32  /// checksum of the file data.
33  /// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,
34  /// the IntegrityCheck.Checksum.File field must be initialized with a value of
35  /// 0xAA. The IntegrityCheck.Checksum.File field is valid any time the
36  /// EFI_FILE_DATA_VALID bit is set in the State field.
37  ///
39  } Checksum;
40  ///
41  /// This is the full 16 bits of the IntegrityCheck field.
42  ///
45 
46 ///
47 /// FFS_FIXED_CHECKSUM is the checksum value used when the
48 /// FFS_ATTRIB_CHECKSUM attribute bit is clear.
49 ///
50 #define FFS_FIXED_CHECKSUM 0xAA
51 
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_MM 0x0A
70 #define EFI_FV_FILETYPE_SMM EFI_FV_FILETYPE_MM
71 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
72 #define EFI_FV_FILETYPE_COMBINED_MM_DXE 0x0C
73 #define EFI_FV_FILETYPE_COMBINED_SMM_DXE EFI_FV_FILETYPE_COMBINED_MM_DXE
74 #define EFI_FV_FILETYPE_MM_CORE 0x0D
75 #define EFI_FV_FILETYPE_SMM_CORE EFI_FV_FILETYPE_MM_CORE
76 #define EFI_FV_FILETYPE_MM_STANDALONE 0x0E
77 #define EFI_FV_FILETYPE_MM_CORE_STANDALONE 0x0F
78 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
79 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
80 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
81 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
82 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
83 #define EFI_FV_FILETYPE_FFS_MAX 0xff
84 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
85 ///
86 /// FFS File Attributes.
87 ///
88 #define FFS_ATTRIB_LARGE_FILE 0x01
89 #define FFS_ATTRIB_DATA_ALIGNMENT_2 0x02
90 #define FFS_ATTRIB_FIXED 0x04
91 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
92 #define FFS_ATTRIB_CHECKSUM 0x40
93 
94 ///
95 /// FFS File State Bits.
96 ///
97 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
98 #define EFI_FILE_HEADER_VALID 0x02
99 #define EFI_FILE_DATA_VALID 0x04
100 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
101 #define EFI_FILE_DELETED 0x10
102 #define EFI_FILE_HEADER_INVALID 0x20
103 
104 ///
105 /// Each file begins with the header that describe the
106 /// contents and state of the files.
107 ///
108 typedef struct {
109  ///
110  /// This GUID is the file name. It is used to uniquely identify the file.
111  ///
113  ///
114  /// Used to verify the integrity of the file.
115  ///
117  ///
118  /// Identifies the type of file.
119  ///
121  ///
122  /// Declares various file attribute bits.
123  ///
125  ///
126  /// The length of the file in bytes, including the FFS header.
127  ///
129  ///
130  /// Used to track the state of the file throughout the life of the file from creation to deletion.
131  ///
134 
135 typedef struct {
136  ///
137  /// This GUID is the file name. It is used to uniquely identify the file. There may be only
138  /// one instance of a file with the file name GUID of Name in any given firmware
139  /// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD.
140  ///
142 
143  ///
144  /// Used to verify the integrity of the file.
145  ///
147 
148  ///
149  /// Identifies the type of file.
150  ///
152 
153  ///
154  /// Declares various file attribute bits.
155  ///
157 
158  ///
159  /// The length of the file in bytes, including the FFS header.
160  /// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a
161  /// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).
162  /// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is
163  /// located at the next 8-byte aligned firmware volume offset following the last byte of the file F.
164  ///
166 
167  ///
168  /// Used to track the state of the file throughout the life of the file from creation to deletion.
169  ///
171 
172  ///
173  /// If FFS_ATTRIB_LARGE_FILE is set in Attributes, then ExtendedSize exists and Size must be set to zero.
174  /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.
175  ///
178 
179 #define IS_FFS_FILE2(FfsFileHeaderPtr) \
180  (((((EFI_FFS_FILE_HEADER *) (UINTN) FfsFileHeaderPtr)->Attributes) & FFS_ATTRIB_LARGE_FILE) == FFS_ATTRIB_LARGE_FILE)
181 
182 ///
183 /// The argument passed as the FfsFileHeaderPtr parameter to the
184 /// FFS_FILE_SIZE() function-like macro below must not have side effects:
185 /// FfsFileHeaderPtr is evaluated multiple times.
186 ///
187 #define FFS_FILE_SIZE(FfsFileHeaderPtr) ((UINT32) (\
188  (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[0] ) | \
189  (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[1] << 8) | \
190  (((EFI_FFS_FILE_HEADER *) (UINTN) (FfsFileHeaderPtr))->Size[2] << 16)))
191 
192 #define FFS_FILE2_SIZE(FfsFileHeaderPtr) \
193  ((UINT32) (((EFI_FFS_FILE_HEADER2 *) (UINTN) FfsFileHeaderPtr)->ExtendedSize))
194 
196 
197 ///
198 /// Pseudo type. It is used as a wild card when retrieving sections.
199 /// The section type EFI_SECTION_ALL matches all section types.
200 ///
201 #define EFI_SECTION_ALL 0x00
202 
203 ///
204 /// Encapsulation section Type values.
205 ///
206 #define EFI_SECTION_COMPRESSION 0x01
207 
208 #define EFI_SECTION_GUID_DEFINED 0x02
209 
210 #define EFI_SECTION_DISPOSABLE 0x03
211 
212 ///
213 /// Leaf section Type values.
214 ///
215 #define EFI_SECTION_PE32 0x10
216 #define EFI_SECTION_PIC 0x11
217 #define EFI_SECTION_TE 0x12
218 #define EFI_SECTION_DXE_DEPEX 0x13
219 #define EFI_SECTION_VERSION 0x14
220 #define EFI_SECTION_USER_INTERFACE 0x15
221 #define EFI_SECTION_COMPATIBILITY16 0x16
222 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
223 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
224 #define EFI_SECTION_RAW 0x19
225 #define EFI_SECTION_PEI_DEPEX 0x1B
226 #define EFI_SECTION_MM_DEPEX 0x1C
227 #define EFI_SECTION_SMM_DEPEX EFI_SECTION_MM_DEPEX
228 
229 ///
230 /// Common section header.
231 ///
232 typedef struct {
233  ///
234  /// A 24-bit unsigned integer that contains the total size of the section in bytes,
235  /// including the EFI_COMMON_SECTION_HEADER.
236  ///
239  ///
240  /// Declares the section type.
241  ///
243 
244 typedef struct {
245  ///
246  /// A 24-bit unsigned integer that contains the total size of the section in bytes,
247  /// including the EFI_COMMON_SECTION_HEADER.
248  ///
250 
252 
253  ///
254  /// If Size is 0xFFFFFF, then ExtendedSize contains the size of the section. If
255  /// Size is not equal to 0xFFFFFF, then this field does not exist.
256  ///
259 
260 ///
261 /// Leaf section type that contains an
262 /// IA-32 16-bit executable image.
263 ///
266 
267 ///
268 /// CompressionType of EFI_COMPRESSION_SECTION.
269 ///
270 #define EFI_NOT_COMPRESSED 0x00
271 #define EFI_STANDARD_COMPRESSION 0x01
272 ///
273 /// An encapsulation section type in which the
274 /// section data is compressed.
275 ///
276 typedef struct {
277  ///
278  /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
279  ///
281  ///
282  /// The UINT32 that indicates the size of the section data after decompression.
283  ///
285  ///
286  /// Indicates which compression algorithm is used.
287  ///
290 
291 typedef struct {
292  ///
293  /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
294  ///
296  ///
297  /// UINT32 that indicates the size of the section data after decompression.
298  ///
300  ///
301  /// Indicates which compression algorithm is used.
302  ///
305 
306 ///
307 /// An encapsulation section type in which the section data is disposable.
308 /// A disposable section is an encapsulation section in which the section data may be disposed of during
309 /// the process of creating or updating a firmware image without significant impact on the usefulness of
310 /// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This
311 /// allows optional or descriptive data to be included with the firmware file which can be removed in
312 /// order to conserve space. The contents of this section are implementation specific, but might contain
313 /// debug data or detailed integration instructions.
314 ///
317 
318 ///
319 /// The leaf section which could be used to determine the dispatch order of DXEs.
320 ///
323 
324 ///
325 /// The leaf section which contains a PI FV.
326 ///
329 
330 ///
331 /// The leaf section which contains a single GUID.
332 ///
333 typedef struct {
334  ///
335  /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
336  ///
338  ///
339  /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
340  ///
343 
344 typedef struct {
345  ///
346  /// The common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
347  ///
349  ///
350  /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
351  ///
354 
355 ///
356 /// Attributes of EFI_GUID_DEFINED_SECTION.
357 ///
358 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
359 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
360 ///
361 /// The leaf section which is encapsulation defined by specific GUID.
362 ///
363 typedef struct {
364  ///
365  /// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
366  ///
368  ///
369  /// The GUID that defines the format of the data that follows. It is a vendor-defined section type.
370  ///
372  ///
373  /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
374  ///
376  ///
377  /// The bit field that declares some specific characteristics of the section contents.
378  ///
381 
382 typedef struct {
383  ///
384  /// The common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
385  ///
387  ///
388  /// The GUID that defines the format of the data that follows. It is a vendor-defined section type.
389  ///
391  ///
392  /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
393  ///
395  ///
396  /// The bit field that declares some specific characteristics of the section contents.
397  ///
400 
401 ///
402 /// The leaf section which contains PE32+ image.
403 ///
406 
407 ///
408 /// The leaf section used to determine the dispatch order of PEIMs.
409 ///
412 
413 ///
414 /// A leaf section type that contains a position-independent-code (PIC) image.
415 /// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.
416 /// In addition to normal PE32+ images that contain relocation information, PEIM executables may be
417 /// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all
418 /// relocation information has been stripped from the image and the image can be moved and will
419 /// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must
420 /// be used if the section is 16MB or larger.
421 ///
424 
425 ///
426 /// The leaf section which constains the position-independent-code image.
427 ///
430 
431 ///
432 /// The leaf section which contains an array of zero or more bytes.
433 ///
436 
437 ///
438 /// The SMM dependency expression section is a leaf section that contains a dependency expression that
439 /// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the
440 /// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform
441 /// Initialization Specification, Volume 2, for details regarding the format of the dependency expression.
442 /// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol
443 /// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger.
444 ///
447 
448 ///
449 /// The leaf section which contains a unicode string that
450 /// is human readable file name.
451 ///
452 typedef struct {
454 
455  ///
456  /// Array of unicode string.
457  ///
458  CHAR16 FileNameString[1];
460 
461 typedef struct {
463  CHAR16 FileNameString[1];
465 
466 ///
467 /// The leaf section which contains a numeric build number and
468 /// an optional unicode string that represents the file revision.
469 ///
470 typedef struct {
473 
474  ///
475  /// Array of unicode string.
476  ///
477  CHAR16 VersionString[1];
479 
480 typedef struct {
482  ///
483  /// A UINT16 that represents a particular build. Subsequent builds have monotonically
484  /// increasing build numbers relative to earlier builds.
485  ///
487  CHAR16 VersionString[1];
489 
490 ///
491 /// The argument passed as the SectionHeaderPtr parameter to the SECTION_SIZE()
492 /// and IS_SECTION2() function-like macros below must not have side effects:
493 /// SectionHeaderPtr is evaluated multiple times.
494 ///
495 #define SECTION_SIZE(SectionHeaderPtr) ((UINT32) (\
496  (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[0] ) | \
497  (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[1] << 8) | \
498  (((EFI_COMMON_SECTION_HEADER *) (UINTN) (SectionHeaderPtr))->Size[2] << 16)))
499 
500 #define IS_SECTION2(SectionHeaderPtr) \
501  (SECTION_SIZE (SectionHeaderPtr) == 0x00ffffff)
502 
503 #define SECTION2_SIZE(SectionHeaderPtr) \
504  (((EFI_COMMON_SECTION_HEADER2 *) (UINTN) SectionHeaderPtr)->ExtendedSize)
505 
506 #pragma pack()
507 
508 #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:215
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:98
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:96
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.
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