]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkPkg/Include/Protocol/FrameworkFirmwareVolumeBlock.h
clean up non-English characters.
[mirror_edk2.git] / IntelFrameworkPkg / Include / Protocol / FrameworkFirmwareVolumeBlock.h
CommitLineData
220c61c1 1/** @file\r
2 This file provides control over block-oriented firmware devices.\r
3\r
4 Copyright (c) 2006 - 2008, Intel Corporation \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 @par Revision Reference: \r
14 This protocol is defined in framework spec: Firmware Volume Block specification\r
15\r
16**/\r
17\r
18#ifndef __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__\r
19#define __FRAMEWORK_FIRMWARE_VOLUME_BLOCK_H__\r
20\r
220c61c1 21\r
22typedef struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;\r
23///\r
24/// type of EFI FVB attribute per Frameowrk spec\r
25/// \r
26typedef UINT32 EFI_FVB_ATTRIBUTES;\r
27\r
28/**\r
29 The GetAttributes() function retrieves the attributes and\r
5259c97d 30 current settings of the block. \r
220c61c1 31\r
32 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
33\r
34 @param Attributes Pointer to EFI_FVB_ATTRIBUTES in which the\r
35 attributes and current settings are\r
36 returned. \r
37\r
38 @retval EFI_SUCCESS The firmware volume attributes were\r
39 returned.\r
40\r
41**/\r
42typedef\r
43EFI_STATUS\r
44(EFIAPI * FRAMEWORK_EFI_FVB_GET_ATTRIBUTES)(\r
45 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
46 OUT EFI_FVB_ATTRIBUTES *Attributes\r
47);\r
48\r
49\r
50/**\r
51 The SetAttributes() function sets configurable firmware volume\r
52 attributes and returns the new settings of the firmware volume.\r
53\r
54 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
55\r
56 @param Attributes On input, Attributes is a pointer to\r
57 EFI_FVB_ATTRIBUTES that contains the\r
58 desired firmware volume settings. On\r
59 successful return, it contains the new\r
60 settings of the firmware volume. \r
61 \r
62 @retval EFI_SUCCESS The firmware volume attributes were returned.\r
63\r
64 @retval EFI_INVALID_PARAMETER The attributes requested are in\r
65 conflict with the capabilities\r
66 as declared in the firmware\r
67 volume header.\r
68\r
69**/\r
70typedef\r
71EFI_STATUS\r
72(EFIAPI * FRAMEWORK_EFI_FVB_SET_ATTRIBUTES)(\r
73 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
74 IN OUT EFI_FVB_ATTRIBUTES *Attributes\r
75);\r
76\r
77\r
78/**\r
79 The GetPhysicalAddress() function retrieves the base address of\r
80 a memory-mapped firmware volume. This function should be called\r
81 only for memory-mapped firmware volumes.\r
82\r
83 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
84 \r
85 @param Address Pointer to a caller-allocated\r
86 EFI_PHYSICAL_ADDRESS that, on successful\r
87 return from GetPhysicalAddress(), contains the\r
88 base address of the firmware volume.\r
89 \r
90 @retval EFI_SUCCESS The firmware volume base address is returned.\r
91 \r
92 @retval EFI_NOT_SUPPORTED The firmware volume is not memory mapped.\r
93\r
94**/\r
95typedef\r
96EFI_STATUS\r
97(EFIAPI * FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS)(\r
98 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
99 OUT EFI_PHYSICAL_ADDRESS *Address\r
100);\r
101\r
102/**\r
103 The GetBlockSize() function retrieves the size of the requested\r
104 block. It also returns the number of additional blocks with\r
105 the identical size. The GetBlockSize() function is used to\r
106 retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).\r
107\r
108\r
109 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
110\r
111 @param Lba Indicates the block for which to return the size.\r
112\r
113 @param BlockSize Pointer to a caller-allocated UINTN in which\r
114 the size of the block is returned.\r
115\r
116 @param NumberOfBlocks Pointer to a caller-allocated UINTN in\r
117 which the number of consecutive blocks,\r
118 starting with Lba, is returned. All\r
119 blocks in this range have a size of\r
120 BlockSize.\r
121\r
122 \r
123 @retval EFI_SUCCESS The firmware volume base address is returned.\r
124 \r
125 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r
126\r
127**/\r
128typedef\r
129EFI_STATUS\r
130(EFIAPI * FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE)(\r
131 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
132 IN EFI_LBA Lba,\r
133 OUT UINTN *BlockSize,\r
134 OUT UINTN *NumberOfBlocks\r
135);\r
136\r
137\r
138/**\r
139 Reads the specified number of bytes into a buffer from the specified block.\r
140\r
141 The Read() function reads the requested number of bytes from the\r
142 requested block and stores them in the provided buffer.\r
143 Implementations should be mindful that the firmware volume\r
144 might be in the ReadDisabled state. If it is in this state,\r
145 the Read() function must return the status code\r
146 EFI_ACCESS_DENIED without modifying the contents of the\r
147 buffer. The Read() function must also prevent spanning block\r
148 boundaries. If a read is requested that would span a block\r
149 boundary, the read must read up to the boundary but not\r
150 beyond. The output parameter NumBytes must be set to correctly\r
151 indicate the number of bytes actually read. The caller must be\r
152 aware that a read may be partially completed.\r
153\r
154 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
155 \r
156 @param Lba The starting logical block index\r
157 from which to read.\r
158\r
159 @param Offset Offset into the block at which to begin reading.\r
160\r
161 @param NumBytes Pointer to a UINTN. At entry, *NumBytes\r
162 contains the total size of the buffer. At\r
163 exit, *NumBytes contains the total number of\r
164 bytes read.\r
165\r
166 @param Buffer Pointer to a caller-allocated buffer that will\r
167 be used to hold the data that is read.\r
168\r
169 @retval EFI_SUCCESS The firmware volume was read successfully\r
170 and contents are in Buffer.\r
171 \r
172 @retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA\r
173 boundary. On output, NumBytes\r
174 contains the total number of bytes\r
175 returned in Buffer.\r
176 \r
177 @retval EFI_ACCESS_DENIED The firmware volume is in the\r
178 ReadDisabled state.\r
179 \r
180 @retval EFI_DEVICE_ERROR The block device is not\r
181 functioning correctly and could\r
182 not be read.\r
183\r
184**/\r
185typedef\r
186EFI_STATUS\r
187(EFIAPI *FRAMEWORK_EFI_FVB_READ)(\r
188 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
189 IN EFI_LBA Lba,\r
190 IN UINTN Offset,\r
191 IN OUT UINTN *NumBytes,\r
192 IN OUT UINT8 *Buffer\r
193);\r
194\r
195/**\r
196 Writes the specified number of bytes from the input buffer to the block.\r
197\r
198 The Write() function writes the specified number of bytes from\r
199 the provided buffer to the specified block and offset. If the\r
200 firmware volume is sticky write, the caller must ensure that\r
201 all the bits of the specified range to write are in the\r
202 EFI_FVB_ERASE_POLARITY state before calling the Write()\r
203 function, or else the result will be unpredictable. This\r
204 unpredictability arises because, for a sticky-write firmware\r
205 volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY\r
206 state but cannot flip it back again. In general, before\r
207 calling the Write() function, the caller should call the\r
208 EraseBlocks() function first to erase the specified block to\r
209 write. A block erase cycle will transition bits from the\r
210 (NOT)EFI_FVB_ERASE_POLARITY state back to the\r
211 EFI_FVB_ERASE_POLARITY state. Implementations should be\r
212 mindful that the firmware volume might be in the WriteDisabled\r
213 state. If it is in this state, the Write() function must\r
214 return the status code EFI_ACCESS_DENIED without modifying the\r
215 contents of the firmware volume. The Write() function must\r
216 also prevent spanning block boundaries. If a write is\r
217 requested that spans a block boundary, the write must store up\r
218 to the boundary but not beyond. The output parameter NumBytes\r
219 must be set to correctly indicate the number of bytes actually\r
220 written. The caller must be aware that a write may be\r
221 partially completed. All writes, partial or otherwise, must be\r
222 fully flushed to the hardware before the Write() service\r
223 returns.\r
224\r
225 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL instance.\r
226 \r
227 @param Lba The starting logical block index to write to.\r
228 \r
229 @param Offset Offset into the block at which to begin writing.\r
230 \r
5259c97d 231 @param NumBytes Pointer to a UINTN. Input: the total size of the buffer.\r
232 Output: the total number of bytes actually written.\r
220c61c1 233 \r
234 @param Buffer Pointer to a caller-allocated buffer that\r
235 contains the source for the write.\r
236 \r
237 @retval EFI_SUCCESS The firmware volume was written successfully.\r
238 \r
239 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an\r
240 LBA boundary. On output, NumBytes\r
241 contains the total number of bytes\r
242 actually written.\r
243 \r
244 @retval EFI_ACCESS_DENIED The firmware volume is in the\r
245 WriteDisabled state.\r
246 \r
247 @retval EFI_DEVICE_ERROR The block device is malfunctioning\r
248 and could not be written.\r
249\r
250\r
251**/\r
252typedef\r
253EFI_STATUS\r
254(EFIAPI * FRAMEWORK_EFI_FVB_WRITE)(\r
255 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
256 IN EFI_LBA Lba,\r
257 IN UINTN Offset,\r
258 IN OUT UINTN *NumBytes,\r
259 IN UINT8 *Buffer\r
260);\r
261\r
262\r
263\r
264\r
265///\r
266/// EFI_LBA_LIST_TERMINATOR\r
267///\r
268#define FRAMEWORK_EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL\r
269\r
270\r
271/**\r
272 Erases and initializes a firmware volume block.\r
273\r
274 The EraseBlocks() function erases one or more blocks as denoted\r
275 by the variable argument list. The entire parameter list of\r
276 blocks must be verified before erasing any blocks. If a block is\r
277 requested that does not exist within the associated firmware\r
278 volume (it has a larger index than the last block of the\r
279 firmware volume), the EraseBlocks() function must return the\r
280 status code EFI_INVALID_PARAMETER without modifying the contents\r
281 of the firmware volume. Implementations should be mindful that\r
282 the firmware volume might be in the WriteDisabled state. If it\r
283 is in this state, the EraseBlocks() function must return the\r
284 status code EFI_ACCESS_DENIED without modifying the contents of\r
285 the firmware volume. All calls to EraseBlocks() must be fully\r
286 flushed to the hardware before the EraseBlocks() service\r
287 returns.\r
288\r
289 @param This Indicates the FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL\r
290 instance.\r
291\r
5259c97d 292 @param ... A list of tuples.\r
220c61c1 293 Each tuple describes a range of LBAs to erase\r
294 and consists of the following:\r
295 - An EFI_LBA that indicates the starting LBA\r
296 - A UINTN that indicates the number of blocks to\r
297 erase\r
298\r
299 The list is terminated with an\r
300 EFI_LBA_LIST_TERMINATOR. For example, the\r
301 following indicates that two ranges of blocks\r
302 (5-7 and 10-11) are to be erased: EraseBlocks\r
303 (This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);\r
304\r
305 @retval EFI_SUCCESS The erase request was successfully\r
306 completed.\r
307 \r
308 @retval EFI_ACCESS_DENIED The firmware volume is in the\r
309 WriteDisabled state.\r
310 @retval EFI_DEVICE_ERROR The block device is not functioning\r
311 correctly and could not be written.\r
312 The firmware device may have been\r
313 partially erased.\r
314 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed\r
315 in the variable argument list do\r
316 not exist in the firmware volume. \r
317\r
318**/\r
319typedef\r
320EFI_STATUS\r
321(EFIAPI * FRAMEWORK_EFI_FVB_ERASE_BLOCKS)(\r
322 IN FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
323 ...\r
324);\r
325\r
326///\r
327/// The Firmware Volume Block Protocol is the low-level interface\r
328/// to a firmware volume. File-level access to a firmware volume\r
329/// should not be done using the Firmware Volume Block Protocol.\r
330/// Normal access to a firmware volume must use the Firmware\r
331/// Volume Protocol. Typically, only the file system driver that\r
332/// produces the Firmware Volume Protocol will bind to the\r
333/// Firmware Volume Block Protocol.\r
334///\r
335struct _FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL {\r
336 FRAMEWORK_EFI_FVB_GET_ATTRIBUTES GetAttributes;\r
337 FRAMEWORK_EFI_FVB_SET_ATTRIBUTES SetAttributes;\r
338 FRAMEWORK_EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress;\r
339 FRAMEWORK_EFI_FVB_GET_BLOCK_SIZE GetBlockSize;\r
340 FRAMEWORK_EFI_FVB_READ Read;\r
341 FRAMEWORK_EFI_FVB_WRITE Write;\r
342 FRAMEWORK_EFI_FVB_ERASE_BLOCKS EraseBlocks;\r
343 ///\r
344 /// Handle of the parent firmware volume.\r
345 /// \r
346 EFI_HANDLE ParentHandle;\r
347};\r
348\r
349\r
350\r
351#endif\r