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