Microchip® Advanced Software Framework

spc_protocol.h File Reference

SCSI Primary Commands.

This file contains definitions of some of the commands found in the SPC-2 standard.

Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.

Data Structures

struct  scsi_inquiry_data
 SCSI Standard Inquiry data structure. More...
 
struct  scsi_mode_page_0_header
 SCSI Page_0 Mode Page header (SPF not set) More...
 
struct  scsi_mode_param_header10
 SCSI Mode Parameter Header used by MODE SELECT(10) and MODE SENSE(10) More...
 
struct  scsi_mode_param_header6
 SCSI Mode Parameter Header used by MODE SELECT(6) and MODE SENSE(6) More...
 
struct  scsi_request_sense_data
 SCSI Standard Request sense data structure. More...
 
struct  spc_control_page_info_execpt
 SPC-2 Informational exceptions control page See chapter 8.3.8. More...
 

Macros

#define SCSI_INQ_ADDL_LEN(tot)   ((tot)-5)
 Total length is tot. More...
 
#define SCSI_INQ_ADDR16   0x01
 
#define SCSI_INQ_BQUE   0x80
 
#define SCSI_INQ_CMDQUE   0x02
 
#define SCSI_INQ_DT_ARRAY   0x0c
 Storage Array Controller. More...
 
#define SCSI_INQ_DT_BCC   0x10
 Bridge Controller Commands. More...
 
#define SCSI_INQ_DT_CD_DVD   0x05
 CD/DVD device. More...
 
#define SCSI_INQ_DT_DIR_ACCESS   0x00
 Direct Access (SBC) More...
 
#define SCSI_INQ_DT_ENCLOSURE   0x0d
 Enclosure Services. More...
 
#define SCSI_INQ_DT_MC   0x08
 Medium Changer. More...
 
#define SCSI_INQ_DT_NONE   0x1f
 No Peripheral. More...
 
#define SCSI_INQ_DT_OCRW   0x0f
 Optical card reader/writer. More...
 
#define SCSI_INQ_DT_OPTICAL   0x07
 Optical Memory. More...
 
#define SCSI_INQ_DT_OSD   0x11
 Object-based Storage. More...
 
#define SCSI_INQ_DT_PRINTER   0x02
 Printer. More...
 
#define SCSI_INQ_DT_PROCESSOR   0x03
 Processor device. More...
 
#define SCSI_INQ_DT_RBC   0x0e
 Simplified Direct Access. More...
 
#define SCSI_INQ_DT_SEQ_ACCESS   0x01
 Sequential Access. More...
 
#define SCSI_INQ_DT_WRITE_ONCE   0x04
 Write-once device. More...
 
#define SCSI_INQ_ENCSERV   0x40
 
#define SCSI_INQ_HISUP   0x10
 Hierarchal LUN addressing. More...
 
#define SCSI_INQ_LINKED   0x08
 
#define SCSI_INQ_MCHGR   0x08
 
#define SCSI_INQ_MULTIP   0x10
 
#define SCSI_INQ_NORMACA   0x20
 Normal ACA Supported. More...
 
#define SCSI_INQ_PQ_CONNECTED   0x00
 Peripheral connected. More...
 
#define SCSI_INQ_PQ_NOT_CONN   0x20
 Peripheral not connected. More...
 
#define SCSI_INQ_PQ_NOT_SUPP   0x60
 Peripheral not supported. More...
 
#define SCSI_INQ_RMB   0x80
 Removable Medium. More...
 
#define SCSI_INQ_RSP_SPC2   0x02
 SPC-2 / SPC-3 response format. More...
 
#define SCSI_INQ_SCCS   0x80
 
#define SCSI_INQ_SYNC   0x10
 
#define SCSI_INQ_VER_NONE   0x00
 No standards conformance. More...
 
#define SCSI_INQ_VER_SPC   0x03
 SCSI Primary Commands (link to SBC) More...
 
#define SCSI_INQ_VER_SPC2   0x04
 SCSI Primary Commands - 2 (link to SBC-2) More...
 
#define SCSI_INQ_VER_SPC3   0x05
 SCSI Primary Commands - 3 (link to SBC-2) More...
 
#define SCSI_INQ_VER_SPC4   0x06
 SCSI Primary Commands - 4 (link to SBC-3) More...
 
#define SCSI_INQ_WBUS16   0x20
 
#define SCSI_MS_PAGE_LEN(total)   ((total) - 2)
 
#define SCSI_PAGE_CODE_PS   (1 << 7)
 Parameters Saveable. More...
 
#define SCSI_PAGE_CODE_SPF   (1 << 6)
 SubPage Format. More...
 
#define SCSI_SENSE_ADDL_LEN(total_len)   ((total_len) - 8)
 
#define SCSI_SENSE_CURRENT   0x70
 Response code 70h (current errors) More...
 
#define SCSI_SENSE_DEFERRED   0x71
 
#define SCSI_SENSE_EOM   0x40
 Indicates that an end-of-medium condition exists. More...
 
#define SCSI_SENSE_FILEMARK   0x80
 Indicates that the current command has read a filemark or setmark. More...
 
#define SCSI_SENSE_ILI   0x20
 Indicates that the requested logical block length did not match the logical block length of the data on the medium. More...
 
#define SCSI_SENSE_KEY(x)   (x&0x0F)
 Sense Key. More...
 
#define SCSI_SENSE_RESERVED   0x10
 Reserved. More...
 
#define SCSI_SENSE_RESPONSE_CODE_MASK   0x7F
 
#define SCSI_SENSE_SKSV   0x80
 Indicates the SENSE-KEY SPECIFIC field contains valid information. More...
 
#define SCSI_SENSE_VALID   0x80
 Indicates the INFORMATION field contains valid information. More...
 
#define SCSI_VPD_CODE_SET_ASCII   2
 
#define SCSI_VPD_CODE_SET_BINARY   1
 
#define SCSI_VPD_CODE_SET_UTF8   3
 
#define SCSI_VPD_HEADER_SIZE   4
 
#define SCSI_VPD_ID_HEADER_SIZE   4
 
#define SCSI_VPD_ID_TYPE_T10   1
 
#define SPC_MP_INFEXP_DEXCPT   (1<<3)
 Size enable. More...
 
#define SPC_MP_INFEXP_EBF   (1<<5)
 Caching Analysis Permitted. More...
 
#define SPC_MP_INFEXP_EWASC   (1<<4)
 Discontinuity. More...
 
#define SPC_MP_INFEXP_LOGERR   (1<<0)
 Log errors bit. More...
 
#define SPC_MP_INFEXP_MRIE_ASYNC_EVENT   0x01
 
#define SPC_MP_INFEXP_MRIE_COND_RECOV_ERROR   0x03
 
#define SPC_MP_INFEXP_MRIE_GEN_UNIT   0x02
 
#define SPC_MP_INFEXP_MRIE_NO_REPORT   0x00
 
#define SPC_MP_INFEXP_MRIE_NO_SENSE   0x05
 
#define SPC_MP_INFEXP_MRIE_ONLY_REPORT   0x06
 
#define SPC_MP_INFEXP_MRIE_UNCOND_RECOV_ERROR   0x04
 
#define SPC_MP_INFEXP_PAGE_LENGTH   0x0A
 
#define SPC_MP_INFEXP_PERF   (1<<7)
 Initiator Control. More...
 
#define SPC_MP_INFEXP_TEST   (1<<2)
 Writeback Cache Enable. More...
 
SCSI commands defined by SPC-2
#define SPC_TEST_UNIT_READY   0x00
 
#define SPC_REQUEST_SENSE   0x03
 
#define SPC_INQUIRY   0x12
 
#define SPC_MODE_SELECT6   0x15
 
#define SPC_MODE_SENSE6   0x1A
 
#define SPC_SEND_DIAGNOSTIC   0x1D
 
#define SPC_PREVENT_ALLOW_MEDIUM_REMOVAL   0x1E
 
#define SPC_MODE_SENSE10   0x5A
 
#define SPC_REPORT_LUNS   0xA0
 
#define SCSI_INQ_REQ_EVPD   0x01
 May be set in byte 0 of the INQUIRY CDB. More...
 
#define SCSI_INQ_REQ_CMDT   0x02
 Command Support Data specified by the PAGE OR OPERATION CODE field. More...
 

Enumerations

enum  scsi_asc_ascq {
  SCSI_ASC_NO_ADDITIONAL_SENSE_INFO = 0x0000,
  SCSI_ASC_LU_NOT_READY_REBUILD_IN_PROGRESS = 0x0405,
  SCSI_ASC_WRITE_ERROR = 0x0c00,
  SCSI_ASC_UNRECOVERED_READ_ERROR = 0x1100,
  SCSI_ASC_INVALID_COMMAND_OPERATION_CODE = 0x2000,
  SCSI_ASC_INVALID_FIELD_IN_CDB = 0x2400,
  SCSI_ASC_WRITE_PROTECTED = 0x2700,
  SCSI_ASC_NOT_READY_TO_READY_CHANGE = 0x2800,
  SCSI_ASC_MEDIUM_NOT_PRESENT = 0x3A00,
  SCSI_ASC_INTERNAL_TARGET_FAILURE = 0x4400
}
 
enum  scsi_sense_key {
  SCSI_SK_NO_SENSE = 0x0,
  SCSI_SK_RECOVERED_ERROR = 0x1,
  SCSI_SK_NOT_READY = 0x2,
  SCSI_SK_MEDIUM_ERROR = 0x3,
  SCSI_SK_HARDWARE_ERROR = 0x4,
  SCSI_SK_ILLEGAL_REQUEST = 0x5,
  SCSI_SK_UNIT_ATTENTION = 0x6,
  SCSI_SK_DATA_PROTECT = 0x7,
  SCSI_SK_BLANK_CHECK = 0x8,
  SCSI_SK_VENDOR_SPECIFIC = 0x9,
  SCSI_SK_COPY_ABORTED = 0xa,
  SCSI_SK_ABORTED_COMMAND = 0xb,
  SCSI_SK_VOLUME_OVERFLOW = 0xd,
  SCSI_SK_MISCOMPARE = 0xe
}
 
enum  scsi_spc_mode {
  SCSI_MS_MODE_VENDOR_SPEC = 0x00,
  SCSI_MS_MODE_INFEXP = 0x1C,
  SCSI_MS_MODE_ALL = 0x3f
}
 SPC-2 Mode parameter This subclause describes the block descriptors and the pages used with MODE SELECT and MODE SENSE commands that are applicable to all SCSI devices. More...
 
enum  scsi_spc_mode_sense_pc {
  SCSI_MS_SENSE_PC_CURRENT = 0,
  SCSI_MS_SENSE_PC_CHANGEABLE = 1,
  SCSI_MS_SENSE_PC_DEFAULT = 2,
  SCSI_MS_SENSE_PC_SAVED = 3
}
 
enum  scsi_vpd_page_code {
  SCSI_VPD_SUPPORTED_PAGES = 0x00,
  SCSI_VPD_UNIT_SERIAL_NUMBER = 0x80,
  SCSI_VPD_DEVICE_IDENTIFICATION = 0x83
}
 

Functions

static bool scsi_mode_sense_dbd_is_set (const uint8_t *cdb)
 
static uint8_t scsi_mode_sense_get_page_code (const uint8_t *cdb)
 
static uint8_t scsi_mode_sense_get_pc (const uint8_t *cdb)
 

#define SCSI_INQ_ADDL_LEN (   tot)    ((tot)-5)

Total length is tot.

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_ADDR16   0x01
#define SCSI_INQ_BQUE   0x80
#define SCSI_INQ_CMDQUE   0x02
#define SCSI_INQ_DT_ARRAY   0x0c

Storage Array Controller.

#define SCSI_INQ_DT_BCC   0x10

Bridge Controller Commands.

#define SCSI_INQ_DT_CD_DVD   0x05

CD/DVD device.

#define SCSI_INQ_DT_DIR_ACCESS   0x00

Direct Access (SBC)

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_DT_ENCLOSURE   0x0d

Enclosure Services.

#define SCSI_INQ_DT_MC   0x08

Medium Changer.

#define SCSI_INQ_DT_NONE   0x1f

No Peripheral.

#define SCSI_INQ_DT_OCRW   0x0f

Optical card reader/writer.

#define SCSI_INQ_DT_OPTICAL   0x07

Optical Memory.

#define SCSI_INQ_DT_OSD   0x11

Object-based Storage.

#define SCSI_INQ_DT_PRINTER   0x02

Printer.

#define SCSI_INQ_DT_PROCESSOR   0x03

Processor device.

#define SCSI_INQ_DT_RBC   0x0e

Simplified Direct Access.

#define SCSI_INQ_DT_SEQ_ACCESS   0x01

Sequential Access.

#define SCSI_INQ_DT_WRITE_ONCE   0x04

Write-once device.

#define SCSI_INQ_ENCSERV   0x40
#define SCSI_INQ_HISUP   0x10

Hierarchal LUN addressing.

#define SCSI_INQ_LINKED   0x08
#define SCSI_INQ_MCHGR   0x08
#define SCSI_INQ_MULTIP   0x10
#define SCSI_INQ_NORMACA   0x20

Normal ACA Supported.

#define SCSI_INQ_PQ_CONNECTED   0x00

Peripheral connected.

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_PQ_NOT_CONN   0x20

Peripheral not connected.

#define SCSI_INQ_PQ_NOT_SUPP   0x60

Peripheral not supported.

#define SCSI_INQ_RMB   0x80

Removable Medium.

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_RSP_SPC2   0x02

SPC-2 / SPC-3 response format.

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_SCCS   0x80
#define SCSI_INQ_SYNC   0x10
#define SCSI_INQ_VER_NONE   0x00

No standards conformance.

#define SCSI_INQ_VER_SPC   0x03

SCSI Primary Commands (link to SBC)

Referenced by udi_msc_spc_inquiry().

#define SCSI_INQ_VER_SPC2   0x04

SCSI Primary Commands - 2 (link to SBC-2)

#define SCSI_INQ_VER_SPC3   0x05

SCSI Primary Commands - 3 (link to SBC-2)

#define SCSI_INQ_VER_SPC4   0x06

SCSI Primary Commands - 4 (link to SBC-3)

#define SCSI_INQ_WBUS16   0x20
#define SCSI_MS_PAGE_LEN (   total)    ((total) - 2)
#define SCSI_PAGE_CODE_PS   (1 << 7)

Parameters Saveable.

#define SCSI_PAGE_CODE_SPF   (1 << 6)

SubPage Format.

#define SCSI_SENSE_ADDL_LEN (   total_len)    ((total_len) - 8)

Referenced by udi_msc_clear_sense().

#define SCSI_SENSE_CURRENT   0x70

Response code 70h (current errors)

Referenced by udi_msc_clear_sense().

#define SCSI_SENSE_DEFERRED   0x71
#define SCSI_SENSE_EOM   0x40

Indicates that an end-of-medium condition exists.

#define SCSI_SENSE_FILEMARK   0x80

Indicates that the current command has read a filemark or setmark.

#define SCSI_SENSE_ILI   0x20

Indicates that the requested logical block length did not match the logical block length of the data on the medium.

#define SCSI_SENSE_KEY (   x)    (x&0x0F)

Sense Key.

#define SCSI_SENSE_RESERVED   0x10

Reserved.

#define SCSI_SENSE_RESPONSE_CODE_MASK   0x7F
#define SCSI_SENSE_SKSV   0x80

Indicates the SENSE-KEY SPECIFIC field contains valid information.

#define SCSI_SENSE_VALID   0x80

Indicates the INFORMATION field contains valid information.

Referenced by udi_msc_clear_sense().

#define SPC_MP_INFEXP_DEXCPT   (1<<3)

Size enable.

#define SPC_MP_INFEXP_EBF   (1<<5)

Caching Analysis Permitted.

#define SPC_MP_INFEXP_EWASC   (1<<4)

Discontinuity.

#define SPC_MP_INFEXP_LOGERR   (1<<0)

Log errors bit.

#define SPC_MP_INFEXP_MRIE_ASYNC_EVENT   0x01
#define SPC_MP_INFEXP_MRIE_COND_RECOV_ERROR   0x03
#define SPC_MP_INFEXP_MRIE_GEN_UNIT   0x02
#define SPC_MP_INFEXP_MRIE_NO_REPORT   0x00
#define SPC_MP_INFEXP_MRIE_NO_SENSE   0x05

Referenced by udi_msc_spc_mode_sense().

#define SPC_MP_INFEXP_MRIE_ONLY_REPORT   0x06
#define SPC_MP_INFEXP_MRIE_UNCOND_RECOV_ERROR   0x04
#define SPC_MP_INFEXP_PAGE_LENGTH   0x0A

Referenced by udi_msc_spc_mode_sense().

#define SPC_MP_INFEXP_PERF   (1<<7)

Initiator Control.

#define SPC_MP_INFEXP_TEST   (1<<2)

Writeback Cache Enable.