SCSI definitions

This commit is contained in:
ksb 2009-07-11 15:25:43 +00:00
parent 292e69a468
commit 53da57ba60
4 changed files with 375 additions and 0 deletions

View file

@ -0,0 +1,66 @@
#ifndef __RBC_CONST_H__7YXZF39S33__
#define __RBC_CONST_H__7YXZF39S33__
#include <spc2_const.h>
/* SCSI operation codes */
/* Additional commands for RBC */
#define SCSI_CMD_FORMAT_UNIT 0x04
#define SCSI_CMD_READ_10 0x28
#define SCSI_CMD_READ_CAPACITY 0x25
#define SCSI_CMD_START_STOP_UNIT 0x1B
#define SCSI_CMD_SYNCHRONIZE_CACHE 0x35
#define SCSI_CMD_TEST_UNIT_READY 0x00
#define SCSI_CMD_VERIFY_10 0x2F
#define SCSI_CMD_WRITE_10 0x2A
/* Status codes */
/* From SAM-2 */
#define SCSI_STATUS_GOOD 0x00
#define SCSI_STATUS_CHECK_CONDITION 0x02
#define SCSI_STATUS_CONDITION _MET 0x04
#define SCSI_STATUS_BUSY 0x08
#define SCSI_STATUS_INTERMEDIATE 0x10
#define SCSI_STATUS_INTERMEDIATE_CONDITION_MET 0x14
#define SCSI_STATUS_RESERVATION_CONFLICT 0x18
#define SCSI_STATUS_TASK_SET_FULL 0x28
#define SCSI_STATUS_ACA_ACTIVE 0x30
#define SCSI_STATUS_TASK_ABORTED 0x40
/* Sense keys */
#define SCSI_SENSE_KEY_NO_SENSE 0x0
#define SCSI_SENSE_KEY_RECOVERED_ERROR 0x1
#define SCSI_SENSE_KEY_NOT_READY 0x2
#define SCSI_SENSE_KEY_MEDIUM_ERROR 0x3
#define SCSI_SENSE_KEY_HARDWARE_ERROR 0x4
#define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x5
#define SCSI_SENSE_KEY_UNIT_ATTENTION 0x6
#define SCSI_SENSE_KEY_DATA_PROTECT 0x7
#define SCSI_SENSE_KEY_BLANK_CHECK 0x8
#define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x9
#define SCSI_SENSE_KEY_COPY_ABORTED 0xA
#define SCSI_SENSE_KEY_ABORTED_COMMAND 0xB
#define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0xD
#define SCSI_SENSE_KEY_MISCOMPARE 0xE
/* Additional sense codes */
#define SCSI_ASC_NO_SENSE 0x0000
#define SCSI_ASC_INVALID_COMMAND_OPERATION 0x2000
#define SCSI_ASC_INVALID_FIELD_IN_PARAMETER_LIST 0x2600
#define SCSI_ASC_INVALID_FIELD_IN_CDB 0x2400
/* RBC mode page */
#define SCSI_MODE_RBC_DEVICE_PAGE 0x06
#define SCSI_MODE_WCD 0x01
#define SCSI_MODE_READD 0x08
#define SCSI_MODE_WRITED 0x04
#define SCSI_MODE_FORMATD 0x02
#define SCSI_MODE_LOCKD 0x01
/* WRITE(10) command flags */
#define SCSI_WRITE_FUA 0x08
#endif /* __RBC_CONST_H__7YXZF39S33__ */

View file

@ -0,0 +1,58 @@
#ifndef __RBC_STRUCT_H__10L0HKARRV__
#define __RBC_STRUCT_H__10L0HKARRV__
#include <spc2_struct.h>
struct rbc_read_capacity_cmd
{
uint8_t op_code;
uint8_t reserved1;
uint8_t reserved2;
uint8_t reserved3;
uint8_t reserved4;
uint8_t reserved5;
uint8_t reserved6;
uint8_t reserved7;
uint8_t reserved8;
uint8_t control;
} CC_BYTE_ALIGNED;
struct rbc_read_capacity_data
{
uint32_bytes last_logical_block;
uint32_bytes block_length;
} CC_BYTE_ALIGNED;
struct rbc_device_parameters_page
{
struct spc2_mode_page head;
uint8_t flags1;
uint16_bytes logical_block_size;
uint40_bytes num_logical_blocks;
uint8_t power_performance;
uint8_t flags2;
uint8_t reserved;
} CC_BYTE_ALIGNED;
struct rbc_read_cmd
{
uint8_t op_code;
uint8_t reserved1;
uint32_bytes logical_block_address;
uint8_t reserved2;
uint16_bytes transfer_length;
uint8_t control;
} CC_BYTE_ALIGNED;
struct rbc_write_cmd
{
uint8_t op_code;
uint8_t flags;
uint32_bytes logical_block_address;
uint8_t reserved;
uint16_bytes transfer_length;
uint8_t control;
} CC_BYTE_ALIGNED;
#endif /* __RBC_STRUCT_H__10L0HKARRV__ */

View file

@ -0,0 +1,112 @@
/* SCSI operation codes */
/* From SPC-2 */
#define SCSI_CMD_EXTENDED_COPY 0x83
#define SCSI_CMD_INQUIRY 0x12
#define SCSI_CMD_LOG_SELECT 0x4C
#define SCSI_CMD_LOG_SENSE 0x4D
#define SCSI_CMD_MODE_SELECT_6 0x15
#define SCSI_CMD_MODE_SELECT_10 0x55
#define SCSI_CMD_MODE_SENSE_6 0x1A
#define SCSI_CMD_MODE_SENSE_10 0x5A
#define SCSI_CMD_MOVE_MEDIUM_ATTACHED 0xA7
#define SCSI_CMD_PERSISTENT_RESERVE_IN 0x5E
#define SCSI_CMD_PERSISTENT RESERVE OUT 0x5F
#define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E
#define SCSI_CMD_READ_BUFFER 0x3C
#define SCSI_CMD_READ_ELEMENT_STATUS_ATTACHED 0xB4
#define SCSI_CMD_RECEIVE_COPY_RESULTS 0x84
#define SCSI_CMD_RECEIVE_DIAGNOSTIC_RESULTS 0x1C
#define SCSI_CMD_RELEASE_10 0x57
#define SCSI_CMD_RELEASE_6 0x17
#define SCSI_CMD_REPORT_DEVICE_IDENTIFIER 0xA3
#define SCSI_CMD_REPORT_LUNS 0xA0
#define SCSI_CMD_REQUEST_SENSE 0x03
#define SCSI_CMD_RESERVE_10 0x56
#define SCSI_CMD_RESERVE_6 0x16
#define SCSI_CMD_SEND_DIAGNOSTIC 0x1D
#define SCSI_CMD_SET_DEVICE_IDENTIFIER 0xA4
#define SCSI_CMD_TEST_UNIT_READY 0x00
#define SCSI_CMD_WRITE_BUFFER 0x3B
/* Flag field of INQUIRY command */
#define SCSI_INQUIRY_FLAG_CMDDT 0x02
#define SCSI_INQUIRY_FLAG_EVPD 0x01
/* Constant for the standard inquiry data */
#define SCSI_STD_INQUIRY_CONNECTED 0x00
#define SCSI_STD_INQUIRY_NOT_CONNECTED 0x20
#define SCSI_STD_INQUIRY_VERSION_NONE 0x00
#define SCSI_STD_INQUIRY_VERSION_SPC2 0x04
#define SCSI_STD_INQUIRY_TYPE_DIRECT_ACCESS 0x00
#define SCSI_STD_INQUIRY_TYPE_SEQUENTIAL 0x01
#define SCSI_STD_INQUIRY_TYPE_PRINTER 0x02
#define SCSI_STD_INQUIRY_TYPE_PROCESSOR 0x03
#define SCSI_STD_INQUIRY_TYPE_WRITE_ONCE 0x04
#define SCSI_STD_INQUIRY_TYPE_CD_ROM 0x05
#define SCSI_STD_INQUIRY_TYPE_SCANNER 0x06
#define SCSI_STD_INQUIRY_TYPE_OPTICAL 0x07
#define SCSI_STD_INQUIRY_TYPE_CHANGER 0x08
#define SCSI_STD_INQUIRY_TYPE_COMM 0x09
#define SCSI_STD_INQUIRY_TYPE_RAID 0x0C
#define SCSI_STD_INQUIRY_TYPE_RBC 0x0E
#define SCSI_STD_INQUIRY_FLAG1_RMB 0x80
#define SCSI_STD_INQUIRY_FLAG2_AERC 0x80
#define SCSI_STD_INQUIRY_FLAG2_NORMACA 0x20
#define SCSI_STD_INQUIRY_FLAG2_HISUP 0x10
#define SCSI_STD_INQUIRY_FLAG2_RESPONSE_FORMAT 0x02
#define SCSI_STD_INQUIRY_FLAG3_SCCS 0x80
#define SCSI_STD_INQUIRY_FLAG4_BQUE 0x80
#define SCSI_STD_INQUIRY_FLAG4_ENCSERV 0x40
#define SCSI_STD_INQUIRY_FLAG4_VS 0x20
#define SCSI_STD_INQUIRY_FLAG4_MULTIP 0x10
#define SCSI_STD_INQUIRY_FLAG4_MCHNGR 0x08
#define SCSI_STD_INQUIRY_FLAG4_ADDR16 0x01
#define SCSI_STD_INQUIRY_FLAG5_RELADR 0x80
#define SCSI_STD_INQUIRY_FLAG5_WBUS 0x20
#define SCSI_STD_INQUIRY_FLAG5_SYNC 0x10
#define SCSI_STD_INQUIRY_FLAG5_LINKED 0x08
#define SCSI_STD_INQUIRY_FLAG5_CMDQUE 0x02
#define SCSI_SENSE_CURRENT_ERROR 0x70
#define SCSI_SENSE_DEFERRED_ERROR 0x71
#define SCSI_SENSE_INFORMATION_VALID 0x80
#define SCSI_SENSE_FILEMARK 0x80
#define SCSI_SENSE_EOM 0x40
#define SCSI_SENSE_ILI 0x20
#define SCSI_PAGE_DEVICE_IDENTIFICATION 0x83
#define SCSI_PAGE_SUPPORTED_PAGES 0x00
#define SCSI_PAGE_UNIT_SERIAL_NUMBER 0x80
#define SCSI_CODE_SET_BINARY 0x01
#define SCSI_CODE_SET_ACSII 0x02
#define SCSI_ASSOCIATION_DEVICE 0x00
#define SCSI_ASSOCIATION_PORT 0x10
#define SCSI_IDENTIFIER_TYPE_NON_UNIQUE 0x00
#define SCSI_IDENTIFIER_TYPE_VENDORID 0x01
#define SCSI_IDENTIFIER_TYPE_EUI_64 0x02
#define SCSI_IDENTIFIER_TYPE_FC_FS 0x03
#define SCSI_IDENTIFIER_TYPE_PORT 0x04
/* Mode parameters */
#define SCSI_MODE_PAGE_SP 0x80
#define SCSI_MODE_SELECT_PF 0x10
#define SCSI_MODE_SELECT_SP 0x01
#define SCSI_MODE_SENSE_DBD 0x08
#define SCSI_MODE_SENSE_PAGE_CODE_MASK 0x3f
#define SCSI_MODE_SENSE_PC_CURRENT 0x00
#define SCSI_MODE_SENSE_PC_CHANGEABLE 0x40
#define SCSI_MODE_SENSE_PC_DEFAULT 0x80
#define SCSI_MODE_SENSE_PC_SAVED 0xc0
#define SCSI_MODE_SENSE_ALL_PAGES 0x3f

View file

@ -0,0 +1,139 @@
#ifndef __SPC2_STRUCT_H__6R1KTJP0NJ__
#define __SPC2_STRUCT_H__6R1KTJP0NJ__
typedef uint8_t uint40_bytes[5];
typedef uint8_t uint32_bytes[4];
typedef uint8_t uint16_bytes[2];
#ifndef CC_BYTE_ALIGNED
#ifdef __GNUC__
#define CC_BYTE_ALIGNED __attribute__ ((packed))
#endif
#endif
#ifndef CC_BYTE_ALIGNED
#define CC_BYTE_ALIGNED
#endif
#define HOST16_TO_BE_BYTES(x) {(((x) >> 8) & 0xff), ((x) & 0xff)}
#define HOST32_TO_BE_BYTES(x) {(((x) >> 24) & 0xff), (((x) >> 16) & 0xff), \
(((x) >> 8) & 0xff), ((x) & 0xff)}
#define HOST40_TO_BE_BYTES(x) {(((x) >> 32) & 0xff), (((x) >> 24) & 0xff), (((x) >> 16) & 0xff), \
(((x) >> 8) & 0xff), ((x) & 0xff)}
inline unsigned long
be16_to_host(uint16_bytes bytes)
{
return bytes[0] << 8 | bytes[1];
}
inline unsigned long
be32_to_host(uint32_bytes bytes)
{
return (be16_to_host(bytes) << 16) | be16_to_host(bytes + 2);
}
#define BE16_TO_HOST(bytes) ((bytes)[0] << 8 | (bytes)[1])
#define BE32_TO_HOST(bytes) \
((BE16_TO_HOST(bytes) << 16) | BE16_TO_HOST((bytes)+2))
struct spc2_inquiry_cmd
{
uint8_t op_code;
uint8_t flags;
uint8_t page;
uint8_t reserved;
uint8_t allocation_length;
uint8_t control;
} CC_BYTE_ALIGNED;
struct spc2_std_inquiry_data
{
uint8_t device;
uint8_t flags1;
uint8_t version;
uint8_t flags2;
uint8_t additional_length;
uint8_t flags3;
uint8_t flags4;
uint8_t flags5;
char vendor_id[8];
char product_id[16];
char product_rev[4];
} CC_BYTE_ALIGNED;
struct spc2_vital_product_data_head
{
uint8_t device;
uint8_t page;
uint8_t reserved;
uint8_t page_length;
} CC_BYTE_ALIGNED;
struct spc2_identification_descriptor
{
uint8_t code_set;
uint8_t identifier_type;
uint8_t reserved;
uint8_t identifier_length;
};
struct spc2_request_sense_cmd
{
uint8_t op_code;
uint8_t reserved1;
uint8_t reserved2;
uint8_t reserved3;
uint8_t allocation_length;
uint8_t control;
} CC_BYTE_ALIGNED;
struct spc2_sense_data
{
uint8_t response_code;
uint8_t obsolete;
uint8_t sense_key;
uint8_t information[4];
uint8_t additional_length;
uint8_t command_specific[4];
uint8_t asc;
uint8_t ascq;
uint8_t unit_code;
uint8_t sense_key_specific[3];
} CC_BYTE_ALIGNED;
struct spc2_mode_sence_6_cmd
{
uint8_t op_code;
uint8_t flags;
uint8_t page_code;
uint8_t reserved;
uint8_t allocation_length;
uint8_t control;
} CC_BYTE_ALIGNED;
struct spc2_mode_select_6_cmd
{
uint8_t op_code;
uint8_t flags;
uint8_t reserved1;
uint8_t reserved2;
uint8_t parameter_list_length;
uint8_t control;
};
struct spc2_mode_parameter_header_6
{
uint8_t mode_data_length;
uint8_t medium_type;
uint8_t device_specific_parameter;
uint8_t block_descriptor_length;
} CC_BYTE_ALIGNED;
struct spc2_mode_page
{
uint8_t page_code;
uint8_t page_length;
} CC_BYTE_ALIGNED;
#endif /* __SPC2_STRUCT_H__6R1KTJP0NJ__ */