28#ifndef USBUS_MSC_VENDOR_ID
29#define USBUS_MSC_VENDOR_ID "RIOT-OS"
32#ifndef USBUS_MSC_PRODUCT_ID
33#define USBUS_MSC_PRODUCT_ID "RIOT_MSC_DISK "
36#ifndef USBUS_MSC_PRODUCT_REV
37#define USBUS_MSC_PRODUCT_REV " 1.0"
47#define SCSI_TEST_UNIT_READY 0x00
48#define SCSI_REQUEST_SENSE 0x03
49#define SCSI_FORMAT_UNIT 0x04
50#define SCSI_INQUIRY 0x12
51#define SCSI_MODE_SELECT6 0x15
52#define SCSI_MODE_SENSE6 0x1A
53#define SCSI_START_STOP_UNIT 0x1B
54#define SCSI_MEDIA_REMOVAL 0x1E
55#define SCSI_READ_FORMAT_CAPACITIES 0x23
56#define SCSI_READ_CAPACITY 0x25
57#define SCSI_READ10 0x28
58#define SCCI_READ12 0xA8
59#define SCSI_WRITE10 0x2A
60#define SCSI_WRITE12 0xAA
62#define SCSI_WRITE_AND_VERIFY 0x2E
63#define SCSI_VERIFY10 0x2F
64#define SCSI_MODE_SELECT10 0x55
65#define SCSI_MODE_SENSE10 0x5A
71#define SCSI_CBW_SIGNATURE 0x43425355
76#define SCSI_CSW_SIGNATURE 0x53425355
82#define SCSI_VERSION_NONE 0x0000
83#define SCSI_VERSION_SCSI1 0x0001
84#define SCSI_VERSION_SCSI2 0x0002
93#define SCSI_READ_FMT_CAPA_TYPE_RESERVED 0x00
94#define SCSI_READ_FMT_CAPA_TYPE_UNFORMATTED 0x01
95#define SCSI_READ_FMT_CAPA_TYPE_FORMATTED 0x02
96#define SCSI_READ_FMT_CAPA_TYPE_NO_MEDIA 0x03
102#define SCSI_REQUEST_SENSE_ERROR 0x70
109#define SCSI_SENSE_KEY_NO_SENSE 0x00
110#define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
111#define SCSI_SENSE_KEY_NOT_READY 0x02
112#define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
113#define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
114#define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
115#define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
116#define SCSI_SENSE_KEY_DATA_PROTECT 0x07
117#define SCSI_SENSE_KEY_BLANK_CHECK 0x08
118#define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
119#define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
120#define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
121#define SCSI_SENSE_KEY_MISCOMPARE 0x0E
129typedef struct __attribute__((packed)) {
141typedef struct __attribute__((packed)) {
156typedef struct __attribute__((packed)) {
172typedef struct __attribute__((packed)) {
192typedef struct __attribute__((packed)) {
204typedef struct __attribute__((packed)) {
225typedef struct __attribute__((packed)) {
236typedef struct __attribute__((packed)) {
252typedef struct __attribute__((packed)) {
Functions to work with different byte orders.
struct usbdev_ep usbdev_ep_t
usbdev_ep_t forward declaration
struct usbus_handler usbus_handler_t
USBUS event handler forward declaration.
struct usbus usbus_t
USBUS context forward declaration.
void usbus_msc_scsi_process_cmd(usbus_t *usbus, usbus_handler_t *handler, usbdev_ep_t *ep, size_t len)
Process incoming Command Block Wrapper buffer.
void scsi_gen_csw(usbus_handler_t *handler, cbw_info_t *cmd)
Generate Command Status Wrapper and send it to the host.
USBUS Command Block Wrapper information.
uint8_t status
Status of the current operation.
size_t len
Remaining bytes to handle.
uint8_t lun
Store LUN from CBW.
uint32_t tag
Store tag information from CBW.
Command Block Wrapper packet structure.
uint32_t tag
ID for the current command.
uint32_t signature
CBW signature (SCSI_CBW_SIGNATURE)
uint8_t lun
Target Logical Unit Number.
uint32_t data_len
Number of bytes host expects to transfer from/to.
uint8_t cb[16]
Command block buffer.
uint8_t flags
Command block flags.
uint8_t cb_len
Length of the block in bytes (max: 16 bytes)
CBW Packet structure for (SCSI_READ10) and (SCSI_WRITE10) requests.
uint8_t group_number
Group number.
uint8_t flags
Miscellaneous flags.
be_uint32_t blk_addr
Block address.
be_uint16_t xfer_len
Transfer length in bytes.
uint8_t opcode
Operation code.
Command Status Wrapper packet structure.
uint32_t signature
CSW signature (SCSI_CSW_SIGNATURE)
uint8_t status
Status of the command.
uint32_t tag
ID for the answered CBW.
uint32_t data_left
Indicate how many bytes from the CBW were not processed.
Packet structure to answer (SCSI_INQUIRY) request.
uint8_t product_rev[4]
Byte 35..32 Product Revision.
uint8_t vendor_id[8]
Byte 15..8 Vendor Identification.
uint8_t length
Byte 4 Additional Length (n-4)
uint8_t removable
Byte 1 [B7] Removable device flag.
uint8_t product_id[16]
Byte 31..16 Product Identification.
uint8_t type
Byte 0 Peripheral type.
uint8_t reserved1
Byte 1 [B6..B0] Reserved.
uint8_t flags[3]
Byte 7..5 Miscellaneous flags UNUSED BY USBUS ONLY.
uint8_t reserved3
Byte 3 [B7..B4] Reserved.
uint8_t response_format
Byte 3 [B3..B0] Response Data Format.
uint8_t version
Byte 2 SCSI Version.
Packet structure to answer (SCSI_MODE_SELECT6) and (SCSI_MODE_SENSE6) requests.
uint8_t medium_type
Type of medium.
uint8_t mode_data_len
Size of the whole packet.
uint8_t flags
Miscellaneous flags.
uint8_t block_desc_len
Length of block descriptor.
Packet structure to answer (SCSI_READ_CAPACITY) request.
be_uint32_t last_blk
Indicate last block number.
be_uint32_t blk_len
Total size of a block in bytes.
Packet structure to answer (SCSI_READ_FORMAT_CAPACITIES) request.
uint8_t type
Byte 8 Descriptor type.
uint8_t blk_len[3]
Byte 11..9 Block length.
uint8_t reserved1[3]
Byte 2..0 reserved.
be_uint32_t blk_nb
Byte 7..4 Number of blocks.
uint8_t list_length
Byte 3 Capacity list length.
Packet structure to answer (SCSI_REQUEST_SENSE) request.
uint8_t reserved2[4]
Byte 6..3 Information.
uint16_t sk_spec
Byte 16..15 Sense Key Specific.
uint8_t fruc
Byte 14 Field Replaceable Unit Code.
uint8_t asc
Byte 12 Additional Sense Code.
uint8_t ascq
Byte 13 Additional Sense Code Qualifier.
uint8_t sense_key
Byte 2 Sense key.
uint8_t reserved1
Reserved.
uint8_t reserved3[4]
Byte 11..8 Vendor specific.
uint8_t error_code
Byte 0 Error code.
uint8_t add_len
Byte 7 Additional sense length.
Packet structure to answer (SCSI_TEST_UNIT_READY) request.
uint8_t reserved[10]
Reserved.
uint8_t type
type of device
uint8_t logical_unit
Selected LUN.
A 16 bit integer in big endian aka network byte order.
A 32 bit integer in big endian aka network byte order.