blob: 0b0382671cc1617369cb085fab41e9a5d9fd691a [file] [log] [blame]
Ronak Kanabar1ae366f2023-06-07 01:21:56 +05301/** @file
2 The firmware volume related definitions in PI.
3
4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 @par Revision Reference:
8 PI Version 1.6
9
10**/
11
12#ifndef __PI_FIRMWAREVOLUME_H__
13#define __PI_FIRMWAREVOLUME_H__
14
15///
16/// EFI_FV_FILE_ATTRIBUTES
17///
18typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
19
20//
21// Value of EFI_FV_FILE_ATTRIBUTES.
22//
23#define EFI_FV_FILE_ATTRIB_ALIGNMENT 0x0000001F
24#define EFI_FV_FILE_ATTRIB_FIXED 0x00000100
25#define EFI_FV_FILE_ATTRIB_MEMORY_MAPPED 0x00000200
26
27///
28/// type of EFI FVB attribute
29///
30typedef UINT32 EFI_FVB_ATTRIBUTES_2;
31
32//
33// Attributes bit definitions
34//
35#define EFI_FVB2_READ_DISABLED_CAP 0x00000001
36#define EFI_FVB2_READ_ENABLED_CAP 0x00000002
37#define EFI_FVB2_READ_STATUS 0x00000004
38#define EFI_FVB2_WRITE_DISABLED_CAP 0x00000008
39#define EFI_FVB2_WRITE_ENABLED_CAP 0x00000010
40#define EFI_FVB2_WRITE_STATUS 0x00000020
41#define EFI_FVB2_LOCK_CAP 0x00000040
42#define EFI_FVB2_LOCK_STATUS 0x00000080
43#define EFI_FVB2_STICKY_WRITE 0x00000200
44#define EFI_FVB2_MEMORY_MAPPED 0x00000400
45#define EFI_FVB2_ERASE_POLARITY 0x00000800
46#define EFI_FVB2_READ_LOCK_CAP 0x00001000
47#define EFI_FVB2_READ_LOCK_STATUS 0x00002000
48#define EFI_FVB2_WRITE_LOCK_CAP 0x00004000
49#define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000
50#define EFI_FVB2_ALIGNMENT 0x001F0000
51#define EFI_FVB2_ALIGNMENT_1 0x00000000
52#define EFI_FVB2_ALIGNMENT_2 0x00010000
53#define EFI_FVB2_ALIGNMENT_4 0x00020000
54#define EFI_FVB2_ALIGNMENT_8 0x00030000
55#define EFI_FVB2_ALIGNMENT_16 0x00040000
56#define EFI_FVB2_ALIGNMENT_32 0x00050000
57#define EFI_FVB2_ALIGNMENT_64 0x00060000
58#define EFI_FVB2_ALIGNMENT_128 0x00070000
59#define EFI_FVB2_ALIGNMENT_256 0x00080000
60#define EFI_FVB2_ALIGNMENT_512 0x00090000
61#define EFI_FVB2_ALIGNMENT_1K 0x000A0000
62#define EFI_FVB2_ALIGNMENT_2K 0x000B0000
63#define EFI_FVB2_ALIGNMENT_4K 0x000C0000
64#define EFI_FVB2_ALIGNMENT_8K 0x000D0000
65#define EFI_FVB2_ALIGNMENT_16K 0x000E0000
66#define EFI_FVB2_ALIGNMENT_32K 0x000F0000
67#define EFI_FVB2_ALIGNMENT_64K 0x00100000
68#define EFI_FVB2_ALIGNMENT_128K 0x00110000
69#define EFI_FVB2_ALIGNMENT_256K 0x00120000
70#define EFI_FVB2_ALIGNMENT_512K 0x00130000
71#define EFI_FVB2_ALIGNMENT_1M 0x00140000
72#define EFI_FVB2_ALIGNMENT_2M 0x00150000
73#define EFI_FVB2_ALIGNMENT_4M 0x00160000
74#define EFI_FVB2_ALIGNMENT_8M 0x00170000
75#define EFI_FVB2_ALIGNMENT_16M 0x00180000
76#define EFI_FVB2_ALIGNMENT_32M 0x00190000
77#define EFI_FVB2_ALIGNMENT_64M 0x001A0000
78#define EFI_FVB2_ALIGNMENT_128M 0x001B0000
79#define EFI_FVB2_ALIGNMENT_256M 0x001C0000
80#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
81#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
82#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
83#define EFI_FVB2_WEAK_ALIGNMENT 0x80000000
84
85typedef struct {
86 ///
87 /// The number of sequential blocks which are of the same size.
88 ///
89 UINT32 NumBlocks;
90 ///
91 /// The size of the blocks.
92 ///
93 UINT32 Length;
94} EFI_FV_BLOCK_MAP_ENTRY;
95
96///
97/// Describes the features and layout of the firmware volume.
98///
99typedef struct {
100 ///
101 /// The first 16 bytes are reserved to allow for the reset vector of
102 /// processors whose reset vector is at address 0.
103 ///
104 UINT8 ZeroVector[16];
105 ///
106 /// Declares the file system with which the firmware volume is formatted.
107 ///
108 EFI_GUID FileSystemGuid;
109 ///
110 /// Length in bytes of the complete firmware volume, including the header.
111 ///
112 UINT64 FvLength;
113 ///
114 /// Set to EFI_FVH_SIGNATURE
115 ///
116 UINT32 Signature;
117 ///
118 /// Declares capabilities and power-on defaults for the firmware volume.
119 ///
120 EFI_FVB_ATTRIBUTES_2 Attributes;
121 ///
122 /// Length in bytes of the complete firmware volume header.
123 ///
124 UINT16 HeaderLength;
125 ///
126 /// A 16-bit checksum of the firmware volume header. A valid header sums to zero.
127 ///
128 UINT16 Checksum;
129 ///
130 /// Offset, relative to the start of the header, of the extended header
131 /// (EFI_FIRMWARE_VOLUME_EXT_HEADER) or zero if there is no extended header.
132 ///
133 UINT16 ExtHeaderOffset;
134 ///
135 /// This field must always be set to zero.
136 ///
137 UINT8 Reserved[1];
138 ///
139 /// Set to 2. Future versions of this specification may define new header fields and will
140 /// increment the Revision field accordingly.
141 ///
142 UINT8 Revision;
143 ///
144 /// An array of run-length encoded FvBlockMapEntry structures. The array is
145 /// terminated with an entry of {0,0}.
146 ///
147 EFI_FV_BLOCK_MAP_ENTRY BlockMap[1];
148} EFI_FIRMWARE_VOLUME_HEADER;
149
150#define EFI_FVH_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', 'H')
151
152///
153/// Firmware Volume Header Revision definition
154///
155#define EFI_FVH_REVISION 0x02
156
157///
158/// Extension header pointed by ExtHeaderOffset of volume header.
159///
160typedef struct {
161 ///
162 /// Firmware volume name.
163 ///
164 EFI_GUID FvName;
165 ///
166 /// Size of the rest of the extension header, including this structure.
167 ///
168 UINT32 ExtHeaderSize;
169} EFI_FIRMWARE_VOLUME_EXT_HEADER;
170
171///
172/// Entry struture for describing FV extension header
173///
174typedef struct {
175 ///
176 /// Size of this header extension.
177 ///
178 UINT16 ExtEntrySize;
179 ///
180 /// Type of the header.
181 ///
182 UINT16 ExtEntryType;
183} EFI_FIRMWARE_VOLUME_EXT_ENTRY;
184
185#define EFI_FV_EXT_TYPE_OEM_TYPE 0x01
186///
187/// This extension header provides a mapping between a GUID and an OEM file type.
188///
189typedef struct {
190 ///
191 /// Standard extension entry, with the type EFI_FV_EXT_TYPE_OEM_TYPE.
192 ///
193 EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
194 ///
195 /// A bit mask, one bit for each file type between 0xC0 (bit 0) and 0xDF (bit 31). If a bit
196 /// is '1', then the GUID entry exists in Types. If a bit is '0' then no GUID entry exists in Types.
197 ///
198 UINT32 TypeMask;
199 ///
200 /// An array of GUIDs, each GUID representing an OEM file type.
201 ///
202 /// EFI_GUID Types[1];
203 ///
204} EFI_FIRMWARE_VOLUME_EXT_ENTRY_OEM_TYPE;
205
206#define EFI_FV_EXT_TYPE_GUID_TYPE 0x0002
207
208///
209/// This extension header EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE provides a vendor specific
210/// GUID FormatType type which includes a length and a successive series of data bytes.
211///
212typedef struct {
213 ///
214 /// Standard extension entry, with the type EFI_FV_EXT_TYPE_OEM_TYPE.
215 ///
216 EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
217 ///
218 /// Vendor-specific GUID.
219 ///
220 EFI_GUID FormatType;
221 ///
222 /// An arry of bytes of length Length.
223 ///
224 /// UINT8 Data[1];
225 ///
226} EFI_FIRMWARE_VOLUME_EXT_ENTRY_GUID_TYPE;
227
228#define EFI_FV_EXT_TYPE_USED_SIZE_TYPE 0x03
229
230///
231/// The EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE can be used to find
232/// out how many EFI_FVB2_ERASE_POLARITY bytes are at the end of the FV.
233///
234typedef struct {
235 ///
236 /// Standard extension entry, with the type EFI_FV_EXT_TYPE_USED_SIZE_TYPE.
237 ///
238 EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
239 ///
240 /// The number of bytes of the FV that are in uses. The remaining
241 /// EFI_FIRMWARE_VOLUME_HEADER FvLength minus UsedSize bytes in
242 /// the FV must contain the value implied by EFI_FVB2_ERASE_POLARITY.
243 ///
244 UINT32 UsedSize;
245} EFI_FIRMWARE_VOLUME_EXT_ENTRY_USED_SIZE_TYPE;
246
247#endif