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