1 | /* $NetBSD: scsipi_all.h,v 1.33 2007/12/25 18:33:42 perry Exp $ */ |
2 | |
3 | /* |
4 | * SCSI and SCSI-like general interface description |
5 | */ |
6 | |
7 | /* |
8 | * Largely written by Julian Elischer (julian@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@tfs.com) Sept 1992 |
22 | */ |
23 | |
24 | #ifndef _DEV_SCSIPI_SCSIPI_ALL_H_ |
25 | #define _DEV_SCSIPI_SCSIPI_ALL_H_ |
26 | |
27 | /* |
28 | * SCSI-like command format and opcode |
29 | */ |
30 | |
31 | /* |
32 | * Some basic, common SCSI command group definitions. |
33 | */ |
34 | |
35 | #define CDB_GROUPID(cmd) ((cmd >> 5) & 0x7) |
36 | #define CDB_GROUPID_0 0 |
37 | #define CDB_GROUPID_1 1 |
38 | #define CDB_GROUPID_2 2 |
39 | #define CDB_GROUPID_3 3 |
40 | #define CDB_GROUPID_4 4 |
41 | #define CDB_GROUPID_5 5 |
42 | #define CDB_GROUPID_6 6 |
43 | #define CDB_GROUPID_7 7 |
44 | |
45 | #define CDB_GROUP0 6 /* 6-byte cdb's */ |
46 | #define CDB_GROUP1 10 /* 10-byte cdb's */ |
47 | #define CDB_GROUP2 10 /* 10-byte cdb's */ |
48 | #define CDB_GROUP3 0 /* reserved */ |
49 | #define CDB_GROUP4 16 /* 16-byte cdb's */ |
50 | #define CDB_GROUP5 12 /* 12-byte cdb's */ |
51 | #define CDB_GROUP6 0 /* vendor specific */ |
52 | #define CDB_GROUP7 0 /* vendor specific */ |
53 | |
54 | /* |
55 | * Some basic, common SCSI commands |
56 | */ |
57 | |
58 | #define INQUIRY 0x12 |
59 | struct scsipi_inquiry { |
60 | u_int8_t opcode; |
61 | u_int8_t byte2; |
62 | u_int8_t unused[2]; |
63 | u_int8_t length; |
64 | u_int8_t control; |
65 | } __packed; |
66 | |
67 | #define START_STOP 0x1b |
68 | struct scsipi_start_stop { |
69 | u_int8_t opcode; |
70 | u_int8_t byte2; |
71 | u_int8_t unused[2]; |
72 | u_int8_t how; |
73 | #define SSS_STOP 0x00 |
74 | #define SSS_START 0x01 |
75 | #define SSS_LOEJ 0x02 |
76 | u_int8_t control; |
77 | }; |
78 | |
79 | /* |
80 | * inquiry data format |
81 | */ |
82 | |
83 | #define T_REMOV 1 /* device is removable */ |
84 | #define T_FIXED 0 /* device is not removable */ |
85 | |
86 | /* |
87 | * According to SPC-2r16, in order to know if a U3W device support PPR, |
88 | * Inquiry Data structure should be at least 57 Bytes |
89 | */ |
90 | |
91 | struct scsipi_inquiry_data { |
92 | /* 1*/ u_int8_t device; |
93 | #define SID_TYPE 0x1f /* device type mask */ |
94 | #define SID_QUAL 0xe0 /* device qualifier mask */ |
95 | #define SID_QUAL_LU_PRESENT 0x00 /* logical unit present */ |
96 | #define SID_QUAL_LU_NOTPRESENT 0x20 /* logical unit not present */ |
97 | #define SID_QUAL_reserved 0x40 |
98 | #define SID_QUAL_LU_NOT_SUPP 0x60 /* logical unit not supported */ |
99 | |
100 | #define T_DIRECT 0x00 /* direct access device */ |
101 | #define T_SEQUENTIAL 0x01 /* sequential access device */ |
102 | #define T_PRINTER 0x02 /* printer device */ |
103 | #define T_PROCESSOR 0x03 /* processor device */ |
104 | #define T_WORM 0x04 /* write once, read many device */ |
105 | #define T_CDROM 0x05 /* cd-rom device */ |
106 | #define T_SCANNER 0x06 /* scanner device */ |
107 | #define T_OPTICAL 0x07 /* optical memory device */ |
108 | #define T_CHANGER 0x08 /* medium changer device */ |
109 | #define T_COMM 0x09 /* communication device */ |
110 | #define T_IT8_1 0x0a /* Defined by ASC IT8... */ |
111 | #define T_IT8_2 0x0b /* ...(Graphic arts pre-press devices) */ |
112 | #define T_STORARRAY 0x0c /* storage array device */ |
113 | #define T_ENCLOSURE 0x0d /* enclosure services device */ |
114 | #define T_SIMPLE_DIRECT 0x0E /* Simplified direct-access device */ |
115 | #define T_OPTIC_CARD_RW 0x0F /* Optical card reader/writer device */ |
116 | #define T_OBJECT_STORED 0x11 /* Object-based Storage Device */ |
117 | #define T_NODEVICE 0x1f |
118 | |
119 | u_int8_t dev_qual2; |
120 | #define SID_QUAL2 0x7F |
121 | #define SID_REMOVABLE 0x80 |
122 | |
123 | /* 3*/ u_int8_t version; |
124 | #define SID_ANSII 0x07 |
125 | #define SID_ECMA 0x38 |
126 | #define SID_ISO 0xC0 |
127 | |
128 | /* 4*/ u_int8_t response_format; |
129 | #define SID_RespDataFmt 0x0F |
130 | #define SID_FORMAT_SCSI1 0x00 /* SCSI-1 format */ |
131 | #define SID_FORMAT_CCS 0x01 /* SCSI CCS format */ |
132 | #define SID_FORMAT_ISO 0x02 /* ISO format */ |
133 | |
134 | /* 5*/ u_int8_t additional_length; /* n-4 */ |
135 | /* 6*/ u_int8_t flags1; |
136 | #define SID_SCC 0x80 |
137 | /* 7*/ u_int8_t flags2; |
138 | #define SID_Addr16 0x01 |
139 | #define SID_MChngr 0x08 |
140 | #define SID_MultiPort 0x10 |
141 | #define SID_EncServ 0x40 |
142 | #define SID_BasQue 0x80 |
143 | /* 8*/ u_int8_t flags3; |
144 | #define SID_SftRe 0x01 |
145 | #define SID_CmdQue 0x02 |
146 | #define SID_Linked 0x08 |
147 | #define SID_Sync 0x10 |
148 | #define SID_WBus16 0x20 |
149 | #define SID_WBus32 0x40 |
150 | #define SID_RelAdr 0x80 |
151 | /* 9*/ char vendor[8]; |
152 | /*17*/ char product[16]; |
153 | /*33*/ char revision[4]; |
154 | #define SCSIPI_INQUIRY_LENGTH_SCSI2 36 |
155 | /*37*/ u_int8_t vendor_specific[20]; |
156 | /*57*/ u_int8_t flags4; |
157 | #define SID_IUS 0x01 |
158 | #define SID_QAS 0x02 |
159 | #define SID_Clocking 0x0C |
160 | #define SID_CLOCKING_ST_ONLY 0x00 |
161 | #define SID_CLOCKING_DT_ONLY 0x04 |
162 | #define SID_CLOCKING_SD_DT 0x0C |
163 | /*58*/ u_int8_t reserved; |
164 | /*59*/ char version_descriptor[8][2]; |
165 | #define SCSIPI_INQUIRY_LENGTH_SCSI3 74 |
166 | } __packed; /* 74 Bytes */ |
167 | |
168 | #endif /* _DEV_SCSIPI_SCSIPI_ALL_H_ */ |
169 | |