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