xref: /titanic_50/usr/src/uts/common/sys/scsi/generic/commands.h (revision b02e9a2d4d2071d770e5aa9ae8f83f2bbe1f2ced)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2007 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 3 Commands
293  */
294 #define	SCMD_VAR_LEN		0x7f
295 
296 /*
297  * Group 4 Commands, All Devices
298  */
299 #define	SCMD_GROUP4		0x80
300 #define	SCMD_EXTENDED_COPY	0x83
301 #define	SCMD_VERIFY_G4		0x8f
302 
303 /*
304  * Group 4 Commands, Direct Access Devices
305  */
306 #define	SCMD_READ_G4		0x88
307 #define	SCMD_WRITE_G4		0x8a
308 #define	SCMD_SVC_ACTION_IN_G4	0x9e
309 #define	SCMD_SVC_ACTION_OUT_G4	0x9f
310 
311 /*
312  * Group 4 Service Actions for Service Action In (16)
313  */
314 #define	SSVC_ACTION_READ_CAPACITY_G4	0x10
315 #define	SSVC_ACTION_READ_LONG_G4	0x11
316 
317 /*
318  * Group 4 Service Actions for Service Action Out (16)
319  */
320 #define	SSVC_ACTION_WRITE_LONG_G4	0x11
321 
322 /*
323  * Group 4 Commands, Sequential Access Devics
324  */
325 #define	SCMD_READ_ATTRIBUTE	0x8c
326 #define	SCMD_WRITE_ATTRIBUTE	0x8d
327 #define	SCMD_LOCATE_G4		0x92
328 
329 /*
330  * Define for Group 5 command.
331  */
332 #define	SCMD_GROUP5		0xA0
333 #define	SCMD_REPORT_LUNS	0xA0
334 #define	SCMD_REPORT_TARGET_PORT_GROUPS	0xA3
335 #define	SCMD_SET_DEVICE		0xA4
336 #define	SCMD_SET_DEVICE_IDENTIFIER	0x06
337 #define	SCMD_SET_PRIORITY		0x0e
338 #define	SCMD_SET_TARGET_PORT_GROUPS	0x0a
339 #define	SCMD_SET_TIMESTAMP		0x0f
340 #define	SCMD_READ_G5		0xA8
341 #define	SCMD_WRITE_G5		0xAA
342 #define	SCMD_READ_MEDIA_SERIAL	0xAB
343 #define	SCMD_GET_PERFORMANCE	0xAC
344 #define	SCMD_VERIFY_G5		0xAF
345 
346 
347 /*
348  * scsi_key_strings for SCMD_ definitions
349  *	NOTE: see SCSI_CMDS_KEY_STRINGS_CDIO in cdio.h for additional
350  *	command-to-string translations.
351  */
352 #define	SCSI_CMDS_KEY_STRINGS						\
353 /* 0x00 */ SCMD_TEST_UNIT_READY,	"test_unit_ready",		\
354 /* 0x01 */ SCMD_REWIND |						\
355 		SCMD_REZERO_UNIT,	"rezero/rewind",		\
356 /* 0x03 */ SCMD_REQUEST_SENSE,		"request_sense",		\
357 /* 0x04 */ SCMD_FORMAT,			"format",			\
358 /* 0x05 */ SCMD_READ_BLKLIM,		"read_block_limits",		\
359 /* 0x07 */ SCMD_REASSIGN_BLOCK,		"reassign",			\
360 /* 0x08 */ SCMD_READ |							\
361 		SCMD_RECEIVE,		"read",				\
362 /* 0x0a */ SCMD_PRINT |							\
363 		SCMD_SEND |						\
364 		SCMD_WRITE,		"write",			\
365 /* 0x0b */ SCMD_SEEK |							\
366 		SCMD_SLEW_PRINT |					\
367 		SCMD_TRK_SEL,		"seek",				\
368 /* 0x0f */ SCMD_READ_REVERSE,		"read_reverse",			\
369 /* 0x10 */ SCMD_WRITE_FILE_MARK |					\
370 		SCMD_FLUSH_PRINT_BUF,	"write_file_mark",		\
371 /* 0x11 */ SCMD_SPACE,			"space",			\
372 /* 0x12 */ SCMD_INQUIRY,		"inquiry",			\
373 /* 0x13 */ SCMD_VERIFY_G0,		"verify",			\
374 /* 0x14 */ SCMD_RECOVER_BUF,		"recover_buffer_data",		\
375 /* 0x15 */ SCMD_MODE_SELECT,		"mode_select",			\
376 /* 0x16 */ SCMD_RESERVE,		"reserve",			\
377 /* 0x17 */ SCMD_RELEASE,		"release",			\
378 /* 0x18 */ SCMD_COPY,			"copy",				\
379 /* 0x19 */ SCMD_ERASE,			"erase_tape",			\
380 /* 0x1a */ SCMD_MODE_SENSE,		"mode_sense",			\
381 /* 0x1b */ SCMD_LOAD |							\
382 		SCMD_START_STOP |					\
383 		SCMD_STOP_PRINT,	"load/start/stop",		\
384 /* 0x1c */ SCMD_GDIAG,			"get_diagnostic_results",	\
385 /* 0x1d */ SCMD_SDIAG,			"send_diagnostic_command",	\
386 /* 0x1e */ SCMD_DOORLOCK,		"door_lock",			\
387 /* 0x23 */ SCMD_READ_FORMAT_CAP,	"read_format_capacity",		\
388 /* 0x25 */ SCMD_READ_CAPACITY,		"read_capacity",		\
389 /* 0x28 */ SCMD_READ_G1,		"read(10)",			\
390 /* 0x2a */ SCMD_WRITE_G1,		"write(10)",			\
391 /* 0x2b */ SCMD_SEEK_G1 |						\
392 		SCMD_LOCATE,		"seek(10)",			\
393 /* 0x2e */ SCMD_WRITE_VERIFY,		"write_verify",			\
394 /* 0x2f */ SCMD_VERIFY,			"verify(10)",			\
395 /* 0x30 */ SCMD_SEARCH_HIGH,		"search_data_high",		\
396 /* 0x31 */ SCMD_SEARCH_EQUAL,		"search_data_equal",		\
397 /* 0x32 */ SCMD_SEARCH_LOW,		"search_data_low",		\
398 /* 0x33 */ SCMD_SET_LIMITS,		"set_limits",			\
399 /* 0x34 */ SCMD_READ_POSITION,		"read_position",		\
400 /* 0x35 */ SCMD_SYNCHRONIZE_CACHE,	"synchronize_cache",		\
401 /* 0x37 */ SCMD_READ_DEFECT_LIST,	"read_defect_data",		\
402 /* 0x39 */ SCMD_COMPARE,		"compare",			\
403 /* 0x3a */ SCMD_COPY_VERIFY,		"copy_verify",			\
404 /* 0x3b */ SCMD_WRITE_BUFFER,		"write_buffer",			\
405 /* 0x3c */ SCMD_READ_BUFFER,		"read_buffer",			\
406 /* 0x3e */ SCMD_READ_LONG,		"read_long",			\
407 /* 0x3f */ SCMD_WRITE_LONG,		"write_long",			\
408 /* 0x44 */ SCMD_REPORT_DENSITIES |					\
409 		/* SCMD_READ_HEADER (from cdio.h) | */			\
410 		0,			"report_densities/read_header",	\
411 /* 0x4c */ SCMD_LOG_SELECT_G1,		"log_select",			\
412 /* 0x4d */ SCMD_LOG_SENSE_G1,		"log_sense",			\
413 /* 0x55 */ SCMD_MODE_SELECT_G1,		"mode_select(10)",		\
414 /* 0x56 */ SCMD_RESERVE_G1,		"reserve(10)",			\
415 /* 0x57 */ SCMD_RELEASE_G1,		"release(10)",			\
416 /* 0x5a */ SCMD_MODE_SENSE_G1,		"mode_sense(10)",		\
417 /* 0x5e */ SCMD_PERSISTENT_RESERVE_IN,	"persistent_reserve_in",	\
418 /* 0x5f */ SCMD_PERSISTENT_RESERVE_OUT,	"persistent_reserve_out",	\
419 /* 0x83 */ SCMD_EXTENDED_COPY,		"extended_copy",		\
420 /* 0x88 */ SCMD_READ_G4,		"read(16)",			\
421 /* 0x8a */ SCMD_WRITE_G4,		"write(16)",			\
422 /* 0x8c */ SCMD_READ_ATTRIBUTE,		"read_attribute",		\
423 /* 0x8d */ SCMD_WRITE_ATTRIBUTE,	"write_attribute",		\
424 /* 0x8f */ SCMD_VERIFY_G4,		"verify(16)",			\
425 /* 0x92 */ SCMD_LOCATE_G4,		"locate(16)",			\
426 /* 0xa0 */ SCMD_REPORT_LUNS,		"report_luns",			\
427 /* 0xa8 */ SCMD_READ_G5,		"read(12)",			\
428 /* 0xaa */ SCMD_WRITE_G5,		"write(12)",			\
429 /* 0xac */ SCMD_GET_PERFORMANCE,	"get_performance",		\
430 /* 0xAF */ SCMD_VERIFY_G5,		"verify(12)"			\
431 	/* see cdio.h for additional command-to-string translations */
432 
433 /* XXX not a command code, does not belong here */
434 #define	ATAPI_CAPABILITIES	0x2A
435 
436 #ifdef	__cplusplus
437 }
438 #endif
439 
440 /*
441  * Below are inclusions of files describing various command structures
442  * of interest.
443  */
444 #include <sys/scsi/generic/inquiry.h>
445 #include <sys/scsi/generic/sense.h>
446 
447 /*
448  * Private Vendor Unique Commands - Each implementation provides this.
449  */
450 #include <sys/scsi/impl/commands.h>
451 
452 #endif	/* _SYS_SCSI_GENERIC_COMMANDS_H */
453