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: PI
12 #ifndef __FIRMWARE_VOLUME_BLOCK_H__
13 #define __FIRMWARE_VOLUME_BLOCK_H__
16 // EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is defined in PI 1.0 spec and its GUID value
17 // is later updated to be the same as that of EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
18 // defined in PI 1.2 spec.
20 #define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \
21 { 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }
23 #define EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID \
24 { 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }
26 typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
;
28 typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
;
31 The GetAttributes() function retrieves the attributes and
32 current settings of the block.
34 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
36 @param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the
37 attributes and current settings are
38 returned. Type EFI_FVB_ATTRIBUTES_2 is defined
39 in EFI_FIRMWARE_VOLUME_HEADER.
41 @retval EFI_SUCCESS The firmware volume attributes were
47 (EFIAPI
*EFI_FVB_GET_ATTRIBUTES
)(
48 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
49 OUT EFI_FVB_ATTRIBUTES_2
*Attributes
53 The SetAttributes() function sets configurable firmware volume
54 attributes and returns the new settings of the firmware volume.
56 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
58 @param Attributes On input, Attributes is a pointer to
59 EFI_FVB_ATTRIBUTES_2 that contains the
60 desired firmware volume settings. On
61 successful return, it contains the new
62 settings of the firmware volume. Type
63 EFI_FVB_ATTRIBUTES_2 is defined in
64 EFI_FIRMWARE_VOLUME_HEADER.
66 @retval EFI_SUCCESS The firmware volume attributes were returned.
68 @retval EFI_INVALID_PARAMETER The attributes requested are in
69 conflict with the capabilities
70 as declared in the firmware
76 (EFIAPI
*EFI_FVB_SET_ATTRIBUTES
)(
77 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
78 IN OUT EFI_FVB_ATTRIBUTES_2
*Attributes
82 The GetPhysicalAddress() function retrieves the base address of
83 a memory-mapped firmware volume. This function should be called
84 only for memory-mapped firmware volumes.
86 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
88 @param Address Pointer to a caller-allocated
89 EFI_PHYSICAL_ADDRESS that, on successful
90 return from GetPhysicalAddress(), contains the
91 base address of the firmware volume.
93 @retval EFI_SUCCESS The firmware volume base address was returned.
95 @retval EFI_UNSUPPORTED The firmware volume is not memory mapped.
100 (EFIAPI
*EFI_FVB_GET_PHYSICAL_ADDRESS
)(
101 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
102 OUT EFI_PHYSICAL_ADDRESS
*Address
106 The GetBlockSize() function retrieves the size of the requested
107 block. It also returns the number of additional blocks with
108 the identical size. The GetBlockSize() function is used to
109 retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).
112 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
114 @param Lba Indicates the block for which to return the size.
116 @param BlockSize Pointer to a caller-allocated UINTN in which
117 the size of the block is returned.
119 @param NumberOfBlocks Pointer to a caller-allocated UINTN in
120 which the number of consecutive blocks,
121 starting with Lba, is returned. All
122 blocks in this range have a size of
126 @retval EFI_SUCCESS The firmware volume base address was returned.
128 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.
133 (EFIAPI
*EFI_FVB_GET_BLOCK_SIZE
)(
134 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
136 OUT UINTN
*BlockSize
,
137 OUT UINTN
*NumberOfBlocks
141 Reads the specified number of bytes into a buffer from the specified block.
143 The Read() function reads the requested number of bytes from the
144 requested block and stores them in the provided buffer.
145 Implementations should be mindful that the firmware volume
146 might be in the ReadDisabled state. If it is in this state,
147 the Read() function must return the status code
148 EFI_ACCESS_DENIED without modifying the contents of the
149 buffer. The Read() function must also prevent spanning block
150 boundaries. If a read is requested that would span a block
151 boundary, the read must read up to the boundary but not
152 beyond. The output parameter NumBytes must be set to correctly
153 indicate the number of bytes actually read. The caller must be
154 aware that a read may be partially completed.
156 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
158 @param Lba The starting logical block index
161 @param Offset Offset into the block at which to begin reading.
163 @param NumBytes Pointer to a UINTN. At entry, *NumBytes
164 contains the total size of the buffer. At
165 exit, *NumBytes contains the total number of
168 @param Buffer Pointer to a caller-allocated buffer that will
169 be used to hold the data that is read.
171 @retval EFI_SUCCESS The firmware volume was read successfully,
172 and contents are in Buffer.
174 @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA
175 boundary. On output, NumBytes
176 contains the total number of bytes
179 @retval EFI_ACCESS_DENIED The firmware volume is in the
182 @retval EFI_DEVICE_ERROR The block device is not
183 functioning correctly and could
189 (EFIAPI
*EFI_FVB_READ
)(
190 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
193 IN OUT UINTN
*NumBytes
,
198 Writes the specified number of bytes from the input buffer to the block.
200 The Write() function writes the specified number of bytes from
201 the provided buffer to the specified block and offset. If the
202 firmware volume is sticky write, the caller must ensure that
203 all the bits of the specified range to write are in the
204 EFI_FVB_ERASE_POLARITY state before calling the Write()
205 function, or else the result will be unpredictable. This
206 unpredictability arises because, for a sticky-write firmware
207 volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY
208 state but cannot flip it back again. Before calling the
209 Write() function, it is recommended for the caller to first call
210 the EraseBlocks() function to erase the specified block to
211 write. A block erase cycle will transition bits from the
212 (NOT)EFI_FVB_ERASE_POLARITY state back to the
213 EFI_FVB_ERASE_POLARITY state. Implementations should be
214 mindful that the firmware volume might be in the WriteDisabled
215 state. If it is in this state, the Write() function must
216 return the status code EFI_ACCESS_DENIED without modifying the
217 contents of the firmware volume. The Write() function must
218 also prevent spanning block boundaries. If a write is
219 requested that spans a block boundary, the write must store up
220 to the boundary but not beyond. The output parameter NumBytes
221 must be set to correctly indicate the number of bytes actually
222 written. The caller must be aware that a write may be
223 partially completed. All writes, partial or otherwise, must be
224 fully flushed to the hardware before the Write() service
227 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
229 @param Lba The starting logical block index to write to.
231 @param Offset Offset into the block at which to begin writing.
233 @param NumBytes The pointer to a UINTN. At entry, *NumBytes
234 contains the total size of the buffer. At
235 exit, *NumBytes contains the total number of
236 bytes actually written.
238 @param Buffer The pointer to a caller-allocated buffer that
239 contains the source for the write.
241 @retval EFI_SUCCESS The firmware volume was written successfully.
243 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an
244 LBA boundary. On output, NumBytes
245 contains the total number of bytes
248 @retval EFI_ACCESS_DENIED The firmware volume is in the
251 @retval EFI_DEVICE_ERROR The block device is malfunctioning
252 and could not be written.
258 (EFIAPI
*EFI_FVB_WRITE
)(
259 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
262 IN OUT UINTN
*NumBytes
,
267 /// EFI_LBA_LIST_TERMINATOR
269 #define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL
272 Erases and initializes a firmware volume block.
274 The EraseBlocks() function erases one or more blocks as denoted
275 by the variable argument list. The entire parameter list of
276 blocks must be verified before erasing any blocks. If a block is
277 requested that does not exist within the associated firmware
278 volume (it has a larger index than the last block of the
279 firmware volume), the EraseBlocks() function must return the
280 status code EFI_INVALID_PARAMETER without modifying the contents
281 of the firmware volume. Implementations should be mindful that
282 the firmware volume might be in the WriteDisabled state. If it
283 is in this state, the EraseBlocks() function must return the
284 status code EFI_ACCESS_DENIED without modifying the contents of
285 the firmware volume. All calls to EraseBlocks() must be fully
286 flushed to the hardware before the EraseBlocks() service
289 @param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
292 @param ... The variable argument list is a list of tuples.
293 Each tuple describes a range of LBAs to erase
294 and consists of the following:
295 - An EFI_LBA that indicates the starting LBA
296 - A UINTN that indicates the number of blocks to
299 The list is terminated with an
300 EFI_LBA_LIST_TERMINATOR. For example, the
301 following indicates that two ranges of blocks
302 (5-7 and 10-11) are to be erased: EraseBlocks
303 (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);
305 @retval EFI_SUCCESS The erase request successfully
308 @retval EFI_ACCESS_DENIED The firmware volume is in the
310 @retval EFI_DEVICE_ERROR The block device is not functioning
311 correctly and could not be written.
312 The firmware device may have been
314 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed
315 in the variable argument list do
316 not exist in the firmware volume.
321 (EFIAPI
*EFI_FVB_ERASE_BLOCKS
)(
322 IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
*This
,
327 /// The Firmware Volume Block Protocol is the low-level interface
328 /// to a firmware volume. File-level access to a firmware volume
329 /// should not be done using the Firmware Volume Block Protocol.
330 /// Normal access to a firmware volume must use the Firmware
331 /// Volume Protocol. Typically, only the file system driver that
332 /// produces the Firmware Volume Protocol will bind to the
333 /// Firmware Volume Block Protocol.
335 struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
{
336 EFI_FVB_GET_ATTRIBUTES GetAttributes
;
337 EFI_FVB_SET_ATTRIBUTES SetAttributes
;
338 EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress
;
339 EFI_FVB_GET_BLOCK_SIZE GetBlockSize
;
342 EFI_FVB_ERASE_BLOCKS EraseBlocks
;
344 /// The handle of the parent firmware volume.
346 EFI_HANDLE ParentHandle
;
349 extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid
;
350 extern EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid
;