25 #ifndef USBUS_MSC_VENDOR_ID
26 #define USBUS_MSC_VENDOR_ID "RIOT-OS"
29 #ifndef USBUS_MSC_PRODUCT_ID
30 #define USBUS_MSC_PRODUCT_ID "RIOT_MSC_DISK "
33 #ifndef USBUS_MSC_PRODUCT_REV
34 #define USBUS_MSC_PRODUCT_REV " 1.0"
44 #define SCSI_TEST_UNIT_READY 0x00
45 #define SCSI_REQUEST_SENSE 0x03
46 #define SCSI_FORMAT_UNIT 0x04
47 #define SCSI_INQUIRY 0x12
48 #define SCSI_MODE_SELECT6 0x15
49 #define SCSI_MODE_SENSE6 0x1A
50 #define SCSI_START_STOP_UNIT 0x1B
51 #define SCSI_MEDIA_REMOVAL 0x1E
52 #define SCSI_READ_FORMAT_CAPACITIES 0x23
53 #define SCSI_READ_CAPACITY 0x25
54 #define SCSI_READ10 0x28
55 #define SCCI_READ12 0xA8
56 #define SCSI_WRITE10 0x2A
57 #define SCSI_WRITE12 0xAA
58 #define SCSI_SEEK 0x2B
59 #define SCSI_WRITE_AND_VERIFY 0x2E
60 #define SCSI_VERIFY10 0x2F
61 #define SCSI_MODE_SELECT10 0x55
62 #define SCSI_MODE_SENSE10 0x5A
68 #define SCSI_CBW_SIGNATURE 0x43425355
73 #define SCSI_CSW_SIGNATURE 0x53425355
79 #define SCSI_VERSION_NONE 0x0000
80 #define SCSI_VERSION_SCSI1 0x0001
81 #define SCSI_VERSION_SCSI2 0x0002
90 #define SCSI_READ_FMT_CAPA_TYPE_RESERVED 0x00
91 #define SCSI_READ_FMT_CAPA_TYPE_UNFORMATTED 0x01
92 #define SCSI_READ_FMT_CAPA_TYPE_FORMATTED 0x02
93 #define SCSI_READ_FMT_CAPA_TYPE_NO_MEDIA 0x03
99 #define SCSI_REQUEST_SENSE_ERROR 0x70
106 #define SCSI_SENSE_KEY_NO_SENSE 0x00
107 #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01
108 #define SCSI_SENSE_KEY_NOT_READY 0x02
109 #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03
110 #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04
111 #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05
112 #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06
113 #define SCSI_SENSE_KEY_DATA_PROTECT 0x07
114 #define SCSI_SENSE_KEY_BLANK_CHECK 0x08
115 #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09
116 #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B
117 #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D
118 #define SCSI_SENSE_KEY_MISCOMPARE 0x0E
126 typedef struct __attribute__((packed)) {
129 uint8_t reserved[10];
138 typedef struct __attribute__((packed)) {
153 typedef struct __attribute__((packed)) {
169 typedef struct __attribute__((packed)) {
178 uint8_t vendor_id[8];
179 uint8_t product_id[16];
180 uint8_t product_rev[4];
189 typedef struct __attribute__((packed)) {
190 uint8_t reserved1[3];
201 typedef struct __attribute__((packed)) {
205 uint8_t reserved2[4];
207 uint8_t reserved3[4];
222 typedef struct __attribute__((packed)) {
233 typedef struct __attribute__((packed)) {
249 typedef struct __attribute__((packed)) {
Functions to work with different byte orders.
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 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 length
Byte 4 Additional Length (n-4)
uint8_t removable
Byte 1 [B7] Removable device flag.
uint8_t type
Byte 0 Peripheral type.
uint8_t reserved1
Byte 1 [B6..B0] Reserved.
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.
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.
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 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 type
type of device
uint8_t logical_unit
Selected LUN.
usbdev endpoint descriptor
A 16 bit integer in big endian aka network byte order.
A 32 bit integer in big endian aka network byte order.