Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.12
      1  1.12    enami /*	$NetBSD: scsi_all.h,v 1.12 1997/10/01 01:18:54 enami Exp $	*/
      2   1.5      cgd 
      3   1.1      cgd /*
      4  1.11   bouyer  * SCSI-specific insterface 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.12    enami  * 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.12    enami #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.12    enami #define	SCSI_CTL_LINK		0x01
     35  1.12    enami #define	SCSI_CTL_FLAG		0x02
     36  1.12    enami #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.11   bouyer /*
     47  1.11   bouyer  * XXX
     48  1.11   bouyer  * Actually some SCSI driver expects this structure to be 12 bytes, so
     49  1.11   bouyer  * don't change it unless you really know what you are doing
     50  1.11   bouyer  */
     51   1.1      cgd 
     52   1.6  mycroft struct scsi_generic {
     53   1.6  mycroft 	u_int8_t opcode;
     54   1.6  mycroft 	u_int8_t bytes[11];
     55   1.6  mycroft };
     56   1.6  mycroft 
     57  1.11   bouyer /* XXX Is this a command ? What's its opcode ? */
     58   1.6  mycroft struct scsi_send_diag {
     59   1.6  mycroft 	u_int8_t opcode;
     60   1.6  mycroft 	u_int8_t byte2;
     61   1.3  mycroft #define	SSD_UOL		0x01
     62   1.3  mycroft #define	SSD_DOL		0x02
     63   1.3  mycroft #define	SSD_SELFTEST	0x04
     64   1.3  mycroft #define	SSD_PF		0x10
     65   1.6  mycroft 	u_int8_t unused[1];
     66   1.6  mycroft 	u_int8_t paramlen[2];
     67   1.6  mycroft 	u_int8_t control;
     68   1.6  mycroft };
     69   1.6  mycroft 
     70  1.12    enami #define	SCSI_MODE_SENSE		0x1a
     71   1.6  mycroft struct scsi_mode_sense {
     72   1.6  mycroft 	u_int8_t opcode;
     73   1.6  mycroft 	u_int8_t byte2;
     74   1.3  mycroft #define	SMS_DBD				0x08
     75   1.6  mycroft 	u_int8_t page;
     76   1.3  mycroft #define	SMS_PAGE_CODE 			0x3F
     77   1.3  mycroft #define	SMS_PAGE_CTRL 			0xC0
     78   1.3  mycroft #define	SMS_PAGE_CTRL_CURRENT 		0x00
     79   1.3  mycroft #define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
     80   1.3  mycroft #define	SMS_PAGE_CTRL_DEFAULT 		0x80
     81   1.3  mycroft #define	SMS_PAGE_CTRL_SAVED 		0xC0
     82   1.6  mycroft 	u_int8_t unused;
     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.11   bouyer #define	SCSI_MODE_SENSE_BIG		0x54
     88   1.6  mycroft struct scsi_mode_sense_big {
     89   1.6  mycroft 	u_int8_t opcode;
     90   1.6  mycroft 	u_int8_t byte2;		/* same bits as small version */
     91   1.6  mycroft 	u_int8_t page; 		/* same bits as small version */
     92   1.6  mycroft 	u_int8_t unused[4];
     93   1.6  mycroft 	u_int8_t length[2];
     94   1.6  mycroft 	u_int8_t control;
     95   1.6  mycroft };
     96   1.6  mycroft 
     97  1.12    enami #define	SCSI_MODE_SELECT		0x15
     98   1.6  mycroft struct scsi_mode_select {
     99   1.6  mycroft 	u_int8_t opcode;
    100   1.6  mycroft 	u_int8_t byte2;
    101   1.3  mycroft #define	SMS_SP	0x01
    102   1.3  mycroft #define	SMS_PF	0x10
    103   1.6  mycroft 	u_int8_t unused[2];
    104   1.6  mycroft 	u_int8_t length;
    105   1.6  mycroft 	u_int8_t control;
    106   1.6  mycroft };
    107   1.6  mycroft 
    108  1.11   bouyer #define	SCSI_MODE_SELECT_BIG		0x55
    109   1.6  mycroft struct scsi_mode_select_big {
    110   1.6  mycroft 	u_int8_t opcode;
    111   1.6  mycroft 	u_int8_t byte2;		/* same bits as small version */
    112   1.6  mycroft 	u_int8_t unused[5];
    113   1.6  mycroft 	u_int8_t length[2];
    114   1.6  mycroft 	u_int8_t control;
    115   1.6  mycroft };
    116   1.6  mycroft 
    117  1.12    enami #define	SCSI_RESERVE      		0x16
    118   1.6  mycroft struct scsi_reserve {
    119   1.6  mycroft 	u_int8_t opcode;
    120   1.6  mycroft 	u_int8_t byte2;
    121   1.6  mycroft 	u_int8_t unused[2];
    122   1.6  mycroft 	u_int8_t length;
    123   1.6  mycroft 	u_int8_t control;
    124   1.6  mycroft };
    125   1.6  mycroft 
    126  1.12    enami #define	SCSI_RELEASE      		0x17
    127   1.6  mycroft struct scsi_release {
    128   1.6  mycroft 	u_int8_t opcode;
    129   1.6  mycroft 	u_int8_t byte2;
    130   1.6  mycroft 	u_int8_t unused[2];
    131   1.6  mycroft 	u_int8_t length;
    132   1.6  mycroft 	u_int8_t control;
    133   1.6  mycroft };
    134   1.6  mycroft 
    135  1.11   bouyer #define	SCSI_CHANGE_DEFINITION	0x40
    136   1.6  mycroft struct scsi_changedef {
    137   1.6  mycroft 	u_int8_t opcode;
    138   1.6  mycroft 	u_int8_t byte2;
    139   1.6  mycroft 	u_int8_t unused1;
    140   1.6  mycroft 	u_int8_t how;
    141   1.6  mycroft 	u_int8_t unused[4];
    142   1.6  mycroft 	u_int8_t datalen;
    143   1.6  mycroft 	u_int8_t control;
    144   1.3  mycroft };
    145  1.12    enami #define	SC_SCSI_1 0x01
    146  1.12    enami #define	SC_SCSI_2 0x03
    147   1.1      cgd 
    148   1.6  mycroft struct scsi_blk_desc {
    149   1.6  mycroft 	u_int8_t density;
    150   1.6  mycroft 	u_int8_t nblocks[3];
    151   1.6  mycroft 	u_int8_t reserved;
    152   1.6  mycroft 	u_int8_t blklen[3];
    153   1.6  mycroft };
    154   1.6  mycroft 
    155   1.6  mycroft struct scsi_mode_header {
    156   1.6  mycroft 	u_int8_t data_length;	/* Sense data length */
    157   1.6  mycroft 	u_int8_t medium_type;
    158   1.6  mycroft 	u_int8_t dev_spec;
    159   1.6  mycroft 	u_int8_t blk_desc_len;
    160   1.6  mycroft };
    161   1.6  mycroft 
    162   1.6  mycroft struct scsi_mode_header_big {
    163   1.6  mycroft 	u_int8_t data_length[2];	/* Sense data length */
    164   1.6  mycroft 	u_int8_t medium_type;
    165   1.6  mycroft 	u_int8_t dev_spec;
    166   1.6  mycroft 	u_int8_t unused[2];
    167   1.6  mycroft 	u_int8_t blk_desc_len[2];
    168   1.1      cgd };
    169   1.1      cgd 
    170   1.1      cgd 
    171   1.1      cgd /*
    172   1.1      cgd  * Status Byte
    173   1.1      cgd  */
    174   1.1      cgd #define	SCSI_OK		0x00
    175   1.6  mycroft #define	SCSI_CHECK	0x02
    176  1.12    enami #define	SCSI_BUSY	0x08
    177  1.12    enami #define	SCSI_INTERM	0x10
    178  1.12    enami #define	SCSI_QUEUE_FULL	0x28
    179   1.6  mycroft 
    180   1.6  mycroft #endif /* _SCSI_SCSI_ALL_H */
    181