Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.10
      1  1.10   thorpej /*	$NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $	*/
      2   1.5       cgd 
      3   1.1       cgd /*
      4   1.2       cgd  * SCSI general  interface description
      5   1.3   mycroft  */
      6   1.3   mycroft 
      7   1.3   mycroft /*
      8   1.1       cgd  * Largely written by Julian Elischer (julian (at) tfs.com)
      9   1.1       cgd  * for TRW Financial Systems.
     10   1.1       cgd  *
     11   1.1       cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
     12   1.1       cgd  * Mellon University, makes this software available to CMU to distribute
     13   1.1       cgd  * or use in any manner that they see fit as long as this message is kept with
     14   1.1       cgd  * the software. For this reason TFS also grants any other persons or
     15   1.1       cgd  * organisations permission to use or modify this software.
     16   1.1       cgd  *
     17   1.1       cgd  * TFS supplies this software to be publicly redistributed
     18   1.1       cgd  * on the understanding that TFS is not responsible for the correct
     19   1.1       cgd  * functioning of this software in any circumstances.
     20   1.1       cgd  *
     21   1.3   mycroft  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     22   1.1       cgd  */
     23   1.1       cgd 
     24   1.3   mycroft #ifndef	_SCSI_SCSI_ALL_H
     25   1.3   mycroft #define _SCSI_SCSI_ALL_H 1
     26   1.6   mycroft 
     27   1.1       cgd /*
     28   1.3   mycroft  * SCSI command format
     29   1.1       cgd  */
     30   1.1       cgd 
     31   1.1       cgd /*
     32   1.3   mycroft  * Define dome bits that are in ALL (or a lot of) scsi commands
     33   1.1       cgd  */
     34   1.3   mycroft #define SCSI_CTL_LINK		0x01
     35   1.3   mycroft #define SCSI_CTL_FLAG		0x02
     36   1.3   mycroft #define SCSI_CTL_VENDOR		0xC0
     37   1.9   thorpej 
     38   1.9   thorpej 
     39   1.9   thorpej /*
     40   1.9   thorpej  * Some old SCSI devices need the LUN to be set in the top 3 bits of the
     41   1.9   thorpej  * second byte of the CDB.
     42   1.9   thorpej  */
     43   1.9   thorpej #define	SCSI_CMD_LUN_MASK	0xe0
     44   1.9   thorpej #define	SCSI_CMD_LUN_SHIFT	5
     45   1.1       cgd 
     46   1.1       cgd 
     47   1.6   mycroft struct scsi_generic {
     48   1.6   mycroft 	u_int8_t opcode;
     49   1.6   mycroft 	u_int8_t bytes[11];
     50   1.6   mycroft };
     51   1.6   mycroft 
     52   1.6   mycroft struct scsi_test_unit_ready {
     53   1.6   mycroft 	u_int8_t opcode;
     54   1.6   mycroft 	u_int8_t byte2;
     55   1.6   mycroft 	u_int8_t unused[3];
     56   1.6   mycroft 	u_int8_t control;
     57   1.6   mycroft };
     58   1.6   mycroft 
     59   1.6   mycroft struct scsi_send_diag {
     60   1.6   mycroft 	u_int8_t opcode;
     61   1.6   mycroft 	u_int8_t byte2;
     62   1.3   mycroft #define	SSD_UOL		0x01
     63   1.3   mycroft #define	SSD_DOL		0x02
     64   1.3   mycroft #define	SSD_SELFTEST	0x04
     65   1.3   mycroft #define	SSD_PF		0x10
     66   1.6   mycroft 	u_int8_t unused[1];
     67   1.6   mycroft 	u_int8_t paramlen[2];
     68   1.6   mycroft 	u_int8_t control;
     69   1.6   mycroft };
     70   1.6   mycroft 
     71   1.6   mycroft struct scsi_sense {
     72   1.6   mycroft 	u_int8_t opcode;
     73   1.6   mycroft 	u_int8_t byte2;
     74   1.6   mycroft 	u_int8_t unused[2];
     75   1.6   mycroft 	u_int8_t length;
     76   1.6   mycroft 	u_int8_t control;
     77   1.6   mycroft };
     78   1.6   mycroft 
     79   1.6   mycroft struct scsi_inquiry {
     80   1.6   mycroft 	u_int8_t opcode;
     81   1.6   mycroft 	u_int8_t byte2;
     82   1.6   mycroft 	u_int8_t unused[2];
     83   1.6   mycroft 	u_int8_t length;
     84   1.6   mycroft 	u_int8_t control;
     85   1.6   mycroft };
     86   1.6   mycroft 
     87   1.6   mycroft struct scsi_mode_sense {
     88   1.6   mycroft 	u_int8_t opcode;
     89   1.6   mycroft 	u_int8_t byte2;
     90   1.3   mycroft #define	SMS_DBD				0x08
     91   1.6   mycroft 	u_int8_t page;
     92   1.3   mycroft #define	SMS_PAGE_CODE 			0x3F
     93   1.3   mycroft #define	SMS_PAGE_CTRL 			0xC0
     94   1.3   mycroft #define	SMS_PAGE_CTRL_CURRENT 		0x00
     95   1.3   mycroft #define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
     96   1.3   mycroft #define	SMS_PAGE_CTRL_DEFAULT 		0x80
     97   1.3   mycroft #define	SMS_PAGE_CTRL_SAVED 		0xC0
     98   1.6   mycroft 	u_int8_t unused;
     99   1.6   mycroft 	u_int8_t length;
    100   1.6   mycroft 	u_int8_t control;
    101   1.6   mycroft };
    102   1.6   mycroft 
    103   1.6   mycroft struct scsi_mode_sense_big {
    104   1.6   mycroft 	u_int8_t opcode;
    105   1.6   mycroft 	u_int8_t byte2;		/* same bits as small version */
    106   1.6   mycroft 	u_int8_t page; 		/* same bits as small version */
    107   1.6   mycroft 	u_int8_t unused[4];
    108   1.6   mycroft 	u_int8_t length[2];
    109   1.6   mycroft 	u_int8_t control;
    110   1.6   mycroft };
    111   1.6   mycroft 
    112   1.6   mycroft struct scsi_mode_select {
    113   1.6   mycroft 	u_int8_t opcode;
    114   1.6   mycroft 	u_int8_t byte2;
    115   1.3   mycroft #define	SMS_SP	0x01
    116   1.3   mycroft #define	SMS_PF	0x10
    117   1.6   mycroft 	u_int8_t unused[2];
    118   1.6   mycroft 	u_int8_t length;
    119   1.6   mycroft 	u_int8_t control;
    120   1.6   mycroft };
    121   1.6   mycroft 
    122   1.6   mycroft struct scsi_mode_select_big {
    123   1.6   mycroft 	u_int8_t opcode;
    124   1.6   mycroft 	u_int8_t byte2;		/* same bits as small version */
    125   1.6   mycroft 	u_int8_t unused[5];
    126   1.6   mycroft 	u_int8_t length[2];
    127   1.6   mycroft 	u_int8_t control;
    128   1.6   mycroft };
    129   1.6   mycroft 
    130   1.6   mycroft struct scsi_reserve {
    131   1.6   mycroft 	u_int8_t opcode;
    132   1.6   mycroft 	u_int8_t byte2;
    133   1.6   mycroft 	u_int8_t unused[2];
    134   1.6   mycroft 	u_int8_t length;
    135   1.6   mycroft 	u_int8_t control;
    136   1.6   mycroft };
    137   1.6   mycroft 
    138   1.6   mycroft struct scsi_release {
    139   1.6   mycroft 	u_int8_t opcode;
    140   1.6   mycroft 	u_int8_t byte2;
    141   1.6   mycroft 	u_int8_t unused[2];
    142   1.6   mycroft 	u_int8_t length;
    143   1.6   mycroft 	u_int8_t control;
    144   1.6   mycroft };
    145   1.6   mycroft 
    146   1.6   mycroft struct scsi_prevent {
    147   1.6   mycroft 	u_int8_t opcode;
    148   1.6   mycroft 	u_int8_t byte2;
    149   1.6   mycroft 	u_int8_t unused[2];
    150   1.6   mycroft 	u_int8_t how;
    151   1.6   mycroft 	u_int8_t control;
    152   1.1       cgd };
    153   1.3   mycroft #define	PR_PREVENT 0x01
    154   1.3   mycroft #define PR_ALLOW   0x00
    155   1.3   mycroft 
    156   1.6   mycroft struct scsi_changedef {
    157   1.6   mycroft 	u_int8_t opcode;
    158   1.6   mycroft 	u_int8_t byte2;
    159   1.6   mycroft 	u_int8_t unused1;
    160   1.6   mycroft 	u_int8_t how;
    161   1.6   mycroft 	u_int8_t unused[4];
    162   1.6   mycroft 	u_int8_t datalen;
    163   1.6   mycroft 	u_int8_t control;
    164   1.3   mycroft };
    165   1.3   mycroft #define SC_SCSI_1 0x01
    166   1.3   mycroft #define SC_SCSI_2 0x03
    167   1.1       cgd 
    168   1.1       cgd /*
    169   1.1       cgd  * Opcodes
    170   1.1       cgd  */
    171   1.1       cgd #define	TEST_UNIT_READY		0x00
    172   1.1       cgd #define REQUEST_SENSE		0x03
    173   1.1       cgd #define INQUIRY			0x12
    174   1.1       cgd #define MODE_SELECT		0x15
    175   1.1       cgd #define MODE_SENSE		0x1a
    176   1.1       cgd #define START_STOP		0x1b
    177   1.1       cgd #define RESERVE      		0x16
    178   1.1       cgd #define RELEASE      		0x17
    179   1.1       cgd #define PREVENT_ALLOW		0x1e
    180   1.1       cgd #define POSITION_TO_ELEMENT	0x2b
    181   1.3   mycroft #define	CHANGE_DEFINITION	0x40
    182   1.1       cgd #define	MODE_SENSE_BIG		0x54
    183   1.1       cgd #define	MODE_SELECT_BIG		0x55
    184   1.1       cgd 
    185   1.1       cgd /*
    186   1.1       cgd  * sense data format
    187   1.1       cgd  */
    188   1.1       cgd #define T_DIRECT	0
    189   1.1       cgd #define T_SEQUENTIAL	1
    190   1.1       cgd #define T_PRINTER	2
    191   1.1       cgd #define T_PROCESSOR	3
    192   1.1       cgd #define T_WORM		4
    193   1.6   mycroft #define T_CDROM		5
    194   1.1       cgd #define T_SCANNER 	6
    195   1.1       cgd #define T_OPTICAL 	7
    196   1.1       cgd #define T_NODEVICE	0x1F
    197   1.1       cgd 
    198   1.1       cgd #define T_CHANGER	8
    199   1.1       cgd #define T_COMM		9
    200   1.1       cgd 
    201   1.1       cgd #define T_REMOV		1
    202   1.1       cgd #define	T_FIXED		0
    203   1.1       cgd 
    204   1.6   mycroft struct scsi_inquiry_data {
    205   1.6   mycroft 	u_int8_t device;
    206   1.3   mycroft #define	SID_TYPE	0x1F
    207   1.3   mycroft #define	SID_QUAL	0xE0
    208   1.3   mycroft #define	SID_QUAL_LU_OK	0x00
    209   1.3   mycroft #define	SID_QUAL_LU_OFFLINE	0x20
    210   1.3   mycroft #define	SID_QUAL_RSVD	0x40
    211   1.3   mycroft #define	SID_QUAL_BAD_LU	0x60
    212   1.6   mycroft 	u_int8_t dev_qual2;
    213   1.3   mycroft #define	SID_QUAL2	0x7F
    214   1.3   mycroft #define	SID_REMOVABLE	0x80
    215   1.6   mycroft 	u_int8_t version;
    216   1.3   mycroft #define SID_ANSII	0x07
    217   1.3   mycroft #define SID_ECMA	0x38
    218   1.3   mycroft #define SID_ISO		0xC0
    219   1.6   mycroft 	u_int8_t response_format;
    220   1.6   mycroft 	u_int8_t additional_length;
    221   1.6   mycroft 	u_int8_t unused[2];
    222   1.6   mycroft 	u_int8_t flags;
    223   1.3   mycroft #define	SID_SftRe	0x01
    224   1.3   mycroft #define	SID_CmdQue	0x02
    225   1.3   mycroft #define	SID_Linked	0x08
    226   1.3   mycroft #define	SID_Sync	0x10
    227   1.3   mycroft #define	SID_WBus16	0x20
    228   1.3   mycroft #define	SID_WBus32	0x40
    229   1.3   mycroft #define	SID_RelAdr	0x80
    230   1.1       cgd 	char	vendor[8];
    231   1.1       cgd 	char	product[16];
    232   1.1       cgd 	char	revision[4];
    233   1.6   mycroft 	u_int8_t extra[8];
    234   1.1       cgd };
    235   1.1       cgd 
    236   1.7   mycroft struct scsi_sense_data_unextended {
    237   1.7   mycroft /* 1*/	u_int8_t error_code;
    238   1.7   mycroft /* 4*/	u_int8_t block[3];
    239   1.7   mycroft };
    240   1.4    chopps 
    241   1.7   mycroft struct scsi_sense_data {
    242   1.6   mycroft /* 1*/	u_int8_t error_code;
    243   1.3   mycroft #define	SSD_ERRCODE		0x7F
    244   1.3   mycroft #define	SSD_ERRCODE_VALID	0x80
    245   1.7   mycroft /* 2*/	u_int8_t segment;
    246   1.7   mycroft /* 3*/	u_int8_t flags;
    247   1.3   mycroft #define	SSD_KEY		0x0F
    248   1.3   mycroft #define	SSD_ILI		0x20
    249   1.3   mycroft #define	SSD_EOM		0x40
    250   1.3   mycroft #define	SSD_FILEMARK	0x80
    251   1.7   mycroft /* 7*/	u_int8_t info[4];
    252   1.7   mycroft /* 8*/	u_int8_t extra_len;
    253   1.7   mycroft /*12*/	u_int8_t cmd_spec_info[4];
    254   1.7   mycroft /*13*/	u_int8_t add_sense_code;
    255   1.7   mycroft /*14*/	u_int8_t add_sense_code_qual;
    256   1.7   mycroft /*15*/	u_int8_t fru;
    257   1.7   mycroft /*16*/	u_int8_t sense_key_spec_1;
    258   1.7   mycroft #define	SSD_SCS_VALID	0x80
    259   1.7   mycroft /*17*/	u_int8_t sense_key_spec_2;
    260   1.7   mycroft /*18*/	u_int8_t sense_key_spec_3;
    261   1.7   mycroft /*32*/	u_int8_t extra_bytes[14];
    262   1.7   mycroft };
    263   1.1       cgd 
    264   1.6   mycroft struct scsi_blk_desc {
    265   1.6   mycroft 	u_int8_t density;
    266   1.6   mycroft 	u_int8_t nblocks[3];
    267   1.6   mycroft 	u_int8_t reserved;
    268   1.6   mycroft 	u_int8_t blklen[3];
    269   1.6   mycroft };
    270   1.6   mycroft 
    271   1.6   mycroft struct scsi_mode_header {
    272   1.6   mycroft 	u_int8_t data_length;	/* Sense data length */
    273   1.6   mycroft 	u_int8_t medium_type;
    274   1.6   mycroft 	u_int8_t dev_spec;
    275   1.6   mycroft 	u_int8_t blk_desc_len;
    276   1.6   mycroft };
    277   1.6   mycroft 
    278   1.6   mycroft struct scsi_mode_header_big {
    279   1.6   mycroft 	u_int8_t data_length[2];	/* Sense data length */
    280   1.6   mycroft 	u_int8_t medium_type;
    281   1.6   mycroft 	u_int8_t dev_spec;
    282   1.6   mycroft 	u_int8_t unused[2];
    283   1.6   mycroft 	u_int8_t blk_desc_len[2];
    284   1.1       cgd };
    285   1.1       cgd 
    286   1.1       cgd 
    287   1.1       cgd /*
    288   1.1       cgd  * Status Byte
    289   1.1       cgd  */
    290   1.1       cgd #define	SCSI_OK		0x00
    291   1.6   mycroft #define	SCSI_CHECK	0x02
    292   1.6   mycroft #define	SCSI_BUSY	0x08
    293   1.6   mycroft #define SCSI_INTERM	0x10
    294   1.8  explorer #define SCSI_QUEUE_FULL		0x28
    295   1.6   mycroft 
    296   1.6   mycroft #endif /* _SCSI_SCSI_ALL_H */
    297