FreeBSD/Linux Kernel Cross Reference
sys/sys/cdio.h
1 /* $OpenBSD: cdio.h,v 1.17 2017/10/24 09:36:13 jsg Exp $ */
2 /* $NetBSD: cdio.h,v 1.11 1996/02/19 18:29:04 scottr Exp $ */
3
4 #ifndef _SYS_CDIO_H_
5 #define _SYS_CDIO_H_
6
7 #include <sys/types.h>
8 #include <sys/ioccom.h>
9
10 /* Shared between kernel & process */
11
12 union msf_lba {
13 struct {
14 u_char unused;
15 u_char minute;
16 u_char second;
17 u_char frame;
18 } msf;
19 u_int32_t lba;
20 u_char addr[4];
21 };
22
23 struct cd_toc_entry {
24 u_char nothing1;
25 #if _BYTE_ORDER == _LITTLE_ENDIAN
26 u_int control:4;
27 u_int addr_type:4;
28 #endif
29 #if _BYTE_ORDER == _BIG_ENDIAN
30 u_int addr_type:4;
31 u_int control:4;
32 #endif
33 u_char track;
34 u_char nothing2;
35 union msf_lba addr;
36 };
37
38 struct cd_sub_channel_header {
39 u_char nothing1;
40 u_char audio_status;
41 #define CD_AS_AUDIO_INVALID 0x00
42 #define CD_AS_PLAY_IN_PROGRESS 0x11
43 #define CD_AS_PLAY_PAUSED 0x12
44 #define CD_AS_PLAY_COMPLETED 0x13
45 #define CD_AS_PLAY_ERROR 0x14
46 #define CD_AS_NO_STATUS 0x15
47 u_char data_len[2];
48 };
49
50 struct cd_sub_channel_q_data {
51 u_char data_format;
52 #if _BYTE_ORDER == _LITTLE_ENDIAN
53 u_int control:4;
54 u_int addr_type:4;
55 #endif
56 #if _BYTE_ORDER == _BIG_ENDIAN
57 u_int addr_type:4;
58 u_int control:4;
59 #endif
60 u_char track_number;
61 u_char index_number;
62 u_char absaddr[4];
63 u_char reladdr[4];
64 #if _BYTE_ORDER == _LITTLE_ENDIAN
65 u_int :7;
66 u_int mc_valid:1;
67 #endif
68 #if _BYTE_ORDER == _BIG_ENDIAN
69 u_int mc_valid:1;
70 u_int :7;
71 #endif
72 u_char mc_number[15];
73 #if _BYTE_ORDER == _LITTLE_ENDIAN
74 u_int :7;
75 u_int ti_valid:1;
76 #endif
77 #if _BYTE_ORDER == _BIG_ENDIAN
78 u_int ti_valid:1;
79 u_int :7;
80 #endif
81 u_char ti_number[15];
82 };
83
84 struct cd_sub_channel_position_data {
85 u_char data_format;
86 #if _BYTE_ORDER == _LITTLE_ENDIAN
87 u_int control:4;
88 u_int addr_type:4;
89 #endif
90 #if _BYTE_ORDER == _BIG_ENDIAN
91 u_int addr_type:4;
92 u_int control:4;
93 #endif
94 u_char track_number;
95 u_char index_number;
96 union msf_lba absaddr;
97 union msf_lba reladdr;
98 };
99
100 struct cd_sub_channel_media_catalog {
101 u_char data_format;
102 u_char nothing1;
103 u_char nothing2;
104 u_char nothing3;
105 #if _BYTE_ORDER == _LITTLE_ENDIAN
106 u_int :7;
107 u_int mc_valid:1;
108 #endif
109 #if _BYTE_ORDER == _BIG_ENDIAN
110 u_int mc_valid:1;
111 u_int :7;
112 #endif
113 u_char mc_number[15];
114 };
115
116 struct cd_sub_channel_track_info {
117 u_char data_format;
118 u_char nothing1;
119 u_char track_number;
120 u_char nothing2;
121 #if _BYTE_ORDER == _LITTLE_ENDIAN
122 u_int :7;
123 u_int ti_valid:1;
124 #endif
125 #if _BYTE_ORDER == _BIG_ENDIAN
126 u_int ti_valid:1;
127 u_int :7;
128 #endif
129 u_char ti_number[15];
130 };
131
132 struct cd_sub_channel_info {
133 struct cd_sub_channel_header header;
134 union {
135 struct cd_sub_channel_q_data q_data;
136 struct cd_sub_channel_position_data position;
137 struct cd_sub_channel_media_catalog media_catalog;
138 struct cd_sub_channel_track_info track_info;
139 } what;
140 };
141
142 /*
143 * Ioctls for the CD drive
144 */
145 struct ioc_play_track {
146 u_char start_track;
147 u_char start_index;
148 u_char end_track;
149 u_char end_index;
150 };
151
152 #define CDIOCPLAYTRACKS _IOW('c', 1, struct ioc_play_track)
153 struct ioc_play_blocks {
154 int blk;
155 int len;
156 };
157 #define CDIOCPLAYBLOCKS _IOW('c', 2, struct ioc_play_blocks)
158
159 struct ioc_read_subchannel {
160 u_char address_format;
161 #define CD_LBA_FORMAT 1
162 #define CD_MSF_FORMAT 2
163 u_char data_format;
164 #define CD_SUBQ_DATA 0
165 #define CD_CURRENT_POSITION 1
166 #define CD_MEDIA_CATALOG 2
167 #define CD_TRACK_INFO 3
168 u_char track;
169 int data_len;
170 struct cd_sub_channel_info *data;
171 };
172 #define CDIOCREADSUBCHANNEL _IOWR('c', 3, struct ioc_read_subchannel)
173
174 struct ioc_toc_header {
175 u_short len;
176 u_char starting_track;
177 u_char ending_track;
178 };
179
180 #define CDIOREADTOCHEADER _IOR('c', 4, struct ioc_toc_header)
181
182 struct ioc_read_toc_entry {
183 u_char address_format;
184 u_char starting_track;
185 #define CD_TRACK_LEADOUT 0xaa
186 u_short data_len;
187 struct cd_toc_entry *data;
188 };
189 #define CDIOREADTOCENTRIES _IOWR('c', 5, struct ioc_read_toc_entry)
190 #define CDIOREADTOCENTRYS CDIOREADTOCENTRIES
191
192 /* read LBA start of a given session; 0=last, others not yet supported */
193 #define CDIOREADMSADDR _IOWR('c', 6, int)
194
195 struct ioc_patch {
196 u_char patch[4]; /* one for each channel */
197 };
198 #define CDIOCSETPATCH _IOW('c', 9, struct ioc_patch)
199
200 struct ioc_vol {
201 u_char vol[4]; /* one for each channel */
202 };
203 #define CDIOCGETVOL _IOR('c', 10, struct ioc_vol)
204 #define CDIOCSETVOL _IOW('c', 11, struct ioc_vol)
205 #define CDIOCSETMONO _IO('c', 12)
206 #define CDIOCSETSTEREO _IO('c', 13)
207 #define CDIOCSETMUTE _IO('c', 14)
208 #define CDIOCSETLEFT _IO('c', 15)
209 #define CDIOCSETRIGHT _IO('c', 16)
210 #define CDIOCSETDEBUG _IO('c', 17)
211 #define CDIOCCLRDEBUG _IO('c', 18)
212 #define CDIOCPAUSE _IO('c', 19)
213 #define CDIOCRESUME _IO('c', 20)
214 #define CDIOCRESET _IO('c', 21)
215 #define CDIOCSTART _IO('c', 22)
216 #define CDIOCSTOP _IO('c', 23)
217 #define CDIOCEJECT _IO('c', 24)
218 #define CDIOCALLOW _IO('c', 25)
219 #define CDIOCPREVENT _IO('c', 26)
220 #define CDIOCCLOSE _IO('c', 27)
221
222 struct ioc_play_msf {
223 u_char start_m;
224 u_char start_s;
225 u_char start_f;
226 u_char end_m;
227 u_char end_s;
228 u_char end_f;
229 };
230 #define CDIOCPLAYMSF _IOW('c', 25, struct ioc_play_msf)
231
232 struct ioc_load_unload {
233 u_char options;
234 #define CD_LU_ABORT 0x1 /* NOTE: These are the same as the ATAPI */
235 #define CD_LU_UNLOAD 0x2 /* op values for the LOAD_UNLOAD command */
236 #define CD_LU_LOAD 0x3
237 u_char slot;
238 };
239 #define CDIOCLOADUNLOAD _IOW('c', 26, struct ioc_load_unload)
240
241 /* DVD definitions */
242
243 /* DVD-ROM Specific ioctls */
244 #define DVD_READ_STRUCT _IOWR('d', 0, union dvd_struct)
245 #define DVD_WRITE_STRUCT _IOWR('d', 1, union dvd_struct)
246 #define DVD_AUTH _IOWR('d', 2, union dvd_authinfo)
247
248 #define GPCMD_READ_DVD_STRUCTURE 0xad
249 #define GPCMD_SEND_DVD_STRUCTURE 0xad
250 #define GPCMD_REPORT_KEY 0xa4
251 #define GPCMD_SEND_KEY 0xa3
252
253 /* DVD struct types */
254 #define DVD_STRUCT_PHYSICAL 0x00
255 #define DVD_STRUCT_COPYRIGHT 0x01
256 #define DVD_STRUCT_DISCKEY 0x02
257 #define DVD_STRUCT_BCA 0x03
258 #define DVD_STRUCT_MANUFACT 0x04
259
260 struct dvd_layer {
261 u_int8_t book_version;
262 u_int8_t book_type;
263 u_int8_t min_rate;
264 u_int8_t disc_size;
265 u_int8_t layer_type;
266 u_int8_t track_path;
267 u_int8_t nlayers;
268 u_int8_t track_density;
269 u_int8_t linear_density;
270 u_int8_t bca;
271 u_int32_t start_sector;
272 u_int32_t end_sector;
273 u_int32_t end_sector_l0;
274 };
275
276 struct dvd_physical {
277 u_int8_t type;
278
279 u_int8_t layer_num;
280 struct dvd_layer layer[4];
281 };
282
283 struct dvd_copyright {
284 u_int8_t type;
285
286 u_int8_t layer_num;
287 u_int8_t cpst;
288 u_int8_t rmi;
289 };
290
291 struct dvd_disckey {
292 u_int8_t type;
293
294 u_int8_t agid;
295 u_int8_t value[2048];
296 };
297
298 struct dvd_bca {
299 u_int8_t type;
300
301 int len;
302 u_int8_t value[188];
303 };
304
305 struct dvd_manufact {
306 u_int8_t type;
307
308 u_int8_t layer_num;
309 int len;
310 u_int8_t value[2048];
311 };
312
313 union dvd_struct {
314 u_int8_t type;
315
316 struct dvd_physical physical;
317 struct dvd_copyright copyright;
318 struct dvd_disckey disckey;
319 struct dvd_bca bca;
320 struct dvd_manufact manufact;
321 };
322
323 /*
324 * DVD authentication ioctl
325 */
326
327 /* Authentication states */
328 #define DVD_LU_SEND_AGID 0
329 #define DVD_HOST_SEND_CHALLENGE 1
330 #define DVD_LU_SEND_KEY1 2
331 #define DVD_LU_SEND_CHALLENGE 3
332 #define DVD_HOST_SEND_KEY2 4
333
334 /* Termination states */
335 #define DVD_AUTH_ESTABLISHED 5
336 #define DVD_AUTH_FAILURE 6
337
338 /* Other functions */
339 #define DVD_LU_SEND_TITLE_KEY 7
340 #define DVD_LU_SEND_ASF 8
341 #define DVD_INVALIDATE_AGID 9
342 #define DVD_LU_SEND_RPC_STATE 10
343 #define DVD_HOST_SEND_RPC_STATE 11
344
345 #if 0
346 /* State data */
347 typedef u_int8_t dvd_key[5]; /* 40-bit value, MSB is first elem. */
348 typedef u_int8_t dvd_challenge[10]; /* 80-bit value, MSB is first elem. */
349 #endif
350
351 #define DVD_KEY_SIZE 5
352 #define DVD_CHALLENGE_SIZE 10
353
354 struct dvd_lu_send_agid {
355 u_int8_t type;
356
357 u_int8_t agid;
358 };
359
360 struct dvd_host_send_challenge {
361 u_int8_t type;
362
363 u_int8_t agid;
364 u_int8_t chal[DVD_CHALLENGE_SIZE];
365 };
366
367 struct dvd_send_key {
368 u_int8_t type;
369
370 u_int8_t agid;
371 u_int8_t key[DVD_KEY_SIZE];
372 };
373
374 struct dvd_lu_send_challenge {
375 u_int8_t type;
376
377 u_int8_t agid;
378 u_int8_t chal[DVD_CHALLENGE_SIZE];
379 };
380
381 #define DVD_CPM_NO_COPYRIGHT 0
382 #define DVD_CPM_COPYRIGHTED 1
383
384 #define DVD_CP_SEC_NONE 0
385 #define DVD_CP_SEC_EXIST 1
386
387 #define DVD_CGMS_UNRESTRICTED 0
388 #define DVD_CGMS_SINGLE 2
389 #define DVD_CGMS_RESTRICTED 3
390
391 struct dvd_lu_send_title_key {
392 u_int8_t type;
393
394 u_int8_t agid;
395 u_int8_t title_key[DVD_KEY_SIZE];
396 int lba;
397 u_int8_t cpm;
398 u_int8_t cp_sec;
399 u_int8_t cgms;
400 };
401
402 struct dvd_lu_send_asf {
403 u_int8_t type;
404
405 u_int8_t agid;
406 u_int8_t asf;
407 };
408
409 struct dvd_host_send_rpcstate {
410 u_int8_t type;
411 u_int8_t pdrc;
412 };
413
414 struct dvd_lu_send_rpcstate {
415 u_int8_t type;
416 u_int8_t vra;
417 u_int8_t ucca;
418 u_int8_t region_mask;
419 u_int8_t rpc_scheme;
420 };
421
422 union dvd_authinfo {
423 u_int8_t type;
424
425 struct dvd_lu_send_agid lsa;
426 struct dvd_host_send_challenge hsc;
427 struct dvd_send_key lsk;
428 struct dvd_lu_send_challenge lsc;
429 struct dvd_send_key hsk;
430 struct dvd_lu_send_title_key lstk;
431 struct dvd_lu_send_asf lsasf;
432 struct dvd_host_send_rpcstate hrpcs;
433 struct dvd_lu_send_rpcstate lrpcs;
434 };
435 #endif /* !_SYS_CDIO_H_ */
Cache object: ae9c68f4a8db65f7c4f668a7cbf90390
|