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