]>
Commit | Line | Data |
---|---|---|
d1f95000 | 1 | /** @file\r |
2 | This file provides control over block-oriented firmware devices.\r | |
3 | \r | |
9095d37b LG |
4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
af2dc6a7 | 7 | The full text of the license may be found at\r |
9095d37b LG |
8 | http://opensource.org/licenses/bsd-license.php.\r |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
d1f95000 | 12 | \r |
d1f95000 | 13 | @par Revision Reference: PI\r |
5bd46269 | 14 | Version 1.0 and 1.2.\r |
d1f95000 | 15 | \r |
16 | **/\r | |
17 | \r | |
18 | #ifndef __FIRMWARE_VOLUME_BLOCK_H__\r | |
19 | #define __FIRMWARE_VOLUME_BLOCK_H__\r | |
20 | \r | |
5bd46269 | 21 | //\r |
22 | // EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is defined in PI 1.0 spec and its GUID value\r | |
23 | // is later updated to be the same as that of EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL\r | |
9095d37b | 24 | // defined in PI 1.2 spec.\r |
5bd46269 | 25 | //\r |
d1f95000 | 26 | #define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \\r |
5bd46269 | 27 | { 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }\r |
d1f95000 | 28 | \r |
5bd46269 | 29 | #define EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID \\r |
30 | { 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }\r | |
d1f95000 | 31 | \r |
32 | typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;\r | |
33 | \r | |
9095d37b | 34 | typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL;\r |
5bd46269 | 35 | \r |
d1f95000 | 36 | /**\r |
37 | The GetAttributes() function retrieves the attributes and\r | |
5209f2a9 | 38 | current settings of the block.\r |
d1f95000 | 39 | \r |
5bd46269 | 40 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
d1f95000 | 41 | \r |
4ba967e7 | 42 | @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the\r |
d1f95000 | 43 | attributes and current settings are\r |
4ba967e7 | 44 | returned. Type EFI_FVB_ATTRIBUTES_2 is defined\r |
d1f95000 | 45 | in EFI_FIRMWARE_VOLUME_HEADER.\r |
46 | \r | |
47 | @retval EFI_SUCCESS The firmware volume attributes were\r | |
48 | returned.\r | |
49 | \r | |
50 | **/\r | |
51 | typedef\r | |
52 | EFI_STATUS\r | |
8b13229b | 53 | (EFIAPI * EFI_FVB_GET_ATTRIBUTES)(\r |
5bd46269 | 54 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
4ba967e7 | 55 | OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r |
d1f95000 | 56 | );\r |
57 | \r | |
58 | \r | |
59 | /**\r | |
60 | The SetAttributes() function sets configurable firmware volume\r | |
61 | attributes and returns the new settings of the firmware volume.\r | |
62 | \r | |
5bd46269 | 63 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
d1f95000 | 64 | \r |
65 | @param Attributes On input, Attributes is a pointer to\r | |
4ba967e7 | 66 | EFI_FVB_ATTRIBUTES_2 that contains the\r |
d1f95000 | 67 | desired firmware volume settings. On\r |
68 | successful return, it contains the new\r | |
69 | settings of the firmware volume. Type\r | |
4ba967e7 | 70 | EFI_FVB_ATTRIBUTES_2 is defined in\r |
d1f95000 | 71 | EFI_FIRMWARE_VOLUME_HEADER.\r |
9095d37b | 72 | \r |
4ca9b6c4 | 73 | @retval EFI_SUCCESS The firmware volume attributes were returned.\r |
d1f95000 | 74 | \r |
75 | @retval EFI_INVALID_PARAMETER The attributes requested are in\r | |
76 | conflict with the capabilities\r | |
77 | as declared in the firmware\r | |
78 | volume header.\r | |
79 | \r | |
80 | **/\r | |
81 | typedef\r | |
82 | EFI_STATUS\r | |
8b13229b | 83 | (EFIAPI * EFI_FVB_SET_ATTRIBUTES)(\r |
5bd46269 | 84 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
4ba967e7 | 85 | IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r |
d1f95000 | 86 | );\r |
87 | \r | |
88 | \r | |
89 | /**\r | |
90 | The GetPhysicalAddress() function retrieves the base address of\r | |
91 | a memory-mapped firmware volume. This function should be called\r | |
92 | only for memory-mapped firmware volumes.\r | |
93 | \r | |
5bd46269 | 94 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
9095d37b | 95 | \r |
d1f95000 | 96 | @param Address Pointer to a caller-allocated\r |
97 | EFI_PHYSICAL_ADDRESS that, on successful\r | |
98 | return from GetPhysicalAddress(), contains the\r | |
4ca9b6c4 | 99 | base address of the firmware volume.\r |
9095d37b | 100 | \r |
af2dc6a7 | 101 | @retval EFI_SUCCESS The firmware volume base address was returned.\r |
9095d37b | 102 | \r |
5fbfa2d0 | 103 | @retval EFI_UNSUPPORTED The firmware volume is not memory mapped.\r |
d1f95000 | 104 | \r |
105 | **/\r | |
106 | typedef\r | |
107 | EFI_STATUS\r | |
8b13229b | 108 | (EFIAPI * EFI_FVB_GET_PHYSICAL_ADDRESS)(\r |
5bd46269 | 109 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
d1f95000 | 110 | OUT EFI_PHYSICAL_ADDRESS *Address\r |
111 | );\r | |
112 | \r | |
113 | /**\r | |
114 | The GetBlockSize() function retrieves the size of the requested\r | |
115 | block. It also returns the number of additional blocks with\r | |
116 | the identical size. The GetBlockSize() function is used to\r | |
117 | retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).\r | |
118 | \r | |
119 | \r | |
5bd46269 | 120 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
d1f95000 | 121 | \r |
4ca9b6c4 | 122 | @param Lba Indicates the block for which to return the size.\r |
d1f95000 | 123 | \r |
4ca9b6c4 LG |
124 | @param BlockSize Pointer to a caller-allocated UINTN in which\r |
125 | the size of the block is returned.\r | |
d1f95000 | 126 | \r |
127 | @param NumberOfBlocks Pointer to a caller-allocated UINTN in\r | |
128 | which the number of consecutive blocks,\r | |
129 | starting with Lba, is returned. All\r | |
130 | blocks in this range have a size of\r | |
131 | BlockSize.\r | |
132 | \r | |
9095d37b | 133 | \r |
af2dc6a7 | 134 | @retval EFI_SUCCESS The firmware volume base address was returned.\r |
9095d37b | 135 | \r |
4ca9b6c4 | 136 | @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r |
d1f95000 | 137 | \r |
138 | **/\r | |
139 | typedef\r | |
140 | EFI_STATUS\r | |
8b13229b | 141 | (EFIAPI * EFI_FVB_GET_BLOCK_SIZE)(\r |
5bd46269 | 142 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
de339b9d | 143 | IN EFI_LBA Lba,\r |
d1f95000 | 144 | OUT UINTN *BlockSize,\r |
145 | OUT UINTN *NumberOfBlocks\r | |
146 | );\r | |
147 | \r | |
148 | \r | |
149 | /**\r | |
eecd469b LG |
150 | Reads the specified number of bytes into a buffer from the specified block.\r |
151 | \r | |
d1f95000 | 152 | The Read() function reads the requested number of bytes from the\r |
153 | requested block and stores them in the provided buffer.\r | |
154 | Implementations should be mindful that the firmware volume\r | |
155 | might be in the ReadDisabled state. If it is in this state,\r | |
156 | the Read() function must return the status code\r | |
157 | EFI_ACCESS_DENIED without modifying the contents of the\r | |
158 | buffer. The Read() function must also prevent spanning block\r | |
159 | boundaries. If a read is requested that would span a block\r | |
160 | boundary, the read must read up to the boundary but not\r | |
161 | beyond. The output parameter NumBytes must be set to correctly\r | |
162 | indicate the number of bytes actually read. The caller must be\r | |
163 | aware that a read may be partially completed.\r | |
164 | \r | |
5bd46269 | 165 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
9095d37b | 166 | \r |
4ca9b6c4 LG |
167 | @param Lba The starting logical block index\r |
168 | from which to read.\r | |
d1f95000 | 169 | \r |
4ca9b6c4 | 170 | @param Offset Offset into the block at which to begin reading.\r |
d1f95000 | 171 | \r |
172 | @param NumBytes Pointer to a UINTN. At entry, *NumBytes\r | |
173 | contains the total size of the buffer. At\r | |
174 | exit, *NumBytes contains the total number of\r | |
175 | bytes read.\r | |
176 | \r | |
177 | @param Buffer Pointer to a caller-allocated buffer that will\r | |
178 | be used to hold the data that is read.\r | |
179 | \r | |
af2dc6a7 | 180 | @retval EFI_SUCCESS The firmware volume was read successfully,\r |
4ca9b6c4 | 181 | and contents are in Buffer.\r |
9095d37b | 182 | \r |
d1f95000 | 183 | @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA\r |
184 | boundary. On output, NumBytes\r | |
185 | contains the total number of bytes\r | |
186 | returned in Buffer.\r | |
9095d37b | 187 | \r |
d1f95000 | 188 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
189 | ReadDisabled state.\r | |
9095d37b | 190 | \r |
d1f95000 | 191 | @retval EFI_DEVICE_ERROR The block device is not\r |
192 | functioning correctly and could\r | |
193 | not be read.\r | |
194 | \r | |
195 | **/\r | |
196 | typedef\r | |
197 | EFI_STATUS\r | |
8b13229b | 198 | (EFIAPI *EFI_FVB_READ)(\r |
5bd46269 | 199 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
de339b9d | 200 | IN EFI_LBA Lba,\r |
201 | IN UINTN Offset,\r | |
d1f95000 | 202 | IN OUT UINTN *NumBytes,\r |
96219b7d | 203 | IN OUT UINT8 *Buffer\r |
d1f95000 | 204 | );\r |
205 | \r | |
d1f95000 | 206 | /**\r |
eecd469b LG |
207 | Writes the specified number of bytes from the input buffer to the block.\r |
208 | \r | |
d1f95000 | 209 | The Write() function writes the specified number of bytes from\r |
210 | the provided buffer to the specified block and offset. If the\r | |
211 | firmware volume is sticky write, the caller must ensure that\r | |
212 | all the bits of the specified range to write are in the\r | |
213 | EFI_FVB_ERASE_POLARITY state before calling the Write()\r | |
214 | function, or else the result will be unpredictable. This\r | |
215 | unpredictability arises because, for a sticky-write firmware\r | |
216 | volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY\r | |
af2dc6a7 | 217 | state but cannot flip it back again. Before calling the\r |
9095d37b | 218 | Write() function, it is recommended for the caller to first call\r |
af2dc6a7 | 219 | the EraseBlocks() function to erase the specified block to\r |
d1f95000 | 220 | write. A block erase cycle will transition bits from the\r |
221 | (NOT)EFI_FVB_ERASE_POLARITY state back to the\r | |
222 | EFI_FVB_ERASE_POLARITY state. Implementations should be\r | |
223 | mindful that the firmware volume might be in the WriteDisabled\r | |
224 | state. If it is in this state, the Write() function must\r | |
225 | return the status code EFI_ACCESS_DENIED without modifying the\r | |
226 | contents of the firmware volume. The Write() function must\r | |
227 | also prevent spanning block boundaries. If a write is\r | |
228 | requested that spans a block boundary, the write must store up\r | |
229 | to the boundary but not beyond. The output parameter NumBytes\r | |
230 | must be set to correctly indicate the number of bytes actually\r | |
231 | written. The caller must be aware that a write may be\r | |
232 | partially completed. All writes, partial or otherwise, must be\r | |
233 | fully flushed to the hardware before the Write() service\r | |
234 | returns.\r | |
235 | \r | |
5bd46269 | 236 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.\r |
9095d37b | 237 | \r |
4ca9b6c4 | 238 | @param Lba The starting logical block index to write to.\r |
9095d37b | 239 | \r |
4ca9b6c4 | 240 | @param Offset Offset into the block at which to begin writing.\r |
9095d37b | 241 | \r |
af2dc6a7 | 242 | @param NumBytes The pointer to a UINTN. At entry, *NumBytes\r |
d1f95000 | 243 | contains the total size of the buffer. At\r |
244 | exit, *NumBytes contains the total number of\r | |
245 | bytes actually written.\r | |
9095d37b | 246 | \r |
af2dc6a7 | 247 | @param Buffer The pointer to a caller-allocated buffer that\r |
4ca9b6c4 | 248 | contains the source for the write.\r |
9095d37b | 249 | \r |
4ca9b6c4 | 250 | @retval EFI_SUCCESS The firmware volume was written successfully.\r |
9095d37b | 251 | \r |
d1f95000 | 252 | @retval EFI_BAD_BUFFER_SIZE The write was attempted across an\r |
253 | LBA boundary. On output, NumBytes\r | |
254 | contains the total number of bytes\r | |
255 | actually written.\r | |
9095d37b | 256 | \r |
d1f95000 | 257 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
258 | WriteDisabled state.\r | |
9095d37b | 259 | \r |
d1f95000 | 260 | @retval EFI_DEVICE_ERROR The block device is malfunctioning\r |
261 | and could not be written.\r | |
262 | \r | |
263 | \r | |
264 | **/\r | |
265 | typedef\r | |
266 | EFI_STATUS\r | |
8b13229b | 267 | (EFIAPI * EFI_FVB_WRITE)(\r |
5bd46269 | 268 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
de339b9d | 269 | IN EFI_LBA Lba,\r |
270 | IN UINTN Offset,\r | |
d1f95000 | 271 | IN OUT UINTN *NumBytes,\r |
85c528bd | 272 | IN UINT8 *Buffer\r |
d1f95000 | 273 | );\r |
274 | \r | |
275 | \r | |
276 | \r | |
277 | \r | |
a4e0b060 | 278 | ///\r |
279 | /// EFI_LBA_LIST_TERMINATOR\r | |
280 | ///\r | |
d1f95000 | 281 | #define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL\r |
282 | \r | |
283 | \r | |
284 | /**\r | |
eecd469b LG |
285 | Erases and initializes a firmware volume block.\r |
286 | \r | |
f754f721 | 287 | The EraseBlocks() function erases one or more blocks as denoted\r |
d1f95000 | 288 | by the variable argument list. The entire parameter list of\r |
289 | blocks must be verified before erasing any blocks. If a block is\r | |
290 | requested that does not exist within the associated firmware\r | |
291 | volume (it has a larger index than the last block of the\r | |
292 | firmware volume), the EraseBlocks() function must return the\r | |
293 | status code EFI_INVALID_PARAMETER without modifying the contents\r | |
294 | of the firmware volume. Implementations should be mindful that\r | |
295 | the firmware volume might be in the WriteDisabled state. If it\r | |
296 | is in this state, the EraseBlocks() function must return the\r | |
297 | status code EFI_ACCESS_DENIED without modifying the contents of\r | |
298 | the firmware volume. All calls to EraseBlocks() must be fully\r | |
299 | flushed to the hardware before the EraseBlocks() service\r | |
300 | returns.\r | |
301 | \r | |
5bd46269 | 302 | @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL\r |
d1f95000 | 303 | instance.\r |
304 | \r | |
305 | @param ... The variable argument list is a list of tuples.\r | |
306 | Each tuple describes a range of LBAs to erase\r | |
307 | and consists of the following:\r | |
308 | - An EFI_LBA that indicates the starting LBA\r | |
309 | - A UINTN that indicates the number of blocks to\r | |
af2dc6a7 | 310 | erase.\r |
d1f95000 | 311 | \r |
312 | The list is terminated with an\r | |
313 | EFI_LBA_LIST_TERMINATOR. For example, the\r | |
314 | following indicates that two ranges of blocks\r | |
315 | (5-7 and 10-11) are to be erased: EraseBlocks\r | |
316 | (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);\r | |
317 | \r | |
af2dc6a7 | 318 | @retval EFI_SUCCESS The erase request successfully\r |
d1f95000 | 319 | completed.\r |
9095d37b | 320 | \r |
d1f95000 | 321 | @retval EFI_ACCESS_DENIED The firmware volume is in the\r |
322 | WriteDisabled state.\r | |
323 | @retval EFI_DEVICE_ERROR The block device is not functioning\r | |
324 | correctly and could not be written.\r | |
325 | The firmware device may have been\r | |
326 | partially erased.\r | |
327 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r | |
328 | in the variable argument list do\r | |
9095d37b | 329 | not exist in the firmware volume.\r |
d1f95000 | 330 | \r |
331 | **/\r | |
332 | typedef\r | |
333 | EFI_STATUS\r | |
8b13229b | 334 | (EFIAPI * EFI_FVB_ERASE_BLOCKS)(\r |
5bd46269 | 335 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,\r |
d1f95000 | 336 | ...\r |
337 | );\r | |
338 | \r | |
44717a39 | 339 | ///\r |
340 | /// The Firmware Volume Block Protocol is the low-level interface\r | |
341 | /// to a firmware volume. File-level access to a firmware volume\r | |
342 | /// should not be done using the Firmware Volume Block Protocol.\r | |
343 | /// Normal access to a firmware volume must use the Firmware\r | |
344 | /// Volume Protocol. Typically, only the file system driver that\r | |
345 | /// produces the Firmware Volume Protocol will bind to the\r | |
346 | /// Firmware Volume Block Protocol.\r | |
347 | ///\r | |
5bd46269 | 348 | struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL{\r |
d1f95000 | 349 | EFI_FVB_GET_ATTRIBUTES GetAttributes;\r |
350 | EFI_FVB_SET_ATTRIBUTES SetAttributes;\r | |
351 | EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress;\r | |
352 | EFI_FVB_GET_BLOCK_SIZE GetBlockSize;\r | |
353 | EFI_FVB_READ Read;\r | |
354 | EFI_FVB_WRITE Write;\r | |
355 | EFI_FVB_ERASE_BLOCKS EraseBlocks;\r | |
a4e0b060 | 356 | ///\r |
af2dc6a7 | 357 | /// The handle of the parent firmware volume.\r |
9095d37b | 358 | ///\r |
d1f95000 | 359 | EFI_HANDLE ParentHandle;\r |
360 | };\r | |
361 | \r | |
362 | \r | |
363 | extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid;\r | |
5bd46269 | 364 | extern EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid;\r |
d1f95000 | 365 | \r |
366 | #endif\r |