]>
Commit | Line | Data |
---|---|---|
220c61c1 | 1 | /** @file\r |
2 | This file provides control over block-oriented firmware devices.\r | |
3 | \r | |
1c2f052d | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
22a69a5e | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
1c2f052d LG |
6 | \r |
7 | @par Revision Reference:\r | |
f22f941e | 8 | This protocol is defined in framework spec: Firmware Volume Block Specification.\r |
220c61c1 | 9 | \r |
10 | **/\r | |
11 | \r | |
12 | #ifndef __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__\r | |
13 | #define __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__\r | |
14 | \r | |
abc0c38a | 15 | #define FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \\r |
16 | { 0xDE28BC59, 0x6228, 0x41BD, {0xBD, 0xF6, 0xA3, 0xB9, 0xAD,0xB5, 0x8D, 0xA1 } }\r | |
220c61c1 | 17 | \r |
18 | typedef struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;\r | |
19 | ///\r | |
f22f941e | 20 | /// The type of EFI FVB attribute per the Framework specification.\r |
1c2f052d | 21 | ///\r |
220c61c1 | 22 | typedef UINT32 EFI_FVB_ATTRIBUTES;\r |
23 | \r | |
24 | /**\r | |
25 | The GetAttributes() function retrieves the attributes and\r | |
1c2f052d | 26 | current settings of the block.\r |
220c61c1 | 27 | \r |
28 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
29 | \r | |
30 | @param Attributes Pointer to EFI_FVB_ATTRIBUTES in which the\r | |
31 | attributes and current settings are\r | |
1c2f052d | 32 | returned.\r |
220c61c1 | 33 | \r |
34 | @retval EFI_SUCCESS The firmware volume attributes were\r | |
35 | returned.\r | |
36 | \r | |
37 | **/\r | |
38 | typedef\r | |
39 | EFI_STATUS\r | |
40 | (EFIAPI * FRAMEWORK_EFI_FVB_GET_ATTRIBUTES)(\r | |
41 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
42 | OUT EFI_FVB_ATTRIBUTES *Attributes\r | |
43 | );\r | |
44 | \r | |
45 | \r | |
46 | /**\r | |
47 | The SetAttributes() function sets configurable firmware volume\r | |
48 | attributes and returns the new settings of the firmware volume.\r | |
49 | \r | |
50 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
51 | \r | |
52 | @param Attributes On input, Attributes is a pointer to\r | |
53 | EFI_FVB_ATTRIBUTES that contains the\r | |
54 | desired firmware volume settings. On\r | |
55 | successful return, it contains the new\r | |
1c2f052d LG |
56 | settings of the firmware volume.\r |
57 | \r | |
220c61c1 | 58 | @retval EFI_SUCCESS The firmware volume attributes were returned.\r |
59 | \r | |
60 | @retval EFI_INVALID_PARAMETER The attributes requested are in\r | |
61 | conflict with the capabilities\r | |
62 | as declared in the firmware\r | |
63 | volume header.\r | |
64 | \r | |
65 | **/\r | |
66 | typedef\r | |
67 | EFI_STATUS\r | |
68 | (EFIAPI * FRAMEWORK_EFI_FVB_SET_ATTRIBUTES)(\r | |
69 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
70 | IN OUT EFI_FVB_ATTRIBUTES *Attributes\r | |
71 | );\r | |
72 | \r | |
73 | \r | |
74 | /**\r | |
75 | The GetPhysicalAddress() function retrieves the base address of\r | |
76 | a memory-mapped firmware volume. This function should be called\r | |
77 | only for memory-mapped firmware volumes.\r | |
78 | \r | |
79 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
1c2f052d | 80 | \r |
220c61c1 | 81 | @param Address Pointer to a caller-allocated\r |
82 | EFI_PHYSICAL_ADDRESS that, on successful\r | |
83 | return from GetPhysicalAddress(), contains the\r | |
84 | base address of the firmware volume.\r | |
1c2f052d | 85 | \r |
220c61c1 | 86 | @retval EFI_SUCCESS The firmware volume base address is returned.\r |
1c2f052d | 87 | \r |
220c61c1 | 88 | @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped.\r |
89 | \r | |
90 | **/\r | |
91 | typedef\r | |
92 | EFI_STATUS\r | |
93 | (EFIAPI * FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS)(\r | |
94 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
95 | OUT EFI_PHYSICAL_ADDRESS *Address\r | |
96 | );\r | |
97 | \r | |
98 | /**\r | |
99 | The GetBlockSize() function retrieves the size of the requested\r | |
100 | block. It also returns the number of additional blocks with\r | |
101 | the identical size. The GetBlockSize() function is used to\r | |
102 | retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).\r | |
103 | \r | |
104 | \r | |
105 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
106 | \r | |
107 | @param Lba Indicates the block for which to return the size.\r | |
108 | \r | |
f22f941e | 109 | @param BlockSize The pointer to a caller-allocated UINTN in which\r |
220c61c1 | 110 | the size of the block is returned.\r |
111 | \r | |
f22f941e | 112 | @param NumberOfBlocks The pointer to a caller-allocated UINTN in\r |
220c61c1 | 113 | which the number of consecutive blocks,\r |
114 | starting with Lba, is returned. All\r | |
115 | blocks in this range have a size of\r | |
116 | BlockSize.\r | |
117 | \r | |
1c2f052d | 118 | \r |
f22f941e | 119 | @retval EFI_SUCCESS The firmware volume base address was returned.\r |
1c2f052d | 120 | \r |
220c61c1 | 121 | @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r |
122 | \r | |
123 | **/\r | |
124 | typedef\r | |
125 | EFI_STATUS\r | |
126 | (EFIAPI * FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE)(\r | |
127 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
128 | IN EFI_LBA Lba,\r | |
129 | OUT UINTN *BlockSize,\r | |
130 | OUT UINTN *NumberOfBlocks\r | |
131 | );\r | |
132 | \r | |
133 | \r | |
134 | /**\r | |
135 | Reads the specified number of bytes into a buffer from the specified block.\r | |
136 | \r | |
137 | The Read() function reads the requested number of bytes from the\r | |
138 | requested block and stores them in the provided buffer.\r | |
139 | Implementations should be mindful that the firmware volume\r | |
140 | might be in the ReadDisabled state. If it is in this state,\r | |
141 | the Read() function must return the status code\r | |
142 | EFI_ACCESS_DENIED without modifying the contents of the\r | |
143 | buffer. The Read() function must also prevent spanning block\r | |
144 | boundaries. If a read is requested that would span a block\r | |
145 | boundary, the read must read up to the boundary but not\r | |
146 | beyond. The output parameter NumBytes must be set to correctly\r | |
147 | indicate the number of bytes actually read. The caller must be\r | |
148 | aware that a read may be partially completed.\r | |
149 | \r | |
150 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
1c2f052d | 151 | \r |
220c61c1 | 152 | @param Lba The starting logical block index\r |
153 | from which to read.\r | |
154 | \r | |
155 | @param Offset Offset into the block at which to begin reading.\r | |
156 | \r | |
f22f941e | 157 | @param NumBytes The pointer to a UINTN. At entry, *NumBytes\r |
220c61c1 | 158 | contains the total size of the buffer. At\r |
159 | exit, *NumBytes contains the total number of\r | |
160 | bytes read.\r | |
161 | \r | |
f22f941e | 162 | @param Buffer The pointer to a caller-allocated buffer that will\r |
220c61c1 | 163 | be used to hold the data that is read.\r |
164 | \r | |
165 | @retval EFI_SUCCESS The firmware volume was read successfully\r | |
166 | and contents are in Buffer.\r | |
1c2f052d | 167 | \r |
f22f941e | 168 | @retval EFI_BAD_BUFFER_SIZE A read was attempted across an LBA\r |
220c61c1 | 169 | boundary. On output, NumBytes\r |
170 | contains the total number of bytes\r | |
171 | returned in Buffer.\r | |
1c2f052d | 172 | \r |
220c61c1 | 173 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
174 | ReadDisabled state.\r | |
1c2f052d | 175 | \r |
220c61c1 | 176 | @retval EFI_DEVICE_ERROR The block device is not\r |
177 | functioning correctly and could\r | |
178 | not be read.\r | |
179 | \r | |
180 | **/\r | |
181 | typedef\r | |
182 | EFI_STATUS\r | |
183 | (EFIAPI *FRAMEWORK_EFI_FVB_READ)(\r | |
184 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
185 | IN EFI_LBA Lba,\r | |
186 | IN UINTN Offset,\r | |
187 | IN OUT UINTN *NumBytes,\r | |
188 | IN OUT UINT8 *Buffer\r | |
189 | );\r | |
190 | \r | |
191 | /**\r | |
192 | Writes the specified number of bytes from the input buffer to the block.\r | |
193 | \r | |
194 | The Write() function writes the specified number of bytes from\r | |
195 | the provided buffer to the specified block and offset. If the\r | |
196 | firmware volume is sticky write, the caller must ensure that\r | |
197 | all the bits of the specified range to write are in the\r | |
198 | EFI_FVB_ERASE_POLARITY state before calling the Write()\r | |
199 | function, or else the result will be unpredictable. This\r | |
200 | unpredictability arises because, for a sticky-write firmware\r | |
201 | volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY\r | |
202 | state but cannot flip it back again. In general, before\r | |
203 | calling the Write() function, the caller should call the\r | |
204 | EraseBlocks() function first to erase the specified block to\r | |
205 | write. A block erase cycle will transition bits from the\r | |
206 | (NOT)EFI_FVB_ERASE_POLARITY state back to the\r | |
1c2f052d | 207 | EFI_FVB_ERASE_POLARITY state. Implementors should note\r |
f22f941e | 208 | that the firmware volume might be in the WriteDisabled\r |
220c61c1 | 209 | state. If it is in this state, the Write() function must\r |
210 | return the status code EFI_ACCESS_DENIED without modifying the\r | |
211 | contents of the firmware volume. The Write() function must\r | |
212 | also prevent spanning block boundaries. If a write is\r | |
213 | requested that spans a block boundary, the write must store up\r | |
214 | to the boundary but not beyond. The output parameter NumBytes\r | |
215 | must be set to correctly indicate the number of bytes actually\r | |
216 | written. The caller must be aware that a write may be\r | |
217 | partially completed. All writes, partial or otherwise, must be\r | |
218 | fully flushed to the hardware before the Write() service\r | |
219 | returns.\r | |
220 | \r | |
221 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r | |
1c2f052d | 222 | \r |
220c61c1 | 223 | @param Lba The starting logical block index to write to.\r |
1c2f052d | 224 | \r |
220c61c1 | 225 | @param Offset Offset into the block at which to begin writing.\r |
1c2f052d | 226 | \r |
f22f941e | 227 | @param NumBytes The pointer to a UINTN. Input: the total size of the buffer.\r |
5259c97d | 228 | Output: the total number of bytes actually written.\r |
1c2f052d | 229 | \r |
f22f941e | 230 | @param Buffer The pointer to a caller-allocated buffer that\r |
220c61c1 | 231 | contains the source for the write.\r |
1c2f052d | 232 | \r |
220c61c1 | 233 | @retval EFI_SUCCESS The firmware volume was written successfully.\r |
1c2f052d | 234 | \r |
220c61c1 | 235 | @retval EFI_BAD_BUFFER_SIZE The write was attempted across an\r |
236 | LBA boundary. On output, NumBytes\r | |
237 | contains the total number of bytes\r | |
238 | actually written.\r | |
1c2f052d | 239 | \r |
220c61c1 | 240 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
241 | WriteDisabled state.\r | |
1c2f052d | 242 | \r |
220c61c1 | 243 | @retval EFI_DEVICE_ERROR The block device is malfunctioning\r |
244 | and could not be written.\r | |
245 | \r | |
246 | \r | |
247 | **/\r | |
248 | typedef\r | |
249 | EFI_STATUS\r | |
250 | (EFIAPI * FRAMEWORK_EFI_FVB_WRITE)(\r | |
251 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
252 | IN EFI_LBA Lba,\r | |
253 | IN UINTN Offset,\r | |
254 | IN OUT UINTN *NumBytes,\r | |
255 | IN UINT8 *Buffer\r | |
256 | );\r | |
257 | \r | |
258 | \r | |
259 | \r | |
260 | \r | |
261 | ///\r | |
f22f941e | 262 | /// EFI_LBA_LIST_TERMINATOR.\r |
220c61c1 | 263 | ///\r |
264 | #define FRAMEWORK_EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL\r | |
265 | \r | |
266 | \r | |
267 | /**\r | |
268 | Erases and initializes a firmware volume block.\r | |
269 | \r | |
270 | The EraseBlocks() function erases one or more blocks as denoted\r | |
271 | by the variable argument list. The entire parameter list of\r | |
272 | blocks must be verified before erasing any blocks. If a block is\r | |
273 | requested that does not exist within the associated firmware\r | |
274 | volume (it has a larger index than the last block of the\r | |
275 | firmware volume), the EraseBlocks() function must return the\r | |
276 | status code EFI_INVALID_PARAMETER without modifying the contents\r | |
f22f941e | 277 | of the firmware volume. Implementors should note that\r |
220c61c1 | 278 | the firmware volume might be in the WriteDisabled state. If it\r |
279 | is in this state, the EraseBlocks() function must return the\r | |
280 | status code EFI_ACCESS_DENIED without modifying the contents of\r | |
281 | the firmware volume. All calls to EraseBlocks() must be fully\r | |
282 | flushed to the hardware before the EraseBlocks() service\r | |
283 | returns.\r | |
284 | \r | |
285 | @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL\r | |
286 | instance.\r | |
287 | \r | |
5259c97d | 288 | @param ... A list of tuples.\r |
220c61c1 | 289 | Each tuple describes a range of LBAs to erase\r |
290 | and consists of the following:\r | |
291 | - An EFI_LBA that indicates the starting LBA\r | |
292 | - A UINTN that indicates the number of blocks to\r | |
293 | erase\r | |
294 | \r | |
295 | The list is terminated with an\r | |
296 | EFI_LBA_LIST_TERMINATOR. For example, the\r | |
297 | following indicates that two ranges of blocks\r | |
298 | (5-7 and 10-11) are to be erased: EraseBlocks\r | |
299 | (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);\r | |
300 | \r | |
f22f941e | 301 | @retval EFI_SUCCESS The erase request successfully\r |
220c61c1 | 302 | completed.\r |
1c2f052d | 303 | \r |
220c61c1 | 304 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
305 | WriteDisabled state.\r | |
306 | @retval EFI_DEVICE_ERROR The block device is not functioning\r | |
307 | correctly and could not be written.\r | |
308 | The firmware device may have been\r | |
309 | partially erased.\r | |
310 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r | |
311 | in the variable argument list do\r | |
1c2f052d | 312 | not exist in the firmware volume.\r |
220c61c1 | 313 | \r |
314 | **/\r | |
315 | typedef\r | |
316 | EFI_STATUS\r | |
317 | (EFIAPI * FRAMEWORK_EFI_FVB_ERASE_BLOCKS)(\r | |
318 | IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
319 | ...\r | |
320 | );\r | |
321 | \r | |
322 | ///\r | |
323 | /// The Firmware Volume Block Protocol is the low-level interface\r | |
324 | /// to a firmware volume. File-level access to a firmware volume\r | |
325 | /// should not be done using the Firmware Volume Block Protocol.\r | |
326 | /// Normal access to a firmware volume must use the Firmware\r | |
327 | /// Volume Protocol. Typically, only the file system driver that\r | |
328 | /// produces the Firmware Volume Protocol will bind to the\r | |
329 | /// Firmware Volume Block Protocol.\r | |
330 | ///\r | |
331 | struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL {\r | |
332 | FRAMEWORK_EFI_FVB_GET_ATTRIBUTES GetAttributes;\r | |
333 | FRAMEWORK_EFI_FVB_SET_ATTRIBUTES SetAttributes;\r | |
334 | FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress;\r | |
335 | FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE GetBlockSize;\r | |
336 | FRAMEWORK_EFI_FVB_READ Read;\r | |
337 | FRAMEWORK_EFI_FVB_WRITE Write;\r | |
338 | FRAMEWORK_EFI_FVB_ERASE_BLOCKS EraseBlocks;\r | |
339 | ///\r | |
f22f941e | 340 | /// The handle of the parent firmware volume.\r |
1c2f052d | 341 | ///\r |
220c61c1 | 342 | EFI_HANDLE ParentHandle;\r |
343 | };\r | |
344 | \r | |
abc0c38a | 345 | extern EFI_GUID gFramerworkEfiFirmwareVolumeBlockProtocolGuid;\r |
220c61c1 | 346 | \r |
347 | #endif\r |