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