1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2000, 2002 Kenneth D. Merry 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions, and the following disclaimer, 12 * without modification, immediately at the beginning of the file. 13 * 2. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 */ 29 /* 30 * Written by Julian Elischer (julian@tfs.com) 31 * for TRW Financial Systems. 32 * 33 * TRW Financial Systems, in accordance with their agreement with Carnegie 34 * Mellon University, makes this software available to CMU to distribute 35 * or use in any manner that they see fit as long as this message is kept with 36 * the software. For this reason TFS also grants any other persons or 37 * organisations permission to use or modify this software. 38 * 39 * TFS supplies this software to be publicly redistributed 40 * on the understanding that TFS is not responsible for the correct 41 * functioning of this software in any circumstances. 42 * 43 * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 44 * 45 * from: scsi_cd.h,v 1.10 1997/02/22 09:44:28 peter Exp $ 46 * $FreeBSD$ 47 */ 48 #ifndef _SCSI_SCSI_CD_H 49 #define _SCSI_SCSI_CD_H 1 50 51 /* 52 * Define two bits always in the same place in byte 2 (flag byte) 53 */ 54 #define CD_RELADDR 0x01 55 #define CD_MSF 0x02 56 57 /* 58 * SCSI command format 59 */ 60 61 struct scsi_get_config 62 { 63 uint8_t opcode; 64 uint8_t rt; 65 #define SGC_RT_ALL 0x00 66 #define SGC_RT_CURRENT 0x01 67 #define SGC_RT_SPECIFIC 0x02 68 #define SGC_RT_MASK 0x03 69 uint8_t starting_feature[2]; 70 uint8_t reserved[3]; 71 uint8_t length[2]; 72 uint8_t control; 73 }; 74 75 struct scsi_get_config_header 76 { 77 uint8_t data_length[4]; 78 uint8_t reserved[2]; 79 uint8_t current_profile[2]; 80 }; 81 82 struct scsi_get_config_feature 83 { 84 uint8_t feature_code[2]; 85 uint8_t flags; 86 #define SGC_F_CURRENT 0x01 87 #define SGC_F_PERSISTENT 0x02 88 #define SGC_F_VERSION_MASK 0x2C 89 #define SGC_F_VERSION_SHIFT 2 90 uint8_t add_length; 91 uint8_t feature_data[]; 92 }; 93 94 struct scsi_get_event_status 95 { 96 uint8_t opcode; 97 uint8_t byte2; 98 #define SGESN_POLLED 1 99 uint8_t reserved[2]; 100 uint8_t notif_class; 101 uint8_t reserved2[2]; 102 uint8_t length[2]; 103 uint8_t control; 104 }; 105 106 struct scsi_get_event_status_header 107 { 108 uint8_t descr_length[4]; 109 uint8_t nea_class; 110 #define SGESN_NEA 0x80 111 uint8_t supported_class; 112 }; 113 114 struct scsi_get_event_status_descr 115 { 116 uint8_t event_code; 117 uint8_t event_info[]; 118 }; 119 120 struct scsi_mechanism_status 121 { 122 uint8_t opcode; 123 uint8_t reserved[7]; 124 uint8_t length[2]; 125 uint8_t reserved2; 126 uint8_t control; 127 }; 128 129 struct scsi_mechanism_status_header 130 { 131 uint8_t state1; 132 uint8_t state2; 133 uint8_t lba[3]; 134 uint8_t slots_num; 135 uint8_t slots_length[2]; 136 }; 137 138 struct scsi_pause 139 { 140 u_int8_t op_code; 141 u_int8_t byte2; 142 u_int8_t unused[6]; 143 u_int8_t resume; 144 u_int8_t control; 145 }; 146 #define PA_PAUSE 1 147 #define PA_RESUME 0 148 149 struct scsi_play_msf 150 { 151 u_int8_t op_code; 152 u_int8_t byte2; 153 u_int8_t unused; 154 u_int8_t start_m; 155 u_int8_t start_s; 156 u_int8_t start_f; 157 u_int8_t end_m; 158 u_int8_t end_s; 159 u_int8_t end_f; 160 u_int8_t control; 161 }; 162 163 struct scsi_play_track 164 { 165 u_int8_t op_code; 166 u_int8_t byte2; 167 u_int8_t unused[2]; 168 u_int8_t start_track; 169 u_int8_t start_index; 170 u_int8_t unused1; 171 u_int8_t end_track; 172 u_int8_t end_index; 173 u_int8_t control; 174 }; 175 176 struct scsi_play_10 177 { 178 u_int8_t op_code; 179 u_int8_t byte2; 180 u_int8_t blk_addr[4]; 181 u_int8_t unused; 182 u_int8_t xfer_len[2]; 183 u_int8_t control; 184 }; 185 186 struct scsi_play_12 187 { 188 u_int8_t op_code; 189 u_int8_t byte2; /* same as above */ 190 u_int8_t blk_addr[4]; 191 u_int8_t xfer_len[4]; 192 u_int8_t unused; 193 u_int8_t control; 194 }; 195 196 struct scsi_play_rel_12 197 { 198 u_int8_t op_code; 199 u_int8_t byte2; /* same as above */ 200 u_int8_t blk_addr[4]; 201 u_int8_t xfer_len[4]; 202 u_int8_t track; 203 u_int8_t control; 204 }; 205 206 struct scsi_read_header 207 { 208 u_int8_t op_code; 209 u_int8_t byte2; 210 u_int8_t blk_addr[4]; 211 u_int8_t unused; 212 u_int8_t data_len[2]; 213 u_int8_t control; 214 }; 215 216 struct scsi_read_subchannel 217 { 218 u_int8_t op_code; 219 u_int8_t byte1; 220 u_int8_t byte2; 221 #define SRS_SUBQ 0x40 222 u_int8_t subchan_format; 223 u_int8_t unused[2]; 224 u_int8_t track; 225 u_int8_t data_len[2]; 226 u_int8_t control; 227 }; 228 229 struct scsi_read_toc 230 { 231 u_int8_t op_code; 232 u_int8_t byte2; 233 u_int8_t format; 234 u_int8_t unused[3]; 235 u_int8_t from_track; 236 u_int8_t data_len[2]; 237 u_int8_t control; 238 }; 239 240 struct scsi_read_toc_hdr 241 { 242 uint8_t data_length[2]; 243 uint8_t first; 244 uint8_t last; 245 }; 246 247 struct scsi_read_toc_type01_descr 248 { 249 uint8_t reserved; 250 uint8_t addr_ctl; 251 uint8_t track_number; 252 uint8_t reserved2; 253 uint8_t track_start[4]; 254 }; 255 256 struct scsi_read_cd_capacity 257 { 258 u_int8_t op_code; 259 u_int8_t byte2; 260 u_int8_t addr_3; /* Most Significant */ 261 u_int8_t addr_2; 262 u_int8_t addr_1; 263 u_int8_t addr_0; /* Least Significant */ 264 u_int8_t unused[3]; 265 u_int8_t control; 266 }; 267 268 struct scsi_set_speed 269 { 270 u_int8_t opcode; 271 u_int8_t byte2; 272 u_int8_t readspeed[2]; 273 u_int8_t writespeed[2]; 274 u_int8_t reserved[5]; 275 u_int8_t control; 276 }; 277 278 struct scsi_report_key 279 { 280 u_int8_t opcode; 281 u_int8_t reserved0; 282 u_int8_t lba[4]; 283 u_int8_t reserved1[2]; 284 u_int8_t alloc_len[2]; 285 u_int8_t agid_keyformat; 286 #define RK_KF_AGID_MASK 0xc0 287 #define RK_KF_AGID_SHIFT 6 288 #define RK_KF_KEYFORMAT_MASK 0x3f 289 #define RK_KF_AGID 0x00 290 #define RK_KF_CHALLENGE 0x01 291 #define RF_KF_KEY1 0x02 292 #define RK_KF_KEY2 0x03 293 #define RF_KF_TITLE 0x04 294 #define RF_KF_ASF 0x05 295 #define RK_KF_RPC_SET 0x06 296 #define RF_KF_RPC_REPORT 0x08 297 #define RF_KF_INV_AGID 0x3f 298 u_int8_t control; 299 }; 300 301 /* 302 * See the report key structure for key format and AGID definitions. 303 */ 304 struct scsi_send_key 305 { 306 u_int8_t opcode; 307 u_int8_t reserved[7]; 308 u_int8_t param_len[2]; 309 u_int8_t agid_keyformat; 310 u_int8_t control; 311 }; 312 313 struct scsi_read_dvd_structure 314 { 315 u_int8_t opcode; 316 u_int8_t reserved; 317 u_int8_t address[4]; 318 u_int8_t layer_number; 319 u_int8_t format; 320 #define RDS_FORMAT_PHYSICAL 0x00 321 #define RDS_FORMAT_COPYRIGHT 0x01 322 #define RDS_FORMAT_DISC_KEY 0x02 323 #define RDS_FORMAT_BCA 0x03 324 #define RDS_FORMAT_MANUFACTURER 0x04 325 #define RDS_FORMAT_CMGS_CPM 0x05 326 #define RDS_FORMAT_PROT_DISCID 0x06 327 #define RDS_FORMAT_DISC_KEY_BLOCK 0x07 328 #define RDS_FORMAT_DDS 0x08 329 #define RDS_FORMAT_DVDRAM_MEDIA_STAT 0x09 330 #define RDS_FORMAT_SPARE_AREA 0x0a 331 #define RDS_FORMAT_RMD_BORDEROUT 0x0c 332 #define RDS_FORMAT_RMD 0x0d 333 #define RDS_FORMAT_LEADIN 0x0e 334 #define RDS_FORMAT_DISC_ID 0x0f 335 #define RDS_FORMAT_DCB 0x30 336 #define RDS_FORMAT_WRITE_PROT 0xc0 337 #define RDS_FORMAT_STRUCTURE_LIST 0xff 338 u_int8_t alloc_len[2]; 339 u_int8_t agid; 340 u_int8_t control; 341 }; 342 343 /* 344 * Opcodes 345 */ 346 #define READ_CD_CAPACITY 0x25 /* slightly different from disk */ 347 #define READ_SUBCHANNEL 0x42 /* cdrom read Subchannel */ 348 #define READ_TOC 0x43 /* cdrom read TOC */ 349 #define READ_HEADER 0x44 /* cdrom read header */ 350 #define PLAY_10 0x45 /* cdrom play 'play audio' mode */ 351 #define GET_CONFIGURATION 0x46 /* Get device configuration */ 352 #define PLAY_MSF 0x47 /* cdrom play Min,Sec,Frames mode */ 353 #define PLAY_TRACK 0x48 /* cdrom play track/index mode */ 354 #define PLAY_TRACK_REL 0x49 /* cdrom play track/index mode */ 355 #define GET_EVENT_STATUS 0x4a /* Get event status notification */ 356 #define PAUSE 0x4b /* cdrom pause in 'play audio' mode */ 357 #define SEND_KEY 0xa3 /* dvd send key command */ 358 #define REPORT_KEY 0xa4 /* dvd report key command */ 359 #define PLAY_12 0xa5 /* cdrom pause in 'play audio' mode */ 360 #define PLAY_TRACK_REL_BIG 0xa9 /* cdrom play track/index mode */ 361 #define READ_DVD_STRUCTURE 0xad /* read dvd structure */ 362 #define SET_CD_SPEED 0xbb /* set c/dvd speed */ 363 #define MECHANISM_STATUS 0xbd /* get status of c/dvd mechanics */ 364 365 struct scsi_report_key_data_header 366 { 367 u_int8_t data_len[2]; 368 u_int8_t reserved[2]; 369 }; 370 371 struct scsi_report_key_data_agid 372 { 373 u_int8_t data_len[2]; 374 u_int8_t reserved[5]; 375 u_int8_t agid; 376 #define RKD_AGID_MASK 0xc0 377 #define RKD_AGID_SHIFT 6 378 }; 379 380 struct scsi_report_key_data_challenge 381 { 382 u_int8_t data_len[2]; 383 u_int8_t reserved0[2]; 384 u_int8_t challenge_key[10]; 385 u_int8_t reserved1[2]; 386 }; 387 388 struct scsi_report_key_data_key1_key2 389 { 390 u_int8_t data_len[2]; 391 u_int8_t reserved0[2]; 392 u_int8_t key1[5]; 393 u_int8_t reserved1[3]; 394 }; 395 396 struct scsi_report_key_data_title 397 { 398 u_int8_t data_len[2]; 399 u_int8_t reserved0[2]; 400 u_int8_t byte0; 401 #define RKD_TITLE_CPM 0x80 402 #define RKD_TITLE_CPM_SHIFT 7 403 #define RKD_TITLE_CP_SEC 0x40 404 #define RKD_TITLE_CP_SEC_SHIFT 6 405 #define RKD_TITLE_CMGS_MASK 0x30 406 #define RKD_TITLE_CMGS_SHIFT 4 407 #define RKD_TITLE_CMGS_NO_RST 0x00 408 #define RKD_TITLE_CMGS_RSVD 0x10 409 #define RKD_TITLE_CMGS_1_GEN 0x20 410 #define RKD_TITLE_CMGS_NO_COPY 0x30 411 u_int8_t title_key[5]; 412 u_int8_t reserved1[2]; 413 }; 414 415 struct scsi_report_key_data_asf 416 { 417 u_int8_t data_len[2]; 418 u_int8_t reserved[5]; 419 u_int8_t success; 420 #define RKD_ASF_SUCCESS 0x01 421 }; 422 423 struct scsi_report_key_data_rpc 424 { 425 u_int8_t data_len[2]; 426 u_int8_t rpc_scheme0; 427 #define RKD_RPC_SCHEME_UNKNOWN 0x00 428 #define RKD_RPC_SCHEME_PHASE_II 0x01 429 u_int8_t reserved0; 430 u_int8_t byte4; 431 #define RKD_RPC_TYPE_MASK 0xC0 432 #define RKD_RPC_TYPE_SHIFT 6 433 #define RKD_RPC_TYPE_NONE 0x00 434 #define RKD_RPC_TYPE_SET 0x40 435 #define RKD_RPC_TYPE_LAST_CHANCE 0x80 436 #define RKD_RPC_TYPE_PERM 0xC0 437 #define RKD_RPC_VENDOR_RESET_MASK 0x38 438 #define RKD_RPC_VENDOR_RESET_SHIFT 3 439 #define RKD_RPC_USER_RESET_MASK 0x07 440 #define RKD_RPC_USER_RESET_SHIFT 0 441 u_int8_t region_mask; 442 u_int8_t rpc_scheme1; 443 u_int8_t reserved1; 444 }; 445 446 struct scsi_send_key_data_rpc 447 { 448 u_int8_t data_len[2]; 449 u_int8_t reserved0[2]; 450 u_int8_t region_code; 451 u_int8_t reserved1[3]; 452 }; 453 454 /* 455 * Common header for the return data from the READ DVD STRUCTURE command. 456 */ 457 struct scsi_read_dvd_struct_data_header 458 { 459 u_int8_t data_len[2]; 460 u_int8_t reserved[2]; 461 }; 462 463 struct scsi_read_dvd_struct_data_layer_desc 464 { 465 u_int8_t book_type_version; 466 #define RDSD_BOOK_TYPE_DVD_ROM 0x00 467 #define RDSD_BOOK_TYPE_DVD_RAM 0x10 468 #define RDSD_BOOK_TYPE_DVD_R 0x20 469 #define RDSD_BOOK_TYPE_DVD_RW 0x30 470 #define RDSD_BOOK_TYPE_DVD_PRW 0x90 471 #define RDSD_BOOK_TYPE_MASK 0xf0 472 #define RDSD_BOOK_TYPE_SHIFT 4 473 #define RDSD_BOOK_VERSION_MASK 0x0f 474 /* 475 * The lower 4 bits of this field is referred to as the "minimum 476 * rate" field in MMC2, and the "maximum rate" field in MMC3. Ugh. 477 */ 478 u_int8_t disc_size_max_rate; 479 #define RDSD_DISC_SIZE_120MM 0x00 480 #define RDSD_DISC_SIZE_80MM 0x10 481 #define RDSD_DISC_SIZE_MASK 0xf0 482 #define RDSD_DISC_SIZE_SHIFT 4 483 #define RDSD_MAX_RATE_0252 0x00 484 #define RDSD_MAX_RATE_0504 0x01 485 #define RDSD_MAX_RATE_1008 0x02 486 #define RDSD_MAX_RATE_NOT_SPEC 0x0f 487 #define RDSD_MAX_RATE_MASK 0x0f 488 u_int8_t layer_info; 489 #define RDSD_NUM_LAYERS_MASK 0x60 490 #define RDSD_NUM_LAYERS_SHIFT 5 491 #define RDSD_NL_ONE_LAYER 0x00 492 #define RDSD_NL_TWO_LAYERS 0x20 493 #define RDSD_TRACK_PATH_MASK 0x10 494 #define RDSD_TRACK_PATH_SHIFT 4 495 #define RDSD_TP_PTP 0x00 496 #define RDSD_TP_OTP 0x10 497 #define RDSD_LAYER_TYPE_RO 0x01 498 #define RDSD_LAYER_TYPE_RECORD 0x02 499 #define RDSD_LAYER_TYPE_RW 0x04 500 #define RDSD_LAYER_TYPE_MASK 0x0f 501 u_int8_t density; 502 #define RDSD_LIN_DENSITY_0267 0x00 503 #define RDSD_LIN_DENSITY_0293 0x10 504 #define RDSD_LIN_DENSITY_0409_0435 0x20 505 #define RDSD_LIN_DENSITY_0280_0291 0x40 506 /* XXX MMC2 uses 0.176um/bit instead of 0.353 as in MMC3 */ 507 #define RDSD_LIN_DENSITY_0353 0x80 508 #define RDSD_LIN_DENSITY_MASK 0xf0 509 #define RDSD_LIN_DENSITY_SHIFT 4 510 #define RDSD_TRACK_DENSITY_074 0x00 511 #define RDSD_TRACK_DENSITY_080 0x01 512 #define RDSD_TRACK_DENSITY_0615 0x02 513 #define RDSD_TRACK_DENSITY_MASK 0x0f 514 u_int8_t zeros0; 515 u_int8_t main_data_start[3]; 516 #define RDSD_MAIN_DATA_START_DVD_RO 0x30000 517 #define RDSD_MAIN_DATA_START_DVD_RW 0x31000 518 u_int8_t zeros1; 519 u_int8_t main_data_end[3]; 520 u_int8_t zeros2; 521 u_int8_t end_sector_layer0[3]; 522 u_int8_t bca; 523 #define RDSD_BCA 0x80 524 #define RDSD_BCA_MASK 0x80 525 #define RDSD_BCA_SHIFT 7 526 u_int8_t media_specific[2031]; 527 }; 528 529 struct scsi_read_dvd_struct_data_physical 530 { 531 u_int8_t data_len[2]; 532 u_int8_t reserved[2]; 533 struct scsi_read_dvd_struct_data_layer_desc layer_desc; 534 }; 535 536 struct scsi_read_dvd_struct_data_copyright 537 { 538 u_int8_t data_len[2]; 539 u_int8_t reserved0[2]; 540 u_int8_t cps_type; 541 #define RDSD_CPS_NOT_PRESENT 0x00 542 #define RDSD_CPS_DATA_EXISTS 0x01 543 u_int8_t region_info; 544 u_int8_t reserved1[2]; 545 }; 546 547 struct scsi_read_dvd_struct_data_disc_key 548 { 549 u_int8_t data_len[2]; 550 u_int8_t reserved[2]; 551 u_int8_t disc_key[2048]; 552 }; 553 554 struct scsi_read_dvd_struct_data_bca 555 { 556 u_int8_t data_len[2]; 557 u_int8_t reserved[2]; 558 u_int8_t bca_info[188]; /* XXX 12-188 bytes */ 559 }; 560 561 struct scsi_read_dvd_struct_data_manufacturer 562 { 563 u_int8_t data_len[2]; 564 u_int8_t reserved[2]; 565 u_int8_t manuf_info[2048]; 566 }; 567 568 struct scsi_read_dvd_struct_data_copy_manage 569 { 570 u_int8_t data_len[2]; 571 u_int8_t reserved0[2]; 572 u_int8_t byte4; 573 #define RDSD_CPM_NO_COPYRIGHT 0x00 574 #define RDSD_CPM_HAS_COPYRIGHT 0x80 575 #define RDSD_CPM_MASK 0x80 576 #define RDSD_CMGS_COPY_ALLOWED 0x00 577 #define RDSD_CMGS_ONE_COPY 0x20 578 #define RDSD_CMGS_NO_COPIES 0x30 579 #define RDSD_CMGS_MASK 0x30 580 u_int8_t reserved1[3]; 581 }; 582 583 struct scsi_read_dvd_struct_data_prot_discid 584 { 585 u_int8_t data_len[2]; 586 u_int8_t reserved[2]; 587 u_int8_t prot_discid_data[16]; 588 }; 589 590 struct scsi_read_dvd_struct_data_disc_key_blk 591 { 592 /* 593 * Length is 0x6ffe == 28670 for CPRM, 0x3002 == 12990 for CSS2. 594 */ 595 u_int8_t data_len[2]; 596 u_int8_t reserved; 597 u_int8_t total_packs; 598 u_int8_t disc_key_pack_data[28668]; 599 }; 600 struct scsi_read_dvd_struct_data_dds 601 { 602 u_int8_t data_len[2]; 603 u_int8_t reserved[2]; 604 u_int8_t dds_info[2048]; 605 }; 606 607 struct scsi_read_dvd_struct_data_medium_status 608 { 609 u_int8_t data_len[2]; 610 u_int8_t reserved0[2]; 611 u_int8_t byte4; 612 #define RDSD_MS_CARTRIDGE 0x80 613 #define RDSD_MS_OUT 0x40 614 #define RDSD_MS_MSWI 0x08 615 #define RDSD_MS_CWP 0x04 616 #define RDSD_MS_PWP 0x02 617 u_int8_t disc_type_id; 618 #define RDSD_DT_NEED_CARTRIDGE 0x00 619 #define RDSD_DT_NO_CART_NEEDED 0x01 620 u_int8_t reserved1; 621 u_int8_t ram_swi_info; 622 #define RDSD_SWI_NO_BARE 0x01 623 #define RDSD_SWI_UNSPEC 0xff 624 }; 625 626 struct scsi_read_dvd_struct_data_spare_area 627 { 628 u_int8_t data_len[2]; 629 u_int8_t reserved[2]; 630 u_int8_t unused_primary[4]; 631 u_int8_t unused_supl[4]; 632 u_int8_t allocated_supl[4]; 633 }; 634 635 struct scsi_read_dvd_struct_data_rmd_borderout 636 { 637 u_int8_t data_len[2]; 638 u_int8_t reserved[2]; 639 u_int8_t rmd[30720]; /* maximum is 30720 bytes */ 640 }; 641 642 struct scsi_read_dvd_struct_data_rmd 643 { 644 u_int8_t data_len[2]; 645 u_int8_t reserved[2]; 646 u_int8_t last_sector_num[4]; 647 u_int8_t rmd_bytes[32768]; /* This is the maximum */ 648 }; 649 650 /* 651 * XXX KDM this is the MMC2 version of the structure. 652 * The variable positions have changed (in a semi-conflicting way) in the 653 * MMC3 spec, although the overall length of the structure is the same. 654 */ 655 struct scsi_read_dvd_struct_data_leadin 656 { 657 u_int8_t data_len[2]; 658 u_int8_t reserved0[2]; 659 u_int8_t field_id_1; 660 u_int8_t app_code; 661 u_int8_t disc_physical_data; 662 u_int8_t last_addr[3]; 663 u_int8_t reserved1[2]; 664 u_int8_t field_id_2; 665 u_int8_t rwp; 666 u_int8_t rwp_wavelength; 667 u_int8_t optimum_write_strategy; 668 u_int8_t reserved2[4]; 669 u_int8_t field_id_3; 670 u_int8_t manuf_id_17_12[6]; 671 u_int8_t reserved3; 672 u_int8_t field_id_4; 673 u_int8_t manuf_id_11_6[6]; 674 u_int8_t reserved4; 675 u_int8_t field_id_5; 676 u_int8_t manuf_id_5_0[6]; 677 u_int8_t reserved5[25]; 678 }; 679 680 struct scsi_read_dvd_struct_data_disc_id 681 { 682 u_int8_t data_len[2]; 683 u_int8_t reserved[4]; 684 u_int8_t random_num[2]; 685 u_int8_t year[4]; 686 u_int8_t month[2]; 687 u_int8_t day[2]; 688 u_int8_t hour[2]; 689 u_int8_t minute[2]; 690 u_int8_t second[2]; 691 }; 692 693 struct scsi_read_dvd_struct_data_generic_dcb 694 { 695 u_int8_t content_desc[4]; 696 #define SCSI_RCB 697 u_int8_t unknown_desc_actions[4]; 698 #define RDSD_ACTION_RECORDING 0x0001 699 #define RDSD_ACTION_READING 0x0002 700 #define RDSD_ACTION_FORMAT 0x0004 701 #define RDSD_ACTION_MODIFY_DCB 0x0008 702 u_int8_t vendor_id[32]; 703 u_int8_t dcb_data[32728]; 704 }; 705 706 struct scsi_read_dvd_struct_data_dcb 707 { 708 u_int8_t data_len[2]; 709 u_int8_t reserved[2]; 710 struct scsi_read_dvd_struct_data_generic_dcb dcb; 711 }; 712 713 struct read_dvd_struct_write_prot 714 { 715 u_int8_t data_len[2]; 716 u_int8_t reserved0[2]; 717 u_int8_t write_prot_status; 718 #define RDSD_WPS_MSWI 0x08 719 #define RDSD_WPS_CWP 0x04 720 #define RDSD_WPS_PWP 0x02 721 #define RDSD_WPS_SWPP 0x01 722 u_int8_t reserved[3]; 723 }; 724 725 struct read_dvd_struct_list_entry 726 { 727 u_int8_t format_code; 728 u_int8_t sds_rds; 729 #define RDSD_SDS_NOT_WRITEABLE 0x00 730 #define RDSD_SDS_WRITEABLE 0x80 731 #define RDSD_SDS_MASK 0x80 732 #define RDSD_RDS_NOT_READABLE 0x00 733 #define RDSD_RDS_READABLE 0x40 734 #define RDSD_RDS_MASK 0x40 735 u_int8_t struct_len[2]; 736 }; 737 738 struct read_dvd_struct_data_list 739 { 740 u_int8_t data_len[2]; 741 u_int8_t reserved[2]; 742 struct read_dvd_struct_list_entry entries[0]; 743 }; 744 745 struct scsi_read_cd_cap_data 746 { 747 u_int8_t addr_3; /* Most significant */ 748 u_int8_t addr_2; 749 u_int8_t addr_1; 750 u_int8_t addr_0; /* Least significant */ 751 u_int8_t length_3; /* Most significant */ 752 u_int8_t length_2; 753 u_int8_t length_1; 754 u_int8_t length_0; /* Least significant */ 755 }; 756 757 struct cd_audio_page 758 { 759 u_int8_t page_code; 760 #define CD_PAGE_CODE 0x3F 761 #define AUDIO_PAGE 0x0e 762 #define CD_PAGE_PS 0x80 763 u_int8_t param_len; 764 u_int8_t flags; 765 #define CD_PA_SOTC 0x02 766 #define CD_PA_IMMED 0x04 767 u_int8_t unused[2]; 768 u_int8_t format_lba; 769 #define CD_PA_FORMAT_LBA 0x0F 770 #define CD_PA_APR_VALID 0x80 771 u_int8_t lb_per_sec[2]; 772 struct port_control 773 { 774 u_int8_t channels; 775 #define CHANNEL 0x0F 776 #define CHANNEL_0 1 777 #define CHANNEL_1 2 778 #define CHANNEL_2 4 779 #define CHANNEL_3 8 780 #define LEFT_CHANNEL CHANNEL_0 781 #define RIGHT_CHANNEL CHANNEL_1 782 u_int8_t volume; 783 } port[4]; 784 #define LEFT_PORT 0 785 #define RIGHT_PORT 1 786 }; 787 788 struct scsi_cddvd_capabilities_page_sd { 789 uint8_t reserved; 790 uint8_t rotation_control; 791 uint8_t write_speed_supported[2]; 792 }; 793 794 struct scsi_cddvd_capabilities_page { 795 uint8_t page_code; 796 #define SMS_CDDVD_CAPS_PAGE 0x2a 797 uint8_t page_length; 798 uint8_t caps1; 799 uint8_t caps2; 800 uint8_t caps3; 801 uint8_t caps4; 802 uint8_t caps5; 803 uint8_t caps6; 804 uint8_t obsolete[2]; 805 uint8_t nvol_levels[2]; 806 uint8_t buffer_size[2]; 807 uint8_t obsolete2[2]; 808 uint8_t reserved; 809 uint8_t digital; 810 uint8_t obsolete3; 811 uint8_t copy_management; 812 uint8_t reserved2; 813 uint8_t rotation_control; 814 uint8_t cur_write_speed; 815 uint8_t num_speed_descr; 816 struct scsi_cddvd_capabilities_page_sd speed_descr[]; 817 }; 818 819 union cd_pages 820 { 821 struct cd_audio_page audio; 822 }; 823 824 struct cd_mode_data_10 825 { 826 struct scsi_mode_header_10 header; 827 struct scsi_mode_blk_desc blk_desc; 828 union cd_pages page; 829 }; 830 831 struct cd_mode_data 832 { 833 struct scsi_mode_header_6 header; 834 struct scsi_mode_blk_desc blk_desc; 835 union cd_pages page; 836 }; 837 838 union cd_mode_data_6_10 839 { 840 struct cd_mode_data mode_data_6; 841 struct cd_mode_data_10 mode_data_10; 842 }; 843 844 struct cd_mode_params 845 { 846 STAILQ_ENTRY(cd_mode_params) links; 847 int cdb_size; 848 int alloc_len; 849 u_int8_t *mode_buf; 850 }; 851 852 __BEGIN_DECLS 853 void scsi_report_key(struct ccb_scsiio *csio, u_int32_t retries, 854 void (*cbfcnp)(struct cam_periph *, union ccb *), 855 u_int8_t tag_action, u_int32_t lba, u_int8_t agid, 856 u_int8_t key_format, u_int8_t *data_ptr, 857 u_int32_t dxfer_len, u_int8_t sense_len, 858 u_int32_t timeout); 859 860 void scsi_send_key(struct ccb_scsiio *csio, u_int32_t retries, 861 void (*cbfcnp)(struct cam_periph *, union ccb *), 862 u_int8_t tag_action, u_int8_t agid, u_int8_t key_format, 863 u_int8_t *data_ptr, u_int32_t dxfer_len, u_int8_t sense_len, 864 u_int32_t timeout); 865 866 void scsi_read_dvd_structure(struct ccb_scsiio *csio, u_int32_t retries, 867 void (*cbfcnp)(struct cam_periph *, union ccb *), 868 u_int8_t tag_action, u_int32_t address, 869 u_int8_t layer_number, u_int8_t format, 870 u_int8_t agid, u_int8_t *data_ptr, 871 u_int32_t dxfer_len, u_int8_t sense_len, 872 u_int32_t timeout); 873 874 __END_DECLS 875 876 #endif /*_SCSI_SCSI_CD_H*/ 877 878