]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiFirmwareFile.h
Add EFI_DISPOSABLE_SECTION type defined in PI 1.2 specification.
[mirror_edk2.git] / MdePkg / Include / Pi / PiFirmwareFile.h
1 /** @file
2 The firmware file related definitions in PI.
3
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
9
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.
12
13 @par Revision Reference:
14 PI Version 1.0
15
16 **/
17
18
19 #ifndef __PI_FIRMWARE_FILE_H__
20 #define __PI_FIRMWARE_FILE_H__
21
22 #pragma pack(1)
23 ///
24 /// Used to verify the integrity of the file.
25 ///
26 typedef union {
27 struct {
28 ///
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.
32 ///
33 UINT8 Header;
34 ///
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.
43 ///
44 UINT8 File;
45 } Checksum;
46 ///
47 /// This is the full 16 bits of the IntegrityCheck field.
48 ///
49 UINT16 Checksum16;
50 } EFI_FFS_INTEGRITY_CHECK;
51
52 typedef UINT8 EFI_FV_FILETYPE;
53 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
54 typedef UINT8 EFI_FFS_FILE_STATE;
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_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
77 ///
78 /// FFS File Attributes.
79 ///
80 #define FFS_ATTRIB_FIXED 0x04
81 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
82 #define FFS_ATTRIB_CHECKSUM 0x40
83
84 ///
85 /// FFS File State Bits.
86 ///
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
93
94
95 ///
96 /// Each file begins with the header that describe the
97 /// contents and state of the files.
98 ///
99 typedef struct {
100 ///
101 /// This GUID is the file name. It is used to uniquely identify the file.
102 ///
103 EFI_GUID Name;
104 ///
105 /// Used to verify the integrity of the file.
106 ///
107 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
108 ///
109 /// Identifies the type of file.
110 ///
111 EFI_FV_FILETYPE Type;
112 ///
113 /// Declares various file attribute bits.
114 ///
115 EFI_FFS_FILE_ATTRIBUTES Attributes;
116 ///
117 /// The length of the file in bytes, including the FFS header.
118 ///
119 UINT8 Size[3];
120 ///
121 /// Used to track the state of the file throughout the life of the file from creation to deletion.
122 ///
123 EFI_FFS_FILE_STATE State;
124 } EFI_FFS_FILE_HEADER;
125
126
127 typedef UINT8 EFI_SECTION_TYPE;
128
129 ///
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.
133 ///
134 #define EFI_SECTION_ALL 0x00
135
136 ///
137 /// Encapsulation section Type values
138 ///
139 #define EFI_SECTION_COMPRESSION 0x01
140
141 #define EFI_SECTION_GUID_DEFINED 0x02
142
143 ///
144 /// Leaf section Type values
145 ///
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
157
158 ///
159 /// Common section header
160 ///
161 typedef struct {
162 ///
163 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
164 /// including the EFI_COMMON_SECTION_HEADER.
165 ///
166 UINT8 Size[3];
167 EFI_SECTION_TYPE Type;
168 ///
169 /// Declares the section type.
170 ///
171 } EFI_COMMON_SECTION_HEADER;
172
173 ///
174 /// Leaf section type that contains an
175 /// IA-32 16-bit executable image.
176 ///
177 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
178
179 ///
180 /// CompressionType of EFI_COMPRESSION_SECTION.
181 ///
182 #define EFI_NOT_COMPRESSED 0x00
183 #define EFI_STANDARD_COMPRESSION 0x01
184 ///
185 /// An encapsulation section type in which the
186 /// section data is compressed.
187 ///
188 typedef struct {
189 ///
190 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
191 ///
192 EFI_COMMON_SECTION_HEADER CommonHeader;
193 ///
194 /// UINT32 that indicates the size of the section data after decompression.
195 ///
196 UINT32 UncompressedLength;
197 ///
198 /// Indicates which compression algorithm is used.
199 ///
200 UINT8 CompressionType;
201 } EFI_COMPRESSION_SECTION;
202
203 ///
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.
211 ///
212 typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION;
213
214 ///
215 /// Leaf section which could be used to determine the dispatch order of DXEs.
216 ///
217 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
218
219 ///
220 /// Leaf section which contains a PI FV.
221 ///
222 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
223
224 ///
225 /// Leaf section which contains a single GUID.
226 ///
227 typedef struct {
228 ///
229 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
230 ///
231 EFI_COMMON_SECTION_HEADER CommonHeader;
232 ///
233 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
234 ///
235 EFI_GUID SubTypeGuid;
236 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
237
238 ///
239 /// Attributes of EFI_GUID_DEFINED_SECTION
240 ///
241 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
242 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
243 ///
244 /// Leaf section which is encapsulation defined by specific GUID
245 ///
246 typedef struct {
247 ///
248 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
249 ///
250 EFI_COMMON_SECTION_HEADER CommonHeader;
251 ///
252 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
253 ///
254 EFI_GUID SectionDefinitionGuid;
255 ///
256 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
257 ///
258 UINT16 DataOffset;
259 ///
260 /// Bit field that declares some specific characteristics of the section contents.
261 ///
262 UINT16 Attributes;
263 } EFI_GUID_DEFINED_SECTION;
264
265 ///
266 /// Leaf section which contains PE32+ image.
267 ///
268 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
269
270
271 ///
272 /// Leaf section which used to determine the dispatch order of PEIMs.
273 ///
274 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
275
276 ///
277 /// Leaf section which constains the position-independent-code image.
278 ///
279 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
280
281 ///
282 /// Leaf section which contains an array of zero or more bytes.
283 ///
284 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
285
286 ///
287 /// Leaf section which contains a unicode string that
288 /// is human readable file name.
289 ///
290 typedef struct {
291 EFI_COMMON_SECTION_HEADER CommonHeader;
292
293 ///
294 /// Array of unicode string.
295 ///
296 CHAR16 FileNameString[1];
297 } EFI_USER_INTERFACE_SECTION;
298
299
300 ///
301 /// Leaf section which contains a numeric build number and
302 /// an optional unicode string that represents the file revision.
303 ///
304 typedef struct {
305 EFI_COMMON_SECTION_HEADER CommonHeader;
306 UINT16 BuildNumber;
307
308 ///
309 /// Array of unicode string.
310 ///
311 CHAR16 VersionString[1];
312 } EFI_VERSION_SECTION;
313
314
315 #define SECTION_SIZE(SectionHeaderPtr) \
316 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
317
318 #pragma pack()
319
320 #endif
321