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