xref: /illumos-gate/usr/src/uts/common/sys/scsi/generic/commands.h (revision 26cf27f05670b1ca90e4a07802cba858cb358690)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_SCSI_GENERIC_COMMANDS_H
28 #define	_SYS_SCSI_GENERIC_COMMANDS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Standard SCSI Command Definitions
38  *
39  * Macros to determine known command sizes
40  */
41 #define	CDB_GROUPID(cmd)	((cmd >> 5) & 0x7)
42 #define	CDB_GROUPID_0	0
43 #define	CDB_GROUPID_1	1
44 #define	CDB_GROUPID_2	2
45 #define	CDB_GROUPID_3	3
46 #define	CDB_GROUPID_4	4
47 #define	CDB_GROUPID_5	5
48 #define	CDB_GROUPID_6	6
49 #define	CDB_GROUPID_7	7
50 
51 #define	CDB_GROUP0	6	/*  6-byte cdb's */
52 #define	CDB_GROUP1	10	/* 10-byte cdb's */
53 #define	CDB_GROUP2	10	/* 10-byte cdb's */
54 #define	CDB_GROUP3	0	/* reserved */
55 #define	CDB_GROUP4	16	/* 16-byte cdb's */
56 #define	CDB_GROUP5	12	/* 12-byte cdb's */
57 #define	CDB_GROUP6	0	/* reserved */
58 #define	CDB_GROUP7	0	/* reserved */
59 
60 /*
61  * Generic Command Definitions
62  * NOTE: CDROM commands are defined in cdio.h
63  */
64 
65 /*
66  * Group 0 Commands (CDB range 0x00 - 0x1F)
67  */
68 #define	SCMD_GROUP0		0x00
69 
70 /*
71  * Group 0 commands, All Devices
72  */
73 #define	SCMD_TEST_UNIT_READY	0x00
74 #define	SCMD_REQUEST_SENSE	0x03
75 #define	SCMD_INQUIRY		0x12
76 #define	SCMD_COPY		0x18
77 #define	SCMD_GDIAG		0x1C	/* receive diagnostic results */
78 #define	SCMD_SDIAG		0x1D	/* send diagnostic results */
79 
80 /*
81  * Group 0 commands, Direct Access Devices
82  */
83 /*	SCMD_TEST_UNIT_READY	0x00	*/
84 #define	SCMD_REZERO_UNIT	0x01
85 /*	SCMD_REQUEST_SENSE	0x03	*/
86 #define	SCMD_FORMAT		0x04
87 #define	SCMD_REASSIGN_BLOCK	0x07
88 #define	SCMD_READ		0x08
89 #define	SCMD_WRITE		0x0a
90 #define	SCMD_SEEK		0x0b
91 /*	SCMD_INQUIRY		0x12	*/
92 #define	SCMD_MODE_SELECT	0x15
93 #define	SCMD_RESERVE		0x16
94 #define	SCMD_RELEASE		0x17
95 /*	SCMD_COPY		0x18	*/
96 #define	SCMD_MODE_SENSE		0x1a
97 #define	SCMD_START_STOP		0x1b
98 /*	SCMD_GDIAG		0x1C	*/
99 /*	SCMD_SDIAG		0x1D	*/
100 #define	SCMD_DOORLOCK		0x1E	/* Prevent/Allow Medium Removal */
101 
102 /*
103  * Group 0 commands, Sequential Access Devices
104  */
105 /*	SCMD_TEST_UNIT_READY	0x00	*/
106 #define	SCMD_REWIND		0x01	/* Note similarity to SCMD_REZERO */
107 /*	SCMD_REQUEST_SENSE	0x03	*/
108 #define	SCMD_READ_BLKLIM	0x05
109 /*	SCMD_READ		0x08	*/
110 /*	SCMD_WRITE		0x0a	*/
111 #define	SCMD_TRK_SEL		0x0b	/* Note similarity to SCMD_SEEK */
112 #define	SCMD_READ_REVERSE	0x0f
113 #define	SCMD_WRITE_FILE_MARK	0x10
114 #define	SCMD_SPACE		0x11
115 /*	SCMD_INQUIRY		0x12	*/
116 #define	SCMD_VERIFY_G0		0x13
117 #define	SCMD_RECOVER_BUF	0x14
118 /*	SCMD_MODE_SELECT	0x15	*/
119 /*	SCMD_RESERVE		0x16	*/
120 /*	SCMD_RELEASE		0x17	*/
121 /*	SCMD_COPY		0x18	*/
122 #define	SCMD_ERASE		0x19
123 /*	SCMD_MODE_SENSE		0x1a	*/
124 #define	SCMD_LOAD		0x1b	/* Note similarity to SCMD_START_STOP */
125 /*	SCMD_GDIAG		0x1c	*/
126 /*	SCMD_SDIAG		0x1d	*/
127 /*	SCMD_DOORLOCK		0x1e	*/
128 
129 
130 /*
131  * Group 0 commands, Printer Devices
132  */
133 /*	SCMD_TEST_UNIT_READY	0x00	*/
134 /*	SCMD_REQUEST_SENSE	0x03	*/
135 /*	SCMD_FORMAT		0x04	*/
136 #define	SCMD_PRINT		0x0a	/* Note similarity to SCMD_WRITE */
137 #define	SCMD_SLEW_PRINT		0x0b	/* ? similar to SCMD_SEEK ? */
138 #define	SCMD_FLUSH_PRINT_BUF	0x10	/* ? similar to SCMD_WRITE_FILE_MARK */
139 /*	SCMD_INQUIRY		0x12	*/
140 /*	SCMD_RECOVER_BUF	0x14	*/
141 /*	SCMD_MODE_SELECT	0x15	*/
142 /*	SCMD_RESERVE		0x16	*/
143 /*	SCMD_RELEASE		0x17	*/
144 /*	SCMD_COPY		0x18	*/
145 /*	SCMD_MODE_SENSE		0x1a	*/
146 #define	SCMD_STOP_PRINT		0x1b	/* Note similarity to SCMD_START_STOP */
147 /*	SCMD_GDIAG		0x1c	*/
148 /*	SCMD_SDIAG		0x1d	*/
149 
150 /*
151  * Group 0 commands, Processor Devices
152  */
153 /*	SCMD_TEST_UNIT_READY	0x00	*/
154 /*	SCMD_REQUEST_SENSE	0x03	*/
155 #define	SCMD_RECEIVE		0x08	/* Note similarity to SCMD_READ */
156 #define	SCMD_SEND		0x0a	/* Note similarity to SCMD_WRITE */
157 /*	SCMD_INQUIRY		0x12	*/
158 /*	SCMD_COPY		0x18	*/
159 /*	SCMD_MODE_SENSE		0x1a	*/
160 /*	SCMD_GDIAG		0x1c	*/
161 /*	SCMD_SDIAG		0x1d	*/
162 
163 /*
164  * Group 0 commands, WORM Devices
165  */
166 /*	SCMD_TEST_UNIT_READY	0x00	*/
167 /*	SCMD_REZERO_UNIT	0x01	*/
168 /*	SCMD_REQUEST_SENSE	0x03	*/
169 /*	SCMD_REASSIGN_BLOCK	0x07	*/
170 /*	SCMD_READ		0x08	*/
171 /*	SCMD_WRITE		0x0a	*/
172 /*	SCMD_SEEK		0x0b	*/
173 /*	SCMD_INQUIRY		0x12	*/
174 /*	SCMD_MODE_SELECT	0x15	*/
175 /*	SCMD_RESERVE		0x16	*/
176 /*	SCMD_RELEASE		0x17	*/
177 /*	SCMD_COPY		0x18	*/
178 /*	SCMD_MODE_SENSE		0x1a	*/
179 /*	SCMD_START_STOP		0x1b	*/
180 /*	SCMD_GDIAG		0x1C	*/
181 /*	SCMD_SDIAG		0x1D	*/
182 /*	SCMD_DOORLOCK		0x1E	*/
183 
184 /*
185  * Group 0 commands, Read Only Devices
186  */
187 /*	SCMD_TEST_UNIT_READY	0x00	*/
188 /*	SCMD_REZERO_UNIT	0x01	*/
189 /*	SCMD_REQUEST_SENSE	0x03	*/
190 /*	SCMD_REASSIGN_BLOCK	0x07	*/
191 /*	SCMD_READ		0x08	*/
192 /*	SCMD_SEEK		0x0b	*/
193 /*	SCMD_INQUIRY		0x12	*/
194 /*	SCMD_MODE_SELECT	0x15	*/
195 /*	SCMD_RESERVE		0x16	*/
196 /*	SCMD_RELEASE		0x17	*/
197 /*	SCMD_COPY		0x18	*/
198 /*	SCMD_MODE_SENSE		0x1a	*/
199 /*	SCMD_START_STOP		0x1b	*/
200 /*	SCMD_GDIAG		0x1C	*/
201 /*	SCMD_SDIAG		0x1D	*/
202 /*	SCMD_DOORLOCK		0x1E	*/
203 
204 /*
205  * Group 1 Commands (CDB range 0x20 - 0x3F)
206  */
207 #define	SCMD_GROUP1		0x20
208 
209 /*
210  * Group 1 Commands, All Devices
211  */
212 #define	SCMD_COMPARE		0x39
213 #define	SCMD_COPY_VERIFY	0x3A
214 #define	SCMD_PERSISTENT_RESERVE_IN		0x5E
215 #define	SCMD_PERSISTENT_RESERVE_OUT		0x5F
216 #define	SCMD_PRIN		SCMD_PERSISTENT_RESERVE_IN
217 #define	SCMD_PROUT		SCMD_PERSISTENT_RESERVE_OUT
218 
219 /*
220  * Group 1 Commands, Direct Access Devices
221  */
222 #define	SCMD_READ_FORMAT_CAP	0x23
223 #define	SCMD_READ_CAPACITY	0x25
224 #define	SCMD_READ_G1		0x28	/* Note that only the group changed */
225 #define	SCMD_WRITE_G1		0x2a	/* Note that only the group changed */
226 #define	SCMD_SEEK_G1		0x2b	/* Note that only the group changed */
227 #define	SCMD_WRITE_VERIFY	0x2e
228 #define	SCMD_VERIFY		0x2f
229 #define	SCMD_SEARCH_HIGH	0x30
230 #define	SCMD_SEARCH_EQUAL	0x31
231 #define	SCMD_SEARCH_LOW		0x32
232 #define	SCMD_SET_LIMITS		0x33
233 #define	SCMD_SYNCHRONIZE_CACHE	0x35
234 #define	SCMD_READ_DEFECT_LIST	0x37
235 #define	SCMD_WRITE_BUFFER	0x3B
236 #define	SCMD_READ_BUFFER	0x3c
237 #define	SCMD_READ_LONG		0x3E
238 #define	SCMD_WRITE_LONG		0x3F
239 #define	SCMD_RESERVE_G1		0x56
240 #define	SCMD_RELEASE_G1		0x57
241 #define	SCMD_MODE_SELECT_G1	0x55
242 #define	SCMD_MODE_SENSE_G1	0x5A
243 #define	SCMD_GET_CONFIGURATION	0x46
244 #define	SCMD_LOG_SELECT_G1	0x4C
245 #define	SCMD_LOG_SENSE_G1	0x4d
246 
247 
248 /*
249  * Group 1 Commands, Sequential Access Devices
250  */
251 #define	SCMD_LOCATE		0x2B	/* Note similarity to SCMD_SEEK_G1 */
252 #define	SCMD_READ_POSITION	0x34
253 #define	SCMD_REPORT_DENSITIES	0x44
254 
255 /*
256  * Group 1 Commands, Printer Devices
257  */
258 /* (None Defined) */
259 
260 /*
261  * Group 1 Commands, Processor Devices
262  */
263 /* (None Defined) */
264 
265 /*
266  * Group 1 Commands, WORM Devices
267  */
268 /*	SCMD_READ_CAPACITY	0x25	*/
269 /*	SCMD_READ_G1		0x28	*/
270 /*	SCMD_WRITE_G1		0x2a	*/
271 /*	SCMD_SEEK_G1		0x2b	*/
272 /*	SCMD_WRITE_VERIFY	0x2e	*/
273 /*	SCMD_VERIFY		0x2f	*/
274 /*	SCMD_SEARCH_HIGH	0x30	*/
275 /*	SCMD_SEARCH_EQUAL	0x31	*/
276 /*	SCMD_SEARCH_LOW		0x32	*/
277 /*	SCMD_SET_LIMITS		0x33	*/
278 
279 /*
280  * Group 1 Commands, Read Only Devices
281  */
282 /*	SCMD_READ_CAPACITY	0x25	*/
283 /*	SCMD_READ_G1		0x28	*/
284 /*	SCMD_SEEK_G1		0x2b	*/
285 /*	SCMD_VERIFY		0x2f	*/
286 /*	SCMD_SEARCH_HIGH	0x30	*/
287 /*	SCMD_SEARCH_EQUAL	0x31	*/
288 /*	SCMD_SEARCH_LOW		0x32	*/
289 /*	SCMD_SET_LIMITS		0x33	*/
290 
291 /*
292  * Group 4 Commands, All Devices
293  */
294 #define	SCMD_GROUP4		0x80
295 #define	SCMD_EXTENDED_COPY	0x83
296 
297 /*
298  * Group 4 Commands, Direct Access Devices
299  */
300 #define	SCMD_READ_G4		0x88
301 #define	SCMD_WRITE_G4		0x8a
302 #define	SCMD_SVC_ACTION_IN_G4	0x9e
303 #define	SCMD_SVC_ACTION_OUT_G4	0x9f
304 
305 /*
306  * Group 4 Service Actions for Service Action In (16)
307  */
308 #define	SSVC_ACTION_READ_CAPACITY_G4	0x10
309 #define	SSVC_ACTION_READ_LONG_G4	0x11
310 
311 /*
312  * Group 4 Service Actions for Service Action Out (16)
313  */
314 #define	SSVC_ACTION_WRITE_LONG_G4	0x11
315 
316 /*
317  * Define for Group 5 command.
318  */
319 #define	SCMD_GROUP5		0xA0
320 #define	SCMD_REPORT_LUNS	0xA0
321 #define	SCMD_READ_G5		0xA8
322 #define	SCMD_WRITE_G5		0xAA
323 #define	SCMD_GET_PERFORMANCE	0xAC
324 
325 
326 
327 /*
328  * scsi_key_strings for SCMD_ definitions
329  *	NOTE: see SCSI_CMDS_KEY_STRINGS_CDIO in cdio.h for additional
330  *	command-to-string translations.
331  */
332 #define	SCSI_CMDS_KEY_STRINGS						\
333 /* 0x00 */ SCMD_TEST_UNIT_READY,	"test_unit_ready",		\
334 /* 0x01 */ SCMD_REWIND |						\
335 		SCMD_REZERO_UNIT,	"rezero/rewind",		\
336 /* 0x03 */ SCMD_REQUEST_SENSE,		"request_sense",		\
337 /* 0x04 */ SCMD_FORMAT,			"format",			\
338 /* 0x05 */ SCMD_READ_BLKLIM,		"read_block_limits",		\
339 /* 0x07 */ SCMD_REASSIGN_BLOCK,		"reassign",			\
340 /* 0x08 */ SCMD_READ |							\
341 		SCMD_RECEIVE,		"read",				\
342 /* 0x0a */ SCMD_PRINT |							\
343 		SCMD_SEND |						\
344 		SCMD_WRITE,		"write",			\
345 /* 0x0b */ SCMD_SEEK |							\
346 		SCMD_SLEW_PRINT |					\
347 		SCMD_TRK_SEL,		"seek",				\
348 /* 0x0f */ SCMD_READ_REVERSE,		"read_reverse",			\
349 /* 0x10 */ SCMD_WRITE_FILE_MARK |					\
350 		SCMD_FLUSH_PRINT_BUF,	"write_file_mark",		\
351 /* 0x11 */ SCMD_SPACE,			"space",			\
352 /* 0x12 */ SCMD_INQUIRY,		"inquiry",			\
353 /* 0x13 */ SCMD_VERIFY_G0,		"verify",			\
354 /* 0x14 */ SCMD_RECOVER_BUF,		"recover_buffer_data",		\
355 /* 0x15 */ SCMD_MODE_SELECT,		"mode_select",			\
356 /* 0x16 */ SCMD_RESERVE,		"reserve",			\
357 /* 0x17 */ SCMD_RELEASE,		"release",			\
358 /* 0x18 */ SCMD_COPY,			"copy",				\
359 /* 0x19 */ SCMD_ERASE,			"erase_tape",			\
360 /* 0x1a */ SCMD_MODE_SENSE,		"mode_sense",			\
361 /* 0x1b */ SCMD_LOAD |							\
362 		SCMD_START_STOP |					\
363 		SCMD_STOP_PRINT,	"load/start/stop",		\
364 /* 0x1c */ SCMD_GDIAG,			"get_diagnostic_results",	\
365 /* 0x1d */ SCMD_SDIAG,			"send_diagnostic_command",	\
366 /* 0x1e */ SCMD_DOORLOCK,		"door_lock",			\
367 /* 0x23 */ SCMD_READ_FORMAT_CAP,	"read_format_capacity",		\
368 /* 0x25 */ SCMD_READ_CAPACITY,		"read_capacity",		\
369 /* 0x28 */ SCMD_READ_G1,		"read(10)",			\
370 /* 0x2a */ SCMD_WRITE_G1,		"write(10)",			\
371 /* 0x2b */ SCMD_SEEK_G1 |						\
372 		SCMD_LOCATE,		"seek(10)",			\
373 /* 0x2e */ SCMD_WRITE_VERIFY,		"write_verify",			\
374 /* 0x2f */ SCMD_VERIFY,			"verify(10)",			\
375 /* 0x30 */ SCMD_SEARCH_HIGH,		"search_data_high",		\
376 /* 0x31 */ SCMD_SEARCH_EQUAL,		"search_data_equal",		\
377 /* 0x32 */ SCMD_SEARCH_LOW,		"search_data_low",		\
378 /* 0x33 */ SCMD_SET_LIMITS,		"set_limits",			\
379 /* 0x34 */ SCMD_READ_POSITION,		"read_position",		\
380 /* 0x35 */ SCMD_SYNCHRONIZE_CACHE,	"synchronize_cache",		\
381 /* 0x37 */ SCMD_READ_DEFECT_LIST,	"read_defect_data",		\
382 /* 0x39 */ SCMD_COMPARE,		"compare",			\
383 /* 0x3a */ SCMD_COPY_VERIFY,		"copy_verify",			\
384 /* 0x3b */ SCMD_WRITE_BUFFER,		"write_buffer",			\
385 /* 0x3c */ SCMD_READ_BUFFER,		"read_buffer",			\
386 /* 0x3e */ SCMD_READ_LONG,		"read_long",			\
387 /* 0x3f */ SCMD_WRITE_LONG,		"write_long",			\
388 /* 0x44 */ SCMD_REPORT_DENSITIES |					\
389 		/* SCMD_READ_HEADER (from cdio.h) | */			\
390 		0,			"report_densities/read_header",	\
391 /* 0x4c */ SCMD_LOG_SELECT_G1,		"log_select",			\
392 /* 0x4d */ SCMD_LOG_SENSE_G1,		"log_sense",			\
393 /* 0x55 */ SCMD_MODE_SELECT_G1,		"mode_select(10)",		\
394 /* 0x56 */ SCMD_RESERVE_G1,		"reserve(10)",			\
395 /* 0x57 */ SCMD_RELEASE_G1,		"release(10)",			\
396 /* 0x5a */ SCMD_MODE_SENSE_G1,		"mode_sense(10)",		\
397 /* 0x5e */ SCMD_PERSISTENT_RESERVE_IN,	"persistent_reserve_in",	\
398 /* 0x5f */ SCMD_PERSISTENT_RESERVE_OUT,	"persistent_reserve_out",	\
399 /* 0x83 */ SCMD_EXTENDED_COPY,		"extended_copy",		\
400 /* 0x88 */ SCMD_READ_G4,		"read(16)",			\
401 /* 0x8a */ SCMD_WRITE_G4,		"write(16)",			\
402 /* 0xa0 */ SCMD_REPORT_LUNS,		"report_luns",			\
403 /* 0xa8 */ SCMD_READ_G5,		"read(12)",			\
404 /* 0xaa */ SCMD_WRITE_G5,		"write(12)",			\
405 /* 0xac */ SCMD_GET_PERFORMANCE,	"get_performance"		\
406 	/* see cdio.h for additional command-to-string translations */
407 
408 /* XXX not a command code, does not belong here */
409 #define	ATAPI_CAPABILITIES	0x2A
410 
411 #ifdef	__cplusplus
412 }
413 #endif
414 
415 /*
416  * Below are inclusions of files describing various command structures
417  * of interest.
418  */
419 #include <sys/scsi/generic/inquiry.h>
420 #include <sys/scsi/generic/sense.h>
421 
422 /*
423  * Private Vendor Unique Commands - Each implementation provides this.
424  */
425 #include <sys/scsi/impl/commands.h>
426 
427 #endif	/* _SYS_SCSI_GENERIC_COMMANDS_H */
428