Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.12
      1 /*	$NetBSD: scsi_all.h,v 1.12 1997/10/01 01:18:54 enami Exp $	*/
      2 
      3 /*
      4  * SCSI-specific insterface description.
      5  */
      6 
      7 /*
      8  * Largely written by Julian Elischer (julian (at) tfs.com)
      9  * for TRW Financial Systems.
     10  *
     11  * TRW Financial Systems, in accordance with their agreement with Carnegie
     12  * Mellon University, makes this software available to CMU to distribute
     13  * or use in any manner that they see fit as long as this message is kept with
     14  * the software. For this reason TFS also grants any other persons or
     15  * organisations permission to use or modify this software.
     16  *
     17  * TFS supplies this software to be publicly redistributed
     18  * on the understanding that TFS is not responsible for the correct
     19  * functioning of this software in any circumstances.
     20  *
     21  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     22  */
     23 
     24 #ifndef	_SCSI_SCSI_ALL_H
     25 #define	_SCSI_SCSI_ALL_H 1
     26 
     27 /*
     28  * SCSI command format
     29  */
     30 
     31 /*
     32  * Define dome bits that are in ALL (or a lot of) scsi commands
     33  */
     34 #define	SCSI_CTL_LINK		0x01
     35 #define	SCSI_CTL_FLAG		0x02
     36 #define	SCSI_CTL_VENDOR		0xC0
     37 
     38 
     39 /*
     40  * Some old SCSI devices need the LUN to be set in the top 3 bits of the
     41  * second byte of the CDB.
     42  */
     43 #define	SCSI_CMD_LUN_MASK	0xe0
     44 #define	SCSI_CMD_LUN_SHIFT	5
     45 
     46 /*
     47  * XXX
     48  * Actually some SCSI driver expects this structure to be 12 bytes, so
     49  * don't change it unless you really know what you are doing
     50  */
     51 
     52 struct scsi_generic {
     53 	u_int8_t opcode;
     54 	u_int8_t bytes[11];
     55 };
     56 
     57 /* XXX Is this a command ? What's its opcode ? */
     58 struct scsi_send_diag {
     59 	u_int8_t opcode;
     60 	u_int8_t byte2;
     61 #define	SSD_UOL		0x01
     62 #define	SSD_DOL		0x02
     63 #define	SSD_SELFTEST	0x04
     64 #define	SSD_PF		0x10
     65 	u_int8_t unused[1];
     66 	u_int8_t paramlen[2];
     67 	u_int8_t control;
     68 };
     69 
     70 #define	SCSI_MODE_SENSE		0x1a
     71 struct scsi_mode_sense {
     72 	u_int8_t opcode;
     73 	u_int8_t byte2;
     74 #define	SMS_DBD				0x08
     75 	u_int8_t page;
     76 #define	SMS_PAGE_CODE 			0x3F
     77 #define	SMS_PAGE_CTRL 			0xC0
     78 #define	SMS_PAGE_CTRL_CURRENT 		0x00
     79 #define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
     80 #define	SMS_PAGE_CTRL_DEFAULT 		0x80
     81 #define	SMS_PAGE_CTRL_SAVED 		0xC0
     82 	u_int8_t unused;
     83 	u_int8_t length;
     84 	u_int8_t control;
     85 };
     86 
     87 #define	SCSI_MODE_SENSE_BIG		0x54
     88 struct scsi_mode_sense_big {
     89 	u_int8_t opcode;
     90 	u_int8_t byte2;		/* same bits as small version */
     91 	u_int8_t page; 		/* same bits as small version */
     92 	u_int8_t unused[4];
     93 	u_int8_t length[2];
     94 	u_int8_t control;
     95 };
     96 
     97 #define	SCSI_MODE_SELECT		0x15
     98 struct scsi_mode_select {
     99 	u_int8_t opcode;
    100 	u_int8_t byte2;
    101 #define	SMS_SP	0x01
    102 #define	SMS_PF	0x10
    103 	u_int8_t unused[2];
    104 	u_int8_t length;
    105 	u_int8_t control;
    106 };
    107 
    108 #define	SCSI_MODE_SELECT_BIG		0x55
    109 struct scsi_mode_select_big {
    110 	u_int8_t opcode;
    111 	u_int8_t byte2;		/* same bits as small version */
    112 	u_int8_t unused[5];
    113 	u_int8_t length[2];
    114 	u_int8_t control;
    115 };
    116 
    117 #define	SCSI_RESERVE      		0x16
    118 struct scsi_reserve {
    119 	u_int8_t opcode;
    120 	u_int8_t byte2;
    121 	u_int8_t unused[2];
    122 	u_int8_t length;
    123 	u_int8_t control;
    124 };
    125 
    126 #define	SCSI_RELEASE      		0x17
    127 struct scsi_release {
    128 	u_int8_t opcode;
    129 	u_int8_t byte2;
    130 	u_int8_t unused[2];
    131 	u_int8_t length;
    132 	u_int8_t control;
    133 };
    134 
    135 #define	SCSI_CHANGE_DEFINITION	0x40
    136 struct scsi_changedef {
    137 	u_int8_t opcode;
    138 	u_int8_t byte2;
    139 	u_int8_t unused1;
    140 	u_int8_t how;
    141 	u_int8_t unused[4];
    142 	u_int8_t datalen;
    143 	u_int8_t control;
    144 };
    145 #define	SC_SCSI_1 0x01
    146 #define	SC_SCSI_2 0x03
    147 
    148 struct scsi_blk_desc {
    149 	u_int8_t density;
    150 	u_int8_t nblocks[3];
    151 	u_int8_t reserved;
    152 	u_int8_t blklen[3];
    153 };
    154 
    155 struct scsi_mode_header {
    156 	u_int8_t data_length;	/* Sense data length */
    157 	u_int8_t medium_type;
    158 	u_int8_t dev_spec;
    159 	u_int8_t blk_desc_len;
    160 };
    161 
    162 struct scsi_mode_header_big {
    163 	u_int8_t data_length[2];	/* Sense data length */
    164 	u_int8_t medium_type;
    165 	u_int8_t dev_spec;
    166 	u_int8_t unused[2];
    167 	u_int8_t blk_desc_len[2];
    168 };
    169 
    170 
    171 /*
    172  * Status Byte
    173  */
    174 #define	SCSI_OK		0x00
    175 #define	SCSI_CHECK	0x02
    176 #define	SCSI_BUSY	0x08
    177 #define	SCSI_INTERM	0x10
    178 #define	SCSI_QUEUE_FULL	0x28
    179 
    180 #endif /* _SCSI_SCSI_ALL_H */
    181