Create a PDEV for the display driver only once.
[reactos.git] / reactos / drivers / storage / include / scsi.h
1 /* $Id: scsi.h,v 1.6 2002/09/08 10:22:23 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 /* SCSI IO Device Control Codes */
848
849 #define FILE_DEVICE_SCSI 0x0000001b
850
851 #define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
852 #define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
853 #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
854
855 /* SMART support in atapi */
856
857 #define IOCTL_SCSI_MINIPORT_SMART_VERSION ((FILE_DEVICE_SCSI << 16) + 0x0500)
858 #define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501)
859 #define IOCTL_SCSI_MINIPORT_READ_SMART_ATTRIBS ((FILE_DEVICE_SCSI << 16) + 0x0502)
860 #define IOCTL_SCSI_MINIPORT_READ_SMART_THRESHOLDS ((FILE_DEVICE_SCSI << 16) + 0x0503)
861 #define IOCTL_SCSI_MINIPORT_ENABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0504)
862 #define IOCTL_SCSI_MINIPORT_DISABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0505)
863 #define IOCTL_SCSI_MINIPORT_RETURN_STATUS ((FILE_DEVICE_SCSI << 16) + 0x0506)
864 #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTOSAVE ((FILE_DEVICE_SCSI << 16) + 0x0507)
865 #define IOCTL_SCSI_MINIPORT_SAVE_ATTRIBUTE_VALUES ((FILE_DEVICE_SCSI << 16) + 0x0508)
866 #define IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS ((FILE_DEVICE_SCSI << 16) + 0x0509)
867
868
869 /* Read Capacity Data - returned in Big Endian format */
870
871 typedef struct _READ_CAPACITY_DATA
872 {
873 ULONG LogicalBlockAddress;
874 ULONG BytesPerBlock;
875 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
876
877
878 //
879 // Read Block Limits Data - returned in Big Endian format
880 // This structure returns the maximum and minimum block
881 // size for a TAPE device.
882 //
883
884 typedef struct _READ_BLOCK_LIMITS
885 {
886 UCHAR Reserved;
887 UCHAR BlockMaximumSize[3];
888 UCHAR BlockMinimumSize[2];
889 } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
890
891
892 //
893 // Mode data structures.
894 //
895
896 //
897 // Define Mode parameter header.
898 //
899
900 typedef struct _MODE_PARAMETER_HEADER
901 {
902 UCHAR ModeDataLength;
903 UCHAR MediumType;
904 UCHAR DeviceSpecificParameter;
905 UCHAR BlockDescriptorLength;
906 }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
907
908 typedef struct _MODE_PARAMETER_HEADER10
909 {
910 UCHAR ModeDataLength[2];
911 UCHAR MediumType;
912 UCHAR DeviceSpecificParameter;
913 UCHAR Reserved[2];
914 UCHAR BlockDescriptorLength[2];
915 }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
916
917 #define MODE_FD_SINGLE_SIDE 0x01
918 #define MODE_FD_DOUBLE_SIDE 0x02
919 #define MODE_FD_MAXIMUM_TYPE 0x1E
920 #define MODE_DSP_FUA_SUPPORTED 0x10
921 #define MODE_DSP_WRITE_PROTECT 0x80
922
923 //
924 // Define the mode parameter block.
925 //
926
927 typedef struct _MODE_PARAMETER_BLOCK
928 {
929 UCHAR DensityCode;
930 UCHAR NumberOfBlocks[3];
931 UCHAR Reserved;
932 UCHAR BlockLength[3];
933 }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
934
935
936 /* Define Disconnect-Reconnect page */
937 typedef struct _MODE_DISCONNECT_PAGE
938 {
939 UCHAR PageCode:6;
940 UCHAR Reserved:1;
941 UCHAR PageSavable:1;
942 UCHAR PageLength;
943 UCHAR BufferFullRatio;
944 UCHAR BufferEmptyRatio;
945 UCHAR BusInactivityLimit[2];
946 UCHAR BusDisconnectTime[2];
947 UCHAR BusConnectTime[2];
948 UCHAR MaximumBurstSize[2];
949 UCHAR DataTransferDisconnect:2;
950 UCHAR Reserved2[3];
951 }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
952
953 //
954 // Define mode caching page.
955 //
956
957 typedef struct _MODE_CACHING_PAGE
958 {
959 UCHAR PageCode:6;
960 UCHAR Reserved:1;
961 UCHAR PageSavable:1;
962 UCHAR PageLength;
963 UCHAR ReadDisableCache:1;
964 UCHAR MultiplicationFactor:1;
965 UCHAR WriteCacheEnable:1;
966 UCHAR Reserved2:5;
967 UCHAR WriteRetensionPriority:4;
968 UCHAR ReadRetensionPriority:4;
969 UCHAR DisablePrefetchTransfer[2];
970 UCHAR MinimumPrefetch[2];
971 UCHAR MaximumPrefetch[2];
972 UCHAR MaximumPrefetchCeiling[2];
973 }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
974
975 //
976 // Define mode flexible disk page.
977 //
978
979 typedef struct _MODE_FLEXIBLE_DISK_PAGE
980 {
981 UCHAR PageCode:6;
982 UCHAR Reserved:1;
983 UCHAR PageSavable:1;
984 UCHAR PageLength;
985 UCHAR TransferRate[2];
986 UCHAR NumberOfHeads;
987 UCHAR SectorsPerTrack;
988 UCHAR BytesPerSector[2];
989 UCHAR NumberOfCylinders[2];
990 UCHAR StartWritePrecom[2];
991 UCHAR StartReducedCurrent[2];
992 UCHAR StepRate[2];
993 UCHAR StepPluseWidth;
994 UCHAR HeadSettleDelay[2];
995 UCHAR MotorOnDelay;
996 UCHAR MotorOffDelay;
997 UCHAR Reserved2:5;
998 UCHAR MotorOnAsserted:1;
999 UCHAR StartSectorNumber:1;
1000 UCHAR TrueReadySignal:1;
1001 UCHAR StepPlusePerCyclynder:4;
1002 UCHAR Reserved3:4;
1003 UCHAR WriteCompenstation;
1004 UCHAR HeadLoadDelay;
1005 UCHAR HeadUnloadDelay;
1006 UCHAR Pin2Usage:4;
1007 UCHAR Pin34Usage:4;
1008 UCHAR Pin1Usage:4;
1009 UCHAR Pin4Usage:4;
1010 UCHAR MediumRotationRate[2];
1011 UCHAR Reserved4[2];
1012 }MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
1013
1014 //
1015 // Define mode format page.
1016 //
1017
1018 typedef struct _MODE_FORMAT_PAGE
1019 {
1020 UCHAR PageCode:6;
1021 UCHAR Reserved:1;
1022 UCHAR PageSavable:1;
1023 UCHAR PageLength;
1024 UCHAR TracksPerZone[2];
1025 UCHAR AlternateSectorsPerZone[2];
1026 UCHAR AlternateTracksPerZone[2];
1027 UCHAR AlternateTracksPerLogicalUnit[2];
1028 UCHAR SectorsPerTrack[2];
1029 UCHAR BytesPerPhysicalSector[2];
1030 UCHAR Interleave[2];
1031 UCHAR TrackSkewFactor[2];
1032 UCHAR CylinderSkewFactor[2];
1033 UCHAR Reserved2:4;
1034 UCHAR SurfaceFirst:1;
1035 UCHAR RemovableMedia:1;
1036 UCHAR HardSectorFormating:1;
1037 UCHAR SoftSectorFormating:1;
1038 UCHAR Reserved3[2];
1039 }MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
1040
1041 //
1042 // Define rigid disk driver geometry page.
1043 //
1044
1045 typedef struct _MODE_RIGID_GEOMETRY_PAGE
1046 {
1047 UCHAR PageCode:6;
1048 UCHAR Reserved:1;
1049 UCHAR PageSavable:1;
1050 UCHAR PageLength;
1051 UCHAR NumberOfCylinders[2];
1052 UCHAR NumberOfHeads;
1053 UCHAR StartWritePrecom[2];
1054 UCHAR StartReducedCurrent[2];
1055 UCHAR DriveStepRate[2];
1056 UCHAR LandZoneCyclinder[2];
1057 UCHAR RotationalPositionLock:2;
1058 UCHAR Reserved2:6;
1059 UCHAR RotationOffset;
1060 UCHAR Reserved3;
1061 UCHAR RoataionRate[2];
1062 UCHAR Reserved4[2];
1063 }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
1064
1065 //
1066 // Define read write recovery page
1067 //
1068
1069 typedef struct _MODE_READ_WRITE_RECOVERY_PAGE
1070 {
1071 UCHAR PageCode:6;
1072 UCHAR Reserved1:1;
1073 UCHAR PSBit:1;
1074 UCHAR PageLength;
1075 UCHAR DCRBit:1;
1076 UCHAR DTEBit:1;
1077 UCHAR PERBit:1;
1078 UCHAR EERBit:1;
1079 UCHAR RCBit:1;
1080 UCHAR TBBit:1;
1081 UCHAR ARRE:1;
1082 UCHAR AWRE:1;
1083 UCHAR ReadRetryCount;
1084 UCHAR Reserved4[4];
1085 UCHAR WriteRetryCount;
1086 UCHAR Reserved5[3];
1087 } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
1088
1089 //
1090 // Define read recovery page - cdrom
1091 //
1092
1093 typedef struct _MODE_READ_RECOVERY_PAGE
1094 {
1095 UCHAR PageCode:6;
1096 UCHAR Reserved1:1;
1097 UCHAR PSBit:1;
1098 UCHAR PageLength;
1099 UCHAR DCRBit:1;
1100 UCHAR DTEBit:1;
1101 UCHAR PERBit:1;
1102 UCHAR Reserved2:1;
1103 UCHAR RCBit:1;
1104 UCHAR TBBit:1;
1105 UCHAR Reserved3:2;
1106 UCHAR ReadRetryCount;
1107 UCHAR Reserved4[4];
1108 } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
1109
1110 //
1111 // Define CD-ROM Capabilities and Mechanical Status Page.
1112 //
1113
1114 typedef struct _MODE_CAPABILITIES_PAGE2
1115 {
1116 UCHAR PageCode:6;
1117 UCHAR Reserved1:1;
1118 UCHAR PSBit:1;
1119 UCHAR PageLength;
1120 UCHAR Reserved2[2];
1121 UCHAR Capabilities[4];
1122 UCHAR MaximumSpeedSupported[2];
1123 UCHAR Reserved3;
1124 UCHAR NumberVolumeLevels;
1125 UCHAR BufferSize[2];
1126 UCHAR CurrentSpeed[2];
1127 UCHAR Reserved4;
1128 UCHAR Reserved5:1;
1129 UCHAR DigitalOutput:4;
1130 UCHAR Reserved6:3;
1131 UCHAR Reserved7[2];
1132 } MODE_CAPABILITIES_PAGE2, *PMODE_CAPABILITIES_PAGE2;
1133
1134 //
1135 // Bit definitions of Capabilites and DigitalOutput
1136 //
1137
1138 #define AUDIO_PLAY_SUPPORTED 0x01
1139 #define MODE2_FORM1_SUPPORTED 0x10
1140 #define MODE2_FORM2_SUPPORTED 0x20
1141 #define MULTI_SESSION_SUPPORTED 0x40
1142
1143 #define READ_CD_SUPPORTED 0x01
1144
1145 #define MEDIA_LOCKING_SUPPORTED 0x01
1146 #define CURRENT_LOCK_STATE 0x02
1147 #define SOFTWARE_EJECT_SUPPORT 0x08
1148
1149 #define DISC_PRESENT_REPORTING 0x04
1150
1151 //
1152 // Mode parameter list block descriptor -
1153 // set the block length for reading/writing
1154 //
1155 //
1156
1157 #define MODE_BLOCK_DESC_LENGTH 8
1158 #define MODE_HEADER_LENGTH 4
1159 #define MODE_HEADER_LENGTH10 8
1160
1161 typedef struct _MODE_PARM_READ_WRITE
1162 {
1163 MODE_PARAMETER_HEADER ParameterListHeader; /* List Header Format */
1164 MODE_PARAMETER_BLOCK ParameterListBlock; /* List Block Descriptor */
1165 } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
1166
1167
1168 //
1169 // CDROM audio control (0x0E)
1170 //
1171
1172 #define CDB_AUDIO_PAUSE 0
1173 #define CDB_AUDIO_RESUME 1
1174
1175 #define CDB_DEVICE_START 0x11
1176 #define CDB_DEVICE_STOP 0x10
1177
1178 #define CDB_EJECT_MEDIA 0x10
1179 #define CDB_LOAD_MEDIA 0x01
1180
1181 #define CDB_SUBCHANNEL_HEADER 0x00
1182 #define CDB_SUBCHANNEL_BLOCK 0x01
1183
1184 #define CDROM_AUDIO_CONTROL_PAGE 0x0E
1185 #define MODE_SELECT_IMMEDIATE 0x04
1186 #define MODE_SELECT_PFBIT 0x10
1187
1188 #define CDB_USE_MSF 0x01
1189
1190 typedef struct _PORT_OUTPUT
1191 {
1192 UCHAR ChannelSelection;
1193 UCHAR Volume;
1194 } PORT_OUTPUT, *PPORT_OUTPUT;
1195
1196 typedef struct _AUDIO_OUTPUT
1197 {
1198 UCHAR CodePage;
1199 UCHAR ParameterLength;
1200 UCHAR Immediate;
1201 UCHAR Reserved[2];
1202 UCHAR LbaFormat;
1203 UCHAR LogicalBlocksPerSecond[2];
1204 PORT_OUTPUT PortOutput[4];
1205 } AUDIO_OUTPUT, *PAUDIO_OUTPUT;
1206
1207
1208 /* Multisession CDROM */
1209
1210 #define GET_LAST_SESSION 0x01
1211 #define GET_SESSION_DATA 0x02;
1212
1213
1214 /* Atapi 2.5 changer */
1215
1216 typedef struct _MECHANICAL_STATUS_INFORMATION_HEADER
1217 {
1218 UCHAR CurrentSlot:5;
1219 UCHAR ChangerState:2;
1220 UCHAR Fault:1;
1221 UCHAR Reserved:5;
1222 UCHAR MechanismState:3;
1223 UCHAR CurrentLogicalBlockAddress[3];
1224 UCHAR NumberAvailableSlots;
1225 UCHAR SlotTableLength[2];
1226 } MECHANICAL_STATUS_INFORMATION_HEADER, *PMECHANICAL_STATUS_INFORMATION_HEADER;
1227
1228 typedef struct _SLOT_TABLE_INFORMATION
1229 {
1230 UCHAR DiscChanged:1;
1231 UCHAR Reserved:6;
1232 UCHAR DiscPresent:1;
1233 UCHAR Reserved2[3];
1234 } SLOT_TABLE_INFORMATION, *PSLOT_TABLE_INFORMATION;
1235
1236 typedef struct _MECHANICAL_STATUS
1237 {
1238 MECHANICAL_STATUS_INFORMATION_HEADER MechanicalStatusHeader;
1239 SLOT_TABLE_INFORMATION SlotTableInfo[1];
1240 } MECHANICAL_STATUS, *PMECHANICAL_STATUS;
1241
1242
1243 /* Tape definitions */
1244
1245 typedef struct _TAPE_POSITION_DATA
1246 {
1247 UCHAR Reserved1:2;
1248 UCHAR BlockPositionUnsupported:1;
1249 UCHAR Reserved2:3;
1250 UCHAR EndOfPartition:1;
1251 UCHAR BeginningOfPartition:1;
1252 UCHAR PartitionNumber;
1253 USHORT Reserved3;
1254 UCHAR FirstBlock[4];
1255 UCHAR LastBlock[4];
1256 UCHAR Reserved4;
1257 UCHAR NumberOfBlocks[3];
1258 UCHAR NumberOfBytes[4];
1259 } TAPE_POSITION_DATA, *PTAPE_POSITION_DATA;
1260
1261 /*
1262 * This structure is used to convert little endian
1263 * ULONGs to SCSI CDB 4 byte big endians values.
1264 */
1265
1266 typedef struct _FOUR_BYTE
1267 {
1268 UCHAR Byte0;
1269 UCHAR Byte1;
1270 UCHAR Byte2;
1271 UCHAR Byte3;
1272 } FOUR_BYTE, *PFOUR_BYTE;
1273
1274 /*
1275 * Byte reversing macro for converting
1276 * between big- and little-endian formats
1277 */
1278
1279 #define REVERSE_BYTES(Destination, Source) \
1280 { \
1281 PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
1282 PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
1283 d->Byte3 = s->Byte0; \
1284 d->Byte2 = s->Byte1; \
1285 d->Byte1 = s->Byte2; \
1286 d->Byte0 = s->Byte3; \
1287 }
1288
1289
1290 /* This macro has the effect of Bit = log2(Data) */
1291
1292 #define WHICH_BIT(Data, Bit) \
1293 { \
1294 for (Bit = 0; Bit < 32; Bit++) \
1295 { \
1296 if ((Data >> Bit) == 1) \
1297 { \
1298 break; \
1299 } \
1300 } \
1301 }
1302
1303
1304 #endif /* __STORAGE_INCLUDE_SCSI_H */
1305
1306 /* EOF */