xref: /titanic_50/usr/src/uts/common/sys/scsi/generic/commands.h (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
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 2006 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 
328 /*
329  * Define for Group 5 command.
330  */
331 #define	SCMD_GROUP5		0xA0
332 #define	SCMD_REPORT_LUNS	0xA0
333 #define	SCMD_REPORT_TARGET_PORT_GROUPS	0xA3
334 #define	SCMD_READ_G5		0xA8
335 #define	SCMD_WRITE_G5		0xAA
336 #define	SCMD_READ_MEDIA_SERIAL	0xAB
337 #define	SCMD_GET_PERFORMANCE	0xAC
338 #define	SCMD_VERIFY_G5		0xAF
339 
340 
341 /*
342  * scsi_key_strings for SCMD_ definitions
343  *	NOTE: see SCSI_CMDS_KEY_STRINGS_CDIO in cdio.h for additional
344  *	command-to-string translations.
345  */
346 #define	SCSI_CMDS_KEY_STRINGS						\
347 /* 0x00 */ SCMD_TEST_UNIT_READY,	"test_unit_ready",		\
348 /* 0x01 */ SCMD_REWIND |						\
349 		SCMD_REZERO_UNIT,	"rezero/rewind",		\
350 /* 0x03 */ SCMD_REQUEST_SENSE,		"request_sense",		\
351 /* 0x04 */ SCMD_FORMAT,			"format",			\
352 /* 0x05 */ SCMD_READ_BLKLIM,		"read_block_limits",		\
353 /* 0x07 */ SCMD_REASSIGN_BLOCK,		"reassign",			\
354 /* 0x08 */ SCMD_READ |							\
355 		SCMD_RECEIVE,		"read",				\
356 /* 0x0a */ SCMD_PRINT |							\
357 		SCMD_SEND |						\
358 		SCMD_WRITE,		"write",			\
359 /* 0x0b */ SCMD_SEEK |							\
360 		SCMD_SLEW_PRINT |					\
361 		SCMD_TRK_SEL,		"seek",				\
362 /* 0x0f */ SCMD_READ_REVERSE,		"read_reverse",			\
363 /* 0x10 */ SCMD_WRITE_FILE_MARK |					\
364 		SCMD_FLUSH_PRINT_BUF,	"write_file_mark",		\
365 /* 0x11 */ SCMD_SPACE,			"space",			\
366 /* 0x12 */ SCMD_INQUIRY,		"inquiry",			\
367 /* 0x13 */ SCMD_VERIFY_G0,		"verify",			\
368 /* 0x14 */ SCMD_RECOVER_BUF,		"recover_buffer_data",		\
369 /* 0x15 */ SCMD_MODE_SELECT,		"mode_select",			\
370 /* 0x16 */ SCMD_RESERVE,		"reserve",			\
371 /* 0x17 */ SCMD_RELEASE,		"release",			\
372 /* 0x18 */ SCMD_COPY,			"copy",				\
373 /* 0x19 */ SCMD_ERASE,			"erase_tape",			\
374 /* 0x1a */ SCMD_MODE_SENSE,		"mode_sense",			\
375 /* 0x1b */ SCMD_LOAD |							\
376 		SCMD_START_STOP |					\
377 		SCMD_STOP_PRINT,	"load/start/stop",		\
378 /* 0x1c */ SCMD_GDIAG,			"get_diagnostic_results",	\
379 /* 0x1d */ SCMD_SDIAG,			"send_diagnostic_command",	\
380 /* 0x1e */ SCMD_DOORLOCK,		"door_lock",			\
381 /* 0x23 */ SCMD_READ_FORMAT_CAP,	"read_format_capacity",		\
382 /* 0x25 */ SCMD_READ_CAPACITY,		"read_capacity",		\
383 /* 0x28 */ SCMD_READ_G1,		"read(10)",			\
384 /* 0x2a */ SCMD_WRITE_G1,		"write(10)",			\
385 /* 0x2b */ SCMD_SEEK_G1 |						\
386 		SCMD_LOCATE,		"seek(10)",			\
387 /* 0x2e */ SCMD_WRITE_VERIFY,		"write_verify",			\
388 /* 0x2f */ SCMD_VERIFY,			"verify(10)",			\
389 /* 0x30 */ SCMD_SEARCH_HIGH,		"search_data_high",		\
390 /* 0x31 */ SCMD_SEARCH_EQUAL,		"search_data_equal",		\
391 /* 0x32 */ SCMD_SEARCH_LOW,		"search_data_low",		\
392 /* 0x33 */ SCMD_SET_LIMITS,		"set_limits",			\
393 /* 0x34 */ SCMD_READ_POSITION,		"read_position",		\
394 /* 0x35 */ SCMD_SYNCHRONIZE_CACHE,	"synchronize_cache",		\
395 /* 0x37 */ SCMD_READ_DEFECT_LIST,	"read_defect_data",		\
396 /* 0x39 */ SCMD_COMPARE,		"compare",			\
397 /* 0x3a */ SCMD_COPY_VERIFY,		"copy_verify",			\
398 /* 0x3b */ SCMD_WRITE_BUFFER,		"write_buffer",			\
399 /* 0x3c */ SCMD_READ_BUFFER,		"read_buffer",			\
400 /* 0x3e */ SCMD_READ_LONG,		"read_long",			\
401 /* 0x3f */ SCMD_WRITE_LONG,		"write_long",			\
402 /* 0x44 */ SCMD_REPORT_DENSITIES |					\
403 		/* SCMD_READ_HEADER (from cdio.h) | */			\
404 		0,			"report_densities/read_header",	\
405 /* 0x4c */ SCMD_LOG_SELECT_G1,		"log_select",			\
406 /* 0x4d */ SCMD_LOG_SENSE_G1,		"log_sense",			\
407 /* 0x55 */ SCMD_MODE_SELECT_G1,		"mode_select(10)",		\
408 /* 0x56 */ SCMD_RESERVE_G1,		"reserve(10)",			\
409 /* 0x57 */ SCMD_RELEASE_G1,		"release(10)",			\
410 /* 0x5a */ SCMD_MODE_SENSE_G1,		"mode_sense(10)",		\
411 /* 0x5e */ SCMD_PERSISTENT_RESERVE_IN,	"persistent_reserve_in",	\
412 /* 0x5f */ SCMD_PERSISTENT_RESERVE_OUT,	"persistent_reserve_out",	\
413 /* 0x83 */ SCMD_EXTENDED_COPY,		"extended_copy",		\
414 /* 0x88 */ SCMD_READ_G4,		"read(16)",			\
415 /* 0x8a */ SCMD_WRITE_G4,		"write(16)",			\
416 /* 0x8c */ SCMD_READ_ATTRIBUTE,		"read_attribute",		\
417 /* 0x8d */ SCMD_WRITE_ATTRIBUTE,	"write_attribute",		\
418 /* 0xa0 */ SCMD_REPORT_LUNS,		"report_luns",			\
419 /* 0xa8 */ SCMD_READ_G5,		"read(12)",			\
420 /* 0xaa */ SCMD_WRITE_G5,		"write(12)",			\
421 /* 0xac */ SCMD_GET_PERFORMANCE,	"get_performance"		\
422 	/* see cdio.h for additional command-to-string translations */
423 
424 /* XXX not a command code, does not belong here */
425 #define	ATAPI_CAPABILITIES	0x2A
426 
427 #ifdef	__cplusplus
428 }
429 #endif
430 
431 /*
432  * Below are inclusions of files describing various command structures
433  * of interest.
434  */
435 #include <sys/scsi/generic/inquiry.h>
436 #include <sys/scsi/generic/sense.h>
437 
438 /*
439  * Private Vendor Unique Commands - Each implementation provides this.
440  */
441 #include <sys/scsi/impl/commands.h>
442 
443 #endif	/* _SYS_SCSI_GENERIC_COMMANDS_H */
444