2 This file provides control over block-oriented firmware devices.
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
7 @par Revision Reference:
8 This protocol is defined in framework spec: Firmware Volume Block Specification.
12 #ifndef __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__
13 #define __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__
15 #define FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \
16 { 0xDE28BC59, 0x6228, 0x41BD, {0xBD, 0xF6, 0xA3, 0xB9, 0xAD,0xB5, 0x8D, 0xA1 } }
18 typedef struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
;
20 /// The type of EFI FVB attribute per the Framework specification.
22 typedef UINT32 EFI_FVB_ATTRIBUTES
;
25 The GetAttributes() function retrieves the attributes and
26 current settings of the block.
28 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
30 @param Attributes Pointer to EFI_FVB_ATTRIBUTES in which the
31 attributes and current settings are
34 @retval EFI_SUCCESS The firmware volume attributes were
40 (EFIAPI
* FRAMEWORK_EFI_FVB_GET_ATTRIBUTES
)(
41 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
42 OUT EFI_FVB_ATTRIBUTES
*Attributes
47 The SetAttributes() function sets configurable firmware volume
48 attributes and returns the new settings of the firmware volume.
50 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
52 @param Attributes On input, Attributes is a pointer to
53 EFI_FVB_ATTRIBUTES that contains the
54 desired firmware volume settings. On
55 successful return, it contains the new
56 settings of the firmware volume.
58 @retval EFI_SUCCESS The firmware volume attributes were returned.
60 @retval EFI_INVALID_PARAMETER The attributes requested are in
61 conflict with the capabilities
62 as declared in the firmware
68 (EFIAPI
* FRAMEWORK_EFI_FVB_SET_ATTRIBUTES
)(
69 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
70 IN OUT EFI_FVB_ATTRIBUTES
*Attributes
75 The GetPhysicalAddress() function retrieves the base address of
76 a memory-mapped firmware volume. This function should be called
77 only for memory-mapped firmware volumes.
79 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
81 @param Address Pointer to a caller-allocated
82 EFI_PHYSICAL_ADDRESS that, on successful
83 return from GetPhysicalAddress(), contains the
84 base address of the firmware volume.
86 @retval EFI_SUCCESS The firmware volume base address is returned.
88 @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped.
93 (EFIAPI
* FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS
)(
94 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
95 OUT EFI_PHYSICAL_ADDRESS
*Address
99 The GetBlockSize() function retrieves the size of the requested
100 block. It also returns the number of additional blocks with
101 the identical size. The GetBlockSize() function is used to
102 retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).
105 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
107 @param Lba Indicates the block for which to return the size.
109 @param BlockSize The pointer to a caller-allocated UINTN in which
110 the size of the block is returned.
112 @param NumberOfBlocks The pointer to a caller-allocated UINTN in
113 which the number of consecutive blocks,
114 starting with Lba, is returned. All
115 blocks in this range have a size of
119 @retval EFI_SUCCESS The firmware volume base address was returned.
121 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.
126 (EFIAPI
* FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE
)(
127 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
129 OUT UINTN
*BlockSize
,
130 OUT UINTN
*NumberOfBlocks
135 Reads the specified number of bytes into a buffer from the specified block.
137 The Read() function reads the requested number of bytes from the
138 requested block and stores them in the provided buffer.
139 Implementations should be mindful that the firmware volume
140 might be in the ReadDisabled state. If it is in this state,
141 the Read() function must return the status code
142 EFI_ACCESS_DENIED without modifying the contents of the
143 buffer. The Read() function must also prevent spanning block
144 boundaries. If a read is requested that would span a block
145 boundary, the read must read up to the boundary but not
146 beyond. The output parameter NumBytes must be set to correctly
147 indicate the number of bytes actually read. The caller must be
148 aware that a read may be partially completed.
150 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
152 @param Lba The starting logical block index
155 @param Offset Offset into the block at which to begin reading.
157 @param NumBytes The pointer to a UINTN. At entry, *NumBytes
158 contains the total size of the buffer. At
159 exit, *NumBytes contains the total number of
162 @param Buffer The pointer to a caller-allocated buffer that will
163 be used to hold the data that is read.
165 @retval EFI_SUCCESS The firmware volume was read successfully
166 and contents are in Buffer.
168 @retval EFI_BAD_BUFFER_SIZE A read was attempted across an LBA
169 boundary. On output, NumBytes
170 contains the total number of bytes
173 @retval EFI_ACCESS_DENIED The firmware volume is in the
176 @retval EFI_DEVICE_ERROR The block device is not
177 functioning correctly and could
183 (EFIAPI
*FRAMEWORK_EFI_FVB_READ
)(
184 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
187 IN OUT UINTN
*NumBytes
,
192 Writes the specified number of bytes from the input buffer to the block.
194 The Write() function writes the specified number of bytes from
195 the provided buffer to the specified block and offset. If the
196 firmware volume is sticky write, the caller must ensure that
197 all the bits of the specified range to write are in the
198 EFI_FVB_ERASE_POLARITY state before calling the Write()
199 function, or else the result will be unpredictable. This
200 unpredictability arises because, for a sticky-write firmware
201 volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY
202 state but cannot flip it back again. In general, before
203 calling the Write() function, the caller should call the
204 EraseBlocks() function first to erase the specified block to
205 write. A block erase cycle will transition bits from the
206 (NOT)EFI_FVB_ERASE_POLARITY state back to the
207 EFI_FVB_ERASE_POLARITY state. Implementors should note
208 that the firmware volume might be in the WriteDisabled
209 state. If it is in this state, the Write() function must
210 return the status code EFI_ACCESS_DENIED without modifying the
211 contents of the firmware volume. The Write() function must
212 also prevent spanning block boundaries. If a write is
213 requested that spans a block boundary, the write must store up
214 to the boundary but not beyond. The output parameter NumBytes
215 must be set to correctly indicate the number of bytes actually
216 written. The caller must be aware that a write may be
217 partially completed. All writes, partial or otherwise, must be
218 fully flushed to the hardware before the Write() service
221 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.
223 @param Lba The starting logical block index to write to.
225 @param Offset Offset into the block at which to begin writing.
227 @param NumBytes The pointer to a UINTN. Input: the total size of the buffer.
228 Output: the total number of bytes actually written.
230 @param Buffer The pointer to a caller-allocated buffer that
231 contains the source for the write.
233 @retval EFI_SUCCESS The firmware volume was written successfully.
235 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an
236 LBA boundary. On output, NumBytes
237 contains the total number of bytes
240 @retval EFI_ACCESS_DENIED The firmware volume is in the
243 @retval EFI_DEVICE_ERROR The block device is malfunctioning
244 and could not be written.
250 (EFIAPI
* FRAMEWORK_EFI_FVB_WRITE
)(
251 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
254 IN OUT UINTN
*NumBytes
,
262 /// EFI_LBA_LIST_TERMINATOR.
264 #define FRAMEWORK_EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL
268 Erases and initializes a firmware volume block.
270 The EraseBlocks() function erases one or more blocks as denoted
271 by the variable argument list. The entire parameter list of
272 blocks must be verified before erasing any blocks. If a block is
273 requested that does not exist within the associated firmware
274 volume (it has a larger index than the last block of the
275 firmware volume), the EraseBlocks() function must return the
276 status code EFI_INVALID_PARAMETER without modifying the contents
277 of the firmware volume. Implementors should note that
278 the firmware volume might be in the WriteDisabled state. If it
279 is in this state, the EraseBlocks() function must return the
280 status code EFI_ACCESS_DENIED without modifying the contents of
281 the firmware volume. All calls to EraseBlocks() must be fully
282 flushed to the hardware before the EraseBlocks() service
285 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
288 @param ... A list of tuples.
289 Each tuple describes a range of LBAs to erase
290 and consists of the following:
291 - An EFI_LBA that indicates the starting LBA
292 - A UINTN that indicates the number of blocks to
295 The list is terminated with an
296 EFI_LBA_LIST_TERMINATOR. For example, the
297 following indicates that two ranges of blocks
298 (5-7 and 10-11) are to be erased: EraseBlocks
299 (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);
301 @retval EFI_SUCCESS The erase request successfully
304 @retval EFI_ACCESS_DENIED The firmware volume is in the
306 @retval EFI_DEVICE_ERROR The block device is not functioning
307 correctly and could not be written.
308 The firmware device may have been
310 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed
311 in the variable argument list do
312 not exist in the firmware volume.
317 (EFIAPI
* FRAMEWORK_EFI_FVB_ERASE_BLOCKS
)(
318 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
323 /// The Firmware Volume Block Protocol is the low-level interface
324 /// to a firmware volume. File-level access to a firmware volume
325 /// should not be done using the Firmware Volume Block Protocol.
326 /// Normal access to a firmware volume must use the Firmware
327 /// Volume Protocol. Typically, only the file system driver that
328 /// produces the Firmware Volume Protocol will bind to the
329 /// Firmware Volume Block Protocol.
331 struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
{
332 FRAMEWORK_EFI_FVB_GET_ATTRIBUTES GetAttributes
;
333 FRAMEWORK_EFI_FVB_SET_ATTRIBUTES SetAttributes
;
334 FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress
;
335 FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE GetBlockSize
;
336 FRAMEWORK_EFI_FVB_READ Read
;
337 FRAMEWORK_EFI_FVB_WRITE Write
;
338 FRAMEWORK_EFI_FVB_ERASE_BLOCKS EraseBlocks
;
340 /// The handle of the parent firmware volume.
342 EFI_HANDLE ParentHandle
;
345 extern EFI_GUID gFramerworkEfiFirmwareVolumeBlockProtocolGuid
;