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.h File Reference
#include <ch.h>
#include <hal.h>
#include "std.h"
+ Include dependency graph for usb_msd.h:
+ This graph shows which files directly or indirectly include this file:

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...
 
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...
 
struct  USBMassStorageConfig
 Driver configuration structure. More...
 
struct  USBMassStorageDriver
 USB mass storage driver structure. More...
 

Macros

#define PACK_STRUCT_BEGIN
 
#define PACK_STRUCT_END
 
#define PACK_STRUCT_STRUCT   __attribute__((packed))
 

Enumerations

enum  msd_state_t { MSD_IDLE, MSD_READ_COMMAND_BLOCK, MSD_EJECTED }
 Possible states for the USB mass storage driver. More...
 

Functions

void msdInit (USBMassStorageDriver *msdp)
 Initializes 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...
 
void msdConfigureHookI (USBMassStorageDriver *msdp)
 USB device configured handler. More...
 
bool msdRequestsHook (USBDriver *usbp)
 Default requests hook. 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
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
struct USBMassStorageDriver

USB mass storage driver structure.

This structure holds all the states and members of a USB mass storage driver.

Definition at line 153 of file usb_msd.h.

+ Collaboration diagram for USBMassStorageDriver:
Data Fields
BlockDeviceInfo block_dev_info
binary_semaphore_t bsem
msd_cbw_t cbw
const USBMassStorageConfig * config
msd_csw_t csw
event_source_t evt_connected
event_source_t evt_ejected
msd_scsi_inquiry_response_t inquiry
bool result
msd_scsi_sense_response_t sense
msd_state_t state
thread_t * thread

Macro Definition Documentation

#define PACK_STRUCT_BEGIN

Definition at line 34 of file usb_msd.h.

#define PACK_STRUCT_END

Definition at line 38 of file usb_msd.h.

#define PACK_STRUCT_STRUCT   __attribute__((packed))

Definition at line 42 of file usb_msd.h.

Enumeration Type Documentation

Possible states for the USB mass storage driver.

Enumerator
MSD_IDLE 
MSD_READ_COMMAND_BLOCK 
MSD_EJECTED 

Definition at line 95 of file usb_msd.h.

Function Documentation

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)

Initializes 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.

Applications wanting to use the Mass Storage over USB driver can use this function as requests hook in the USB configuration. The following requests are emulated:

  • MSD_REQ_RESET.
  • MSD_GET_MAX_LUN.
Parameters
[in]usbppointer to the USBDriver object
Returns
The hook status.
Return values
trueMessage handled internally.
falseMessage not handled.
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: