Path: blob/main/sys/contrib/edk2/Include/Protocol/BlockIo.h
96339 views
/** @file1Block IO protocol as defined in the UEFI 2.0 specification.23The Block IO protocol is used to abstract block devices like hard drives,4DVD-ROMs and floppy drives.56Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>7SPDX-License-Identifier: BSD-2-Clause-Patent89**/1011#ifndef __BLOCK_IO_H__12#define __BLOCK_IO_H__1314#define EFI_BLOCK_IO_PROTOCOL_GUID \15{ \160x964e5b21, 0x6459, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \17}1819typedef struct _EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL;2021///22/// Protocol GUID name defined in EFI1.1.23///24#define BLOCK_IO_PROTOCOL EFI_BLOCK_IO_PROTOCOL_GUID2526///27/// Protocol defined in EFI1.1.28///29typedef EFI_BLOCK_IO_PROTOCOL EFI_BLOCK_IO;3031/**32Reset the Block Device.3334@param This Indicates a pointer to the calling context.35@param ExtendedVerification Driver may perform diagnostics on reset.3637@retval EFI_SUCCESS The device was reset.38@retval EFI_DEVICE_ERROR The device is not functioning properly and could39not be reset.4041**/42typedef43EFI_STATUS44(EFIAPI *EFI_BLOCK_RESET)(45IN EFI_BLOCK_IO_PROTOCOL *This,46IN BOOLEAN ExtendedVerification47);4849/**50Read BufferSize bytes from Lba into Buffer.5152@param This Indicates a pointer to the calling context.53@param MediaId Id of the media, changes every time the media is replaced.54@param Lba The starting Logical Block Address to read from55@param BufferSize Size of Buffer, must be a multiple of device block size.56@param Buffer A pointer to the destination buffer for the data. The caller is57responsible for either having implicit or explicit ownership of the buffer.5859@retval EFI_SUCCESS The data was read correctly from the device.60@retval EFI_DEVICE_ERROR The device reported an error while performing the read.61@retval EFI_NO_MEDIA There is no media in the device.62@retval EFI_MEDIA_CHANGED The MediaId does not matched the current device.63@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.64@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,65or the buffer is not on proper alignment.6667**/68typedef69EFI_STATUS70(EFIAPI *EFI_BLOCK_READ)(71IN EFI_BLOCK_IO_PROTOCOL *This,72IN UINT32 MediaId,73IN EFI_LBA Lba,74IN UINTN BufferSize,75OUT VOID *Buffer76);7778/**79Write BufferSize bytes from Lba into Buffer.8081@param This Indicates a pointer to the calling context.82@param MediaId The media ID that the write request is for.83@param Lba The starting logical block address to be written. The caller is84responsible for writing to only legitimate locations.85@param BufferSize Size of Buffer, must be a multiple of device block size.86@param Buffer A pointer to the source buffer for the data.8788@retval EFI_SUCCESS The data was written correctly to the device.89@retval EFI_WRITE_PROTECTED The device can not be written to.90@retval EFI_DEVICE_ERROR The device reported an error while performing the write.91@retval EFI_NO_MEDIA There is no media in the device.92@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.93@retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.94@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,95or the buffer is not on proper alignment.9697**/98typedef99EFI_STATUS100(EFIAPI *EFI_BLOCK_WRITE)(101IN EFI_BLOCK_IO_PROTOCOL *This,102IN UINT32 MediaId,103IN EFI_LBA Lba,104IN UINTN BufferSize,105IN VOID *Buffer106);107108/**109Flush the Block Device.110111@param This Indicates a pointer to the calling context.112113@retval EFI_SUCCESS All outstanding data was written to the device114@retval EFI_DEVICE_ERROR The device reported an error while writting back the data115@retval EFI_NO_MEDIA There is no media in the device.116117**/118typedef119EFI_STATUS120(EFIAPI *EFI_BLOCK_FLUSH)(121IN EFI_BLOCK_IO_PROTOCOL *This122);123124/**125Block IO read only mode data and updated only via members of BlockIO126**/127typedef struct {128///129/// The curent media Id. If the media changes, this value is changed.130///131UINT32 MediaId;132133///134/// TRUE if the media is removable; otherwise, FALSE.135///136BOOLEAN RemovableMedia;137138///139/// TRUE if there is a media currently present in the device;140/// othersise, FALSE. THis field shows the media present status141/// as of the most recent ReadBlocks() or WriteBlocks() call.142///143BOOLEAN MediaPresent;144145///146/// TRUE if LBA 0 is the first block of a partition; otherwise147/// FALSE. For media with only one partition this would be TRUE.148///149BOOLEAN LogicalPartition;150151///152/// TRUE if the media is marked read-only otherwise, FALSE.153/// This field shows the read-only status as of the most recent WriteBlocks () call.154///155BOOLEAN ReadOnly;156157///158/// TRUE if the WriteBlock () function caches write data.159///160BOOLEAN WriteCaching;161162///163/// The intrinsic block size of the device. If the media changes, then164/// this field is updated.165///166UINT32 BlockSize;167168///169/// Supplies the alignment requirement for any buffer to read or write block(s).170///171UINT32 IoAlign;172173///174/// The last logical block address on the device.175/// If the media changes, then this field is updated.176///177EFI_LBA LastBlock;178179///180/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to181/// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the first LBA is aligned to182/// a physical block boundary.183///184EFI_LBA LowestAlignedLba;185186///187/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to188/// EFI_BLOCK_IO_PROTOCOL_REVISION2. Returns the number of logical blocks189/// per physical block.190///191UINT32 LogicalBlocksPerPhysicalBlock;192193///194/// Only present if EFI_BLOCK_IO_PROTOCOL.Revision is greater than or equal to195/// EFI_BLOCK_IO_PROTOCOL_REVISION3. Returns the optimal transfer length196/// granularity as a number of logical blocks.197///198UINT32 OptimalTransferLengthGranularity;199} EFI_BLOCK_IO_MEDIA;200201#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000202#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001203#define EFI_BLOCK_IO_PROTOCOL_REVISION3 0x0002001F204205///206/// Revision defined in EFI1.1.207///208#define EFI_BLOCK_IO_INTERFACE_REVISION EFI_BLOCK_IO_PROTOCOL_REVISION209210///211/// This protocol provides control over block devices.212///213struct _EFI_BLOCK_IO_PROTOCOL {214///215/// The revision to which the block IO interface adheres. All future216/// revisions must be backwards compatible. If a future version is not217/// back wards compatible, it is not the same GUID.218///219UINT64 Revision;220///221/// Pointer to the EFI_BLOCK_IO_MEDIA data for this device.222///223EFI_BLOCK_IO_MEDIA *Media;224225EFI_BLOCK_RESET Reset;226EFI_BLOCK_READ ReadBlocks;227EFI_BLOCK_WRITE WriteBlocks;228EFI_BLOCK_FLUSH FlushBlocks;229};230231extern EFI_GUID gEfiBlockIoProtocolGuid;232233#endif234235236