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