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