3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Light weight lib to support Tiano Firmware Volume Block
19 protocol abstraction at runtime.
21 All these functions convert EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
22 class function to the Runtime Lib function. There is a 1 to 1 mapping.
24 If you are using any of these lib functions.you must first call FvbInitialize ().
30 IN EFI_HANDLE ImageHandle
,
31 IN EFI_SYSTEM_TABLE
*SystemTable
36 Initialize globals and register Fvb Protocol notification function.
49 // The following functions wrap Fvb protocol in the Runtime Lib functions.
50 // The Instance translates into Fvb instance. The Fvb order defined by HOBs and
51 // thus the sequence of FVB protocol addition define Instance.
53 // EfiFvbInitialize () must be called before any of the following functions
61 IN OUT UINTN
*NumBytes
,
67 Reads specified number of bytes into a buffer from the specified block
70 Instance - The FV instance to be read from
71 Lba - The logical block address to be read from
72 Offset - Offset into the block at which to begin reading
73 NumBytes - Pointer that on input contains the total size of
74 the buffer. On output, it contains the total number
76 Buffer - Pointer to a caller allocated buffer that will be
77 used to hold the data read
84 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
86 return EfiCallEsalService (&Guid
, Read
, Instance
, Lba
, Offset
, (UINT64
) NumBytes
, (UINT64
) Buffer
, 0, 0).Status
;
94 IN OUT UINTN
*NumBytes
,
100 Writes specified number of bytes from the input buffer to the block
103 Instance - The FV instance to be written to
104 Lba - The starting logical block index to write to
105 Offset - Offset into the block at which to begin writing
106 NumBytes - Pointer that on input contains the total size of
107 the buffer. On output, it contains the total number
108 of bytes actually written
109 Buffer - Pointer to a caller allocated buffer that contains
110 the source for the write
117 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
119 return EfiCallEsalService (&Guid
, Write
, Instance
, Lba
, Offset
, (UINT64
) NumBytes
, (UINT64
) Buffer
, 0, 0).Status
;
130 Erases and initializes a firmware volume block
133 Instance - The FV instance to be erased
134 Lba - The logical block index to be erased
141 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
143 return EfiCallEsalService (&Guid
, EraseBlock
, Instance
, Lba
, 0, 0, 0, 0, 0).Status
;
147 EfiFvbGetVolumeAttributes (
149 OUT EFI_FVB_ATTRIBUTES
*Attributes
154 Retrieves attributes, insures positive polarity of attribute bits, returns
155 resulting attributes in output parameter
158 Instance - The FV instance whose attributes is going to be
160 Attributes - Output buffer which contains attributes
167 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
169 return EfiCallEsalService (&Guid
, SetVolumeAttributes
, Instance
, (UINT64
) Attributes
, 0, 0, 0, 0, 0).Status
;
173 EfiFvbSetVolumeAttributes (
175 IN EFI_FVB_ATTRIBUTES Attributes
180 Modifies the current settings of the firmware volume according to the
181 input parameter, and returns the new setting of the volume
184 Instance - The FV instance whose attributes is going to be
186 Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES
187 containing the desired firmware volume settings.
188 On successful return, it contains the new settings
189 of the firmware volume
196 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
198 return EfiCallEsalService (&Guid
, SetVolumeAttributes
, Instance
, (UINT64
) Attributes
, 0, 0, 0, 0, 0).Status
;
202 EfiFvbGetPhysicalAddress (
204 OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
209 Retrieves the physical address of a memory mapped FV
212 Instance - The FV instance whose base address is going to be
214 BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
215 that on successful return, contains the base address
216 of the firmware volume.
223 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
225 return EfiCallEsalService (&Guid
, GetPhysicalAddress
, Instance
, (UINT64
) BaseAddress
, 0, 0, 0, 0, 0).Status
;
232 OUT UINTN
*BlockSize
,
233 OUT UINTN
*NumOfBlocks
238 Retrieve the size of a logical block
241 Instance - The FV instance whose block size is going to be
243 Lba - Indicates which block to return the size for.
244 BlockSize - A pointer to a caller allocated UINTN in which
245 the size of the block is returned
246 NumOfBlocks - a pointer to a caller allocated UINTN in which the
247 number of consecutive blocks starting with Lba is
248 returned. All blocks in this range have a size of
252 EFI_SUCCESS - The firmware volume was read successfully and
253 contents are in Buffer
257 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
259 return EfiCallEsalService (
265 (UINT64
) NumOfBlocks
,
273 EfiFvbEraseCustomBlockRange (
276 IN UINTN OffsetStartLba
,
278 IN UINTN OffsetLastLba
283 Erases and initializes a specified range of a firmware volume
286 Instance - The FV instance to be erased
287 StartLba - The starting logical block index to be erased
288 OffsetStartLba - Offset into the starting block at which to
290 LastLba - The last logical block index to be erased
291 OffsetLastLba - Offset into the last block at which to end erasing
298 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
300 return EfiCallEsalService (
302 EraseCustomBlockRange
,
315 BugBug: Can't turn this off in the current MSA so we need a stub
319 FvbVirtualAddressChangeNotifyEvent (