LUFA Library - Mass Storage Class Bootloader
SCSI.c File Reference
#include "SCSI.h"

Functions

bool SCSI_DecodeSCSICommand (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 
static bool SCSI_Command_Inquiry (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 
static bool SCSI_Command_Request_Sense (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 
static bool SCSI_Command_Read_Capacity_10 (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 
static bool SCSI_Command_ReadWrite_10 (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo, const bool IsDataRead)
 
static bool SCSI_Command_ModeSense_6 (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 

Variables

static const
SCSI_Inquiry_Response_t 
InquiryData
 
static
SCSI_Request_Sense_Response_t 
SenseData
 

Detailed Description

SCSI command processing routines, for SCSI commands issued by the host. Mass Storage devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information, which wrap around standard SCSI device commands for controlling the actual storage medium.

Function Documentation

static bool SCSI_Command_Inquiry ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)
static

Command processing for an issued SCSI INQUIRY command. This command returns information about the device's features and capabilities to the host.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
Returns
Boolean true if the command completed successfully, false otherwise.
static bool SCSI_Command_ModeSense_6 ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)
static

Command processing for an issued SCSI MODE SENSE (6) command. This command returns various informational pages about the SCSI device, as well as the device's Write Protect status.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
Returns
Boolean true if the command completed successfully, false otherwise.
static bool SCSI_Command_Read_Capacity_10 ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)
static

Command processing for an issued SCSI READ CAPACITY (10) command. This command returns information about the device's capacity on the selected Logical Unit (drive), as a number of OS-sized blocks.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
Returns
Boolean true if the command completed successfully, false otherwise.
static bool SCSI_Command_ReadWrite_10 ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo,
const bool  IsDataRead 
)
static

Command processing for an issued SCSI READ (10) or WRITE (10) command. This command reads in the block start address and total number of blocks to process, then calls the appropriate low-level Dataflash routine to handle the actual reading and writing of the data.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
[in]IsDataReadIndicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE)
Returns
Boolean true if the command completed successfully, false otherwise.
static bool SCSI_Command_Request_Sense ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)
static

Command processing for an issued SCSI REQUEST SENSE command. This command returns information about the last issued command, including the error code and additional error information so that the host can determine why a command failed to complete.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
Returns
Boolean true if the command completed successfully, false otherwise.
bool SCSI_DecodeSCSICommand ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)

Main routine to process the SCSI command located in the Command Block Wrapper read from the host. This dispatches to the appropriate SCSI command handling routine if the issued command is supported by the device, else it returns a command failure due to a ILLEGAL REQUEST.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface structure that the command is associated with
Returns
Boolean true if the command completed successfully, false otherwise

Variable Documentation

const SCSI_Inquiry_Response_t InquiryData
static
Initial value:
=
{
.DeviceType = DEVICE_TYPE_BLOCK,
.PeripheralQualifier = 0,
.Removable = true,
.Version = 0,
.ResponseDataFormat = 2,
.NormACA = false,
.TrmTsk = false,
.AERC = false,
.AdditionalLength = 0x1F,
.SoftReset = false,
.CmdQue = false,
.Linked = false,
.Sync = false,
.WideBus16Bit = false,
.WideBus32Bit = false,
.RelAddr = false,
.VendorID = "LUFA",
.ProductID = "Bootloader",
.RevisionID = {'0','.','0','0'},
}

Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's features and capabilities.

SCSI_Request_Sense_Response_t SenseData
static
Initial value:
=
{
.ResponseCode = 0x70,
.AdditionalLength = 0x0A,
}

Structure to hold the sense data for the last issued SCSI command, which is returned to the host after a SCSI REQUEST SENSE command is issued. This gives information on exactly why the last command failed to complete.