Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / drivers / storage / include / scsi.h
1 /* $Id: scsi.h,v 1.5 2002/09/07 15:12:09 chorns Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/storage/include/scsi.h
6 * PURPOSE: SCSI class driver definitions
7 * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
8 */
9
10 #ifndef __STORAGE_INCLUDE_SCSI_H
11 #define __STORAGE_INCLUDE_SCSI_H
12
13
14 /* Command Descriptor Block */
15
16 typedef union _CDB
17 {
18 /* Generic 6-Byte CDB */
19 struct _CDB6GENERIC
20 {
21 UCHAR OperationCode;
22 UCHAR Immediate:1;
23 UCHAR CommandUniqueBits:4;
24 UCHAR LogicalUnitNumber:3;
25 UCHAR CommandUniqueBytes[3];
26 UCHAR Link:1;
27 UCHAR Flag:1;
28 UCHAR Reserved:4;
29 UCHAR VendorUnique:2;
30 } CDB6GENERIC, *PCDB6GENERIC;
31
32 /* Standard 6-byte CDB */
33 struct _CDB6READWRITE
34 {
35 UCHAR OperationCode;
36 UCHAR LogicalBlockMsb1:5;
37 UCHAR LogicalUnitNumber:3;
38 UCHAR LogicalBlockMsb0;
39 UCHAR LogicalBlockLsb;
40 UCHAR TransferBlocks;
41 UCHAR Control;
42 } CDB6READWRITE, *PCDB6READWRITE;
43
44 /* SCSI Inquiry CDB */
45 struct _CDB6INQUIRY
46 {
47 UCHAR OperationCode;
48 UCHAR Reserved1:5;
49 UCHAR LogicalUnitNumber:3;
50 UCHAR PageCode;
51 UCHAR IReserved;
52 UCHAR AllocationLength;
53 UCHAR Control;
54 } CDB6INQUIRY, *PCDB6INQUIRY;
55
56 /* SCSI Format CDB */
57 struct _CDB6FORMAT
58 {
59 UCHAR OperationCode;
60 UCHAR FormatControl:5;
61 UCHAR LogicalUnitNumber:3;
62 UCHAR FReserved1;
63 UCHAR InterleaveMsb;
64 UCHAR InterleaveLsb;
65 UCHAR FReserved2;
66 } CDB6FORMAT, *PCDB6FORMAT;
67
68 /* Standard 10-byte CDB */
69 struct _CDB10
70 {
71 UCHAR OperationCode;
72 UCHAR RelativeAddress:1;
73 UCHAR Reserved1:2;
74 UCHAR ForceUnitAccess:1;
75 UCHAR DisablePageOut:1;
76 UCHAR LogicalUnitNumber:3;
77 UCHAR LogicalBlockByte0;
78 UCHAR LogicalBlockByte1;
79 UCHAR LogicalBlockByte2;
80 UCHAR LogicalBlockByte3;
81 UCHAR Reserved2;
82 UCHAR TransferBlocksMsb;
83 UCHAR TransferBlocksLsb;
84 UCHAR Control;
85 } CDB10, *PCDB10;
86
87 /* CD Rom Audio CDBs */
88 struct _PAUSE_RESUME
89 {
90 UCHAR OperationCode;
91 UCHAR Reserved1:5;
92 UCHAR LogicalUnitNumber:3;
93 UCHAR Reserved2[6];
94 UCHAR Action;
95 UCHAR Control;
96 } PAUSE_RESUME, *PPAUSE_RESUME;
97
98 /* Read Table of Contents */
99 struct _READ_TOC
100 {
101 UCHAR OperationCode;
102 UCHAR Reserved0:1;
103 UCHAR Msf:1;
104 UCHAR Reserved1:3;
105 UCHAR LogicalUnitNumber:3;
106 UCHAR Reserved2[4];
107 UCHAR StartingTrack;
108 UCHAR AllocationLength[2];
109 UCHAR Control:6;
110 UCHAR Format:2;
111 } READ_TOC, *PREAD_TOC;
112
113 struct _PLAY_AUDIO_MSF
114 {
115 UCHAR OperationCode;
116 UCHAR Reserved1:5;
117 UCHAR LogicalUnitNumber:3;
118 UCHAR Reserved2;
119 UCHAR StartingM;
120 UCHAR StartingS;
121 UCHAR StartingF;
122 UCHAR EndingM;
123 UCHAR EndingS;
124 UCHAR EndingF;
125 UCHAR Control;
126 } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
127
128 /* Read SubChannel Data */
129 struct _SUBCHANNEL
130 {
131 UCHAR OperationCode;
132 UCHAR Reserved0:1;
133 UCHAR Msf:1;
134 UCHAR Reserved1:3;
135 UCHAR LogicalUnitNumber:3;
136 UCHAR Reserved2:6;
137 UCHAR SubQ:1;
138 UCHAR Reserved3:1;
139 UCHAR Format;
140 UCHAR Reserved4[2];
141 UCHAR TrackNumber;
142 UCHAR AllocationLength[2];
143 UCHAR Control;
144 } SUBCHANNEL, *PSUBCHANNEL;
145
146 /* Read CD. Used by Atapi for raw sector reads. */
147 struct _READ_CD
148 {
149 UCHAR OperationCode;
150 UCHAR Reserved0:2;
151 UCHAR ExpectedSectorType:3;
152 UCHAR Reserved1:3;
153 UCHAR StartingLBA[4];
154 UCHAR TransferBlocks[3];
155 UCHAR Reserved2:1;
156 UCHAR ErrorFlags:2;
157 UCHAR IncludeEDC:1;
158 UCHAR IncludeUserData:1;
159 UCHAR HeaderCode:2;
160 UCHAR IncludeSyncData:1;
161 UCHAR SubChannelSelection:3;
162 UCHAR Reserved3:5;
163 UCHAR Reserved4;
164 } READ_CD, *PREAD_CD;
165
166 /* Plextor Read CD-DA */
167 struct _PLXTR_READ_CDDA
168 {
169 UCHAR OperationCode;
170 UCHAR Reserved0:5;
171 UCHAR LogicalUnitNumber:3;
172 UCHAR LogicalBlockByte0;
173 UCHAR LogicalBlockByte1;
174 UCHAR LogicalBlockByte2;
175 UCHAR LogicalBlockByte3;
176 UCHAR TransferBlockByte0;
177 UCHAR TransferBlockByte1;
178 UCHAR TransferBlockByte2;
179 UCHAR TransferBlockByte3;
180 UCHAR SubCode;
181 UCHAR Control;
182 } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
183
184 /* NEC Read CD-DA */
185 struct _NEC_READ_CDDA
186 {
187 UCHAR OperationCode;
188 UCHAR Reserved0;
189 UCHAR LogicalBlockByte0;
190 UCHAR LogicalBlockByte1;
191 UCHAR LogicalBlockByte2;
192 UCHAR LogicalBlockByte3;
193 UCHAR Reserved1;
194 UCHAR TransferBlockByte0;
195 UCHAR TransferBlockByte1;
196 UCHAR Control;
197 } NEC_READ_CDDA, *PNEC_READ_CDDA;
198
199 /* Mode sense */
200 struct _MODE_SENSE
201 {
202 UCHAR OperationCode;
203 UCHAR Reserved1:3;
204 UCHAR Dbd:1;
205 UCHAR Reserved2:1;
206 UCHAR LogicalUnitNumber:3;
207 UCHAR PageCode:6;
208 UCHAR Pc:2;
209 UCHAR Reserved3;
210 UCHAR AllocationLength;
211 UCHAR Control;
212 } MODE_SENSE, *PMODE_SENSE;
213
214 struct _MODE_SENSE10
215 {
216 UCHAR OperationCode;
217 UCHAR Reserved1:3;
218 UCHAR Dbd:1;
219 UCHAR Reserved2:1;
220 UCHAR LogicalUnitNumber:3;
221 UCHAR PageCode:6;
222 UCHAR Pc:2;
223 UCHAR Reserved3[4];
224 UCHAR AllocationLength[2];
225 UCHAR Control;
226 } MODE_SENSE10, *PMODE_SENSE10;
227
228 /* Mode select */
229 struct _MODE_SELECT
230 {
231 UCHAR OperationCode;
232 UCHAR SPBit:1;
233 UCHAR Reserved1:3;
234 UCHAR PFBit:1;
235 UCHAR LogicalUnitNumber:3;
236 UCHAR Reserved2[2];
237 UCHAR ParameterListLength;
238 UCHAR Control;
239 } MODE_SELECT, *PMODE_SELECT;
240
241 struct _MODE_SELECT10
242 {
243 UCHAR OperationCode;
244 UCHAR SPBit:1;
245 UCHAR Reserved1:3;
246 UCHAR PFBit:1;
247 UCHAR LogicalUnitNumber:3;
248 UCHAR Reserved2[5];
249 UCHAR ParameterListLength[2];
250 UCHAR Control;
251 } MODE_SELECT10, *PMODE_SELECT10;
252
253 struct _LOCATE
254 {
255 UCHAR OperationCode;
256 UCHAR Immediate:1;
257 UCHAR CPBit:1;
258 UCHAR BTBit:1;
259 UCHAR Reserved1:2;
260 UCHAR LogicalUnitNumber:3;
261 UCHAR Reserved3;
262 UCHAR LogicalBlockAddress[4];
263 UCHAR Reserved4;
264 UCHAR Partition;
265 UCHAR Control;
266 } LOCATE, *PLOCATE;
267
268 struct _LOGSENSE
269 {
270 UCHAR OperationCode;
271 UCHAR SPBit:1;
272 UCHAR PPCBit:1;
273 UCHAR Reserved1:3;
274 UCHAR LogicalUnitNumber:3;
275 UCHAR PageCode:6;
276 UCHAR PCBit:2;
277 UCHAR Reserved2;
278 UCHAR Reserved3;
279 UCHAR ParameterPointer[2]; /* [0]=MSB, [1]=LSB */
280 UCHAR AllocationLength[2]; /* [0]=MSB, [1]=LSB */
281 UCHAR Control;
282 } LOGSENSE, *PLOGSENSE;
283
284 struct _PRINT
285 {
286 UCHAR OperationCode;
287 UCHAR Reserved:5;
288 UCHAR LogicalUnitNumber:3;
289 UCHAR TransferLength[3];
290 UCHAR Control;
291 } PRINT, *PPRINT;
292
293 struct _SEEK
294 {
295 UCHAR OperationCode;
296 UCHAR Reserved1:5;
297 UCHAR LogicalUnitNumber:3;
298 UCHAR LogicalBlockAddress[4];
299 UCHAR Reserved2[3];
300 UCHAR Control;
301 } SEEK, *PSEEK;
302
303 struct _ERASE
304 {
305 UCHAR OperationCode;
306 UCHAR Long:1;
307 UCHAR Immediate:1;
308 UCHAR Reserved1:3;
309 UCHAR LogicalUnitNumber:3;
310 UCHAR Reserved2[3];
311 UCHAR Control;
312 } ERASE, *PERASE;
313
314 struct _START_STOP
315 {
316 UCHAR OperationCode;
317 UCHAR Immediate:1;
318 UCHAR Reserved1:4;
319 UCHAR LogicalUnitNumber:3;
320 UCHAR Reserved2[2];
321 UCHAR Start:1;
322 UCHAR LoadEject:1;
323 UCHAR Reserved3:6;
324 UCHAR Control;
325 } START_STOP, *PSTART_STOP;
326
327 struct _MEDIA_REMOVAL
328 {
329 UCHAR OperationCode;
330 UCHAR Reserved1:5;
331 UCHAR LogicalUnitNumber:3;
332 UCHAR Reserved2[2];
333 UCHAR Prevent;
334 UCHAR Control;
335 } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
336
337 /* Tape CDBs */
338 struct _SEEK_BLOCK
339 {
340 UCHAR OperationCode;
341 UCHAR Immediate:1;
342 UCHAR Reserved1:7;
343 UCHAR BlockAddress[3];
344 UCHAR Link:1;
345 UCHAR Flag:1;
346 UCHAR Reserved2:4;
347 UCHAR VendorUnique:2;
348 } SEEK_BLOCK, *PSEEK_BLOCK;
349
350 struct _REQUEST_BLOCK_ADDRESS
351 {
352 UCHAR OperationCode;
353 UCHAR Reserved1[3];
354 UCHAR AllocationLength;
355 UCHAR Link:1;
356 UCHAR Flag:1;
357 UCHAR Reserved2:4;
358 UCHAR VendorUnique:2;
359 } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
360
361 struct _PARTITION
362 {
363 UCHAR OperationCode;
364 UCHAR Immediate:1;
365 UCHAR Sel:1;
366 UCHAR PartitionSelect:6;
367 UCHAR Reserved1[3];
368 UCHAR Control;
369 } PARTITION, *PPARTITION;
370
371 struct _WRITE_TAPE_MARKS
372 {
373 UCHAR OperationCode;
374 UCHAR Immediate:1;
375 UCHAR WriteSetMarks:1;
376 UCHAR Reserved:3;
377 UCHAR LogicalUnitNumber:3;
378 UCHAR TransferLength[3];
379 UCHAR Control;
380 } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
381
382 struct _SPACE_TAPE_MARKS
383 {
384 UCHAR OperationCode;
385 UCHAR Code:3;
386 UCHAR Reserved:2;
387 UCHAR LogicalUnitNumber:3;
388 UCHAR NumMarksMSB ;
389 UCHAR NumMarks;
390 UCHAR NumMarksLSB;
391 union
392 {
393 UCHAR value;
394 struct
395 {
396 UCHAR Link:1;
397 UCHAR Flag:1;
398 UCHAR Reserved:4;
399 UCHAR VendorUnique:2;
400 } Fields;
401 } Byte6;
402 } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
403
404 /* Read tape position */
405 struct _READ_POSITION
406 {
407 UCHAR Operation;
408 UCHAR BlockType:1;
409 UCHAR Reserved1:4;
410 UCHAR Lun:3;
411 UCHAR Reserved2[7];
412 UCHAR Control;
413 } READ_POSITION, *PREAD_POSITION;
414
415 /* ReadWrite for Tape */
416 struct _CDB6READWRITETAPE
417 {
418 UCHAR OperationCode;
419 UCHAR VendorSpecific:5;
420 UCHAR Reserved:3;
421 UCHAR TransferLenMSB;
422 UCHAR TransferLen;
423 UCHAR TransferLenLSB;
424 UCHAR Link:1;
425 UCHAR Flag:1;
426 UCHAR Reserved1:4;
427 UCHAR VendorUnique:2;
428 } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
429
430 /* Atapi 2.5 Changer 12-byte CDBs */
431 struct _LOAD_UNLOAD
432 {
433 UCHAR OperationCode;
434 UCHAR Immediate:1;
435 UCHAR Reserved1:7;
436 UCHAR Reserved2[2];
437 UCHAR Start:1;
438 UCHAR LoadEject:1;
439 UCHAR Reserved3:6;
440 UCHAR Reserved4[3];
441 UCHAR Slot;
442 UCHAR Reserved5[3];
443 } LOAD_UNLOAD, *PLOAD_UNLOAD;
444
445 struct _MECH_STATUS
446 {
447 UCHAR OperationCode;
448 UCHAR Reserved1[7];
449 UCHAR AllocationLength[2];
450 UCHAR Reserved2[2];
451 } MECH_STATUS, *PMECH_STATUS;
452 } CDB, *PCDB;
453
454
455 /* Command Descriptor Block constants */
456
457 #define CDB6GENERIC_LENGTH 6
458 #define CDB10GENERIC_LENGTH 10
459 #define CDB12GENERIC_LENGTH 12
460
461 #define SETBITON 1
462 #define SETBITOFF 0
463
464
465 /* Mode Sense/Select page constants */
466
467 #define MODE_PAGE_ERROR_RECOVERY 0x01
468 #define MODE_PAGE_DISCONNECT 0x02
469 #define MODE_PAGE_FORMAT_DEVICE 0x03
470 #define MODE_PAGE_RIGID_GEOMETRY 0x04
471 #define MODE_PAGE_FLEXIBILE 0x05
472 #define MODE_PAGE_VERIFY_ERROR 0x07
473 #define MODE_PAGE_CACHING 0x08
474 #define MODE_PAGE_PERIPHERAL 0x09
475 #define MODE_PAGE_CONTROL 0x0A
476 #define MODE_PAGE_MEDIUM_TYPES 0x0B
477 #define MODE_PAGE_NOTCH_PARTITION 0x0C
478 #define MODE_SENSE_RETURN_ALL 0x3f
479 #define MODE_SENSE_CURRENT_VALUES 0x00
480 #define MODE_SENSE_CHANGEABLE_VALUES 0x40
481 #define MODE_SENSE_DEFAULT_VAULES 0x80
482 #define MODE_SENSE_SAVED_VALUES 0xc0
483 #define MODE_PAGE_DEVICE_CONFIG 0x10
484 #define MODE_PAGE_MEDIUM_PARTITION 0x11
485 #define MODE_PAGE_DATA_COMPRESS 0x0f
486 #define MODE_PAGE_CAPABILITIES 0x2A
487
488
489 /* SCSI CDB operation codes */
490
491 #define SCSIOP_TEST_UNIT_READY 0x00
492 #define SCSIOP_REZERO_UNIT 0x01
493 #define SCSIOP_REWIND 0x01
494 #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
495 #define SCSIOP_REQUEST_SENSE 0x03
496 #define SCSIOP_FORMAT_UNIT 0x04
497 #define SCSIOP_READ_BLOCK_LIMITS 0x05
498 #define SCSIOP_REASSIGN_BLOCKS 0x07
499 #define SCSIOP_READ6 0x08
500 #define SCSIOP_RECEIVE 0x08
501 #define SCSIOP_WRITE6 0x0A
502 #define SCSIOP_PRINT 0x0A
503 #define SCSIOP_SEND 0x0A
504 #define SCSIOP_SEEK6 0x0B
505 #define SCSIOP_TRACK_SELECT 0x0B
506 #define SCSIOP_SLEW_PRINT 0x0B
507 #define SCSIOP_SEEK_BLOCK 0x0C
508 #define SCSIOP_PARTITION 0x0D
509 #define SCSIOP_READ_REVERSE 0x0F
510 #define SCSIOP_WRITE_FILEMARKS 0x10
511 #define SCSIOP_FLUSH_BUFFER 0x10
512 #define SCSIOP_SPACE 0x11
513 #define SCSIOP_INQUIRY 0x12
514 #define SCSIOP_VERIFY6 0x13
515 #define SCSIOP_RECOVER_BUF_DATA 0x14
516 #define SCSIOP_MODE_SELECT 0x15
517 #define SCSIOP_RESERVE_UNIT 0x16
518 #define SCSIOP_RELEASE_UNIT 0x17
519 #define SCSIOP_COPY 0x18
520 #define SCSIOP_ERASE 0x19
521 #define SCSIOP_MODE_SENSE 0x1A
522 #define SCSIOP_START_STOP_UNIT 0x1B
523 #define SCSIOP_STOP_PRINT 0x1B
524 #define SCSIOP_LOAD_UNLOAD 0x1B
525 #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
526 #define SCSIOP_SEND_DIAGNOSTIC 0x1D
527 #define SCSIOP_MEDIUM_REMOVAL 0x1E
528 #define SCSIOP_READ_CAPACITY 0x25
529 #define SCSIOP_READ 0x28
530 #define SCSIOP_WRITE 0x2A
531 #define SCSIOP_SEEK 0x2B
532 #define SCSIOP_LOCATE 0x2B
533 #define SCSIOP_WRITE_VERIFY 0x2E
534 #define SCSIOP_VERIFY 0x2F
535 #define SCSIOP_SEARCH_DATA_HIGH 0x30
536 #define SCSIOP_SEARCH_DATA_EQUAL 0x31
537 #define SCSIOP_SEARCH_DATA_LOW 0x32
538 #define SCSIOP_SET_LIMITS 0x33
539 #define SCSIOP_READ_POSITION 0x34
540 #define SCSIOP_SYNCHRONIZE_CACHE 0x35
541 #define SCSIOP_COMPARE 0x39
542 #define SCSIOP_COPY_COMPARE 0x3A
543 #define SCSIOP_WRITE_DATA_BUFF 0x3B
544 #define SCSIOP_READ_DATA_BUFF 0x3C
545 #define SCSIOP_CHANGE_DEFINITION 0x40
546 #define SCSIOP_READ_SUB_CHANNEL 0x42
547 #define SCSIOP_READ_TOC 0x43
548 #define SCSIOP_READ_HEADER 0x44
549 #define SCSIOP_PLAY_AUDIO 0x45
550 #define SCSIOP_PLAY_AUDIO_MSF 0x47
551 #define SCSIOP_PLAY_TRACK_INDEX 0x48
552 #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
553 #define SCSIOP_PAUSE_RESUME 0x4B
554 #define SCSIOP_LOG_SELECT 0x4C
555 #define SCSIOP_LOG_SENSE 0x4D
556 #define SCSIOP_MODE_SELECT10 0x55
557 #define SCSIOP_MODE_SENSE10 0x5A
558 #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
559 #define SCSIOP_MECHANISM_STATUS 0xBD
560 #define SCSIOP_READ_CD 0xBE
561
562 //
563 // If the IMMED bit is 1, status is returned as soon
564 // as the operation is initiated. If the IMMED bit
565 // is 0, status is not returned until the operation
566 // is completed.
567 //
568
569 #define CDB_RETURN_ON_COMPLETION 0
570 #define CDB_RETURN_IMMEDIATE 1
571
572
573 //
574 // CDB Force media access used in extended read and write commands.
575 //
576
577 #define CDB_FORCE_MEDIA_ACCESS 0x08
578
579 //
580 // Denon CD ROM operation codes
581 //
582
583 #define SCSIOP_DENON_EJECT_DISC 0xE6
584 #define SCSIOP_DENON_STOP_AUDIO 0xE7
585 #define SCSIOP_DENON_PLAY_AUDIO 0xE8
586 #define SCSIOP_DENON_READ_TOC 0xE9
587 #define SCSIOP_DENON_READ_SUBCODE 0xEB
588
589 //
590 // SCSI Bus Messages
591 //
592
593 #define SCSIMESS_ABORT 0x06
594 #define SCSIMESS_ABORT_WITH_TAG 0x0D
595 #define SCSIMESS_BUS_DEVICE_RESET 0X0C
596 #define SCSIMESS_CLEAR_QUEUE 0X0E
597 #define SCSIMESS_COMMAND_COMPLETE 0X00
598 #define SCSIMESS_DISCONNECT 0X04
599 #define SCSIMESS_EXTENDED_MESSAGE 0X01
600 #define SCSIMESS_IDENTIFY 0X80
601 #define SCSIMESS_IDENTIFY_WITH_DISCON 0XC0
602 #define SCSIMESS_IGNORE_WIDE_RESIDUE 0X23
603 #define SCSIMESS_INITIATE_RECOVERY 0X0F
604 #define SCSIMESS_INIT_DETECTED_ERROR 0X05
605 #define SCSIMESS_LINK_CMD_COMP 0X0A
606 #define SCSIMESS_LINK_CMD_COMP_W_FLAG 0X0B
607 #define SCSIMESS_MESS_PARITY_ERROR 0X09
608 #define SCSIMESS_MESSAGE_REJECT 0X07
609 #define SCSIMESS_NO_OPERATION 0X08
610 #define SCSIMESS_HEAD_OF_QUEUE_TAG 0X21
611 #define SCSIMESS_ORDERED_QUEUE_TAG 0X22
612 #define SCSIMESS_SIMPLE_QUEUE_TAG 0X20
613 #define SCSIMESS_RELEASE_RECOVERY 0X10
614 #define SCSIMESS_RESTORE_POINTERS 0X03
615 #define SCSIMESS_SAVE_DATA_POINTER 0X02
616 #define SCSIMESS_TERMINATE_IO_PROCESS 0X11
617
618 //
619 // SCSI Extended Message operation codes
620 //
621
622 #define SCSIMESS_MODIFY_DATA_POINTER 0X00
623 #define SCSIMESS_SYNCHRONOUS_DATA_REQ 0X01
624 #define SCSIMESS_WIDE_DATA_REQUEST 0X03
625
626 //
627 // SCSI Extended Message Lengths
628 //
629
630 #define SCSIMESS_MODIFY_DATA_LENGTH 5
631 #define SCSIMESS_SYNCH_DATA_LENGTH 3
632 #define SCSIMESS_WIDE_DATA_LENGTH 2
633
634 //
635 // SCSI extended message structure
636 //
637
638 #pragma pack (1)
639 typedef struct _SCSI_EXTENDED_MESSAGE
640 {
641 UCHAR InitialMessageCode;
642 UCHAR MessageLength;
643 UCHAR MessageType;
644 union _EXTENDED_ARGUMENTS
645 {
646 struct
647 {
648 UCHAR Modifier[4];
649 } Modify;
650
651 struct
652 {
653 UCHAR TransferPeriod;
654 UCHAR ReqAckOffset;
655 } Synchronous;
656
657 struct
658 {
659 UCHAR Width;
660 } Wide;
661 } ExtendedArguments;
662 }SCSI_EXTENDED_MESSAGE, *PSCSI_EXTENDED_MESSAGE;
663 #pragma pack ()
664
665
666 /* SCSI bus status codes */
667
668 #define SCSISTAT_GOOD 0x00
669 #define SCSISTAT_CHECK_CONDITION 0x02
670 #define SCSISTAT_CONDITION_MET 0x04
671 #define SCSISTAT_BUSY 0x08
672 #define SCSISTAT_INTERMEDIATE 0x10
673 #define SCSISTAT_INTERMEDIATE_COND_MET 0x14
674 #define SCSISTAT_RESERVATION_CONFLICT 0x18
675 #define SCSISTAT_COMMAND_TERMINATED 0x22
676 #define SCSISTAT_QUEUE_FULL 0x28
677
678 //
679 // Enable Vital Product Data Flag (EVPD)
680 // used with INQUIRY command.
681 //
682
683 #define CDB_INQUIRY_EVPD 0x01
684
685 //
686 // Defines for format CDB
687 //
688
689 #define LUN0_FORMAT_SAVING_DEFECT_LIST 0
690 #define USE_DEFAULTMSB 0
691 #define USE_DEFAULTLSB 0
692
693 #define START_UNIT_CODE 0x01
694 #define STOP_UNIT_CODE 0x00
695
696
697
698 //
699 // Inquiry buffer structure. This is the data returned from the target
700 // after it receives an inquiry.
701 //
702 // This structure may be extended by the number of bytes specified
703 // in the field AdditionalLength. The defined size constant only
704 // includes fields through ProductRevisionLevel.
705 //
706 // The NT SCSI drivers are only interested in the first 36 bytes of data.
707 //
708
709 #define INQUIRYDATABUFFERSIZE 36
710
711
712 typedef struct _INQUIRYDATA
713 {
714 UCHAR DeviceType:5;
715 UCHAR DeviceTypeQualifier:3;
716 UCHAR DeviceTypeModifier:7;
717 UCHAR RemovableMedia:1;
718 UCHAR Versions;
719 UCHAR ResponseDataFormat;
720 UCHAR AdditionalLength;
721 UCHAR Reserved[2];
722 UCHAR SoftReset:1;
723 UCHAR CommandQueue:1;
724 UCHAR Reserved2:1;
725 UCHAR LinkedCommands:1;
726 UCHAR Synchronous:1;
727 UCHAR Wide16Bit:1;
728 UCHAR Wide32Bit:1;
729 UCHAR RelativeAddressing:1;
730 UCHAR VendorId[8];
731 UCHAR ProductId[16];
732 UCHAR ProductRevisionLevel[4];
733 UCHAR VendorSpecific[20];
734 UCHAR Reserved3[40];
735 } INQUIRYDATA, *PINQUIRYDATA;
736
737 //
738 // Inquiry defines. Used to interpret data returned from target as result
739 // of inquiry command.
740 //
741 // DeviceType field
742 //
743
744 #define DIRECT_ACCESS_DEVICE 0x00 // disks
745 #define SEQUENTIAL_ACCESS_DEVICE 0x01 // tapes
746 #define PRINTER_DEVICE 0x02 // printers
747 #define PROCESSOR_DEVICE 0x03 // scanners, printers, etc
748 #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04 // worms
749 #define READ_ONLY_DIRECT_ACCESS_DEVICE 0x05 // cdroms
750 #define SCANNER_DEVICE 0x06 // scanners
751 #define OPTICAL_DEVICE 0x07 // optical disks
752 #define MEDIUM_CHANGER 0x08 // jukebox
753 #define COMMUNICATION_DEVICE 0x09 // network
754 #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
755 #define DEVICE_QUALIFIER_NOT_SUPPORTED 0x03
756
757 //
758 // DeviceTypeQualifier field
759 //
760
761 #define DEVICE_CONNECTED 0x00
762
763
764 /* Sense Data Format */
765
766 typedef struct _SENSE_DATA
767 {
768 UCHAR ErrorCode:7;
769 UCHAR Valid:1;
770 UCHAR SegmentNumber;
771 UCHAR SenseKey:4;
772 UCHAR Reserved:1;
773 UCHAR IncorrectLength:1;
774 UCHAR EndOfMedia:1;
775 UCHAR FileMark:1;
776 UCHAR Information[4];
777 UCHAR AdditionalSenseLength;
778 UCHAR CommandSpecificInformation[4];
779 UCHAR AdditionalSenseCode;
780 UCHAR AdditionalSenseCodeQualifier;
781 UCHAR FieldReplaceableUnitCode;
782 UCHAR SenseKeySpecific[3];
783 } SENSE_DATA, *PSENSE_DATA;
784
785
786 /* Default request sense buffer size */
787
788 #define SENSE_BUFFER_SIZE 18
789
790 /* Sense codes */
791
792 #define SCSI_SENSE_NO_SENSE 0x00
793 #define SCSI_SENSE_RECOVERED_ERROR 0x01
794 #define SCSI_SENSE_NOT_READY 0x02
795 #define SCSI_SENSE_MEDIUM_ERROR 0x03
796 #define SCSI_SENSE_HARDWARE_ERROR 0x04
797 #define SCSI_SENSE_ILLEGAL_REQUEST 0x05
798 #define SCSI_SENSE_UNIT_ATTENTION 0x06
799 #define SCSI_SENSE_DATA_PROTECT 0x07
800 #define SCSI_SENSE_BLANK_CHECK 0x08
801 #define SCSI_SENSE_UNIQUE 0x09
802 #define SCSI_SENSE_COPY_ABORTED 0x0A
803 #define SCSI_SENSE_ABORTED_COMMAND 0x0B
804 #define SCSI_SENSE_EQUAL 0x0C
805 #define SCSI_SENSE_VOL_OVERFLOW 0x0D
806 #define SCSI_SENSE_MISCOMPARE 0x0E
807 #define SCSI_SENSE_RESERVED 0x0F
808
809 /* Additional tape bit */
810
811 #define SCSI_ILLEGAL_LENGTH 0x20
812 #define SCSI_EOM 0x40
813 #define SCSI_FILE_MARK 0x80
814
815 /* Additional Sense codes */
816
817 #define SCSI_ADSENSE_NO_SENSE 0x00
818 #define SCSI_ADSENSE_LUN_NOT_READY 0x04
819 #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
820 #define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
821 #define SCSI_ADSENSE_INVALID_LUN 0x25
822 #define SCSI_ADSENSE_INVALID_CDB 0x24
823 #define SCSI_ADSENSE_MUSIC_AREA 0xA0
824 #define SCSI_ADSENSE_DATA_AREA 0xA1
825 #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
826
827 #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
828 #define SCSI_ADWRITE_PROTECT 0x27
829 #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
830 #define SCSI_ADSENSE_BUS_RESET 0x29
831 #define SCSI_ADSENSE_TRACK_ERROR 0x14
832 #define SCSI_ADSENSE_SEEK_ERROR 0x15
833 #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
834 #define SCSI_ADSENSE_REC_DATA_ECC 0x18
835
836 /* Additional sense code qualifier */
837
838 #define SCSI_SENSEQ_FORMAT_IN_PROGRESS 0x04
839 #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED 0x02
840 #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
841 #define SCSI_SENSEQ_BECOMING_READY 0x01
842 #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
843 #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
844 #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
845 #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
846
847
848
849
850
851
852
853
854
855
856
857
858
859 /* SCSI IO Device Control Codes */
860
861 #define FILE_DEVICE_SCSI 0x0000001b
862
863 #define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
864 #define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
865 #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
866
867 /* SMART support in atapi */
868
869 #define IOCTL_SCSI_MINIPORT_SMART_VERSION ((FILE_DEVICE_SCSI << 16) + 0x0500)
870 #define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501)
871 #define IOCTL_SCSI_MINIPORT_READ_SMART_ATTRIBS ((FILE_DEVICE_SCSI << 16) + 0x0502)
872 #define IOCTL_SCSI_MINIPORT_READ_SMART_THRESHOLDS ((FILE_DEVICE_SCSI << 16) + 0x0503)
873 #define IOCTL_SCSI_MINIPORT_ENABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0504)
874 #define IOCTL_SCSI_MINIPORT_DISABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0505)
875 #define IOCTL_SCSI_MINIPORT_RETURN_STATUS ((FILE_DEVICE_SCSI << 16) + 0x0506)
876 #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTOSAVE ((FILE_DEVICE_SCSI << 16) + 0x0507)
877 #define IOCTL_SCSI_MINIPORT_SAVE_ATTRIBUTE_VALUES ((FILE_DEVICE_SCSI << 16) + 0x0508)
878 #define IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS ((FILE_DEVICE_SCSI << 16) + 0x0509)
879
880
881 /* Read Capacity Data - returned in Big Endian format */
882
883 typedef struct _READ_CAPACITY_DATA
884 {
885 ULONG LogicalBlockAddress;
886 ULONG BytesPerBlock;
887 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
888
889
890 //
891 // Read Block Limits Data - returned in Big Endian format
892 // This structure returns the maximum and minimum block
893 // size for a TAPE device.
894 //
895
896 typedef struct _READ_BLOCK_LIMITS
897 {
898 UCHAR Reserved;
899 UCHAR BlockMaximumSize[3];
900 UCHAR BlockMinimumSize[2];
901 } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
902
903
904 //
905 // Mode data structures.
906 //
907
908 //
909 // Define Mode parameter header.
910 //
911
912 typedef struct _MODE_PARAMETER_HEADER
913 {
914 UCHAR ModeDataLength;
915 UCHAR MediumType;
916 UCHAR DeviceSpecificParameter;
917 UCHAR BlockDescriptorLength;
918 }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
919
920 typedef struct _MODE_PARAMETER_HEADER10
921 {
922 UCHAR ModeDataLength[2];
923 UCHAR MediumType;
924 UCHAR DeviceSpecificParameter;
925 UCHAR Reserved[2];
926 UCHAR BlockDescriptorLength[2];
927 }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
928
929 #define MODE_FD_SINGLE_SIDE 0x01
930 #define MODE_FD_DOUBLE_SIDE 0x02
931 #define MODE_FD_MAXIMUM_TYPE 0x1E
932 #define MODE_DSP_FUA_SUPPORTED 0x10
933 #define MODE_DSP_WRITE_PROTECT 0x80
934
935 //
936 // Define the mode parameter block.
937 //
938
939 typedef struct _MODE_PARAMETER_BLOCK
940 {
941 UCHAR DensityCode;
942 UCHAR NumberOfBlocks[3];
943 UCHAR Reserved;
944 UCHAR BlockLength[3];
945 }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
946
947
948 /* Define Disconnect-Reconnect page */
949 typedef struct _MODE_DISCONNECT_PAGE
950 {
951 UCHAR PageCode:6;
952 UCHAR Reserved:1;
953 UCHAR PageSavable:1;
954 UCHAR PageLength;
955 UCHAR BufferFullRatio;
956 UCHAR BufferEmptyRatio;
957 UCHAR BusInactivityLimit[2];
958 UCHAR BusDisconnectTime[2];
959 UCHAR BusConnectTime[2];
960 UCHAR MaximumBurstSize[2];
961 UCHAR DataTransferDisconnect:2;
962 UCHAR Reserved2[3];
963 }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
964
965 //
966 // Define mode caching page.
967 //
968
969 typedef struct _MODE_CACHING_PAGE
970 {
971 UCHAR PageCode:6;
972 UCHAR Reserved:1;
973 UCHAR PageSavable:1;
974 UCHAR PageLength;
975 UCHAR ReadDisableCache:1;
976 UCHAR MultiplicationFactor:1;
977 UCHAR WriteCacheEnable:1;
978 UCHAR Reserved2:5;
979 UCHAR WriteRetensionPriority:4;
980 UCHAR ReadRetensionPriority:4;
981 UCHAR DisablePrefetchTransfer[2];
982 UCHAR MinimumPrefetch[2];
983 UCHAR MaximumPrefetch[2];
984 UCHAR MaximumPrefetchCeiling[2];
985 }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
986
987 //
988 // Define mode flexible disk page.
989 //
990
991 typedef struct _MODE_FLEXIBLE_DISK_PAGE
992 {
993 UCHAR PageCode:6;
994 UCHAR Reserved:1;
995 UCHAR PageSavable:1;
996 UCHAR PageLength;
997 UCHAR TransferRate[2];
998 UCHAR NumberOfHeads;
999 UCHAR SectorsPerTrack;
1000 UCHAR BytesPerSector[2];
1001 UCHAR NumberOfCylinders[2];
1002 UCHAR StartWritePrecom[2];
1003 UCHAR StartReducedCurrent[2];
1004 UCHAR StepRate[2];
1005 UCHAR StepPluseWidth;
1006 UCHAR HeadSettleDelay[2];
1007 UCHAR MotorOnDelay;
1008 UCHAR MotorOffDelay;
1009 UCHAR Reserved2:5;
1010 UCHAR MotorOnAsserted:1;
1011 UCHAR StartSectorNumber:1;
1012 UCHAR TrueReadySignal:1;
1013 UCHAR StepPlusePerCyclynder:4;
1014 UCHAR Reserved3:4;
1015 UCHAR WriteCompenstation;
1016 UCHAR HeadLoadDelay;
1017 UCHAR HeadUnloadDelay;
1018 UCHAR Pin2Usage:4;
1019 UCHAR Pin34Usage:4;
1020 UCHAR Pin1Usage:4;
1021 UCHAR Pin4Usage:4;
1022 UCHAR MediumRotationRate[2];
1023 UCHAR Reserved4[2];
1024 }MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
1025
1026 //
1027 // Define mode format page.
1028 //
1029
1030 typedef struct _MODE_FORMAT_PAGE
1031 {
1032 UCHAR PageCode:6;
1033 UCHAR Reserved:1;
1034 UCHAR PageSavable:1;
1035 UCHAR PageLength;
1036 UCHAR TracksPerZone[2];
1037 UCHAR AlternateSectorsPerZone[2];
1038 UCHAR AlternateTracksPerZone[2];
1039 UCHAR AlternateTracksPerLogicalUnit[2];
1040 UCHAR SectorsPerTrack[2];
1041 UCHAR BytesPerPhysicalSector[2];
1042 UCHAR Interleave[2];
1043 UCHAR TrackSkewFactor[2];
1044 UCHAR CylinderSkewFactor[2];
1045 UCHAR Reserved2:4;
1046 UCHAR SurfaceFirst:1;
1047 UCHAR RemovableMedia:1;
1048 UCHAR HardSectorFormating:1;
1049 UCHAR SoftSectorFormating:1;
1050 UCHAR Reserved3[2];
1051 }MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
1052
1053 //
1054 // Define rigid disk driver geometry page.
1055 //
1056
1057 typedef struct _MODE_RIGID_GEOMETRY_PAGE
1058 {
1059 UCHAR PageCode:6;
1060 UCHAR Reserved:1;
1061 UCHAR PageSavable:1;
1062 UCHAR PageLength;
1063 UCHAR NumberOfCylinders[2];
1064 UCHAR NumberOfHeads;
1065 UCHAR StartWritePrecom[2];
1066 UCHAR StartReducedCurrent[2];
1067 UCHAR DriveStepRate[2];
1068 UCHAR LandZoneCyclinder[2];
1069 UCHAR RotationalPositionLock:2;
1070 UCHAR Reserved2:6;
1071 UCHAR RotationOffset;
1072 UCHAR Reserved3;
1073 UCHAR RoataionRate[2];
1074 UCHAR Reserved4[2];
1075 }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
1076
1077 //
1078 // Define read write recovery page
1079 //
1080
1081 typedef struct _MODE_READ_WRITE_RECOVERY_PAGE
1082 {
1083 UCHAR PageCode:6;
1084 UCHAR Reserved1:1;
1085 UCHAR PSBit:1;
1086 UCHAR PageLength;
1087 UCHAR DCRBit:1;
1088 UCHAR DTEBit:1;
1089 UCHAR PERBit:1;
1090 UCHAR EERBit:1;
1091 UCHAR RCBit:1;
1092 UCHAR TBBit:1;
1093 UCHAR ARRE:1;
1094 UCHAR AWRE:1;
1095 UCHAR ReadRetryCount;
1096 UCHAR Reserved4[4];
1097 UCHAR WriteRetryCount;
1098 UCHAR Reserved5[3];
1099 } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
1100
1101 //
1102 // Define read recovery page - cdrom
1103 //
1104
1105 typedef struct _MODE_READ_RECOVERY_PAGE
1106 {
1107 UCHAR PageCode:6;
1108 UCHAR Reserved1:1;
1109 UCHAR PSBit:1;
1110 UCHAR PageLength;
1111 UCHAR DCRBit:1;
1112 UCHAR DTEBit:1;
1113 UCHAR PERBit:1;
1114 UCHAR Reserved2:1;
1115 UCHAR RCBit:1;
1116 UCHAR TBBit:1;
1117 UCHAR Reserved3:2;
1118 UCHAR ReadRetryCount;
1119 UCHAR Reserved4[4];
1120 } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
1121
1122 //
1123 // Define CD-ROM Capabilities and Mechanical Status Page.
1124 //
1125
1126 typedef struct _MODE_CAPABILITIES_PAGE2
1127 {
1128 UCHAR PageCode:6;
1129 UCHAR Reserved1:1;
1130 UCHAR PSBit:1;
1131 UCHAR PageLength;
1132 UCHAR Reserved2[2];
1133 UCHAR Capabilities[4];
1134 UCHAR MaximumSpeedSupported[2];
1135 UCHAR Reserved3;
1136 UCHAR NumberVolumeLevels;
1137 UCHAR BufferSize[2];
1138 UCHAR CurrentSpeed[2];
1139 UCHAR Reserved4;
1140 UCHAR Reserved5:1;
1141 UCHAR DigitalOutput:4;
1142 UCHAR Reserved6:3;
1143 UCHAR Reserved7[2];
1144 } MODE_CAPABILITIES_PAGE2, *PMODE_CAPABILITIES_PAGE2;
1145
1146 //
1147 // Bit definitions of Capabilites and DigitalOutput
1148 //
1149
1150 #define AUDIO_PLAY_SUPPORTED 0x01
1151 #define MODE2_FORM1_SUPPORTED 0x10
1152 #define MODE2_FORM2_SUPPORTED 0x20
1153 #define MULTI_SESSION_SUPPORTED 0x40
1154
1155 #define READ_CD_SUPPORTED 0x01
1156
1157 #define MEDIA_LOCKING_SUPPORTED 0x01
1158 #define CURRENT_LOCK_STATE 0x02
1159 #define SOFTWARE_EJECT_SUPPORT 0x08
1160
1161 #define DISC_PRESENT_REPORTING 0x04
1162
1163 //
1164 // Mode parameter list block descriptor -
1165 // set the block length for reading/writing
1166 //
1167 //
1168
1169 #define MODE_BLOCK_DESC_LENGTH 8
1170 #define MODE_HEADER_LENGTH 4
1171 #define MODE_HEADER_LENGTH10 8
1172
1173 typedef struct _MODE_PARM_READ_WRITE
1174 {
1175 MODE_PARAMETER_HEADER ParameterListHeader; /* List Header Format */
1176 MODE_PARAMETER_BLOCK ParameterListBlock; /* List Block Descriptor */
1177 } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
1178
1179
1180 //
1181 // CDROM audio control (0x0E)
1182 //
1183
1184 #define CDB_AUDIO_PAUSE 0
1185 #define CDB_AUDIO_RESUME 1
1186
1187 #define CDB_DEVICE_START 0x11
1188 #define CDB_DEVICE_STOP 0x10
1189
1190 #define CDB_EJECT_MEDIA 0x10
1191 #define CDB_LOAD_MEDIA 0x01
1192
1193 #define CDB_SUBCHANNEL_HEADER 0x00
1194 #define CDB_SUBCHANNEL_BLOCK 0x01
1195
1196 #define CDROM_AUDIO_CONTROL_PAGE 0x0E
1197 #define MODE_SELECT_IMMEDIATE 0x04
1198 #define MODE_SELECT_PFBIT 0x10
1199
1200 #define CDB_USE_MSF 0x01
1201
1202 typedef struct _PORT_OUTPUT
1203 {
1204 UCHAR ChannelSelection;
1205 UCHAR Volume;
1206 } PORT_OUTPUT, *PPORT_OUTPUT;
1207
1208 typedef struct _AUDIO_OUTPUT
1209 {
1210 UCHAR CodePage;
1211 UCHAR ParameterLength;
1212 UCHAR Immediate;
1213 UCHAR Reserved[2];
1214 UCHAR LbaFormat;
1215 UCHAR LogicalBlocksPerSecond[2];
1216 PORT_OUTPUT PortOutput[4];
1217 } AUDIO_OUTPUT, *PAUDIO_OUTPUT;
1218
1219
1220 /* Multisession CDROM */
1221
1222 #define GET_LAST_SESSION 0x01
1223 #define GET_SESSION_DATA 0x02;
1224
1225
1226 /* Atapi 2.5 changer */
1227
1228 typedef struct _MECHANICAL_STATUS_INFORMATION_HEADER
1229 {
1230 UCHAR CurrentSlot:5;
1231 UCHAR ChangerState:2;
1232 UCHAR Fault:1;
1233 UCHAR Reserved:5;
1234 UCHAR MechanismState:3;
1235 UCHAR CurrentLogicalBlockAddress[3];
1236 UCHAR NumberAvailableSlots;
1237 UCHAR SlotTableLength[2];
1238 } MECHANICAL_STATUS_INFORMATION_HEADER, *PMECHANICAL_STATUS_INFORMATION_HEADER;
1239
1240 typedef struct _SLOT_TABLE_INFORMATION
1241 {
1242 UCHAR DiscChanged:1;
1243 UCHAR Reserved:6;
1244 UCHAR DiscPresent:1;
1245 UCHAR Reserved2[3];
1246 } SLOT_TABLE_INFORMATION, *PSLOT_TABLE_INFORMATION;
1247
1248 typedef struct _MECHANICAL_STATUS
1249 {
1250 MECHANICAL_STATUS_INFORMATION_HEADER MechanicalStatusHeader;
1251 SLOT_TABLE_INFORMATION SlotTableInfo[1];
1252 } MECHANICAL_STATUS, *PMECHANICAL_STATUS;
1253
1254
1255 /* Tape definitions */
1256
1257 typedef struct _TAPE_POSITION_DATA
1258 {
1259 UCHAR Reserved1:2;
1260 UCHAR BlockPositionUnsupported:1;
1261 UCHAR Reserved2:3;
1262 UCHAR EndOfPartition:1;
1263 UCHAR BeginningOfPartition:1;
1264 UCHAR PartitionNumber;
1265 USHORT Reserved3;
1266 UCHAR FirstBlock[4];
1267 UCHAR LastBlock[4];
1268 UCHAR Reserved4;
1269 UCHAR NumberOfBlocks[3];
1270 UCHAR NumberOfBytes[4];
1271 } TAPE_POSITION_DATA, *PTAPE_POSITION_DATA;
1272
1273 /*
1274 * This structure is used to convert little endian
1275 * ULONGs to SCSI CDB 4 byte big endians values.
1276 */
1277
1278 typedef struct _FOUR_BYTE
1279 {
1280 UCHAR Byte0;
1281 UCHAR Byte1;
1282 UCHAR Byte2;
1283 UCHAR Byte3;
1284 } FOUR_BYTE, *PFOUR_BYTE;
1285
1286 /*
1287 * Byte reversing macro for converting
1288 * between big- and little-endian formats
1289 */
1290
1291 #define REVERSE_BYTES(Destination, Source) \
1292 { \
1293 PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
1294 PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
1295 d->Byte3 = s->Byte0; \
1296 d->Byte2 = s->Byte1; \
1297 d->Byte1 = s->Byte2; \
1298 d->Byte0 = s->Byte3; \
1299 }
1300
1301
1302 /* This macro has the effect of Bit = log2(Data) */
1303
1304 #define WHICH_BIT(Data, Bit) \
1305 { \
1306 for (Bit = 0; Bit < 32; Bit++) \
1307 { \
1308 if ((Data >> Bit) == 1) \
1309 { \
1310 break; \
1311 } \
1312 } \
1313 }
1314
1315
1316 #endif /* __STORAGE_INCLUDE_SCSI_H */
1317
1318 /* EOF */