]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Include/Common/PiFirmwareFile.h
Check In tool source code based on Build tool project revision r1655.
[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 - 2008, Intel Corporation All rights reserved.
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_FIRMWARE_VOLUME_IMAGE 0x0B
54 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
55 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
56 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
57 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
58 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
59 #define EFI_FV_FILETYPE_FFS_MAX 0xff
60 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
61 //
62 // FFS File Attributes.
63 //
64 #define FFS_ATTRIB_FIXED 0x04
65 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
66 #define FFS_ATTRIB_CHECKSUM 0x40
67 //
68 // FFS_FIXED_CHECKSUM is the default checksum value used when the
69 // FFS_ATTRIB_CHECKSUM attribute bit is clear
70 // note this is NOT an architecturally defined value, but is in this file for
71 // implementation convenience
72 //
73 #define FFS_FIXED_CHECKSUM 0x5A
74
75 //
76 // FFS File State Bits.
77 //
78 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
79 #define EFI_FILE_HEADER_VALID 0x02
80 #define EFI_FILE_DATA_VALID 0x04
81 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
82 #define EFI_FILE_DELETED 0x10
83 #define EFI_FILE_HEADER_INVALID 0x20
84
85 #define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \
86 EFI_FILE_HEADER_VALID | \
87 EFI_FILE_DATA_VALID | \
88 EFI_FILE_MARKED_FOR_UPDATE | \
89 EFI_FILE_DELETED | \
90 EFI_FILE_HEADER_INVALID \
91 )
92
93 //
94 // Each file begins with the header that describe the
95 // contents and state of the files.
96 //
97 typedef struct {
98 EFI_GUID Name;
99 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
100 EFI_FV_FILETYPE Type;
101 EFI_FFS_FILE_ATTRIBUTES Attributes;
102 UINT8 Size[3];
103 EFI_FFS_FILE_STATE State;
104 } EFI_FFS_FILE_HEADER;
105
106
107 typedef UINT8 EFI_SECTION_TYPE;
108
109 //
110 // Pseudo type. It is
111 // used as a wild card when retrieving sections. The section
112 // type EFI_SECTION_ALL matches all section types.
113 //
114 #define EFI_SECTION_ALL 0x00
115
116 //
117 // Encapsulation section Type values
118 //
119 #define EFI_SECTION_COMPRESSION 0x01
120
121 #define EFI_SECTION_GUID_DEFINED 0x02
122
123 //
124 // Leaf section Type values
125 //
126 #define EFI_SECTION_PE32 0x10
127 #define EFI_SECTION_PIC 0x11
128 #define EFI_SECTION_TE 0x12
129 #define EFI_SECTION_DXE_DEPEX 0x13
130 #define EFI_SECTION_VERSION 0x14
131 #define EFI_SECTION_USER_INTERFACE 0x15
132 #define EFI_SECTION_COMPATIBILITY16 0x16
133 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
134 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
135 #define EFI_SECTION_RAW 0x19
136 #define EFI_SECTION_PEI_DEPEX 0x1B
137
138 typedef struct {
139 UINT8 Size[3];
140 EFI_SECTION_TYPE Type;
141 } EFI_COMMON_SECTION_HEADER;
142
143 //
144 // Leaf section type that contains an
145 // IA-32 16-bit executable image.
146 //
147 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
148
149 //
150 // CompressionType of EFI_COMPRESSION_SECTION.
151 //
152 #define EFI_NOT_COMPRESSED 0x00
153 #define EFI_STANDARD_COMPRESSION 0x01
154 //
155 // An encapsulation section type in which the
156 // section data is compressed.
157 //
158 typedef struct {
159 EFI_COMMON_SECTION_HEADER CommonHeader;
160 UINT32 UncompressedLength;
161 UINT8 CompressionType;
162 } EFI_COMPRESSION_SECTION;
163
164 //
165 // Leaf section which could be used to determine the dispatch order of DXEs.
166 //
167 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
168
169 //
170 // Leaf section witch contains a PI FV.
171 //
172 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
173
174 //
175 // Leaf section which contains a single GUID.
176 //
177 typedef struct {
178 EFI_COMMON_SECTION_HEADER CommonHeader;
179 EFI_GUID SubTypeGuid;
180 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
181
182 //
183 // Attributes of EFI_GUID_DEFINED_SECTION
184 //
185 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
186 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
187 //
188 // Leaf section which is encapsulation defined by specific GUID
189 //
190 typedef struct {
191 EFI_COMMON_SECTION_HEADER CommonHeader;
192 EFI_GUID SectionDefinitionGuid;
193 UINT16 DataOffset;
194 UINT16 Attributes;
195 } EFI_GUID_DEFINED_SECTION;
196
197 //
198 // Leaf section which contains PE32+ image.
199 //
200 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
201
202 //
203 // Leaf section which contains PIC image.
204 //
205 typedef EFI_COMMON_SECTION_HEADER EFI_PIC_SECTION;
206
207 //
208 // Leaf section which used to determine the dispatch order of PEIMs.
209 //
210 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
211
212 //
213 // Leaf section which constains the position-independent-code image.
214 //
215 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
216
217 //
218 // Leaf section which contains an array of zero or more bytes.
219 //
220 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
221
222 //
223 // Leaf section which contains a unicode string that
224 // is human readable file name.
225 //
226 typedef struct {
227 EFI_COMMON_SECTION_HEADER CommonHeader;
228
229 //
230 // Array of unicode string.
231 //
232 CHAR16 FileNameString[1];
233 } EFI_USER_INTERFACE_SECTION;
234
235
236 //
237 // Leaf section which contains a numeric build number and
238 // an optional unicode string that represent the file revision.
239 //
240 typedef struct {
241 EFI_COMMON_SECTION_HEADER CommonHeader;
242 UINT16 BuildNumber;
243 CHAR16 VersionString[1];
244 } EFI_VERSION_SECTION;
245
246
247 #define SECTION_SIZE(SectionHeaderPtr) \
248 ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
249
250 #pragma pack()
251
252 typedef union {
253 EFI_COMMON_SECTION_HEADER *CommonHeader;
254 EFI_COMPRESSION_SECTION *CompressionSection;
255 EFI_GUID_DEFINED_SECTION *GuidDefinedSection;
256 EFI_PE32_SECTION *Pe32Section;
257 EFI_PIC_SECTION *PicSection;
258 EFI_TE_SECTION *TeSection;
259 EFI_PEI_DEPEX_SECTION *PeimHeaderSection;
260 EFI_DXE_DEPEX_SECTION *DependencySection;
261 EFI_VERSION_SECTION *VersionSection;
262 EFI_USER_INTERFACE_SECTION *UISection;
263 EFI_COMPATIBILITY16_SECTION *Code16Section;
264 EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
265 EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
266 EFI_RAW_SECTION *RawSection;
267 } EFI_FILE_SECTION_POINTER;
268
269 #endif
270