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