xref: /reactos/drivers/storage/ide/uniata/scsi.h (revision 34593d93)
1 /*++
2 
3 Copyright (c) 2002-2005 Alexandr A. Telyatnikov (Alter)
4 
5 Module Name:
6     scsi.h
7 
8 Abstract:
9     This file contains SCSI protocol definitions
10 
11 Author:
12     Alexander A. Telyatnikov (Alter)
13 
14 Environment:
15     kernel mode only
16 
17 Notes:
18 
19     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 
30 Revision History:
31 
32 --*/
33 #ifndef __CDRW_DEVICE_H__
34 #define __CDRW_DEVICE_H__
35 
36 #include "srb.h"
37 
38 #pragma pack(push, 1)
39 
40 // Command Descriptor Block. Passed by SCSI controller chip over the SCSI bus
41 
42 typedef union _CDB {
43 
44     // Generic 6-Byte CDB
45     struct _CDB6 {
46        UCHAR  OperationCode;
47        UCHAR  Immediate : 1;
48        UCHAR  CommandUniqueBits : 4;
49        UCHAR  Lun : 3;
50        UCHAR  CommandUniqueBytes[3];
51        UCHAR  Link : 1;
52        UCHAR  Flag : 1;
53        UCHAR  Reserved : 4;
54        UCHAR  VendorUnique : 2;
55     } CDB6, *PCDB6;
56 
57     struct _REQUEST_SENSE {
58         UCHAR OperationCode;
59         UCHAR Reserved0 : 5;
60         UCHAR Lun : 3;
61         UCHAR Reserved1[2];
62         UCHAR AllocationLength;
63         UCHAR Link : 1;
64         UCHAR Flag : 1;
65         UCHAR Reserved2 : 6;
66     } REQUEST_SENSE, *PREQUEST_SENSE;
67 
68     // Standard 6-byte CDB
69     struct _CDB6READWRITE {
70         UCHAR OperationCode;
71         UCHAR LBA2 : 5;
72         UCHAR Lun : 3;
73         UCHAR LBA0[2];
74         UCHAR NumOfBlocks;
75         UCHAR Control;
76     } CDB6READWRITE, *PCDB6READWRITE;
77 
78     // SCSI Inquiry CDB
79     struct _CDB6INQUIRY {
80         UCHAR OperationCode;
81         UCHAR Reserved1 : 5;
82         UCHAR Lun : 3;
83         UCHAR PageCode;
84         UCHAR IReserved;
85         UCHAR AllocationLength;
86         UCHAR Control;
87     } CDB6INQUIRY, *PCDB6INQUIRY;
88 
89     // SCSI Format CDB
90 
91     struct _ERASE {
92         UCHAR OperationCode;
93         UCHAR Long : 1;
94         UCHAR Immediate : 1;
95         UCHAR Reserved1 : 3;
96         UCHAR Lun : 3;
97         UCHAR Reserved2[3];
98         UCHAR Control;
99     } ERASE, *PERASE;
100 
101     struct _ERASE10 {
102         UCHAR OperationCode;
103         UCHAR Reserved : 1;
104         UCHAR Immediate : 1;
105         UCHAR ERA : 1;
106         UCHAR Reserved1 : 2;
107         UCHAR Lun : 3;
108         UCHAR LBA[4];
109         UCHAR Reserved2;
110         UCHAR TransferBlocks[2];
111         UCHAR Control;
112     } ERASE10, *PERASE10;
113 
114 #define FormatUnit_Code_Mask    0x07
115 #define FormatUnit_Cmp          0x08
116 #define FormatUnit_Fmt          0x10
117 
118     struct _CDB6FORMAT {
119         UCHAR OperationCode;
120         union {
121             UCHAR Flags;
122             struct {
123                 UCHAR FormatCode : 3;
124                 UCHAR Cmp:1;
125                 UCHAR Fmt:1;
126                 UCHAR Lun : 3;
127             } Fields;
128         } Byte1;
129         UCHAR FReserved1;
130         UCHAR Interleave[2];
131         UCHAR FReserved2;
132     } CDB6FORMAT, *PCDB6FORMAT;
133 
134     // Standard 10-byte CDB
135     struct _CDB10 {
136         UCHAR OperationCode;
137         UCHAR RelativeAddress : 1;
138         UCHAR Reserved1 : 2;
139         UCHAR ForceUnitAccess : 1;
140         UCHAR DisablePageOut : 1;
141         UCHAR Lun : 3;
142         UCHAR LBA[4];
143         UCHAR Reserved2;
144         UCHAR TransferBlocks[2];
145         UCHAR Control;
146     } CDB10, *PCDB10;
147 
148     // Service Action 16-byte CDB
149     struct _SERVICE_ACTION16 {
150         UCHAR OperationCode; // 0x9E
151         UCHAR ServiceAction : 5;
152         UCHAR Reserved1 : 3;
153         UCHAR Data[14];
154     } SERVICE_ACTION16, *PSERVICE_ACTION16;
155 
156     // CD Rom Audio CDBs
157 
158 #define PauseResume_Pause   0x00
159 #define PauseResume_Resume  0x01
160 
161     struct _PAUSE_RESUME {
162         UCHAR OperationCode;
163         UCHAR Reserved1 : 5;
164         UCHAR Lun : 3;
165         UCHAR Reserved2[6];
166         UCHAR Action;
167         UCHAR Control;
168     } PAUSE_RESUME, *PPAUSE_RESUME;
169 
170     // Read Table of Contents (TOC)
171 
172 #define ReadTOC_Format_Mask     0x0f
173 #define ReadTOC_Format_TOC      0x00
174 #define ReadTOC_Format_SesInfo  0x01
175 #define ReadTOC_Format_FullTOC  0x02
176 #define ReadTOC_Format_PMA      0x03
177 #define ReadTOC_Format_ATIP     0x04
178 #define ReadTOC_Format_CdText   0x05
179 
180     struct _READ_TOC {
181         UCHAR OperationCode;
182         UCHAR Reserved0 : 1;
183         UCHAR Msf : 1;  // HMSF MMC-3
184         UCHAR Reserved1 : 3;
185         UCHAR Lun : 3;
186 
187         union {
188             UCHAR Flags;
189             struct {
190                 UCHAR Format : 4;
191                 UCHAR Reserved : 4;
192             } Fields;
193         } Byte2;
194 
195         UCHAR Reserved2[3];
196         UCHAR Start_TrackSes;;
197         UCHAR AllocationLength[2];
198         UCHAR Control : 6;
199         UCHAR Format : 2;
200     } READ_TOC, *PREAD_TOC;
201 
202     // Play Audio MSF
203     struct _PLAY_AUDIO_MSF {
204         UCHAR OperationCode;
205         UCHAR Reserved1 : 5;
206         UCHAR Lun : 3;
207         UCHAR Reserved2;
208         UCHAR StartingMSF[3];
209         UCHAR EndingMSF[3];
210         UCHAR Control;
211     } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
212 
213     // Read SubChannel Data
214 
215 #define SubChannel_SubQ_Header      0x00
216 #define SubChannel_SubQ_Block       0x01
217 
218     struct _SUBCHANNEL {
219         UCHAR OperationCode;
220         UCHAR Reserved0 : 1;
221         UCHAR Msf : 1;
222         UCHAR Reserved1 : 3;
223         UCHAR Lun : 3;
224         UCHAR Reserved2 : 6;
225         UCHAR SubQ : 1;
226         UCHAR Reserved3 : 1;
227         UCHAR Format;
228         UCHAR Reserved4[2];
229         UCHAR TrackNumber;
230         UCHAR AllocationLength[2];
231         UCHAR Control;
232     } SUBCHANNEL, *PSUBCHANNEL;
233 
234     // Read CD (by LBA/MSF). Used by Atapi for raw sector reads.
235 
236 #define ReadCD_SecType_Mask    0x1c
237 #define ReadCD_SecType_Any     0x00
238 #define ReadCD_SecType_CDDA    0x04
239 #define ReadCD_SecType_M1      0x08
240 #define ReadCD_SecType_M2      0x0c
241 #define ReadCD_SecType_M2F1    0x10
242 #define ReadCD_SecType_M2F2    0x14
243 
244     struct _READ_CD_MSF {
245         UCHAR OperationCode;
246 
247         UCHAR Reserved0 : 2;
248         UCHAR ExpectedSectorType : 3;
249         UCHAR Reserved1 : 3;
250 
251         UCHAR Reserved2;
252         UCHAR Starting_MSF[3];
253         UCHAR Ending_MSF[3];
254 
255         UCHAR Reserved3 : 1;
256         UCHAR ErrorFlags : 2;
257         UCHAR IncludeEDC : 1;
258         UCHAR IncludeUserData : 1;
259         UCHAR HeaderCode : 2;
260         UCHAR IncludeSyncData : 1;
261 
262         UCHAR SubChannelSelection : 3;
263         UCHAR Reserved4 : 5;
264 
265         UCHAR Control;
266     } READ_CD_MSF, *PREAD_CD_MSF;
267 
268     struct _READ_CD {
269         UCHAR OperationCode;
270 
271         UCHAR Reserved0 : 2;
272         UCHAR ExpectedSectorType : 3;
273         UCHAR Reserved1 : 3;
274 
275         UCHAR LBA[4];
276         UCHAR NumOfBlocks[3];
277 
278         UCHAR Reserved3 : 1;
279         UCHAR ErrorFlags : 2;
280         UCHAR IncludeEDC : 1;
281         UCHAR IncludeUserData : 1;
282         UCHAR HeaderCode : 2;
283         UCHAR IncludeSyncData : 1;
284 
285         UCHAR SubChannelSelection : 3;
286         UCHAR Reserved4 : 5;
287 
288         UCHAR Control;
289     } READ_CD, *PREAD_CD;
290 
291 #define WriteCd_RELADR  0x01
292 #define WriteCd_FUA     0x08
293 #define WriteCd_DPO     0x10
294 
295     struct _WRITE_CD {
296         UCHAR OperationCode;
297         union {
298             UCHAR Flags;
299             struct {
300                 UCHAR RELADR    : 1;
301                 UCHAR Reserved0 : 2;
302                 UCHAR FUA       : 1;
303                 UCHAR DPO       : 1;
304                 UCHAR Reserved1 : 3;
305             } Fields;
306         } Byte1;
307         UCHAR LBA [4];
308         UCHAR Reserved1;
309         UCHAR NumOfBlocks [2];
310         UCHAR Reserved2 [3];
311     } WRITE_CD, *PWRITE_CD;
312 
313     // Mode sense
314     struct _MODE_SENSE {
315         UCHAR OperationCode;
316         UCHAR Reserved1 : 3;
317         UCHAR Dbd : 1;
318         UCHAR Reserved2 : 1;
319         UCHAR Lun : 3;
320         UCHAR PageCode : 6;
321         UCHAR Pc : 2;
322         UCHAR Reserved3;
323         UCHAR AllocationLength;
324         UCHAR Control;
325     } MODE_SENSE, *PMODE_SENSE;
326 
327     struct _MODE_SENSE10 {
328         UCHAR OperationCode;
329         UCHAR Reserved1 : 3;
330         UCHAR Dbd : 1;
331         UCHAR Reserved2 : 1;
332         UCHAR Lun : 3;
333         UCHAR PageCode : 6;
334         UCHAR Pc : 2;
335         UCHAR Reserved3[4];
336         UCHAR AllocationLength[2];
337         UCHAR Control;
338     } MODE_SENSE10, *PMODE_SENSE10;
339 
340     // Mode select
341     struct _MODE_SELECT {
342         UCHAR OperationCode;
343         UCHAR SPBit : 1;
344         UCHAR Reserved1 : 3;
345         UCHAR PFBit : 1;
346         UCHAR Lun : 3;
347         UCHAR Reserved2[2];
348         UCHAR ParameterListLength;
349         UCHAR Control;
350     } MODE_SELECT, *PMODE_SELECT;
351 
352     struct _MODE_SELECT10 {
353         UCHAR OperationCode;
354         UCHAR SPBit : 1;
355         UCHAR Reserved1 : 3;
356         UCHAR PFBit : 1;
357         UCHAR Lun : 3;
358         UCHAR Reserved2[5];
359         UCHAR ParameterListLength[2];
360         UCHAR Control;
361     } MODE_SELECT10, *PMODE_SELECT10;
362 
363     struct _LOGSENSE {
364         UCHAR OperationCode;
365         UCHAR SPBit : 1;
366         UCHAR PPCBit : 1;
367         UCHAR Reserved1 : 3;
368         UCHAR Lun : 3;
369         UCHAR PageCode : 6;
370         UCHAR PCBit : 2;
371         UCHAR Reserved2;
372         UCHAR Reserved3;
373         UCHAR ParameterPointer[2];  // [0]=MSB, [1]=LSB
374         UCHAR AllocationLength[2];  // [0]=MSB, [1]=LSB
375         UCHAR Control;
376     } LOGSENSE, *PLOGSENSE;
377 
378     struct _SEEK {
379         UCHAR OperationCode;
380         UCHAR Reserved1 : 5;
381         UCHAR Lun : 3;
382         UCHAR LBA[4];
383         UCHAR Reserved2[3];
384         UCHAR Control;
385     } SEEK, *PSEEK;
386 
387 #define StartStop_Start     0x01
388 #define StartStop_Load      0x02
389 
390     struct _START_STOP {
391         UCHAR OperationCode;
392         UCHAR Immediate: 1;
393         UCHAR Reserved1 : 4;
394         UCHAR Lun : 3;
395         UCHAR Reserved2;
396         UCHAR FormatLayerNumber : 2;
397         UCHAR Reserved2_2 : 6;
398         UCHAR Start : 1;
399         UCHAR LoadEject : 1;
400         UCHAR FL : 1;
401         UCHAR Reserved3 : 1;
402         UCHAR PowerConditions : 4;
403         UCHAR Control;
404     } START_STOP, *PSTART_STOP;
405 
406 #define StartStop_Power_NoChg    0x00
407 #define StartStop_Power_Idle     0x02
408 #define StartStop_Power_Standby  0x03
409 #define StartStop_Power_Sleep    0x05
410 
411     struct _MEDIA_REMOVAL {
412         UCHAR OperationCode;
413         UCHAR Reserved1 : 5;
414         UCHAR Lun : 3;
415         UCHAR Reserved2[2];
416         UCHAR Prevent;
417         UCHAR Control;
418     } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
419 
420     struct _READ_FORMAT_CAPACITIES {
421         UCHAR OperationCode;
422         union {
423             UCHAR Flags;
424             struct {
425                 UCHAR Reserved0 : 5;
426                 UCHAR Reserved1 : 3;
427             } Fields;
428         } Byte1;
429         UCHAR Reserved0[5];
430         UCHAR AllocationLength[2];
431         UCHAR Control;
432     } READ_FORMAT_CAPACITIES, *PREAD_FORMAT_CAPACITIES;
433 
434     // Atapi 2.5 Changer 12-byte CDBs
435 #define LoadUnload_Start    0x01
436 #define LoadUnload_Load     0x02
437 
438     struct _LOAD_UNLOAD {
439         UCHAR OperationCode;
440         UCHAR Immediate : 1;
441         UCHAR Reserved1 : 7;
442         UCHAR Reserved2[2];
443         UCHAR Start : 1;
444         UCHAR LoadEject : 1;
445         UCHAR Reserved3: 6;
446         UCHAR Reserved4[3];
447         UCHAR Slot;
448         UCHAR Reserved5[3];
449     } LOAD_UNLOAD, *PLOAD_UNLOAD;
450 
451     struct _MECH_STATUS {
452         UCHAR OperationCode;
453         UCHAR Reserved0[7];
454         UCHAR AllocationLength[2];
455         UCHAR Reserved2[2];
456     } MECH_STATUS, *PMECH_STATUS;
457 
458     struct _LOCK_DOOR {
459         UCHAR OperationCode;
460         UCHAR Reserved0[9];
461     } LOCK_DOOR, *PLOCK_DOOR;
462 
463 #define EventStat_Immed             0x01
464 
465 #define EventStat_Class_OpChange    0x02
466 #define EventStat_Class_PM          0x04
467 #define EventStat_Class_ExternalReq 0x08
468 #define EventStat_Class_Media       0x10
469 #define EventStat_Class_MultiInit   0x20
470 #define EventStat_Class_DevBusy     0x40
471 
472     struct _GET_EVENT_STATUS {
473         UCHAR OperationCode;
474         union {
475             UCHAR Flags;
476             struct {
477                 UCHAR Immed     : 1;
478                 UCHAR Reserved0 : 7;
479             } Fields;
480         } Byte1;
481         UCHAR Reserved0[2];
482         UCHAR NotificationClass;
483         UCHAR Reserved1[2];
484         UCHAR AllocationLength[2];
485         UCHAR Control;
486     } GET_EVENT_STATUS, *PGET_EVENT_STATUS;
487 
488     struct _READ_DISC_INFO {
489         UCHAR OperationCode;
490         UCHAR Reserved0[6];
491         UCHAR AllocationLength[2];
492         UCHAR Reserved2[3];
493     } READ_DISC_INFO, *PREAD_DISC_INFO;
494 
495 #define ReadTrackInfo_Type_Mask    0x01
496 #define ReadTrackInfo_Type_LBA     0x00
497 #define ReadTrackInfo_Type_Track   0x01
498 
499 #define ReadTrackInfo_LastTrk      0xff
500 
501     struct _READ_TRACK_INFO {
502         UCHAR OperationCode;
503         UCHAR Track     : 1;
504         UCHAR Reserved0 : 7;
505         UCHAR LBA_TrkNum [4];
506         UCHAR Reserved1;
507         UCHAR AllocationLength[2];
508         UCHAR Reserved2[3];
509     } READ_TRACK_INFO, *PREAD_TRACK_INFO;
510 
511 #define ReadTrackInfo3_Type_Mask    0x03
512 #define ReadTrackInfo3_Type_LBA     ReadTrackInfo_Type_LBA
513 #define ReadTrackInfo3_Type_Track   ReadTrackInfo_Type_Track
514 #define ReadTrackInfo3_Type_Ses     0x02
515 
516 #define ReadTrackInfo3_LastTrk      ReadTrackInfo_LastTrk
517 #define ReadTrackInfo3_DiscLeadIn   0x00  // for Track type
518 
519     struct _READ_TRACK_INFO_3 {
520         UCHAR OperationCode;
521         UCHAR DataType     : 2;
522         UCHAR Reserved0 : 6;
523         UCHAR LBA_TrkNum [4];
524         UCHAR Reserved1;
525         UCHAR AllocationLength[2];
526         UCHAR Reserved2[3];
527     } READ_TRACK_INFO_3, *PREAD_TRACK_INFO_3;
528 
529     struct _RESERVE_TRACK {
530         UCHAR OperationCode;
531         UCHAR Reserved0[4];
532         UCHAR Size[4];
533         UCHAR Reserved2[3];
534     } RESERVE_TRACK, *PRESERVE_TRACK;
535 
536 #define CloseTrkSes_Immed   0x01
537 
538 #define CloseTrkSes_Trk   0x01
539 #define CloseTrkSes_Ses   0x02
540 
541 #define CloseTrkSes_LastTrkSes  0xff
542 
543 #define CloseTrkSes_Delay   DEF_I64(3100000000)        //  310 s
544 
545     struct _CLOSE_TRACK_SESSION {
546         UCHAR OperationCode;
547         union {
548             UCHAR Flags;
549             struct {
550                 UCHAR Immed     : 1;
551                 UCHAR Reserved0 : 7;
552             } Fields;
553         } Byte1;
554         union {
555             UCHAR Flags;
556             struct {
557                 UCHAR Track     : 1;
558                 UCHAR Session   : 1;
559                 UCHAR Reserved0 : 6;
560             } Fields;
561         } Byte2;
562         UCHAR Reserved1 [2];
563         UCHAR TrackNum;
564         UCHAR Reserved2 [6];
565 
566     } CLOSE_TRACK_SESSION, *PCLOSE_TRACK_SESSION;
567 
568     struct _SET_CD_SPEED {
569         UCHAR OperationCode;
570         UCHAR Reserved0;
571         UCHAR ReadSpeed [2];        // Kbyte/sec
572         UCHAR WriteSpeed [2];        // Kbyte/sec
573         UCHAR Reserved1[6];
574     } SET_CD_SPEED, *PSET_CD_SPEED;
575 
576 #define SyncCache_RELADR        0x01
577 #define SyncCache_Immed         0x02
578 
579     struct _SYNCHRONIZE_CACHE {
580         UCHAR OperationCode;
581         union {
582             UCHAR Flags;
583             struct {
584                 UCHAR RELADR    : 1;
585                 UCHAR Immed     : 1;
586                 UCHAR Reserved0 : 6;            // All these are unused by drive
587             } Fields;
588         } Byte1;
589         UCHAR LBA [4];
590         UCHAR Reserved1;
591         UCHAR NumOfBlocks [2];
592         UCHAR Reserved2 [3];
593 /*
594         UCHAR Unused [11];*/
595     } SYNCHRONIZE_CACHE, *PSYNCHRONIZE_CACHE;
596 
597 #define BlankMedia_Mask             0x07
598 #define BlankMedia_Complete         0x00
599 #define BlankMedia_Minimal          0x01
600 #define BlankMedia_Track            0x02
601 #define BlankMedia_UnreserveTrack   0x03
602 #define BlankMedia_TrackTail        0x04
603 #define BlankMedia_UncloseLastSes   0x05
604 #define BlankMedia_EraseSes         0x06
605 #define BlankMedia_Immed            0x10
606 
607     struct _BLANK_MEDIA {
608         UCHAR OperationCode;
609         union {
610             UCHAR Flags;
611             struct {
612                 UCHAR BlankType : 3;
613                 UCHAR Reserved0 : 1;
614                 UCHAR Immed     : 1;
615                 UCHAR Reserved1 : 3;
616             } Fields;
617         } Byte1;
618         UCHAR StartAddr_TrkNum [4];
619         UCHAR Reserved2 [6];
620     } BLANK_MEDIA, *PBLANK_MEDIA;
621 
622 #define SendKey_ReportAGID            0x00
623 #define SendKey_ChallengeKey          0x01
624 #define SendKey_Key1                  0x02
625 #define SendKey_Key2                  0x03
626 #define SendKey_TitleKey              0x04
627 #define SendKey_ReportASF             0x05
628 #define SendKey_InvalidateAGID        0x3F
629 
630     struct _SEND_KEY {
631         UCHAR OperationCode;
632         UCHAR Reserved1 : 5;
633         UCHAR Lun : 3;
634         UCHAR Reserved2[6];
635         UCHAR ParameterListLength[2];
636         UCHAR KeyFormat : 6;
637         UCHAR AGID : 2;
638         UCHAR Control;
639     } SEND_KEY, *PSEND_KEY;
640 
641     struct _REPORT_KEY {
642         UCHAR OperationCode;    // 0xA4
643         UCHAR Reserved1 : 5;
644         UCHAR Lun : 3;
645         UCHAR LBA[4];           // for title key
646         UCHAR Reserved2[2];
647         UCHAR AllocationLength[2];
648         UCHAR KeyFormat : 6;
649         UCHAR AGID : 2;
650         UCHAR Control;
651     } REPORT_KEY, *PREPORT_KEY;
652 
653     struct _READ_DVD_STRUCTURE {
654         UCHAR OperationCode;    // 0xAD
655         UCHAR Reserved1 : 5;
656         UCHAR Lun : 3;
657         UCHAR RMDBlockNumber[4];
658         UCHAR LayerNumber;
659         UCHAR Format;
660         UCHAR AllocationLength[2];  // [0]=MSB, [1]=LSB
661         UCHAR Reserved3 : 6;
662         UCHAR AGID : 2;
663         UCHAR Control;
664     } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
665 
666     struct _READ_BUFFER_CAPACITY {
667         UCHAR OperationCode;
668         UCHAR Reserved0 [6];
669         UCHAR AllocationLength[2];
670         UCHAR Reserved1 [3];
671     } READ_BUFFER_CAPACITY, *PREAD_BUFFER_CAPACITY;
672 
673     struct _GET_CONFIGURATION {
674         UCHAR OperationCode;
675         union {
676             UCHAR Flags;
677             struct {
678                 UCHAR RT        : 2;
679                 UCHAR Reserved0 : 6;
680             } Fields;
681         } Byte1;
682         UCHAR StartFeatureNum [2];
683         UCHAR Reserved0 [3];
684         UCHAR AllocationLength[2];
685         UCHAR Control;
686     } GET_CONFIGURATION, *PGET_CONFIGURATION;
687 
688     struct _SET_READ_AHEAD {
689         UCHAR OperationCode;
690         UCHAR Reserved0;
691         UCHAR TriggerLBA[4];
692         UCHAR ReadAheadLBA[4];
693         UCHAR Reserved1;
694         UCHAR Control;
695     } SET_READ_AHEAD, *PSET_READ_AHEAD;
696 
697     struct _REPORT_LUNS {
698         UCHAR OperationCode;    // 0xA0 - SCSIOP_REPORT_LUNS
699         UCHAR Reserved1[5];
700         UCHAR AllocationLength[4];
701         UCHAR Reserved2[1];
702         UCHAR Control;
703     } REPORT_LUNS, *PREPORT_LUNS;
704 
705 #define SendOpc_DoOpc   0x01
706 
707     struct _SEND_OPC_INFO {
708         UCHAR OperationCode;
709         union {
710             UCHAR Flags;
711             struct {
712                 UCHAR DoOpc     : 1;
713                 UCHAR Reserved0 : 4;
714                 UCHAR Reserved1 : 3;
715             } Fields;
716         } Byte1;
717         UCHAR Reserved0 [5];
718         UCHAR AllocationLength[2];
719         UCHAR Control;
720     } SEND_OPC_INFO, *PSEND_OPC_INFO;
721 
722     struct _SEND_CUE_SHEET {
723         UCHAR OperationCode;
724         UCHAR Reserved0 [5];
725         UCHAR AllocationLength[3];
726         UCHAR Control;
727     } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
728 
729     struct _CDB12 {
730         UCHAR OperationCode;
731         UCHAR Params[11];
732     } CDB12, *PCDB12;
733 
734     struct _CDB12READWRITE {
735         UCHAR OperationCode;
736         union {
737             UCHAR Flags;
738             struct {
739                 UCHAR RELADR    : 1;
740                 UCHAR Reserved0 : 2;
741                 UCHAR FUA       : 1;
742                 UCHAR DPO       : 1;
743                 UCHAR Reserved1 : 3;
744             } Fields;
745         } Byte1;
746         UCHAR LBA [4];
747         UCHAR NumOfBlocks [4];
748         UCHAR Reserved1[2];
749     } CDB12READWRITE, *PCDB12READWRITE;
750 
751     struct _CDB16READWRITE {
752         UCHAR OperationCode;
753         union {
754             UCHAR Flags;
755             struct {
756                 UCHAR RELADR    : 1;
757                 UCHAR Reserved0 : 2;
758                 UCHAR FUA       : 1;
759                 UCHAR DPO       : 1;
760                 UCHAR Reserved1 : 3;
761             } Fields;
762         } Byte1;
763         UCHAR LBA [8];
764         UCHAR NumOfBlocks [4];
765         UCHAR GroupNumber:5;
766         UCHAR Reserved14_5_6:2;
767         UCHAR Restricted:1; // MMC-4
768         UCHAR Reserved1[1];
769     } CDB16READWRITE, *PCDB16READWRITE;
770 
771     // Plextor Read CD-DA
772     struct _PLXTR_READ_CDDA {
773         UCHAR OperationCode;
774         UCHAR Reserved0 : 5;
775         UCHAR Lun :3;
776         UCHAR LBA[4];
777         UCHAR TransferBlock[4];
778         UCHAR SubCode;
779         UCHAR Control;
780     } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
781 
782     // NEC Read CD-DA
783     struct _NEC_READ_CDDA {
784         UCHAR OperationCode;
785         UCHAR Reserved0;
786         UCHAR LBA[4];
787         UCHAR Reserved1;
788         UCHAR TransferBlock[2];
789         UCHAR Control;
790     } NEC_READ_CDDA, *PNEC_READ_CDDA;
791 
792 } CDB, *PCDB;
793 
794 // Command Descriptor Block constants.
795 
796 #define CDB6GENERIC_LENGTH                  6
797 #define CDB10GENERIC_LENGTH                 10
798 #define CDB12GENERIC_LENGTH                 12
799 
800 #define MAXIMUM_NUMBER_OF_TRACKS            100
801 #define MAXIMUM_NUMBER_OF_SESSIONS          1024    //maximal number of entries in Read Full TOC
802 
803 #define SETBITON                            1
804 #define SETBITOFF                           0
805 
806 // Mode Sense/Select page constants.
807 
808 #define MODE_PAGE_ERROR_RECOVERY        0x01
809 #define MODE_PAGE_WRITE_PARAMS          0x05
810 #define MODE_PAGE_VERIFY_ERROR          0x07        // shall not be used
811 #define MODE_PAGE_CACHING               0x08        // undocumented, but used by DirectCd
812 #define MODE_PAGE_MEDIUM_TYPES          0x0B        // shall not be used
813 #define MODE_PAGE_CD_DEVICE_PARAMS      0x0D
814 #define MODE_PAGE_CD_AUDIO_CONTROL      0x0E
815 #define MODE_PAGE_POWER_CONDITION       0x1A
816 #define MODE_PAGE_FAIL_REPORT           0x1C
817 #define MODE_PAGE_TIMEOUT_AND_PROTECT   0x1D
818 #define MODE_PAGE_PHILIPS_SECTOR_TYPE   0x21
819 #define MODE_PAGE_CAPABILITIES          0x2A
820 
821 #define MODE_SENSE_RETURN_ALL           0x3f
822 
823 #define MODE_SENSE_CURRENT_VALUES       0x00
824 #define MODE_SENSE_CHANGEABLE_VALUES    0x40
825 #define MODE_SENSE_DEFAULT_VAULES       0x80
826 #define MODE_SENSE_SAVED_VALUES         0xc0
827 
828 // SCSI CDB operation codes
829 
830 #define SCSIOP_TEST_UNIT_READY      0x00
831 #define SCSIOP_REZERO_UNIT          0x01
832 #define SCSIOP_REWIND               0x01
833 #define SCSIOP_REQUEST_BLOCK_ADDR   0x02
834 #define SCSIOP_REQUEST_SENSE        0x03
835 #define SCSIOP_FORMAT_UNIT          0x04
836 #define SCSIOP_READ_BLOCK_LIMITS    0x05
837 #define SCSIOP_REASSIGN_BLOCKS      0x07
838 #define SCSIOP_READ6                0x08
839 #define SCSIOP_RECEIVE              0x08
840 #define SCSIOP_WRITE6               0x0A
841 #define SCSIOP_PRINT                0x0A
842 #define SCSIOP_SEND                 0x0A
843 #define SCSIOP_SEEK6                0x0B
844 #define SCSIOP_TRACK_SELECT         0x0B
845 #define SCSIOP_SLEW_PRINT           0x0B
846 #define SCSIOP_SEEK_BLOCK           0x0C
847 #define SCSIOP_PARTITION            0x0D
848 #define SCSIOP_READ_REVERSE         0x0F
849 #define SCSIOP_WRITE_FILEMARKS      0x10
850 #define SCSIOP_FLUSH_BUFFER         0x10
851 #define SCSIOP_SPACE                0x11
852 #define SCSIOP_INQUIRY              0x12
853 #define SCSIOP_VERIFY6              0x13
854 #define SCSIOP_RECOVER_BUF_DATA     0x14
855 #define SCSIOP_MODE_SELECT          0x15
856 #define SCSIOP_RESERVE_UNIT         0x16
857 #define SCSIOP_RELEASE_UNIT         0x17
858 #define SCSIOP_COPY                 0x18
859 #define SCSIOP_ERASE                0x19
860 #define SCSIOP_MODE_SENSE           0x1A
861 #define SCSIOP_START_STOP_UNIT      0x1B
862 #define SCSIOP_STOP_PRINT           0x1B
863 #define SCSIOP_LOAD_UNLOAD          0x1B
864 #define SCSIOP_RECEIVE_DIAGNOSTIC   0x1C
865 #define SCSIOP_SEND_DIAGNOSTIC      0x1D
866 #define SCSIOP_MEDIUM_REMOVAL       0x1E
867 #define SCSIOP_READ_FORMAT_CAPACITY 0x23
868 #define SCSIOP_READ_CAPACITY        0x25
869 #define SCSIOP_READ                 0x28
870 #define SCSIOP_WRITE                0x2A
871 #define SCSIOP_WRITE_CD             0x2A
872 #define SCSIOP_SEEK                 0x2B
873 #define SCSIOP_LOCATE               0x2B
874 #define SCSIOP_ERASE10              0x2C
875 #define SCSIOP_WRITE_VERIFY         0x2E
876 #define SCSIOP_VERIFY               0x2F
877 #define SCSIOP_SEARCH_DATA_HIGH     0x30
878 #define SCSIOP_SEARCH_DATA_EQUAL    0x31
879 #define SCSIOP_SEARCH_DATA_LOW      0x32
880 #define SCSIOP_SET_LIMITS           0x33
881 #define SCSIOP_READ_POSITION        0x34
882 #define SCSIOP_SYNCHRONIZE_CACHE    0x35
883 #define SCSIOP_COMPARE              0x39
884 #define SCSIOP_COPY_COMPARE         0x3A
885 #define SCSIOP_COPY_VERIFY          0x3A
886 #define SCSIOP_WRITE_DATA_BUFF      0x3B
887 #define SCSIOP_READ_DATA_BUFF       0x3C
888 #define SCSIOP_CHANGE_DEFINITION    0x40
889 #define SCSIOP_PLAY_AUDIO10         0x41
890 #define SCSIOP_READ_SUB_CHANNEL     0x42
891 #define SCSIOP_READ_TOC             0x43
892 #define SCSIOP_READ_HEADER          0x44
893 #define SCSIOP_PLAY_AUDIO           0x45
894 #define SCSIOP_GET_CONFIGURATION    0x46
895 #define SCSIOP_PLAY_AUDIO_MSF       0x47
896 #define SCSIOP_PLAY_TRACK_INDEX     0x48
897 #define SCSIOP_PLAY_TRACK_RELATIVE  0x49
898 #define SCSIOP_GET_EVENT_STATUS     0x4A
899 #define SCSIOP_PAUSE_RESUME         0x4B
900 #define SCSIOP_LOG_SELECT           0x4C
901 #define SCSIOP_LOG_SENSE            0x4D
902 #define SCSIOP_STOP_PLAY_SCAN       0x4E
903 #define SCSIOP_READ_DISC_INFO       0x51
904 #define SCSIOP_READ_TRACK_INFO      0x52
905 #define SCSIOP_RESERVE_TRACK        0x53
906 #define SCSIOP_SEND_OPC_INFO        0x54
907 #define SCSIOP_MODE_SELECT10        0x55
908 #define SCSIOP_REPAIR_TRACK         0x58    // obsolete
909 #define SCSIOP_READ_MASTER_CUE      0x59
910 #define SCSIOP_MODE_SENSE10         0x5A
911 #define SCSIOP_CLOSE_TRACK_SESSION  0x5B
912 #define SCSIOP_READ_BUFFER_CAPACITY 0x5C
913 #define SCSIOP_SEND_CUE_SHEET       0x5D
914 #define SCSIOP_READ16               0x88
915 #define SCSIOP_WRITE16              0x8A
916 #define SCSIOP_VERIFY16             0x8F
917 #define SCSIOP_SERVICE_ACTION16     0x9E
918 
919   #define SCSIOP_SA_READ_CAPACITY16     0x10
920 
921 #define SCSIOP_REPORT_LUNS          0xA0
922 #define SCSIOP_BLANK                0xA1
923 #define SCSIOP_SEND_KEY             0xA3
924 #define SCSIOP_REPORT_KEY           0xA4
925 #define SCSIOP_PLAY_AUDIO12         0xA5
926 #define SCSIOP_LOAD_UNLOAD_SLOT     0xA6
927 #define SCSIOP_SET_READ_AHEAD       0xA7
928 #define SCSIOP_READ12               0xA8
929 #define SCSIOP_WRITE12              0xAA
930 #define SCSIOP_VERIFY12             0xAF
931 #define SCSIOP_SEEK12               0xAB
932 #define SCSIOP_GET_PERFORMANCE      0xAC
933 #define SCSIOP_READ_DVD_STRUCTURE   0xAD
934 #define SCSIOP_WRITE_VERIFY12       0xAE
935 #define SCSIOP_VERIFY12             0xAF
936 #define SCSIOP_SET_STREAMING        0xB6
937 #define SCSIOP_READ_CD_MSF          0xB9
938 #define SCSIOP_SET_CD_SPEED         0xBB
939 #define SCSIOP_MECHANISM_STATUS     0xBD
940 #define SCSIOP_READ_CD              0xBE
941 #define SCSIOP_SEND_DVD_STRUCTURE   0xBF
942 #define SCSIOP_DOORLOCK             0xDE    // lock door on removable drives
943 #define SCSIOP_DOORUNLOCK           0xDF    // unlock door on removable drives
944 
945 // If the IMMED bit is 1, status is returned as soon
946 // as the operation is initiated. If the IMMED bit
947 // is 0, status is not returned until the operation
948 // is completed.
949 
950 #define CDB_RETURN_ON_COMPLETION   0
951 #define CDB_RETURN_IMMEDIATE       1
952 
953 // end_ntminitape
954 
955 // CDB Force media access used in extended read and write commands.
956 
957 #define CDB_FORCE_MEDIA_ACCESS 0x08
958 
959 // Denon CD ROM operation codes
960 
961 #define SCSIOP_DENON_EJECT_DISC    0xE6
962 #define SCSIOP_DENON_STOP_AUDIO    0xE7
963 #define SCSIOP_DENON_PLAY_AUDIO    0xE8
964 #define SCSIOP_DENON_READ_TOC      0xE9
965 #define SCSIOP_DENON_READ_SUBCODE  0xEB
966 
967 // Philips/Matshushita CD-R(W) operation codes
968 
969 #define SCSIOP_PHILIPS_GET_NWA                0xE2
970 #define SCSIOP_PHILIPS_RESERVE_TRACK          0xE4
971 #define SCSIOP_PHILIPS_WRITE_TRACK            0xE6
972 #define SCSIOP_PHILIPS_LOAD_UNLOAD            0xE7
973 #define SCSIOP_PHILIPS_CLOSE_TRACK_SESSION    0xE9
974 #define SCSIOP_PHILIPS_RECOVER_BUF_DATA       0xEC
975 #define SCSIOP_PHILIPS_READ_SESSION_INFO      0xEE
976 
977 // Plextor operation codes
978 
979 #define SCSIOP_PLEXTOR_READ_CDDA   0xD8
980 
981 // NEC operation codes
982 
983 #define SCSIOP_NEC_READ_CDDA       0xD4
984 
985 // SCSI Bus Messages
986 
987 #define SCSIMESS_ABORT                0x06
988 #define SCSIMESS_ABORT_WITH_TAG       0x0D
989 #define SCSIMESS_BUS_DEVICE_RESET     0X0C
990 #define SCSIMESS_CLEAR_QUEUE          0X0E
991 #define SCSIMESS_COMMAND_COMPLETE     0X00
992 #define SCSIMESS_DISCONNECT           0X04
993 #define SCSIMESS_EXTENDED_MESSAGE     0X01
994 #define SCSIMESS_IDENTIFY             0X80
995 #define SCSIMESS_IDENTIFY_WITH_DISCON 0XC0
996 #define SCSIMESS_IGNORE_WIDE_RESIDUE  0X23
997 #define SCSIMESS_INITIATE_RECOVERY    0X0F
998 #define SCSIMESS_INIT_DETECTED_ERROR  0X05
999 #define SCSIMESS_LINK_CMD_COMP        0X0A
1000 #define SCSIMESS_LINK_CMD_COMP_W_FLAG 0X0B
1001 #define SCSIMESS_MESS_PARITY_ERROR    0X09
1002 #define SCSIMESS_MESSAGE_REJECT       0X07
1003 #define SCSIMESS_NO_OPERATION         0X08
1004 #define SCSIMESS_HEAD_OF_QUEUE_TAG    0X21
1005 #define SCSIMESS_ORDERED_QUEUE_TAG    0X22
1006 #define SCSIMESS_SIMPLE_QUEUE_TAG     0X20
1007 #define SCSIMESS_RELEASE_RECOVERY     0X10
1008 #define SCSIMESS_RESTORE_POINTERS     0X03
1009 #define SCSIMESS_SAVE_DATA_POINTER    0X02
1010 #define SCSIMESS_TERMINATE_IO_PROCESS 0X11
1011 
1012 // SCSI Extended Message operation codes
1013 
1014 #define SCSIMESS_MODIFY_DATA_POINTER  0X00
1015 #define SCSIMESS_SYNCHRONOUS_DATA_REQ 0X01
1016 #define SCSIMESS_WIDE_DATA_REQUEST    0X03
1017 
1018 // SCSI Extended Message Lengths
1019 
1020 #define SCSIMESS_MODIFY_DATA_LENGTH   5
1021 #define SCSIMESS_SYNCH_DATA_LENGTH    3
1022 #define SCSIMESS_WIDE_DATA_LENGTH     2
1023 
1024 // SCSI extended message structure
1025 
1026 typedef struct _SCSI_EXTENDED_MESSAGE {
1027     UCHAR InitialMessageCode;
1028     UCHAR MessageLength;
1029     UCHAR MessageType;
1030     union _EXTENDED_ARGUMENTS {
1031 
1032         struct {
1033             UCHAR Modifier[4];
1034         } Modify;
1035 
1036         struct {
1037             UCHAR TransferPeriod;
1038             UCHAR ReqAckOffset;
1039         } Synchronous;
1040 
1041         struct{
1042             UCHAR Width;
1043         } Wide;
1044     }ExtendedArguments;
1045 }SCSI_EXTENDED_MESSAGE, *PSCSI_EXTENDED_MESSAGE;
1046 
1047 // SCSI bus status codes.
1048 
1049 #define SCSISTAT_GOOD                  0x00
1050 #define SCSISTAT_CHECK_CONDITION       0x02
1051 #define SCSISTAT_CONDITION_MET         0x04
1052 #define SCSISTAT_BUSY                  0x08
1053 #define SCSISTAT_INTERMEDIATE          0x10
1054 #define SCSISTAT_INTERMEDIATE_COND_MET 0x14
1055 #define SCSISTAT_RESERVATION_CONFLICT  0x18
1056 #define SCSISTAT_COMMAND_TERMINATED    0x22
1057 #define SCSISTAT_QUEUE_FULL            0x28
1058 
1059 // Enable Vital Product Data Flag (EVPD)
1060 // used with INQUIRY command.
1061 
1062 #define CDB_INQUIRY_EVPD           0x01
1063 
1064 // retry time (in deci-seconds)
1065 #define NOT_READY_RETRY_INTERVAL    20
1066 
1067 // Defines for format CDB
1068 #define LUN0_FORMAT_SAVING_DEFECT_LIST 0
1069 #define USE_DEFAULTMSB  0
1070 #define USE_DEFAULTLSB  0
1071 
1072 #define START_UNIT_CODE 0x01
1073 #define STOP_UNIT_CODE  0x00
1074 
1075 // Inquiry buffer structure. This is the data returned from the target
1076 // after it receives an inquiry.
1077 //
1078 // This structure may be extended by the number of bytes specified
1079 // in the field AdditionalLength. The defined size constant only
1080 // includes fields through ProductRevisionLevel.
1081 //
1082 // The NT SCSI drivers are only interested in the first 36 bytes of data.
1083 
1084 #define INQUIRYDATABUFFERSIZE 36
1085 
1086 typedef struct _INQUIRYDATA {
1087     UCHAR DeviceType : 5;
1088     UCHAR DeviceTypeQualifier : 3;
1089     UCHAR DeviceTypeModifier : 7;
1090     UCHAR RemovableMedia : 1;
1091     UCHAR Versions;
1092     UCHAR ResponseDataFormat;
1093     UCHAR AdditionalLength;
1094     UCHAR Reserved[2];
1095     UCHAR SoftReset : 1;
1096     UCHAR CommandQueue : 1;
1097     UCHAR Reserved2 : 1;
1098     UCHAR LinkedCommands : 1;
1099     UCHAR Synchronous : 1;
1100     UCHAR Wide16Bit : 1;
1101     UCHAR Wide32Bit : 1;
1102     UCHAR RelativeAddressing : 1;
1103     union {
1104     UCHAR DeviceIdentificationString[28];
1105         struct {
1106             UCHAR VendorId[8];
1107             UCHAR ProductId[16];
1108             UCHAR ProductRevisionLevel[4];
1109         };
1110     };
1111     UCHAR VendorSpecific[20];
1112     UCHAR Reserved3[40];
1113 } INQUIRYDATA, *PINQUIRYDATA;
1114 
1115 // Inquiry defines. Used to interpret data returned from target as result
1116 // of inquiry command.
1117 
1118 // DeviceType field
1119 
1120 #define DIRECT_ACCESS_DEVICE            0x00    // disks
1121 #define SEQUENTIAL_ACCESS_DEVICE        0x01    // tapes
1122 #define PRINTER_DEVICE                  0x02    // printers
1123 #define PROCESSOR_DEVICE                0x03    // scanners, printers, etc
1124 #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04    // worms
1125 #define READ_ONLY_DIRECT_ACCESS_DEVICE  0x05    // cdroms
1126 #define SCANNER_DEVICE                  0x06    // scanners
1127 #define OPTICAL_DEVICE                  0x07    // optical disks
1128 #define MEDIUM_CHANGER                  0x08    // jukebox
1129 #define COMMUNICATION_DEVICE            0x09    // network
1130 #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
1131 #define DEVICE_QUALIFIER_NOT_SUPPORTED  0x03
1132 
1133 // DeviceTypeQualifier field
1134 
1135 #define DEVICE_CONNECTED 0x00
1136 
1137 // Sense Data Format
1138 
1139 typedef struct _SENSE_DATA {
1140     UCHAR ErrorCode:7;
1141     UCHAR Valid:1;
1142     UCHAR SegmentNumber;
1143     UCHAR SenseKey:4;
1144     UCHAR Reserved:1;
1145     UCHAR IncorrectLength:1;
1146     UCHAR EndOfMedia:1;
1147     UCHAR FileMark:1;
1148     UCHAR Information[4];
1149     UCHAR AdditionalSenseLength;
1150     UCHAR CommandSpecificInformation[4];
1151     UCHAR AdditionalSenseCode;
1152     UCHAR AdditionalSenseCodeQualifier;
1153     UCHAR FieldReplaceableUnitCode;
1154     UCHAR SenseKeySpecific[3];
1155 } SENSE_DATA, *PSENSE_DATA;
1156 
1157 // Default request sense buffer size
1158 
1159 #define SENSE_BUFFER_SIZE 18
1160 
1161 // Sense keys
1162 
1163 #define SCSI_SENSE_NO_SENSE         0x00
1164 #define SCSI_SENSE_RECOVERED_ERROR  0x01
1165 #define SCSI_SENSE_NOT_READY        0x02
1166 #define SCSI_SENSE_MEDIUM_ERROR     0x03
1167 #define SCSI_SENSE_HARDWARE_ERROR   0x04
1168 #define SCSI_SENSE_ILLEGAL_REQUEST  0x05
1169 #define SCSI_SENSE_UNIT_ATTENTION   0x06
1170 #define SCSI_SENSE_DATA_PROTECT     0x07
1171 #define SCSI_SENSE_BLANK_CHECK      0x08
1172 #define SCSI_SENSE_UNIQUE           0x09
1173 #define SCSI_SENSE_COPY_ABORTED     0x0A
1174 #define SCSI_SENSE_ABORTED_COMMAND  0x0B
1175 #define SCSI_SENSE_EQUAL            0x0C
1176 #define SCSI_SENSE_VOL_OVERFLOW     0x0D
1177 #define SCSI_SENSE_MISCOMPARE       0x0E
1178 #define SCSI_SENSE_RESERVED         0x0F
1179 
1180 // Additional Sense codes
1181 
1182 // SK = 0x00
1183 #define SCSI_ADSENSE_NO_SENSE       0x00
1184 
1185 // SK = 0x01
1186 #define SCSI_ADSENSE_WARNING        0x0B
1187 #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
1188 #define SCSI_ADSENSE_REC_DATA_ECC   0x18
1189 #define SCSI_ADSENSE_ROUNDED_PARAM  0x37
1190 #define SCSI_ADSENSE_FAILURE_PREDICTED 0x5D
1191 #define SCSI_ADSENSE_CD_CONTROL_ERR 0x73
1192 
1193 // SK = 0x02
1194 #define SCSI_ADSENSE_LUN_NOT_READY  0x04
1195 #define SCSI_ADSENSE_INCOMPATIBLE_MEDIA 0x30
1196 #define SCSI_ADSENSE_INVALID_MEDIA  SCSI_ADSENSE_INCOMPATIBLE_MEDIA // for w2k
1197 #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3A
1198 #define SCSI_ADSENSE_POSITION_ERROR 0x3B
1199 #define SCSI_ADSENSE_NOT_SELF_CONFIGURED 0x3E
1200 
1201 
1202 // SK = 0x03
1203 #define SCSI_ADSENSE_NO_SEEK        0x02
1204 #define SCSI_ADSENSE_NO_REFERENCE   0x06
1205 #define SCSI_ADSENSE_CD_WRITE_ERROR 0x0C
1206 #define SCSI_ADSENSE_CD_READ_ERROR  0x11
1207 #define SCSI_ADSENSE_TRACK_ERROR    0x14
1208 #define SCSI_ADSENSE_SEEK_ERROR     0x15
1209 #define SCSI_ADSENSE_FORMAT_CORRUPTED 0x31
1210 #define SCSI_ADSENSE_ENCLOSURE_FAILURE 0x34
1211 #define SCSI_ADSENSE_ENCLOSURE_SERVICE 0x35
1212 #define SCSI_ADSENSE_ERASE_ERROR    0x51
1213 #define SCSI_ADSENSE_UNRECOVERED_TOC 0x57
1214 #define SCSI_ADSENSE_SESSION_FIXATION 0x71
1215 //#define SCSI_ADSENSE_CD_CONTROL_ERR 0x73  // redefinition
1216 
1217 // SK = 0x04
1218 #define SCSI_ADSENSE_CLEAN_REQUEST  0x00
1219 #define SCSI_ADSENSE_SELECT         0x04
1220 #define SCSI_ADSENSE_COMMUNICATION  0x08
1221 #define SCSI_ADSENSE_LOST_STREAMING 0x09
1222 #define SCSI_ADSENSE_SYNC_ERROR     0x1B
1223 #define SCSI_ADSENSE_MECH_ERROR     0x3B
1224 #define SCSI_ADSENSE_LUN_ERROR      0x3E
1225 #define SCSI_ADSENSE_DIAGNOSTIC     0x40
1226 #define SCSI_ADSENSE_INTERNAL       0x44
1227 #define SCSI_ADSENSE_SOFT_RESET     0x46
1228 #define SCSI_ADSENSE_SCSI_PARITY    0x47
1229 #define SCSI_ADSENSE_CMD_PHASE      0x4A
1230 #define SCSI_ADSENSE_DATA_PHASE     0x4B
1231 #define SCSI_ADSENSE_SELF_CONFIG    0x4C
1232 #define SCSI_ADSENSE_MEDIUM_REMOVAL 0x53
1233 #define SCSI_ADSENSE_VOLTAGE        0x65
1234 
1235 // SK = 0x05
1236 #define SCSI_ADSENSE_AUDIO_PLAY     0x00
1237 #define SCSI_ADSENSE_MULTISELECT    0x07
1238 #define SCSI_ADSENSE_INVALID_PARAM_LENGTH 0x1A
1239 #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
1240 #define SCSI_ADSENSE_ILLEGAL_BLOCK  0x21
1241 #define SCSI_ADSENSE_INVALID_CDB    0x24
1242 #define SCSI_ADSENSE_INVALID_LUN    0x25
1243 #define SCSI_ADSENSE_INVALID_VALUE  0x26
1244 #define SCSI_ADSENSE_WRITE_PROTECT  0x27
1245 #define SCSI_ADSENSE_CANT_DISCONNECT 0x2B
1246 #define SCSI_ADSENSE_INVALID_CMD_SEQUENCE 0x2C
1247 #define SCSI_ADSENSE_INVALID_SESSION_MODE 0x30
1248 #define SCSI_ADSENSE_SAVE_NOT_SUPPORTED 0x35
1249 #define SCSI_ADSENSE_INVALID_BITS_IN_IDENT_MSG 0x3D
1250 #define SCSI_ADSENSE_MSG_ERROR      0x43
1251 //#define SCSI_ADSENSE_MEDIUM_REMOVAL 0x53  // redefinition
1252 #define SCSI_ADSENSE_SYS_RESOURCE_FAILURE 0x55
1253 #define SCSI_ADSENSE_OUT_OF_SPACE   0x63
1254 #define SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK 0x64
1255 #define SCSI_ADSENSE_CD_COPY_ERROR  0x6F
1256 #define SCSI_ADSENSE_INCOMPLETE_DATA 0x72
1257 #define SCSI_ADSENSE_VENDOR_UNIQUE  0x80
1258 #define SCSI_ADSENSE_MUSIC_AREA     0xA0
1259 #define SCSI_ADSENSE_DATA_AREA      0xA1
1260 #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
1261 
1262 // SK = 0x06
1263 #define SCSI_ADSENSE_LOG_OVERFLOW   0x0A
1264 #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
1265 #define SCSI_ADSENSE_BUS_RESET      0x29
1266 #define SCSI_ADSENSE_PARAM_CHANGE   0x2A
1267 #define SCSI_ADSENSE_CMD_CLEARED_BY_ANOTHER 0x2F
1268 #define SCSI_ADSENSE_MEDIA_STATE    0x3B
1269 #define SCSI_ADSENSE_FUNCTIONALTY_CHANGE 0x3F
1270 #define SCSI_ADSENSE_OPERATOR       0x5A
1271 #define SCSI_ADSENSE_MAX_LOG        0x5B
1272 #define SCSI_ADSENSE_POWER          0x5E
1273 
1274 // SK = 0x0B
1275 #define SCSI_ADSENSE_READ_LOST_STREAMING 0x11
1276 #define SCSI_ADSENSE_RESELECT_FAILURE 0x45
1277 #define SCSI_ADSENSE_ERR_MSG_DETECTED 0x48
1278 #define SCSI_ADSENSE_INVALID_ERR_MSG 0x49
1279 #define SCSI_ADSENSE_TEGGED_OVERLAPPED 0x4D
1280 #define SCSI_ADSENSE_OVERLAPPED_ATTEMPT 0x4E
1281 
1282 // Additional sense code qualifier
1283 
1284 #define SCSI_SENSEQ_NO_SENSE 0x00
1285 
1286 // SK:ASC = 02:04
1287 //#define SCSI_SENSEQ_NO_SENSE 0x00
1288 #define SCSI_SENSEQ_CAUSE_NOT_REPORTABLE    0x00
1289 #define SCSI_SENSEQ_BECOMING_READY          0x01
1290 #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED   0x02
1291 #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
1292 #define SCSI_SENSEQ_FORMAT_IN_PROGRESS      0x04
1293 #define SCSI_SENSEQ_OPERATION_IN_PROGRESS   0x07
1294 #define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS  0x08
1295 
1296 // SK:ASC = 02:30
1297 #define SCSI_SENSEQ_INCOMPATIBLE_MEDIA_INSTALLED 0x00
1298 #define SCSI_SENSEQ_UNKNOWN_FORMAT      0x01
1299 #define SCSI_SENSEQ_INCOMPATIBLE_FORMAT 0x02
1300 #define SCSI_SENSEQ_CLEANING_CARTRIDGE_INSTALLED 0x03
1301 #define SCSI_SENSEQ_WRITE_UNKNOWN_FORMAT 0x04
1302 #define SCSI_SENSEQ_WRITE_INCOMPATIBLE_FORMAT 0x05
1303 #define SCSI_SENSEQ_FORMAT_INCOMPATIBLE_MEDIUM 0x06
1304 #define SCSI_SENSEQ_CLEANING_FAILURE    0x07
1305 
1306 // SK:ASC = 02:3A
1307 #define SCSI_SENSEQ_TRAY_CLOSED         0x01
1308 #define SCSI_SENSEQ_TRAY_OPEN           0x02
1309 
1310 // SK:ASC = 03:0C
1311 #define SENSEQ_W_RECOVERY_NEEDED        0x07
1312 #define SENSEQ_W_RECOVERY_FAILED        0x08
1313 #define SENSEQ_LOST_STREAMING           0x09
1314 #define SENSEQ_PADDING_BLOCKS_ADDED     0x0A
1315 
1316 // SK:ASC = 03:72
1317 //#define SCSI_SENSEQ_NO_SENSE 0x00
1318 #define SCSI_SENSEQ_LEAD_IN_ERROR       0x01
1319 #define SCSI_SENSEQ_LEAD_OUT_ERRROR     0x02
1320 #define SCSI_SENSEQ_INCOMPLETE_TRACK    0x03
1321 #define SCSI_SENSEQ_INCOMPLETE_RESERVED_TRACK 0x04
1322 #define SCSI_SENSEQ_NO_MORE_RESERVATION 0x05
1323 
1324 // SK:ASC = 05:26
1325 #define SCSI_SENSEQ_PARAM_NOT_SUPPORTED 0x01
1326 #define SCSI_SENSEQ_PARAM_INVALID_VALUE 0x02
1327 #define SCSI_SENSEQ_THRESHOLD_PARAM_NOT_SUPPORTED 0x03
1328 #define SCSI_SENSEQ_INVALID_RELEASE_OF_PERSISTENT_RESERVATION 0x04
1329 
1330 // SK:ASC = 05:27
1331 #define SCSI_SENSEQ_HW_PROTECTION       0x01
1332 #define SCSI_SENSEQ_LUN_SOFT_PROTECTION 0x02
1333 #define SCSI_SENSEQ_ASSOCIATED_PROTECTION 0x03
1334 #define SCSI_SENSEQ_PERSIST_PROTECTION  0x04
1335 #define SCSI_SENSEQ_PERMANENT_PROTECTION 0x05
1336 
1337 // SK:ASC = 05:2C
1338 #define SCSI_SENSEQ_PROGRAMM_AREA_NOT_EMPTY 0x03
1339 #define SCSI_SENSEQ_PROGRAMM_AREA_EMPTY 0x04
1340 
1341 // SK:ASC = 05:30
1342 #define SCSI_SENSEQ_APP_CODE_MISSMATCH  0x08
1343 #define SCSI_SENSEQ_NOT_FIXED_FOR_APPEND 0x09
1344 
1345 // SK:ASC = 05:6F
1346 #define SCSI_SENSEQ_AUTHENTICATION_FAILURE 0x00
1347 #define SCSI_SENSEQ_KEY_NOT_PRESENT        0x01
1348 #define SCSI_SENSEQ_KEY_NOT_ESTABLISHED    0x02
1349 #define SCSI_SENSEQ_READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION 0x03
1350 #define SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT 0x04
1351 #define SCSI_SENSEQ_LOGICAL_UNIT_RESET_COUNT_ERROR 0x05
1352 
1353 // SK:ASC = 06:28
1354 #define SCSI_SENSEQ_IMPORT_OR_EXPERT_ELEMENT_ACCESS   0x01
1355 
1356 // SK:ASC = 06:29
1357 #define SCSI_SENSEQ_POWER_ON            0x01
1358 #define SCSI_SENSEQ_SCSI_BUS            0x02
1359 #define SCSI_SENSEQ_BUS_DEVICE_FUNCTION 0x03
1360 #define SCSI_SENSEQ_DEVICE_INTERNAL     0x04
1361 
1362 // SK:ASC = 06:2A
1363 #define SCSI_SENSEQ_MODE_PARAMETERS     0x01
1364 #define SCSI_SENSEQ_LOG_PARAMETERS      0x02
1365 #define SCSI_SENSEQ_RESERVATIONS_PREEMPTED 0x03
1366 
1367 // SK:ASC = 06:3B
1368 #define SCSI_SENSEQ_DESTINATION_ELEMENT_FULL 0x0D
1369 #define SCSI_SENSEQ_SOURCE_ELEMENT_EMPTY 0x0E
1370 #define SCSI_SENSEQ_END_OF_MEDIUM       0x0F
1371 #define SCSI_SENSEQ_MAGAZINE_NOT_ACCESSIBLE 0x11
1372 #define SCSI_SENSEQ_MAGAZINE_REMOVED    0x12
1373 #define SCSI_SENSEQ_MAGAZINE_INSERTED   0x13
1374 #define SCSI_SENSEQ_MAGAZINE_LOCKED     0x14
1375 #define SCSI_SENSEQ_MAGAZINE_UNLOCKED   0x15
1376 
1377 // SK:ASC = 06:3F
1378 #define SCSI_SENSEQ_MICROCODE           0x01
1379 #define SCSI_SENSEQ_OPERATION_DEFINITION 0x02
1380 #define SCSI_SENSEQ_INQUIRY_DATA        0x03
1381 
1382 // SK:ASC = 06:5A
1383 #define SCSI_SENSEQ_MEDIUM_CHANGE_REQ   0x01
1384 #define SCSI_SENSEQ_W_PROTECT_SELECTED  0x02
1385 #define SCSI_SENSEQ_W_PROTECT_PERMITED  0x03
1386 
1387 // SK:ASC = 06:5E
1388 #define SCSI_SENSEQ_LOW_POWER_COND      0x00
1389 #define SCSI_SENSEQ_IDLE_BY_TIMER       0x01
1390 #define SCSI_SENSEQ_STANDBY_BY_TIMER    0x02
1391 #define SCSI_SENSEQ_IDLE_BY_CMD         0x03
1392 #define SCSI_SENSEQ_STANDBY_BY_CMD      0x04
1393 
1394 #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
1395 #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
1396 #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
1397 #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
1398 
1399 // SCSI IO Device Control Codes
1400 
1401 #define FILE_DEVICE_SCSI 0x0000001b
1402 
1403 #define IOCTL_SCSI_EXECUTE_IN   ((FILE_DEVICE_SCSI << 16) + 0x0011)
1404 #define IOCTL_SCSI_EXECUTE_OUT  ((FILE_DEVICE_SCSI << 16) + 0x0012)
1405 #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
1406 
1407 // SMART support in atapi
1408 
1409 #define IOCTL_SCSI_MINIPORT_SMART_VERSION           ((FILE_DEVICE_SCSI << 16) + 0x0500)
1410 #define IOCTL_SCSI_MINIPORT_IDENTIFY                ((FILE_DEVICE_SCSI << 16) + 0x0501)
1411 #define IOCTL_SCSI_MINIPORT_READ_SMART_ATTRIBS      ((FILE_DEVICE_SCSI << 16) + 0x0502)
1412 #define IOCTL_SCSI_MINIPORT_READ_SMART_THRESHOLDS   ((FILE_DEVICE_SCSI << 16) + 0x0503)
1413 #define IOCTL_SCSI_MINIPORT_ENABLE_SMART            ((FILE_DEVICE_SCSI << 16) + 0x0504)
1414 #define IOCTL_SCSI_MINIPORT_DISABLE_SMART           ((FILE_DEVICE_SCSI << 16) + 0x0505)
1415 #define IOCTL_SCSI_MINIPORT_RETURN_STATUS           ((FILE_DEVICE_SCSI << 16) + 0x0506)
1416 #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTOSAVE ((FILE_DEVICE_SCSI << 16) + 0x0507)
1417 #define IOCTL_SCSI_MINIPORT_SAVE_ATTRIBUTE_VALUES   ((FILE_DEVICE_SCSI << 16) + 0x0508)
1418 #define IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS   ((FILE_DEVICE_SCSI << 16) + 0x0509)
1419 #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTO_OFFLINE ((FILE_DEVICE_SCSI << 16) + 0x050a)
1420 #define IOCTL_SCSI_MINIPORT_READ_SMART_LOG              ((FILE_DEVICE_SCSI << 16) + 0x050b)
1421 #define IOCTL_SCSI_MINIPORT_WRITE_SMART_LOG             ((FILE_DEVICE_SCSI << 16) + 0x050c)
1422 
1423 // Read Capacity Data - returned in Big Endian format
1424 
1425 typedef struct _READ_CAPACITY_DATA {
1426     ULONG LogicalBlockAddress;
1427     ULONG BytesPerBlock;
1428 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
1429 
1430 typedef struct _READ_CAPACITY16_DATA {
1431     ULONGLONG LogicalBlockAddress;
1432     ULONG BytesPerBlock;
1433     UCHAR Prot_EN:1;
1434     UCHAR RTO_EN:1;
1435     UCHAR Reserved:6;
1436     UCHAR Reserved1[20];
1437 } READ_CAPACITY16_DATA, *PREAD_CAPACITY16_DATA;
1438 
1439 // CD ROM Read Table Of Contents (TOC) structures
1440 // Format 0 - Get table of contents
1441 
1442 #define TocControl_TrkMode_Mask           WParam_TrkMode_Mask
1443 #define TocControl_TrkMode_Audio          WParam_TrkMode_Audio
1444 #define TocControl_TrkMode_Audio_PreEmph  WParam_TrkMode_Audio_PreEmph
1445 #define TocControl_TrkMode_Data           WParam_TrkMode_Data
1446 #define TocControl_TrkMode_IncrData       WParam_TrkMode_IncrData
1447 #define TocControl_TrkMode_QAudio_PreEmph WParam_TrkMode_QAudio_PreEmph
1448 #define TocControl_TrkMode_AllowCpy       WParam_TrkMode_AllowCpy
1449 
1450 typedef struct _TOC_TRACK_INFO {
1451     UCHAR Reserved;
1452     UCHAR Control : 4;
1453     UCHAR Adr : 4;
1454     UCHAR TrackNum;
1455     UCHAR Reserved1;
1456     UCHAR LBA[4];
1457 } TOC_TRACK_INFO, *PTOC_TRACK_INFO;
1458 
1459 typedef struct _READ_TOC_HEADER {
1460     UCHAR Length[2];
1461     UCHAR First_TrackSes;
1462     UCHAR Last_TrackSes;
1463 } READ_TOC_HEADER, *PREAD_TOC_HEADER;
1464 
1465 #define TOC_LastTrack_ID                    0xAA
1466 
1467 typedef struct _READ_TOC_TOC {
1468     READ_TOC_HEADER Tracks;
1469     TOC_TRACK_INFO TrackData[MAXIMUM_NUMBER_OF_TRACKS+1];
1470 } READ_TOC_TOC, *PREAD_TOC_TOC;
1471 
1472 // Format 1 - Session Info
1473 
1474 typedef struct _READ_TOC_SES {
1475     READ_TOC_HEADER Sessions;
1476     TOC_TRACK_INFO LastSes_1stTrack;            // First Track Number In Last Complete Session
1477 } READ_TOC_SES, *PREAD_TOC_SES;
1478 
1479 // Format 2,3 - Full TOC, PMA
1480 
1481 // ADR = 1
1482 #define POINT_StartPositionOfTrack_Min      0x01
1483 #define POINT_StartPositionOfTrack_Max      0x63
1484 #define POINT_FirstTrackNum                 0xA0
1485 #define POINT_LastTrackNum                  0xA1
1486 #define POINT_StartPositionOfLeadOut        0xA2
1487 // ADR = 5
1488 #define POINT_SkipInterval_Min              0x01
1489 #define POINT_SkipInterval_Max              0x40
1490 #define POINT_StartPositionOfNextProgramArea 0xB0
1491 #define POINT_NumOfSkips                    0xB1
1492 #define POINT_SkipTrackAssignmet_Min        0xB2
1493 #define POINT_SkipTrackAssignmet_Max        0xB4
1494 #define POINT_StartPositionOfFirstLeadIn    0xC0
1495 #define POINT_CopyOfAdditionalAreaInATIP    0xC1
1496 
1497 typedef struct _TOC_SES_INFO {
1498     UCHAR SesNumber;
1499     UCHAR Control : 4;
1500     UCHAR Adr : 4;
1501     UCHAR TNO;
1502     UCHAR POINT;
1503 
1504     union {
1505 
1506         struct {
1507             UCHAR MSF[3];
1508             UCHAR Reserved;
1509             UCHAR P_MSF[3];
1510         } GENERIC;
1511 
1512 // ADR = 1:
1513 
1514 //0x01 - 0x63
1515         struct {
1516             UCHAR ATIME[3];
1517             UCHAR Zero;
1518             UCHAR MSF[3];
1519         } StartPositionOfTrack;
1520 
1521 //0xA0
1522 #define FullTOC_DiscType_CDDA_or_M1  WParam_SesFmt_CdRom        // 0x00
1523 #define FullTOC_DiscType_CDI         WParam_SesFmt_CdI          // 0x10
1524 #define FullTOC_DiscType_CDXA_M2     WParam_SesFmt_CdRomXa      // 0x20
1525 
1526         struct {
1527             UCHAR ATIME[3];
1528             UCHAR Zero;
1529             UCHAR FirstTrackNum;
1530             UCHAR DiscType;
1531             UCHAR Zero1;
1532         } FirstTrackNum;
1533 
1534 //0xA1
1535         struct {
1536             UCHAR ATIME[3];
1537             UCHAR Zero;
1538             UCHAR LastTrackNum;
1539             UCHAR Zero1[2];
1540         } LastTrackNum;
1541 
1542 //0xA2
1543         struct {
1544             UCHAR ATIME[3];
1545             UCHAR Zero;
1546             UCHAR MSF[3];
1547         } StartPositionOfLeadOut;
1548 
1549 // ADR = 5:
1550 
1551 //0x01 - 0x40
1552         struct {
1553             UCHAR End_MSF[3];
1554             UCHAR Reserved;
1555             UCHAR Start_MSF[3];
1556         } SkipInterval;
1557 
1558 //0xB0
1559         struct {
1560             UCHAR Program_MSF[3];
1561             UCHAR NumOfPointers_M5;
1562             UCHAR MaxLeadOut_MSF[3];
1563         } StartPositionOfNextProgramArea;
1564 
1565 //0xB1
1566         struct {
1567             UCHAR Zero[4];
1568             UCHAR Intervals;
1569             UCHAR Tracks;
1570             UCHAR Zero1;
1571         } NumOfSkips;
1572 
1573 //0xB2 - 0xB4
1574         struct {
1575             UCHAR SkipNum[7];
1576         } SkipTrackAsignment;
1577 
1578 //0xC0
1579         struct {
1580             UCHAR OptimumRecordingPower;
1581             UCHAR SpecInfoATIP[3];
1582             UCHAR LeadIn_MSF[3];
1583         } StartPositionOfFirstLeadIn;
1584 
1585 //0xC1
1586         struct {
1587             UCHAR Bytes[7];
1588         } AdditionalAreaInATIP;
1589 
1590     } Params;
1591 } TOC_SES_INFO, *PTOC_SES_INFO;
1592 
1593 typedef struct _READ_TOC_FULL_TOC {
1594     READ_TOC_HEADER Sessions;
1595     TOC_SES_INFO SessionData[MAXIMUM_NUMBER_OF_SESSIONS];
1596 } READ_TOC_FULL_TOC, *PREAD_TOC_FULL_TOC;
1597 
1598 typedef READ_TOC_FULL_TOC   READ_TOC_PMA;
1599 typedef PREAD_TOC_FULL_TOC  PREAD_TOC_PMA;
1600 
1601 // Format 4 - ATIP
1602 
1603 typedef struct _READ_TOC_ATIP {
1604     UCHAR Length[2];
1605     UCHAR Reserved[2];
1606 
1607 #define ATIP_SpeedRef_Mask  0x07
1608 #define ATIP_SpeedRef_2X    0x01
1609 #define ATIP_WritingPower_Mask  0x07
1610 
1611     union {
1612         UCHAR Flags;
1613         struct {
1614             UCHAR SpeedRef: 3;
1615             UCHAR Reserved: 1;
1616             UCHAR WritingPower: 3;
1617             UCHAR One: 1;
1618         } Fields;
1619     } Flags1;
1620 
1621 #define ATIP_URU            0x40
1622 
1623     union {
1624         UCHAR Flags;
1625         struct {
1626             UCHAR Reserved: 6;
1627             UCHAR URU: 1;
1628             UCHAR Zero: 1;
1629         } Fields;
1630     } Flags2;
1631 
1632 #define ATIP_A1             0x01        // 16-18 are valid
1633 #define ATIP_A2             0x02        // 20-22 are valid
1634 #define ATIP_A3             0x04        // 24-26 are valid
1635 #define ATIP_SubType_Mask   0x38        // shall be set to zero
1636 #define ATIP_Type_Mask      0x40
1637 #define ATIP_Type_CDR       0x00
1638 #define ATIP_Type_CDRW      0x40
1639 
1640     union {
1641         UCHAR Flags;
1642         struct {
1643             UCHAR A1: 1;
1644             UCHAR A2: 1;
1645             UCHAR A3: 1;
1646             UCHAR SubType: 3;
1647             UCHAR Type: 1;
1648             UCHAR One: 1;
1649         } Fields;
1650     } DiscType;
1651 
1652     UCHAR Reserved0;
1653     UCHAR LeadIn_MSF[3];
1654     UCHAR Reserved1;
1655     UCHAR LeadOut_MSF[3];
1656     UCHAR Reserved2;
1657 
1658 #define ATIP_MinSpeedCVL_Mask   0x70
1659 #define ATIP_MinSpeedCVL_2X     0x10
1660 #define ATIP_MaxSpeedCVL_Mask   0x0f
1661 #define ATIP_MaxSpeedCVL_2X     0x01
1662 #define ATIP_MaxSpeedCVL_4X     0x02
1663 #define ATIP_MaxSpeedCVL_6X     0x03
1664 #define ATIP_MaxSpeedCVL_8X     0x04
1665 
1666     union {
1667         UCHAR Flags;
1668         struct {
1669             UCHAR MaxSpeedCVL: 4;
1670             UCHAR MinSpeedCVL: 3;
1671             UCHAR Zero: 1;
1672         } Fields;
1673     } Speed;
1674 
1675 #define ATIP_Power_Y_Mask       0x0e
1676 #define ATIP_Power_P_Mask       0x70
1677 
1678     union {
1679         UCHAR Flags;
1680         struct {
1681             UCHAR Reserved: 1;
1682             UCHAR Y_value: 3;
1683             UCHAR P_factor: 3;
1684             UCHAR Zero: 1;
1685         } Fields;
1686     } Power;
1687 
1688 #define ATIP_PW_ratio_Mask      0x70
1689 
1690     union {
1691         UCHAR Flags;
1692         struct {
1693             UCHAR Reserved: 4;
1694             UCHAR P_W_ratio: 3;
1695             UCHAR Zero: 1;
1696         } Fields;
1697     } ErasePower;
1698 
1699     UCHAR Reserved3;
1700     UCHAR A1_value[3];
1701     UCHAR Reserved4;
1702     UCHAR A2_value[3];
1703     UCHAR Reserved5;
1704     UCHAR A3_value[3];
1705 
1706 } READ_TOC_ATIP, *PREAD_TOC_ATIP;
1707 
1708 // Format 5 - CD-TEXT
1709 
1710 typedef struct _CD_TEXT_PACK_DATA {
1711 
1712 #define CdText_ID1_Title        0x80    // ID2 = 0 - Album, ID2 = 1-63 - Track
1713 #define CdText_ID1_Performer    0x81
1714 #define CdText_ID1_Songwriter   0x82
1715 #define CdText_ID1_Composer     0x83
1716 #define CdText_ID1_Arranger     0x84
1717 #define CdText_ID1_Message      0x85
1718 #define CdText_ID1_DiscID       0x86
1719 #define CdText_ID1_GenreInfo    0x87
1720 #define CdText_ID1_TOC          0x88
1721 #define CdText_ID1_TOC2         0x89
1722 #define CdText_ID1_Special      0x8D
1723 #define CdText_ID1_UPC_EAN_ISRC 0x8E
1724 #define CdText_ID1_BlockSizeInfo 0x8F
1725 
1726     UCHAR ID1;
1727     UCHAR ID2;
1728     UCHAR ID3;
1729 
1730 #define CdText_CharPos_Mask     0x0f
1731 #define CdText_BlkNum_Mask      0x70
1732 
1733     union {
1734         UCHAR Flags;
1735         struct {
1736             UCHAR CharPos: 4;
1737             UCHAR BlkNum: 3;
1738             UCHAR DBCC: 1;          // used to indicate Double Byte text encoding (Unicode ?)
1739         } Fields;
1740     } BlkNum_CharPos;
1741 
1742     UCHAR TextData[12];
1743     UCHAR CRC[2];
1744 } CD_TEXT_PACK_DATA, *PCD_TEXT_PACK_DATA;
1745 
1746 typedef struct _READ_TOC_CD_TEXT {
1747     UCHAR Length[2];
1748     UCHAR Reserved[2];
1749     CD_TEXT_PACK_DATA Chunk0;
1750 } READ_TOC_CD_TEXT, *PREAD_TOC_CD_TEXT;
1751 
1752 // OPC block
1753 
1754 typedef struct _OPC_INFO_BLOCK {
1755     UCHAR Speed[2];
1756     UCHAR OpcValue[6];
1757 } OPC_INFO_BLOCK, *POPC_INFO_BLOCK;
1758 
1759 // Buffer Capacity format
1760 
1761 typedef struct _BUFFER_CAPACITY_BLOCK {
1762     UCHAR DataLength[2];
1763     UCHAR Reserved0[2];
1764     UCHAR BufferLength[4];
1765     UCHAR BlankBufferLength[4];
1766 } BUFFER_CAPACITY_BLOCK, *PBUFFER_CAPACITY_BLOCK;
1767 
1768 // Format Unit structures
1769 
1770 typedef struct _FORMAT_LIST_HEADER {
1771     UCHAR Reserved0;
1772 
1773 #define FormatHeader_VS     0x01
1774 #define FormatHeader_Immed  0x02
1775 #define FormatHeader_DSP    0x04
1776 #define FormatHeader_IP     0x08
1777 #define FormatHeader_STPF   0x10
1778 #define FormatHeader_DCRT   0x20
1779 #define FormatHeader_DPRY   0x40
1780 #define FormatHeader_FOV    0x80
1781 
1782     union {
1783         UCHAR Flags;
1784         struct {
1785             UCHAR VS: 1;
1786             UCHAR Immed: 1;
1787             UCHAR DSP: 1;
1788             UCHAR IP: 1;
1789             UCHAR STPF: 1;
1790             UCHAR DCRT: 1;
1791             UCHAR DPRY: 1;
1792             UCHAR FOV: 1;
1793         } Fields;
1794     } Flags;
1795     UCHAR FormatDescriptorLength[2];            // =0x0008
1796 } FORMAT_LIST_HEADER, *PFORMAT_LIST_HEADER;
1797 
1798 typedef struct _CDRW_FORMAT_DESCRIPTOR {
1799 
1800 #define FormatDesc_Grow     0x40
1801 #define FormatDesc_Ses      0x80
1802 
1803     union {
1804         UCHAR Flags;
1805         struct {
1806             UCHAR Reserved0: 6;
1807             UCHAR Grow: 1;
1808             UCHAR Ses: 1;
1809         } Fields;
1810     } Flags;
1811     UCHAR Reserved1[3];
1812     UCHAR FormatSize[4];
1813 } CDRW_FORMAT_DESCRIPTOR, *PCDRW_FORMAT_DESCRIPTOR;
1814 
1815 typedef struct _FORMAT_UNIT_PARAMETER_LIST {
1816     FORMAT_LIST_HEADER Header;
1817     UCHAR InitPatternDescr[4];
1818     CDRW_FORMAT_DESCRIPTOR FormatDescr;
1819 } FORMAT_UNIT_PARAMETER_LIST, *PFORMAT_UNIT_PARAMETER_LIST;
1820 
1821 // define Read Format Capacities info blocks
1822 
1823 typedef struct _CAPACITY_LIST_HEADER {
1824     UCHAR Reserved[3];
1825     UCHAR Length;
1826 } CAPACITY_LIST_HEADER, *PCAPACITY_LIST_HEADER;
1827 
1828 typedef struct _FORMATTABLE_CAPACITY_DESCRIPTOR {
1829     UCHAR NumOfBlocks [4];
1830     union {
1831         UCHAR Flags;
1832         struct {
1833             UCHAR DescType: 2;
1834             UCHAR Reserved0: 6;
1835         } Fields;
1836     } Flags;
1837     UCHAR BlockSize [3];
1838 } FORMATTABLE_CAPACITY_DESCRIPTOR, *PFORMATTABLE_CAPACITY_DESCRIPTOR;
1839 
1840 typedef struct _FORMAT_CAPACITIES_DATA {
1841     CAPACITY_LIST_HEADER Header;
1842 } FORMAT_CAPACITIES_DATA, *PFORMAT_CAPACITIES_DATA;
1843 
1844 // Define Event Status info blocks
1845 
1846 typedef struct _EVENT_STAT_HEADER {
1847     UCHAR DataLength[2];
1848 
1849 #define EventRetStat_Class_Mask       0x07
1850 #define EventRetStat_Class_OpChange   0x01
1851 #define EventRetStat_Class_PM         0x02
1852 #define EventRetStat_Class_Media      0x04
1853 #define EventRetStat_Class_DevBusy    0x06
1854 #define EventRetStat_NEA              0x80
1855 
1856     union {
1857         UCHAR Flags;
1858         struct {
1859             UCHAR Class: 3;
1860             UCHAR Reserved0: 4;
1861             UCHAR NEA: 1;
1862         } Fields;
1863     } Flags;
1864 
1865     UCHAR SupportedClasses;  // see command format
1866 
1867 } EVENT_STAT_HEADER, *PEVENT_STAT_HEADER;
1868 
1869 typedef struct _EVENT_STAT_OPERATIONAL_BLOCK {
1870 
1871     EVENT_STAT_HEADER Header;
1872 
1873 #define EventStat_OpEvent_Mask      0x0f
1874 
1875     union {
1876         UCHAR Flags;
1877         struct {
1878             UCHAR OpEvent  : 4;
1879             UCHAR Reserved0: 4;
1880         } Fields;
1881     } Byte0;
1882 
1883 #define EventStat_OpStat_Mask       0x0f
1884 #define EventStat_OpStat_Ready      0x00
1885 #define EventStat_OpStat_TempBusy   0x01
1886 #define EventStat_OpStat_Busy       0x02
1887 
1888     union {
1889         UCHAR Flags;
1890         struct {
1891             UCHAR OpStatus  : 4;
1892             UCHAR Reserved0 : 3;
1893             UCHAR PersistentPrevent: 1;
1894         } Fields;
1895     } Byte1;
1896 
1897 #define EventStat_OpReport_NoChg        0x00
1898 #define EventStat_OpReport_Change       0x01
1899 #define EventStat_OpReport_AddChg       0x02
1900 #define EventStat_OpReport_Reset        0x03
1901 #define EventStat_OpReport_FirmwareChg  0x04 // microcode change
1902 #define EventStat_OpReport_InquaryChg   0x05
1903 #define EventStat_OpReport_CtrlReq      0x06
1904 #define EventStat_OpReport_CtrlRelease  0x07
1905 
1906     UCHAR OpReport[2];
1907 
1908 } EVENT_STAT_OPERATIONAL_BLOCK, *PEVENT_STAT_OPERATIONAL_BLOCK;
1909 
1910 typedef struct _EVENT_STAT_PM_BLOCK {
1911 
1912     EVENT_STAT_HEADER Header;
1913 
1914 #define EventStat_PowerEvent_Mask       0x0f
1915 #define EventStat_PowerEvent_NoChg      0x00
1916 #define EventStat_PowerEvent_ChgOK      0x01
1917 #define EventStat_PowerEvent_ChgFail    0x02
1918 
1919     union {
1920         UCHAR Flags;
1921         struct {
1922             UCHAR PowerEvent : 4;
1923             UCHAR Reserved0  : 4;
1924         } Fields;
1925     } Byte0;
1926 
1927 #define EventStat_PowerStat_Mask        0x0f
1928 #define EventStat_PowerStat_Active      0x01
1929 #define EventStat_PowerStat_Idle        0x02
1930 #define EventStat_PowerStat_Standby     0x03
1931 #define EventStat_PowerStat_Sleep       0x04
1932 
1933     union {
1934         UCHAR Flags;
1935         struct {
1936             UCHAR PowerStatus: 4;
1937             UCHAR Reserved0  : 4;
1938         } Fields;
1939     } Byte1;
1940 
1941     UCHAR Reserved0[2];
1942 
1943 } EVENT_STAT_PM_BLOCK, *PEVENT_STAT_PM_BLOCK;
1944 
1945 typedef struct _EVENT_STAT_MEDIA_BLOCK {
1946 
1947     EVENT_STAT_HEADER Header;
1948 
1949 #define EventStat_MediaEvent_Mask       0x0f
1950 #define EventStat_MediaEvent_None       0x00
1951 #define EventStat_MediaEvent_EjectReq   0x01
1952 #define EventStat_MediaEvent_New        0x02
1953 #define EventStat_MediaEvent_Removal    0x03
1954 #define EventStat_MediaEvent_Chg        0x04
1955 
1956     union {
1957         UCHAR Flags;
1958         struct {
1959             UCHAR MediaEvent : 4;
1960             UCHAR Reserved0  : 4;
1961         } Fields;
1962     } Byte0;
1963 
1964 #define EventStat_MediaStat_DoorOpen    0x01
1965 #define EventStat_MediaStat_Present     0x02
1966 
1967     union {
1968         UCHAR Flags;
1969         struct {
1970             UCHAR DoorOpen  : 1;
1971             UCHAR Present   : 1;
1972             UCHAR Reserved0 : 6;
1973         } Fields;
1974     } Byte1;
1975 
1976     UCHAR StartSlot;
1977     UCHAR EndSlot;
1978 
1979 } EVENT_STAT_MEDIA_BLOCK, *PEVENT_STAT_MEDIA_BLOCK;
1980 
1981 typedef struct _EVENT_STAT_DEV_BUSY_BLOCK {
1982 
1983     EVENT_STAT_HEADER Header;
1984 
1985 #define EventStat_BusyEvent_Mask       0x0f
1986 #define EventStat_BusyEvent_None       0x00
1987 #define EventStat_BusyEvent_Busy       0x01
1988 
1989     union {
1990         UCHAR Flags;
1991         struct {
1992             UCHAR BusyEvent : 4;
1993             UCHAR Reserved0 : 4;
1994         } Fields;
1995     } Byte0;
1996 
1997 #define EventStat_BusyStat_Mask        0x0f
1998 #define EventStat_BusyStat_NoEvent     0x00
1999 #define EventStat_BusyStat_Power       0x01
2000 #define EventStat_BusyStat_Immed       0x02
2001 #define EventStat_BusyStat_Deferred    0x03
2002 
2003     union {
2004         UCHAR Flags;
2005         struct {
2006             UCHAR BusyStatus: 4;
2007             UCHAR Reserved0 : 4;
2008         } Fields;
2009     } Byte1;
2010 
2011     UCHAR Time[2];
2012 
2013 } EVENT_STAT_DEV_BUSY_BLOCK, *PEVENT_STAT_DEV_BUSY_BLOCK;
2014 
2015 // Define mode disc info block.
2016 
2017 typedef struct _DISC_INFO_BLOCK {        //
2018     UCHAR DataLength [2];
2019 
2020 #define DiscInfo_Disk_Mask          0x03
2021 #define DiscInfo_Disk_Empty         0x00
2022 #define DiscInfo_Disk_Appendable    0x01
2023 #define DiscInfo_Disk_Complete      0x02
2024 
2025 #define DiscInfo_Ses_Mask       0x0C
2026 #define DiscInfo_Ses_Empty      0x00
2027 #define DiscInfo_Ses_Incomplete 0x04
2028 #define DiscInfo_Ses_Complete   0x0C
2029 
2030 #define DiscInfo_Disk_Erasable  0x10
2031 
2032     union {
2033         UCHAR Flags;
2034         struct {
2035             UCHAR DiscStat : 2;
2036             UCHAR LastSesStat : 2;
2037             UCHAR Erasable : 1;
2038             UCHAR Reserved0: 3;
2039         } Fields;
2040     } DiscStat;
2041 
2042     UCHAR FirstTrackNum;
2043     UCHAR NumOfSes;
2044     UCHAR FirstTrackNumLastSes;
2045     UCHAR LastTrackNumLastSes;
2046 
2047 #define DiscInfo_URU            0x20
2048 #define DiscInfo_DBC_V          0x40
2049 #define DiscInfo_DID_V          0x80
2050 
2051     union {
2052         UCHAR Flags;
2053         struct {
2054             UCHAR Reserved1: 5;
2055             UCHAR URU      : 1;
2056             UCHAR DBC_V    : 1; // 0
2057             UCHAR DID_V    : 1;
2058         } Fields;
2059     } Flags;
2060 
2061 #define DiscInfo_Type_cdrom     0x00    // CD-DA / CD-ROM
2062 #define DiscInfo_Type_cdi       0x10    // CD-I
2063 #define DiscInfo_Type_cdromxa   0x20    // CD-ROM XA
2064 #define DiscInfo_Type_unknown   0xFF    // HZ ;)
2065 
2066     UCHAR DiskType;
2067     UCHAR NumOfSes2;              // MSB MMC-3
2068     UCHAR FirstTrackNumLastSes2;  // MSB MMC-3
2069     UCHAR LastTrackNumLastSes2;   // MSB MMC-3
2070     UCHAR DiskId [4];
2071     UCHAR LastSesLeadInTime [4];  // MSF
2072     UCHAR LastSesLeadOutTime [4]; // MSF
2073     UCHAR DiskBarCode [8];
2074     UCHAR Reserved3;
2075     UCHAR OPCNum;
2076 } DISC_INFO_BLOCK, *PDISC_INFO_BLOCK;
2077 
2078 // Define track info block.
2079 
2080 typedef struct _TRACK_INFO_BLOCK {
2081     UCHAR DataLength [2];
2082     UCHAR TrackNum;
2083     UCHAR SesNum;
2084     UCHAR Reserved0;
2085 
2086 #define TrkInfo_Trk_Mask    0x0F
2087 #define TrkInfo_Trk_Mode1   0x01
2088 #define TrkInfo_Trk_Mode2   0x02
2089 #define TrkInfo_Trk_XA      0x02
2090 #define TrkInfo_Trk_DDCD    0x04  // MMC-3
2091 #define TrkInfo_Trk_NonCD   0x04  // MMC-3
2092 #define TrkInfo_Trk_Inc     0x05  // MMC-3
2093 #define TrkInfo_Trk_unknown 0x0F
2094 #define TrkInfo_Copy        0x10
2095 #define TrkInfo_Damage      0x20
2096 
2097     UCHAR TrackParam;
2098 /*  UCHAR TrackMode : 4;
2099     UCHAR Copy      : 1;
2100     UCHAR Damage    : 1;
2101     UCHAR Reserved1 : 2; */
2102 
2103 #define TrkInfo_Dat_Mask    0x0F
2104 #define TrkInfo_Dat_Mode1   0x01
2105 #define TrkInfo_Dat_Mode2   0x02
2106 #define TrkInfo_Dat_XA      0x02
2107 #define TrkInfo_Dat_DDCD    0x02
2108 #define TrkInfo_Dat_unknown 0x0F
2109 #define TrkInfo_FP          0x10
2110 #define TrkInfo_Packet      0x20
2111 #define TrkInfo_Blank       0x40
2112 #define TrkInfo_RT          0x80
2113 
2114     UCHAR DataParam;
2115 /*  UCHAR DataMode  : 4;
2116     UCHAR FP        : 1;
2117     UCHAR Packet    : 1;
2118     UCHAR Blank     : 1;
2119     UCHAR RT        : 1; */
2120 
2121 #define TrkInfo_NWA_V       0x01
2122 #define TrkInfo_LRA_V       0x02  // MMC-3
2123 
2124     UCHAR NWA_V;
2125 /*  UCHAR NWA_V     : 1;
2126     UCHAR LRA_V     : 1;
2127     UCHAR Reserved  : 6; */
2128 
2129     UCHAR TrackStartAddr [4];
2130     UCHAR NextWriteAddr [4];
2131     UCHAR FreeBlocks [4];
2132     UCHAR FixPacketSize [4];
2133     UCHAR TrackLength [4];
2134 
2135 // MMC-3
2136 
2137     UCHAR LastRecordedAddr [4];
2138     UCHAR TrackNum2;  // MSB
2139     UCHAR SesNum2;    // MSB
2140     UCHAR Reserved2[2];
2141 
2142 }TRACK_INFO_BLOCK, *PTRACK_INFO_BLOCK;
2143 
2144 // Mode data structures.
2145 
2146 // Define Mode parameter header.
2147 
2148 #define MediaType_Unknown                        0x00
2149 #define MediaType_120mm_CDROM_DataOnly           0x01
2150 #define MediaType_120mm_CDROM_AudioOnly          0x02        //CDDA
2151 #define MediaType_120mm_CDROM_DataAudioCombined  0x03
2152 #define MediaType_120mm_CDROM_Hybrid_PhotoCD     0x04
2153 #define MediaType_80mm_CDROM_DataOnly            0x05
2154 #define MediaType_80mm_CDROM_AudioOnly           0x06        //CDDA
2155 #define MediaType_80mm_CDROM_DataAudioCombined   0x07
2156 #define MediaType_80mm_CDROM_Hybrid_PhotoCD      0x08
2157 
2158 #define MediaType_UnknownSize_CDR                0x10
2159 #define MediaType_120mm_CDR_DataOnly             0x11
2160 #define MediaType_120mm_CDR_AudioOnly            0x12        //CDDA
2161 #define MediaType_120mm_CDR_DataAudioCombined    0x13
2162 #define MediaType_120mm_CDR_Hybrid_PhotoCD       0x14
2163 #define MediaType_80mm_CDR_DataOnly              0x15
2164 #define MediaType_80mm_CDR_AudioOnly             0x16        //CDDA
2165 #define MediaType_80mm_CDR_DataAudioCombined     0x17
2166 #define MediaType_80mm_CDR_Hybrid_Photo_CD       0x18
2167 
2168 #define MediaType_UnknownSize_CDRW               0x20
2169 #define MediaType_120mm_CDRW_DataOnly            0x21
2170 #define MediaType_120mm_CDRW_AudioOnly           0x22        //CDDA
2171 #define MediaType_120mm_CDRW_DataAudioCombined   0x23
2172 #define MediaType_120mm_CDRW_Hybrid              0x24
2173 #define MediaType_80mm_CDRW_DataOnly             0x25
2174 #define MediaType_80mm_CDRW_AudioOnly            0x26        //CDDA
2175 #define MediaType_80mm_CDRW_DataAudioCombined    0x27
2176 #define MediaType_80mm_CDRW_Hybrid               0x28
2177 
2178 #define MediaType_NoDiscPresent                  0x70
2179 #define MediaType_DoorOpen                       0x71
2180 
2181 //*********************************************************************************************
2182 
2183 typedef struct _MODE_PARAMETER_HEADER {
2184     UCHAR ModeDataLength;
2185     UCHAR MediumType;
2186     UCHAR DeviceSpecificParameter;
2187     UCHAR BlockDescriptorLength;
2188 } MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
2189 
2190 typedef struct _MODE_PARAMETER_HEADER10 {
2191     UCHAR ModeDataLength[2];
2192     UCHAR MediumType;
2193     UCHAR DeviceSpecificParameter;
2194     UCHAR Reserved[2];
2195     UCHAR BlockDescriptorLength[2];
2196 } MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
2197 
2198 #define MODE_FD_SINGLE_SIDE     0x01
2199 #define MODE_FD_DOUBLE_SIDE     0x02
2200 #define MODE_FD_MAXIMUM_TYPE    0x1E
2201 #define MODE_DSP_FUA_SUPPORTED  0x10
2202 #define MODE_DSP_WRITE_PROTECT  0x80
2203 
2204 // Define the mode parameter block.
2205 
2206 typedef struct _MODE_PARAMETER_BLOCK {
2207     UCHAR DensityCode;
2208     UCHAR NumberOfBlocks[3];
2209     UCHAR Reserved;
2210     UCHAR BlockLength[3];
2211 } MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
2212 
2213 typedef struct _MODE_PARM_READ_WRITE {
2214 
2215    MODE_PARAMETER_HEADER  ParameterListHeader;  // List Header Format
2216    MODE_PARAMETER_BLOCK   ParameterListBlock;   // List Block Descriptor
2217 
2218 } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
2219 
2220 //*********************************************************************************************
2221 // Define read write recovery page
2222 
2223 typedef struct _MODE_READ_WRITE_RECOVERY_PAGE {     // 0x01
2224 
2225     UCHAR PageCode : 6;
2226     UCHAR Reserved1 : 1;
2227     UCHAR PSBit : 1;
2228     UCHAR PageLength;
2229     union {
2230         UCHAR Flags;
2231         struct {
2232             UCHAR DCRBit : 1;
2233             UCHAR DTEBit : 1;
2234             UCHAR PERBit : 1;
2235             UCHAR EERBit : 1;
2236             UCHAR RCBit : 1;
2237             UCHAR TBBit : 1;
2238             UCHAR ARRE : 1;
2239             UCHAR AWRE : 1;
2240         } Fields;
2241     } ErrorRecoveryParam;
2242     UCHAR ReadRetryCount;
2243     UCHAR CorrectionSpan;           //SCSI CBS only
2244     UCHAR HeadOffsetCount;          //SCSI CBS only
2245     UCHAR DataStrobOffsetCount;     //SCSI CBS only
2246     UCHAR Reserved4;
2247     UCHAR WriteRetryCount;
2248     UCHAR Reserved5;
2249     UCHAR RecoveryTimeLimit[2];     // 0
2250 
2251 } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
2252 
2253 // Define Read Recovery page - cdrom
2254 
2255 typedef struct _MODE_READ_RECOVERY_PAGE {       // 0x01
2256 
2257     UCHAR PageCode : 6;
2258     UCHAR Reserved1 : 1;
2259     UCHAR PSBit : 1;
2260     UCHAR PageLength;
2261     UCHAR DCRBit : 1;
2262     UCHAR DTEBit : 1;
2263     UCHAR PERBit : 1;
2264     UCHAR Reserved2 : 1;
2265     UCHAR RCBit : 1;
2266     UCHAR TBBit : 1;
2267     UCHAR Reserved3 : 2;
2268     UCHAR ReadRetryCount;
2269     UCHAR Reserved4[4];
2270 
2271 } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
2272 
2273 //*********************************************************************************************
2274 // Define mode write parameters page.
2275 
2276 typedef struct _MODE_WRITE_PARAMS_PAGE {        // 0x05
2277     UCHAR PageCode : 6;
2278     UCHAR Reserved1: 1;
2279     UCHAR PageSavable : 1;
2280 
2281     UCHAR PageLength;               // 0x32
2282 
2283 #define WParam_WType_Mask   0x0f
2284 #define WParam_WType_Packet 0x00
2285 #define WParam_WType_TAO    0x01
2286 #define WParam_WType_Ses    0x02
2287 #define WParam_WType_Raw    0x03
2288 #define WParam_TestWrite    0x10
2289 #define WParam_LS_V         0x20
2290 #define WParam_BUFF         0x40
2291 
2292     union {
2293         UCHAR Flags;
2294         struct {
2295             UCHAR WriteType: 4;             // 1
2296             UCHAR TestWrite: 1;
2297             UCHAR LS_V: 1;
2298             UCHAR BUFF: 1;
2299             UCHAR Reserved1: 1;
2300         } Fields;
2301     } Byte2;
2302 
2303 #define WParam_TrkMode_Mask             0x0d // xx0x
2304 #define WParam_TrkMode_None             0x00
2305 #define WParam_TrkMode_Audio            0x00
2306 #define WParam_TrkMode_Audio_PreEmph    0x01
2307 #define WParam_TrkMode_Data             0x04
2308 #define WParam_TrkMode_IncrData         0x05
2309 #define WParam_TrkMode_QAudio_PreEmph   0x08
2310 #define WParam_TrkMode_AllowCpy         0x02
2311 #define WParam_Copy             0x10
2312 #define WParam_FP               0x20
2313 #define WParam_MultiSes_Mask    0xc0
2314 #define WParam_Multises_None    0x00
2315 #define WParam_Multises_Final   0x80
2316 #define WParam_Multises_Multi   0xc0
2317 
2318     union {
2319         UCHAR Flags;
2320         struct {
2321             UCHAR TrackMode: 4;             // 4
2322             UCHAR Copy     : 1;             // 0
2323             UCHAR FP       : 1;             // 0
2324             UCHAR Multisession: 2;          // 11
2325         } Fields;
2326     } Byte3;
2327 
2328 #define WParam_BlkType_Mask         0x0f
2329 #define WParam_BlkType_Raw_2352     0x00
2330 #define WParam_BlkType_RawPQ_2368   0x01
2331 #define WParam_BlkType_RawPW_2448   0x02
2332 #define WParam_BlkType_RawPW_R_2448 0x03
2333 #define WParam_BlkType_VendorSpec1  0x07
2334 #define WParam_BlkType_M1_2048      0x08
2335 #define WParam_BlkType_M2_2336      0x09
2336 #define WParam_BlkType_M2XAF1_2048  0x0a
2337 #define WParam_BlkType_M2XAF1SH_2056 0x0b
2338 #define WParam_BlkType_M2XAF2_2324  0x0c
2339 #define WParam_BlkType_M2XAFXSH_2332 0x0d
2340 #define WParam_BlkType_VendorSpec2  0x0f
2341 
2342     union {
2343         UCHAR Flags;
2344         struct {
2345             UCHAR DataBlockType: 4;         // 8
2346             UCHAR Reserved2: 4;
2347         } Fields;
2348     } Byte4;
2349 
2350     UCHAR LinkSize;
2351     UCHAR Reserved3;
2352 
2353     union {
2354         UCHAR Flags;
2355         struct {
2356             UCHAR HostAppCode : 6;          // 0
2357             UCHAR Reserved4   : 2;
2358         } Fields;
2359     } Byte7;
2360 
2361 #define WParam_SesFmt_CdRom     0x00
2362 #define WParam_SesFmt_CdI       0x10
2363 #define WParam_SesFmt_CdRomXa   0x20
2364 
2365     UCHAR SesFmt;                   // 0
2366     UCHAR Reserved5;
2367     UCHAR PacketSize[4];            // 0
2368     UCHAR AudioPause[2];            // 150
2369 
2370     UCHAR Reserved6: 7;
2371     UCHAR MCVAL    : 1;
2372 
2373     UCHAR N[13];
2374     UCHAR Zero;
2375     UCHAR AFRAME;
2376 
2377     UCHAR Reserved7: 7;
2378     UCHAR TCVAL    : 1;
2379 
2380     UCHAR I[12];
2381     UCHAR Zero_2;
2382     UCHAR AFRAME_2;
2383     UCHAR Reserved8;
2384 
2385     struct {
2386         union {
2387             UCHAR MSF[3];
2388             struct _SubHdrParams1 {
2389                 UCHAR FileNum;
2390                 UCHAR ChannelNum;
2391 
2392 #define WParam_SubHdr_SubMode0          0x00
2393 #define WParam_SubHdr_SubMode1          0x08
2394 
2395                 UCHAR SubMode;
2396             } Params1;
2397         } Params;
2398 
2399 #define WParam_SubHdr_Mode_Mask         0x03
2400 #define WParam_SubHdr_Mode0             0x00
2401 #define WParam_SubHdr_Mode1             0x01
2402 #define WParam_SubHdr_Mode2             0x02
2403 #define WParam_SubHdr_Format_Mask       0xe0
2404 #define WParam_SubHdr_Format_UserData   0x00
2405 #define WParam_SubHdr_Format_RunIn4     0x20
2406 #define WParam_SubHdr_Format_RunIn3     0x40
2407 #define WParam_SubHdr_Format_RunIn2     0x60
2408 #define WParam_SubHdr_Format_RunIn1     0x80
2409 #define WParam_SubHdr_Format_Link       0xa0
2410 #define WParam_SubHdr_Format_RunOut2    0xc0
2411 #define WParam_SubHdr_Format_RunOut1    0xe0
2412 
2413         union {
2414             UCHAR Flags;
2415             struct {
2416                 UCHAR Mode      : 2;
2417                 UCHAR Reserved  : 3;
2418                 UCHAR Format    : 3;
2419             } Fields;
2420         } Mode;
2421     } SubHeader ;
2422 
2423 } MODE_WRITE_PARAMS_PAGE, *PMODE_WRITE_PARAMS_PAGE;
2424 
2425 typedef struct _MODE_WRITE_PARAMS_PAGE_3 {
2426     MODE_WRITE_PARAMS_PAGE Standard;
2427     UCHAR VendorSpec[4];
2428 } MODE_WRITE_PARAMS_PAGE_3, *PMODE_WRITE_PARAMS_PAGE_3;
2429 
2430 //*********************************************************************************************
2431 // Define Caching page.
2432 
2433 typedef struct _MODE_CACHING_PAGE {         // 0x08
2434     UCHAR PageCode : 6;
2435     UCHAR Reserved1: 1;
2436     UCHAR PageSavable : 1;
2437     UCHAR PageLength;
2438     UCHAR ReadDisableCache : 1;
2439     UCHAR MultiplicationFactor : 1;
2440     UCHAR WriteCacheEnable : 1;
2441     UCHAR Reserved2 : 5;
2442     UCHAR WriteRetensionPriority : 4;
2443     UCHAR ReadRetensionPriority : 4;
2444     UCHAR DisablePrefetchTransfer[2];
2445     UCHAR MinimumPrefetch[2];
2446     UCHAR MaximumPrefetch[2];
2447     UCHAR MaximumPrefetchCeiling[2];
2448 } MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
2449 
2450 //*********************************************************************************************
2451 // Define CD Parameters page.
2452 
2453 typedef struct _MODE_CD_PARAMS_PAGE {         // 0x0D
2454     UCHAR PageCode : 6;
2455     UCHAR Reserved : 1;
2456     UCHAR PageSavable : 1;
2457 
2458     UCHAR PageLength;                       // 0x06
2459     UCHAR Reserved1;
2460 
2461 #define CdParams_InactvityTime_Mask     0x0f
2462 
2463     union {
2464         UCHAR Flags;
2465         struct {
2466             UCHAR InactivityTime: 4;        // 1 - 125ms, 2 - 250ms... 9 - 32s, A - 1min...
2467             UCHAR Reserved0 : 4;
2468         } Fields;
2469     } Byte2;
2470 
2471     UCHAR SUnits_per_MUnit[2];
2472     UCHAR FUnits_per_SUnit[2];
2473 } MODE_CD_PARAMS_PAGE, *PMODE_CD_PARAMS_PAGE;
2474 
2475 //*********************************************************************************************
2476 // Define CD Audio Control Mode page.
2477 
2478 typedef struct _CDDA_PORT_CONTROL {
2479 
2480 #define CddaPort_Channel_Mask       0x0f
2481 #define CddaPort_Channel_Mute       0x00
2482 #define CddaPort_Channel_0          0x01
2483 #define CddaPort_Channel_1          0x02
2484 #define CddaPort_Channel_0_1        0x03
2485 #define CddaPort_Channel_2          0x04
2486 #define CddaPort_Channel_3          0x08
2487 
2488     UCHAR ChannelSelection;
2489     UCHAR Volume;
2490 } CDDA_PORT_CONTROL, *PCDDA_PORT_CONTROL;
2491 
2492 typedef struct _MODE_CD_AUDIO_CONTROL_PAGE {         // 0x0E
2493     UCHAR PageCode : 6;
2494     UCHAR Reserved1: 1;
2495     UCHAR PageSavable : 1;
2496 
2497     UCHAR PageLength;                       // 0x0E
2498 
2499 #define CdAudio_SOTC        0x02
2500 #define CdAudio_Immed       0x04
2501 
2502     union {
2503         UCHAR Flags;
2504         struct {
2505             UCHAR Reserved0 : 1;
2506             UCHAR SOTC      : 1;
2507             UCHAR Immed     : 1;
2508             UCHAR Reserved1 : 5;
2509         } Fields;
2510     } Byte2;
2511 
2512     UCHAR Reserved2[2];
2513     UCHAR LbaFormat;
2514     UCHAR LogicalBlocksPerSecond[2];
2515     CDDA_PORT_CONTROL Port[4];
2516 } MODE_CD_AUDIO_CONTROL_PAGE, *PMODE_CD_AUDIO_CONTROL_PAGE;
2517 
2518 //*********************************************************************************************
2519 // Define Power Condition Mode page.
2520 
2521 typedef struct _MODE_POWER_CONDITION_PAGE {         // 0x1A
2522     UCHAR PageCode : 6;
2523     UCHAR Reserved1: 1;
2524     UCHAR PageSavable : 1;
2525 
2526     UCHAR PageLength;                       // 0x0A
2527     UCHAR Reserved2;
2528 
2529 #define PowerCond_Standby       0x01
2530 #define PowerCond_Idle          0x02
2531 
2532     union {
2533         UCHAR Flags;
2534         struct {
2535             UCHAR Standby   : 1;
2536             UCHAR Idle      : 1;
2537             UCHAR Reserved1 : 6;
2538         } Fields;
2539     } Byte3;
2540 
2541     UCHAR IdleTimer[4];                 // 1unit = 100ms
2542     UCHAR StandbyTimer[4];              // 1unit = 100ms
2543 } MODE_POWER_CONDITION_PAGE, *PMODE_POWER_CONDITION_PAGE;
2544 
2545 //*********************************************************************************************
2546 // Define Fault/Failure Reporting Control page.
2547 
2548 typedef struct _MODE_FAIL_REPORT_PAGE {         // 0x1C
2549     UCHAR PageCode : 6;
2550     UCHAR Reserved1: 1;
2551     UCHAR PageSavable : 1;
2552 
2553     UCHAR PageLength;                       // 0x0A
2554 
2555 #define FailReport_LogErr       0x01
2556 #define FailReport_Test         0x04
2557 #define FailReport_DExcept      0x08
2558 #define FailReport_Perf         0x80
2559 
2560     union {
2561         UCHAR Flags;
2562         struct {
2563             UCHAR LogErr    : 1;
2564             UCHAR Reserved1 : 1;
2565             UCHAR Test      : 1;
2566             UCHAR DExcept   : 1;
2567             UCHAR Reserved2 : 3;
2568             UCHAR Perf      : 1;
2569         } Fields;
2570     } Byte2;
2571 
2572     union {
2573         UCHAR Flags;
2574         struct {
2575             UCHAR MRIE      : 4;
2576             UCHAR Reserved1 : 4;
2577         } Fields;
2578     } Byte3;
2579 
2580     UCHAR IntervalTimer[4];                 // 1unit = 100ms
2581     UCHAR ReportCount[4];
2582 } MODE_FAIL_REPORT_PAGE, *PMODE_FAIL_REPORT_PAGE;
2583 
2584 //*********************************************************************************************
2585 // Define Time-out and Protect page.
2586 
2587 typedef struct _MODE_TIMEOUT_AND_PROTECT_PAGE {         // 0x1D
2588     UCHAR PageCode : 6;
2589     UCHAR Reserved1: 1;
2590     UCHAR PageSavable : 1;
2591 
2592     UCHAR PageLength;                       // 0x08
2593 
2594     UCHAR Reserved2[2];
2595 
2596 #define Timeout_SW          0x01
2597 #define Timeout_DISP        0x02
2598 #define Timeout_TMOE        0x04
2599 
2600     union {
2601         UCHAR Flags;
2602         struct {
2603             UCHAR SW       : 1;
2604             UCHAR DISP     : 1;
2605             UCHAR TMOE     : 1;
2606             UCHAR Reserved : 5;
2607         } Fields;
2608     } Byte4;
2609 
2610     UCHAR Reserved3;
2611 
2612     UCHAR Group1_Timeout[2];                 // 1unit = 1s
2613     UCHAR Group2_Timeout[2];                 // 1unit = 1s
2614 } MODE_TIMEOUT_AND_PROTECT_PAGE, *PMODE_TIMEOUT_AND_PROTECT_PAGE;
2615 
2616 //*********************************************************************************************
2617 // Define Philips CD-R(W) Sector Mode page.
2618 
2619 typedef struct _MODE_PHILIPS_SECTOR_TYPE_PAGE {   // 0x21
2620     UCHAR PageCode : 6;
2621     UCHAR Reserved1 : 1;
2622     UCHAR PSBit : 1;
2623 
2624     UCHAR PageLength;
2625 
2626     UCHAR Reserved0[2];
2627 
2628     union {
2629         UCHAR Flags;
2630         struct {
2631             UCHAR DataBlockType: 4;         // 8
2632             UCHAR Reserved2: 4;
2633         } Fields;
2634     } Byte4;
2635 
2636 #define WParams_Philips_CreateNewTrack      0
2637 
2638     UCHAR Track;
2639     UCHAR ISRC[9];
2640 
2641     UCHAR Reserved3[2];
2642 } MODE_PHILIPS_SECTOR_TYPE_PAGE, *PMODE_PHILIPS_SECTOR_TYPE_PAGE;
2643 
2644 //*********************************************************************************************
2645 // Define CD-X Capabilities and Mechanical Status page.
2646 
2647 typedef struct _MODE_CAPABILITIES_PAGE2 {   // 0x2A
2648     UCHAR PageCode : 6;
2649     UCHAR Reserved1 : 1;
2650     UCHAR PSBit : 1;
2651 
2652     UCHAR PageLength;
2653 
2654 #define DevCap_read_cd_r          0x01 // reserved in 1.2
2655 #define DevCap_read_cd_rw         0x02 // reserved in 1.2
2656 #define DevCap_method2            0x04
2657 #define DevCap_read_dvd_rom       0x08
2658 #define DevCap_read_dvd_r         0x10
2659 #define DevCap_read_dvd_ram       0x20
2660 
2661     UCHAR ReadCap;            // DevCap_*_read
2662 /*    UCHAR cd_r_read         : 1; // reserved in 1.2
2663     UCHAR cd_rw_read        : 1; // reserved in 1.2
2664     UCHAR method2           : 1;
2665     UCHAR dvd_rom           : 1;
2666     UCHAR dvd_r_read        : 1;
2667     UCHAR dvd_ram_read      : 1;
2668     UCHAR Reserved2            : 2;*/
2669 
2670 #define DevCap_write_cd_r         0x01 // reserved in 1.2
2671 #define DevCap_write_cd_rw        0x02 // reserved in 1.2
2672 #define DevCap_test_write         0x04
2673 #define DevCap_write_dvd_r        0x10
2674 #define DevCap_write_dvd_ram      0x20
2675 
2676     UCHAR WriteCap;            // DevCap_*_write
2677 /*    UCHAR cd_r_write        : 1; // reserved in 1.2
2678     UCHAR cd_rw_write        : 1; // reserved in 1.2
2679     UCHAR test_write        : 1;
2680     UCHAR reserved3a        : 1;
2681     UCHAR dvd_r_write       : 1;
2682     UCHAR dvd_ram_write     : 1;
2683     UCHAR Reserved3         : 2;*/
2684 
2685 #define DevCap_audio_play          0x01
2686 #define DevCap_composite          0x02
2687 #define DevCap_digport1           0x04
2688 #define DevCap_digport2           0x08
2689 #define DevCap_mode2_form1        0x10
2690 #define DevCap_mode2_form2        0x20
2691 #define DevCap_multisession       0x40
2692 
2693     UCHAR Capabilities0;
2694 /*    UCHAR audio_play        : 1;
2695     UCHAR composite         : 1;
2696     UCHAR digport1          : 1;
2697     UCHAR digport2          : 1;
2698     UCHAR mode2_form1       : 1;
2699     UCHAR mode2_form2       : 1;
2700     UCHAR multisession      : 1;
2701     UCHAR Reserved4         : 1;*/
2702 
2703 #define DevCap_cdda               0x01
2704 #define DevCap_cdda_accurate      0x02
2705 #define DevCap_rw_supported       0x04
2706 #define DevCap_rw_corr            0x08
2707 #define DevCap_c2_pointers        0x10
2708 #define DevCap_isrc               0x20
2709 #define DevCap_upc                0x40
2710 #define DevCap_read_bar_code      0x80
2711 
2712     UCHAR Capabilities1;
2713 /*    UCHAR cdda              : 1;
2714     UCHAR cdda_accurate     : 1;
2715     UCHAR rw_supported      : 1;
2716     UCHAR rw_corr           : 1;
2717     UCHAR c2_pointers       : 1;
2718     UCHAR isrc              : 1;
2719     UCHAR upc               : 1;
2720     UCHAR Reserved5         : 1;*/
2721 
2722 #define DevCap_lock               0x01
2723 #define DevCap_lock_state         0x02
2724 #define DevCap_prevent_jumper     0x04
2725 #define DevCap_eject              0x08
2726 #define DevCap_mechtype_mask      0xE0
2727 #define DevCap_mechtype_caddy      0x00
2728 #define DevCap_mechtype_tray      (0x01<<5)
2729 #define DevCap_mechtype_popup      (0x02<<5)
2730 #define DevCap_mechtype_individual_changer      (0x04<<5)
2731 #define DevCap_mechtype_cartridge_changer      (0x05<<5)
2732 
2733     UCHAR Capabilities2;
2734 /*    UCHAR lock              : 1;
2735     UCHAR lock_state        : 1;
2736     UCHAR prevent_jumper    : 1;
2737     UCHAR eject             : 1;
2738     UCHAR Reserved6         : 1;
2739     UCHAR mechtype        : 3;*/
2740 
2741 #define DevCap_separate_volume    0x01
2742 #define DevCap_separate_mute      0x02
2743 #define DevCap_disc_present       0x04          // reserved in 1.2
2744 #define DevCap_sw_slot_select     0x08          // reserved in 1.2
2745 #define DevCap_change_side_cap    0x10
2746 #define DevCap_rw_leadin_read     0x20
2747 
2748     UCHAR Capabilities3;
2749 /*    UCHAR separate_volume   : 1;
2750     UCHAR separate_mute     : 1;
2751     UCHAR disc_present      : 1;  // reserved in 1.2
2752     UCHAR sss               : 1;  // reserved in 1.2
2753     UCHAR Reserved7         : 4;*/
2754 
2755     UCHAR MaximumSpeedSupported[2];
2756     UCHAR NumberVolumeLevels[2];
2757     UCHAR BufferSize[2];
2758     UCHAR CurrentSpeed[2];
2759 
2760     UCHAR Reserved8;
2761 
2762     UCHAR SpecialParameters0;
2763 /*  UCHAR Reserved9        : 1;
2764     UCHAR BCK           : 1;
2765     UCHAR RCK           : 1;
2766     UCHAR LSBF          : 1;
2767     UCHAR Length        : 2;
2768     UCHAR Reserved10    : 2;*/
2769 
2770     UCHAR MaximumWriteSpeedSupported[2];
2771     UCHAR CurrentWriteSpeed[2];
2772     UCHAR CopyManagementRevision[2];
2773     UCHAR Reserved11[2];
2774 
2775 // MMC3
2776 
2777     UCHAR Reserved12;
2778 
2779     UCHAR SpecialParameters1;
2780 /*  UCHAR RCS           : 2; // rotation control selected
2781     UCHAR Reserved13    : 6; */
2782 
2783     UCHAR CurrentWriteSpeed3[2];
2784     UCHAR LunWPerfDescriptorCount[2];
2785 
2786 //    LUN_WRITE_PERF_DESC  LunWPerfDescriptor[0];
2787 
2788 } MODE_CAPABILITIES_PAGE2, *PMODE_CAPABILITIES_PAGE2;
2789 
2790 typedef struct _LUN_WRITE_PERF_DESC {
2791     UCHAR Reserved;
2792 
2793 #define LunWPerf_RotCtrl_Mask   0x07
2794 #define LunWPerf_RotCtrl_CLV    0x00
2795 #define LunWPerf_RotCtrl_CAV    0x01
2796 
2797     UCHAR RotationControl;
2798     UCHAR WriteSpeedSupported[2]; // kbps
2799 
2800 } LUN_WRITE_PERF_DESC, *PLUN_WRITE_PERF_DESC;
2801 
2802 // Mode parameter list block descriptor -
2803 // set the block length for reading/writing
2804 
2805 #define MODE_BLOCK_DESC_LENGTH               8
2806 #define MODE_HEADER_LENGTH                   4
2807 #define MODE_HEADER_LENGTH10                 8
2808 
2809 #define CDB_USE_MSF                0x01
2810 
2811 // Atapi 2.5 changer
2812 typedef struct _MECHANICAL_STATUS_INFORMATION_HEADER {
2813     UCHAR CurrentSlot : 5;
2814     UCHAR ChangerState : 2;
2815     UCHAR Fault : 1;
2816     UCHAR Reserved : 5;
2817     UCHAR MechanismState : 3;
2818     UCHAR CurrentLogicalBlockAddress[3];
2819     UCHAR NumberAvailableSlots;
2820     UCHAR SlotTableLength[2];
2821 } MECHANICAL_STATUS_INFORMATION_HEADER, *PMECHANICAL_STATUS_INFORMATION_HEADER;
2822 
2823 typedef struct _SLOT_TABLE_INFORMATION {
2824     UCHAR DiscChanged : 1;
2825     UCHAR Reserved : 6;
2826     UCHAR DiscPresent : 1;
2827     UCHAR Reserved2[3];
2828 } SLOT_TABLE_INFORMATION, *PSLOT_TABLE_INFORMATION;
2829 
2830 typedef struct _MECHANICAL_STATUS {
2831     MECHANICAL_STATUS_INFORMATION_HEADER MechanicalStatusHeader;
2832     SLOT_TABLE_INFORMATION SlotTableInfo[1];
2833 } MECHANICAL_STATUS, *PMECHANICAL_STATUS;
2834 
2835 // DVD structure blocks
2836 
2837 typedef struct _DVD_DESCRIPTOR_HEADER {
2838     UCHAR Length[2];
2839     UCHAR Reserved[2];
2840 } DVD_DESCRIPTOR_HEADER, *PDVD_DESCRIPTOR_HEADER;
2841 
2842 typedef struct _DVD_LAYER_DESCRIPTOR {
2843     DVD_DESCRIPTOR_HEADER Header;
2844     UCHAR Length[2];
2845     UCHAR BookVersion : 4;
2846     UCHAR BookType : 4;
2847     UCHAR MinimumRate : 4;
2848     UCHAR DiskSize : 4;
2849     UCHAR LayerType : 4;
2850     UCHAR TrackPath : 1;
2851     UCHAR NumberOfLayers : 2;
2852     UCHAR Reserved1 : 1;
2853     UCHAR TrackDensity : 4;
2854     UCHAR LinearDensity : 4;
2855     UCHAR StartingDataSector[4];
2856     UCHAR EndDataSector[4];
2857     UCHAR EndLayerZeroSector[4];
2858     UCHAR Reserved5 : 7;
2859     UCHAR BCAFlag : 1;
2860     UCHAR Reserved6;
2861 } DVD_LAYER_DESCRIPTOR, *PDVD_LAYER_DESCRIPTOR;
2862 
2863 typedef struct _DVD_COPYRIGHT_INFORMATION {
2864     UCHAR CopyrightProtectionSystemType;
2865     UCHAR RegionManagementInformation;
2866     UCHAR Reserved[2];
2867 } DVD_COPYRIGHT_INFORMATION, *PDVD_COPYRIGHT_INFORMATION;
2868 
2869 typedef struct _DVD_DISK_KEY_STRUCTURES {
2870     UCHAR DiskKeyData[2048];
2871 } DVD_DISK_KEY_STRUCTURES, *PDVD_DISK_KEY_STRUCTURES;
2872 
2873 typedef struct _CDVD_KEY_HEADER {
2874     UCHAR DataLength[2];
2875     UCHAR Reserved[2];
2876 } CDVD_KEY_HEADER, *PCDVD_KEY_HEADER;
2877 
2878 typedef struct _CDVD_REPORT_AGID_DATA {
2879     CDVD_KEY_HEADER Header;
2880     UCHAR Reserved1[3];
2881     UCHAR Reserved2 : 6;
2882     UCHAR AGID : 2;
2883 } CDVD_REPORT_AGID_DATA, *PCDVD_REPORT_AGID_DATA;
2884 
2885 typedef struct _CDVD_CHALLENGE_KEY_DATA {
2886     CDVD_KEY_HEADER Header;
2887     UCHAR ChallengeKeyValue[10];
2888     UCHAR Reserved[2];
2889 } CDVD_CHALLENGE_KEY_DATA, *PCDVD_CHALLENGE_KEY_DATA;
2890 
2891 typedef struct _CDVD_KEY_DATA {
2892     CDVD_KEY_HEADER Header;
2893     UCHAR Key[5];
2894     UCHAR Reserved[3];
2895 } CDVD_KEY_DATA, *PCDVD_KEY_DATA;
2896 
2897 typedef struct _CDVD_REPORT_ASF_DATA {
2898     CDVD_KEY_HEADER Header;
2899     UCHAR Reserved1[3];
2900     UCHAR Success : 1;
2901     UCHAR Reserved2 : 7;
2902 } CDVD_REPORT_ASF_DATA, *PCDVD_REPORT_ASF_DATA;
2903 
2904 typedef struct _CDVD_TITLE_KEY_HEADER {
2905     CDVD_KEY_HEADER Header;
2906     UCHAR DataLength[2];
2907     UCHAR Reserved1[1];
2908     UCHAR Reserved2 : 3;
2909     UCHAR CGMS : 2;
2910     UCHAR CP_SEC : 1;
2911     UCHAR CPM : 1;
2912     UCHAR Zero : 1;
2913     CDVD_KEY_DATA TitleKey;
2914 } CDVD_TITLE_KEY_HEADER, *PCDVD_TITLE_KEY_HEADER;
2915 
2916 typedef struct _DVD_COPYRIGHT_DESCRIPTOR {
2917     UCHAR CopyrightProtectionType;
2918     UCHAR RegionManagementInformation;
2919     UCHAR Reserved[2];
2920 } DVD_COPYRIGHT_DESCRIPTOR, *PDVD_COPYRIGHT_DESCRIPTOR;
2921 
2922 typedef struct _DVD_RPC_KEY {
2923     UCHAR UserResetsAvailable:3;
2924     UCHAR ManufacturerResetsAvailable:3;
2925     UCHAR TypeCode:2;
2926     UCHAR RegionMask;
2927     UCHAR RpcScheme;
2928     UCHAR Reserved2[1];
2929 } DVD_RPC_KEY, * PDVD_RPC_KEY;
2930 
2931 typedef struct _REPORT_LUNS_INFO_HDR {
2932     UCHAR ListLength[4];
2933     UCHAR Reserved[4];
2934 } REPORT_LUNS_INFO_HDR, *PREPORT_LUNS_INFO_HDR;
2935 
2936 
2937 #pragma pack(pop)
2938 
2939 #endif //__CDRW_DEVICE_H__
2940