Files | |
file | cmds.h |
USB mass storage commands. | |
file | inquiry.c |
Main routines of USB mass storage driver. | |
file | main.c |
Main routines of USB mass storage driver. | |
file | mast.c |
Generic functions for USB mass storage (implementation). | |
file | mast.h |
Generic functions for USB mass storage. | |
file | scsi.h |
SCSI related structures. | |
Data Structures | |
struct | scsi_cmd_inquiry_t |
struct | usb_massstor_cbw_t |
struct | usb_massstor_csw_t |
struct | usb_massstor_inquiry_result_t |
Result of SCSI INQUIRY command. More... | |
Defines | |
#define | BITS_GET(type, number, bitcount, offset) ((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset)) |
#define | BITS_GET_MASK(type, bitcount) (((type)(1 << (bitcount)))-1) |
#define | BITS_GET_MID_MASK(type, bitcount, offset) ((type)( BITS_GET_MASK(type, (bitcount) + (offset)) - BITS_GET_MASK(type, bitcount) )) |
#define | BULK_IN_EP 0 |
#define | BULK_OUT_EP 1 |
#define | GET_BULK_IN(dev) ((dev)->pipes[BULK_IN_EP].pipe) |
#define | GET_BULK_OUT(dev) ((dev)->pipes[BULK_OUT_EP].pipe) |
#define | INQUIRY_RESPONSE_LENGTH 36 |
#define | MASTLOG(format,) |
#define | NAME "usbmast" |
#define | str_peripheral_device_types_count (sizeof(str_peripheral_device_types)/sizeof(str_peripheral_device_types[0])) |
#define | STR_UNKNOWN "<unknown>" |
Functions | |
int | main (int argc, char *argv[]) |
Main entry point. | |
static void | trim_trailing_spaces (char *name) |
Trim trailing spaces from a string (rewrite with string terminator). | |
static void | usb_massstor_cbw_prepare (usb_massstor_cbw_t *cbw, uint32_t tag, uint32_t transfer_length, usb_direction_t dir, uint8_t lun, uint8_t cmd_len, uint8_t *cmd) |
int | usb_massstor_data_in (usb_device_t *dev, size_t bulk_in_pipe_index, size_t bulk_out_pipe_index, uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size, void *in_buffer, size_t in_buffer_size, size_t *received_size) |
Request data from mass storage device. | |
int | usb_massstor_get_max_lun (usb_device_t *dev) |
Get max LUN of a mass storage device. | |
int | usb_massstor_inquiry (usb_device_t *dev, size_t bulk_in_idx, size_t bulk_out_idx, usb_massstor_inquiry_result_t *inquiry_result) |
Perform SCSI INQUIRY command on USB mass storage device. | |
int | usb_massstor_reset (usb_device_t *dev) |
Perform bulk-only mass storage reset. | |
void | usb_massstor_reset_recovery (usb_device_t *dev, size_t bulk_in_idx, size_t bulk_out_idx) |
Perform complete reset recovery of bulk-only mass storage. | |
size_t | usb_masstor_get_lun_count (usb_device_t *dev) |
Get number of LUNs supported by mass storage device. | |
const char * | usb_str_masstor_scsi_peripheral_device_type (int type) |
Get string representation for SCSI peripheral device type. | |
static int | usbmast_add_device (usb_device_t *dev) |
Callback when new device is attached and recognized as a mass storage. | |
Variables | |
static usb_endpoint_description_t | bulk_in_ep |
static usb_endpoint_description_t | bulk_out_ep |
usb_endpoint_description_t * | mast_endpoints [] |
static const char * | str_peripheral_device_types [] |
String constants for SCSI peripheral device types. | |
bool | usb_mast_verbose = true |
static usb_driver_t | usbmast_driver |
USB mass storage driver. | |
static usb_driver_ops_t | usbmast_driver_ops |
USB mass storage driver ops. |
This driver is a only a stub and is currently used only for testing that bulk transfers work.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
static void trim_trailing_spaces | ( | char * | name | ) | [static] |
int usb_massstor_data_in | ( | usb_device_t * | dev, | |
size_t | bulk_in_pipe_index, | |||
size_t | bulk_out_pipe_index, | |||
uint32_t | tag, | |||
uint8_t | lun, | |||
void * | cmd, | |||
size_t | cmd_size, | |||
void * | in_buffer, | |||
size_t | in_buffer_size, | |||
size_t * | received_size | |||
) |
Request data from mass storage device.
bulk_in_pipe | Bulk in pipe to the device. | |
bulk_out_pipe | Bulk out pipe to the device. | |
tag | Command block wrapper tag (automatically compared with answer). | |
lun | LUN index. | |
cmd | SCSI command buffer (in SCSI endianness). | |
cmd_size | Length of SCSI command cmd in bytes. | |
in_buffer | Buffer where to store the answer (CSW is not returned). | |
in_buffer_size | Size of the buffer (size of the request to the device). | |
received_size | Number of actually received bytes. |
int usb_massstor_get_max_lun | ( | usb_device_t * | dev | ) |
Get max LUN of a mass storage device.
dev | Mass storage device. |
int usb_massstor_inquiry | ( | usb_device_t * | dev, | |
size_t | bulk_in_idx, | |||
size_t | bulk_out_idx, | |||
usb_massstor_inquiry_result_t * | inquiry_result | |||
) |
int usb_massstor_reset | ( | usb_device_t * | dev | ) |
void usb_massstor_reset_recovery | ( | usb_device_t * | dev, | |
size_t | bulk_in_idx, | |||
size_t | bulk_out_idx | |||
) |
Perform complete reset recovery of bulk-only mass storage.
Notice that no error is reported because if this fails, the error would reappear on next transaction somehow.
dev | Device to be reseted. | |
bulk_in_idx | Index of bulk in pipe. | |
bulk_out_idx | Index of bulk out pipe. |
size_t usb_masstor_get_lun_count | ( | usb_device_t * | dev | ) |
const char * usb_str_masstor_scsi_peripheral_device_type | ( | int | type | ) |
Get string representation for SCSI peripheral device type.
See for example here for a list http://en.wikipedia.org/wiki/SCSI_Peripheral_Device_Type.
type | SCSI peripheral device type code. |
static int usbmast_add_device | ( | usb_device_t * | dev | ) | [static] |