]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiFirmwareFile.h
Add related definitions support large file.
[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_LARGE_FILE 0x01
81 #define FFS_ATTRIB_FIXED 0x04
82 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
83 #define FFS_ATTRIB_CHECKSUM 0x40
84
85 ///
86 /// FFS File State Bits.
87 ///
88 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
89 #define EFI_FILE_HEADER_VALID 0x02
90 #define EFI_FILE_DATA_VALID 0x04
91 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
92 #define EFI_FILE_DELETED 0x10
93 #define EFI_FILE_HEADER_INVALID 0x20
94
95
96 ///
97 /// Each file begins with the header that describe the
98 /// contents and state of the files.
99 ///
100 typedef struct {
101 ///
102 /// This GUID is the file name. It is used to uniquely identify the file.
103 ///
104 EFI_GUID Name;
105 ///
106 /// Used to verify the integrity of the file.
107 ///
108 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
109 ///
110 /// Identifies the type of file.
111 ///
112 EFI_FV_FILETYPE Type;
113 ///
114 /// Declares various file attribute bits.
115 ///
116 EFI_FFS_FILE_ATTRIBUTES Attributes;
117 ///
118 /// The length of the file in bytes, including the FFS header.
119 ///
120 UINT8 Size[3];
121 ///
122 /// Used to track the state of the file throughout the life of the file from creation to deletion.
123 ///
124 EFI_FFS_FILE_STATE State;
125 } EFI_FFS_FILE_HEADER;
126
127 typedef struct {
128 ///
129 /// This GUID is the file name. It is used to uniquely identify the file. There may be only
130 /// one instance of a file with the file name GUID of Name in any given firmware
131 /// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD.
132 ///
133 EFI_GUID Name;
134
135 ///
136 /// Used to verify the integrity of the file.
137 ///
138 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
139
140 ///
141 /// Identifies the type of file.
142 ///
143 EFI_FV_FILETYPE Type;
144
145 ///
146 /// Declares various file attribute bits.
147 ///
148 EFI_FFS_FILE_ATTRIBUTES Attributes;
149
150 ///
151 /// The length of the file in bytes, including the FFS header.
152 /// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a
153 /// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).
154 /// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is
155 /// located at the next 8-byte aligned firmware volume offset following the last byte of the file F.
156 ///
157 UINT8 Size[3];
158
159 ///
160 /// Used to track the state of the file throughout the life of the file from creation to deletion.
161 ///
162 EFI_FFS_FILE_STATE State;
163
164 ///
165 /// If FFS_ATTRIB_LARGE_FILE is set in Attributes then ExtendedSize exists and Size must be set to zero.
166 /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.
167 ///
168 EFI_FFS_FILE_STATE ExtendedSize;
169 } EFI_FFS_FILE_HEADER2;
170
171 typedef UINT8 EFI_SECTION_TYPE;
172
173 ///
174 /// Pseudo type. It is
175 /// used as a wild card when retrieving sections. The section
176 /// type EFI_SECTION_ALL matches all section types.
177 ///
178 #define EFI_SECTION_ALL 0x00
179
180 ///
181 /// Encapsulation section Type values
182 ///
183 #define EFI_SECTION_COMPRESSION 0x01
184
185 #define EFI_SECTION_GUID_DEFINED 0x02
186
187 #define EFI_SECTION_DISPOSABLE 0x03
188
189 ///
190 /// Leaf section Type values
191 ///
192 #define EFI_SECTION_PE32 0x10
193 #define EFI_SECTION_PIC 0x11
194 #define EFI_SECTION_TE 0x12
195 #define EFI_SECTION_DXE_DEPEX 0x13
196 #define EFI_SECTION_VERSION 0x14
197 #define EFI_SECTION_USER_INTERFACE 0x15
198 #define EFI_SECTION_COMPATIBILITY16 0x16
199 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
200 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
201 #define EFI_SECTION_RAW 0x19
202 #define EFI_SECTION_PEI_DEPEX 0x1B
203 #define EFI_SECTION_SMM_DEPEX 0x1C
204
205 ///
206 /// Common section header
207 ///
208 typedef struct {
209 ///
210 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
211 /// including the EFI_COMMON_SECTION_HEADER.
212 ///
213 UINT8 Size[3];
214 EFI_SECTION_TYPE Type;
215 ///
216 /// Declares the section type.
217 ///
218 } EFI_COMMON_SECTION_HEADER;
219
220 typedef struct {
221 ///
222 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
223 /// including the EFI_COMMON_SECTION_HEADER.
224 ///
225 UINT8 Size[3];
226
227 EFI_SECTION_TYPE Type;
228
229 ///
230 /// If Size is 0xFFFFFF then ExtendedSize contains the size of the section. If
231 /// Size is not equal to 0xFFFFFF then this field does not exist.
232 ///
233 UINT32 ExtendedSize;
234 } EFI_COMMON_SECTION_HEADER2;
235
236 ///
237 /// Leaf section type that contains an
238 /// IA-32 16-bit executable image.
239 ///
240 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
241 typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;
242
243 ///
244 /// CompressionType of EFI_COMPRESSION_SECTION.
245 ///
246 #define EFI_NOT_COMPRESSED 0x00
247 #define EFI_STANDARD_COMPRESSION 0x01
248 ///
249 /// An encapsulation section type in which the
250 /// section data is compressed.
251 ///
252 typedef struct {
253 ///
254 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
255 ///
256 EFI_COMMON_SECTION_HEADER CommonHeader;
257 ///
258 /// UINT32 that indicates the size of the section data after decompression.
259 ///
260 UINT32 UncompressedLength;
261 ///
262 /// Indicates which compression algorithm is used.
263 ///
264 UINT8 CompressionType;
265 } EFI_COMPRESSION_SECTION;
266
267 typedef struct {
268 ///
269 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
270 ///
271 EFI_COMMON_SECTION_HEADER2 CommonHeader;
272 ///
273 /// UINT32 that indicates the size of the section data after decompression.
274 ///
275 UINT32 UncompressedLength;
276 ///
277 /// Indicates which compression algorithm is used.
278 ///
279 UINT8 CompressionType;
280 } EFI_COMPRESSION_SECTION2;
281
282 ///
283 /// An encapsulation section type in which the section data is disposable.
284 /// A disposable section is an encapsulation section in which the section data may be disposed of during
285 /// the process of creating or updating a firmware image without significant impact on the usefulness of
286 /// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This
287 /// allows optional or descriptive data to be included with the firmware file which can be removed in
288 /// order to conserve space. The contents of this section are implementation specific, but might contain
289 /// debug data or detailed integration instructions.
290 ///
291 typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION;
292 typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2;
293
294 ///
295 /// Leaf section which could be used to determine the dispatch order of DXEs.
296 ///
297 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
298 typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;
299
300 ///
301 /// Leaf section which contains a PI FV.
302 ///
303 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
304 typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;
305
306 ///
307 /// Leaf section which contains a single GUID.
308 ///
309 typedef struct {
310 ///
311 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
312 ///
313 EFI_COMMON_SECTION_HEADER CommonHeader;
314 ///
315 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
316 ///
317 EFI_GUID SubTypeGuid;
318 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
319
320 typedef struct {
321 ///
322 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
323 ///
324 EFI_COMMON_SECTION_HEADER2 CommonHeader;
325 ///
326 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
327 ///
328 EFI_GUID SubTypeGuid;
329 } EFI_FREEFORM_SUBTYPE_GUID_SECTION2;
330
331 ///
332 /// Attributes of EFI_GUID_DEFINED_SECTION
333 ///
334 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
335 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
336 ///
337 /// Leaf section which is encapsulation defined by specific GUID
338 ///
339 typedef struct {
340 ///
341 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
342 ///
343 EFI_COMMON_SECTION_HEADER CommonHeader;
344 ///
345 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
346 ///
347 EFI_GUID SectionDefinitionGuid;
348 ///
349 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
350 ///
351 UINT16 DataOffset;
352 ///
353 /// Bit field that declares some specific characteristics of the section contents.
354 ///
355 UINT16 Attributes;
356 } EFI_GUID_DEFINED_SECTION;
357
358 typedef struct {
359 ///
360 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
361 ///
362 EFI_COMMON_SECTION_HEADER2 CommonHeader;
363 ///
364 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
365 ///
366 EFI_GUID SectionDefinitionGuid;
367 ///
368 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
369 ///
370 UINT16 DataOffset;
371 ///
372 /// Bit field that declares some specific characteristics of the section contents.
373 ///
374 UINT16 Attributes;
375 } EFI_GUID_DEFINED_SECTION2;
376
377 ///
378 /// Leaf section which contains PE32+ image.
379 ///
380 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
381 typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;
382
383 ///
384 /// Leaf section which used to determine the dispatch order of PEIMs.
385 ///
386 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
387 typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;
388
389 ///
390 /// A leaf section type that contains a position-independent-code (PIC) image.
391 /// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.
392 /// In addition to normal PE32+ images that contain relocation information, PEIM executables may be
393 /// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all
394 /// relocation information has been stripped from the image and the image can be moved and will
395 /// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must
396 /// be used if the section is 16MB or larger.
397 ///
398 typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;
399 typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;
400
401 ///
402 /// Leaf section which constains the position-independent-code image.
403 ///
404 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
405 typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;
406
407 ///
408 /// Leaf section which contains an array of zero or more bytes.
409 ///
410 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
411 typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;
412
413 ///
414 /// The SMM dependency expression section is a leaf section that contains a dependency expression that
415 /// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the
416 /// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform
417 /// Initialization Specification, Volume 2for details regarding the format of the dependency expression.
418 /// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol
419 /// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger.
420 ///
421 typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION;
422 typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2;
423
424 ///
425 /// Leaf section which contains a unicode string that
426 /// is human readable file name.
427 ///
428 typedef struct {
429 EFI_COMMON_SECTION_HEADER CommonHeader;
430
431 ///
432 /// Array of unicode string.
433 ///
434 CHAR16 FileNameString[1];
435 } EFI_USER_INTERFACE_SECTION;
436
437 typedef struct {
438 EFI_COMMON_SECTION_HEADER2 CommonHeader;
439 CHAR16 FileNameString[1];
440 } EFI_USER_INTERFACE_SECTION2;
441
442 ///
443 /// Leaf section which contains a numeric build number and
444 /// an optional unicode string that represents the file revision.
445 ///
446 typedef struct {
447 EFI_COMMON_SECTION_HEADER CommonHeader;
448 UINT16 BuildNumber;
449
450 ///
451 /// Array of unicode string.
452 ///
453 CHAR16 VersionString[1];
454 } EFI_VERSION_SECTION;
455
456 typedef struct {
457 EFI_COMMON_SECTION_HEADER2 CommonHeader;
458 ///
459 /// A UINT16 that represents a particular build. Subsequent builds have monotonically
460 /// increasing build numbers relative to earlier builds.
461 ///
462 UINT16 BuildNumber;
463 CHAR16 VersionString[1];
464 } EFI_VERSION_SECTION2;
465
466 #define SECTION_SIZE(SectionHeaderPtr) \
467 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
468
469 #pragma pack()
470
471 #endif
472