1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
|
/*
* linux/drivers/ide/ide_cd.h
*
* Copyright (C) 1996-98 Erik Andersen
* Copyright (C) 1998-2000 Jens Axboe
*/
#ifndef _IDE_CD_H
#define _IDE_CD_H
#include <linux/cdrom.h>
#include <asm/byteorder.h>
/* Turn this on to have the driver print out the meanings of the
ATAPI error codes. This will use up additional kernel-space
memory, though. */
#ifndef VERBOSE_IDE_CD_ERRORS
#define VERBOSE_IDE_CD_ERRORS 1
#endif
/* Turning this on will remove code to work around various nonstandard
ATAPI implementations. If you know your drive follows the standard,
this will give you a slightly smaller kernel. */
#ifndef STANDARD_ATAPI
#define STANDARD_ATAPI 0
#endif
/* Turning this on will disable the door-locking functionality.
This is apparently needed for supermount. */
#ifndef NO_DOOR_LOCKING
#define NO_DOOR_LOCKING 0
#endif
/*
* typical timeout for packet command
*/
#define ATAPI_WAIT_PC (60 * HZ)
#define ATAPI_WAIT_WRITE_BUSY (10 * HZ)
/************************************************************************/
#define SECTOR_BITS 9
#ifndef SECTOR_SIZE
#define SECTOR_SIZE (1 << SECTOR_BITS)
#endif
#define SECTORS_PER_FRAME (CD_FRAMESIZE >> SECTOR_BITS)
#define SECTOR_BUFFER_SIZE (CD_FRAMESIZE * 32)
/* Configuration flags. These describe the capabilities of the drive.
They generally do not change after initialization, unless we learn
more about the drive from stuff failing. */
struct ide_cd_config_flags {
__u8 drq_interrupt : 1; /* Device sends an interrupt when ready
for a packet command. */
__u8 no_doorlock : 1; /* Drive cannot lock the door. */
__u8 no_eject : 1; /* Drive cannot eject the disc. */
__u8 nec260 : 1; /* Drive is a pre-1.2 NEC 260 drive. */
__u8 tocaddr_as_bcd : 1; /* TOC addresses are in BCD. */
__u8 toctracks_as_bcd : 1; /* TOC track numbers are in BCD. */
__u8 limit_nframes : 1; /* Drive does not provide data in
multiples of SECTOR_SIZE when more
than one interrupt is needed. */
__u8 seeking : 1; /* Seeking in progress */
__u8 no_speed_select : 1; /* SET_CD_SPEED command is unsupported. */
byte max_speed; /* Max speed of the drive */
};
/* State flags. These give information about the current state of the
drive, and will change during normal operation. */
struct ide_cd_state_flags {
__u8 media_changed : 1; /* Driver has noticed a media change. */
__u8 toc_valid : 1; /* Saved TOC information is current. */
__u8 door_locked : 1; /* We think that the drive door is locked. */
__u8 writing : 1; /* the drive is currently writing */
__u8 reserved : 4;
byte current_speed; /* Current speed of the drive */
};
#define CDROM_STATE_FLAGS(drive) (&(((struct cdrom_info *)(drive->driver_data))->state_flags))
/* Structure of a MSF cdrom address. */
struct atapi_msf {
byte reserved;
byte minute;
byte second;
byte frame;
};
/* Space to hold the disk TOC. */
#define MAX_TRACKS 99
struct atapi_toc_header {
unsigned short toc_length;
byte first_track;
byte last_track;
};
struct atapi_toc_entry {
byte reserved1;
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 adr : 4;
__u8 control : 4;
#elif defined(__LITTLE_ENDIAN_BITFIELD)
__u8 control : 4;
__u8 adr : 4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
byte track;
byte reserved2;
union {
unsigned lba;
struct atapi_msf msf;
} addr;
};
struct atapi_toc {
int last_session_lba;
int xa_flag;
unsigned long capacity;
struct atapi_toc_header hdr;
struct atapi_toc_entry ent[MAX_TRACKS+1];
/* One extra for the leadout. */
};
/* This should probably go into cdrom.h along with the other
* generic stuff now in the Mt. Fuji spec.
*/
struct atapi_capabilities_page {
struct mode_page_header header;
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 parameters_saveable : 1;
__u8 reserved1 : 1;
__u8 page_code : 6;
#elif defined(__LITTLE_ENDIAN_BITFIELD)
__u8 page_code : 6;
__u8 reserved1 : 1;
__u8 parameters_saveable : 1;
#else
#error "Please fix <asm/byteorder.h>"
#endif
byte page_length;
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 reserved2 : 2;
/* Drive supports reading of DVD-RAM discs */
__u8 dvd_ram_read : 1;
/* Drive supports reading of DVD-R discs */
__u8 dvd_r_read : 1;
/* Drive supports reading of DVD-ROM discs */
__u8 dvd_rom : 1;
/* Drive supports reading CD-R discs with addressing method 2 */
__u8 method2 : 1; /* reserved in 1.2 */
/* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */
__u8 cd_rw_read : 1; /* reserved in 1.2 */
/* Drive supports read from CD-R discs (orange book, part II) */
__u8 cd_r_read : 1; /* reserved in 1.2 */
#elif defined(__LITTLE_ENDIAN_BITFIELD)
/* Drive supports read from CD-R discs (orange book, part II) */
__u8 cd_r_read : 1; /* reserved in 1.2 */
/* Drive can read from CD-R/W (CD-E) discs (orange book, part III) */
__u8 cd_rw_read : 1; /* reserved in 1.2 */
/* Drive supports reading CD-R discs with addressing method 2 */
__u8 method2 : 1;
/* Drive supports reading of DVD-ROM discs */
__u8 dvd_rom : 1;
/* Drive supports reading of DVD-R discs */
__u8 dvd_r_read : 1;
/* Drive supports reading of DVD-RAM discs */
__u8 dvd_ram_read : 1;
__u8 reserved2 : 2;
#else
#error "Please fix <asm/byteorder.h>"
#endif
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 reserved3 : 2;
/* Drive can write DVD-RAM discs */
__u8 dvd_ram_write : 1;
/* Drive can write DVD-R discs */
__u8 dvd_r_write : 1;
__u8 reserved3a : 1;
/* Drive can fake writes */
__u8 test_write : 1;
/* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */
__u8 cd_rw_write : 1; /* reserved in 1.2 */
/* Drive supports write to CD-R discs (orange book, part II) */
__u8 cd_r_write : 1; /* reserved in 1.2 */
#elif defined(__LITTLE_ENDIAN_BITFIELD)
/* Drive can write to CD-R discs (orange book, part II) */
__u8 cd_r_write : 1; /* reserved in 1.2 */
/* Drive can write to CD-R/W (CD-E) discs (orange book, part III) */
__u8 cd_rw_write : 1; /* reserved in 1.2 */
/* Drive can fake writes */
__u8 test_write : 1;
__u8 reserved3a : 1;
/* Drive can write DVD-R discs */
__u8 dvd_r_write : 1;
/* Drive can write DVD-RAM discs */
__u8 dvd_ram_write : 1;
__u8 reserved3 : 2;
#else
#error "Please fix <asm/byteorder.h>"
#endif
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 reserved4 : 1;
/* Drive can read multisession discs. */
__u8 multisession : 1;
/* Drive can read mode 2, form 2 data. */
__u8 mode2_form2 : 1;
/* Drive can read mode 2, form 1 (XA) data. */
__u8 mode2_form1 : 1;
/* Drive supports digital output on port 2. */
__u8 digport2 : 1;
/* Drive supports digital output on port 1. */
__u8 digport1 : 1;
/* Drive can deliver a composite audio/video data stream. */
__u8 composite : 1;
/* Drive supports audio play operations. */
__u8 audio_play : 1;
#elif defined(__LITTLE_ENDIAN_BITFIELD)
/* Drive supports audio play operations. */
__u8 audio_play : 1;
/* Drive can deliver a composite audio/video data stream. */
__u8 composite : 1;
/* Drive supports digital output on port 1. */
__u8 digport1 : 1;
/* Drive supports digital output on port 2. */
__u8 digport2 : 1;
/* Drive can read mode 2, form 1 (XA) data. */
__u8 mode2_form1 : 1;
/* Drive can read mode 2, form 2 data. */
__u8 mode2_form2 : 1;
/* Drive can read multisession discs. */
__u8 multisession : 1;
__u8 reserved4 : 1;
#else
#error "Please fix <asm/byteorder.h>"
#endif
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 reserved5 : 1;
/* Drive can return Media Catalog Number (UPC) info. */
__u8 upc : 1;
/* Drive can return International Standard Recording Code info. */
__u8 isrc : 1;
/* Drive supports C2 error pointers. */
__u8 c2_pointers : 1;
/* R-W data will be returned deinterleaved and error corrected. */
__u8 rw_corr : 1;
/* Subchannel reads can return combined R-W information. */
__u8 rw_supported : 1;
/* Drive can continue a read cdda operation from a loss of streaming.*/
__u8 cdda_accurate : 1;
/* Drive can read Red Book audio data. */
__u8 cdda : 1;
#elif defined(__LITTLE_ENDIAN_BITFIELD)
/* Drive can read Red Book audio data. */
__u8 cdda : 1;
/* Drive can continue a read cdda operation from a loss of streaming.*/
__u8 cdda_accurate : 1;
/* Subchannel reads can return combined R-W information. */
__u8 rw_supported : 1;
/* R-W data will be returned deinterleaved and error corrected. */
__u8 rw_corr : 1;
/* Drive supports C2 error pointers. */
__u8 c2_pointers : 1;
/* Drive can return International Standard Recording Code info. */
__u8 isrc : 1;
|