TianoCore EDK2 master
Loading...
Searching...
No Matches
FwVolBlock.c File Reference
#include "DxeMain.h"
#include "FwVolBlock.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI FwVolBlockGetAttributes (IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
 
EFI_STATUS EFIAPI FwVolBlockSetAttributes (IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes)
 
EFI_STATUS EFIAPI FwVolBlockEraseBlock (IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,...)
 
EFI_STATUS EFIAPI FwVolBlockReadBlock (IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN CONST UINTN Offset, IN OUT UINTN *NumBytes, IN OUT UINT8 *Buffer)
 
EFI_STATUS EFIAPI FwVolBlockWriteBlock (IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
 
EFI_STATUS EFIAPI FwVolBlockGetPhysicalAddress (IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_PHYSICAL_ADDRESS *Address)
 
EFI_STATUS EFIAPI FwVolBlockGetBlockSize (IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN OUT UINTN *BlockSize, IN OUT UINTN *NumberOfBlocks)
 
UINT32 GetFvbAuthenticationStatus (IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvbProtocol)
 
EFI_STATUS ProduceFVBProtocolOnBuffer (IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN EFI_HANDLE ParentHandle, IN UINT32 AuthenticationStatus, OUT EFI_HANDLE *FvProtocol OPTIONAL)
 
EFI_STATUS EFIAPI FwVolBlockDriverInit (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI CoreProcessFirmwareVolume (IN VOID *FvHeader, IN UINTN Size, OUT EFI_HANDLE *FVProtocolHandle)
 

Variables

FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate
 
FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate
 
EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock
 

Detailed Description

Implementations for Firmware Volume Block protocol.

It consumes FV HOBs and creates read-only Firmare Volume Block protocol instances for each of them.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FwVolBlock.c.

Function Documentation

◆ CoreProcessFirmwareVolume()

EFI_STATUS EFIAPI CoreProcessFirmwareVolume ( IN VOID *  FvHeader,
IN UINTN  Size,
OUT EFI_HANDLE FVProtocolHandle 
)

This DXE service routine is used to process a firmware volume. In particular, it can be called by BDS to process a single firmware volume found in a capsule.

Caution: The caller need validate the input firmware volume to follow PI specification. DxeCore will trust the input data and process firmware volume directly.

Parameters
FvHeaderpointer to a firmware volume header
Sizethe size of the buffer pointed to by FvHeader
FVProtocolHandlethe handle on which a firmware volume protocol was produced for the firmware volume passed in.
Return values
EFI_OUT_OF_RESOURCESif an FVB could not be produced due to lack of system resources
EFI_VOLUME_CORRUPTEDif the volume was corrupted
EFI_SUCCESSa firmware volume protocol was produced for the firmware volume

Definition at line 676 of file FwVolBlock.c.

◆ FwVolBlockDriverInit()

EFI_STATUS EFIAPI FwVolBlockDriverInit ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

This routine consumes FV hobs and produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.

Parameters
ImageHandleThe image handle.
SystemTableThe system table.
Return values
EFI_SUCCESSSuccessfully initialized firmware volume block driver.

Definition at line 613 of file FwVolBlock.c.

◆ FwVolBlockEraseBlock()

EFI_STATUS EFIAPI FwVolBlockEraseBlock ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
  ... 
)

The EraseBlock() 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.

Parameters
ThisCalling context
...Starting LBA followed by Number of Lba to erase. a -1 to terminate the list.
Return values
EFI_SUCCESSThe erase request was successfully completed.
EFI_ACCESS_DENIEDThe firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERRORThe block device is not functioning correctly and could not be written. The firmware device may have been partially erased.
EFI_INVALID_PARAMETEROne or more of the LBAs listed in the variable argument list do
EFI_UNSUPPORTEDNot supported.

Definition at line 158 of file FwVolBlock.c.

◆ FwVolBlockGetAttributes()

EFI_STATUS EFIAPI FwVolBlockGetAttributes ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
OUT EFI_FVB_ATTRIBUTES_2 Attributes 
)

Retrieves Volume attributes. No polarity translations are done.

Parameters
ThisCalling context
Attributesoutput buffer which contains attributes
Return values
EFI_SUCCESSThe firmware volume attributes were returned.

Definition at line 93 of file FwVolBlock.c.

◆ FwVolBlockGetBlockSize()

EFI_STATUS EFIAPI FwVolBlockGetBlockSize ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
IN CONST EFI_LBA  Lba,
IN OUT UINTN BlockSize,
IN OUT UINTN NumberOfBlocks 
)

Retrieves the size in bytes of a specific block within a firmware volume.

Parameters
ThisIndicates the calling context.
LbaIndicates the block for which to return the size.
BlockSizePointer to a caller-allocated UINTN in which the size of the block is returned.
NumberOfBlocksPointer 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.
Return values
EFI_SUCCESSThe firmware volume base address is returned.
EFI_INVALID_PARAMETERThe requested LBA is out of range.

Definition at line 339 of file FwVolBlock.c.

◆ FwVolBlockGetPhysicalAddress()

EFI_STATUS EFIAPI FwVolBlockGetPhysicalAddress ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
OUT EFI_PHYSICAL_ADDRESS Address 
)

Get Fvb's base address.

Parameters
ThisIndicates the calling context.
AddressFvb device base address.
Return values
EFI_SUCCESSSuccessfully got Fvb's base address.
EFI_UNSUPPORTEDNot supported.

Definition at line 303 of file FwVolBlock.c.

◆ FwVolBlockReadBlock()

EFI_STATUS EFIAPI FwVolBlockReadBlock ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
IN CONST EFI_LBA  Lba,
IN CONST UINTN  Offset,
IN OUT UINTN NumBytes,
IN OUT UINT8 *  Buffer 
)

Read the specified number of bytes from the block to the input buffer.

Parameters
ThisIndicates the calling context.
LbaThe starting logical block index to read.
OffsetOffset into the block at which to begin reading.
NumBytesPointer to a UINT32. At entry, *NumBytes contains the total size of the buffer. At exit, NumBytes contains the total number of bytes actually read.
BufferPinter to a caller-allocated buffer that contains the destine for the read.
Return values
EFI_SUCCESSThe firmware volume was read successfully.
EFI_BAD_BUFFER_SIZEThe read was attempted across an LBA boundary.
EFI_ACCESS_DENIEDAccess denied.
EFI_DEVICE_ERRORThe block device is malfunctioning and could not be read.

Definition at line 188 of file FwVolBlock.c.

◆ FwVolBlockSetAttributes()

EFI_STATUS EFIAPI FwVolBlockSetAttributes ( IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
IN CONST EFI_FVB_ATTRIBUTES_2 Attributes 
)

Modifies the current settings of the firmware volume according to the input parameter.

Parameters
ThisCalling context
Attributesinput buffer which contains attributes
Return values
EFI_SUCCESSThe firmware volume attributes were returned.
EFI_INVALID_PARAMETERThe attributes requested are in conflict with the capabilities as declared in the firmware volume header.
EFI_UNSUPPORTEDNot supported.

Definition at line 125 of file FwVolBlock.c.

◆ FwVolBlockWriteBlock()

EFI_STATUS EFIAPI FwVolBlockWriteBlock ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL This,
IN EFI_LBA  Lba,
IN UINTN  Offset,
IN OUT UINTN NumBytes,
IN UINT8 *  Buffer 
)

Writes the specified number of bytes from the input buffer to the block.

Parameters
ThisIndicates the calling context.
LbaThe starting logical block index to write to.
OffsetOffset into the block at which to begin writing.
NumBytesPointer to a UINT32. At entry, *NumBytes contains the total size of the buffer. At exit, NumBytes contains the total number of bytes actually written.
BufferPinter to a caller-allocated buffer that contains the source for the write.
Return values
EFI_SUCCESSThe firmware volume was written successfully.
EFI_BAD_BUFFER_SIZEThe write was attempted across an LBA boundary. On output, NumBytes contains the total number of bytes actually written.
EFI_ACCESS_DENIEDThe firmware volume is in the WriteDisabled state.
EFI_DEVICE_ERRORThe block device is malfunctioning and could not be written.
EFI_UNSUPPORTEDNot supported.

Definition at line 280 of file FwVolBlock.c.

◆ GetFvbAuthenticationStatus()

UINT32 GetFvbAuthenticationStatus ( IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FvbProtocol)

Get FVB authentication status

Parameters
FvbProtocolFVB protocol.
Returns
Authentication status.

Definition at line 396 of file FwVolBlock.c.

◆ ProduceFVBProtocolOnBuffer()

EFI_STATUS ProduceFVBProtocolOnBuffer ( IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN EFI_HANDLE  ParentHandle,
IN UINT32  AuthenticationStatus,
OUT EFI_HANDLE *FvProtocol  OPTIONAL 
)

This routine produces a firmware volume block protocol on a given buffer.

Parameters
BaseAddressbase address of the firmware volume image
Lengthlength of the firmware volume image
ParentHandlehandle of parent firmware volume, if this image came from an FV image file and section in another firmware volume (ala capsules)
AuthenticationStatusAuthentication status inherited, if this image came from an FV image file and section in another firmware volume.
FvProtocolFirmware volume block protocol produced.
Return values
EFI_VOLUME_CORRUPTEDVolume corrupted.
EFI_OUT_OF_RESOURCESNo enough buffer to be allocated.
EFI_SUCCESSSuccessfully produced a FVB protocol on given buffer.

Definition at line 432 of file FwVolBlock.c.

Variable Documentation

◆ mFvMemmapDevicePathTemplate

FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate
Initial value:
= {
{
{
{
(UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
(UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8)
}
},
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_MEMMAP_DP
Definition: DevicePath.h:109
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
@ EfiMemoryMappedIO

Definition at line 15 of file FwVolBlock.c.

◆ mFvPIWGDevicePathTemplate

FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate
Initial value:
= {
{
{
MEDIA_DEVICE_PATH,
{
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)),
(UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8)
}
},
{ 0 }
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
}
#define MEDIA_PIWG_FW_VOL_DP
Definition: DevicePath.h:1146

Definition at line 39 of file FwVolBlock.c.

◆ mFwVolBlock

Initial value:
= {
FVB_DEVICE_SIGNATURE,
{
},
0,
0,
0,
0
}
EFI_STATUS(EFIAPI * EFI_FVB_WRITE)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
EFI_STATUS(EFIAPI * EFI_FVB_SET_ATTRIBUTES)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This, IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
EFI_STATUS(EFIAPI * EFI_FVB_ERASE_BLOCKS)(IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,...)
EFI_STATUS EFIAPI FwVolBlockGetBlockSize(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN OUT UINTN *BlockSize, IN OUT UINTN *NumberOfBlocks)
Definition: FwVolBlock.c:339
EFI_STATUS EFIAPI FwVolBlockGetPhysicalAddress(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_PHYSICAL_ADDRESS *Address)
Definition: FwVolBlock.c:303
EFI_STATUS EFIAPI FwVolBlockSetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FVB_ATTRIBUTES_2 *Attributes)
Definition: FwVolBlock.c:125
EFI_STATUS EFIAPI FwVolBlockWriteBlock(IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN OUT UINTN *NumBytes, IN UINT8 *Buffer)
Definition: FwVolBlock.c:280
EFI_STATUS EFIAPI FwVolBlockReadBlock(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_LBA Lba, IN CONST UINTN Offset, IN OUT UINTN *NumBytes, IN OUT UINT8 *Buffer)
Definition: FwVolBlock.c:188
EFI_STATUS EFIAPI FwVolBlockGetAttributes(IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, OUT EFI_FVB_ATTRIBUTES_2 *Attributes)
Definition: FwVolBlock.c:93
EFI_STATUS EFIAPI FwVolBlockEraseBlock(IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,...)
Definition: FwVolBlock.c:158
#define NULL
Definition: Base.h:319

Definition at line 61 of file FwVolBlock.c.