Path: blob/main/sys/contrib/edk2/Include/Protocol/FirmwareVolumeBlock.h
96339 views
/** @file1This file provides control over block-oriented firmware devices.23Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>4SPDX-License-Identifier: BSD-2-Clause-Patent56@par Revision Reference: PI7Version 1.0 and 1.2.89**/1011#ifndef __FIRMWARE_VOLUME_BLOCK_H__12#define __FIRMWARE_VOLUME_BLOCK_H__1314//15// EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is defined in PI 1.0 spec and its GUID value16// is later updated to be the same as that of EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL17// defined in PI 1.2 spec.18//19#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \20{ 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }2122#define EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID \23{ 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } }2425typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;2627typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL;2829/**30The GetAttributes() function retrieves the attributes and31current settings of the block.3233@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.3435@param Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the36attributes and current settings are37returned. Type EFI_FVB_ATTRIBUTES_2 is defined38in EFI_FIRMWARE_VOLUME_HEADER.3940@retval EFI_SUCCESS The firmware volume attributes were41returned.4243**/44typedef45EFI_STATUS46(EFIAPI *EFI_FVB_GET_ATTRIBUTES)(47IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,48OUT EFI_FVB_ATTRIBUTES_2 *Attributes49);5051/**52The SetAttributes() function sets configurable firmware volume53attributes and returns the new settings of the firmware volume.5455@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.5657@param Attributes On input, Attributes is a pointer to58EFI_FVB_ATTRIBUTES_2 that contains the59desired firmware volume settings. On60successful return, it contains the new61settings of the firmware volume. Type62EFI_FVB_ATTRIBUTES_2 is defined in63EFI_FIRMWARE_VOLUME_HEADER.6465@retval EFI_SUCCESS The firmware volume attributes were returned.6667@retval EFI_INVALID_PARAMETER The attributes requested are in68conflict with the capabilities69as declared in the firmware70volume header.7172**/73typedef74EFI_STATUS75(EFIAPI *EFI_FVB_SET_ATTRIBUTES)(76IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,77IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes78);7980/**81The GetPhysicalAddress() function retrieves the base address of82a memory-mapped firmware volume. This function should be called83only for memory-mapped firmware volumes.8485@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.8687@param Address Pointer to a caller-allocated88EFI_PHYSICAL_ADDRESS that, on successful89return from GetPhysicalAddress(), contains the90base address of the firmware volume.9192@retval EFI_SUCCESS The firmware volume base address was returned.9394@retval EFI_UNSUPPORTED The firmware volume is not memory mapped.9596**/97typedef98EFI_STATUS99(EFIAPI *EFI_FVB_GET_PHYSICAL_ADDRESS)(100IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,101OUT EFI_PHYSICAL_ADDRESS *Address102);103104/**105The GetBlockSize() function retrieves the size of the requested106block. It also returns the number of additional blocks with107the identical size. The GetBlockSize() function is used to108retrieve the block map (see EFI_FIRMWARE_VOLUME_HEADER).109110111@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.112113@param Lba Indicates the block for which to return the size.114115@param BlockSize Pointer to a caller-allocated UINTN in which116the size of the block is returned.117118@param NumberOfBlocks Pointer to a caller-allocated UINTN in119which the number of consecutive blocks,120starting with Lba, is returned. All121blocks in this range have a size of122BlockSize.123124125@retval EFI_SUCCESS The firmware volume base address was returned.126127@retval EFI_INVALID_PARAMETER The requested LBA is out of range.128129**/130typedef131EFI_STATUS132(EFIAPI *EFI_FVB_GET_BLOCK_SIZE)(133IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,134IN EFI_LBA Lba,135OUT UINTN *BlockSize,136OUT UINTN *NumberOfBlocks137);138139/**140Reads the specified number of bytes into a buffer from the specified block.141142The Read() function reads the requested number of bytes from the143requested block and stores them in the provided buffer.144Implementations should be mindful that the firmware volume145might be in the ReadDisabled state. If it is in this state,146the Read() function must return the status code147EFI_ACCESS_DENIED without modifying the contents of the148buffer. The Read() function must also prevent spanning block149boundaries. If a read is requested that would span a block150boundary, the read must read up to the boundary but not151beyond. The output parameter NumBytes must be set to correctly152indicate the number of bytes actually read. The caller must be153aware that a read may be partially completed.154155@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.156157@param Lba The starting logical block index158from which to read.159160@param Offset Offset into the block at which to begin reading.161162@param NumBytes Pointer to a UINTN. At entry, *NumBytes163contains the total size of the buffer. At164exit, *NumBytes contains the total number of165bytes read.166167@param Buffer Pointer to a caller-allocated buffer that will168be used to hold the data that is read.169170@retval EFI_SUCCESS The firmware volume was read successfully,171and contents are in Buffer.172173@retval EFI_BAD_BUFFER_SIZE Read attempted across an LBA174boundary. On output, NumBytes175contains the total number of bytes176returned in Buffer.177178@retval EFI_ACCESS_DENIED The firmware volume is in the179ReadDisabled state.180181@retval EFI_DEVICE_ERROR The block device is not182functioning correctly and could183not be read.184185**/186typedef187EFI_STATUS188(EFIAPI *EFI_FVB_READ)(189IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,190IN EFI_LBA Lba,191IN UINTN Offset,192IN OUT UINTN *NumBytes,193IN OUT UINT8 *Buffer194);195196/**197Writes the specified number of bytes from the input buffer to the block.198199The Write() function writes the specified number of bytes from200the provided buffer to the specified block and offset. If the201firmware volume is sticky write, the caller must ensure that202all the bits of the specified range to write are in the203EFI_FVB_ERASE_POLARITY state before calling the Write()204function, or else the result will be unpredictable. This205unpredictability arises because, for a sticky-write firmware206volume, a write may negate a bit in the EFI_FVB_ERASE_POLARITY207state but cannot flip it back again. Before calling the208Write() function, it is recommended for the caller to first call209the EraseBlocks() function to erase the specified block to210write. A block erase cycle will transition bits from the211(NOT)EFI_FVB_ERASE_POLARITY state back to the212EFI_FVB_ERASE_POLARITY state. Implementations should be213mindful that the firmware volume might be in the WriteDisabled214state. If it is in this state, the Write() function must215return the status code EFI_ACCESS_DENIED without modifying the216contents of the firmware volume. The Write() function must217also prevent spanning block boundaries. If a write is218requested that spans a block boundary, the write must store up219to the boundary but not beyond. The output parameter NumBytes220must be set to correctly indicate the number of bytes actually221written. The caller must be aware that a write may be222partially completed. All writes, partial or otherwise, must be223fully flushed to the hardware before the Write() service224returns.225226@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.227228@param Lba The starting logical block index to write to.229230@param Offset Offset into the block at which to begin writing.231232@param NumBytes The pointer to a UINTN. At entry, *NumBytes233contains the total size of the buffer. At234exit, *NumBytes contains the total number of235bytes actually written.236237@param Buffer The pointer to a caller-allocated buffer that238contains the source for the write.239240@retval EFI_SUCCESS The firmware volume was written successfully.241242@retval EFI_BAD_BUFFER_SIZE The write was attempted across an243LBA boundary. On output, NumBytes244contains the total number of bytes245actually written.246247@retval EFI_ACCESS_DENIED The firmware volume is in the248WriteDisabled state.249250@retval EFI_DEVICE_ERROR The block device is malfunctioning251and could not be written.252253254**/255typedef256EFI_STATUS257(EFIAPI *EFI_FVB_WRITE)(258IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,259IN EFI_LBA Lba,260IN UINTN Offset,261IN OUT UINTN *NumBytes,262IN UINT8 *Buffer263);264265///266/// EFI_LBA_LIST_TERMINATOR267///268#define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFFULL269270/**271Erases and initializes a firmware volume block.272273The EraseBlocks() function erases one or more blocks as denoted274by the variable argument list. The entire parameter list of275blocks must be verified before erasing any blocks. If a block is276requested that does not exist within the associated firmware277volume (it has a larger index than the last block of the278firmware volume), the EraseBlocks() function must return the279status code EFI_INVALID_PARAMETER without modifying the contents280of the firmware volume. Implementations should be mindful that281the firmware volume might be in the WriteDisabled state. If it282is in this state, the EraseBlocks() function must return the283status code EFI_ACCESS_DENIED without modifying the contents of284the firmware volume. All calls to EraseBlocks() must be fully285flushed to the hardware before the EraseBlocks() service286returns.287288@param This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL289instance.290291@param ... The variable argument list is a list of tuples.292Each tuple describes a range of LBAs to erase293and consists of the following:294- An EFI_LBA that indicates the starting LBA295- A UINTN that indicates the number of blocks to296erase.297298The list is terminated with an299EFI_LBA_LIST_TERMINATOR. For example, the300following indicates that two ranges of blocks301(5-7 and 10-11) are to be erased: EraseBlocks302(This, 5, 3, 10, 2, EFI_LBA_LIST_TERMINATOR);303304@retval EFI_SUCCESS The erase request successfully305completed.306307@retval EFI_ACCESS_DENIED The firmware volume is in the308WriteDisabled state.309@retval EFI_DEVICE_ERROR The block device is not functioning310correctly and could not be written.311The firmware device may have been312partially erased.313@retval EFI_INVALID_PARAMETER One or more of the LBAs listed314in the variable argument list do315not exist in the firmware volume.316317**/318typedef319EFI_STATUS320(EFIAPI *EFI_FVB_ERASE_BLOCKS)(321IN CONST EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL *This,322...323);324325///326/// The Firmware Volume Block Protocol is the low-level interface327/// to a firmware volume. File-level access to a firmware volume328/// should not be done using the Firmware Volume Block Protocol.329/// Normal access to a firmware volume must use the Firmware330/// Volume Protocol. Typically, only the file system driver that331/// produces the Firmware Volume Protocol will bind to the332/// Firmware Volume Block Protocol.333///334struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL {335EFI_FVB_GET_ATTRIBUTES GetAttributes;336EFI_FVB_SET_ATTRIBUTES SetAttributes;337EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress;338EFI_FVB_GET_BLOCK_SIZE GetBlockSize;339EFI_FVB_READ Read;340EFI_FVB_WRITE Write;341EFI_FVB_ERASE_BLOCKS EraseBlocks;342///343/// The handle of the parent firmware volume.344///345EFI_HANDLE ParentHandle;346};347348extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid;349extern EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid;350351#endif352353354