2 The firmware file related definitions in PI.
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
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.
13 @par Revision Reference:
19 #ifndef __PI_FIRMWARE_FILE_H__
20 #define __PI_FIRMWARE_FILE_H__
24 /// Used to verify the integrity of the file.
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.
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.
47 /// This is the full 16 bits of the IntegrityCheck field.
50 } EFI_FFS_INTEGRITY_CHECK
;
52 typedef UINT8 EFI_FV_FILETYPE
;
53 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES
;
54 typedef UINT8 EFI_FFS_FILE_STATE
;
57 /// File Types Definitions
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_FIRMWARE_VOLUME_IMAGE 0x0B
70 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
71 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
72 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
73 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
74 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
75 #define EFI_FV_FILETYPE_FFS_MAX 0xff
76 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
78 /// FFS File Attributes.
80 #define FFS_ATTRIB_FIXED 0x04
81 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
82 #define FFS_ATTRIB_CHECKSUM 0x40
85 /// FFS File State Bits.
87 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
88 #define EFI_FILE_HEADER_VALID 0x02
89 #define EFI_FILE_DATA_VALID 0x04
90 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
91 #define EFI_FILE_DELETED 0x10
92 #define EFI_FILE_HEADER_INVALID 0x20
96 /// Each file begins with the header that describe the
97 /// contents and state of the files.
101 /// This GUID is the file name. It is used to uniquely identify the file.
105 /// Used to verify the integrity of the file.
107 EFI_FFS_INTEGRITY_CHECK IntegrityCheck
;
109 /// Identifies the type of file.
111 EFI_FV_FILETYPE Type
;
113 /// Declares various file attribute bits.
115 EFI_FFS_FILE_ATTRIBUTES Attributes
;
117 /// The length of the file in bytes, including the FFS header.
121 /// Used to track the state of the file throughout the life of the file from creation to deletion.
123 EFI_FFS_FILE_STATE State
;
124 } EFI_FFS_FILE_HEADER
;
127 typedef UINT8 EFI_SECTION_TYPE
;
130 /// Pseudo type. It is
131 /// used as a wild card when retrieving sections. The section
132 /// type EFI_SECTION_ALL matches all section types.
134 #define EFI_SECTION_ALL 0x00
137 /// Encapsulation section Type values
139 #define EFI_SECTION_COMPRESSION 0x01
141 #define EFI_SECTION_GUID_DEFINED 0x02
144 /// Leaf section Type values
146 #define EFI_SECTION_PE32 0x10
147 #define EFI_SECTION_PIC 0x11
148 #define EFI_SECTION_TE 0x12
149 #define EFI_SECTION_DXE_DEPEX 0x13
150 #define EFI_SECTION_VERSION 0x14
151 #define EFI_SECTION_USER_INTERFACE 0x15
152 #define EFI_SECTION_COMPATIBILITY16 0x16
153 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
154 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
155 #define EFI_SECTION_RAW 0x19
156 #define EFI_SECTION_PEI_DEPEX 0x1B
159 /// Common section header
163 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
164 /// including the EFI_COMMON_SECTION_HEADER.
167 EFI_SECTION_TYPE Type
;
169 /// Declares the section type.
171 } EFI_COMMON_SECTION_HEADER
;
174 /// Leaf section type that contains an
175 /// IA-32 16-bit executable image.
177 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION
;
180 /// CompressionType of EFI_COMPRESSION_SECTION.
182 #define EFI_NOT_COMPRESSED 0x00
183 #define EFI_STANDARD_COMPRESSION 0x01
185 /// An encapsulation section type in which the
186 /// section data is compressed.
190 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
192 EFI_COMMON_SECTION_HEADER CommonHeader
;
194 /// UINT32 that indicates the size of the section data after decompression.
196 UINT32 UncompressedLength
;
198 /// Indicates which compression algorithm is used.
200 UINT8 CompressionType
;
201 } EFI_COMPRESSION_SECTION
;
204 /// An encapsulation section type in which the section data is disposable.
205 /// A disposable section is an encapsulation section in which the section data may be disposed of during
206 /// the process of creating or updating a firmware image without significant impact on the usefulness of
207 /// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This
208 /// allows optional or descriptive data to be included with the firmware file which can be removed in
209 /// order to conserve space. The contents of this section are implementation specific, but might contain
210 /// debug data or detailed integration instructions.
212 typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION
;
215 /// Leaf section which could be used to determine the dispatch order of DXEs.
217 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION
;
220 /// Leaf section which contains a PI FV.
222 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION
;
225 /// Leaf section which contains a single GUID.
229 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
231 EFI_COMMON_SECTION_HEADER CommonHeader
;
233 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
235 EFI_GUID SubTypeGuid
;
236 } EFI_FREEFORM_SUBTYPE_GUID_SECTION
;
239 /// Attributes of EFI_GUID_DEFINED_SECTION
241 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
242 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
244 /// Leaf section which is encapsulation defined by specific GUID
248 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
250 EFI_COMMON_SECTION_HEADER CommonHeader
;
252 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
254 EFI_GUID SectionDefinitionGuid
;
256 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
260 /// Bit field that declares some specific characteristics of the section contents.
263 } EFI_GUID_DEFINED_SECTION
;
266 /// Leaf section which contains PE32+ image.
268 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION
;
272 /// Leaf section which used to determine the dispatch order of PEIMs.
274 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION
;
277 /// Leaf section which constains the position-independent-code image.
279 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION
;
282 /// Leaf section which contains an array of zero or more bytes.
284 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION
;
287 /// Leaf section which contains a unicode string that
288 /// is human readable file name.
291 EFI_COMMON_SECTION_HEADER CommonHeader
;
294 /// Array of unicode string.
296 CHAR16 FileNameString
[1];
297 } EFI_USER_INTERFACE_SECTION
;
301 /// Leaf section which contains a numeric build number and
302 /// an optional unicode string that represents the file revision.
305 EFI_COMMON_SECTION_HEADER CommonHeader
;
309 /// Array of unicode string.
311 CHAR16 VersionString
[1];
312 } EFI_VERSION_SECTION
;
315 #define SECTION_SIZE(SectionHeaderPtr) \
316 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))