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