2 Firmeware Volume BLock Service Library
4 Copyright (c) 2006 - 2007, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __FVB_SERVICE_LIB_H__
16 #define __FVB_SERVICE_LIB_H__
19 Reads specified number of bytes into a buffer from the specified block.
21 The EfiFvbReadBlock() function reads the requested number of bytes from
22 the requested block in the specified firmware volume and stores them in
23 the provided buffer. Implementations should be mindful that the firmware
24 volume might be in the ReadDisabled state. If it is in this state, the
25 EfiFvbReadBlock() function must return the status code EFI_ACCESS_DENIED
26 without modifying the contents of the buffer.
28 The EfiFvbReadBlock() function must also prevent spanning block boundaries.
29 If a read is requested that would span a block boundary, the read must read
30 up to the boundary but not beyond. The output parameter NumBytes must be
31 set to correctly indicate the number of bytes actually read.
32 The caller must be aware that a read may be partially completed.
34 If NumBytes is NULL, then ASSERT().
36 If Buffer is NULL, then ASSERT().
38 @param[in] Instance The FV instance to be read from.
39 @param[in] Lba The logical block address to be read from
40 @param[in] Offset The offset relative to the block, at which to begin reading.
41 @param[in, out] NumBytes Pointer to a UINTN. On input, *NumBytes contains the total
42 size of the buffer. On output, it contains the actual number
44 @param[out] Buffer Pointer to a caller allocated buffer that will be
45 used to hold the data read.
47 @retval EFI_SUCCESS The firmware volume was read successfully and contents are in Buffer.
48 @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer.
49 @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state.
50 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read.
51 @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. Lba index is larger than the last block of the firmware volume. Offset is larger than the block size.
60 IN OUT UINTN
*NumBytes
,
66 Writes specified number of bytes from the input buffer to the block
68 The EfiFvbWriteBlock() function writes the specified number of bytes
69 from the provided buffer to the specified block and offset in the
70 requested firmware volume.
72 If the firmware volume is sticky write, the caller must ensure that
73 all the bits of the specified range to write are in the EFI_FVB_ERASE_POLARITY
74 state before calling the EfiFvbWriteBlock() function, or else the
75 result will be unpredictable. This unpredictability arises because,
76 for a sticky-write firmware volume, a write may negate a bit in the
77 EFI_FVB_ERASE_POLARITY state but it cannot flip it back again. In
78 general, before calling the EfiFvbWriteBlock() function, the caller
79 should call the EfiFvbEraseBlock() function first to erase the specified
80 block to write. A block erase cycle will transition bits from the
81 (NOT)EFI_FVB_ERASE_POLARITY state back to the EFI_FVB_ERASE_POLARITY state.
82 Implementations should be mindful that the firmware volume might be
83 in the WriteDisabled state. If it is in this state, the EfiFvbWriteBlock()
84 function must return the status code EFI_ACCESS_DENIED without modifying
85 the contents of the firmware volume.
87 The EfiFvbWriteBlock() function must also prevent spanning block boundaries.
88 If a write is requested that spans a block boundary, the write must store
89 up to the boundary but not beyond. The output parameter NumBytes must be
90 set to correctly indicate the number of bytes actually written. The caller
91 must be aware that a write may be partially completed.
92 All writes, partial or otherwise, must be fully flushed to the hardware
93 before the EfiFvbWriteBlock() function returns.
95 If NumBytes is NULL, then ASSERT().
97 @param Instance The FV instance to be written to
98 @param Lba The starting logical block index to write to
99 @param Offset The offset relative to the block, at which to begin writting.
100 @param NumBytes Pointer to a UINTN. On input, *NumBytes contains
101 the total size of the buffer. On output, it contains
102 the actual number of bytes written.
103 @param Buffer Pointer to a caller allocated buffer that contains
104 the source for the write
106 @retval EFI_SUCCESS The firmware volume was written successfully.
107 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.
108 On output, NumBytes contains the total number of bytes actually written.
109 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.
110 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written.
111 @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number.
112 Lba index is larger than the last block of the firmware volume.
113 Offset is larger than the block size.
121 IN OUT UINTN
*NumBytes
,
127 Erases and initializes a firmware volume block.
129 The EfiFvbEraseBlock() function erases one block specified by Lba.
130 Implementations should be mindful that the firmware volume might
131 be in the WriteDisabled state. If it is in this state, the EfiFvbEraseBlock()
132 function must return the status code EFI_ACCESS_DENIED without
133 modifying the contents of the firmware volume. If Instance is
134 larger than the max FVB number, or Lba index is larger than the
135 last block of the firmware volume, this function return the status
136 code EFI_INVALID_PARAMETER.
138 All calls to EfiFvbEraseBlock() must be fully flushed to the
139 hardware before this function returns.
141 @param[in] Instance The FV instance to be erased.
142 @param[in] Lba The logical block index to be erased from.
144 @retval EFI_SUCCESS The erase request was successfully completed.
145 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.
146 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
147 could not be written. The firmware device may
148 have been partially erased.
149 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max
150 FVB number. Lba index is larger than the last block
151 of the firmware volume.
163 Retrieves the attributes and current settings of the specified block,
164 returns resulting attributes in output parameter.
166 The EfiFvbGetAttributes() function retrieves the attributes and current
167 settings of the block specified by Instance. If Instance is larger than
168 the max FVB number, this function returns the status code EFI_INVALID_PARAMETER.
170 If Attributes is NULL, then ASSERT().
172 @param[in] Instance The FV instance to be operated.
173 @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the
174 attributes and current settings are returned.
176 @retval EFI_EFI_SUCCESS The firmware volume attributes were returned.
177 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.
181 EfiFvbGetVolumeAttributes (
183 OUT EFI_FVB_ATTRIBUTES_2
*Attributes
188 Modify the attributes and current settings of the specified block
189 according to the input parameter.
191 The EfiFvbSetAttributes() function sets configurable firmware volume
192 attributes and returns the new settings of the firmware volume specified
193 by Instance. If Instance is larger than the max FVB number, this function
194 returns the status code EFI_INVALID_PARAMETER.
196 If Attributes is NULL, then ASSERT().
198 @param[in] Instance The FV instance to be operated.
199 @param[in, out]Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2
200 that contains the desired firmware volume settings.
201 On successful return, it contains the new settings of the firmware volume.
203 @retval EFI_EFI_SUCCESS The firmware volume attributes were modified successfully.
204 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.
209 EfiFvbSetVolumeAttributes (
211 IN OUT EFI_FVB_ATTRIBUTES_2
*Attributes
216 Retrieves the physical address of the specified memory mapped FV.
218 Retrieve the base address of a memory-mapped firmware volume specified by Instance.
219 If Instance is larger than the max FVB number, this function returns the status
220 code EFI_INVALID_PARAMETER.
222 If BaseAddress is NULL, then ASSERT().
224 @param[in] Instance The FV instance to be operated.
225 @param[out] BaseAddress Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
226 that on successful return, contains the base address
227 of the firmware volume.
229 @retval EFI_EFI_SUCCESS The firmware volume base address is returned.
230 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.
235 EfiFvbGetPhysicalAddress (
237 OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
242 Retrieve the block size of the specified fv.
244 The EfiFvbGetBlockSize() function retrieves the size of the requested block.
245 It also returns the number of additional blocks with the identical size.
246 If Instance is larger than the max FVB number, or Lba index is larger than
247 the last block of the firmware volume, this function return the status code
248 EFI_INVALID_PARAMETER.
250 If BlockSize is NULL, then ASSERT().
252 If NumOfBlocks is NULL, then ASSERT().
254 @param[in] Instance The FV instance to be operated.
255 @param[in] Lba Indicates which block to return the size for.
256 @param[out] BlockSize Pointer to a caller-allocated UINTN in which the
257 size of the block is returned.
258 @param[out] NumOfBlocks Pointer to a caller-allocated UINTN in which the
259 number of consecutive blocks, starting with Lba,
260 is returned. All blocks in this range have a size of BlockSize.
262 @retval EFI_EFI_SUCCESS The firmware volume base address is returned.
263 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.
264 Lba index is larger than the last block of the firmware volume.
272 OUT UINTN
*BlockSize
,
273 OUT UINTN
*NumOfBlocks
278 Erases and initializes a specified range of a firmware volume.
280 The EfiFvbEraseCustomBlockRange() function erases the specified range in the firmware
281 volume index by Instance. If Instance is larger than the max FVB number, StartLba or
282 LastLba index is larger than the last block of the firmware volume, StartLba > LastLba
283 or StartLba equal to LastLba but OffsetStartLba > OffsetLastLba, this function return
284 the status code EFI_INVALID_PARAMETER.
286 @param[in] Instance The FV instance to be operated.
287 @param[in] StartLba The starting logical block index to be erased.
288 @param[in] OffsetStartLba Offset into the starting block at which to
290 @param[in] LastLba The last logical block index to be erased.
291 @param[in] OffsetLastLba Offset into the last block at which to end erasing.
293 @retval EFI_EFI_SUCCESS Successfully erase custom block range
294 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.
295 @retval EFI_UNSUPPORTED Firmware volume block device has no this capability.
300 EfiFvbEraseCustomBlockRange (
303 IN UINTN OffsetStartLba
,
305 IN UINTN OffsetLastLba