]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Pi/PiFirmwareFile.h
Add comments for enumeration, structure data members those are referred by UefiServic...
[mirror_edk2.git] / MdePkg / Include / Pi / PiFirmwareFile.h
1 /** @file
2 The firmware file related definitions in PI.
3
4 Copyright (c) 2006 - 2008, 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 #include <ProcessorBind.h>
23
24 #pragma pack(1)
25 ///
26 /// Used to verify the integrity of the file.
27 ///
28 typedef union {
29 struct {
30 ///
31 /// The IntegrityCheck.Checksum.Header field is an 8-bit checksum of the file
32 /// header. The State and IntegrityCheck.Checksum.File fields are assumed
33 /// to be zero and the checksum is calculated such that the entire header sums to zero.
34 ///
35 UINT8 Header;
36 ///
37 /// If the FFS_ATTRIB_CHECKSUM (see definition below) bit of the Attributes
38 /// field is set to one, the IntegrityCheck.Checksum.File field is an 8-bit
39 /// checksum of the entire file The State field and the file tail are assumed to be zero
40 /// and the checksum is calculated such that the entire file sums to zero.
41 /// If the FFS_ATTRIB_CHECKSUM bit of the Attributes field is cleared to zero,
42 /// the IntegrityCheck.Checksum.File field must be initialized with a value of
43 /// 0x55AA. The IntegrityCheck.Checksum.File field is valid any time the
44 /// EFI_FILE_DATA_VALID bit is set in the State field.
45 ///
46 UINT8 File;
47 } Checksum;
48 ///
49 /// This is the full 16 bits of the IntegrityCheck field.
50 ///
51 UINT16 Checksum16;
52 } EFI_FFS_INTEGRITY_CHECK;
53
54 typedef UINT8 EFI_FV_FILETYPE;
55 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
56 typedef UINT8 EFI_FFS_FILE_STATE;
57
58 ///
59 /// File Types Definitions
60 ///
61 #define EFI_FV_FILETYPE_ALL 0x00
62 #define EFI_FV_FILETYPE_RAW 0x01
63 #define EFI_FV_FILETYPE_FREEFORM 0x02
64 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
65 #define EFI_FV_FILETYPE_PEI_CORE 0x04
66 #define EFI_FV_FILETYPE_DXE_CORE 0x05
67 #define EFI_FV_FILETYPE_PEIM 0x06
68 #define EFI_FV_FILETYPE_DRIVER 0x07
69 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
70 #define EFI_FV_FILETYPE_APPLICATION 0x09
71 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
72 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
73 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
74 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
75 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
76 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
77 #define EFI_FV_FILETYPE_FFS_MAX 0xff
78 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
79 ///
80 /// FFS File Attributes.
81 ///
82 #define FFS_ATTRIB_FIXED 0x04
83 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
84 #define FFS_ATTRIB_CHECKSUM 0x40
85
86 ///
87 /// FFS File State Bits.
88 ///
89 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
90 #define EFI_FILE_HEADER_VALID 0x02
91 #define EFI_FILE_DATA_VALID 0x04
92 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
93 #define EFI_FILE_DELETED 0x10
94 #define EFI_FILE_HEADER_INVALID 0x20
95
96
97 ///
98 /// Each file begins with the header that describe the
99 /// contents and state of the files.
100 ///
101 typedef struct {
102 ///
103 /// This GUID is the file name. It is used to uniquely identify the file.
104 ///
105 EFI_GUID Name;
106 ///
107 /// Used to verify the integrity of the file.
108 ///
109 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
110 ///
111 /// Identifies the type of file.
112 ///
113 EFI_FV_FILETYPE Type;
114 ///
115 /// Declares various file attribute bits.
116 ///
117 EFI_FFS_FILE_ATTRIBUTES Attributes;
118 ///
119 /// The length of the file in bytes, including the FFS header.
120 ///
121 UINT8 Size[3];
122 ///
123 /// Used to track the state of the file throughout the life of the file from creation to deletion.
124 ///
125 EFI_FFS_FILE_STATE State;
126 } EFI_FFS_FILE_HEADER;
127
128
129 typedef UINT8 EFI_SECTION_TYPE;
130
131 ///
132 /// Pseudo type. It is
133 /// used as a wild card when retrieving sections. The section
134 /// type EFI_SECTION_ALL matches all section types.
135 ///
136 #define EFI_SECTION_ALL 0x00
137
138 ///
139 /// Encapsulation section Type values
140 ///
141 #define EFI_SECTION_COMPRESSION 0x01
142
143 #define EFI_SECTION_GUID_DEFINED 0x02
144
145 ///
146 /// Leaf section Type values
147 ///
148 #define EFI_SECTION_PE32 0x10
149 #define EFI_SECTION_PIC 0x11
150 #define EFI_SECTION_TE 0x12
151 #define EFI_SECTION_DXE_DEPEX 0x13
152 #define EFI_SECTION_VERSION 0x14
153 #define EFI_SECTION_USER_INTERFACE 0x15
154 #define EFI_SECTION_COMPATIBILITY16 0x16
155 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
156 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
157 #define EFI_SECTION_RAW 0x19
158 #define EFI_SECTION_PEI_DEPEX 0x1B
159
160 ///
161 /// Common section header
162 ///
163 typedef struct {
164 ///
165 /// A 24-bit unsigned integer that contains the total size of the section in bytes,
166 /// including the EFI_COMMON_SECTION_HEADER.
167 ///
168 UINT8 Size[3];
169 EFI_SECTION_TYPE Type;
170 ///
171 /// Declares the section type.
172 ///
173 } EFI_COMMON_SECTION_HEADER;
174
175 ///
176 /// Leaf section type that contains an
177 /// IA-32 16-bit executable image.
178 ///
179 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
180
181 ///
182 /// CompressionType of EFI_COMPRESSION_SECTION.
183 ///
184 #define EFI_NOT_COMPRESSED 0x00
185 #define EFI_STANDARD_COMPRESSION 0x01
186 ///
187 /// An encapsulation section type in which the
188 /// section data is compressed.
189 ///
190 typedef struct {
191 ///
192 /// Usual common section header. CommonHeader.Type = EFI_SECTION_COMPRESSION.
193 ///
194 EFI_COMMON_SECTION_HEADER CommonHeader;
195 ///
196 /// UINT32 that indicates the size of the section data after decompression.
197 ///
198 UINT32 UncompressedLength;
199 ///
200 /// Indicates which compression algorithm is used.
201 ///
202 UINT8 CompressionType;
203 } EFI_COMPRESSION_SECTION;
204
205 ///
206 /// Leaf section which could be used to determine the dispatch order of DXEs.
207 ///
208 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
209
210 ///
211 /// Leaf section which contains a PI FV.
212 ///
213 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
214
215 ///
216 /// Leaf section which contains a single GUID.
217 ///
218 typedef struct {
219 ///
220 /// Common section header. CommonHeader.Type = EFI_SECTION_FREEFORM_SUBTYPE_GUID.
221 ///
222 EFI_COMMON_SECTION_HEADER CommonHeader;
223 ///
224 /// This GUID is defined by the creator of the file. It is a vendor-defined file type.
225 ///
226 EFI_GUID SubTypeGuid;
227 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
228
229 ///
230 /// Attributes of EFI_GUID_DEFINED_SECTION
231 ///
232 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
233 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
234 ///
235 /// Leaf section which is encapsulation defined by specific GUID
236 ///
237 typedef struct {
238 ///
239 /// Common section header. CommonHeader.Type = EFI_SECTION_GUID_DEFINED.
240 ///
241 EFI_COMMON_SECTION_HEADER CommonHeader;
242 ///
243 /// GUID that defines the format of the data that follows. It is a vendor-defined section type.
244 ///
245 EFI_GUID SectionDefinitionGuid;
246 ///
247 /// Contains the offset in bytes from the beginning of the common header to the first byte of the data.
248 ///
249 UINT16 DataOffset;
250 ///
251 /// Bit field that declares some specific characteristics of the section contents.
252 ///
253 UINT16 Attributes;
254 } EFI_GUID_DEFINED_SECTION;
255
256 ///
257 /// Leaf section which contains PE32+ image.
258 ///
259 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
260
261
262 ///
263 /// Leaf section which used to determine the dispatch order of PEIMs.
264 ///
265 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
266
267 ///
268 /// Leaf section which constains the position-independent-code image.
269 ///
270 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
271
272 ///
273 /// Leaf section which contains an array of zero or more bytes.
274 ///
275 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
276
277 ///
278 /// Leaf section which contains a unicode string that
279 /// is human readable file name.
280 ///
281 typedef struct {
282 EFI_COMMON_SECTION_HEADER CommonHeader;
283
284 ///
285 /// Array of unicode string.
286 ///
287 CHAR16 FileNameString[1];
288 } EFI_USER_INTERFACE_SECTION;
289
290
291 ///
292 /// Leaf section which contains a numeric build number and
293 /// an optional unicode string that represents the file revision.
294 ///
295 typedef struct {
296 EFI_COMMON_SECTION_HEADER CommonHeader;
297 UINT16 BuildNumber;
298
299 ///
300 /// Array of unicode string.
301 ///
302 CHAR16 VersionString[1];
303 } EFI_VERSION_SECTION;
304
305
306 #define SECTION_SIZE(SectionHeaderPtr) \
307 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
308
309 #pragma pack()
310
311 #endif
312