3 Copyright (c) 2004 - 2007, 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 ().
29 #include "EfiRuntimeLib.h"
30 #include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
40 Initialize globals and register Fvb Protocol notification function.
53 // The following functions wrap Fvb protocol in the Runtime Lib functions.
54 // The Instance translates into Fvb instance. The Fvb order defined by HOBs and
55 // thus the sequence of FVB protocol addition define Instance.
57 // EfiFvbInitialize () must be called before any of the following functions
65 IN OUT UINTN
*NumBytes
,
71 Reads specified number of bytes into a buffer from the specified block
74 Instance - The FV instance to be read from
75 Lba - The logical block address to be read from
76 Offset - Offset into the block at which to begin reading
77 NumBytes - Pointer that on input contains the total size of
78 the buffer. On output, it contains the total number
80 Buffer - Pointer to a caller allocated buffer that will be
81 used to hold the data read
88 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
90 return EfiCallEsalService (&Guid
, Read
, Instance
, Lba
, Offset
, (UINT64
) NumBytes
, (UINT64
) Buffer
, 0, 0).Status
;
98 IN OUT UINTN
*NumBytes
,
104 Writes specified number of bytes from the input buffer to the block
107 Instance - The FV instance to be written to
108 Lba - The starting logical block index to write to
109 Offset - Offset into the block at which to begin writing
110 NumBytes - Pointer that on input contains the total size of
111 the buffer. On output, it contains the total number
112 of bytes actually written
113 Buffer - Pointer to a caller allocated buffer that contains
114 the source for the write
121 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
123 return EfiCallEsalService (&Guid
, Write
, Instance
, Lba
, Offset
, (UINT64
) NumBytes
, (UINT64
) Buffer
, 0, 0).Status
;
134 Erases and initializes a firmware volume block
137 Instance - The FV instance to be erased
138 Lba - The logical block index to be erased
145 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
147 return EfiCallEsalService (&Guid
, EraseBlock
, Instance
, Lba
, 0, 0, 0, 0, 0).Status
;
151 EfiFvbGetVolumeAttributes (
153 OUT EFI_FVB_ATTRIBUTES
*Attributes
158 Retrieves attributes, insures positive polarity of attribute bits, returns
159 resulting attributes in output parameter
162 Instance - The FV instance whose attributes is going to be
164 Attributes - Output buffer which contains attributes
171 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
173 return EfiCallEsalService (&Guid
, SetVolumeAttributes
, Instance
, (UINT64
) Attributes
, 0, 0, 0, 0, 0).Status
;
177 EfiFvbSetVolumeAttributes (
179 IN EFI_FVB_ATTRIBUTES Attributes
184 Modifies the current settings of the firmware volume according to the
188 Instance - The FV instance whose attributes is going to be
190 Attributes - It is a pointer to EFI_FVB_ATTRIBUTES
191 containing the desired firmware volume settings.
198 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
200 return EfiCallEsalService (&Guid
, SetVolumeAttributes
, Instance
, (UINT64
) (&Attributes
), 0, 0, 0, 0, 0).Status
;
204 EfiFvbGetPhysicalAddress (
206 OUT EFI_PHYSICAL_ADDRESS
*BaseAddress
211 Retrieves the physical address of a memory mapped FV
214 Instance - The FV instance whose base address is going to be
216 BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
217 that on successful return, contains the base address
218 of the firmware volume.
225 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
227 return EfiCallEsalService (&Guid
, GetPhysicalAddress
, Instance
, (UINT64
) BaseAddress
, 0, 0, 0, 0, 0).Status
;
234 OUT UINTN
*BlockSize
,
235 OUT UINTN
*NumOfBlocks
240 Retrieve the size of a logical block
243 Instance - The FV instance whose block size is going to be
245 Lba - Indicates which block to return the size for.
246 BlockSize - A pointer to a caller allocated UINTN in which
247 the size of the block is returned
248 NumOfBlocks - a pointer to a caller allocated UINTN in which the
249 number of consecutive blocks starting with Lba is
250 returned. All blocks in this range have a size of
254 EFI_SUCCESS - The firmware volume was read successfully and
255 contents are in Buffer
259 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
261 return EfiCallEsalService (
267 (UINT64
) NumOfBlocks
,
275 EfiFvbEraseCustomBlockRange (
278 IN UINTN OffsetStartLba
,
280 IN UINTN OffsetLastLba
285 Erases and initializes a specified range of a firmware volume
288 Instance - The FV instance to be erased
289 StartLba - The starting logical block index to be erased
290 OffsetStartLba - Offset into the starting block at which to
292 LastLba - The last logical block index to be erased
293 OffsetLastLba - Offset into the last block at which to end erasing
300 EFI_GUID Guid
= EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
;
302 return EfiCallEsalService (
304 EraseCustomBlockRange
,
321 Release resources allocated in EfiFvbInitialize.