3 Firmware Volume Block protocol functions.
4 Consumes FV hobs and creates appropriate block protocols.
6 Copyright (c) 2006 - 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #ifndef _FWVOL_BLOCK_H_
18 #define _FWVOL_BLOCK_H_
21 #define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B')
29 MEMMAP_DEVICE_PATH MemMapDevPath
;
30 EFI_DEVICE_PATH_PROTOCOL EndDevPath
;
37 FV_DEVICE_PATH DevicePath
;
38 EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance
;
42 EFI_PHYSICAL_ADDRESS BaseAddress
;
43 } EFI_FW_VOL_BLOCK_DEVICE
;
45 #define FVB_DEVICE_FROM_THIS(a) \
46 CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
51 This routine is the driver initialization entry point. It initializes the
52 libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
53 produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
55 @param ImageHandle The image handle.
56 @param SystemTable The system table.
58 @retval EFI_SUCCESS Successfully initialized firmware volume block
64 FwVolBlockDriverInit (
65 IN EFI_HANDLE ImageHandle
,
66 IN EFI_SYSTEM_TABLE
*SystemTable
73 Retrieves Volume attributes. No polarity translations are done.
75 @param This Calling context
76 @param Attributes output buffer which contains attributes
78 @retval EFI_SUCCESS The firmware volume attributes were returned.
83 FwVolBlockGetAttributes (
84 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
85 OUT EFI_FVB_ATTRIBUTES
*Attributes
92 Modifies the current settings of the firmware volume according to the input parameter.
94 @param This Calling context
95 @param Attributes input buffer which contains attributes
97 @retval EFI_SUCCESS The firmware volume attributes were returned.
98 @retval EFI_INVALID_PARAMETER The attributes requested are in conflict with
99 the capabilities as declared in the firmware
101 @retval EFI_UNSUPPORTED Not supported.
106 FwVolBlockSetAttributes (
107 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
108 IN CONST EFI_FVB_ATTRIBUTES
*Attributes
115 The EraseBlock() function erases one or more blocks as denoted by the
116 variable argument list. The entire parameter list of blocks must be verified
117 prior to erasing any blocks. If a block is requested that does not exist
118 within the associated firmware volume (it has a larger index than the last
119 block of the firmware volume), the EraseBlock() function must return
120 EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
122 @param This Calling context
123 @param ... Starting LBA followed by Number of Lba to erase.
124 a -1 to terminate the list.
126 @retval EFI_SUCCESS The erase request was successfully completed.
127 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
129 @retval EFI_DEVICE_ERROR The block device is not functioning correctly
130 and could not be written. The firmware device
131 may have been partially erased.
132 @retval EFI_INVALID_PARAMETER One or more of the LBAs listed in the variable
134 @retval EFI_UNSUPPORTED Not supported.
139 FwVolBlockEraseBlock (
140 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
148 Read the specified number of bytes from the block to the input buffer.
150 @param This Indicates the calling context.
151 @param Lba The starting logical block index to read.
152 @param Offset Offset into the block at which to begin reading.
153 @param NumBytes Pointer to a UINT32. At entry, *NumBytes
154 contains the total size of the buffer. At exit,
155 *NumBytes contains the total number of bytes
157 @param Buffer Pinter to a caller-allocated buffer that
158 contains the destine for the read.
160 @retval EFI_SUCCESS The firmware volume was read successfully.
161 @retval EFI_BAD_BUFFER_SIZE The read was attempted across an LBA boundary.
162 @retval EFI_ACCESS_DENIED Access denied.
163 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
169 FwVolBlockReadBlock (
170 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
171 IN CONST EFI_LBA Lba
,
172 IN CONST UINTN Offset
,
173 IN OUT UINTN
*NumBytes
,
181 Writes the specified number of bytes from the input buffer to the block.
183 @param This Indicates the calling context.
184 @param Lba The starting logical block index to write to.
185 @param Offset Offset into the block at which to begin writing.
186 @param NumBytes Pointer to a UINT32. At entry, *NumBytes
187 contains the total size of the buffer. At exit,
188 *NumBytes contains the total number of bytes
190 @param Buffer Pinter to a caller-allocated buffer that
191 contains the source for the write.
193 @retval EFI_SUCCESS The firmware volume was written successfully.
194 @retval EFI_BAD_BUFFER_SIZE The write was attempted across an LBA boundary.
195 On output, NumBytes contains the total number of
196 bytes actually written.
197 @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled
199 @retval EFI_DEVICE_ERROR The block device is malfunctioning and could not
201 @retval EFI_UNSUPPORTED Not supported.
206 FwVolBlockWriteBlock (
207 IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
210 IN OUT UINTN
*NumBytes
,
218 Get Fvb's base address.
220 @param This Indicates the calling context.
221 @param Address Fvb device base address.
223 @retval EFI_SUCCESS Successfully got Fvb's base address.
224 @retval EFI_UNSUPPORTED Not supported.
229 FwVolBlockGetPhysicalAddress (
230 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
231 OUT EFI_PHYSICAL_ADDRESS
*Address
238 Retrieves the size in bytes of a specific block within a firmware volume.
240 @param This Indicates the calling context.
241 @param Lba Indicates the block for which to return the
243 @param BlockSize Pointer to a caller-allocated UINTN in which the
244 size of the block is returned.
245 @param NumberOfBlocks Pointer to a caller-allocated UINTN in which the
246 number of consecutive blocks starting with Lba
247 is returned. All blocks in this range have a
250 @retval EFI_SUCCESS The firmware volume base address is returned.
251 @retval EFI_INVALID_PARAMETER The requested LBA is out of range.
256 FwVolBlockGetBlockSize (
257 IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL
*This
,
258 IN CONST EFI_LBA Lba
,
259 OUT UINTN
*BlockSize
,
260 OUT UINTN
*NumberOfBlocks
265 This routine is the driver initialization entry point. It initializes the
266 libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
267 produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
269 @param ImageHandle The image handle.
270 @param SystemTable The system table.
272 @retval EFI_SUCCESS Successfully initialized firmware volume block
277 FwVolBlockDriverInit (
278 IN EFI_HANDLE ImageHandle
,
279 IN EFI_SYSTEM_TABLE
*SystemTable
285 This routine produces a firmware volume block protocol on a given
288 @param BaseAddress base address of the firmware volume image
289 @param Length length of the firmware volume image
290 @param ParentHandle handle of parent firmware volume, if this image
291 came from an FV image file in another firmware
292 volume (ala capsules)
293 @param FvProtocol Firmware volume block protocol produced.
295 @retval EFI_VOLUME_CORRUPTED Volume corrupted.
296 @retval EFI_OUT_OF_RESOURCES No enough buffer to be allocated.
297 @retval EFI_SUCCESS Successfully produced a FVB protocol on given
302 ProduceFVBProtocolOnBuffer (
303 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
305 IN EFI_HANDLE ParentHandle
,
306 OUT EFI_HANDLE
*FvProtocol OPTIONAL