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