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