A.3.8 BlockIo.c File

Example A-20-Block I/O, Block I/O 2, and Storage Security Protocols implementation template
/** @file
  <<BriefDescription>>
  <<DetailedDescription>>
  <<Copyright>>
  <<License>>
**/

#include "<<DriverName>>.h"

///
/// Block I/O Media structure
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_BLOCK_IO_MEDIA g<<DriverName>>BlockIoMedia = {
  0,           // MediaId
  FALSE,       // RemovableMedia 
  FALSE,       // MediaPresent
  TRUE,        // LogicalPartition
  FALSE,       // ReadOnly
  FALSE,       // WriteCaching
  512,         // BlockSize
  0,           // IoAlign
  0,           // LastBlock
  0,           // LowestAlignedLba
  0,           // LogicalBlocksPerPhysicalBlock
  0            // OptimalTransferLengthGranularity
};

///
/// Block I/O Protocol instance
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_BLOCK_IO_PROTOCOL g<<DriverName>>BlockIo = {
  EFI_BLOCK_IO_PROTOCOL_REVISION3,              // Revision 
  &g<<DriverName>>BlockIoMedia,                 // Media
  (EFI_BLOCK_RESET) <<DriverName>>BlockIoReset, // Reset
  <<DriverName>>BlockIoReadBlocks,              // ReadBlocks
  <<DriverName>>BlockIoWriteBlocks,             // WriteBlocks
  <<DriverName>>BlockIoFlushBlocks              // FlushBlocks
};

///
/// Block I/O 2 Protocol instance
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_BLOCK_IO2_PROTOCOL g<<DriverName>>BlockIo2 = {
  &g<<DriverName>>BlockIoMedia,                 // Media
  <<DriverName>>BlockIoReset,                   // Reset
  <<DriverName>>BlockIoReadBlocksEx,            // ReadBlocks
  <<DriverName>>BlockIoWriteBlocksEx,           // WriteBlocks
  <<DriverName>>BlockIoFlushBlocksEx            // FlushBlocks
};

///
/// Storage Securtity Command Protocol instance
///
GLOBAL_REMOVE_IF_UNREFERENCED
EFI_STORAGE_SECURITY_COMMAND_PROTOCOL g<<DriverName>>StorageSecurityCommand = {
  <<DriverName>>StorageSecurityCommandReceiveData,
  <<DriverName>>StorageSecurityCommandSendData
};

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoReadBlocks (
  IN  EFI_BLOCK_IO_PROTOCOL                     *This,
  IN  UINT32                                    MediaId,
  IN EFI_LBA                                    Lba,
  IN  UINTN                                     BufferSize,
  OUT VOID                                      *Buffer
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoWriteBlocks (
  IN EFI_BLOCK_IO_PROTOCOL                      *This,
  IN UINT32                                     MediaId,
  IN EFI_LBA                                    Lba,
  IN UINTN                                      BufferSize,
  IN VOID                                       *Buffer
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoFlushBlocks (
  IN EFI_BLOCK_IO_PROTOCOL                     *This
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoReset (
  IN EFI_BLOCK_IO2_PROTOCOL                    *This,
  IN BOOLEAN                                   ExtendedVerification
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoReadBlocksEx (
  IN     EFI_BLOCK_IO2_PROTOCOL                *This,
  IN     UINT32                                MediaId,
  IN EFI_LBA                                   LBA,
  IN OUT EFI_BLOCK_IO2_TOKEN                   *Token,
  IN     UINTN                                 BufferSize,
  OUT    VOID                                  *Buffer
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoWriteBlocksEx (
  IN     EFI_BLOCK_IO2_PROTOCOL                *This,
  IN     UINT32                                MediaId,
  IN EFI_LBA                                   LBA,
  IN OUT EFI_BLOCK_IO2_TOKEN                   *Token,
  IN     UINTN                                 BufferSize,
  IN     VOID                                  *Buffer
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>BlockIoFlushBlocksEx (
  IN     EFI_BLOCK_IO2_PROTOCOL                *This,
  IN OUT EFI_BLOCK_IO2_TOKEN                   *Token
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>StorageSecurityCommandReceiveData (
  IN  EFI_STORAGE_SECURITY_COMMAND_PROTOCOL    *This,
  IN  UINT32                                   MediaId,
  IN  UINT64                                   Timeout,
  IN  UINT8                                    SecurityProtocolId,
  IN  UINT16                                   SecurityProtocolSpecificData,
  IN  UINTN                                    PayloadBufferSize, 
  OUT VOID                                     *PayloadBuffer
  OUT UINTN                                    *PayloadTransferSize
  )
{
}

EFI_STATUS
EFIAPI
<<DriverName>>StorageSecurityCommandSendData (
  IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL     *This,
  IN UINT32                                    MediaId,
  IN UINT64                                    Timeout,
  IN UINT8                                     SecurityProtocolId,
  IN UINT16                                    SecurityProtocolSpecificData,
  IN UINTN                                     PayloadBufferSize,
  IN VOID                                      *PayloadBuffer
  )
{
}