BaseTools: Clear build versions to sync with buildtools/BaseTools
[mirror_edk2.git] / BaseTools / Source / C / Include / Common / PiFirmwareFile.h
1 /** @file
2 The firmware file related definitions in PI.
3
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at:
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 File Name: PiFirmwareFile.h
15
16 @par Revision Reference:
17 Version 1.0.
18
19 **/
20
21 #ifndef __PI_FIRMWARE_FILE_H__
22 #define __PI_FIRMWARE_FILE_H__
23
24 #pragma pack(1)
25 //
26 // Used to verify the integrity of the file.
27 //
28 typedef union {
29 struct {
30 UINT8 Header;
31 UINT8 File;
32 } Checksum;
33 UINT16 Checksum16;
34 } EFI_FFS_INTEGRITY_CHECK;
35
36 typedef UINT8 EFI_FV_FILETYPE;
37 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
38 typedef UINT8 EFI_FFS_FILE_STATE;
39
40 //
41 // File Types Definitions
42 //
43 #define EFI_FV_FILETYPE_ALL 0x00
44 #define EFI_FV_FILETYPE_RAW 0x01
45 #define EFI_FV_FILETYPE_FREEFORM 0x02
46 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
47 #define EFI_FV_FILETYPE_PEI_CORE 0x04
48 #define EFI_FV_FILETYPE_DXE_CORE 0x05
49 #define EFI_FV_FILETYPE_PEIM 0x06
50 #define EFI_FV_FILETYPE_DRIVER 0x07
51 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
52 #define EFI_FV_FILETYPE_APPLICATION 0x09
53 #define EFI_FV_FILETYPE_SMM 0x0A
54 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
55 #define EFI_FV_FILETYPE_COMBINED_SMM_DXE 0x0C
56 #define EFI_FV_FILETYPE_SMM_CORE 0x0D
57 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
58 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
59 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
60 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
61 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
62 #define EFI_FV_FILETYPE_FFS_MAX 0xff
63 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
64 //
65 // FFS File Attributes.
66 //
67 #define FFS_ATTRIB_LARGE_FILE 0x01
68 #define FFS_ATTRIB_FIXED 0x04
69 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
70 #define FFS_ATTRIB_CHECKSUM 0x40
71 //
72 // FFS_FIXED_CHECKSUM is the checksum value used when the
73 // FFS_ATTRIB_CHECKSUM attribute bit is clear
74 //
75 #define FFS_FIXED_CHECKSUM 0xAA
76
77 //
78 // FFS File State Bits.
79 //
80 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
81 #define EFI_FILE_HEADER_VALID 0x02
82 #define EFI_FILE_DATA_VALID 0x04
83 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
84 #define EFI_FILE_DELETED 0x10
85 #define EFI_FILE_HEADER_INVALID 0x20
86
87 #define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \
88 EFI_FILE_HEADER_VALID | \
89 EFI_FILE_DATA_VALID | \
90 EFI_FILE_MARKED_FOR_UPDATE | \
91 EFI_FILE_DELETED | \
92 EFI_FILE_HEADER_INVALID \
93 )
94
95 //
96 // Each file begins with the header that describe the
97 // contents and state of the files.
98 //
99 typedef struct {
100 EFI_GUID Name;
101 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
102 EFI_FV_FILETYPE Type;
103 EFI_FFS_FILE_ATTRIBUTES Attributes;
104 UINT8 Size[3];
105 EFI_FFS_FILE_STATE State;
106 } EFI_FFS_FILE_HEADER;
107
108 typedef struct {
109 EFI_GUID Name;
110 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
111 EFI_FV_FILETYPE Type;
112 EFI_FFS_FILE_ATTRIBUTES Attributes;
113 UINT8 Size[3];
114 EFI_FFS_FILE_STATE State;
115 UINT32 ExtendedSize;
116 } EFI_FFS_FILE_HEADER2;
117
118 #define MAX_FFS_SIZE 0x1000000
119
120 typedef UINT8 EFI_SECTION_TYPE;
121
122 //
123 // Pseudo type. It is
124 // used as a wild card when retrieving sections. The section
125 // type EFI_SECTION_ALL matches all section types.
126 //
127 #define EFI_SECTION_ALL 0x00
128
129 //
130 // Encapsulation section Type values
131 //
132 #define EFI_SECTION_COMPRESSION 0x01
133
134 #define EFI_SECTION_GUID_DEFINED 0x02
135
136 //
137 // Leaf section Type values
138 //
139 #define EFI_SECTION_PE32 0x10
140 #define EFI_SECTION_PIC 0x11
141 #define EFI_SECTION_TE 0x12
142 #define EFI_SECTION_DXE_DEPEX 0x13
143 #define EFI_SECTION_VERSION 0x14
144 #define EFI_SECTION_USER_INTERFACE 0x15
145 #define EFI_SECTION_COMPATIBILITY16 0x16
146 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
147 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
148 #define EFI_SECTION_RAW 0x19
149 #define EFI_SECTION_PEI_DEPEX 0x1B
150 #define EFI_SECTION_SMM_DEPEX 0x1C
151
152 typedef struct {
153 UINT8 Size[3];
154 EFI_SECTION_TYPE Type;
155 } EFI_COMMON_SECTION_HEADER;
156
157 typedef struct {
158 UINT8 Size[3];
159 EFI_SECTION_TYPE Type;
160 UINT32 ExtendedSize;
161 } EFI_COMMON_SECTION_HEADER2;
162
163 #define MAX_SECTION_SIZE 0x1000000
164
165 //
166 // Leaf section type that contains an
167 // IA-32 16-bit executable image.
168 //
169 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
170 typedef EFI_COMMON_SECTION_HEADER2 EFI_COMPATIBILITY16_SECTION2;
171
172 //
173 // CompressionType of EFI_COMPRESSION_SECTION.
174 //
175 #define EFI_NOT_COMPRESSED 0x00
176 #define EFI_STANDARD_COMPRESSION 0x01
177 //
178 // An encapsulation section type in which the
179 // section data is compressed.
180 //
181 typedef struct {
182 EFI_COMMON_SECTION_HEADER CommonHeader;
183 UINT32 UncompressedLength;
184 UINT8 CompressionType;
185 } EFI_COMPRESSION_SECTION;
186
187 typedef struct {
188 EFI_COMMON_SECTION_HEADER2 CommonHeader;
189 UINT32 UncompressedLength;
190 UINT8 CompressionType;
191 } EFI_COMPRESSION_SECTION2;
192
193 //
194 // Leaf section which could be used to determine the dispatch order of DXEs.
195 //
196 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
197 typedef EFI_COMMON_SECTION_HEADER2 EFI_DXE_DEPEX_SECTION2;
198
199 //
200 // Leaf section witch contains a PI FV.
201 //
202 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
203 typedef EFI_COMMON_SECTION_HEADER2 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2;
204
205 //
206 // Leaf section which contains a single GUID.
207 //
208 typedef struct {
209 EFI_COMMON_SECTION_HEADER CommonHeader;
210 EFI_GUID SubTypeGuid;
211 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
212
213 typedef struct {
214 EFI_COMMON_SECTION_HEADER2 CommonHeader;
215 EFI_GUID SubTypeGuid;
216 } EFI_FREEFORM_SUBTYPE_GUID_SECTION2;
217
218 //
219 // Attributes of EFI_GUID_DEFINED_SECTION
220 //
221 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
222 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
223 //
224 // Leaf section which is encapsulation defined by specific GUID
225 //
226 typedef struct {
227 EFI_COMMON_SECTION_HEADER CommonHeader;
228 EFI_GUID SectionDefinitionGuid;
229 UINT16 DataOffset;
230 UINT16 Attributes;
231 } EFI_GUID_DEFINED_SECTION;
232
233 typedef struct {
234 EFI_COMMON_SECTION_HEADER2 CommonHeader;
235 EFI_GUID SectionDefinitionGuid;
236 UINT16 DataOffset;
237 UINT16 Attributes;
238 } EFI_GUID_DEFINED_SECTION2;
239
240 //
241 // Leaf section which contains PE32+ image.
242 //
243 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
244 typedef EFI_COMMON_SECTION_HEADER2 EFI_PE32_SECTION2;
245
246 //
247 // Leaf section which contains PIC image.
248 //
249 typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;
250 typedef EFI_COMMON_SECTION_HEADER2 EFI_PIC_SECTION2;
251
252 //
253 // Leaf section which used to determine the dispatch order of PEIMs.
254 //
255 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
256 typedef EFI_COMMON_SECTION_HEADER2 EFI_PEI_DEPEX_SECTION2;
257
258 //
259 // Leaf section which constains the position-independent-code image.
260 //
261 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
262 typedef EFI_COMMON_SECTION_HEADER2 EFI_TE_SECTION2;
263
264 //
265 // Leaf section which contains an array of zero or more bytes.
266 //
267 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
268 typedef EFI_COMMON_SECTION_HEADER2 EFI_RAW_SECTION2;
269
270 //
271 // Leaf section which contains a unicode string that
272 // is human readable file name.
273 //
274 typedef struct {
275 EFI_COMMON_SECTION_HEADER CommonHeader;
276
277 //
278 // Array of unicode string.
279 //
280 CHAR16 FileNameString[1];
281 } EFI_USER_INTERFACE_SECTION;
282
283 typedef struct {
284 EFI_COMMON_SECTION_HEADER2 CommonHeader;
285
286 //
287 // Array of unicode string.
288 //
289 CHAR16 FileNameString[1];
290 } EFI_USER_INTERFACE_SECTION2;
291
292 //
293 // Leaf section which contains a numeric build number and
294 // an optional unicode string that represent the file revision.
295 //
296 typedef struct {
297 EFI_COMMON_SECTION_HEADER CommonHeader;
298 UINT16 BuildNumber;
299 CHAR16 VersionString[1];
300 } EFI_VERSION_SECTION;
301
302 typedef struct {
303 EFI_COMMON_SECTION_HEADER2 CommonHeader;
304 UINT16 BuildNumber;
305 CHAR16 VersionString[1];
306 } EFI_VERSION_SECTION2;
307
308 #define SECTION_SIZE(SectionHeaderPtr) \
309 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
310
311 #pragma pack()
312
313 typedef union {
314 EFI_COMMON_SECTION_HEADER *CommonHeader;
315 EFI_COMPRESSION_SECTION *CompressionSection;
316 EFI_GUID_DEFINED_SECTION *GuidDefinedSection;
317 EFI_PE32_SECTION *Pe32Section;
318 EFI_PIC_SECTION *PicSection;
319 EFI_TE_SECTION *TeSection;
320 EFI_PEI_DEPEX_SECTION *PeimHeaderSection;
321 EFI_DXE_DEPEX_SECTION *DependencySection;
322 EFI_VERSION_SECTION *VersionSection;
323 EFI_USER_INTERFACE_SECTION *UISection;
324 EFI_COMPATIBILITY16_SECTION *Code16Section;
325 EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
326 EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
327 EFI_RAW_SECTION *RawSection;
328 //
329 // For section whose size is equal or greater than 0x1000000
330 //
331 EFI_COMMON_SECTION_HEADER2 *CommonHeader2;
332 EFI_COMPRESSION_SECTION2 *CompressionSection2;
333 EFI_GUID_DEFINED_SECTION2 *GuidDefinedSection2;
334 EFI_PE32_SECTION2 *Pe32Section2;
335 EFI_PIC_SECTION2 *PicSection2;
336 EFI_TE_SECTION2 *TeSection2;
337 EFI_PEI_DEPEX_SECTION2 *PeimHeaderSection2;
338 EFI_DXE_DEPEX_SECTION2 *DependencySection2;
339 EFI_VERSION_SECTION2 *VersionSection2;
340 EFI_USER_INTERFACE_SECTION2 *UISection2;
341 EFI_COMPATIBILITY16_SECTION2 *Code16Section2;
342 EFI_FIRMWARE_VOLUME_IMAGE_SECTION2 *FVImageSection2;
343 EFI_FREEFORM_SUBTYPE_GUID_SECTION2 *FreeformSubtypeSection2;
344 EFI_RAW_SECTION2 *RawSection2;
345 } EFI_FILE_SECTION_POINTER;
346
347 #endif
348