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