Home | History | Annotate | Line # | Download | only in scsipi
scsipi_all.h revision 1.2.2.2
      1 /*	$NetBSD: scsipi_all.h,v 1.2.2.2 1997/08/27 23:33:22 thorpej Exp $	*/
      2 
      3 /*
      4  * SCSI and SCSI-like general interface 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_PI_ALL_H
     25 #define _SCSI_PI_ALL_H 1
     26 
     27 /*
     28  * SCSI-like command format and opcode
     29  */
     30 
     31 #define	TEST_UNIT_READY		0x00
     32 struct scsipi_test_unit_ready {
     33 	u_int8_t opcode;
     34 	u_int8_t byte2;
     35 	u_int8_t unused[3];
     36 	u_int8_t control;
     37 };
     38 
     39 #define REQUEST_SENSE       0x03
     40 struct scsipi_sense {
     41 	u_int8_t opcode;
     42 	u_int8_t byte2;
     43 	u_int8_t unused[2];
     44 	u_int8_t length;
     45 	u_int8_t control;
     46 };
     47 
     48 #define INQUIRY			0x12
     49 struct scsipi_inquiry {
     50 	u_int8_t opcode;
     51 	u_int8_t byte2;
     52 	u_int8_t unused[2];
     53 	u_int8_t length;
     54 	u_int8_t control;
     55 };
     56 
     57 #define PREVENT_ALLOW		0x1e
     58 struct scsipi_prevent {
     59 	u_int8_t opcode;
     60 	u_int8_t byte2;
     61 	u_int8_t unused[2];
     62 	u_int8_t how;
     63 	u_int8_t control;
     64 };
     65 #define	PR_PREVENT 0x01
     66 #define PR_ALLOW   0x00
     67 
     68 /*
     69  * inquiry and sense data format
     70  */
     71 
     72 struct scsipi_sense_data {
     73 /* 1*/  u_int8_t error_code;
     74 #define SSD_ERRCODE     0x7F
     75 #define SSD_ERRCODE_VALID   0x80
     76 /* 2*/  u_int8_t segment;
     77 /* 3*/  u_int8_t flags;
     78 #define SSD_KEY     0x0F
     79 #define SSD_ILI     0x20
     80 #define SSD_EOM     0x40
     81 #define SSD_FILEMARK    0x80
     82 /* 7*/  u_int8_t info[4];
     83 /* 8*/  u_int8_t extra_len;
     84 /*12*/  u_int8_t cmd_spec_info[4];
     85 /*13*/  u_int8_t add_sense_code;
     86 /*14*/  u_int8_t add_sense_code_qual;
     87 /*15*/  u_int8_t fru;
     88 /*16*/  u_int8_t sense_key_spec_1;
     89 #define SSD_SCS_VALID   0x80
     90 /*17*/  u_int8_t sense_key_spec_2;
     91 /*18*/  u_int8_t sense_key_spec_3;
     92 /*32*/  u_int8_t extra_bytes[14];
     93 };
     94 
     95 struct scsipi_sense_data_unextended {
     96 /* 1*/  u_int8_t error_code;
     97 /* 4*/  u_int8_t block[3];
     98 };
     99 
    100 #define T_DIRECT	0
    101 #define T_SEQUENTIAL	1
    102 #define T_PRINTER	2
    103 #define T_PROCESSOR	3
    104 #define T_WORM		4
    105 #define T_CDROM		5
    106 #define T_SCANNER 	6
    107 #define T_OPTICAL 	7
    108 #define T_NODEVICE	0x1F
    109 
    110 #define T_CHANGER	8
    111 #define T_COMM		9
    112 
    113 #define T_REMOV		1
    114 #define	T_FIXED		0
    115 
    116 /*
    117  * XXX
    118  * Actually I think some SCSI driver expects this structure to be 32 bytes, so
    119  * don't change it unless you really know what you are doing
    120  */
    121 
    122 struct scsipi_inquiry_data {
    123 	u_int8_t device;
    124 #define	SID_TYPE	0x1F
    125 #define	SID_QUAL	0xE0
    126 #define	SID_QUAL_LU_OK	0x00
    127 #define	SID_QUAL_LU_OFFLINE	0x20
    128 #define	SID_QUAL_RSVD	0x40
    129 #define	SID_QUAL_BAD_LU	0x60
    130 	u_int8_t dev_qual2;
    131 #define	SID_QUAL2	0x7F
    132 #define	SID_REMOVABLE	0x80
    133 	u_int8_t version;
    134 #define SID_ANSII	0x07
    135 #define SID_ECMA	0x38
    136 #define SID_ISO		0xC0
    137 	u_int8_t response_format;
    138 	u_int8_t additional_length;
    139 	u_int8_t unused[2];
    140 	u_int8_t flags;
    141 #define	SID_SftRe	0x01
    142 #define	SID_CmdQue	0x02
    143 #define	SID_Linked	0x08
    144 #define	SID_Sync	0x10
    145 #define	SID_WBus16	0x20
    146 #define	SID_WBus32	0x40
    147 #define	SID_RelAdr	0x80
    148 	char	vendor[8];
    149 	char	product[16];
    150 	char	revision[4];
    151 	u_int8_t extra[8];
    152 };
    153 
    154 #endif /* _SCSI_PI_ALL_H */
    155