Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1105 lines
28 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. scsi.h
  5. Abstract:
  6. These are the structures and defines that are used in the
  7. SCSI port and class drivers.
  8. Authors:
  9. John Freeman (johnfr) 28-Mar-90
  10. Andre Vachon (andrev) 06-Jun-90
  11. Mike Glass (mglass)
  12. Jeff Havens (jhavens)
  13. Revision History:
  14. --*/
  15. #ifndef _NTSCSI_
  16. #define _NTSCSI_
  17. //
  18. // Define SCSI maximum configuration parameters.
  19. //
  20. #define SCSI_MAXIMUM_TARGETS 8
  21. #define SCSI_MAXIMUM_LOGICAL_UNITS 8
  22. #define SCSI_MAXIMUM_TARGETS_PER_BUS 32
  23. #define MAXIMUM_CDB_SIZE 12
  24. //
  25. // Command Descriptor Block. Passed by SCSI controller chip over the SCSI bus
  26. //
  27. typedef union _CDB {
  28. //
  29. // Generic 6-Byte CDB
  30. //
  31. struct _CDB6GENERIC {
  32. UCHAR OperationCode;
  33. UCHAR Immediate : 1;
  34. UCHAR CommandUniqueBits : 4;
  35. UCHAR LogicalUnitNumber : 3;
  36. UCHAR CommandUniqueBytes[3];
  37. UCHAR Link : 1;
  38. UCHAR Flag : 1;
  39. UCHAR Reserved : 4;
  40. UCHAR VendorUnique : 2;
  41. } CDB6GENERIC, *PCDB6GENERIC;
  42. //
  43. // Standard 6-byte CDB
  44. //
  45. struct _CDB6READWRITE {
  46. UCHAR OperationCode;
  47. UCHAR LogicalBlockMsb1 : 5;
  48. UCHAR LogicalUnitNumber : 3;
  49. UCHAR LogicalBlockMsb0;
  50. UCHAR LogicalBlockLsb;
  51. UCHAR TransferBlocks;
  52. UCHAR Control;
  53. } CDB6READWRITE, *PCDB6READWRITE;
  54. //
  55. // SCSI Inquiry CDB
  56. //
  57. struct _CDB6INQUIRY {
  58. UCHAR OperationCode;
  59. UCHAR Reserved1 : 5;
  60. UCHAR LogicalUnitNumber : 3;
  61. UCHAR PageCode;
  62. UCHAR IReserved;
  63. UCHAR AllocationLength;
  64. UCHAR Control;
  65. } CDB6INQUIRY, *PCDB6INQUIRY;
  66. //
  67. // SCSI Format CDB
  68. //
  69. struct _CDB6FORMAT {
  70. UCHAR OperationCode;
  71. UCHAR FormatControl : 5;
  72. UCHAR LogicalUnitNumber : 3;
  73. UCHAR FReserved1;
  74. UCHAR InterleaveMsb;
  75. UCHAR InterleaveLsb;
  76. UCHAR FReserved2;
  77. } CDB6FORMAT, *PCDB6FORMAT;
  78. //
  79. // Standard 10-byte CDB
  80. struct _CDB10 {
  81. UCHAR OperationCode;
  82. UCHAR RelativeAddress : 1;
  83. UCHAR Reserved1 : 2;
  84. UCHAR ForceUnitAccess : 1;
  85. UCHAR DisablePageOut : 1;
  86. UCHAR LogicalUnitNumber : 3;
  87. UCHAR LogicalBlockByte0;
  88. UCHAR LogicalBlockByte1;
  89. UCHAR LogicalBlockByte2;
  90. UCHAR LogicalBlockByte3;
  91. UCHAR Reserved2;
  92. UCHAR TransferBlocksMsb;
  93. UCHAR TransferBlocksLsb;
  94. UCHAR Control;
  95. } CDB10, *PCDB10;
  96. //
  97. // CD Rom Audio CDBs
  98. //
  99. struct _PAUSE_RESUME {
  100. UCHAR OperationCode;
  101. UCHAR Reserved1 : 5;
  102. UCHAR LogicalUnitNumber : 3;
  103. UCHAR Reserved2[6];
  104. UCHAR Action;
  105. UCHAR Control;
  106. } PAUSE_RESUME, *PPAUSE_RESUME;
  107. //
  108. // Read Table of Contents
  109. //
  110. struct _READ_TOC {
  111. UCHAR OperationCode;
  112. UCHAR Reserved0 : 1;
  113. UCHAR Msf : 1;
  114. UCHAR Reserved1 : 3;
  115. UCHAR LogicalUnitNumber : 3;
  116. UCHAR Reserved2[4];
  117. UCHAR StartingTrack;
  118. UCHAR AllocationLength[2];
  119. UCHAR Control : 6;
  120. UCHAR Format : 2;
  121. } READ_TOC, *PREAD_TOC;
  122. struct _PLAY_AUDIO_MSF {
  123. UCHAR OperationCode;
  124. UCHAR Reserved1 : 5;
  125. UCHAR LogicalUnitNumber : 3;
  126. UCHAR Reserved2;
  127. UCHAR StartingM;
  128. UCHAR StartingS;
  129. UCHAR StartingF;
  130. UCHAR EndingM;
  131. UCHAR EndingS;
  132. UCHAR EndingF;
  133. UCHAR Control;
  134. } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
  135. //
  136. // Read SubChannel Data
  137. //
  138. struct _SUBCHANNEL {
  139. UCHAR OperationCode;
  140. UCHAR Reserved0 : 1;
  141. UCHAR Msf : 1;
  142. UCHAR Reserved1 : 3;
  143. UCHAR LogicalUnitNumber : 3;
  144. UCHAR Reserved2 : 6;
  145. UCHAR SubQ : 1;
  146. UCHAR Reserved3 : 1;
  147. UCHAR Format;
  148. UCHAR Reserved4[2];
  149. UCHAR TrackNumber;
  150. UCHAR AllocationLength[2];
  151. UCHAR Control;
  152. } SUBCHANNEL, *PSUBCHANNEL;
  153. //
  154. // Mode sense
  155. //
  156. struct _MODE_SENSE {
  157. UCHAR OperationCode;
  158. UCHAR Reserved1 : 3;
  159. UCHAR Dbd : 1;
  160. UCHAR Reserved2 : 1;
  161. UCHAR LogicalUnitNumber : 3;
  162. UCHAR PageCode : 6;
  163. UCHAR Pc : 2;
  164. UCHAR Reserved3;
  165. UCHAR AllocationLength;
  166. UCHAR Control;
  167. } MODE_SENSE, *PMODE_SENSE;
  168. //
  169. // Mode select
  170. //
  171. struct _MODE_SELECT {
  172. UCHAR OperationCode;
  173. UCHAR SPBit : 1;
  174. UCHAR Reserved1 : 3;
  175. UCHAR PFBit : 1;
  176. UCHAR LogicalUnitNumber : 3;
  177. UCHAR Reserved2[2];
  178. UCHAR ParameterListLength;
  179. UCHAR Control;
  180. } MODE_SELECT, *PMODE_SELECT;
  181. struct _LOCATE {
  182. UCHAR OperationCode;
  183. UCHAR Immediate : 1;
  184. UCHAR CPBit : 1;
  185. UCHAR BTBit : 1;
  186. UCHAR Reserved1 : 2;
  187. UCHAR LogicalUnitNumber : 3;
  188. UCHAR Reserved3;
  189. UCHAR LogicalBlockAddress[4];
  190. UCHAR Reserved4;
  191. UCHAR Partition;
  192. UCHAR Control;
  193. } LOCATE, *PLOCATE;
  194. struct _LOGSENSE {
  195. UCHAR OperationCode;
  196. UCHAR SPBit : 1;
  197. UCHAR PPCBit : 1;
  198. UCHAR Reserved1 : 3;
  199. UCHAR LogicalUnitNumber : 3;
  200. UCHAR PageCode : 6;
  201. UCHAR PCBit : 2;
  202. UCHAR Reserved2;
  203. UCHAR Reserved3;
  204. UCHAR ParameterPointer[2]; // [0]=MSB, [1]=LSB
  205. UCHAR AllocationLength[2]; // [0]=MSB, [1]=LSB
  206. UCHAR Control;
  207. } LOGSENSE, *PLOGSENSE;
  208. struct _PRINT {
  209. UCHAR OperationCode;
  210. UCHAR Reserved : 5;
  211. UCHAR LogicalUnitNumber : 3;
  212. UCHAR TransferLength[3];
  213. UCHAR Control;
  214. } PRINT, *PPRINT;
  215. struct _SEEK {
  216. UCHAR OperationCode;
  217. UCHAR Reserved1 : 5;
  218. UCHAR LogicalUnitNumber : 3;
  219. UCHAR LogicalBlockAddress[4];
  220. UCHAR Reserved2[3];
  221. UCHAR Control;
  222. } SEEK, *PSEEK;
  223. struct _ERASE {
  224. UCHAR OperationCode;
  225. UCHAR Long : 1;
  226. UCHAR Immediate : 1;
  227. UCHAR Reserved1 : 3;
  228. UCHAR LogicalUnitNumber : 3;
  229. UCHAR Reserved2[3];
  230. UCHAR Control;
  231. } ERASE, *PERASE;
  232. struct _START_STOP {
  233. UCHAR OperationCode;
  234. UCHAR Immediate: 1;
  235. UCHAR Reserved1 : 4;
  236. UCHAR LogicalUnitNumber : 3;
  237. UCHAR Reserved2[2];
  238. UCHAR Start : 1;
  239. UCHAR LoadEject : 1;
  240. UCHAR Reserved3 : 6;
  241. UCHAR Control;
  242. } START_STOP, *PSTART_STOP;
  243. struct _MEDIA_REMOVAL {
  244. UCHAR OperationCode;
  245. UCHAR Reserved1 : 5;
  246. UCHAR LogicalUnitNumber : 3;
  247. UCHAR Reserved2[2];
  248. UCHAR Prevent;
  249. UCHAR Control;
  250. } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
  251. //
  252. // Tape CDBs
  253. //
  254. struct _SEEK_BLOCK {
  255. UCHAR OperationCode;
  256. UCHAR Immediate : 1;
  257. UCHAR Reserved1 : 7;
  258. UCHAR BlockAddress[3];
  259. UCHAR Link : 1;
  260. UCHAR Flag : 1;
  261. UCHAR Reserved2 : 4;
  262. UCHAR VendorUnique : 2;
  263. } SEEK_BLOCK, *PSEEK_BLOCK;
  264. struct _REQUEST_BLOCK_ADDRESS {
  265. UCHAR OperationCode;
  266. UCHAR Reserved1[3];
  267. UCHAR AllocationLength;
  268. UCHAR Link : 1;
  269. UCHAR Flag : 1;
  270. UCHAR Reserved2 : 4;
  271. UCHAR VendorUnique : 2;
  272. } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
  273. struct _PARTITION {
  274. UCHAR OperationCode;
  275. UCHAR Immediate : 1;
  276. UCHAR Sel: 1;
  277. UCHAR PartitionSelect : 6;
  278. UCHAR Reserved1[3];
  279. UCHAR Control;
  280. } PARTITION, *PPARTITION;
  281. struct _WRITE_TAPE_MARKS {
  282. UCHAR OperationCode;
  283. UCHAR Immediate : 1;
  284. UCHAR WriteSetMarks: 1;
  285. UCHAR Reserved : 3;
  286. UCHAR LogicalUnitNumber : 3;
  287. UCHAR TransferLength[3];
  288. UCHAR Control;
  289. } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
  290. struct _SPACE_TAPE_MARKS {
  291. UCHAR OperationCode;
  292. UCHAR Code : 3;
  293. UCHAR Reserved : 2;
  294. UCHAR LogicalUnitNumber : 3;
  295. UCHAR NumMarksMSB ;
  296. UCHAR NumMarks;
  297. UCHAR NumMarksLSB;
  298. union {
  299. UCHAR value;
  300. struct {
  301. UCHAR Link : 1;
  302. UCHAR Flag : 1;
  303. UCHAR Reserved : 4;
  304. UCHAR VendorUnique : 2;
  305. } Fields;
  306. } Byte6;
  307. } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
  308. //
  309. // Read tape position
  310. //
  311. struct _READ_POSITION {
  312. UCHAR Operation;
  313. UCHAR BlockType:1;
  314. UCHAR Reserved1:4;
  315. UCHAR Lun:3;
  316. UCHAR Reserved2[7];
  317. UCHAR Control;
  318. } READ_POSITION, *PREAD_POSITION;
  319. //
  320. // ReadWrite for Tape
  321. //
  322. struct _CDB6READWRITETAPE {
  323. UCHAR OperationCode;
  324. UCHAR VendorSpecific : 5;
  325. UCHAR Reserved : 3;
  326. UCHAR TransferLenMSB;
  327. UCHAR TransferLen;
  328. UCHAR TransferLenLSB;
  329. UCHAR Link : 1;
  330. UCHAR Flag : 1;
  331. UCHAR Reserved1 : 4;
  332. UCHAR VendorUnique : 2;
  333. } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
  334. } CDB, *PCDB;
  335. //
  336. // Command Descriptor Block constants.
  337. //
  338. #define CDB6GENERIC_LENGTH 6
  339. #define CDB10GENERIC_LENGTH 10
  340. #define SETBITON 1
  341. #define SETBITOFF 0
  342. //
  343. // Mode Sense/Select page constants.
  344. //
  345. #define MODE_PAGE_ERROR_RECOVERY 0x01
  346. #define MODE_PAGE_DISCONNECT 0x02
  347. #define MODE_PAGE_FORMAT_DEVICE 0x03
  348. #define MODE_PAGE_RIGID_GEOMETRY 0x04
  349. #define MODE_PAGE_FLEXIBILE 0x05
  350. #define MODE_PAGE_VERIFY_ERROR 0x07
  351. #define MODE_PAGE_CACHING 0x08
  352. #define MODE_PAGE_PERIPHERAL 0x09
  353. #define MODE_PAGE_CONTROL 0x0A
  354. #define MODE_PAGE_MEDIUM_TYPES 0x0B
  355. #define MODE_PAGE_NOTCH_PARTITION 0x0C
  356. #define MODE_SENSE_RETURN_ALL 0x3f
  357. #define MODE_SENSE_CURRENT_VALUES 0x00
  358. #define MODE_SENSE_CHANGEABLE_VALUES 0x40
  359. #define MODE_SENSE_DEFAULT_VAULES 0x80
  360. #define MODE_SENSE_SAVED_VALUES 0xc0
  361. #define MODE_PAGE_DEVICE_CONFIG 0x10
  362. #define MODE_PAGE_MEDIUM_PARTITION 0x11
  363. #define MODE_PAGE_DATA_COMPRESS 0x0f
  364. //
  365. // SCSI CDB operation codes
  366. //
  367. #define SCSIOP_TEST_UNIT_READY 0x00
  368. #define SCSIOP_REZERO_UNIT 0x01
  369. #define SCSIOP_REWIND 0x01
  370. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  371. #define SCSIOP_REQUEST_SENSE 0x03
  372. #define SCSIOP_FORMAT_UNIT 0x04
  373. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  374. #define SCSIOP_REASSIGN_BLOCKS 0x07
  375. #define SCSIOP_READ6 0x08
  376. #define SCSIOP_RECEIVE 0x08
  377. #define SCSIOP_WRITE6 0x0A
  378. #define SCSIOP_PRINT 0x0A
  379. #define SCSIOP_SEND 0x0A
  380. #define SCSIOP_SEEK6 0x0B
  381. #define SCSIOP_TRACK_SELECT 0x0B
  382. #define SCSIOP_SLEW_PRINT 0x0B
  383. #define SCSIOP_SEEK_BLOCK 0x0C
  384. #define SCSIOP_PARTITION 0x0D
  385. #define SCSIOP_READ_REVERSE 0x0F
  386. #define SCSIOP_WRITE_FILEMARKS 0x10
  387. #define SCSIOP_FLUSH_BUFFER 0x10
  388. #define SCSIOP_SPACE 0x11
  389. #define SCSIOP_INQUIRY 0x12
  390. #define SCSIOP_VERIFY6 0x13
  391. #define SCSIOP_RECOVER_BUF_DATA 0x14
  392. #define SCSIOP_MODE_SELECT 0x15
  393. #define SCSIOP_RESERVE_UNIT 0x16
  394. #define SCSIOP_RELEASE_UNIT 0x17
  395. #define SCSIOP_COPY 0x18
  396. #define SCSIOP_ERASE 0x19
  397. #define SCSIOP_MODE_SENSE 0x1A
  398. #define SCSIOP_START_STOP_UNIT 0x1B
  399. #define SCSIOP_STOP_PRINT 0x1B
  400. #define SCSIOP_LOAD_UNLOAD 0x1B
  401. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  402. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  403. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  404. #define SCSIOP_READ_CAPACITY 0x25
  405. #define SCSIOP_READ 0x28
  406. #define SCSIOP_WRITE 0x2A
  407. #define SCSIOP_SEEK 0x2B
  408. #define SCSIOP_LOCATE 0x2B
  409. #define SCSIOP_WRITE_VERIFY 0x2E
  410. #define SCSIOP_VERIFY 0x2F
  411. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  412. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  413. #define SCSIOP_SEARCH_DATA_LOW 0x32
  414. #define SCSIOP_SET_LIMITS 0x33
  415. #define SCSIOP_READ_POSITION 0x34
  416. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  417. #define SCSIOP_COMPARE 0x39
  418. #define SCSIOP_COPY_COMPARE 0x3A
  419. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  420. #define SCSIOP_READ_DATA_BUFF 0x3C
  421. #define SCSIOP_CHANGE_DEFINITION 0x40
  422. #define SCSIOP_READ_SUB_CHANNEL 0x42
  423. #define SCSIOP_READ_TOC 0x43
  424. #define SCSIOP_READ_HEADER 0x44
  425. #define SCSIOP_PLAY_AUDIO 0x45
  426. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  427. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  428. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  429. #define SCSIOP_PAUSE_RESUME 0x4B
  430. #define SCSIOP_LOG_SELECT 0x4C
  431. #define SCSIOP_LOG_SENSE 0x4D
  432. //
  433. // If the IMMED bit is 1, status is returned as soon
  434. // as the operation is initiated. If the IMMED bit
  435. // is 0, status is not returned until the operation
  436. // is completed.
  437. //
  438. #define CDB_RETURN_ON_COMPLETION 0
  439. #define CDB_RETURN_IMMEDIATE 1
  440. //
  441. // CDB Force media access used in extended read and write commands.
  442. //
  443. #define CDB_FORCE_MEDIA_ACCESS 0x08
  444. //
  445. // Denon CD ROM operation codes
  446. //
  447. #define SCSIOP_DENON_EJECT_DISC 0xE6
  448. #define SCSIOP_DENON_STOP_AUDIO 0xE7
  449. #define SCSIOP_DENON_PLAY_AUDIO 0xE8
  450. #define SCSIOP_DENON_READ_TOC 0xE9
  451. #define SCSIOP_DENON_READ_SUBCODE 0xEB
  452. //
  453. // SCSI Bus Messages
  454. //
  455. #define SCSIMESS_ABORT 0x06
  456. #define SCSIMESS_ABORT_WITH_TAG 0x0D
  457. #define SCSIMESS_BUS_DEVICE_RESET 0X0C
  458. #define SCSIMESS_CLEAR_QUEUE 0X0E
  459. #define SCSIMESS_COMMAND_COMPLETE 0X00
  460. #define SCSIMESS_DISCONNECT 0X04
  461. #define SCSIMESS_EXTENDED_MESSAGE 0X01
  462. #define SCSIMESS_IDENTIFY 0X80
  463. #define SCSIMESS_IDENTIFY_WITH_DISCON 0XC0
  464. #define SCSIMESS_IGNORE_WIDE_RESIDUE 0X23
  465. #define SCSIMESS_INITIATE_RECOVERY 0X0F
  466. #define SCSIMESS_INIT_DETECTED_ERROR 0X05
  467. #define SCSIMESS_LINK_CMD_COMP 0X0A
  468. #define SCSIMESS_LINK_CMD_COMP_W_FLAG 0X0B
  469. #define SCSIMESS_MESS_PARITY_ERROR 0X09
  470. #define SCSIMESS_MESSAGE_REJECT 0X07
  471. #define SCSIMESS_NO_OPERATION 0X08
  472. #define SCSIMESS_HEAD_OF_QUEUE_TAG 0X21
  473. #define SCSIMESS_ORDERED_QUEUE_TAG 0X22
  474. #define SCSIMESS_SIMPLE_QUEUE_TAG 0X20
  475. #define SCSIMESS_RELEASE_RECOVERY 0X10
  476. #define SCSIMESS_RESTORE_POINTERS 0X03
  477. #define SCSIMESS_SAVE_DATA_POINTER 0X02
  478. #define SCSIMESS_TERMINATE_IO_PROCESS 0X11
  479. //
  480. // SCSI Extended Message operation codes
  481. //
  482. #define SCSIMESS_MODIFY_DATA_POINTER 0X00
  483. #define SCSIMESS_SYNCHRONOUS_DATA_REQ 0X01
  484. #define SCSIMESS_WIDE_DATA_REQUEST 0X03
  485. //
  486. // SCSI Extended Message Lengths
  487. //
  488. #define SCSIMESS_MODIFY_DATA_LENGTH 5
  489. #define SCSIMESS_SYNCH_DATA_LENGTH 3
  490. #define SCSIMESS_WIDE_DATA_LENGTH 2
  491. //
  492. // SCSI extended message structure
  493. //
  494. #pragma pack (1)
  495. typedef struct _SCSI_EXTENDED_MESSAGE {
  496. UCHAR InitialMessageCode;
  497. UCHAR MessageLength;
  498. UCHAR MessageType;
  499. union _EXTENDED_ARGUMENTS {
  500. struct {
  501. UCHAR Modifier[4];
  502. } Modify;
  503. struct {
  504. UCHAR TransferPeriod;
  505. UCHAR ReqAckOffset;
  506. } Synchronous;
  507. struct{
  508. UCHAR Width;
  509. } Wide;
  510. }ExtendedArguments;
  511. }SCSI_EXTENDED_MESSAGE, *PSCSI_EXTENDED_MESSAGE;
  512. #pragma pack ()
  513. //
  514. // SCSI bus status codes.
  515. //
  516. #define SCSISTAT_GOOD 0x00
  517. #define SCSISTAT_CHECK_CONDITION 0x02
  518. #define SCSISTAT_CONDITION_MET 0x04
  519. #define SCSISTAT_BUSY 0x08
  520. #define SCSISTAT_INTERMEDIATE 0x10
  521. #define SCSISTAT_INTERMEDIATE_COND_MET 0x14
  522. #define SCSISTAT_RESERVATION_CONFLICT 0x18
  523. #define SCSISTAT_COMMAND_TERMINATED 0x22
  524. #define SCSISTAT_QUEUE_FULL 0x28
  525. //
  526. // Enable Vital Product Data Flag (EVPD)
  527. // used with INQUIRY command.
  528. //
  529. #define CDB_INQUIRY_EVPD 0x01
  530. //
  531. // Defines for format CDB
  532. //
  533. #define LUN0_FORMAT_SAVING_DEFECT_LIST 0
  534. #define USE_DEFAULTMSB 0
  535. #define USE_DEFAULTLSB 0
  536. #define START_UNIT_CODE 0x01
  537. #define STOP_UNIT_CODE 0x00
  538. //
  539. // Inquiry buffer structure. This is the data returned from the target
  540. // after it receives an inquiry.
  541. //
  542. // This structure may be extended by the number of bytes specified
  543. // in the field AdditionalLength. The defined size constant only
  544. // includes fields through ProductRevisionLevel.
  545. //
  546. // The NT SCSI drivers are only interested in the first 36 bytes of data.
  547. //
  548. #define INQUIRYDATABUFFERSIZE 36
  549. typedef struct _INQUIRYDATA {
  550. UCHAR DeviceType : 5;
  551. UCHAR DeviceTypeQualifier : 3;
  552. UCHAR DeviceTypeModifier : 7;
  553. UCHAR RemovableMedia : 1;
  554. UCHAR Versions;
  555. UCHAR ResponseDataFormat;
  556. UCHAR AdditionalLength;
  557. UCHAR Reserved[2];
  558. UCHAR SoftReset : 1;
  559. UCHAR CommandQueue : 1;
  560. UCHAR Reserved2 : 1;
  561. UCHAR LinkedCommands : 1;
  562. UCHAR Synchronous : 1;
  563. UCHAR Wide16Bit : 1;
  564. UCHAR Wide32Bit : 1;
  565. UCHAR RelativeAddressing : 1;
  566. UCHAR VendorId[8];
  567. UCHAR ProductId[16];
  568. UCHAR ProductRevisionLevel[4];
  569. UCHAR VendorSpecific[20];
  570. UCHAR Reserved3[40];
  571. } INQUIRYDATA, *PINQUIRYDATA;
  572. //
  573. // Inquiry defines. Used to interpret data returned from target as result
  574. // of inquiry command.
  575. //
  576. // DeviceType field
  577. //
  578. #define DIRECT_ACCESS_DEVICE 0x00 // disks
  579. #define SEQUENTIAL_ACCESS_DEVICE 0x01 // tapes
  580. #define PRINTER_DEVICE 0x02 // printers
  581. #define PROCESSOR_DEVICE 0x03 // scanners, printers, etc
  582. #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04 // worms
  583. #define READ_ONLY_DIRECT_ACCESS_DEVICE 0x05 // cdroms
  584. #define SCANNER_DEVICE 0x06 // scanners
  585. #define OPTICAL_DEVICE 0x07 // optical disks
  586. #define MEDIUM_CHANGER 0x08 // jukebox
  587. #define COMMUNICATION_DEVICE 0x09 // network
  588. #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
  589. //
  590. // DeviceTypeQualifier field
  591. //
  592. #define DEVICE_CONNECTED 0x00
  593. //
  594. // Sense Data Format
  595. //
  596. typedef struct _SENSE_DATA {
  597. UCHAR ErrorCode:7;
  598. UCHAR Valid:1;
  599. UCHAR SegmentNumber;
  600. UCHAR SenseKey:4;
  601. UCHAR Reserved:1;
  602. UCHAR IncorrectLength:1;
  603. UCHAR EndOfMedia:1;
  604. UCHAR FileMark:1;
  605. UCHAR Information[4];
  606. UCHAR AdditionalSenseLength;
  607. UCHAR CommandSpecificInformation[4];
  608. UCHAR AdditionalSenseCode;
  609. UCHAR AdditionalSenseCodeQualifier;
  610. UCHAR FieldReplaceableUnitCode;
  611. UCHAR SenseKeySpecific[3];
  612. } SENSE_DATA, *PSENSE_DATA;
  613. //
  614. // Default request sense buffer size
  615. //
  616. #define SENSE_BUFFER_SIZE 18
  617. //
  618. // Sense codes
  619. //
  620. #define SCSI_SENSE_NO_SENSE 0x00
  621. #define SCSI_SENSE_RECOVERED_ERROR 0x01
  622. #define SCSI_SENSE_NOT_READY 0x02
  623. #define SCSI_SENSE_MEDIUM_ERROR 0x03
  624. #define SCSI_SENSE_HARDWARE_ERROR 0x04
  625. #define SCSI_SENSE_ILLEGAL_REQUEST 0x05
  626. #define SCSI_SENSE_UNIT_ATTENTION 0x06
  627. #define SCSI_SENSE_DATA_PROTECT 0x07
  628. #define SCSI_SENSE_BLANK_CHECK 0x08
  629. #define SCSI_SENSE_UNIQUE 0x09
  630. #define SCSI_SENSE_COPY_ABORTED 0x0A
  631. #define SCSI_SENSE_ABORTED_COMMAND 0x0B
  632. #define SCSI_SENSE_EQUAL 0x0C
  633. #define SCSI_SENSE_VOL_OVERFLOW 0x0D
  634. #define SCSI_SENSE_MISCOMPARE 0x0E
  635. #define SCSI_SENSE_RESERVED 0x0F
  636. //
  637. // Additional tape bit
  638. //
  639. #define SCSI_ILLEGAL_LENGTH 0x20
  640. #define SCSI_EOM 0x40
  641. #define SCSI_FILE_MARK 0x80
  642. //
  643. // Additional Sense codes
  644. //
  645. #define SCSI_ADSENSE_NO_SENSE 0x00
  646. #define SCSI_ADSENSE_LUN_NOT_READY 0x04
  647. #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
  648. #define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
  649. #define SCSI_ADSENSE_INVALID_LUN 0x25
  650. #define SCSI_ADSENSE_MUSIC_AREA 0xA0
  651. #define SCSI_ADSENSE_DATA_AREA 0xA1
  652. #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
  653. #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
  654. #define SCSI_ADWRITE_PROTECT 0x27
  655. #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
  656. #define SCSI_ADSENSE_BUS_RESET 0x29
  657. #define SCSI_ADSENSE_TRACK_ERROR 0x14
  658. #define SCSI_ADSENSE_SEEK_ERROR 0x15
  659. #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
  660. #define SCSI_ADSENSE_REC_DATA_ECC 0x18
  661. //
  662. // Additional sense code qualifier
  663. //
  664. #define SCSI_SENSEQ_FORMAT_IN_PROGRESS 0x04
  665. #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED 0x02
  666. #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
  667. #define SCSI_SENSEQ_BECOMING_READY 0x01
  668. #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
  669. #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
  670. #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
  671. #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
  672. //
  673. // SCSI IO Device Control Codes
  674. //
  675. #define FILE_DEVICE_SCSI 0x0000001b
  676. #define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
  677. #define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
  678. #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
  679. //
  680. // Read Capacity Data - returned in Big Endian format
  681. //
  682. typedef struct _READ_CAPACITY_DATA {
  683. ULONG LogicalBlockAddress;
  684. ULONG BytesPerBlock;
  685. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  686. //
  687. // Read Block Limits Data - returned in Big Endian format
  688. // This structure returns the maximum and minimum block
  689. // size for a TAPE device.
  690. //
  691. typedef struct _READ_BLOCK_LIMITS {
  692. UCHAR Reserved;
  693. UCHAR BlockMaximumSize[3];
  694. UCHAR BlockMinimumSize[2];
  695. } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
  696. //
  697. // Mode data structures.
  698. //
  699. //
  700. // Define Mode parameter header.
  701. //
  702. typedef struct _MODE_PARAMETER_HEADER {
  703. UCHAR ModeDataLength;
  704. UCHAR MediumType;
  705. UCHAR DeviceSpecificParameter;
  706. UCHAR BlockDescriptorLength;
  707. }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
  708. #define MODE_FD_SINGLE_SIDE 0x01
  709. #define MODE_FD_DOUBLE_SIDE 0x02
  710. #define MODE_FD_MAXIMUM_TYPE 0x1E
  711. #define MODE_DSP_FUA_SUPPORTED 0x10
  712. #define MODE_DSP_WRITE_PROTECT 0x80
  713. //
  714. // Define the mode parameter block.
  715. //
  716. typedef struct _MODE_PARAMETER_BLOCK {
  717. UCHAR DensityCode;
  718. UCHAR NumberOfBlocks[3];
  719. UCHAR Reserved;
  720. UCHAR BlockLength[3];
  721. }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
  722. //
  723. // Define Disconnect-Reconnect page.
  724. //
  725. typedef struct _MODE_DISCONNECT_PAGE {
  726. UCHAR PageCode : 6;
  727. UCHAR Reserved : 1;
  728. UCHAR PageSavable : 1;
  729. UCHAR PageLength;
  730. UCHAR BufferFullRatio;
  731. UCHAR BufferEmptyRatio;
  732. UCHAR BusInactivityLimit[2];
  733. UCHAR BusDisconnectTime[2];
  734. UCHAR BusConnectTime[2];
  735. UCHAR MaximumBurstSize[2];
  736. UCHAR DataTransferDisconnect : 2;
  737. UCHAR Reserved2[3];
  738. }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
  739. //
  740. // Define mode caching page.
  741. //
  742. typedef struct _MODE_CACHING_PAGE {
  743. UCHAR PageCode : 6;
  744. UCHAR Reserved : 1;
  745. UCHAR PageSavable : 1;
  746. UCHAR PageLength;
  747. UCHAR ReadDisableCache : 1;
  748. UCHAR MultiplicationFactor : 1;
  749. UCHAR WriteCacheEnable : 1;
  750. UCHAR Reserved2 : 5;
  751. UCHAR WriteRetensionPriority : 4;
  752. UCHAR ReadRetensionPriority : 4;
  753. UCHAR DisablePrefetchTransfer[2];
  754. UCHAR MinimumPrefectch[2];
  755. UCHAR MaximumPrefectch[2];
  756. UCHAR MaximumPrefectchCeil[2];
  757. }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
  758. //
  759. // Define mode flexible disk page.
  760. //
  761. typedef struct _MODE_FLEXIBLE_DISK_PAGE {
  762. UCHAR PageCode : 6;
  763. UCHAR Reserved : 1;
  764. UCHAR PageSavable : 1;
  765. UCHAR PageLength;
  766. UCHAR TransferRate[2];
  767. UCHAR NumberOfHeads;
  768. UCHAR SectorsPerTrack;
  769. UCHAR BytesPerSector[2];
  770. UCHAR NumberOfCylinders[2];
  771. UCHAR StartWritePrecom[2];
  772. UCHAR StartReducedCurrent[2];
  773. UCHAR StepRate[2];
  774. UCHAR StepPluseWidth;
  775. UCHAR HeadSettleDelay[2];
  776. UCHAR MotorOnDelay;
  777. UCHAR MotorOffDelay;
  778. UCHAR Reserved2 : 5;
  779. UCHAR MotorOnAsserted : 1;
  780. UCHAR StartSectorNumber : 1;
  781. UCHAR TrueReadySignal : 1;
  782. UCHAR StepPlusePerCyclynder : 4;
  783. UCHAR Reserved3 : 4;
  784. UCHAR WriteCompenstation;
  785. UCHAR HeadLoadDelay;
  786. UCHAR HeadUnloadDelay;
  787. UCHAR Pin2Usage : 4;
  788. UCHAR Pin34Usage : 4;
  789. UCHAR Pin1Usage : 4;
  790. UCHAR Pin4Usage : 4;
  791. UCHAR MediumRotationRate[2];
  792. UCHAR Reserved4[2];
  793. }MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
  794. //
  795. // Define mode format page.
  796. //
  797. typedef struct _MODE_FORMAT_PAGE {
  798. UCHAR PageCode : 6;
  799. UCHAR Reserved : 1;
  800. UCHAR PageSavable : 1;
  801. UCHAR PageLength;
  802. UCHAR TracksPerZone[2];
  803. UCHAR AlternetSectorsPerZone[2];
  804. UCHAR AlternetTracksPerZone[2];
  805. UCHAR SectorsPerTrack[2];
  806. UCHAR BytesPerPhysicalSector[2];
  807. UCHAR Interleave[2];
  808. UCHAR TrackSkewFactor[2];
  809. UCHAR CylinderSkewFactor[2];
  810. UCHAR Reserved2 : 4;
  811. UCHAR SurfaceFirst : 1;
  812. UCHAR RemovableMedia : 1;
  813. UCHAR HardSectorFormating : 1;
  814. UCHAR SoftSectorFormating : 1;
  815. UCHAR Reserved3[2];
  816. }MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
  817. //
  818. // Define rigid disk driver geometry page.
  819. //
  820. typedef struct _MODE_RIGID_GEOMETRY_PAGE {
  821. UCHAR PageCode : 6;
  822. UCHAR Reserved : 1;
  823. UCHAR PageSavable : 1;
  824. UCHAR PageLength;
  825. UCHAR NumberOfCylinders[2];
  826. UCHAR NumberOfHeads;
  827. UCHAR StartWritePrecom[2];
  828. UCHAR StartReducedCurrent[2];
  829. UCHAR DriveStepRate[2];
  830. UCHAR LandZoneCyclinder[2];
  831. UCHAR RotationalPositionLock : 2;
  832. UCHAR Reserved2 : 6;
  833. UCHAR RotationOffset;
  834. UCHAR Reserved3;
  835. UCHAR RoataionRate[2];
  836. UCHAR Reserved4[2];
  837. }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
  838. //
  839. // Define read write recovery page
  840. //
  841. typedef struct _MODE_READ_WRITE_RECOVERY_PAGE {
  842. UCHAR PageCode : 6;
  843. UCHAR Reserved1 : 1;
  844. UCHAR PSBit : 1;
  845. UCHAR PageLength;
  846. UCHAR DCRBit : 1;
  847. UCHAR DTEBit : 1;
  848. UCHAR PERBit : 1;
  849. UCHAR EERBit : 1;
  850. UCHAR Reserved2 : 1;
  851. UCHAR TBBit : 1;
  852. UCHAR Reserved3 : 2;
  853. UCHAR ReadRetryCount;
  854. UCHAR Reserved4[4];
  855. UCHAR WriteRetryCount;
  856. UCHAR Reserved5[3];
  857. } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
  858. //
  859. // Mode parameter list block descriptor -
  860. // set the block length for reading/writing
  861. //
  862. //
  863. #define MODE_BLOCK_DESC_LENGTH 8
  864. typedef struct _MODE_PARM_READ_WRITE {
  865. MODE_PARAMETER_HEADER ParameterListHeader; // List Header Format
  866. MODE_PARAMETER_BLOCK ParameterListBlock; // List Block Descriptor
  867. } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
  868. //
  869. // CDROM audio control (0x0E)
  870. //
  871. #define CDB_AUDIO_PAUSE 0
  872. #define CDB_AUDIO_RESUME 1
  873. #define CDB_DEVICE_START 0x11
  874. #define CDB_DEVICE_STOP 0x10
  875. #define CDB_EJECT_MEDIA 0x10
  876. #define CDB_LOAD_MEDIA 0x01
  877. #define CDB_SUBCHANNEL_HEADER 0x00
  878. #define CDB_SUBCHANNEL_BLOCK 0x01
  879. #define CDROM_AUDIO_CONTROL_PAGE 0x0E
  880. #define MODE_SELECT_IMMEDIATE 0x04
  881. #define MODE_SELECT_PFBIT 0x10
  882. #define CDB_USE_MSF 0x01
  883. typedef struct _PORT_OUTPUT {
  884. UCHAR ChannelSelection;
  885. UCHAR Volume;
  886. } PORT_OUTPUT, *PPORT_OUTPUT;
  887. typedef struct _AUDIO_OUTPUT {
  888. UCHAR CodePage;
  889. UCHAR ParameterLength;
  890. UCHAR Immediate;
  891. UCHAR Reserved[2];
  892. UCHAR LbaFormat;
  893. UCHAR LogicalBlocksPerSecond[2];
  894. PORT_OUTPUT PortOutput[4];
  895. } AUDIO_OUTPUT, *PAUDIO_OUTPUT;
  896. //
  897. // Multisession CDROM
  898. //
  899. #define GET_LAST_SESSION 0x01
  900. #define GET_SESSION_DATA 0x02;
  901. //
  902. // Tape definitions
  903. //
  904. typedef struct _TAPE_POSITION_DATA {
  905. UCHAR Reserved1:2;
  906. UCHAR BlockPositionUnsupported:1;
  907. UCHAR Reserved2:3;
  908. UCHAR EndOfPartition:1;
  909. UCHAR BeginningOfPartition:1;
  910. UCHAR PartitionNumber;
  911. USHORT Reserved3;
  912. UCHAR FirstBlock[4];
  913. UCHAR LastBlock[4];
  914. UCHAR Reserved4;
  915. UCHAR NumberOfBlocks[3];
  916. UCHAR NumberOfBytes[4];
  917. } TAPE_POSITION_DATA, *PTAPE_POSITION_DATA;
  918. //
  919. // Byte reversing macro for converting
  920. // between big- and little-endian formats
  921. //
  922. #define REVERSE_BYTES(Destination, Source) { \
  923. (Destination)->Byte3 = (Source)->Byte0; \
  924. (Destination)->Byte2 = (Source)->Byte1; \
  925. (Destination)->Byte1 = (Source)->Byte2; \
  926. (Destination)->Byte0 = (Source)->Byte3; \
  927. }
  928. //
  929. // This structure is used to convert little endian
  930. // ULONGs to SCSI CDB 4 byte big endians values.
  931. //
  932. typedef struct _FOUR_BYTE {
  933. UCHAR Byte0;
  934. UCHAR Byte1;
  935. UCHAR Byte2;
  936. UCHAR Byte3;
  937. } FOUR_BYTE, *PFOUR_BYTE;
  938. //
  939. // This macro has the effect of Bit = log2(Data)
  940. //
  941. #define WHICH_BIT(Data, Bit) { \
  942. for (Bit = 0; Bit < 32; Bit++) { \
  943. if ((Data >> Bit) == 1) { \
  944. break; \
  945. } \
  946. } \
  947. }
  948. #endif