Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
|
#include "ch.h"
#include "hal.h"
#include "chdebug.h"
#include "modules/loggers/sdlog_chibios/usb_msd.h"
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_STRUCT __attribute__((packed)) |
#define | PACK_STRUCT_BEGIN |
#define | PACK_STRUCT_END |
#define | USB_MS_DATA_EP 1 |
#define | USBD USBD1 |
#define | SEM_TAKEN |
#define | SEM_RELEASED |
#define | EVT_USB_RESET (1 << 0) |
#define | EVT_BOT_RESET (1 << 1) |
#define | EVT_SEM_TAKEN (1 << 2) |
#define | EVT_SEM_RELEASED (1 << 3) |
#define | EVT_USB_CONFIGURED (1 << 4) |
#define | EVT_SCSI_REQ_TEST_UNIT_READY (1 << 5) |
#define | EVT_SCSI_REQ_READ_FMT_CAP (1 << 6) |
#define | EVT_SCSI_REQ_SENSE6 (1 << 7) |
#define | EVT_SCSI_REQ_SENSE10 (1 << 8) |
#define | EVT_WAIT_FOR_COMMAND_BLOCK (1 << 9) |
#define | EVT_SCSI_REQ_SEND_DIAGNOSTIC (1 << 10) |
#define | EVT_SCSI_REQ_READ_CAP10 (1 << 11) |
#define | EVT_SCSI_PROC_INQ (1 << 12) |
Enumerations | |
enum | msd_state_t { MSD_IDLE, MSD_READ_COMMAND_BLOCK, MSD_EJECTED, MSD_BOT_RESET } |
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... | |
void | init_msd_driver (void *dbgThreadPtr, USBMassStorageConfig *msdConfig) |
void | deinit_msd_driver (void) |
void | msd_register_evt_connected (event_listener_t *elp, eventmask_t mask) |
register connected event source in local event mask More... | |
void | msd_register_evt_ejected (event_listener_t *elp, eventmask_t mask) |
register ejected event source in local event mask More... | |
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.
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.
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.
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.
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.
Data Fields | ||
---|---|---|
BlockDeviceInfo | block_dev_info | |
bool | bot_reset | |
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 | reconfigured_or_reset_event | |
bool | result | |
msd_scsi_sense_response_t | sense | |
msd_state_t | state | |
thread_t * | thread |
#define EVT_BOT_RESET (1 << 1) |
Definition at line 50 of file usb_msd.h.
Referenced by msdRequestsHook().
#define EVT_SCSI_PROC_INQ (1 << 12) |
Definition at line 61 of file usb_msd.h.
Referenced by msd_scsi_process_inquiry().
#define EVT_SCSI_REQ_READ_CAP10 (1 << 11) |
Definition at line 60 of file usb_msd.h.
Referenced by msd_scsi_process_read_capacity_10().
#define EVT_SCSI_REQ_READ_FMT_CAP (1 << 6) |
Definition at line 55 of file usb_msd.h.
Referenced by msd_scsi_process_read_format_capacities().
#define EVT_SCSI_REQ_SENSE10 (1 << 8) |
Definition at line 57 of file usb_msd.h.
Referenced by msd_scsi_process_start_read_write_10().
#define EVT_SCSI_REQ_SENSE6 (1 << 7) |
Definition at line 56 of file usb_msd.h.
Referenced by msd_scsi_process_mode_sense_6().
#define EVT_SCSI_REQ_TEST_UNIT_READY (1 << 5) |
Definition at line 54 of file usb_msd.h.
Referenced by msd_scsi_process_test_unit_ready().
#define EVT_SEM_RELEASED (1 << 3) |
Definition at line 52 of file usb_msd.h.
Referenced by msdConfigureHookI().
#define EVT_SEM_TAKEN (1 << 2) |
Definition at line 51 of file usb_msd.h.
Referenced by msd_wait_for_isr(), and msdInit().
#define EVT_USB_RESET (1 << 0) |
Definition at line 49 of file usb_msd.h.
Referenced by usbEvent().
#define EVT_WAIT_FOR_COMMAND_BLOCK (1 << 9) |
Definition at line 58 of file usb_msd.h.
Referenced by msd_wait_for_command_block().
#define PACK_STRUCT_STRUCT __attribute__((packed)) |
#define SEM_RELEASED |
Definition at line 47 of file usb_msd.h.
Referenced by msd_handle_end_point_notification(), and msdConfigureHookI().
#define SEM_TAKEN |
Definition at line 46 of file usb_msd.h.
Referenced by msd_wait_for_isr().
#define USB_MS_DATA_EP 1 |
Definition at line 40 of file usb_msd.h.
Referenced by mass_storage_thread().
#define USBD USBD1 |
Definition at line 44 of file usb_msd.h.
Referenced by init_msd_driver().
enum msd_state_t |
void deinit_msd_driver | ( | void | ) |
Definition at line 1121 of file usb_msd.c.
References msdStop().
Referenced by thdUsbStorage().
void init_msd_driver | ( | void * | dbgThreadPtr, |
USBMassStorageConfig * | msdConfig | ||
) |
Definition at line 1126 of file usb_msd.c.
References dbg_printer, msdInit(), msdStart(), and USBD.
Referenced by thdUsbStorage().
void msd_register_evt_connected | ( | event_listener_t * | elp, |
eventmask_t | mask | ||
) |
register connected event source in local event mask
This function is a stub to chEvtRegisterMask
Definition at line 1142 of file usb_msd.c.
References USBMassStorageDriver::evt_connected.
Referenced by thdUsbStorage().
void msd_register_evt_ejected | ( | event_listener_t * | elp, |
eventmask_t | mask | ||
) |
register ejected event source in local event mask
This function is a stub to chEvtRegisterMask ejected event is a logical event : when host unmount the filesystem, not a physical event (event is not sent in case of unplugged usb wire)
Definition at line 1147 of file usb_msd.c.
References USBMassStorageDriver::evt_ejected.
void msdConfigureHookI | ( | USBMassStorageDriver * | msdp | ) |
USB device configured handler.
[in] | msdp | pointer to the USBMassStorageDriver object |
Definition at line 188 of file usb_msd.c.
References USBMassStorageDriver::bsem, USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, debug_snd_evt_inl(), USBMassStorageDriver::evt_connected, EVT_SEM_RELEASED, SEM_RELEASED, and USBMassStorageConfig::usbp.
Referenced by usbEvent().
void msdInit | ( | USBMassStorageDriver * | msdp | ) |
Initializes a USB mass storage driver.
Initializes a USB mass storage driver.
Definition at line 815 of file usb_msd.c.
References USBMassStorageDriver::bot_reset, USBMassStorageDriver::bsem, USBMassStorageDriver::config, debug_snd_evt_i(), USBMassStorageDriver::evt_connected, USBMassStorageDriver::evt_ejected, EVT_SEM_TAKEN, USBMassStorageDriver::inquiry, MSD_IDLE, USBMassStorageDriver::reconfigured_or_reset_event, USBMassStorageDriver::sense, USBMassStorageDriver::state, and USBMassStorageDriver::thread.
Referenced by init_msd_driver().
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:
[in] | usbp | pointer to the USBDriver object |
true | Message handled internally. |
false | Message not handled. |
[in] | usbp | pointer to the USBDriver object |
true | Message handled internally. |
false | Message not handled. |
Definition at line 205 of file usb_msd.c.
References USBMassStorageDriver::bot_reset, USBMassStorageDriver::bsem, USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, debug_snd_evt_i(), EVT_BOT_RESET, MSD_BOT_RESET, MSD_GET_MAX_LUN, MSD_REQ_RESET, MSD_SETUP_INDEX, MSD_SETUP_LENGTH, MSD_SETUP_VALUE, USBMassStorageDriver::state, and USBMassStorageConfig::usbp.
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 855 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 init_msd_driver().
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 900 of file usb_msd.c.
References USBMassStorageDriver::bsem, USBMassStorageConfig::bulk_ep, USBMassStorageDriver::config, USBMassStorageDriver::thread, and USBMassStorageConfig::usbp.
Referenced by deinit_msd_driver().