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