2 Firmware Volume Block protocol functions.
3 Consumes FV hobs and creates appropriate block protocols.
5 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _FWVOL_BLOCK_H_
17 #define _FWVOL_BLOCK_H_
20 #define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B')
28 MEMMAP_DEVICE_PATH MemMapDevPath
;
29 EFI_DEVICE_PATH_PROTOCOL EndDevPath
;
36 FV_DEVICE_PATH DevicePath
;
37 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance
;
41 EFI_PHYSICAL_ADDRESS BaseAddress
;
42 } EFI_FW_VOL_BLOCK_DEVICE
;
44 #define FVB_DEVICE_FROM_THIS(a) \
45 CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
50 This routine is the driver initialization entry point. It initializes the
51 libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
52 produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
54 @param ImageHandle The image handle.
55 @param SystemTable The system table.
57 @retval EFI_SUCCESS Successfully initialized firmware volume block
63 FwVolBlockDriverInit (
64 IN EFI_HANDLE ImageHandle
,
65 IN EFI_SYSTEM_TABLE
*SystemTable
71 Retrieves Volume attributes. No polarity translations are done.
73 @param This Calling context
74 @param Attributes output buffer which contains attributes
76 @retval EFI_SUCCESS The firmware volume attributes were returned.
81 FwVolBlockGetAttributes (
82 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
83 OUT EFI_FVB_ATTRIBUTES
*Attributes
89 Modifies the current settings of the firmware volume according to the input parameter.
91 @param This Calling context
92 @param Attributes input buffer which contains attributes
94 @retval EFI_SUCCESS The firmware volume attributes were returned.
95 @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with
96 the capabilities as declared in the firmware
98 @retval EFI_UNSUPPORTED Not supported.
103 FwVolBlockSetAttributes (
104 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
105 IN CONST EFI_FVB_ATTRIBUTES
*Attributes
111 The EraseBlock() function erases one or more blocks as denoted by the
112 variable argument list. The entire parameter list of blocks must be verified
113 prior to erasing any blocks. If a block is requested that does not exist
114 within the associated firmware volume (it has a larger index than the last
115 block of the firmware volume), the EraseBlock() function must return
116 EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
118 @param This Calling context
119 @param ... Starting LBA followed by Number of Lba to erase.
120 a -1 to terminate the list.
122 @retval EFI_SUCCESS The erase request was successfully completed.
123 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
125 @retval EFI_DEVICE_ERROR The block device is not functioning correctly
126 and could not be written. The firmware device
127 may have been partially erased.
128 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable
130 @retval EFI_UNSUPPORTED Not supported.
135 FwVolBlockEraseBlock (
136 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
143 Read the specified number of bytes from the block to the input buffer.
145 @param This Indicates the calling context.
146 @param Lba The starting logical block index to read.
147 @param Offset Offset into the block at which to begin reading.
148 @param NumBytes Pointer to a UINT32. At entry, *NumBytes
149 contains the total size of the buffer. At exit,
150 *NumBytes contains the total number of bytes
152 @param Buffer Pinter to a caller-allocated buffer that
153 contains the destine for the read.
155 @retval EFI_SUCCESS The firmware volume was read successfully.
156 @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary.
157 @retval EFI_ACCESS_DENIED Access denied.
158 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
164 FwVolBlockReadBlock (
165 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
166 IN CONST EFI_LBA Lba
,
167 IN CONST UINTN Offset
,
168 IN OUT UINTN
*NumBytes
,
175 Writes the specified number of bytes from the input buffer to the block.
177 @param This Indicates the calling context.
178 @param Lba The starting logical block index to write to.
179 @param Offset Offset into the block at which to begin writing.
180 @param NumBytes Pointer to a UINT32. At entry, *NumBytes
181 contains the total size of the buffer. At exit,
182 *NumBytes contains the total number of bytes
184 @param Buffer Pinter to a caller-allocated buffer that
185 contains the source for the write.
187 @retval EFI_SUCCESS The firmware volume was written successfully.
188 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.
189 On output, NumBytes contains the total number of
190 bytes actually written.
191 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
193 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
195 @retval EFI_UNSUPPORTED Not supported.
200 FwVolBlockWriteBlock (
201 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
204 IN OUT UINTN
*NumBytes
,
211 Get Fvb's base address.
213 @param This Indicates the calling context.
214 @param Address Fvb device base address.
216 @retval EFI_SUCCESS Successfully got Fvb's base address.
217 @retval EFI_UNSUPPORTED Not supported.
222 FwVolBlockGetPhysicalAddress (
223 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
224 OUT EFI_PHYSICAL_ADDRESS
*Address
230 Retrieves the size in bytes of a specific block within a firmware volume.
232 @param This Indicates the calling context.
233 @param Lba Indicates the block for which to return the
235 @param BlockSize Pointer to a caller-allocated UINTN in which the
236 size of the block is returned.
237 @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the
238 number of consecutive blocks starting with Lba
239 is returned. All blocks in this range have a
242 @retval EFI_SUCCESS The firmware volume base address is returned.
243 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.
248 FwVolBlockGetBlockSize (
249 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
250 IN CONST EFI_LBA Lba
,
251 IN OUT UINTN
*BlockSize
,
252 IN OUT UINTN
*NumberOfBlocks
256 This routine is the driver initialization entry point. It initializes the
257 libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
258 produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
260 @param ImageHandle The image handle.
261 @param SystemTable The system table.
263 @retval EFI_SUCCESS Successfully initialized firmware volume block
269 FwVolBlockDriverInit (
270 IN EFI_HANDLE ImageHandle
,
271 IN EFI_SYSTEM_TABLE
*SystemTable
276 This routine produces a firmware volume block protocol on a given
279 @param BaseAddress base address of the firmware volume image
280 @param Length length of the firmware volume image
281 @param ParentHandle handle of parent firmware volume, if this image
282 came from an FV image file in another firmware
283 volume (ala capsules)
284 @param FvProtocol Firmware volume block protocol produced.
286 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
287 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
288 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
293 ProduceFVBProtocolOnBuffer (
294 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
296 IN EFI_HANDLE ParentHandle
,
297 OUT EFI_HANDLE
*FvProtocol OPTIONAL