Porting SecMain module for Nt32Pkg, but not enable PI, so it currently dependent...
[mirror_edk2.git] / MdePkg / Include / Pi / PiFirmwareFile.h
1 /** @file
2 The firmware file related definitions in PI.
3
4 Copyright (c) 2006 - 2007, 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 Version 1.0.
15
16 **/
17
18 #ifndef __PI_FIRMWARE_FILE_H__
19 #define __PI_FIRMWARE_FILE_H__
20
21 //
22 // Used to verify the integrity of the file.
23 //
24 typedef union {
25 struct {
26 UINT8 Header;
27 UINT8 File;
28 } Checksum;
29 UINT16 Checksum16;
30 } EFI_FFS_INTEGRITY_CHECK;
31
32 typedef UINT8 EFI_FV_FILETYPE;
33
34 #define EFI_FV_FILETYPE_ALL 0x00
35 #define EFI_FV_FILETYPE_RAW 0x01
36 #define EFI_FV_FILETYPE_FREEFORM 0x02
37 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
38 #define EFI_FV_FILETYPE_PEI_CORE 0x04
39 #define EFI_FV_FILETYPE_DXE_CORE 0x05
40 #define EFI_FV_FILETYPE_PEIM 0x06
41 #define EFI_FV_FILETYPE_DRIVER 0x07
42 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
43 #define EFI_FV_FILETYPE_APPLICATION 0x09
44 //
45 // File type 0x0A is reserved and should not be used
46 //
47 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
48
49 typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
50 typedef UINT8 EFI_FFS_FILE_STATE;
51
52 //
53 // File Types Definitions
54 //
55 #define EFI_FV_FILETYPE_RAW 0x01
56 #define EFI_FV_FILETYPE_FREEFORM 0x02
57 #define EFI_FV_FILETYPE_SECURITY_CORE 0x03
58 #define EFI_FV_FILETYPE_PEI_CORE 0x04
59 #define EFI_FV_FILETYPE_DXE_CORE 0x05
60 #define EFI_FV_FILETYPE_PEIM 0x06
61 #define EFI_FV_FILETYPE_DRIVER 0x07
62 #define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
63 #define EFI_FV_FILETYPE_APPLICATION 0x09
64 #define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
65 #define EFI_FV_FILETYPE_OEM_MIN 0xc0
66 #define EFI_FV_FILETYPE_OEM_MAX 0xdf
67 #define EFI_FV_FILETYPE_DEBUG_MIN 0xe0
68 #define EFI_FV_FILETYPE_DEBUG_MAX 0xef
69 #define EFI_FV_FILETYPE_FFS_MIN 0xf0
70 #define EFI_FV_FILETYPE_FFS_MAX 0xff
71 #define EFI_FV_FILETYPE_FFS_PAD 0xf0
72 //
73 // FFS File Attributes.
74 //
75 #define FFS_ATTRIB_FIXED 0x04
76 #define FFS_ATTRIB_DATA_ALIGNMENT 0x38
77 #define FFS_ATTRIB_CHECKSUM 0x40
78
79 //
80 // FFS File State Bits.
81 //
82 #define EFI_FILE_HEADER_CONSTRUCTION 0x01
83 #define EFI_FILE_HEADER_VALID 0x02
84 #define EFI_FILE_DATA_VALID 0x04
85 #define EFI_FILE_MARKED_FOR_UPDATE 0x08
86 #define EFI_FILE_DELETED 0x10
87 #define EFI_FILE_HEADER_INVALID 0x20
88
89
90 //
91 // Each file begins with the header that describe the
92 // contents and state of the files.
93 //
94 typedef struct {
95 EFI_GUID Name;
96 EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
97 EFI_FV_FILETYPE Type;
98 EFI_FFS_FILE_ATTRIBUTES Attributes;
99 UINT8 Size[3];
100 EFI_FFS_FILE_STATE State;
101 } EFI_FFS_FILE_HEADER;
102
103
104 typedef UINT8 EFI_SECTION_TYPE;
105
106 //
107 // Pseudo type. It is
108 // used as a wild card when retrieving sections. The section
109 // type EFI_SECTION_ALL matches all section types.
110 //
111 #define EFI_SECTION_ALL 0x00
112
113 //
114 // Encapsulation section Type values
115 //
116 #define EFI_SECTION_COMPRESSION 0x01
117
118 #define EFI_SECTION_GUID_DEFINED 0x02
119
120 //
121 // Leaf section Type values
122 //
123 #define EFI_SECTION_PE32 0x10
124 #define EFI_SECTION_PIC 0x11
125 #define EFI_SECTION_TE 0x12
126 #define EFI_SECTION_DXE_DEPEX 0x13
127 #define EFI_SECTION_VERSION 0x14
128 #define EFI_SECTION_USER_INTERFACE 0x15
129 #define EFI_SECTION_COMPATIBILITY16 0x16
130 #define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
131 #define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
132 #define EFI_SECTION_RAW 0x19
133 #define EFI_SECTION_PEI_DEPEX 0x1B
134
135 typedef struct {
136 UINT8 Size[3];
137 EFI_SECTION_TYPE Type;
138 } EFI_COMMON_SECTION_HEADER;
139
140 //
141 // Leaf section type that contains an
142 // IA-32 16-bit executable image.
143 //
144 typedef EFI_COMMON_SECTION_HEADER EFI_COMPATIBILITY16_SECTION;
145
146 //
147 // CompressionType of EFI_COMPRESSION_SECTION.
148 //
149 #define EFI_NOT_COMPRESSED 0x00
150 #define EFI_STANDARD_COMPRESSION 0x01
151 //
152 // An encapsulation section type in which the
153 // section data is compressed.
154 //
155 typedef struct {
156 EFI_COMMON_SECTION_HEADER CommonHeader;
157 UINT32 UncompressedLength;
158 UINT8 CompressionType;
159 } EFI_COMPRESSION_SECTION;
160
161 //
162 // Leaf section which could be used to determine the dispatch order of DXEs.
163 //
164 typedef EFI_COMMON_SECTION_HEADER EFI_DXE_DEPEX_SECTION;
165
166 //
167 // Leaf section witch contains a PI FV.
168 //
169 typedef EFI_COMMON_SECTION_HEADER EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
170
171 //
172 // Leaf section which contains a single GUID.
173 //
174 typedef struct {
175 EFI_COMMON_SECTION_HEADER CommonHeader;
176 EFI_GUID SubTypeGuid;
177 } EFI_FREEFORM_SUBTYPE_GUID_SECTION;
178
179 //
180 // Attributes of EFI_GUID_DEFINED_SECTION
181 //
182 #define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
183 #define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
184 //
185 // Leaf section which is encapsulation defined by specific GUID
186 //
187 typedef struct {
188 EFI_COMMON_SECTION_HEADER CommonHeader;
189 EFI_GUID SectionDefinitionGuid;
190 UINT16 DataOffset;
191 UINT16 Attributes;
192 } EFI_GUID_DEFINED_SECTION;
193
194 //
195 // Leaf section which contains PE32+ image.
196 //
197 typedef EFI_COMMON_SECTION_HEADER EFI_PE32_SECTION;
198
199
200 //
201 // Leaf section which used to determine the dispatch order of PEIMs.
202 //
203 typedef EFI_COMMON_SECTION_HEADER EFI_PEI_DEPEX_SECTION;
204
205 //
206 // Leaf section which constains the position-independent-code image.
207 //
208 typedef EFI_COMMON_SECTION_HEADER EFI_TE_SECTION;
209
210 //
211 // Leaf section which contains an array of zero or more bytes.
212 //
213 typedef EFI_COMMON_SECTION_HEADER EFI_RAW_SECTION;
214
215 //
216 // Leaf section which contains a unicode string that
217 // is human readable file name.
218 //
219 typedef struct {
220 EFI_COMMON_SECTION_HEADER CommonHeader;
221
222 //
223 // Array of unicode string.
224 //
225 CHAR16 FileNameString[1];
226 } EFI_USER_INTERFACE_SECTION;
227
228
229 //
230 // Leaf section which contains a numeric build number and
231 // an optional unicode string that represent the file revision.
232 //
233 typedef struct {
234 EFI_COMMON_SECTION_HEADER CommonHeader;
235 UINT16 BuildNumber;
236 CHAR16 VersionString[1];
237 } EFI_VERSION_SECTION;
238
239 #endif
240