]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/FwVolBlock.h
Update to fix minor coding style issues.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / FwVolBlock.h
CommitLineData
23c98c94 1/** @file\r
504214c4 2 Firmware Volume Block protocol functions. \r
23c98c94 3 Consumes FV hobs and creates appropriate block protocols.\r
4\r
5Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
6All rights reserved. This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
28a00297 13\r
504214c4 14**/\r
28a00297 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
22typedef struct {\r
23 UINTN Base;\r
24 UINTN Length;\r
25} LBA_CACHE;\r
26\r
27typedef struct {\r
28 MEMMAP_DEVICE_PATH MemMapDevPath;\r
29 EFI_DEVICE_PATH_PROTOCOL EndDevPath;\r
30} FV_DEVICE_PATH;\r
31\r
32\r
33typedef 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
162ed594 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
28a00297 61EFI_STATUS\r
62EFIAPI\r
63FwVolBlockDriverInit (\r
23c98c94 64 IN EFI_HANDLE ImageHandle,\r
65 IN EFI_SYSTEM_TABLE *SystemTable\r
66 );\r
28a00297 67\r
68\r
162ed594 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
28a00297 79EFI_STATUS\r
80EFIAPI\r
81FwVolBlockGetAttributes (\r
82 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
83 OUT EFI_FVB_ATTRIBUTES *Attributes\r
23c98c94 84 );\r
28a00297 85\r
28a00297 86\r
28a00297 87\r
162ed594 88/**\r
89 Modifies the current settings of the firmware volume according to the input parameter.\r
28a00297 90\r
162ed594 91 @param This Calling context \r
92 @param Attributes input buffer which contains attributes \r
28a00297 93\r
162ed594 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
28a00297 99\r
162ed594 100**/\r
28a00297 101EFI_STATUS\r
102EFIAPI\r
103FwVolBlockSetAttributes (\r
104 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
105 IN CONST EFI_FVB_ATTRIBUTES *Attributes\r
23c98c94 106 );\r
28a00297 107\r
28a00297 108\r
28a00297 109\r
162ed594 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
28a00297 121\r
162ed594 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
28a00297 131\r
162ed594 132**/\r
28a00297 133EFI_STATUS\r
134EFIAPI\r
135FwVolBlockEraseBlock (\r
136 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
137 ...\r
23c98c94 138 );\r
28a00297 139\r
140\r
162ed594 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
28a00297 162EFI_STATUS\r
163EFIAPI\r
164FwVolBlockReadBlock (\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
23c98c94 170 );\r
28a00297 171\r
172 \r
162ed594 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
28a00297 198EFI_STATUS\r
199EFIAPI\r
200FwVolBlockWriteBlock (\r
23c98c94 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
28a00297 207\r
208 \r
162ed594 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
28a00297 220EFI_STATUS\r
221EFIAPI\r
222FwVolBlockGetPhysicalAddress (\r
23c98c94 223 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
224 OUT EFI_PHYSICAL_ADDRESS *Address\r
225 );\r
28a00297 226\r
28a00297 227\r
28a00297 228\r
162ed594 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
28a00297 241\r
162ed594 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
28a00297 244\r
162ed594 245**/\r
28a00297 246EFI_STATUS\r
247EFIAPI\r
248FwVolBlockGetBlockSize (\r
249 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,\r
250 IN CONST EFI_LBA Lba,\r
23c98c94 251 IN OUT UINTN *BlockSize,\r
252 IN OUT UINTN *NumberOfBlocks\r
253 );\r
28a00297 254\r
162ed594 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
28a00297 259\r
162ed594 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
28a00297 267EFI_STATUS\r
23c98c94 268EFIAPI\r
28a00297 269FwVolBlockDriverInit (\r
23c98c94 270 IN EFI_HANDLE ImageHandle,\r
271 IN EFI_SYSTEM_TABLE *SystemTable\r
272 );\r
28a00297 273\r
162ed594 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
28a00297 292EFI_STATUS\r
293ProduceFVBProtocolOnBuffer (\r
294 IN EFI_PHYSICAL_ADDRESS BaseAddress,\r
295 IN UINT64 Length,\r
296 IN EFI_HANDLE ParentHandle,\r
162ed594 297 OUT EFI_HANDLE *FvProtocol OPTIONAL\r
23c98c94 298 );\r
28a00297 299\r
300#endif\r