Loading...
Searching...
No Matches
scsi.h File Reference

SCSI protocol definitions for USBUS. More...

Detailed Description

SCSI protocol definitions for USBUS.

Author
Dylan Laduranty dylan.nosp@m..lad.nosp@m.urant.nosp@m.y@me.nosp@m.sotic.nosp@m..com

Definition in file scsi.h.

#include "byteorder.h"
+ Include dependency graph for scsi.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  msc_test_unit_pkt_t
 Packet structure to answer (SCSI_TEST_UNIT_READY) request. More...
 
struct  msc_mode_parameter_pkt_t
 Packet structure to answer (SCSI_MODE_SELECT6) and (SCSI_MODE_SENSE6) requests. More...
 
struct  msc_cbw_rw10_pkt_t
 CBW Packet structure for (SCSI_READ10) and (SCSI_WRITE10) requests. More...
 
struct  msc_inquiry_pkt_t
 Packet structure to answer (SCSI_INQUIRY) request. More...
 
struct  msc_read_fmt_capa_pkt_t
 Packet structure to answer (SCSI_READ_FORMAT_CAPACITIES) request. More...
 
struct  msc_request_sense_pkt_t
 Packet structure to answer (SCSI_REQUEST_SENSE) request. More...
 
struct  msc_read_capa_pkt_t
 Packet structure to answer (SCSI_READ_CAPACITY) request. More...
 
struct  msc_cbw_buf_t
 Command Block Wrapper packet structure. More...
 
struct  msc_csw_buf_t
 Command Status Wrapper packet structure. More...
 
struct  cbw_info_t
 USBUS Command Block Wrapper information. More...
 

Macros

#define SCSI_CBW_SIGNATURE   0x43425355
 Command Block Wrapper signature.
 
#define SCSI_CSW_SIGNATURE   0x53425355
 Command Status Wrapper signature.
 
#define SCSI_REQUEST_SENSE_ERROR   0x70
 SCSI Request Sense error type.
 

Functions

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.
 
#define USBUS_MSC_VENDOR_ID   "RIOT-OS"
 
#define USBUS_MSC_PRODUCT_ID   "RIOT_MSC_DISK "
 
#define USBUS_MSC_PRODUCT_REV   " 1.0"
 

USB SCSI Commands

See also
Table 9 - Packet Commands Supported by ATAPI Block Devices from INF-8070i draft published by SFF
#define SCSI_TEST_UNIT_READY   0x00
 SCSI Test Unit Ready.
 
#define SCSI_REQUEST_SENSE   0x03
 SCSI Request Sense.
 
#define SCSI_FORMAT_UNIT   0x04
 SCSI Format Unit.
 
#define SCSI_INQUIRY   0x12
 SCSI Inquiry.
 
#define SCSI_MODE_SELECT6   0x15
 SCSI Mode Select6.
 
#define SCSI_MODE_SENSE6   0x1A
 SCSI Mode Sense6.
 
#define SCSI_START_STOP_UNIT   0x1B
 SCSI Start Stop Unit.
 
#define SCSI_MEDIA_REMOVAL   0x1E
 SCSI Media Removal.
 
#define SCSI_READ_FORMAT_CAPACITIES   0x23
 SCSI Read Format Capacities.
 
#define SCSI_READ_CAPACITY   0x25
 SCSI Read Capacity.
 
#define SCSI_READ10   0x28
 SCSI Read10.
 
#define SCCI_READ12   0xA8
 SCSI Read12.
 
#define SCSI_WRITE10   0x2A
 SCSI Write10.
 
#define SCSI_WRITE12   0xAA
 SCSI Write12.
 
#define SCSI_SEEK   0x2B
 SCSI Seek.
 
#define SCSI_WRITE_AND_VERIFY   0x2E
 SCSI Write and Verify.
 
#define SCSI_VERIFY10   0x2F
 SCSI Verify10.
 
#define SCSI_MODE_SELECT10   0x55
 SCSI Mode Select10.
 
#define SCSI_MODE_SENSE10   0x5A
 SCSI Mode Sense10.
 

USB SCSI Version list

#define SCSI_VERSION_NONE   0x0000
 
#define SCSI_VERSION_SCSI1   0x0001
 
#define SCSI_VERSION_SCSI2   0x0002
 

USB SCSI Read format capacities descriptor type

See also
( msc_read_fmt_capa_pkt_t )
#define SCSI_READ_FMT_CAPA_TYPE_RESERVED   0x00
 
#define SCSI_READ_FMT_CAPA_TYPE_UNFORMATTED   0x01
 
#define SCSI_READ_FMT_CAPA_TYPE_FORMATTED   0x02
 
#define SCSI_READ_FMT_CAPA_TYPE_NO_MEDIA   0x03
 

USB SCSI Request Sense Sense Key type

#define SCSI_SENSE_KEY_NO_SENSE   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_ABORTED_COMMAND   0x0B
 
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D
 
#define SCSI_SENSE_KEY_MISCOMPARE   0x0E
 

Macro Definition Documentation

◆ SCCI_READ12

#define SCCI_READ12   0xA8

SCSI Read12.

Definition at line 59 of file scsi.h.

◆ SCSI_CBW_SIGNATURE

#define SCSI_CBW_SIGNATURE   0x43425355

Command Block Wrapper signature.

Definition at line 72 of file scsi.h.

◆ SCSI_CSW_SIGNATURE

#define SCSI_CSW_SIGNATURE   0x53425355

Command Status Wrapper signature.

Definition at line 77 of file scsi.h.

◆ SCSI_FORMAT_UNIT

#define SCSI_FORMAT_UNIT   0x04

SCSI Format Unit.

Definition at line 50 of file scsi.h.

◆ SCSI_INQUIRY

#define SCSI_INQUIRY   0x12

SCSI Inquiry.

Definition at line 51 of file scsi.h.

◆ SCSI_MEDIA_REMOVAL

#define SCSI_MEDIA_REMOVAL   0x1E

SCSI Media Removal.

Definition at line 55 of file scsi.h.

◆ SCSI_MODE_SELECT10

#define SCSI_MODE_SELECT10   0x55

SCSI Mode Select10.

Definition at line 65 of file scsi.h.

◆ SCSI_MODE_SELECT6

#define SCSI_MODE_SELECT6   0x15

SCSI Mode Select6.

Definition at line 52 of file scsi.h.

◆ SCSI_MODE_SENSE10

#define SCSI_MODE_SENSE10   0x5A

SCSI Mode Sense10.

Definition at line 66 of file scsi.h.

◆ SCSI_MODE_SENSE6

#define SCSI_MODE_SENSE6   0x1A

SCSI Mode Sense6.

Definition at line 53 of file scsi.h.

◆ SCSI_READ10

#define SCSI_READ10   0x28

SCSI Read10.

Definition at line 58 of file scsi.h.

◆ SCSI_READ_CAPACITY

#define SCSI_READ_CAPACITY   0x25

SCSI Read Capacity.

Definition at line 57 of file scsi.h.

◆ SCSI_READ_FMT_CAPA_TYPE_FORMATTED

#define SCSI_READ_FMT_CAPA_TYPE_FORMATTED   0x02

Definition at line 96 of file scsi.h.

◆ SCSI_READ_FMT_CAPA_TYPE_NO_MEDIA

#define SCSI_READ_FMT_CAPA_TYPE_NO_MEDIA   0x03

Definition at line 97 of file scsi.h.

◆ SCSI_READ_FMT_CAPA_TYPE_RESERVED

#define SCSI_READ_FMT_CAPA_TYPE_RESERVED   0x00

Definition at line 94 of file scsi.h.

◆ SCSI_READ_FMT_CAPA_TYPE_UNFORMATTED

#define SCSI_READ_FMT_CAPA_TYPE_UNFORMATTED   0x01

Definition at line 95 of file scsi.h.

◆ SCSI_READ_FORMAT_CAPACITIES

#define SCSI_READ_FORMAT_CAPACITIES   0x23

SCSI Read Format Capacities.

Definition at line 56 of file scsi.h.

◆ SCSI_REQUEST_SENSE

#define SCSI_REQUEST_SENSE   0x03

SCSI Request Sense.

Definition at line 49 of file scsi.h.

◆ SCSI_REQUEST_SENSE_ERROR

#define SCSI_REQUEST_SENSE_ERROR   0x70

SCSI Request Sense error type.

Definition at line 103 of file scsi.h.

◆ SCSI_SEEK

#define SCSI_SEEK   0x2B

SCSI Seek.

Definition at line 62 of file scsi.h.

◆ SCSI_SENSE_KEY_ABORTED_COMMAND

#define SCSI_SENSE_KEY_ABORTED_COMMAND   0x0B

Definition at line 120 of file scsi.h.

◆ SCSI_SENSE_KEY_BLANK_CHECK

#define SCSI_SENSE_KEY_BLANK_CHECK   0x08

Definition at line 118 of file scsi.h.

◆ SCSI_SENSE_KEY_DATA_PROTECT

#define SCSI_SENSE_KEY_DATA_PROTECT   0x07

Definition at line 117 of file scsi.h.

◆ SCSI_SENSE_KEY_HARDWARE_ERROR

#define SCSI_SENSE_KEY_HARDWARE_ERROR   0x04

Definition at line 114 of file scsi.h.

◆ SCSI_SENSE_KEY_ILLEGAL_REQUEST

#define SCSI_SENSE_KEY_ILLEGAL_REQUEST   0x05

Definition at line 115 of file scsi.h.

◆ SCSI_SENSE_KEY_MEDIUM_ERROR

#define SCSI_SENSE_KEY_MEDIUM_ERROR   0x03

Definition at line 113 of file scsi.h.

◆ SCSI_SENSE_KEY_MISCOMPARE

#define SCSI_SENSE_KEY_MISCOMPARE   0x0E

Definition at line 122 of file scsi.h.

◆ SCSI_SENSE_KEY_NO_SENSE

#define SCSI_SENSE_KEY_NO_SENSE   0x00

Definition at line 110 of file scsi.h.

◆ SCSI_SENSE_KEY_NOT_READY

#define SCSI_SENSE_KEY_NOT_READY   0x02

Definition at line 112 of file scsi.h.

◆ SCSI_SENSE_KEY_RECOVERED_ERROR

#define SCSI_SENSE_KEY_RECOVERED_ERROR   0x01

Definition at line 111 of file scsi.h.

◆ SCSI_SENSE_KEY_UNIT_ATTENTION

#define SCSI_SENSE_KEY_UNIT_ATTENTION   0x06

Definition at line 116 of file scsi.h.

◆ SCSI_SENSE_KEY_VENDOR_SPECIFIC

#define SCSI_SENSE_KEY_VENDOR_SPECIFIC   0x09

Definition at line 119 of file scsi.h.

◆ SCSI_SENSE_KEY_VOLUME_OVERFLOW

#define SCSI_SENSE_KEY_VOLUME_OVERFLOW   0x0D

Definition at line 121 of file scsi.h.

◆ SCSI_START_STOP_UNIT

#define SCSI_START_STOP_UNIT   0x1B

SCSI Start Stop Unit.

Definition at line 54 of file scsi.h.

◆ SCSI_TEST_UNIT_READY

#define SCSI_TEST_UNIT_READY   0x00

SCSI Test Unit Ready.

Definition at line 48 of file scsi.h.

◆ SCSI_VERIFY10

#define SCSI_VERIFY10   0x2F

SCSI Verify10.

Definition at line 64 of file scsi.h.

◆ SCSI_VERSION_NONE

#define SCSI_VERSION_NONE   0x0000

Definition at line 83 of file scsi.h.

◆ SCSI_VERSION_SCSI1

#define SCSI_VERSION_SCSI1   0x0001

Definition at line 84 of file scsi.h.

◆ SCSI_VERSION_SCSI2

#define SCSI_VERSION_SCSI2   0x0002

Definition at line 85 of file scsi.h.

◆ SCSI_WRITE10

#define SCSI_WRITE10   0x2A

SCSI Write10.

Definition at line 60 of file scsi.h.

◆ SCSI_WRITE12

#define SCSI_WRITE12   0xAA

SCSI Write12.

Definition at line 61 of file scsi.h.

◆ SCSI_WRITE_AND_VERIFY

#define SCSI_WRITE_AND_VERIFY   0x2E

SCSI Write and Verify.

Definition at line 63 of file scsi.h.

◆ USBUS_MSC_PRODUCT_ID

#define USBUS_MSC_PRODUCT_ID   "RIOT_MSC_DISK "

Definition at line 34 of file scsi.h.

◆ USBUS_MSC_PRODUCT_REV

#define USBUS_MSC_PRODUCT_REV   " 1.0"

Definition at line 38 of file scsi.h.

◆ USBUS_MSC_VENDOR_ID

#define USBUS_MSC_VENDOR_ID   "RIOT-OS"

Definition at line 30 of file scsi.h.

Function Documentation

◆ scsi_gen_csw()

void scsi_gen_csw ( usbus_handler_t handler,
cbw_info_t cmd 
)

Generate Command Status Wrapper and send it to the host.

Parameters
handlerMSC device struct
cmdstruct containing needed information to generate CBW response

◆ usbus_msc_scsi_process_cmd()

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.

Parameters
usbusUSBUS thread to use
handlerMSC device struct
epEndpoint pointer to read CBW from
lenSize of the received CBW buffer