2 The firmware file related definitions in PI.
4 Copyright (c) 2006 - 2008, 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__
22 #include <ProcessorBind.h>
26 /// Used to verify the integrity of the file.
31 /// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file
32 /// header. The State and IntegrityCheck.Checksum.File fields are assumed
33 /// to be zero and the checksum is calculated such that the entire header sums to zero.
37 /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes
38 /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit
39 /// checksum of the entire file The State field and the file tail are assumed to be zero
40 /// and the checksum is calculated such that the entire file sums to zero.
41 /// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,
42 /// the IntegrityCheck.Checksum.File field must be initialized with a value of
43 /// 0x55AA. The IntegrityCheck.Checksum.File field is valid any time the
44 /// EFI_FILE_DATA_VALID bit is set in the State field.
49 /// This is the full 16 bits of the IntegrityCheck field.
52 } EFI_FFS_INTEGRITY_CHECK
;
54 typedef UINT8 EFI_FV_FILETYPE
;
55 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES
;
56 typedef UINT8 EFI_FFS_FILE_STATE
;
59 /// File Types Definitions
61 #define EFI_FV_FILETYPE_ALL 0x00
62 #define EFI_FV_FILETYPE_RAW 0x01
63 #define EFI_FV_FILETYPE_FREEFORM 0x02
64 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
65 #define EFI_FV_FILETYPE_PEI_CORE 0x04
66 #define EFI_FV_FILETYPE_DXE_CORE 0x05
67 #define EFI_FV_FILETYPE_PEIM 0x06
68 #define EFI_FV_FILETYPE_DRIVER 0x07
69 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
70 #define EFI_FV_FILETYPE_APPLICATION 0x09
71 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
72 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
73 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
74 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
75 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
76 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
77 #define EFI_FV_FILETYPE_FFS_MAX 0xff
78 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
80 /// FFS File Attributes.
82 #define FFS_ATTRIB_FIXED 0x04
83 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
84 #define FFS_ATTRIB_CHECKSUM 0x40
87 /// FFS File State Bits.
89 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
90 #define EFI_FILE_HEADER_VALID 0x02
91 #define EFI_FILE_DATA_VALID 0x04
92 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
93 #define EFI_FILE_DELETED 0x10
94 #define EFI_FILE_HEADER_INVALID 0x20
98 /// Each file begins with the header that describe the
99 /// contents and state of the files.
103 /// This GUID is the file name. It is used to uniquely identify the file.
107 /// Used to verify the integrity of the file.
109 EFI_FFS_INTEGRITY_CHECK IntegrityCheck
;
111 /// Identifies the type of file.
113 EFI_FV_FILETYPE Type
;
115 /// Declares various file attribute bits.
117 EFI_FFS_FILE_ATTRIBUTES Attributes
;
119 /// The length of the file in bytes, including the FFS header.
123 /// Used to track the state of the file throughout the life of the file from creation to deletion.
125 EFI_FFS_FILE_STATE State
;
126 } EFI_FFS_FILE_HEADER
;
129 typedef UINT8 EFI_SECTION_TYPE
;
132 /// Pseudo type. It is
133 /// used as a wild card when retrieving sections. The section
134 /// type EFI_SECTION_ALL matches all section types.
136 #define EFI_SECTION_ALL 0x00
139 /// Encapsulation section Type values
141 #define EFI_SECTION_COMPRESSION 0x01
143 #define EFI_SECTION_GUID_DEFINED 0x02
146 /// Leaf section Type values
148 #define EFI_SECTION_PE32 0x10
149 #define EFI_SECTION_PIC 0x11
150 #define EFI_SECTION_TE 0x12
151 #define EFI_SECTION_DXE_DEPEX 0x13
152 #define EFI_SECTION_VERSION 0x14
153 #define EFI_SECTION_USER_INTERFACE 0x15
154 #define EFI_SECTION_COMPATIBILITY16 0x16
155 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
156 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
157 #define EFI_SECTION_RAW 0x19
158 #define EFI_SECTION_PEI_DEPEX 0x1B
161 /// Common section header
165 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
166 /// including the EFI_COMMON_SECTION_HEADER.
169 EFI_SECTION_TYPE Type
;
171 /// Declares the section type.
173 } EFI_COMMON_SECTION_HEADER
;
176 /// Leaf section type that contains an
177 /// IA-32 16-bit executable image.
179 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION
;
182 /// CompressionType of EFI_COMPRESSION_SECTION.
184 #define EFI_NOT_COMPRESSED 0x00
185 #define EFI_STANDARD_COMPRESSION 0x01
187 /// An encapsulation section type in which the
188 /// section data is compressed.
192 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
194 EFI_COMMON_SECTION_HEADER CommonHeader
;
196 /// UINT32 that indicates the size of the section data after decompression.
198 UINT32 UncompressedLength
;
200 /// Indicates which compression algorithm is used.
202 UINT8 CompressionType
;
203 } EFI_COMPRESSION_SECTION
;
206 /// Leaf section which could be used to determine the dispatch order of DXEs.
208 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION
;
211 /// Leaf section which contains a PI FV.
213 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION
;
216 /// Leaf section which contains a single GUID.
220 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
222 EFI_COMMON_SECTION_HEADER CommonHeader
;
224 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
226 EFI_GUID SubTypeGuid
;
227 } EFI_FREEFORM_SUBTYPE_GUID_SECTION
;
230 /// Attributes of EFI_GUID_DEFINED_SECTION
232 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
233 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
235 /// Leaf section which is encapsulation defined by specific GUID
239 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
241 EFI_COMMON_SECTION_HEADER CommonHeader
;
243 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
245 EFI_GUID SectionDefinitionGuid
;
247 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
251 /// Bit field that declares some specific characteristics of the section contents.
254 } EFI_GUID_DEFINED_SECTION
;
257 /// Leaf section which contains PE32+ image.
259 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION
;
263 /// Leaf section which used to determine the dispatch order of PEIMs.
265 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION
;
268 /// Leaf section which constains the position-independent-code image.
270 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION
;
273 /// Leaf section which contains an array of zero or more bytes.
275 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION
;
278 /// Leaf section which contains a unicode string that
279 /// is human readable file name.
282 EFI_COMMON_SECTION_HEADER CommonHeader
;
285 /// Array of unicode string.
287 CHAR16 FileNameString
[1];
288 } EFI_USER_INTERFACE_SECTION
;
292 /// Leaf section which contains a numeric build number and
293 /// an optional unicode string that represents the file revision.
296 EFI_COMMON_SECTION_HEADER CommonHeader
;
300 /// Array of unicode string.
302 CHAR16 VersionString
[1];
303 } EFI_VERSION_SECTION
;
306 #define SECTION_SIZE(SectionHeaderPtr) \
307 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))