]>
Commit | Line | Data |
---|---|---|
504214c4 | 1 | /** @file \r |
28a00297 | 2 | \r |
504214c4 LG |
3 | Firmware Volume Block protocol functions. \r |
4 | Consumes FV hobs and creates appropriate block protocols. \r | |
5 | \r | |
6 | Copyright (c) 2006 - 2008, Intel Corporation \r | |
28a00297 | 7 | All rights reserved. This program and the accompanying materials \r |
8 | are licensed and made available under the terms and conditions of the BSD License \r | |
9 | which accompanies this distribution. The full text of the license may be found at \r | |
10 | http://opensource.org/licenses/bsd-license.php \r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
14 | \r | |
504214c4 | 15 | **/\r |
28a00297 | 16 | \r |
17 | #ifndef _FWVOL_BLOCK_H_\r | |
18 | #define _FWVOL_BLOCK_H_\r | |
19 | \r | |
20 | \r | |
21 | #define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B')\r | |
22 | \r | |
23 | typedef struct {\r | |
24 | UINTN Base;\r | |
25 | UINTN Length;\r | |
26 | } LBA_CACHE;\r | |
27 | \r | |
28 | typedef struct {\r | |
29 | MEMMAP_DEVICE_PATH MemMapDevPath;\r | |
30 | EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r | |
31 | } FV_DEVICE_PATH;\r | |
32 | \r | |
33 | \r | |
34 | typedef struct {\r | |
35 | UINTN Signature;\r | |
36 | EFI_HANDLE Handle;\r | |
37 | FV_DEVICE_PATH DevicePath;\r | |
38 | EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;\r | |
39 | UINTN NumBlocks;\r | |
40 | LBA_CACHE *LbaCache;\r | |
41 | UINT32 FvbAttributes;\r | |
42 | EFI_PHYSICAL_ADDRESS BaseAddress;\r | |
43 | } EFI_FW_VOL_BLOCK_DEVICE;\r | |
44 | \r | |
45 | #define FVB_DEVICE_FROM_THIS(a) \\r | |
46 | CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)\r | |
47 | \r | |
48 | \r | |
49 | \r | |
162ed594 | 50 | /**\r |
51 | This routine is the driver initialization entry point. It initializes the\r | |
52 | libraries, consumes FV hobs and NT_NON_MM_FV environment variable and\r | |
53 | produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.\r | |
54 | \r | |
55 | @param ImageHandle The image handle. \r | |
56 | @param SystemTable The system table. \r | |
57 | \r | |
58 | @retval EFI_SUCCESS Successfully initialized firmware volume block \r | |
59 | driver.\r | |
60 | \r | |
61 | **/\r | |
28a00297 | 62 | EFI_STATUS\r |
63 | EFIAPI\r | |
64 | FwVolBlockDriverInit (\r | |
65 | IN EFI_HANDLE ImageHandle,\r | |
66 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
67 | )\r | |
28a00297 | 68 | ;\r |
69 | \r | |
70 | \r | |
162ed594 | 71 | \r |
72 | /**\r | |
73 | Retrieves Volume attributes. No polarity translations are done.\r | |
74 | \r | |
75 | @param This Calling context \r | |
76 | @param Attributes output buffer which contains attributes \r | |
77 | \r | |
78 | @retval EFI_SUCCESS The firmware volume attributes were returned.\r | |
79 | \r | |
80 | **/\r | |
28a00297 | 81 | EFI_STATUS\r |
82 | EFIAPI\r | |
83 | FwVolBlockGetAttributes (\r | |
84 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
85 | OUT EFI_FVB_ATTRIBUTES *Attributes\r | |
86 | )\r | |
162ed594 | 87 | ;\r |
28a00297 | 88 | \r |
28a00297 | 89 | \r |
28a00297 | 90 | \r |
162ed594 | 91 | /**\r |
92 | Modifies the current settings of the firmware volume according to the input parameter.\r | |
28a00297 | 93 | \r |
162ed594 | 94 | @param This Calling context \r |
95 | @param Attributes input buffer which contains attributes \r | |
28a00297 | 96 | \r |
162ed594 | 97 | @retval EFI_SUCCESS The firmware volume attributes were returned. \r |
98 | @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with \r | |
99 | the capabilities as declared in the firmware \r | |
100 | volume header. \r | |
101 | @retval EFI_UNSUPPORTED Not supported.\r | |
28a00297 | 102 | \r |
162ed594 | 103 | **/\r |
28a00297 | 104 | EFI_STATUS\r |
105 | EFIAPI\r | |
106 | FwVolBlockSetAttributes (\r | |
107 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
108 | IN CONST EFI_FVB_ATTRIBUTES *Attributes\r | |
109 | )\r | |
162ed594 | 110 | ;\r |
28a00297 | 111 | \r |
28a00297 | 112 | \r |
28a00297 | 113 | \r |
162ed594 | 114 | /**\r |
115 | The EraseBlock() function erases one or more blocks as denoted by the\r | |
116 | variable argument list. The entire parameter list of blocks must be verified\r | |
117 | prior to erasing any blocks. If a block is requested that does not exist\r | |
118 | within the associated firmware volume (it has a larger index than the last\r | |
119 | block of the firmware volume), the EraseBlock() function must return\r | |
120 | EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.\r | |
121 | \r | |
122 | @param This Calling context \r | |
123 | @param ... Starting LBA followed by Number of Lba to erase. \r | |
124 | a -1 to terminate the list. \r | |
28a00297 | 125 | \r |
162ed594 | 126 | @retval EFI_SUCCESS The erase request was successfully completed. \r |
127 | @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled \r | |
128 | state. \r | |
129 | @retval EFI_DEVICE_ERROR The block device is not functioning correctly \r | |
130 | and could not be written. The firmware device \r | |
131 | may have been partially erased. \r | |
132 | @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable \r | |
133 | argument list do \r | |
134 | @retval EFI_UNSUPPORTED Not supported.\r | |
28a00297 | 135 | \r |
162ed594 | 136 | **/\r |
28a00297 | 137 | EFI_STATUS\r |
138 | EFIAPI\r | |
139 | FwVolBlockEraseBlock (\r | |
140 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
141 | ...\r | |
142 | )\r | |
28a00297 | 143 | ;\r |
144 | \r | |
145 | \r | |
162ed594 | 146 | \r |
147 | /**\r | |
148 | Read the specified number of bytes from the block to the input buffer.\r | |
149 | \r | |
150 | @param This Indicates the calling context. \r | |
151 | @param Lba The starting logical block index to read. \r | |
152 | @param Offset Offset into the block at which to begin reading. \r | |
153 | @param NumBytes Pointer to a UINT32. At entry, *NumBytes \r | |
154 | contains the total size of the buffer. At exit, \r | |
155 | *NumBytes contains the total number of bytes \r | |
156 | actually read. \r | |
157 | @param Buffer Pinter to a caller-allocated buffer that \r | |
158 | contains the destine for the read. \r | |
159 | \r | |
160 | @retval EFI_SUCCESS The firmware volume was read successfully. \r | |
161 | @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary. \r | |
162 | @retval EFI_ACCESS_DENIED Access denied. \r | |
163 | @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not \r | |
164 | be read.\r | |
165 | \r | |
166 | **/\r | |
28a00297 | 167 | EFI_STATUS\r |
168 | EFIAPI\r | |
169 | FwVolBlockReadBlock (\r | |
170 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
171 | IN CONST EFI_LBA Lba,\r | |
172 | IN CONST UINTN Offset,\r | |
173 | IN OUT UINTN *NumBytes,\r | |
174 | IN OUT UINT8 *Buffer\r | |
175 | )\r | |
28a00297 | 176 | ;\r |
177 | \r | |
178 | \r | |
162ed594 | 179 | \r |
180 | /**\r | |
181 | Writes the specified number of bytes from the input buffer to the block.\r | |
182 | \r | |
183 | @param This Indicates the calling context. \r | |
184 | @param Lba The starting logical block index to write to. \r | |
185 | @param Offset Offset into the block at which to begin writing. \r | |
186 | @param NumBytes Pointer to a UINT32. At entry, *NumBytes \r | |
187 | contains the total size of the buffer. At exit, \r | |
188 | *NumBytes contains the total number of bytes \r | |
189 | actually written. \r | |
190 | @param Buffer Pinter to a caller-allocated buffer that \r | |
191 | contains the source for the write. \r | |
192 | \r | |
193 | @retval EFI_SUCCESS The firmware volume was written successfully. \r | |
194 | @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary. \r | |
195 | On output, NumBytes contains the total number of \r | |
196 | bytes actually written. \r | |
197 | @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled \r | |
198 | state. \r | |
199 | @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not \r | |
200 | be written. \r | |
201 | @retval EFI_UNSUPPORTED Not supported.\r | |
202 | \r | |
203 | **/\r | |
28a00297 | 204 | EFI_STATUS\r |
205 | EFIAPI\r | |
206 | FwVolBlockWriteBlock (\r | |
207 | IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
208 | IN EFI_LBA Lba,\r | |
209 | IN UINTN Offset,\r | |
210 | IN OUT UINTN *NumBytes,\r | |
211 | IN UINT8 *Buffer\r | |
212 | )\r | |
28a00297 | 213 | ;\r |
214 | \r | |
215 | \r | |
162ed594 | 216 | \r |
217 | /**\r | |
218 | Get Fvb's base address.\r | |
219 | \r | |
220 | @param This Indicates the calling context. \r | |
221 | @param Address Fvb device base address. \r | |
222 | \r | |
223 | @retval EFI_SUCCESS Successfully got Fvb's base address. \r | |
224 | @retval EFI_UNSUPPORTED Not supported.\r | |
225 | \r | |
226 | **/\r | |
28a00297 | 227 | EFI_STATUS\r |
228 | EFIAPI\r | |
229 | FwVolBlockGetPhysicalAddress (\r | |
230 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
231 | OUT EFI_PHYSICAL_ADDRESS *Address\r | |
232 | )\r | |
162ed594 | 233 | ;\r |
28a00297 | 234 | \r |
28a00297 | 235 | \r |
28a00297 | 236 | \r |
162ed594 | 237 | /**\r |
238 | Retrieves the size in bytes of a specific block within a firmware volume.\r | |
239 | \r | |
240 | @param This Indicates the calling context. \r | |
241 | @param Lba Indicates the block for which to return the \r | |
242 | size. \r | |
243 | @param BlockSize Pointer to a caller-allocated UINTN in which the \r | |
244 | size of the block is returned. \r | |
245 | @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the \r | |
246 | number of consecutive blocks starting with Lba \r | |
247 | is returned. All blocks in this range have a \r | |
248 | size of BlockSize. \r | |
28a00297 | 249 | \r |
162ed594 | 250 | @retval EFI_SUCCESS The firmware volume base address is returned. \r |
251 | @retval EFI_INVALID_PARAMETER The requested LBA is out of range.\r | |
28a00297 | 252 | \r |
162ed594 | 253 | **/\r |
28a00297 | 254 | EFI_STATUS\r |
255 | EFIAPI\r | |
256 | FwVolBlockGetBlockSize (\r | |
257 | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r | |
258 | IN CONST EFI_LBA Lba,\r | |
259 | OUT UINTN *BlockSize,\r | |
260 | OUT UINTN *NumberOfBlocks\r | |
261 | )\r | |
162ed594 | 262 | ;\r |
28a00297 | 263 | \r |
162ed594 | 264 | /**\r |
265 | This routine is the driver initialization entry point. It initializes the\r | |
266 | libraries, consumes FV hobs and NT_NON_MM_FV environment variable and\r | |
267 | produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.\r | |
28a00297 | 268 | \r |
162ed594 | 269 | @param ImageHandle The image handle. \r |
270 | @param SystemTable The system table. \r | |
271 | \r | |
272 | @retval EFI_SUCCESS Successfully initialized firmware volume block \r | |
273 | driver.\r | |
274 | \r | |
275 | **/\r | |
28a00297 | 276 | EFI_STATUS\r |
277 | FwVolBlockDriverInit (\r | |
278 | IN EFI_HANDLE ImageHandle,\r | |
279 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
280 | )\r | |
28a00297 | 281 | ;\r |
282 | \r | |
162ed594 | 283 | \r |
284 | /**\r | |
285 | This routine produces a firmware volume block protocol on a given\r | |
286 | buffer.\r | |
287 | \r | |
288 | @param BaseAddress base address of the firmware volume image \r | |
289 | @param Length length of the firmware volume image \r | |
290 | @param ParentHandle handle of parent firmware volume, if this image \r | |
291 | came from an FV image file in another firmware \r | |
292 | volume (ala capsules) \r | |
293 | @param FvProtocol Firmware volume block protocol produced. \r | |
294 | \r | |
295 | @retval EFI_VOLUME_CORRUPTED Volume corrupted. \r | |
296 | @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated. \r | |
297 | @retval EFI_SUCCESS Successfully produced a FVB protocol on given \r | |
298 | buffer.\r | |
299 | \r | |
300 | **/\r | |
28a00297 | 301 | EFI_STATUS\r |
302 | ProduceFVBProtocolOnBuffer (\r | |
303 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
304 | IN UINT64 Length,\r | |
305 | IN EFI_HANDLE ParentHandle,\r | |
162ed594 | 306 | OUT EFI_HANDLE *FvProtocol OPTIONAL\r |
28a00297 | 307 | )\r |
28a00297 | 308 | ;\r |
309 | \r | |
310 | #endif\r |