]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Pi/PiFirmwareFile.h
Add related definitions support large file.
[mirror_edk2.git] / MdePkg / Include / Pi / PiFirmwareFile.h
CommitLineData
959ccb23 1/** @file\r
2 The firmware file related definitions in PI.\r
3\r
d7dfd027 4 Copyright (c) 2006 - 2009, Intel Corporation \r
959ccb23 5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
959ccb23 13 @par Revision Reference:\r
0047820e 14 PI Version 1.0\r
959ccb23 15\r
16**/\r
17\r
0b3cac32 18\r
959ccb23 19#ifndef __PI_FIRMWARE_FILE_H__\r
20#define __PI_FIRMWARE_FILE_H__\r
21\r
62d1e08b 22#pragma pack(1)\r
dc53faa3 23///\r
24/// Used to verify the integrity of the file.\r
25/// \r
959ccb23 26typedef union {\r
27 struct {\r
1bf79370
LG
28 ///\r
29 /// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file\r
30 /// header. The State and IntegrityCheck.Checksum.File fields are assumed\r
31 /// to be zero and the checksum is calculated such that the entire header sums to zero.\r
32 ///\r
959ccb23 33 UINT8 Header;\r
1bf79370
LG
34 ///\r
35 /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes\r
36 /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit\r
37 /// checksum of the entire file The State field and the file tail are assumed to be zero\r
38 /// and the checksum is calculated such that the entire file sums to zero.\r
39 /// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,\r
40 /// the IntegrityCheck.Checksum.File field must be initialized with a value of\r
41 /// 0x55AA. The IntegrityCheck.Checksum.File field is valid any time the\r
42 /// EFI_FILE_DATA_VALID bit is set in the State field.\r
43 ///\r
959ccb23 44 UINT8 File;\r
45 } Checksum;\r
1bf79370
LG
46 ///\r
47 /// This is the full 16 bits of the IntegrityCheck field.\r
48 ///\r
959ccb23 49 UINT16 Checksum16;\r
50} EFI_FFS_INTEGRITY_CHECK;\r
51\r
52typedef UINT8 EFI_FV_FILETYPE;\r
53typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;\r
54typedef UINT8 EFI_FFS_FILE_STATE;\r
55\r
dc53faa3 56///\r
57/// File Types Definitions\r
58/// \r
d44d2087 59#define EFI_FV_FILETYPE_ALL 0x00\r
8fb30482 60#define EFI_FV_FILETYPE_RAW 0x01\r
61#define EFI_FV_FILETYPE_FREEFORM 0x02\r
62#define EFI_FV_FILETYPE_SECURITY_CORE 0x03\r
63#define EFI_FV_FILETYPE_PEI_CORE 0x04\r
64#define EFI_FV_FILETYPE_DXE_CORE 0x05\r
65#define EFI_FV_FILETYPE_PEIM 0x06\r
66#define EFI_FV_FILETYPE_DRIVER 0x07\r
67#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08\r
68#define EFI_FV_FILETYPE_APPLICATION 0x09\r
69#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B\r
70#define EFI_FV_FILETYPE_OEM_MIN 0xc0\r
71#define EFI_FV_FILETYPE_OEM_MAX 0xdf\r
72#define EFI_FV_FILETYPE_DEBUG_MIN 0xe0\r
73#define EFI_FV_FILETYPE_DEBUG_MAX 0xef\r
74#define EFI_FV_FILETYPE_FFS_MIN 0xf0\r
75#define EFI_FV_FILETYPE_FFS_MAX 0xff\r
76#define EFI_FV_FILETYPE_FFS_PAD 0xf0\r
dc53faa3 77/// \r
78/// FFS File Attributes.\r
79/// \r
3d4d4cfa 80#define FFS_ATTRIB_LARGE_FILE 0x01\r
959ccb23 81#define FFS_ATTRIB_FIXED 0x04\r
82#define FFS_ATTRIB_DATA_ALIGNMENT 0x38\r
83#define FFS_ATTRIB_CHECKSUM 0x40\r
84\r
dc53faa3 85/// \r
86/// FFS File State Bits.\r
87/// \r
959ccb23 88#define EFI_FILE_HEADER_CONSTRUCTION 0x01\r
89#define EFI_FILE_HEADER_VALID 0x02\r
90#define EFI_FILE_DATA_VALID 0x04\r
91#define EFI_FILE_MARKED_FOR_UPDATE 0x08\r
92#define EFI_FILE_DELETED 0x10\r
93#define EFI_FILE_HEADER_INVALID 0x20\r
94\r
95\r
dc53faa3 96///\r
97/// Each file begins with the header that describe the \r
98/// contents and state of the files.\r
99/// \r
959ccb23 100typedef struct {\r
1bf79370
LG
101 ///\r
102 /// This GUID is the file name. It is used to uniquely identify the file.\r
103 ///\r
959ccb23 104 EFI_GUID Name;\r
1bf79370
LG
105 ///\r
106 /// Used to verify the integrity of the file.\r
107 ///\r
959ccb23 108 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;\r
1bf79370
LG
109 ///\r
110 /// Identifies the type of file.\r
111 ///\r
959ccb23 112 EFI_FV_FILETYPE Type;\r
1bf79370
LG
113 ///\r
114 /// Declares various file attribute bits.\r
115 ///\r
959ccb23 116 EFI_FFS_FILE_ATTRIBUTES Attributes;\r
1bf79370
LG
117 ///\r
118 /// The length of the file in bytes, including the FFS header.\r
119 ///\r
959ccb23 120 UINT8 Size[3];\r
1bf79370
LG
121 ///\r
122 /// Used to track the state of the file throughout the life of the file from creation to deletion.\r
123 ///\r
959ccb23 124 EFI_FFS_FILE_STATE State;\r
125} EFI_FFS_FILE_HEADER;\r
126\r
3d4d4cfa 127typedef struct {\r
128 ///\r
129 /// This GUID is the file name. It is used to uniquely identify the file. There may be only\r
130 /// one instance of a file with the file name GUID of Name in any given firmware\r
131 /// volume, except if the file type is EFI_FV_FILETYPE_FFS_PAD.\r
132 ///\r
133 EFI_GUID Name;\r
134 \r
135 ///\r
136 /// Used to verify the integrity of the file.\r
137 /// \r
138 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;\r
139 \r
140 ///\r
141 /// Identifies the type of file.\r
142 /// \r
143 EFI_FV_FILETYPE Type;\r
144 \r
145 ///\r
146 /// Declares various file attribute bits.\r
147 /// \r
148 EFI_FFS_FILE_ATTRIBUTES Attributes;\r
149 \r
150 ///\r
151 /// The length of the file in bytes, including the FFS header.\r
152 /// The length of the file data is either (Size - sizeof(EFI_FFS_FILE_HEADER)). This calculation means a\r
153 /// zero-length file has a Size of 24 bytes, which is sizeof(EFI_FFS_FILE_HEADER).\r
154 /// Size is not required to be a multiple of 8 bytes. Given a file F, the next file header is\r
155 /// located at the next 8-byte aligned firmware volume offset following the last byte of the file F.\r
156 ///\r
157 UINT8 Size[3];\r
158 \r
159 ///\r
160 /// Used to track the state of the file throughout the life of the file from creation to deletion.\r
161 ///\r
162 EFI_FFS_FILE_STATE State;\r
163 \r
164 ///\r
165 /// If FFS_ATTRIB_LARGE_FILE is set in Attributes then ExtendedSize exists and Size must be set to zero.\r
166 /// If FFS_ATTRIB_LARGE_FILE is not set then EFI_FFS_FILE_HEADER is used.\r
167 ///\r
168 EFI_FFS_FILE_STATE ExtendedSize;\r
169} EFI_FFS_FILE_HEADER2;\r
959ccb23 170\r
171typedef UINT8 EFI_SECTION_TYPE;\r
172\r
dc53faa3 173///\r
174/// Pseudo type. It is\r
175/// used as a wild card when retrieving sections. The section\r
176/// type EFI_SECTION_ALL matches all section types.\r
177///\r
959ccb23 178#define EFI_SECTION_ALL 0x00\r
179\r
dc53faa3 180///\r
181/// Encapsulation section Type values\r
182///\r
959ccb23 183#define EFI_SECTION_COMPRESSION 0x01\r
184\r
185#define EFI_SECTION_GUID_DEFINED 0x02\r
186\r
3d4d4cfa 187#define EFI_SECTION_DISPOSABLE 0x03\r
188\r
dc53faa3 189///\r
190/// Leaf section Type values\r
191///\r
959ccb23 192#define EFI_SECTION_PE32 0x10\r
193#define EFI_SECTION_PIC 0x11\r
194#define EFI_SECTION_TE 0x12\r
195#define EFI_SECTION_DXE_DEPEX 0x13\r
196#define EFI_SECTION_VERSION 0x14\r
197#define EFI_SECTION_USER_INTERFACE 0x15\r
198#define EFI_SECTION_COMPATIBILITY16 0x16\r
199#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17\r
200#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18\r
201#define EFI_SECTION_RAW 0x19\r
202#define EFI_SECTION_PEI_DEPEX 0x1B\r
3d4d4cfa 203#define EFI_SECTION_SMM_DEPEX 0x1C\r
959ccb23 204\r
dc53faa3 205///\r
206/// Common section header\r
207/// \r
959ccb23 208typedef struct {\r
1bf79370
LG
209 ///\r
210 /// A 24-bit unsigned integer that contains the total size of the section in bytes, \r
211 /// including the EFI_COMMON_SECTION_HEADER.\r
212 ///\r
959ccb23 213 UINT8 Size[3];\r
214 EFI_SECTION_TYPE Type;\r
1bf79370
LG
215 ///\r
216 /// Declares the section type.\r
217 ///\r
959ccb23 218} EFI_COMMON_SECTION_HEADER;\r
219\r
3d4d4cfa 220typedef struct {\r
221 ///\r
222 /// A 24-bit unsigned integer that contains the total size of the section in bytes, \r
223 /// including the EFI_COMMON_SECTION_HEADER.\r
224 ///\r
225 UINT8 Size[3];\r
226 \r
227 EFI_SECTION_TYPE Type;\r
228 \r
229 ///\r
230 /// If Size is 0xFFFFFF then ExtendedSize contains the size of the section. If\r
231 /// Size is not equal to 0xFFFFFF then this field does not exist. \r
232 ///\r
233 UINT32 ExtendedSize;\r
234} EFI_COMMON_SECTION_HEADER2;\r
235\r
dc53faa3 236///\r
237/// Leaf section type that contains an \r
238/// IA-32 16-bit executable image.\r
239/// \r
3d4d4cfa 240typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;\r
241typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;\r
959ccb23 242\r
dc53faa3 243///\r
244/// CompressionType of EFI_COMPRESSION_SECTION.\r
245/// \r
959ccb23 246#define EFI_NOT_COMPRESSED 0x00\r
247#define EFI_STANDARD_COMPRESSION 0x01\r
dc53faa3 248///\r
249/// An encapsulation section type in which the \r
250/// section data is compressed.\r
251/// \r
959ccb23 252typedef struct {\r
1bf79370
LG
253 ///\r
254 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.\r
255 ///\r
00edb218 256 EFI_COMMON_SECTION_HEADER CommonHeader;\r
1bf79370
LG
257 ///\r
258 /// UINT32 that indicates the size of the section data after decompression.\r
259 ///\r
00edb218 260 UINT32 UncompressedLength;\r
1bf79370
LG
261 ///\r
262 /// Indicates which compression algorithm is used.\r
263 ///\r
00edb218 264 UINT8 CompressionType;\r
959ccb23 265} EFI_COMPRESSION_SECTION;\r
266\r
3d4d4cfa 267typedef struct {\r
268 ///\r
269 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.\r
270 ///\r
271 EFI_COMMON_SECTION_HEADER2 CommonHeader;\r
272 ///\r
273 /// UINT32 that indicates the size of the section data after decompression.\r
274 ///\r
275 UINT32 UncompressedLength;\r
276 ///\r
277 /// Indicates which compression algorithm is used.\r
278 ///\r
279 UINT8 CompressionType;\r
280} EFI_COMPRESSION_SECTION2;\r
281\r
73d622ed 282///\r
283/// An encapsulation section type in which the section data is disposable.\r
284/// A disposable section is an encapsulation section in which the section data may be disposed of during\r
285/// the process of creating or updating a firmware image without significant impact on the usefulness of\r
286/// the file. The Type field in the section header is set to EFI_SECTION_DISPOSABLE. This\r
287/// allows optional or descriptive data to be included with the firmware file which can be removed in\r
288/// order to conserve space. The contents of this section are implementation specific, but might contain\r
289/// debug data or detailed integration instructions.\r
290///\r
3d4d4cfa 291typedef EFI_COMMON_SECTION_HEADER EFI_DISPOSABLE_SECTION;\r
292typedef EFI_COMMON_SECTION_HEADER2 EFI_DISPOSABLE_SECTION2;\r
73d622ed 293\r
dc53faa3 294///\r
295/// Leaf section which could be used to determine the dispatch order of DXEs.\r
296/// \r
3d4d4cfa 297typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;\r
298typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;\r
959ccb23 299\r
dc53faa3 300///\r
4b503a77 301/// Leaf section which contains a PI FV.\r
dc53faa3 302/// \r
3d4d4cfa 303typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;\r
304typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;\r
959ccb23 305\r
dc53faa3 306///\r
307/// Leaf section which contains a single GUID.\r
308/// \r
959ccb23 309typedef struct {\r
1bf79370
LG
310 ///\r
311 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.\r
312 ///\r
00edb218 313 EFI_COMMON_SECTION_HEADER CommonHeader;\r
1bf79370
LG
314 ///\r
315 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.\r
316 ///\r
00edb218 317 EFI_GUID SubTypeGuid;\r
959ccb23 318} EFI_FREEFORM_SUBTYPE_GUID_SECTION;\r
319\r
3d4d4cfa 320typedef struct {\r
321 ///\r
322 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.\r
323 ///\r
324 EFI_COMMON_SECTION_HEADER2 CommonHeader;\r
325 ///\r
326 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.\r
327 /// \r
328 EFI_GUID SubTypeGuid;\r
329} EFI_FREEFORM_SUBTYPE_GUID_SECTION2;\r
330\r
dc53faa3 331///\r
332/// Attributes of EFI_GUID_DEFINED_SECTION\r
333/// \r
959ccb23 334#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01\r
335#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02\r
dc53faa3 336///\r
337/// Leaf section which is encapsulation defined by specific GUID\r
338/// \r
959ccb23 339typedef struct {\r
1bf79370
LG
340 ///\r
341 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.\r
342 ///\r
00edb218 343 EFI_COMMON_SECTION_HEADER CommonHeader;\r
1bf79370
LG
344 ///\r
345 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.\r
346 ///\r
00edb218 347 EFI_GUID SectionDefinitionGuid;\r
1bf79370
LG
348 ///\r
349 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.\r
350 ///\r
00edb218 351 UINT16 DataOffset;\r
1bf79370
LG
352 ///\r
353 /// Bit field that declares some specific characteristics of the section contents.\r
354 ///\r
00edb218 355 UINT16 Attributes;\r
959ccb23 356} EFI_GUID_DEFINED_SECTION;\r
357\r
3d4d4cfa 358typedef struct {\r
359 ///\r
360 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.\r
361 ///\r
362 EFI_COMMON_SECTION_HEADER2 CommonHeader;\r
363 ///\r
364 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.\r
365 /// \r
366 EFI_GUID SectionDefinitionGuid;\r
367 ///\r
368 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.\r
369 /// \r
370 UINT16 DataOffset;\r
371 ///\r
372 /// Bit field that declares some specific characteristics of the section contents.\r
373 /// \r
374 UINT16 Attributes;\r
375} EFI_GUID_DEFINED_SECTION2;\r
376\r
dc53faa3 377///\r
378/// Leaf section which contains PE32+ image.\r
379/// \r
3d4d4cfa 380typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;\r
381typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;\r
959ccb23 382\r
dc53faa3 383///\r
384/// Leaf section which used to determine the dispatch order of PEIMs.\r
385/// \r
3d4d4cfa 386typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;\r
387typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;\r
388\r
389///\r
390/// A leaf section type that contains a position-independent-code (PIC) image.\r
391/// A PIC image section is a leaf section that contains a position-independent-code (PIC) image.\r
392/// In addition to normal PE32+ images that contain relocation information, PEIM executables may be\r
393/// PIC and are referred to as PIC images. A PIC image is the same as a PE32+ image except that all\r
394/// relocation information has been stripped from the image and the image can be moved and will\r
395/// execute correctly without performing any relocation or other fix-ups. EFI_PIC_SECTION2 must\r
396/// be used if the section is 16MB or larger.\r
397///\r
398typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;\r
399typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;\r
959ccb23 400\r
dc53faa3 401///\r
402/// Leaf section which constains the position-independent-code image.\r
403/// \r
3d4d4cfa 404typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;\r
405typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;\r
959ccb23 406\r
dc53faa3 407///\r
408/// Leaf section which contains an array of zero or more bytes.\r
409/// \r
3d4d4cfa 410typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;\r
411typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;\r
412\r
413/// \r
414/// The SMM dependency expression section is a leaf section that contains a dependency expression that\r
415/// is used to determine the dispatch order for SMM drivers. Before the SMRAM invocation of the\r
416/// SMM driver's entry point, this dependency expression must evaluate to TRUE. See the Platform\r
417/// Initialization Specification, Volume 2for details regarding the format of the dependency expression.\r
418/// The dependency expression may refer to protocols installed in either the UEFI or the SMM protocol\r
419/// database. EFI_SMM_DEPEX_SECTION2 must be used if the section is 16MB or larger.\r
420/// \r
421typedef EFI_COMMON_SECTION_HEADER EFI_SMM_DEPEX_SECTION;\r
422typedef EFI_COMMON_SECTION_HEADER2 EFI_SMM_DEPEX_SECTION2;\r
959ccb23 423\r
dc53faa3 424///\r
425/// Leaf section which contains a unicode string that \r
426/// is human readable file name.\r
427/// \r
959ccb23 428typedef struct {\r
00edb218 429 EFI_COMMON_SECTION_HEADER CommonHeader;\r
959ccb23 430\r
dc53faa3 431 ///\r
432 /// Array of unicode string.\r
433 /// \r
00edb218 434 CHAR16 FileNameString[1];\r
959ccb23 435} EFI_USER_INTERFACE_SECTION;\r
436\r
3d4d4cfa 437typedef struct {\r
438 EFI_COMMON_SECTION_HEADER2 CommonHeader;\r
439 CHAR16 FileNameString[1];\r
440} EFI_USER_INTERFACE_SECTION2;\r
959ccb23 441\r
dc53faa3 442///\r
443/// Leaf section which contains a numeric build number and\r
4b503a77 444/// an optional unicode string that represents the file revision. \r
dc53faa3 445/// \r
959ccb23 446typedef struct {\r
00edb218
A
447 EFI_COMMON_SECTION_HEADER CommonHeader;\r
448 UINT16 BuildNumber;\r
7b1bf9f6 449\r
450 ///\r
451 /// Array of unicode string.\r
452 /// \r
00edb218 453 CHAR16 VersionString[1];\r
959ccb23 454} EFI_VERSION_SECTION;\r
455\r
3d4d4cfa 456typedef struct {\r
457 EFI_COMMON_SECTION_HEADER2 CommonHeader;\r
458 ///\r
459 /// A UINT16 that represents a particular build. Subsequent builds have monotonically\r
460 /// increasing build numbers relative to earlier builds.\r
461 ///\r
462 UINT16 BuildNumber;\r
463 CHAR16 VersionString[1];\r
464} EFI_VERSION_SECTION2;\r
ddd3f471 465\r
466#define SECTION_SIZE(SectionHeaderPtr) \\r
467 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))\r
468\r
62d1e08b 469#pragma pack()\r
ddd3f471 470\r
959ccb23 471#endif\r
472\r