Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
usb_msd.c File Reference
+ Include dependency graph for usb_msd.c:

Go to the source code of this file.

Data Structures

struct  PACK_STRUCT_STRUCT
 Response to a READ_CAPACITY_10 SCSI command. More...
 
struct  PACK_STRUCT_STRUCT
 Response to a READ_CAPACITY_10 SCSI command. More...
 

Macros

#define MSD_REQ_RESET   0xFF
 
#define MSD_GET_MAX_LUN   0xFE
 
#define MSD_CBW_SIGNATURE   0x43425355
 
#define MSD_CSW_SIGNATURE   0x53425355
 
#define MSD_SETUP_WORD(setup, index)   (uint16_t)(((uint16_t)setup[index + 1] << 8) | (setup[index] & 0x00FF))
 
#define MSD_SETUP_VALUE(setup)   MSD_SETUP_WORD(setup, 2)
 
#define MSD_SETUP_INDEX(setup)   MSD_SETUP_WORD(setup, 4)
 
#define MSD_SETUP_LENGTH(setup)   MSD_SETUP_WORD(setup, 6)
 
#define MSD_COMMAND_PASSED   0x00
 
#define MSD_COMMAND_FAILED   0x01
 
#define MSD_COMMAND_PHASE_ERROR   0x02
 
#define SCSI_CMD_TEST_UNIT_READY   0x00
 
#define SCSI_CMD_REQUEST_SENSE   0x03
 
#define SCSI_CMD_FORMAT_UNIT   0x04
 
#define SCSI_CMD_INQUIRY   0x12
 
#define SCSI_CMD_MODE_SENSE_6   0x1A
 
#define SCSI_CMD_START_STOP_UNIT   0x1B
 
#define SCSI_CMD_SEND_DIAGNOSTIC   0x1D
 
#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E
 
#define SCSI_CMD_READ_FORMAT_CAPACITIES   0x23
 
#define SCSI_CMD_READ_CAPACITY_10   0x25
 
#define SCSI_CMD_READ_10   0x28
 
#define SCSI_CMD_WRITE_10   0x2A
 
#define SCSI_CMD_VERIFY_10   0x2F
 
#define SCSI_SENSE_KEY_GOOD   0x00
 
#define SCSI_SENSE_KEY_RECOVERED_ERROR   0x01
 
#define SCSI_SENSE_KEY_NOT_READY   0x02
 
#define SCSI_SENSE_KEY_MEDIUM_ERROR   0x03
 
#define SCSI_SENSE_KEY_HARDWARE_ERROR   0x04
 
#define SCSI_SENSE_KEY_ILLEGAL_REQUEST   0x05
 
#define SCSI_SENSE_KEY_UNIT_ATTENTION   0x06
 
#define SCSI_SENSE_KEY_DATA_PROTECT   0x07
 
#define SCSI_SENSE_KEY_BLANK_CHECK   0x08
 
#define SCSI_SENSE_KEY_VENDOR_SPECIFIC   0x09
 
#define SCSI_SENSE_KEY_COPY_ABORTED   0x0A
 
#define SCSI_SENSE_KEY_ABORTED_COMMAND   0x0B
 
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D
 
#define SCSI_SENSE_KEY_MISCOMPARE   0x0E
 
#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION   0x00
 
#define SCSI_ASENSE_WRITE_FAULT   0x03
 
#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY   0x04
 
#define SCSI_ASENSE_READ_ERROR   0x11
 
#define SCSI_ASENSE_INVALID_COMMAND   0x20
 
#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x21
 
#define SCSI_ASENSE_INVALID_FIELD_IN_CDB   0x24
 
#define SCSI_ASENSE_WRITE_PROTECTED   0x27
 
#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE   0x28
 
#define SCSI_ASENSE_FORMAT_ERROR   0x31
 
#define SCSI_ASENSE_MEDIUM_NOT_PRESENT   0x3A
 
#define SCSI_ASENSEQ_NO_QUALIFIER   0x00
 
#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED   0x01
 
#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED   0x02
 
#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS   0x07
 
#define swap_uint16(x)   (((((WORD)(x)) >> 8) & 0xff) | ((((WORD)(x)) & 0xff) << 8))
 Byte-swap a 16 bits unsigned integer. More...
 

Typedefs

typedef uint32_t DWORD
 
typedef uint16_t WORD
 

Functions

static DWORD swap_uint32 (DWORD val)
 Byte-swap a 32 bits unsigned integer. More...
 
static void msd_handle_end_point_notification (USBDriver *usbp, usbep_t ep)
 Called when data can be read or written on the endpoint – wakes the thread up. More...
 
void msdConfigureHookI (USBMassStorageDriver *msdp)
 USB device configured handler. More...
 
bool msdRequestsHook (USBDriver *usbp)
 Default requests hook. More...
 
static void msd_wait_for_isr (USBMassStorageDriver *msdp)
 Wait until the end-point interrupt handler has been called. More...
 
static void msd_start_transmit (USBMassStorageDriver *msdp, const uint8_t *buffer, size_t size)
 Starts sending data. More...
 
static void msd_start_receive (USBMassStorageDriver *msdp, uint8_t *buffer, size_t size)
 Starts receiving data. More...
 
static void msd_scsi_set_sense (USBMassStorageDriver *msdp, uint8_t key, uint8_t acode, uint8_t aqual)
 Changes the SCSI sense information. More...
 
bool msd_scsi_process_inquiry (USBMassStorageDriver *msdp)
 Processes an INQUIRY SCSI command. More...
 
bool msd_scsi_process_request_sense (USBMassStorageDriver *msdp)
 Processes a REQUEST_SENSE SCSI command. More...
 
bool msd_scsi_process_read_capacity_10 (USBMassStorageDriver *msdp)
 Processes a READ_CAPACITY_10 SCSI command. More...
 
bool msd_scsi_process_send_diagnostic (USBMassStorageDriver *msdp)
 Processes a SEND_DIAGNOSTIC SCSI command. More...
 
bool msd_scsi_process_start_read_write_10 (USBMassStorageDriver *msdp)
 Processes a READ_WRITE_10 SCSI command. More...
 
bool msd_scsi_process_start_stop_unit (USBMassStorageDriver *msdp)
 Processes a START_STOP_UNIT SCSI command. More...
 
bool msd_scsi_process_mode_sense_6 (USBMassStorageDriver *msdp)
 Processes a MODE_SENSE_6 SCSI command. More...
 
bool msd_scsi_process_read_format_capacities (USBMassStorageDriver *msdp)
 Processes a READ_FORMAT_CAPACITIES SCSI command. More...
 
bool msd_scsi_process_test_unit_ready (USBMassStorageDriver *msdp)
 Processes a TEST_UNIT_READY SCSI command. More...
 
bool msd_wait_for_command_block (USBMassStorageDriver *msdp)
 Waits for a new command block. More...
 
bool msd_read_command_block (USBMassStorageDriver *msdp)
 Reads a newly received command block. More...
 
static THD_WORKING_AREA (mass_storage_thread_wa, 1024)
 Mass storage thread that processes commands. More...
 
static void mass_storage_thread (void *arg)
 
void msdInit (USBMassStorageDriver *msdp)
 Initializse a USB mass storage driver. More...
 
void msdStart (USBMassStorageDriver *msdp, const USBMassStorageConfig *config)
 Starts a USB mass storage driver. More...
 
void msdStop (USBMassStorageDriver *msdp)
 Stops a USB mass storage driver. More...
 

Variables

static uint8_t rw_buf [2][512]
 Read-write buffers (TODO: need a way of specifying the size of this) More...
 
static USBInEndpointState ep1_in_state
 IN end-point 1 state. More...
 
static USBOutEndpointState ep1_out_state
 OUT end-point 1 state. More...
 
static const USBEndpointConfig ep_data_config
 End-point 1 initialization structure. More...
 

Data Structure Documentation

struct PACK_STRUCT_STRUCT

Response to a READ_CAPACITY_10 SCSI command.

structure holding the data to reply to an INQUIRY SCSI command

Structure holding sense data (status/error information)

Command Status Wrapper structure.

Command Block Wrapper structure.

Response to a READ_FORMAT_CAPACITIES SCSI command.

Definition at line 99 of file usb_msd.c.

Data Fields
uint8_t additional_length
uint32_t block_count
uint32_t block_size
uint8_t bqueetc
uint8_t byte[18]
uint8_t capacity_list_length
uint8_t cmdque
uint32_t data_len
uint32_t data_residue
uint32_t desc_and_block_length
uint8_t flags
uint32_t last_block_addr
uint8_t lun
uint8_t peripheral
uint8_t product_id[16]
uint8_t product_rev[4]
uint8_t removable
uint8_t reserved[3]
uint8_t response_data_format
uint8_t sccstp
uint8_t scsi_cmd_data[16]
uint8_t scsi_cmd_len
uint32_t signature
uint8_t status
uint32_t tag
uint8_t vendor_id[8]
uint8_t version
struct PACK_STRUCT_STRUCT

Response to a READ_CAPACITY_10 SCSI command.

structure holding the data to reply to an INQUIRY SCSI command

Structure holding sense data (status/error information)

Command Status Wrapper structure.

Command Block Wrapper structure.

Response to a READ_FORMAT_CAPACITIES SCSI command.

Definition at line 99 of file usb_msd.c.

Data Fields
uint8_t additional_length
uint32_t block_count
uint32_t block_size
uint8_t bqueetc
uint8_t byte[18]
uint8_t capacity_list_length
uint8_t cmdque
uint32_t data_len
uint32_t data_residue
uint32_t desc_and_block_length
uint8_t flags
uint32_t last_block_addr
uint8_t lun
uint8_t peripheral
uint8_t product_id[16]
uint8_t product_rev[4]
uint8_t removable
uint8_t reserved[3]
uint8_t response_data_format
uint8_t sccstp
uint8_t scsi_cmd_data[16]
uint8_t scsi_cmd_len
uint32_t signature
uint8_t status
uint32_t tag
uint8_t vendor_id[8]
uint8_t version

Macro Definition Documentation

#define MSD_CBW_SIGNATURE   0x43425355

Definition at line 34 of file usb_msd.c.

Referenced by msd_read_command_block().

#define MSD_COMMAND_FAILED   0x01

Definition at line 45 of file usb_msd.c.

Referenced by msd_read_command_block().

#define MSD_COMMAND_PASSED   0x00

Definition at line 44 of file usb_msd.c.

Referenced by msd_read_command_block().

#define MSD_COMMAND_PHASE_ERROR   0x02

Definition at line 46 of file usb_msd.c.

#define MSD_CSW_SIGNATURE   0x53425355

Definition at line 35 of file usb_msd.c.

Referenced by msd_read_command_block().

#define MSD_GET_MAX_LUN   0xFE

Definition at line 31 of file usb_msd.c.

Referenced by msdRequestsHook().

#define MSD_REQ_RESET   0xFF

Definition at line 30 of file usb_msd.c.

Referenced by msdRequestsHook().

#define MSD_SETUP_INDEX (   setup)    MSD_SETUP_WORD(setup, 4)

Definition at line 40 of file usb_msd.c.

Referenced by msdRequestsHook().

#define MSD_SETUP_LENGTH (   setup)    MSD_SETUP_WORD(setup, 6)

Definition at line 41 of file usb_msd.c.

Referenced by msdRequestsHook().

#define MSD_SETUP_VALUE (   setup)    MSD_SETUP_WORD(setup, 2)

Definition at line 39 of file usb_msd.c.

Referenced by msdRequestsHook().

#define MSD_SETUP_WORD (   setup,
  index 
)    (uint16_t)(((uint16_t)setup[index + 1] << 8) | (setup[index] & 0x00FF))

Definition at line 38 of file usb_msd.c.

#define SCSI_ASENSE_FORMAT_ERROR   0x31

Definition at line 88 of file usb_msd.c.

#define SCSI_ASENSE_INVALID_COMMAND   0x20

Definition at line 83 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_ASENSE_INVALID_FIELD_IN_CDB   0x24

Definition at line 85 of file usb_msd.c.

Referenced by msd_scsi_process_inquiry(), and msd_scsi_process_send_diagnostic().

#define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE   0x21

Definition at line 84 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY   0x04

Definition at line 81 of file usb_msd.c.

#define SCSI_ASENSE_MEDIUM_NOT_PRESENT   0x3A

Definition at line 89 of file usb_msd.c.

Referenced by msd_scsi_process_test_unit_ready().

#define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION   0x00

Definition at line 79 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE   0x28

Definition at line 87 of file usb_msd.c.

#define SCSI_ASENSE_READ_ERROR   0x11

Definition at line 82 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_ASENSE_WRITE_FAULT   0x03

Definition at line 80 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_ASENSE_WRITE_PROTECTED   0x27

Definition at line 86 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED   0x01

Definition at line 92 of file usb_msd.c.

#define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED   0x02

Definition at line 93 of file usb_msd.c.

#define SCSI_ASENSEQ_OPERATION_IN_PROGRESS   0x07

Definition at line 94 of file usb_msd.c.

#define SCSI_CMD_FORMAT_UNIT   0x04

Definition at line 51 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_INQUIRY   0x12

Definition at line 52 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_MODE_SENSE_6   0x1A

Definition at line 53 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E

Definition at line 56 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_READ_10   0x28

Definition at line 59 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_READ_CAPACITY_10   0x25

Definition at line 58 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_READ_FORMAT_CAPACITIES   0x23

Definition at line 57 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_REQUEST_SENSE   0x03

Definition at line 50 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_SEND_DIAGNOSTIC   0x1D

Definition at line 55 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_START_STOP_UNIT   0x1B

Definition at line 54 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_TEST_UNIT_READY   0x00

Definition at line 49 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_VERIFY_10   0x2F

Definition at line 61 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_CMD_WRITE_10   0x2A

Definition at line 60 of file usb_msd.c.

Referenced by msd_read_command_block(), and msd_scsi_process_start_read_write_10().

#define SCSI_SENSE_KEY_ABORTED_COMMAND   0x0B

Definition at line 75 of file usb_msd.c.

#define SCSI_SENSE_KEY_BLANK_CHECK   0x08

Definition at line 72 of file usb_msd.c.

#define SCSI_SENSE_KEY_COPY_ABORTED   0x0A

Definition at line 74 of file usb_msd.c.

#define SCSI_SENSE_KEY_DATA_PROTECT   0x07

Definition at line 71 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_SENSE_KEY_GOOD   0x00

Definition at line 64 of file usb_msd.c.

Referenced by msd_read_command_block().

#define SCSI_SENSE_KEY_HARDWARE_ERROR   0x04

Definition at line 68 of file usb_msd.c.

#define SCSI_SENSE_KEY_ILLEGAL_REQUEST   0x05
#define SCSI_SENSE_KEY_MEDIUM_ERROR   0x03

Definition at line 67 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

#define SCSI_SENSE_KEY_MISCOMPARE   0x0E

Definition at line 77 of file usb_msd.c.

#define SCSI_SENSE_KEY_NOT_READY   0x02

Definition at line 66 of file usb_msd.c.

Referenced by msd_scsi_process_test_unit_ready().

#define SCSI_SENSE_KEY_RECOVERED_ERROR   0x01

Definition at line 65 of file usb_msd.c.

#define SCSI_SENSE_KEY_UNIT_ATTENTION   0x06

Definition at line 70 of file usb_msd.c.

#define SCSI_SENSE_KEY_VENDOR_SPECIFIC   0x09

Definition at line 73 of file usb_msd.c.

#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D

Definition at line 76 of file usb_msd.c.

#define swap_uint16 (   x)    (((((WORD)(x)) >> 8) & 0xff) | ((((WORD)(x)) & 0xff) << 8))

Byte-swap a 16 bits unsigned integer.

Definition at line 136 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().

Typedef Documentation

typedef uint32_t DWORD

Definition at line 119 of file usb_msd.c.

typedef uint16_t WORD

Definition at line 119 of file usb_msd.c.

Function Documentation

static void mass_storage_thread ( void *  arg)
static

Definition at line 741 of file usb_msd.c.

References USBMassStorageDriver::config, MSD_EJECTED, MSD_IDLE, MSD_READ_COMMAND_BLOCK, msd_read_command_block(), msd_wait_for_command_block(), msd_wait_for_isr(), USBMassStorageDriver::state, and USBMassStorageConfig::usbp.

Referenced by msdStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void msd_handle_end_point_notification ( USBDriver *  usbp,
usbep_t  ep 
)
static

Called when data can be read or written on the endpoint – wakes the thread up.

Definition at line 252 of file usb_msd.c.

bool msd_scsi_process_inquiry ( USBMassStorageDriver msdp)

Processes an INQUIRY SCSI command.

Definition at line 296 of file usb_msd.c.

References USBMassStorageDriver::cbw, USBMassStorageDriver::inquiry, msd_scsi_set_sense(), msd_start_transmit(), USBMassStorageDriver::result, SCSI_ASENSE_INVALID_FIELD_IN_CDB, SCSI_ASENSEQ_NO_QUALIFIER, and SCSI_SENSE_KEY_ILLEGAL_REQUEST.

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_mode_sense_6 ( USBMassStorageDriver msdp)

Processes a MODE_SENSE_6 SCSI command.

Definition at line 535 of file usb_msd.c.

References msd_start_transmit(), and USBMassStorageDriver::result.

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_read_capacity_10 ( USBMassStorageDriver msdp)

Processes a READ_CAPACITY_10 SCSI command.

Definition at line 353 of file usb_msd.c.

References USBMassStorageDriver::block_dev_info, msd_start_transmit(), USBMassStorageDriver::result, and swap_uint32().

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_read_format_capacities ( USBMassStorageDriver msdp)

Processes a READ_FORMAT_CAPACITIES SCSI command.

Definition at line 555 of file usb_msd.c.

References USBMassStorageDriver::block_dev_info, msd_start_transmit(), USBMassStorageDriver::result, and swap_uint32().

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_request_sense ( USBMassStorageDriver msdp)

Processes a REQUEST_SENSE SCSI command.

Definition at line 337 of file usb_msd.c.

References msd_start_transmit(), msd_wait_for_isr(), USBMassStorageDriver::result, and USBMassStorageDriver::sense.

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_send_diagnostic ( USBMassStorageDriver msdp)

Processes a SEND_DIAGNOSTIC SCSI command.

Definition at line 371 of file usb_msd.c.

References USBMassStorageDriver::cbw, msd_scsi_set_sense(), USBMassStorageDriver::result, SCSI_ASENSE_INVALID_FIELD_IN_CDB, SCSI_ASENSEQ_NO_QUALIFIER, and SCSI_SENSE_KEY_ILLEGAL_REQUEST.

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool msd_scsi_process_start_stop_unit ( USBMassStorageDriver msdp)

Processes a START_STOP_UNIT SCSI command.

Definition at line 517 of file usb_msd.c.

References USBMassStorageDriver::cbw, USBMassStorageDriver::evt_ejected, MSD_EJECTED, USBMassStorageDriver::result, and USBMassStorageDriver::state.

Referenced by msd_read_command_block().

+ Here is the caller graph for this function:

bool msd_scsi_process_test_unit_ready ( USBMassStorageDriver msdp)

Processes a TEST_UNIT_READY SCSI command.

Definition at line 573 of file usb_msd.c.

References USBMassStorageConfig::bbdp, USBMassStorageDriver::config, msd_scsi_set_sense(), USBMassStorageDriver::result, SCSI_ASENSE_MEDIUM_NOT_PRESENT, SCSI_ASENSEQ_NO_QUALIFIER, and SCSI_SENSE_KEY_NOT_READY.

Referenced by msd_read_command_block().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void msd_scsi_set_sense ( USBMassStorageDriver msdp,
uint8_t  key,
uint8_t  acode,
uint8_t  aqual 
)
inlinestatic

Changes the SCSI sense information.

Definition at line 286 of file usb_msd.c.

References USBMassStorageDriver::sense.

Referenced by msd_read_command_block(), msd_scsi_process_inquiry(), msd_scsi_process_send_diagnostic(), msd_scsi_process_start_read_write_10(), and msd_scsi_process_test_unit_ready().

+ Here is the caller graph for this function:

static void msd_start_receive ( USBMassStorageDriver msdp,
uint8_t buffer,
size_t  size 
)
static

Starts receiving data.

Definition at line 276 of file usb_msd.c.

References USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, and USBMassStorageConfig::usbp.

Referenced by msd_scsi_process_start_read_write_10(), and msd_wait_for_command_block().

+ Here is the caller graph for this function:

static void msd_start_transmit ( USBMassStorageDriver msdp,
const uint8_t buffer,
size_t  size 
)
static
bool msd_wait_for_command_block ( USBMassStorageDriver msdp)

Waits for a new command block.

Definition at line 595 of file usb_msd.c.

References USBMassStorageDriver::cbw, MSD_READ_COMMAND_BLOCK, msd_start_receive(), and USBMassStorageDriver::state.

Referenced by mass_storage_thread().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void msd_wait_for_isr ( USBMassStorageDriver msdp)
static

Wait until the end-point interrupt handler has been called.

Definition at line 240 of file usb_msd.c.

References USBMassStorageDriver::bsem.

Referenced by mass_storage_thread(), msd_read_command_block(), msd_scsi_process_request_sense(), and msd_scsi_process_start_read_write_10().

+ Here is the caller graph for this function:

void msdConfigureHookI ( USBMassStorageDriver msdp)

USB device configured handler.

Parameters
[in]msdppointer to the USBMassStorageDriver object

Definition at line 173 of file usb_msd.c.

References USBMassStorageDriver::bsem, USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, USBMassStorageDriver::evt_connected, and USBMassStorageConfig::usbp.

Referenced by usbEvent().

+ Here is the caller graph for this function:

void msdInit ( USBMassStorageDriver msdp)

Initializse a USB mass storage driver.

Initializes a USB mass storage driver.

Definition at line 782 of file usb_msd.c.

References USBMassStorageDriver::bsem, USBMassStorageDriver::config, USBMassStorageDriver::evt_connected, USBMassStorageDriver::evt_ejected, USBMassStorageDriver::inquiry, MSD_IDLE, USBMassStorageDriver::sense, USBMassStorageDriver::state, and USBMassStorageDriver::thread.

Referenced by thdUsbStorage().

+ Here is the caller graph for this function:

bool msdRequestsHook ( USBDriver *  usbp)

Default requests hook.

Parameters
[in]usbppointer to the USBDriver object
Returns
The hook status.
Return values
trueMessage handled internally.
falseMessage not handled.

Definition at line 188 of file usb_msd.c.

References MSD_GET_MAX_LUN, MSD_REQ_RESET, MSD_SETUP_INDEX, MSD_SETUP_LENGTH, and MSD_SETUP_VALUE.

void msdStart ( USBMassStorageDriver msdp,
const USBMassStorageConfig config 
)

Starts a USB mass storage driver.

This function is sufficient to have USB mass storage running, it internally runs a thread that handles USB requests and transfers. The block device must be connected but no file system must be mounted, everything is handled by the host system.

Definition at line 820 of file usb_msd.c.

References USBMassStorageConfig::bbdp, USBMassStorageDriver::block_dev_info, USBMassStorageConfig::bulk_ep, config, USBMassStorageDriver::config, USBMassStorageDriver::inquiry, mass_storage_thread(), MSD_IDLE, USBMassStorageConfig::short_product_id, USBMassStorageConfig::short_product_version, USBMassStorageConfig::short_vendor_id, USBMassStorageDriver::state, USBMassStorageDriver::thread, and USBMassStorageConfig::usbp.

Referenced by thdUsbStorage().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void msdStop ( USBMassStorageDriver msdp)

Stops a USB mass storage driver.

This function waits for current tasks to be finished, if any, and then stops the mass storage thread.

Definition at line 866 of file usb_msd.c.

References USBMassStorageDriver::bsem, USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, USBMassStorageDriver::thread, and USBMassStorageConfig::usbp.

Referenced by thdUsbStorage().

+ Here is the caller graph for this function:

static DWORD swap_uint32 ( DWORD  val)
inlinestatic

Byte-swap a 32 bits unsigned integer.

Definition at line 128 of file usb_msd.c.

Referenced by msd_scsi_process_read_capacity_10(), msd_scsi_process_read_format_capacities(), and msd_scsi_process_start_read_write_10().

+ Here is the caller graph for this function:

static THD_WORKING_AREA ( mass_storage_thread_wa  ,
1024   
)
static

Mass storage thread that processes commands.

Variable Documentation

USBInEndpointState ep1_in_state
static

IN end-point 1 state.

Definition at line 143 of file usb_msd.c.

USBOutEndpointState ep1_out_state
static

OUT end-point 1 state.

Definition at line 148 of file usb_msd.c.

const USBEndpointConfig ep_data_config
static
Initial value:
= {
USB_EP_MODE_TYPE_BULK,
NULL,
64,
64,
1,
NULL
}
static void msd_handle_end_point_notification(USBDriver *usbp, usbep_t ep)
Called when data can be read or written on the endpoint – wakes the thread up.
Definition: usb_msd.c:252
static USBOutEndpointState ep1_out_state
OUT end-point 1 state.
Definition: usb_msd.c:148
static USBInEndpointState ep1_in_state
IN end-point 1 state.
Definition: usb_msd.c:143

End-point 1 initialization structure.

Definition at line 153 of file usb_msd.c.

uint8_t rw_buf[2][512]
static

Read-write buffers (TODO: need a way of specifying the size of this)

Definition at line 117 of file usb_msd.c.

Referenced by msd_scsi_process_start_read_write_10().