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