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