]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Library/FvbServiceLib.h
sync the comments of FvbServiceLib library class with Mde Library Spec.
[mirror_edk2.git] / MdePkg / Include / Library / FvbServiceLib.h
1 /** @file
2 Firmeware Volume BLock Service Library
3
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
9
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.
12
13 **/
14
15 #ifndef __FVB_SERVICE_LIB_H__
16 #define __FVB_SERVICE_LIB_H__
17
18 /**
19 Reads specified number of bytes into a buffer from the specified block.
20
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.
27
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.
33
34 If NumBytes is NULL, then ASSERT().
35
36 If Buffer is NULL, then ASSERT().
37
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
43 of bytes read.
44 @param[out] Buffer Pointer to a caller allocated buffer that will be
45 used to hold the data read.
46
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.
52
53 **/
54 EFI_STATUS
55 EFIAPI
56 EfiFvbReadBlock (
57 IN UINTN Instance,
58 IN EFI_LBA Lba,
59 IN UINTN Offset,
60 IN OUT UINTN *NumBytes,
61 OUT UINT8 *Buffer
62 );
63
64
65 /**
66 Writes specified number of bytes from the input buffer to the block
67
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.
71
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.
86
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.
94
95 If NumBytes is NULL, then ASSERT().
96
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
105
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.
114 **/
115 EFI_STATUS
116 EFIAPI
117 EfiFvbWriteBlock (
118 IN UINTN Instance,
119 IN EFI_LBA Lba,
120 IN UINTN Offset,
121 IN OUT UINTN *NumBytes,
122 IN UINT8 *Buffer
123 );
124
125
126 /**
127 Erases and initializes a firmware volume block.
128
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.
137
138 All calls to EfiFvbEraseBlock() must be fully flushed to the
139 hardware before this function returns.
140
141 @param[in] Instance The FV instance to be erased.
142 @param[in] Lba The logical block index to be erased from.
143
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.
152
153 **/
154 EFI_STATUS
155 EFIAPI
156 EfiFvbEraseBlock (
157 IN UINTN Instance,
158 IN EFI_LBA Lba
159 );
160
161
162 /**
163 Retrieves the attributes and current settings of the specified block,
164 returns resulting attributes in output parameter.
165
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.
169
170 If Attributes is NULL, then ASSERT().
171
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.
175
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.
178 **/
179 EFI_STATUS
180 EFIAPI
181 EfiFvbGetVolumeAttributes (
182 IN UINTN Instance,
183 OUT EFI_FVB_ATTRIBUTES_2 *Attributes
184 );
185
186
187 /**
188 Modify the attributes and current settings of the specified block
189 according to the input parameter.
190
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.
195
196 If Attributes is NULL, then ASSERT().
197
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.
202
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.
205
206 **/
207 EFI_STATUS
208 EFIAPI
209 EfiFvbSetVolumeAttributes (
210 IN UINTN Instance,
211 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
212 );
213
214
215 /**
216 Retrieves the physical address of the specified memory mapped FV.
217
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.
221
222 If BaseAddress is NULL, then ASSERT().
223
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.
228
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.
231
232 **/
233 EFI_STATUS
234 EFIAPI
235 EfiFvbGetPhysicalAddress (
236 IN UINTN Instance,
237 OUT EFI_PHYSICAL_ADDRESS *BaseAddress
238 );
239
240
241 /**
242 Retrieve the block size of the specified fv.
243
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.
249
250 If BlockSize is NULL, then ASSERT().
251
252 If NumOfBlocks is NULL, then ASSERT().
253
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.
261
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.
265
266 **/
267 EFI_STATUS
268 EFIAPI
269 EfiFvbGetBlockSize (
270 IN UINTN Instance,
271 IN EFI_LBA Lba,
272 OUT UINTN *BlockSize,
273 OUT UINTN *NumOfBlocks
274 );
275
276
277 /**
278 Erases and initializes a specified range of a firmware volume.
279
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.
285
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
289 begin erasing.
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.
292
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.
296
297 **/
298 EFI_STATUS
299 EFIAPI
300 EfiFvbEraseCustomBlockRange (
301 IN UINTN Instance,
302 IN EFI_LBA StartLba,
303 IN UINTN OffsetStartLba,
304 IN EFI_LBA LastLba,
305 IN UINTN OffsetLastLba
306 );
307
308 #endif