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