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