TianoCore EDK2 master
|
#include "FvbService.h"
Go to the source code of this file.
Variables | |
FWB_GLOBAL | mFvbModuleGlobal |
FV_MEMMAP_DEVICE_PATH | mFvMemmapDevicePathTemplate |
FV_PIWG_DEVICE_PATH | mFvPIWGDevicePathTemplate |
EFI_FW_VOL_BLOCK_DEVICE | mFvbDeviceTemplate |
Firmware Volume Block Driver to provide FVB service.
Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file FvbService.c.
EFI_STATUS FvbEraseBlock | ( | IN UINTN | Instance, |
IN EFI_LBA | Lba | ||
) |
Erases and initializes a firmware volume block
[in] | Instance | The FV instance to be erased |
[in] | Lba | The logical block index to be erased |
EFI_SUCCESS | The erase request was successfully completed |
EFI_ACCESS_DENIED | The firmware volume is in the WriteDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be written. Firmware device may have been partially erased |
EFI_INVALID_PARAMETER | Instance not found |
Definition at line 405 of file FvbService.c.
STATIC EFI_STATUS FvbGetLbaAddress | ( | IN UINTN | Instance, |
IN EFI_LBA | Lba, | ||
OUT UINTN * | LbaAddress, | ||
OUT UINTN * | LbaLength, | ||
OUT UINTN * | NumOfBlocks | ||
) |
Retrieves the starting address of an LBA in an FV. It also return a few other attribut of the FV.
[in] | Instance | The index of the EFI_FW_VOL_INSTANCE. |
[in] | Lba | The logical block address |
[out] | LbaAddress | On output, contains the physical starting address of the Lba |
[out] | LbaLength | On output, contains the length of the block |
[out] | NumOfBlocks | A pointer to a caller allocated UINTN in which the number of consecutive blocks starting with Lba is returned. All blocks in this range have a size of BlockSize |
EFI_SUCCESS | Successfully returns |
EFI_INVALID_PARAMETER | Instance not found |
Definition at line 162 of file FvbService.c.
STATIC EFI_FVB_ATTRIBUTES_2 FvbGetVolumeAttributes | ( | IN UINTN | Instance | ) |
Get the EFI_FVB_ATTRIBUTES_2 of a FV.
[in] | Instance | The index of the EFI_FW_VOL_INSTANCE. |
EFI_FVB_ATTRIBUTES_2 | of the FV identified by Instance. |
Definition at line 126 of file FvbService.c.
EFI_STATUS FvbInitialize | ( | VOID | ) |
The function does the necessary initialization work for Firmware Volume Block Driver.
EFI_SUCCESS | This funtion always return EFI_SUCCESS. It will ASSERT on errors. |
Definition at line 996 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolEraseBlocks | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
... | |||
) |
This function erases one or more blocks as denoted by the variable argument list. The entire parameter list of blocks must be verified prior to erasing any blocks. If a block is requested that does not exist within the associated firmware volume (it has a larger index than the last block of the firmware volume), the EraseBlock() function must return EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
[in] | This | Calling context |
[in] | ... | Starting LBA followed by Number of Lba to erase. a -1 to terminate the list. |
EFI_SUCCESS | The erase request was successfully completed |
EFI_ACCESS_DENIED | The firmware volume is in the WriteDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be written. Firmware device may have been partially erased |
Definition at line 704 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolGetAttributes | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
OUT EFI_FVB_ATTRIBUTES_2 * | Attributes | ||
) |
Retrieves Volume attributes. No polarity translations are done.
[in] | This | Calling context |
[out] | Attributes | Output buffer which contains attributes |
EFI_SUCCESS | The function always return successfully. |
Definition at line 646 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolGetBlockSize | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
IN EFI_LBA | Lba, | ||
OUT UINTN * | BlockSize, | ||
OUT UINTN * | NumOfBlocks | ||
) |
Retrieve the size of a logical block
[in] | This | Calling context |
[in] | Lba | Indicates which block to return the size for. |
[out] | BlockSize | A pointer to a caller allocated UINTN in which the size of the block is returned |
[out] | NumOfBlocks | A pointer to a caller allocated UINTN in which the number of consecutive blocks starting with Lba is returned. All blocks in this range have a size of BlockSize |
EFI_SUCCESS | The function always return successfully. |
Definition at line 622 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolGetPhysicalAddress | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
OUT EFI_PHYSICAL_ADDRESS * | Address | ||
) |
Retrieves the physical address of the device.
[in] | This | A pointer to EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL. |
[out] | Address | Output buffer containing the address. |
EFI_SUCCESS | The function always return successfully. |
EFI_INVALID_PARAMETER | Instance not found. |
Definition at line 587 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolRead | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
IN EFI_LBA | Lba, | ||
IN UINTN | Offset, | ||
IN OUT UINTN * | NumBytes, | ||
OUT UINT8 * | Buffer | ||
) |
Reads data beginning at Lba:Offset from FV. The Read terminates either when *NumBytes of data have been read, or when a block boundary is reached. *NumBytes is updated to reflect the actual number of bytes written. The write opertion does not include erase. This routine will attempt to write only the specified bytes. If the writes do not stick, it will return an error.
[in] | This | Calling context |
[in] | Lba | Block in which to begin write |
[in] | Offset | Offset in the block at which to begin write |
[in,out] | NumBytes | On input, indicates the requested write size. On output, indicates the actual number of bytes written |
[out] | Buffer | Buffer containing source data for the write. |
Returns:
EFI_SUCCESS | The firmware volume was read successfully and contents are in Buffer |
EFI_BAD_BUFFER_SIZE | Read attempted across a LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer |
EFI_ACCESS_DENIED | The firmware volume is in the ReadDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be read |
EFI_INVALID_PARAMETER | NumBytes or Buffer are NULL |
Definition at line 858 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolSetAttributes | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
IN OUT EFI_FVB_ATTRIBUTES_2 * | Attributes | ||
) |
Sets Volume attributes. No polarity translations are done.
[in] | This | Calling context |
[in,out] | Attributes | Output buffer which contains attributes |
EFI_SUCCESS | The function always return successfully. |
Definition at line 670 of file FvbService.c.
EFI_STATUS EFIAPI FvbProtocolWrite | ( | IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * | This, |
IN EFI_LBA | Lba, | ||
IN UINTN | Offset, | ||
IN OUT UINTN * | NumBytes, | ||
IN UINT8 * | Buffer | ||
) |
Writes data beginning at Lba:Offset from FV. The write terminates either when *NumBytes of data have been written, or when a block boundary is reached. *NumBytes is updated to reflect the actual number of bytes written. The write opertion does not include erase. This routine will attempt to write only the specified bytes. If the writes do not stick, it will return an error.
[in] | This | Calling context |
[in] | Lba | Block in which to begin write |
[in] | Offset | Offset in the block at which to begin write |
[in,out] | NumBytes | On input, indicates the requested write size. On output, indicates the actual number of bytes written |
[in] | Buffer | Buffer containing source data for the write. |
EFI_SUCCESS | The firmware volume was written successfully |
EFI_BAD_BUFFER_SIZE | Write attempted across a LBA boundary. On output, NumBytes contains the total number of bytes actually written |
EFI_ACCESS_DENIED | The firmware volume is in the WriteDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be written |
EFI_INVALID_PARAMETER | NumBytes or Buffer are NULL |
Definition at line 802 of file FvbService.c.
STATIC EFI_STATUS FvbReadBlock | ( | IN UINTN | Instance, |
IN EFI_LBA | Lba, | ||
IN UINTN | BlockOffset, | ||
IN OUT UINTN * | NumBytes, | ||
IN UINT8 * | Buffer | ||
) |
Reads specified number of bytes into a buffer from the specified block
[in] | Instance | The FV instance to be read from |
[in] | Lba | The logical block address to be read from |
[in] | BlockOffset | Offset into the block at which to begin reading |
[in,out] | NumBytes | Pointer that on input contains the total size of the buffer. On output, it contains the total number of bytes read |
[in] | Buffer | Pointer to a caller allocated buffer that will be used to hold the data read |
EFI_SUCCESS | The firmware volume was read successfully and contents are in Buffer |
EFI_BAD_BUFFER_SIZE | Read attempted across a LBA boundary. On output, NumBytes contains the total number of bytes returned in Buffer |
EFI_ACCESS_DENIED | The firmware volume is in the ReadDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be read |
EFI_INVALID_PARAMETER | Instance not found, or NumBytes, Buffer are NULL |
Definition at line 258 of file FvbService.c.
STATIC EFI_STATUS FvbSetVolumeAttributes | ( | IN UINTN | Instance, |
IN OUT EFI_FVB_ATTRIBUTES_2 * | Attributes | ||
) |
Modifies the current settings of the firmware volume according to the input parameter, and returns the new setting of the volume
[in] | Instance | The FV instance whose attributes is going to be modified |
[in,out] | Attributes | On input, it is a pointer to EFI_FVB_ATTRIBUTES_2 containing the desired firmware volume settings. On successful return, it contains the new settings of the firmware volume |
EFI_SUCCESS | Successfully returns |
EFI_ACCESS_DENIED | The volume setting is locked and cannot be modified |
EFI_INVALID_PARAMETER | Instance not found, or The attributes requested are in conflict with the capabilities as declared in the firmware volume header |
Definition at line 463 of file FvbService.c.
EFI_STATUS FvbWriteBlock | ( | IN UINTN | Instance, |
IN EFI_LBA | Lba, | ||
IN UINTN | BlockOffset, | ||
IN OUT UINTN * | NumBytes, | ||
IN UINT8 * | Buffer | ||
) |
Writes specified number of bytes from the input buffer to the block
[in] | Instance | The FV instance to be written to |
[in] | Lba | The starting logical block index to write to |
[in] | BlockOffset | Offset into the block at which to begin writing |
[in,out] | NumBytes | Pointer that on input contains the total size of the buffer. On output, it contains the total number of bytes actually written |
[in] | Buffer | Pointer to a caller allocated buffer that contains the source for the write |
EFI_SUCCESS | The firmware volume was written successfully |
EFI_BAD_BUFFER_SIZE | Write attempted across a LBA boundary. On output, NumBytes contains the total number of bytes actually written |
EFI_ACCESS_DENIED | The firmware volume is in the WriteDisabled state |
EFI_DEVICE_ERROR | The block device is not functioning correctly and could not be written |
EFI_INVALID_PARAMETER | Instance not found, or NumBytes, Buffer are NULL |
Definition at line 330 of file FvbService.c.
EFI_FW_VOL_INSTANCE * GetFvbInstance | ( | IN UINTN | Instance | ) |
Get the pointer to EFI_FW_VOL_INSTANCE from the buffer pointed by mFvbModuleGlobal.FvInstance based on a index. Each EFI_FW_VOL_INSTANCE is with variable length as we have a block map at the end of the EFI_FIRMWARE_VOLUME_HEADER.
[in] | Instance | The index of the EFI_FW_VOL_INSTANCE. |
Definition at line 91 of file FvbService.c.
EFI_STATUS GetInitialVariableData | ( | OUT VOID ** | VarData, |
OUT UINTN * | VarSize | ||
) |
Get intial variable data.
[out] | VarData | Valid variable data. |
[out] | VarSize | Valid variable size. |
RETURN_SUCCESS | Successfully found initial variable data. |
RETURN_NOT_FOUND | Failed to find the variable data file from FV. |
EFI_INVALID_PARAMETER | VarData or VarSize is null. |
Definition at line 945 of file FvbService.c.
BOOLEAN IsFvHeaderValid | ( | IN EFI_PHYSICAL_ADDRESS | FvBase | ) |
Check the integrity of firmware volume header in FvBase
[in] | FvBase | A pointer to firmware volume base address. |
TRUE | The firmware volume is consistent |
FALSE | The firmware volume has corrupted. |
Definition at line 894 of file FvbService.c.
EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate |
Definition at line 63 of file FvbService.c.
FWB_GLOBAL mFvbModuleGlobal |
Definition at line 15 of file FvbService.c.
FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate |
Definition at line 17 of file FvbService.c.
FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate |
Definition at line 41 of file FvbService.c.