]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/FvbServiceLib.h
sync the comments of FvbServiceLib library class with Mde Library Spec.
[mirror_edk2.git] / MdePkg / Include / Library / FvbServiceLib.h
CommitLineData
842f5579
A
1/** @file\r
2 Firmeware Volume BLock Service Library\r
fb3df220 3\r
bf231ea6 4 Copyright (c) 2006 - 2007, Intel Corporation.<BR>\r
842f5579
A
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
fb3df220 9\r
842f5579
A
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
fb3df220 12\r
842f5579 13**/\r
fb3df220 14\r
584125bc 15#ifndef __FVB_SERVICE_LIB_H__\r
16#define __FVB_SERVICE_LIB_H__\r
fb3df220 17\r
bf231ea6 18/**
7acc6db7 19 Reads specified number of bytes into a buffer from the specified block.\r
1b88ce86 20\r
21 The EfiFvbReadBlock() function reads the requested number of bytes from\r
22 the requested block in the specified firmware volume and stores them in\r
23 the provided buffer. Implementations should be mindful that the firmware\r
24 volume might be in the ReadDisabled state. If it is in this state, the \r
25 EfiFvbReadBlock() function must return the status code EFI_ACCESS_DENIED\r
26 without modifying the contents of the buffer.\r
27 \r
28 The EfiFvbReadBlock() function must also prevent spanning block boundaries.\r
29 If a read is requested that would span a block boundary, the read must read\r
30 up to the boundary but not beyond. The output parameter NumBytes must be\r
31 set to correctly indicate the number of bytes actually read. \r
32 The caller must be aware that a read may be partially completed.\r
33\r
34 If NumBytes is NULL, then ASSERT().\r
35\r
36 If Buffer is NULL, then ASSERT().\r
37\r
38 @param[in] Instance The FV instance to be read from.\r
39 @param[in] Lba The logical block address to be read from\r
40 @param[in] Offset The offset relative to the block, at which to begin reading.\r
41 @param[in, out] NumBytes Pointer to a UINTN. On input, *NumBytes contains the total\r
42 size of the buffer. On output, it contains the actual number\r
43 of bytes read.\r
44 @param[out] Buffer Pointer to a caller allocated buffer that will be\r
45 used to hold the data read.\r
46\r
47 @retval EFI_SUCCESS The firmware volume was read successfully and contents are in Buffer.\r
48 @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer.\r
49 @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state.\r
50 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be read.\r
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.\r
bf231ea6
A
52
53**/\r
fb3df220 54EFI_STATUS\r
9199040c 55EFIAPI\r
fb3df220 56EfiFvbReadBlock (\r
57 IN UINTN Instance,\r
58 IN EFI_LBA Lba,\r
59 IN UINTN Offset,\r
60 IN OUT UINTN *NumBytes,\r
c57da111 61 OUT UINT8 *Buffer\r
bf231ea6 62 );\r
fb3df220 63\r
fb3df220 64\r
1b88ce86 65/**\r
66 Writes specified number of bytes from the input buffer to the block\r
67\r
68 The EfiFvbWriteBlock() function writes the specified number of bytes\r
69 from the provided buffer to the specified block and offset in the \r
70 requested firmware volume. \r
71\r
72 If the firmware volume is sticky write, the caller must ensure that\r
73 all the bits of the specified range to write are in the EFI_FVB_ERASE_POLARITY\r
74 state before calling the EfiFvbWriteBlock() function, or else the \r
75 result will be unpredictable. This unpredictability arises because,\r
76 for a sticky-write firmware volume, a write may negate a bit in the \r
77 EFI_FVB_ERASE_POLARITY state but it cannot flip it back again. In \r
78 general, before calling the EfiFvbWriteBlock() function, the caller\r
79 should call the EfiFvbEraseBlock() function first to erase the specified\r
80 block to write. A block erase cycle will transition bits from the\r
81 (NOT)EFI_FVB_ERASE_POLARITY state back to the EFI_FVB_ERASE_POLARITY state.\r
82 Implementations should be mindful that the firmware volume might be \r
83 in the WriteDisabled state. If it is in this state, the EfiFvbWriteBlock()\r
84 function must return the status code EFI_ACCESS_DENIED without modifying\r
85 the contents of the firmware volume.\r
86 \r
87 The EfiFvbWriteBlock() function must also prevent spanning block boundaries.\r
88 If a write is requested that spans a block boundary, the write must store\r
89 up to the boundary but not beyond. The output parameter NumBytes must be \r
90 set to correctly indicate the number of bytes actually written. The caller\r
91 must be aware that a write may be partially completed.\r
92 All writes, partial or otherwise, must be fully flushed to the hardware \r
93 before the EfiFvbWriteBlock() function returns. \r
94 \r
95 If NumBytes is NULL, then ASSERT().\r
96\r
97 @param Instance The FV instance to be written to\r
98 @param Lba The starting logical block index to write to\r
99 @param Offset The offset relative to the block, at which to begin writting.\r
100 @param NumBytes Pointer to a UINTN. On input, *NumBytes contains\r
101 the total size of the buffer. On output, it contains\r
102 the actual number of bytes written.\r
103 @param Buffer Pointer to a caller allocated buffer that contains\r
104 the source for the write\r
105\r
106 @retval EFI_SUCCESS The firmware volume was written successfully.\r
107 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. \r
108 On output, NumBytes contains the total number of bytes actually written.\r
109 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
110 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not be written.\r
111 @retval EFI_INVALID_PARAMETER Invalid parameter, Instance is larger than the max FVB number. \r
112 Lba index is larger than the last block of the firmware volume.\r
113 Offset is larger than the block size.\r
bf231ea6 114**/\r
fb3df220 115EFI_STATUS\r
9199040c 116EFIAPI\r
fb3df220 117EfiFvbWriteBlock (\r
118 IN UINTN Instance,\r
119 IN EFI_LBA Lba,\r
120 IN UINTN Offset,\r
121 IN OUT UINTN *NumBytes,\r
122 IN UINT8 *Buffer\r
bf231ea6 123 );\r
fb3df220 124\r
fb3df220 125\r
bf231ea6 126/**
7acc6db7 127 Erases and initializes a firmware volume block.\r
1b88ce86 128\r
129 The EfiFvbEraseBlock() function erases one block specified by Lba.\r
130 Implementations should be mindful that the firmware volume might \r
131 be in the WriteDisabled state. If it is in this state, the EfiFvbEraseBlock()\r
132 function must return the status code EFI_ACCESS_DENIED without \r
133 modifying the contents of the firmware volume. If Instance is \r
134 larger than the max FVB number, or Lba index is larger than the\r
135 last block of the firmware volume, this function return the status\r
136 code EFI_INVALID_PARAMETER.\r
137 \r
138 All calls to EfiFvbEraseBlock() must be fully flushed to the \r
139 hardware before this function returns. \r
bf231ea6 140
7acc6db7 141 @param[in] Instance The FV instance to be erased.\r
1b88ce86 142 @param[in] Lba The logical block index to be erased from.\r
143 \r
144 @retval EFI_SUCCESS The erase request was successfully completed.\r
145 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state.\r
146 @retval EFI_DEVICE_ERROR The block device is not functioning correctly and\r
147 could not be written. The firmware device may \r
148 have been partially erased.\r
149 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max\r
150 FVB number. Lba index is larger than the last block\r
151 of the firmware volume. \r
bf231ea6
A
152
153**/\r
fb3df220 154EFI_STATUS\r
9199040c 155EFIAPI\r
fb3df220 156EfiFvbEraseBlock (\r
157 IN UINTN Instance,\r
158 IN EFI_LBA Lba\r
bf231ea6 159 );\r
fb3df220 160\r
fb3df220 161\r
bf231ea6 162/**
1b88ce86 163 Retrieves the attributes and current settings of the specified block, \r
164 returns resulting attributes in output parameter.\r
165\r
166 The EfiFvbGetAttributes() function retrieves the attributes and current\r
167 settings of the block specified by Instance. If Instance is larger than\r
168 the max FVB number, this function returns the status code EFI_INVALID_PARAMETER.\r
169\r
170 If Attributes is NULL, then ASSERT().\r
bf231ea6 171
1b88ce86 172 @param[in] Instance The FV instance to be operated.\r
173 @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the\r
174 attributes and current settings are returned.\r
bf231ea6 175
1b88ce86 176 @retval EFI_EFI_SUCCESS The firmware volume attributes were returned.\r
177 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
bf231ea6 178**/\r
fb3df220 179EFI_STATUS\r
9199040c 180EFIAPI\r
fb3df220 181EfiFvbGetVolumeAttributes (\r
182 IN UINTN Instance,\r
4ba967e7 183 OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
bf231ea6 184 );\r
fb3df220 185\r
fb3df220 186\r
bf231ea6 187/**
1b88ce86 188 Modify the attributes and current settings of the specified block\r
189 according to the input parameter.\r
190\r
191 The EfiFvbSetAttributes() function sets configurable firmware volume\r
192 attributes and returns the new settings of the firmware volume specified\r
193 by Instance. If Instance is larger than the max FVB number, this function\r
194 returns the status code EFI_INVALID_PARAMETER.\r
195\r
196 If Attributes is NULL, then ASSERT().\r
197\r
198 @param[in] Instance The FV instance to be operated.\r
199 @param[in, out]Attributes On input, Attributes is a pointer to EFI_FVB_ATTRIBUTES_2\r
200 that contains the desired firmware volume settings. \r
201 On successful return, it contains the new settings of the firmware volume.\r
bf231ea6 202
1b88ce86 203 @retval EFI_EFI_SUCCESS The firmware volume attributes were modified successfully.\r
204 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
bf231ea6
A
205
206**/\r
fb3df220 207EFI_STATUS\r
9199040c 208EFIAPI\r
fb3df220 209EfiFvbSetVolumeAttributes (\r
d3a58e2d 210 IN UINTN Instance,\r
4ba967e7 211 IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes\r
bf231ea6 212 );\r
fb3df220 213\r
fb3df220 214\r
bf231ea6 215/**
1b88ce86 216 Retrieves the physical address of the specified memory mapped FV.\r
217\r
218 Retrieve the base address of a memory-mapped firmware volume specified by Instance.\r
219 If Instance is larger than the max FVB number, this function returns the status \r
220 code EFI_INVALID_PARAMETER.\r
221 \r
222 If BaseAddress is NULL, then ASSERT().\r
bf231ea6 223
1b88ce86 224 @param[in] Instance The FV instance to be operated.\r
225 @param[out] BaseAddress Pointer to a caller allocated EFI_PHYSICAL_ADDRESS \r
226 that on successful return, contains the base address\r
227 of the firmware volume. \r
bf231ea6 228
1b88ce86 229 @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
230 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
bf231ea6
A
231
232**/\r
fb3df220 233EFI_STATUS\r
9199040c 234EFIAPI\r
fb3df220 235EfiFvbGetPhysicalAddress (\r
236 IN UINTN Instance,\r
237 OUT EFI_PHYSICAL_ADDRESS *BaseAddress\r
bf231ea6 238 );\r
fb3df220 239\r
fb3df220 240\r
bf231ea6 241/**
1b88ce86 242 Retrieve the block size of the specified fv.\r
243 \r
244 The EfiFvbGetBlockSize() function retrieves the size of the requested block. \r
245 It also returns the number of additional blocks with the identical size. \r
246 If Instance is larger than the max FVB number, or Lba index is larger than\r
247 the last block of the firmware volume, this function return the status code\r
248 EFI_INVALID_PARAMETER.\r
249\r
250 If BlockSize is NULL, then ASSERT().\r
251 \r
252 If NumOfBlocks is NULL, then ASSERT().\r
bf231ea6 253
1b88ce86 254 @param[in] Instance The FV instance to be operated.\r
255 @param[in] Lba Indicates which block to return the size for.\r
256 @param[out] BlockSize Pointer to a caller-allocated UINTN in which the\r
257 size of the block is returned.\r
258 @param[out] NumOfBlocks Pointer to a caller-allocated UINTN in which the \r
259 number of consecutive blocks, starting with Lba, \r
260 is returned. All blocks in this range have a size of BlockSize.\r
bf231ea6 261
1b88ce86 262 @retval EFI_EFI_SUCCESS The firmware volume base address is returned.\r
263 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number.\r
264 Lba index is larger than the last block of the firmware volume.\r
bf231ea6
A
265
266**/\r
fb3df220 267EFI_STATUS\r
9199040c 268EFIAPI\r
fb3df220 269EfiFvbGetBlockSize (\r
270 IN UINTN Instance,\r
271 IN EFI_LBA Lba,\r
272 OUT UINTN *BlockSize,\r
273 OUT UINTN *NumOfBlocks\r
bf231ea6 274 );\r
fb3df220 275\r
fb3df220 276\r
bf231ea6 277/**
7acc6db7 278 Erases and initializes a specified range of a firmware volume.\r
1b88ce86 279\r
280 The EfiFvbEraseCustomBlockRange() function erases the specified range in the firmware\r
281 volume index by Instance. If Instance is larger than the max FVB number, StartLba or \r
282 LastLba index is larger than the last block of the firmware volume, StartLba > LastLba\r
283 or StartLba equal to LastLba but OffsetStartLba > OffsetLastLba, this function return \r
284 the status code EFI_INVALID_PARAMETER.\r
bf231ea6 285
1b88ce86 286 @param[in] Instance The FV instance to be operated.\r
287 @param[in] StartLba The starting logical block index to be erased.\r
288 @param[in] OffsetStartLba Offset into the starting block at which to \r
289 begin erasing. \r
290 @param[in] LastLba The last logical block index to be erased.\r
291 @param[in] OffsetLastLba Offset into the last block at which to end erasing. \r
bf231ea6 292
1b88ce86 293 @retval EFI_EFI_SUCCESS Successfully erase custom block range\r
294 @retval EFI_INVALID_PARAMETER Invalid parameter. Instance is larger than the max FVB number. \r
295 @retval EFI_UNSUPPORTED Firmware volume block device has no this capability.\r
bf231ea6
A
296
297**/\r
fb3df220 298EFI_STATUS\r
9199040c 299EFIAPI\r
fb3df220 300EfiFvbEraseCustomBlockRange (\r
301 IN UINTN Instance,\r
302 IN EFI_LBA StartLba,\r
303 IN UINTN OffsetStartLba,\r
304 IN EFI_LBA LastLba,\r
305 IN UINTN OffsetLastLba\r
bf231ea6 306 );\r
fb3df220 307\r
308#endif\r