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