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