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