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