scsi_all.h
来自「基于组件方式开发操作系统的OSKIT源代码」· C头文件 代码 · 共 921 行 · 第 1/2 页
H
921 行
/* * Largely written by Julian Elischer (julian@tfs.com) * for TRW Financial Systems. * * TRW Financial Systems, in accordance with their agreement with Carnegie * Mellon University, makes this software available to CMU to distribute * or use in any manner that they see fit as long as this message is kept with * the software. For this reason TFS also grants any other persons or * organisations permission to use or modify this software. * * TFS supplies this software to be publicly redistributed * on the understanding that TFS is not responsible for the correct * functioning of this software in any circumstances. * * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * * $Id: scsi_all.h,v 1.6.2.1 1999/05/09 01:27:31 ken Exp $ *//* * SCSI general interface description */#ifndef _SCSI_SCSI_ALL_H#define _SCSI_SCSI_ALL_H 1#include <sys/cdefs.h>/* * SCSI command format *//* * Define dome bits that are in ALL (or a lot of) scsi commands */#define SCSI_CTL_LINK 0x01#define SCSI_CTL_FLAG 0x02#define SCSI_CTL_VENDOR 0xC0#define SCSI_CMD_LUN 0xA0 /* these two should not be needed */#define SCSI_CMD_LUN_SHIFT 5 /* LUN in the cmd is no longer SCSI */#define SCSI_MAX_CDBLEN 16 /* * 16 byte commands are in the * SCSI-3 spec */#if defined(CAM_MAX_CDBLEN) && (CAM_MAX_CDBLEN < SCSI_MAX_CDBLEN)#error "CAM_MAX_CDBLEN cannot be less than SCSI_MAX_CDBLEN"#endif/* * This type defines actions to be taken when a particular sense code is * received. Right now, these flags are only defined to take up 16 bits, * but can be expanded in the future if necessary. */typedef enum { SS_NOP = 0x000000, /* Do nothing */ SS_RETRY = 0x010000, /* Retry the command */ SS_FAIL = 0x020000, /* Bail out */ SS_START = 0x030000, /* Send a Start Unit command to the device, * then retry the original command. */ SS_TUR = 0x040000, /* Send a Test Unit Ready command to the * device, then retry the original command. */ SS_MANUAL = 0x050000, /* * This error must be handled manually, * i.e. the code must look at the asc and * ascq values and determine the proper * course of action. */ SS_TURSTART = 0x060000, /* * Send a Test Unit Ready command to the * device, and if that fails, send a start * unit. */ SS_MASK = 0xff0000} scsi_sense_action;typedef enum { SSQ_NONE = 0x0000, SSQ_DECREMENT_COUNT = 0x0100, /* Decrement the retry count */ SSQ_MANY = 0x0200, /* send lots of recovery commands */ SSQ_RANGE = 0x0400, /* * Yes, this is a hack. Basically, * if this flag is set then it * represents an ascq range. The * "correct" way to implement the * ranges might be to add a special * field to the sense code table, * but that would take up a lot of * additional space. This solution * isn't as elegant, but is more * space efficient. */ SSQ_PRINT_SENSE = 0x0800, SSQ_MASK = 0xff00} scsi_sense_action_qualifier;/* Mask for error status values */#define SS_ERRMASK 0xff/* The default error action */#define SS_DEF SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE|EIO/* Default error action, without an error return value */#define SS_NEDEF SS_RETRY|SSQ_DECREMENT_COUNT|SSQ_PRINT_SENSE/* Default error action, without sense printing or an error return value */#define SS_NEPDEF SS_RETRY|SSQ_DECREMENT_COUNTstruct scsi_generic{ u_int8_t opcode; u_int8_t bytes[11];};struct scsi_request_sense{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[2]; u_int8_t length; u_int8_t control;};struct scsi_test_unit_ready{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[3]; u_int8_t control;};struct scsi_send_diag{ u_int8_t opcode; u_int8_t byte2;#define SSD_UOL 0x01#define SSD_DOL 0x02#define SSD_SELFTEST 0x04#define SSD_PF 0x10 u_int8_t unused[1]; u_int8_t paramlen[2]; u_int8_t control;};struct scsi_sense{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[2]; u_int8_t length; u_int8_t control;};struct scsi_inquiry{ u_int8_t opcode; u_int8_t byte2;#define SI_EVPD 0x01 u_int8_t page_code; u_int8_t reserved; u_int8_t length; u_int8_t control;};struct scsi_mode_sense_6{ u_int8_t opcode; u_int8_t byte2;#define SMS_DBD 0x08 u_int8_t page;#define SMS_PAGE_CODE 0x3F#define SMS_VENDOR_SPECIFIC_PAGE 0x00#define SMS_DISCONNECT_RECONNECT_PAGE 0x02#define SMS_PERIPHERAL_DEVICE_PAGE 0x09#define SMS_CONTROL_MODE_PAGE 0x0A#define SMS_ALL_PAGES_PAGE 0x3F#define SMS_PAGE_CTRL_MASK 0xC0#define SMS_PAGE_CTRL_CURRENT 0x00#define SMS_PAGE_CTRL_CHANGEABLE 0x40#define SMS_PAGE_CTRL_DEFAULT 0x80#define SMS_PAGE_CTRL_SAVED 0xC0 u_int8_t unused; u_int8_t length; u_int8_t control;};struct scsi_mode_sense_10{ u_int8_t opcode; u_int8_t byte2; /* same bits as small version */ u_int8_t page; /* same bits as small version */ u_int8_t unused[4]; u_int8_t length[2]; u_int8_t control;};struct scsi_mode_select_6{ u_int8_t opcode; u_int8_t byte2;#define SMS_SP 0x01#define SMS_PF 0x10 u_int8_t unused[2]; u_int8_t length; u_int8_t control;};struct scsi_mode_select_10{ u_int8_t opcode; u_int8_t byte2; /* same bits as small version */ u_int8_t unused[5]; u_int8_t length[2]; u_int8_t control;};/* * When sending a mode select to a tape drive, the medium type must be 0. */struct scsi_mode_hdr_6{ u_int8_t datalen; u_int8_t medium_type; u_int8_t dev_specific; u_int8_t block_descr_len;};struct scsi_mode_hdr_10{ u_int8_t datalen[2]; u_int8_t medium_type; u_int8_t dev_specific; u_int8_t reserved[2]; u_int8_t block_descr_len[2];};struct scsi_mode_block_descr{ u_int8_t density_code; u_int8_t num_blocks[3]; u_int8_t reserved; u_int8_t block_len[3];};struct scsi_control_page { u_int8_t page_code; u_int8_t page_length; u_int8_t rlec;#define SCB_RLEC 0x01 /*Report Log Exception Cond*/ u_int8_t queue_flags;#define SCP_QUEUE_ALG_MASK 0xF0#define SCP_QUEUE_ALG_RESTRICTED 0x00#define SCP_QUEUE_ALG_UNRESTRICTED 0x10#define SCP_QUEUE_ERR 0x02 /*Queued I/O aborted for CACs*/#define SCP_QUEUE_DQUE 0x01 /*Queued I/O disabled*/ u_int8_t eca_and_aen;#define SCP_EECA 0x80 /*Enable Extended CA*/#define SCP_RAENP 0x04 /*Ready AEN Permission*/#define SCP_UAAENP 0x02 /*UA AEN Permission*/#define SCP_EAENP 0x01 /*Error AEN Permission*/ u_int8_t reserved; u_int8_t aen_holdoff_period[2];};struct scsi_reserve{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[2]; u_int8_t length; u_int8_t control;};struct scsi_release{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[2]; u_int8_t length; u_int8_t control;};struct scsi_prevent{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused[2]; u_int8_t how; u_int8_t control;};#define PR_PREVENT 0x01#define PR_ALLOW 0x00struct scsi_sync_cache{ u_int8_t opcode; u_int8_t byte2; u_int8_t begin_lba[4]; u_int8_t reserved; u_int8_t lb_count[2]; u_int8_t control; };struct scsi_changedef{ u_int8_t opcode; u_int8_t byte2; u_int8_t unused1; u_int8_t how; u_int8_t unused[4]; u_int8_t datalen; u_int8_t control;};struct scsi_read_buffer{ u_int8_t opcode; u_int8_t byte2;#define RWB_MODE 0x07#define RWB_MODE_HDR_DATA 0x00#define RWB_MODE_DATA 0x02#define RWB_MODE_DOWNLOAD 0x04#define RWB_MODE_DOWNLOAD_SAVE 0x05 u_int8_t buffer_id; u_int8_t offset[3]; u_int8_t length[3]; u_int8_t control;};struct scsi_write_buffer{ u_int8_t opcode; u_int8_t byte2; u_int8_t buffer_id; u_int8_t offset[3]; u_int8_t length[3]; u_int8_t control;};struct scsi_rw_6{ u_int8_t opcode; u_int8_t addr[3];/* only 5 bits are valid in the MSB address byte */#define SRW_TOPADDR 0x1F u_int8_t length; u_int8_t control;};struct scsi_rw_10{ u_int8_t opcode;#define SRW10_RELADDR 0x01#define SRW10_FUA 0x08#define SRW10_DPO 0x10 u_int8_t byte2; u_int8_t addr[4]; u_int8_t reserved; u_int8_t length[2]; u_int8_t control;};struct scsi_rw_12{ u_int8_t opcode;#define SRW12_RELADDR 0x01#define SRW12_FUA 0x08#define SRW12_DPO 0x10 u_int8_t byte2; u_int8_t addr[4]; u_int8_t reserved; u_int8_t length[4]; u_int8_t control;};struct scsi_start_stop_unit{ u_int8_t opcode; u_int8_t byte2;#define SSS_IMMED 0x01 u_int8_t reserved[2]; u_int8_t how;#define SSS_START 0x01#define SSS_LOEJ 0x02 u_int8_t control;};#define SC_SCSI_1 0x01#define SC_SCSI_2 0x03/* * Opcodes */#define TEST_UNIT_READY 0x00#define REQUEST_SENSE 0x03#define READ_6 0x08#define WRITE_6 0x0a#define INQUIRY 0x12#define MODE_SELECT_6 0x15#define MODE_SENSE_6 0x1a#define START_STOP_UNIT 0x1b#define START_STOP 0x1b#define RESERVE 0x16#define RELEASE 0x17#define PREVENT_ALLOW 0x1e#define READ_CAPACITY 0x25#define READ_10 0x28#define WRITE_10 0x2a#define POSITION_TO_ELEMENT 0x2b#define SYNCHRONIZE_CACHE 0x35#define WRITE_BUFFER 0x3b#define READ_BUFFER 0x3c#define CHANGE_DEFINITION 0x40#define MODE_SELECT_10 0x55#define MODE_SENSE_10 0x5A#define MOVE_MEDIUM 0xa5#define READ_12 0xa8#define WRITE_12 0xaa#define READ_ELEMENT_STATUS 0xb8/* * Device Types */#define T_DIRECT 0x00#define T_SEQUENTIAL 0x01#define T_PRINTER 0x02#define T_PROCESSOR 0x03#define T_WORM 0x04#define T_CDROM 0x05#define T_SCANNER 0x06#define T_OPTICAL 0x07#define T_CHANGER 0x08#define T_COMM 0x09#define T_ASC0 0x0a#define T_ASC1 0x0b#define T_STORARRAY 0x0c#define T_ENCLOSURE 0x0d#define T_NODEVICE 0x1F#define T_ANY 0xFF /* Used in Quirk table matches */#define T_REMOV 1#define T_FIXED 0struct scsi_inquiry_data{ u_int8_t device;#define SID_TYPE(inq_data) ((inq_data)->device & 0x1f)#define SID_QUAL(inq_data) (((inq_data)->device & 0xE0) >> 5)#define SID_QUAL_LU_CONNECTED 0x00 /* The specified peripheral device * type is currently connected to * logical unit. If the target cannot * determine whether or not a physical * device is currently connected, it * shall also use this peripheral * qualifier when returning the INQUIRY * data. This peripheral qualifier
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?