Leaked source code of windows server 2003
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.

3179 lines
93 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  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. Revision History:
  10. --*/
  11. #ifndef _NTSCSI_
  12. #define _NTSCSI_
  13. #ifndef _NTSCSI_USER_MODE_
  14. #include "srb.h"
  15. #endif // !defined _NTSCSI_USER_MODE_
  16. #if _MSC_VER >= 1200
  17. #pragma warning(push)
  18. #endif
  19. #pragma warning(disable:4200) // array[0] is not a warning for this file
  20. #pragma pack(push, _scsi_)
  21. // begin_ntminitape
  22. //
  23. // Command Descriptor Block. Passed by SCSI controller chip over the SCSI bus
  24. //
  25. #pragma pack(push, cdb, 1)
  26. typedef union _CDB {
  27. //
  28. // Generic 6-Byte CDB
  29. //
  30. struct _CDB6GENERIC {
  31. UCHAR OperationCode;
  32. UCHAR Immediate : 1;
  33. UCHAR CommandUniqueBits : 4;
  34. UCHAR LogicalUnitNumber : 3;
  35. UCHAR CommandUniqueBytes[3];
  36. UCHAR Link : 1;
  37. UCHAR Flag : 1;
  38. UCHAR Reserved : 4;
  39. UCHAR VendorUnique : 2;
  40. } CDB6GENERIC, *PCDB6GENERIC;
  41. //
  42. // Standard 6-byte CDB
  43. //
  44. struct _CDB6READWRITE {
  45. UCHAR OperationCode; // 0x08, 0x0A - SCSIOP_READ, SCSIOP_WRITE
  46. UCHAR LogicalBlockMsb1 : 5;
  47. UCHAR LogicalUnitNumber : 3;
  48. UCHAR LogicalBlockMsb0;
  49. UCHAR LogicalBlockLsb;
  50. UCHAR TransferBlocks;
  51. UCHAR Control;
  52. } CDB6READWRITE, *PCDB6READWRITE;
  53. //
  54. // SCSI-1 Inquiry CDB
  55. //
  56. struct _CDB6INQUIRY {
  57. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  58. UCHAR Reserved1 : 5;
  59. UCHAR LogicalUnitNumber : 3;
  60. UCHAR PageCode;
  61. UCHAR IReserved;
  62. UCHAR AllocationLength;
  63. UCHAR Control;
  64. } CDB6INQUIRY, *PCDB6INQUIRY;
  65. //
  66. // SCSI-3 Inquiry CDB
  67. //
  68. struct _CDB6INQUIRY3 {
  69. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  70. UCHAR EnableVitalProductData : 1;
  71. UCHAR CommandSupportData : 1;
  72. UCHAR Reserved1 : 6;
  73. UCHAR PageCode;
  74. UCHAR Reserved2;
  75. UCHAR AllocationLength;
  76. UCHAR Control;
  77. } CDB6INQUIRY3, *PCDB6INQUIRY3;
  78. struct _CDB6VERIFY {
  79. UCHAR OperationCode; // 0x13 - SCSIOP_VERIFY
  80. UCHAR Fixed : 1;
  81. UCHAR ByteCompare : 1;
  82. UCHAR Immediate : 1;
  83. UCHAR Reserved : 2;
  84. UCHAR LogicalUnitNumber : 3;
  85. UCHAR VerificationLength[3];
  86. UCHAR Control;
  87. } CDB6VERIFY, *PCDB6VERIFY;
  88. //
  89. // SCSI Format CDB
  90. //
  91. struct _CDB6FORMAT {
  92. UCHAR OperationCode; // 0x04 - SCSIOP_FORMAT_UNIT
  93. UCHAR FormatControl : 5;
  94. UCHAR LogicalUnitNumber : 3;
  95. UCHAR FReserved1;
  96. UCHAR InterleaveMsb;
  97. UCHAR InterleaveLsb;
  98. UCHAR FReserved2;
  99. } CDB6FORMAT, *PCDB6FORMAT;
  100. //
  101. // Standard 10-byte CDB
  102. struct _CDB10 {
  103. UCHAR OperationCode;
  104. UCHAR RelativeAddress : 1;
  105. UCHAR Reserved1 : 2;
  106. UCHAR ForceUnitAccess : 1;
  107. UCHAR DisablePageOut : 1;
  108. UCHAR LogicalUnitNumber : 3;
  109. UCHAR LogicalBlockByte0;
  110. UCHAR LogicalBlockByte1;
  111. UCHAR LogicalBlockByte2;
  112. UCHAR LogicalBlockByte3;
  113. UCHAR Reserved2;
  114. UCHAR TransferBlocksMsb;
  115. UCHAR TransferBlocksLsb;
  116. UCHAR Control;
  117. } CDB10, *PCDB10;
  118. //
  119. // Standard 12-byte CDB
  120. //
  121. struct _CDB12 {
  122. UCHAR OperationCode;
  123. UCHAR RelativeAddress : 1;
  124. UCHAR Reserved1 : 2;
  125. UCHAR ForceUnitAccess : 1;
  126. UCHAR DisablePageOut : 1;
  127. UCHAR LogicalUnitNumber : 3;
  128. UCHAR LogicalBlock[4];
  129. UCHAR TransferLength[4];
  130. UCHAR Reserved2;
  131. UCHAR Control;
  132. } CDB12, *PCDB12;
  133. //
  134. // CD Rom Audio CDBs
  135. //
  136. struct _PAUSE_RESUME {
  137. UCHAR OperationCode; // 0x4B - SCSIOP_PAUSE_RESUME
  138. UCHAR Reserved1 : 5;
  139. UCHAR LogicalUnitNumber : 3;
  140. UCHAR Reserved2[6];
  141. UCHAR Action;
  142. UCHAR Control;
  143. } PAUSE_RESUME, *PPAUSE_RESUME;
  144. //
  145. // Read Table of Contents
  146. //
  147. struct _READ_TOC {
  148. UCHAR OperationCode; // 0x43 - SCSIOP_READ_TOC
  149. UCHAR Reserved0 : 1;
  150. UCHAR Msf : 1;
  151. UCHAR Reserved1 : 3;
  152. UCHAR LogicalUnitNumber : 3;
  153. UCHAR Format2 : 4;
  154. UCHAR Reserved2 : 4;
  155. UCHAR Reserved3[3];
  156. UCHAR StartingTrack;
  157. UCHAR AllocationLength[2];
  158. UCHAR Control : 6;
  159. UCHAR Format : 2;
  160. } READ_TOC, *PREAD_TOC;
  161. struct _READ_DISK_INFORMATION {
  162. UCHAR OperationCode; // 0x51 - SCSIOP_READ_DISC_INFORMATION
  163. UCHAR Reserved1 : 5;
  164. UCHAR Lun : 3;
  165. UCHAR Reserved2[5];
  166. UCHAR AllocationLength[2];
  167. UCHAR Control;
  168. } READ_DISK_INFORMATION, *PREAD_DISK_INFORMATION,
  169. READ_DISC_INFORMATION, *PREAD_DISC_INFORMATION;
  170. struct _READ_TRACK_INFORMATION {
  171. UCHAR OperationCode; // 0x52 - SCSIOP_READ_TRACK_INFORMATION
  172. UCHAR Track : 2;
  173. UCHAR Reserved4 : 3;
  174. UCHAR Lun : 3;
  175. UCHAR BlockAddress[4]; // or Track Number
  176. UCHAR Reserved3;
  177. UCHAR AllocationLength[2];
  178. UCHAR Control;
  179. } READ_TRACK_INFORMATION, *PREAD_TRACK_INFORMATION;
  180. struct _RESERVE_TRACK_RZONE {
  181. UCHAR OperationCode; // 0x53 - SCSIOP_RESERVE_TRACK_RZONE
  182. UCHAR Reserved1[4];
  183. UCHAR ReservationSize[4];
  184. UCHAR Control;
  185. } RESERVE_TRACK_RZONE, *PRESERVE_TRACK_RZONE;
  186. struct _SEND_OPC_INFORMATION {
  187. UCHAR OperationCode; // 0x54 - SCSIOP_SEND_OPC_INFORMATION
  188. UCHAR DoOpc : 1; // perform OPC
  189. UCHAR Reserved : 7;
  190. UCHAR Reserved1[5];
  191. UCHAR ParameterListLength[2];
  192. UCHAR Reserved2;
  193. } SEND_OPC_INFORMATION, *PSEND_OPC_INFORMATION;
  194. struct _CLOSE_TRACK {
  195. UCHAR OperationCode; // 0x5B - SCSIOP_CLOSE_TRACK_SESSION
  196. UCHAR Immediate : 1;
  197. UCHAR Reserved1 : 7;
  198. UCHAR Track : 1;
  199. UCHAR Session : 1;
  200. UCHAR Reserved2 : 6;
  201. UCHAR Reserved3;
  202. UCHAR TrackNumber[2];
  203. UCHAR Reserved4[3];
  204. UCHAR Control;
  205. } CLOSE_TRACK, *PCLOSE_TRACK;
  206. struct _SEND_CUE_SHEET {
  207. UCHAR OperationCode; // 0x5D - SCSIOP_SEND_CUE_SHEET
  208. UCHAR Reserved[5];
  209. UCHAR CueSheetSize[3];
  210. UCHAR Control;
  211. } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
  212. struct _READ_HEADER {
  213. UCHAR OperationCode; // 0x44 - SCSIOP_READ_HEADER
  214. UCHAR Reserved1 : 1;
  215. UCHAR Msf : 1;
  216. UCHAR Reserved2 : 3;
  217. UCHAR Lun : 3;
  218. UCHAR LogicalBlockAddress[4];
  219. UCHAR Reserved3;
  220. UCHAR AllocationLength[2];
  221. UCHAR Control;
  222. } READ_HEADER, *PREAD_HEADER;
  223. struct _PLAY_AUDIO {
  224. UCHAR OperationCode; // 0x45 - SCSIOP_PLAY_AUDIO
  225. UCHAR Reserved1 : 5;
  226. UCHAR LogicalUnitNumber : 3;
  227. UCHAR StartingBlockAddress[4];
  228. UCHAR Reserved2;
  229. UCHAR PlayLength[2];
  230. UCHAR Control;
  231. } PLAY_AUDIO, *PPLAY_AUDIO;
  232. struct _PLAY_AUDIO_MSF {
  233. UCHAR OperationCode; // 0x47 - SCSIOP_PLAY_AUDIO_MSF
  234. UCHAR Reserved1 : 5;
  235. UCHAR LogicalUnitNumber : 3;
  236. UCHAR Reserved2;
  237. UCHAR StartingM;
  238. UCHAR StartingS;
  239. UCHAR StartingF;
  240. UCHAR EndingM;
  241. UCHAR EndingS;
  242. UCHAR EndingF;
  243. UCHAR Control;
  244. } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
  245. struct _BLANK_MEDIA {
  246. UCHAR OperationCode; // 0xA1 - SCSIOP_BLANK
  247. UCHAR BlankType : 3;
  248. UCHAR Reserved1 : 1;
  249. UCHAR Immediate : 1;
  250. UCHAR Reserved2 : 3;
  251. UCHAR AddressOrTrack[4];
  252. UCHAR Reserved3[5];
  253. UCHAR Control;
  254. } BLANK_MEDIA, *PBLANK_MEDIA;
  255. struct _PLAY_CD {
  256. UCHAR OperationCode; // 0xBC - SCSIOP_PLAY_CD
  257. UCHAR Reserved1 : 1;
  258. UCHAR CMSF : 1; // LBA = 0, MSF = 1
  259. UCHAR ExpectedSectorType : 3;
  260. UCHAR Lun : 3;
  261. union {
  262. struct _LBA {
  263. UCHAR StartingBlockAddress[4];
  264. UCHAR PlayLength[4];
  265. } LBA;
  266. struct _MSF {
  267. UCHAR Reserved1;
  268. UCHAR StartingM;
  269. UCHAR StartingS;
  270. UCHAR StartingF;
  271. UCHAR EndingM;
  272. UCHAR EndingS;
  273. UCHAR EndingF;
  274. UCHAR Reserved2;
  275. } MSF;
  276. };
  277. UCHAR Audio : 1;
  278. UCHAR Composite : 1;
  279. UCHAR Port1 : 1;
  280. UCHAR Port2 : 1;
  281. UCHAR Reserved2 : 3;
  282. UCHAR Speed : 1;
  283. UCHAR Control;
  284. } PLAY_CD, *PPLAY_CD;
  285. struct _SCAN_CD {
  286. UCHAR OperationCode; // 0xBA - SCSIOP_SCAN_CD
  287. UCHAR RelativeAddress : 1;
  288. UCHAR Reserved1 : 3;
  289. UCHAR Direct : 1;
  290. UCHAR Lun : 3;
  291. UCHAR StartingAddress[4];
  292. UCHAR Reserved2[3];
  293. UCHAR Reserved3 : 6;
  294. UCHAR Type : 2;
  295. UCHAR Reserved4;
  296. UCHAR Control;
  297. } SCAN_CD, *PSCAN_CD;
  298. struct _STOP_PLAY_SCAN {
  299. UCHAR OperationCode; // 0x4E - SCSIOP_STOP_PLAY_SCAN
  300. UCHAR Reserved1 : 5;
  301. UCHAR Lun : 3;
  302. UCHAR Reserved2[7];
  303. UCHAR Control;
  304. } STOP_PLAY_SCAN, *PSTOP_PLAY_SCAN;
  305. //
  306. // Read SubChannel Data
  307. //
  308. struct _SUBCHANNEL {
  309. UCHAR OperationCode; // 0x42 - SCSIOP_READ_SUB_CHANNEL
  310. UCHAR Reserved0 : 1;
  311. UCHAR Msf : 1;
  312. UCHAR Reserved1 : 3;
  313. UCHAR LogicalUnitNumber : 3;
  314. UCHAR Reserved2 : 6;
  315. UCHAR SubQ : 1;
  316. UCHAR Reserved3 : 1;
  317. UCHAR Format;
  318. UCHAR Reserved4[2];
  319. UCHAR TrackNumber;
  320. UCHAR AllocationLength[2];
  321. UCHAR Control;
  322. } SUBCHANNEL, *PSUBCHANNEL;
  323. //
  324. // Read CD. Used by Atapi for raw sector reads.
  325. //
  326. struct _READ_CD {
  327. UCHAR OperationCode; // 0xBE - SCSIOP_READ_CD
  328. UCHAR RelativeAddress : 1;
  329. UCHAR Reserved0 : 1;
  330. UCHAR ExpectedSectorType : 3;
  331. UCHAR Lun : 3;
  332. UCHAR StartingLBA[4];
  333. UCHAR TransferBlocks[3];
  334. UCHAR Reserved2 : 1;
  335. UCHAR ErrorFlags : 2;
  336. UCHAR IncludeEDC : 1;
  337. UCHAR IncludeUserData : 1;
  338. UCHAR HeaderCode : 2;
  339. UCHAR IncludeSyncData : 1;
  340. UCHAR SubChannelSelection : 3;
  341. UCHAR Reserved3 : 5;
  342. UCHAR Control;
  343. } READ_CD, *PREAD_CD;
  344. struct _READ_CD_MSF {
  345. UCHAR OperationCode; // 0xB9 - SCSIOP_READ_CD_MSF
  346. UCHAR RelativeAddress : 1;
  347. UCHAR Reserved1 : 1;
  348. UCHAR ExpectedSectorType : 3;
  349. UCHAR Lun : 3;
  350. UCHAR Reserved2;
  351. UCHAR StartingM;
  352. UCHAR StartingS;
  353. UCHAR StartingF;
  354. UCHAR EndingM;
  355. UCHAR EndingS;
  356. UCHAR EndingF;
  357. UCHAR Reserved4 : 1;
  358. UCHAR ErrorFlags : 2;
  359. UCHAR IncludeEDC : 1;
  360. UCHAR IncludeUserData : 1;
  361. UCHAR HeaderCode : 2;
  362. UCHAR IncludeSyncData : 1;
  363. UCHAR SubChannelSelection : 3;
  364. UCHAR Reserved5 : 5;
  365. UCHAR Control;
  366. } READ_CD_MSF, *PREAD_CD_MSF;
  367. //
  368. // Plextor Read CD-DA
  369. //
  370. struct _PLXTR_READ_CDDA {
  371. UCHAR OperationCode; // Unknown -- vendor-unique?
  372. UCHAR Reserved0 : 5;
  373. UCHAR LogicalUnitNumber :3;
  374. UCHAR LogicalBlockByte0;
  375. UCHAR LogicalBlockByte1;
  376. UCHAR LogicalBlockByte2;
  377. UCHAR LogicalBlockByte3;
  378. UCHAR TransferBlockByte0;
  379. UCHAR TransferBlockByte1;
  380. UCHAR TransferBlockByte2;
  381. UCHAR TransferBlockByte3;
  382. UCHAR SubCode;
  383. UCHAR Control;
  384. } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
  385. //
  386. // NEC Read CD-DA
  387. //
  388. struct _NEC_READ_CDDA {
  389. UCHAR OperationCode; // Unknown -- vendor-unique?
  390. UCHAR Reserved0;
  391. UCHAR LogicalBlockByte0;
  392. UCHAR LogicalBlockByte1;
  393. UCHAR LogicalBlockByte2;
  394. UCHAR LogicalBlockByte3;
  395. UCHAR Reserved1;
  396. UCHAR TransferBlockByte0;
  397. UCHAR TransferBlockByte1;
  398. UCHAR Control;
  399. } NEC_READ_CDDA, *PNEC_READ_CDDA;
  400. //
  401. // Mode sense
  402. //
  403. struct _MODE_SENSE {
  404. UCHAR OperationCode; // 0x1A - SCSIOP_MODE_SENSE
  405. UCHAR Reserved1 : 3;
  406. UCHAR Dbd : 1;
  407. UCHAR Reserved2 : 1;
  408. UCHAR LogicalUnitNumber : 3;
  409. UCHAR PageCode : 6;
  410. UCHAR Pc : 2;
  411. UCHAR Reserved3;
  412. UCHAR AllocationLength;
  413. UCHAR Control;
  414. } MODE_SENSE, *PMODE_SENSE;
  415. struct _MODE_SENSE10 {
  416. UCHAR OperationCode; // 0x5A - SCSIOP_MODE_SENSE10
  417. UCHAR Reserved1 : 3;
  418. UCHAR Dbd : 1;
  419. UCHAR Reserved2 : 1;
  420. UCHAR LogicalUnitNumber : 3;
  421. UCHAR PageCode : 6;
  422. UCHAR Pc : 2;
  423. UCHAR Reserved3[4];
  424. UCHAR AllocationLength[2];
  425. UCHAR Control;
  426. } MODE_SENSE10, *PMODE_SENSE10;
  427. //
  428. // Mode select
  429. //
  430. struct _MODE_SELECT {
  431. UCHAR OperationCode; // 0x15 - SCSIOP_MODE_SELECT
  432. UCHAR SPBit : 1;
  433. UCHAR Reserved1 : 3;
  434. UCHAR PFBit : 1;
  435. UCHAR LogicalUnitNumber : 3;
  436. UCHAR Reserved2[2];
  437. UCHAR ParameterListLength;
  438. UCHAR Control;
  439. } MODE_SELECT, *PMODE_SELECT;
  440. struct _MODE_SELECT10 {
  441. UCHAR OperationCode; // 0x55 - SCSIOP_MODE_SELECT10
  442. UCHAR SPBit : 1;
  443. UCHAR Reserved1 : 3;
  444. UCHAR PFBit : 1;
  445. UCHAR LogicalUnitNumber : 3;
  446. UCHAR Reserved2[5];
  447. UCHAR ParameterListLength[2];
  448. UCHAR Control;
  449. } MODE_SELECT10, *PMODE_SELECT10;
  450. struct _LOCATE {
  451. UCHAR OperationCode; // 0x2B - SCSIOP_LOCATE
  452. UCHAR Immediate : 1;
  453. UCHAR CPBit : 1;
  454. UCHAR BTBit : 1;
  455. UCHAR Reserved1 : 2;
  456. UCHAR LogicalUnitNumber : 3;
  457. UCHAR Reserved3;
  458. UCHAR LogicalBlockAddress[4];
  459. UCHAR Reserved4;
  460. UCHAR Partition;
  461. UCHAR Control;
  462. } LOCATE, *PLOCATE;
  463. struct _LOGSENSE {
  464. UCHAR OperationCode; // 0x4D - SCSIOP_LOG_SENSE
  465. UCHAR SPBit : 1;
  466. UCHAR PPCBit : 1;
  467. UCHAR Reserved1 : 3;
  468. UCHAR LogicalUnitNumber : 3;
  469. UCHAR PageCode : 6;
  470. UCHAR PCBit : 2;
  471. UCHAR Reserved2;
  472. UCHAR Reserved3;
  473. UCHAR ParameterPointer[2];
  474. UCHAR AllocationLength[2];
  475. UCHAR Control;
  476. } LOGSENSE, *PLOGSENSE;
  477. struct _LOGSELECT {
  478. UCHAR OperationCode; // 0x4C - SCSIOP_LOG_SELECT
  479. UCHAR SPBit : 1;
  480. UCHAR PCRBit : 1;
  481. UCHAR Reserved1 : 3;
  482. UCHAR LogicalUnitNumber : 3;
  483. UCHAR Reserved : 6;
  484. UCHAR PCBit : 2;
  485. UCHAR Reserved2[4];
  486. UCHAR ParameterListLength[2];
  487. UCHAR Control;
  488. } LOGSELECT, *PLOGSELECT;
  489. struct _PRINT {
  490. UCHAR OperationCode; // 0x0A - SCSIOP_PRINT
  491. UCHAR Reserved : 5;
  492. UCHAR LogicalUnitNumber : 3;
  493. UCHAR TransferLength[3];
  494. UCHAR Control;
  495. } PRINT, *PPRINT;
  496. struct _SEEK {
  497. UCHAR OperationCode; // 0x2B - SCSIOP_SEEK
  498. UCHAR Reserved1 : 5;
  499. UCHAR LogicalUnitNumber : 3;
  500. UCHAR LogicalBlockAddress[4];
  501. UCHAR Reserved2[3];
  502. UCHAR Control;
  503. } SEEK, *PSEEK;
  504. struct _ERASE {
  505. UCHAR OperationCode; // 0x19 - SCSIOP_ERASE
  506. UCHAR Long : 1;
  507. UCHAR Immediate : 1;
  508. UCHAR Reserved1 : 3;
  509. UCHAR LogicalUnitNumber : 3;
  510. UCHAR Reserved2[3];
  511. UCHAR Control;
  512. } ERASE, *PERASE;
  513. struct _START_STOP {
  514. UCHAR OperationCode; // 0x1B - SCSIOP_START_STOP_UNIT
  515. UCHAR Immediate: 1;
  516. UCHAR Reserved1 : 4;
  517. UCHAR LogicalUnitNumber : 3;
  518. UCHAR Reserved2[2];
  519. UCHAR Start : 1;
  520. UCHAR LoadEject : 1;
  521. UCHAR Reserved3 : 6;
  522. UCHAR Control;
  523. } START_STOP, *PSTART_STOP;
  524. struct _MEDIA_REMOVAL {
  525. UCHAR OperationCode; // 0x1E - SCSIOP_MEDIUM_REMOVAL
  526. UCHAR Reserved1 : 5;
  527. UCHAR LogicalUnitNumber : 3;
  528. UCHAR Reserved2[2];
  529. UCHAR Prevent : 1;
  530. UCHAR Persistant : 1;
  531. UCHAR Reserved3 : 6;
  532. UCHAR Control;
  533. } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
  534. //
  535. // Tape CDBs
  536. //
  537. struct _SEEK_BLOCK {
  538. UCHAR OperationCode; // 0x0C - SCSIOP_SEEK_BLOCK
  539. UCHAR Immediate : 1;
  540. UCHAR Reserved1 : 7;
  541. UCHAR BlockAddress[3];
  542. UCHAR Link : 1;
  543. UCHAR Flag : 1;
  544. UCHAR Reserved2 : 4;
  545. UCHAR VendorUnique : 2;
  546. } SEEK_BLOCK, *PSEEK_BLOCK;
  547. struct _REQUEST_BLOCK_ADDRESS {
  548. UCHAR OperationCode; // 0x02 - SCSIOP_REQUEST_BLOCK_ADDR
  549. UCHAR Reserved1[3];
  550. UCHAR AllocationLength;
  551. UCHAR Link : 1;
  552. UCHAR Flag : 1;
  553. UCHAR Reserved2 : 4;
  554. UCHAR VendorUnique : 2;
  555. } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
  556. struct _PARTITION {
  557. UCHAR OperationCode; // 0x0D - SCSIOP_PARTITION
  558. UCHAR Immediate : 1;
  559. UCHAR Sel: 1;
  560. UCHAR PartitionSelect : 6;
  561. UCHAR Reserved1[3];
  562. UCHAR Control;
  563. } PARTITION, *PPARTITION;
  564. struct _WRITE_TAPE_MARKS {
  565. UCHAR OperationCode; // Unknown -- vendor-unique?
  566. UCHAR Immediate : 1;
  567. UCHAR WriteSetMarks: 1;
  568. UCHAR Reserved : 3;
  569. UCHAR LogicalUnitNumber : 3;
  570. UCHAR TransferLength[3];
  571. UCHAR Control;
  572. } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
  573. struct _SPACE_TAPE_MARKS {
  574. UCHAR OperationCode; // Unknown -- vendor-unique?
  575. UCHAR Code : 3;
  576. UCHAR Reserved : 2;
  577. UCHAR LogicalUnitNumber : 3;
  578. UCHAR NumMarksMSB ;
  579. UCHAR NumMarks;
  580. UCHAR NumMarksLSB;
  581. union {
  582. UCHAR value;
  583. struct {
  584. UCHAR Link : 1;
  585. UCHAR Flag : 1;
  586. UCHAR Reserved : 4;
  587. UCHAR VendorUnique : 2;
  588. } Fields;
  589. } Byte6;
  590. } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
  591. //
  592. // Read tape position
  593. //
  594. struct _READ_POSITION {
  595. UCHAR Operation; // 0x43 - SCSIOP_READ_POSITION
  596. UCHAR BlockType:1;
  597. UCHAR Reserved1:4;
  598. UCHAR Lun:3;
  599. UCHAR Reserved2[7];
  600. UCHAR Control;
  601. } READ_POSITION, *PREAD_POSITION;
  602. //
  603. // ReadWrite for Tape
  604. //
  605. struct _CDB6READWRITETAPE {
  606. UCHAR OperationCode; // Unknown -- vendor-unique?
  607. UCHAR VendorSpecific : 5;
  608. UCHAR Reserved : 3;
  609. UCHAR TransferLenMSB;
  610. UCHAR TransferLen;
  611. UCHAR TransferLenLSB;
  612. UCHAR Link : 1;
  613. UCHAR Flag : 1;
  614. UCHAR Reserved1 : 4;
  615. UCHAR VendorUnique : 2;
  616. } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
  617. //
  618. // Medium changer CDB's
  619. //
  620. struct _INIT_ELEMENT_STATUS {
  621. UCHAR OperationCode; // 0x07 - SCSIOP_INIT_ELEMENT_STATUS
  622. UCHAR Reserved1 : 5;
  623. UCHAR LogicalUnitNubmer : 3;
  624. UCHAR Reserved2[3];
  625. UCHAR Reserved3 : 7;
  626. UCHAR NoBarCode : 1;
  627. } INIT_ELEMENT_STATUS, *PINIT_ELEMENT_STATUS;
  628. struct _INITIALIZE_ELEMENT_RANGE {
  629. UCHAR OperationCode; // 0xE7 - SCSIOP_INIT_ELEMENT_RANGE
  630. UCHAR Range : 1;
  631. UCHAR Reserved1 : 4;
  632. UCHAR LogicalUnitNubmer : 3;
  633. UCHAR FirstElementAddress[2];
  634. UCHAR Reserved2[2];
  635. UCHAR NumberOfElements[2];
  636. UCHAR Reserved3;
  637. UCHAR Reserved4 : 7;
  638. UCHAR NoBarCode : 1;
  639. } INITIALIZE_ELEMENT_RANGE, *PINITIALIZE_ELEMENT_RANGE;
  640. struct _POSITION_TO_ELEMENT {
  641. UCHAR OperationCode; // 0x2B - SCSIOP_POSITION_TO_ELEMENT
  642. UCHAR Reserved1 : 5;
  643. UCHAR LogicalUnitNumber : 3;
  644. UCHAR TransportElementAddress[2];
  645. UCHAR DestinationElementAddress[2];
  646. UCHAR Reserved2[2];
  647. UCHAR Flip : 1;
  648. UCHAR Reserved3 : 7;
  649. UCHAR Control;
  650. } POSITION_TO_ELEMENT, *PPOSITION_TO_ELEMENT;
  651. struct _MOVE_MEDIUM {
  652. UCHAR OperationCode; // 0xA5 - SCSIOP_MOVE_MEDIUM
  653. UCHAR Reserved1 : 5;
  654. UCHAR LogicalUnitNumber : 3;
  655. UCHAR TransportElementAddress[2];
  656. UCHAR SourceElementAddress[2];
  657. UCHAR DestinationElementAddress[2];
  658. UCHAR Reserved2[2];
  659. UCHAR Flip : 1;
  660. UCHAR Reserved3 : 7;
  661. UCHAR Control;
  662. } MOVE_MEDIUM, *PMOVE_MEDIUM;
  663. struct _EXCHANGE_MEDIUM {
  664. UCHAR OperationCode; // 0xA6 - SCSIOP_EXCHANGE_MEDIUM
  665. UCHAR Reserved1 : 5;
  666. UCHAR LogicalUnitNumber : 3;
  667. UCHAR TransportElementAddress[2];
  668. UCHAR SourceElementAddress[2];
  669. UCHAR Destination1ElementAddress[2];
  670. UCHAR Destination2ElementAddress[2];
  671. UCHAR Flip1 : 1;
  672. UCHAR Flip2 : 1;
  673. UCHAR Reserved3 : 6;
  674. UCHAR Control;
  675. } EXCHANGE_MEDIUM, *PEXCHANGE_MEDIUM;
  676. struct _READ_ELEMENT_STATUS {
  677. UCHAR OperationCode; // 0xB8 - SCSIOP_READ_ELEMENT_STATUS
  678. UCHAR ElementType : 4;
  679. UCHAR VolTag : 1;
  680. UCHAR LogicalUnitNumber : 3;
  681. UCHAR StartingElementAddress[2];
  682. UCHAR NumberOfElements[2];
  683. UCHAR Reserved1;
  684. UCHAR AllocationLength[3];
  685. UCHAR Reserved2;
  686. UCHAR Control;
  687. } READ_ELEMENT_STATUS, *PREAD_ELEMENT_STATUS;
  688. struct _SEND_VOLUME_TAG {
  689. UCHAR OperationCode; // 0xB6 - SCSIOP_SEND_VOLUME_TAG
  690. UCHAR ElementType : 4;
  691. UCHAR Reserved1 : 1;
  692. UCHAR LogicalUnitNumber : 3;
  693. UCHAR StartingElementAddress[2];
  694. UCHAR Reserved2;
  695. UCHAR ActionCode : 5;
  696. UCHAR Reserved3 : 3;
  697. UCHAR Reserved4[2];
  698. UCHAR ParameterListLength[2];
  699. UCHAR Reserved5;
  700. UCHAR Control;
  701. } SEND_VOLUME_TAG, *PSEND_VOLUME_TAG;
  702. struct _REQUEST_VOLUME_ELEMENT_ADDRESS {
  703. UCHAR OperationCode; // Unknown -- vendor-unique?
  704. UCHAR ElementType : 4;
  705. UCHAR VolTag : 1;
  706. UCHAR LogicalUnitNumber : 3;
  707. UCHAR StartingElementAddress[2];
  708. UCHAR NumberElements[2];
  709. UCHAR Reserved1;
  710. UCHAR AllocationLength[3];
  711. UCHAR Reserved2;
  712. UCHAR Control;
  713. } REQUEST_VOLUME_ELEMENT_ADDRESS, *PREQUEST_VOLUME_ELEMENT_ADDRESS;
  714. //
  715. // Atapi 2.5 Changer 12-byte CDBs
  716. //
  717. struct _LOAD_UNLOAD {
  718. UCHAR OperationCode; // 0xA6 - SCSIOP_LOAD_UNLOAD_SLOT
  719. UCHAR Immediate : 1;
  720. UCHAR Reserved1 : 4;
  721. UCHAR Lun : 3;
  722. UCHAR Reserved2[2];
  723. UCHAR Start : 1;
  724. UCHAR LoadEject : 1;
  725. UCHAR Reserved3: 6;
  726. UCHAR Reserved4[3];
  727. UCHAR Slot;
  728. UCHAR Reserved5[3];
  729. } LOAD_UNLOAD, *PLOAD_UNLOAD;
  730. struct _MECH_STATUS {
  731. UCHAR OperationCode; // 0xBD - SCSIOP_MECHANISM_STATUS
  732. UCHAR Reserved : 5;
  733. UCHAR Lun : 3;
  734. UCHAR Reserved1[6];
  735. UCHAR AllocationLength[2];
  736. UCHAR Reserved2[1];
  737. UCHAR Control;
  738. } MECH_STATUS, *PMECH_STATUS;
  739. //
  740. // C/DVD 0.9 CDBs
  741. //
  742. struct _SYNCHRONIZE_CACHE10 {
  743. UCHAR OperationCode; // 0x35 - SCSIOP_SYNCHRONIZE_CACHE
  744. UCHAR RelAddr : 1;
  745. UCHAR Immediate : 1;
  746. UCHAR Reserved : 3;
  747. UCHAR Lun : 3;
  748. UCHAR LogicalBlockAddress[4]; // Unused - set to zero
  749. UCHAR Reserved2;
  750. UCHAR BlockCount[2]; // Unused - set to zero
  751. UCHAR Control;
  752. } SYNCHRONIZE_CACHE10, *PSYNCHRONIZE_CACHE10;
  753. struct _GET_EVENT_STATUS_NOTIFICATION {
  754. UCHAR OperationCode; // 0x4A - SCSIOP_GET_EVENT_STATUS_NOTIFICATION
  755. UCHAR Immediate : 1;
  756. UCHAR Reserved : 4;
  757. UCHAR Lun : 3;
  758. UCHAR Reserved2[2];
  759. UCHAR NotificationClassRequest;
  760. UCHAR Reserved3[2];
  761. UCHAR EventListLength[2];
  762. UCHAR Control;
  763. } GET_EVENT_STATUS_NOTIFICATION, *PGET_EVENT_STATUS_NOTIFICATION;
  764. struct _READ_DVD_STRUCTURE {
  765. UCHAR OperationCode; // 0xAD - SCSIOP_READ_DVD_STRUCTURE
  766. UCHAR Reserved1 : 5;
  767. UCHAR Lun : 3;
  768. UCHAR RMDBlockNumber[4];
  769. UCHAR LayerNumber;
  770. UCHAR Format;
  771. UCHAR AllocationLength[2];
  772. UCHAR Reserved3 : 6;
  773. UCHAR AGID : 2;
  774. UCHAR Control;
  775. } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
  776. struct _SEND_DVD_STRUCTURE {
  777. UCHAR OperationCode; // 0xBF - SCSIOP_SEND_DVD_STRUCTURE
  778. UCHAR Reserved1 : 5;
  779. UCHAR Lun : 3;
  780. UCHAR Reserved2[5];
  781. UCHAR Format;
  782. UCHAR ParameterListLength[2];
  783. UCHAR Reserved3;
  784. UCHAR Control;
  785. } SEND_DVD_STRUCTURE, *PSEND_DVD_STRUCTURE;
  786. struct _SEND_KEY {
  787. UCHAR OperationCode; // 0xA3 - SCSIOP_SEND_KEY
  788. UCHAR Reserved1 : 5;
  789. UCHAR Lun : 3;
  790. UCHAR Reserved2[6];
  791. UCHAR ParameterListLength[2];
  792. UCHAR KeyFormat : 6;
  793. UCHAR AGID : 2;
  794. UCHAR Control;
  795. } SEND_KEY, *PSEND_KEY;
  796. struct _REPORT_KEY {
  797. UCHAR OperationCode; // 0xA4 - SCSIOP_REPORT_KEY
  798. UCHAR Reserved1 : 5;
  799. UCHAR Lun : 3;
  800. UCHAR LogicalBlockAddress[4]; // for title key
  801. UCHAR Reserved2[2];
  802. UCHAR AllocationLength[2];
  803. UCHAR KeyFormat : 6;
  804. UCHAR AGID : 2;
  805. UCHAR Control;
  806. } REPORT_KEY, *PREPORT_KEY;
  807. struct _SET_READ_AHEAD {
  808. UCHAR OperationCode; // 0xA7 - SCSIOP_SET_READ_AHEAD
  809. UCHAR Reserved1 : 5;
  810. UCHAR Lun : 3;
  811. UCHAR TriggerLBA[4];
  812. UCHAR ReadAheadLBA[4];
  813. UCHAR Reserved2;
  814. UCHAR Control;
  815. } SET_READ_AHEAD, *PSET_READ_AHEAD;
  816. struct _READ_FORMATTED_CAPACITIES {
  817. UCHAR OperationCode; // 0x23 - SCSIOP_READ_FORMATTED_CAPACITY
  818. UCHAR Reserved1 : 5;
  819. UCHAR Lun : 3;
  820. UCHAR Reserved2[5];
  821. UCHAR AllocationLength[2];
  822. UCHAR Control;
  823. } READ_FORMATTED_CAPACITIES, *PREAD_FORMATTED_CAPACITIES;
  824. //
  825. // SCSI-3
  826. //
  827. struct _REPORT_LUNS {
  828. UCHAR OperationCode; // 0xA0 - SCSIOP_REPORT_LUNS
  829. UCHAR Reserved1[5];
  830. UCHAR AllocationLength[4];
  831. UCHAR Reserved2[1];
  832. UCHAR Control;
  833. } REPORT_LUNS, *PREPORT_LUNS;
  834. struct _PERSISTENT_RESERVE_IN {
  835. UCHAR OperationCode; // 0x5E - SCSIOP_PERSISTENT_RESERVE_IN
  836. UCHAR ServiceAction : 5;
  837. UCHAR Reserved1 : 3;
  838. UCHAR Reserved2[5];
  839. UCHAR AllocationLength[2];
  840. UCHAR Control;
  841. } PERSISTENT_RESERVE_IN, *PPERSISTENT_RESERVE_IN;
  842. struct _PERSISTENT_RESERVE_OUT {
  843. UCHAR OperationCode; // 0x5F - SCSIOP_PERSISTENT_RESERVE_OUT
  844. UCHAR ServiceAction : 5;
  845. UCHAR Reserved1 : 3;
  846. UCHAR Type : 4;
  847. UCHAR Scope : 4;
  848. UCHAR Reserved2[4];
  849. UCHAR ParameterListLength[2]; // 0x18
  850. UCHAR Control;
  851. } PERSISTENT_RESERVE_OUT, *PPERSISTENT_RESERVE_OUT;
  852. //
  853. // MMC / SFF-8090 commands
  854. //
  855. struct _GET_CONFIGURATION {
  856. UCHAR OperationCode; // 0x46 - SCSIOP_GET_CONFIGURATION
  857. UCHAR RequestType : 2; // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
  858. UCHAR Reserved1 : 6; // includes obsolete LUN field
  859. UCHAR StartingFeature[2];
  860. UCHAR Reserved2[3];
  861. UCHAR AllocationLength[2];
  862. UCHAR Control;
  863. } GET_CONFIGURATION, *PGET_CONFIGURATION;
  864. struct _SET_CD_SPEED {
  865. UCHAR OperationCode; // 0xB8 - SCSIOP_SET_CD_SPEED
  866. UCHAR Reserved1;
  867. UCHAR ReadSpeed[2]; // 1x == (75 * 2352)
  868. UCHAR WriteSpeed[2]; // 1x == (75 * 2352)
  869. UCHAR Reserved2[5];
  870. UCHAR Control;
  871. } SET_CD_SPEED, *PSET_CD_SPEED;
  872. ULONG AsUlong[4];
  873. UCHAR AsByte[16];
  874. } CDB, *PCDB;
  875. #pragma pack(pop, cdb)
  876. ////////////////////////////////////////////////////////////////////////////////
  877. //
  878. // GET_EVENT_STATUS_NOTIFICATION
  879. //
  880. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_MASK 0x02
  881. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_MASK 0x04
  882. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK 0x08
  883. #define NOTIFICATION_MEDIA_STATUS_CLASS_MASK 0x10
  884. #define NOTIFICATION_MULTI_HOST_CLASS_MASK 0x20
  885. #define NOTIFICATION_DEVICE_BUSY_CLASS_MASK 0x40
  886. #define NOTIFICATION_NO_CLASS_EVENTS 0x0
  887. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_EVENTS 0x1
  888. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_EVENTS 0x2
  889. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS 0x3
  890. #define NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS 0x4
  891. #define NOTIFICATION_MULTI_HOST_CLASS_EVENTS 0x5
  892. #define NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS 0x6
  893. #pragma pack(push, not_header, 1)
  894. typedef struct _NOTIFICATION_EVENT_STATUS_HEADER {
  895. UCHAR EventDataLength[2];
  896. UCHAR NotificationClass : 3;
  897. UCHAR Reserved : 4;
  898. UCHAR NEA : 1;
  899. UCHAR SupportedEventClasses;
  900. UCHAR ClassEventData[0];
  901. } NOTIFICATION_EVENT_STATUS_HEADER, *PNOTIFICATION_EVENT_STATUS_HEADER;
  902. #pragma pack(pop, not_header)
  903. #define NOTIFICATION_OPERATIONAL_EVENT_NO_CHANGE 0x0
  904. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_REQUESTED 0x1
  905. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_OCCURRED 0x2
  906. #define NOTIFICATION_OPERATIONAL_STATUS_AVAILABLE 0x0
  907. #define NOTIFICATION_OPERATIONAL_STATUS_TEMPORARY_BUSY 0x1
  908. #define NOTIFICATION_OPERATIONAL_STATUS_EXTENDED_BUSY 0x2
  909. #define NOTIFICATION_OPERATIONAL_OPCODE_NONE 0x0
  910. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_CHANGE 0x1
  911. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_ADDED 0x2
  912. #define NOTIFICATION_OPERATIONAL_OPCODE_UNIT_RESET 0x3
  913. #define NOTIFICATION_OPERATIONAL_OPCODE_FIRMWARE_CHANGED 0x4
  914. #define NOTIFICATION_OPERATIONAL_OPCODE_INQUIRY_CHANGED 0x5
  915. //
  916. // Class event data may be one (or none) of the following:
  917. //
  918. #pragma pack(push, not_op, 1)
  919. typedef struct _NOTIFICATION_OPERATIONAL_STATUS { // event class == 0x1
  920. UCHAR OperationalEvent : 4;
  921. UCHAR Reserved1 : 4;
  922. UCHAR OperationalStatus : 4;
  923. UCHAR Reserved2 : 3;
  924. UCHAR PersistentPrevented : 1;
  925. UCHAR Operation[2];
  926. } NOTIFICATION_OPERATIONAL_STATUS, *PNOTIFICATION_OPERATIONAL_STATUS;
  927. #pragma pack(pop, not_op)
  928. #define NOTIFICATION_POWER_EVENT_NO_CHANGE 0x0
  929. #define NOTIFICATION_POWER_EVENT_CHANGE_SUCCEEDED 0x1
  930. #define NOTIFICATION_POWER_EVENT_CHANGE_FAILED 0x2
  931. #define NOTIFICATION_POWER_STATUS_ACTIVE 0x1
  932. #define NOTIFICATION_POWER_STATUS_IDLE 0x2
  933. #define NOTIFICATION_POWER_STATUS_STANDBY 0x3
  934. #define NOTIFICATION_POWER_STATUS_SLEEP 0x4
  935. #pragma pack(push, not_power, 1)
  936. typedef struct _NOTIFICATION_POWER_STATUS { // event class == 0x2
  937. UCHAR PowerEvent : 4;
  938. UCHAR Reserved : 4;
  939. UCHAR PowerStatus;
  940. UCHAR Reserved2[2];
  941. } NOTIFICATION_POWER_STATUS, *PNOTIFICATION_POWER_STATUS;
  942. #pragma pack(pop, not_power)
  943. #define NOTIFICATION_EXTERNAL_EVENT_NO_CHANGE 0x0
  944. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN 0x1
  945. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_UP 0x2
  946. #define NOTIFICATION_EXTERNAL_EVENT_EXTERNAL 0x3 // respond with GET_CONFIGURATION?
  947. #define NOTIFICATION_EXTERNAL_STATUS_READY 0x0
  948. #define NOTIFICATION_EXTERNAL_STATUS_PREVENT 0x1
  949. #define NOTIFICATION_EXTERNAL_REQUEST_NONE 0x0000
  950. #define NOTIFICATION_EXTERNAL_REQUEST_QUEUE_OVERRUN 0x0001
  951. #define NOTIFICATION_EXTERNAL_REQUEST_PLAY 0x0101
  952. #define NOTIFICATION_EXTERNAL_REQUEST_REWIND_BACK 0x0102
  953. #define NOTIFICATION_EXTERNAL_REQUEST_FAST_FORWARD 0x0103
  954. #define NOTIFICATION_EXTERNAL_REQUEST_PAUSE 0x0104
  955. #define NOTIFICATION_EXTERNAL_REQUEST_STOP 0x0106
  956. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_LOW 0x0200
  957. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_HIGH 0x02ff
  958. #pragma pack(push, not_extern, 1)
  959. typedef struct _NOTIFICATION_EXTERNAL_STATUS { // event class == 0x3
  960. UCHAR ExternalEvent : 4;
  961. UCHAR Reserved1 : 4;
  962. UCHAR ExternalStatus : 4;
  963. UCHAR Reserved2 : 3;
  964. UCHAR PersistentPrevented : 1;
  965. UCHAR Request[2];
  966. } NOTIFICATION_EXTERNAL_STATUS, *PNOTIFICATION_EXTERNAL_STATUS;
  967. #pragma pack(pop, not_extern)
  968. #define NOTIFICATION_MEDIA_EVENT_NO_CHANGE 0x0
  969. #define NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST 0x1
  970. #define NOTIFICATION_MEDIA_EVENT_NEW_MEDIA 0x2
  971. #define NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL 0x3
  972. #define NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE 0x4
  973. #pragma pack(push, not_media, 1)
  974. typedef struct _NOTIFICATION_MEDIA_STATUS { // event class == 0x4
  975. UCHAR MediaEvent : 4;
  976. UCHAR Reserved : 4;
  977. union {
  978. UCHAR PowerStatus; // OBSOLETE -- was improperly named in NT5 headers
  979. UCHAR MediaStatus; // Use this for currently reserved fields
  980. struct {
  981. UCHAR DoorTrayOpen : 1;
  982. UCHAR MediaPresent : 1;
  983. UCHAR ReservedX : 6; // do not reference this directly!
  984. };
  985. };
  986. UCHAR StartSlot;
  987. UCHAR EndSlot;
  988. } NOTIFICATION_MEDIA_STATUS, *PNOTIFICATION_MEDIA_STATUS;
  989. #pragma pack(pop, not_media)
  990. #define NOTIFICATION_MULTI_HOST_EVENT_NO_CHANGE 0x0
  991. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_REQUEST 0x1
  992. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_GRANT 0x2
  993. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_RELEASE 0x3
  994. #define NOTIFICATION_MULTI_HOST_STATUS_READY 0x0
  995. #define NOTIFICATION_MULTI_HOST_STATUS_PREVENT 0x1
  996. #define NOTIFICATION_MULTI_HOST_PRIORITY_NO_REQUESTS 0x0
  997. #define NOTIFICATION_MULTI_HOST_PRIORITY_LOW 0x1
  998. #define NOTIFICATION_MULTI_HOST_PRIORITY_MEDIUM 0x2
  999. #define NOTIFICATION_MULTI_HOST_PRIORITY_HIGH 0x3
  1000. #pragma pack(push, not_multi, 1)
  1001. typedef struct _NOTIFICATION_MULTI_HOST_STATUS { // event class == 0x5
  1002. UCHAR MultiHostEvent : 4;
  1003. UCHAR Reserved1 : 4;
  1004. UCHAR MultiHostStatus : 4;
  1005. UCHAR Reserved2 : 3;
  1006. UCHAR PersistentPrevented : 1;
  1007. UCHAR Priority[2];
  1008. } NOTIFICATION_MULTI_HOST_STATUS, *PNOTIFICATION_MULTI_HOST_STATUS;
  1009. #pragma pack(pop, not_multi)
  1010. #define NOTIFICATION_BUSY_EVENT_NO_CHANGE 0x0
  1011. #define NOTIFICATION_BUSY_EVENT_BUSY 0x1
  1012. #define NOTIFICATION_BUSY_STATUS_NO_EVENT 0x0
  1013. #define NOTIFICATION_BUSY_STATUS_POWER 0x1
  1014. #define NOTIFICATION_BUSY_STATUS_IMMEDIATE 0x2
  1015. #define NOTIFICATION_BUSY_STATUS_DEFERRED 0x3
  1016. #pragma pack(push, not_busy, 1)
  1017. typedef struct _NOTIFICATION_BUSY_STATUS { // event class == 0x6
  1018. UCHAR DeviceBusyEvent : 4;
  1019. UCHAR Reserved : 4;
  1020. UCHAR DeviceBusyStatus;
  1021. UCHAR Time[2];
  1022. } NOTIFICATION_BUSY_STATUS, *PNOTIFICATION_BUSY_STATUS;
  1023. #pragma pack(pop, not_busy)
  1024. ////////////////////////////////////////////////////////////////////////////////
  1025. //
  1026. // Read DVD Structure Definitions and Constants
  1027. //
  1028. #define DVD_FORMAT_LEAD_IN 0x00
  1029. #define DVD_FORMAT_COPYRIGHT 0x01
  1030. #define DVD_FORMAT_DISK_KEY 0x02
  1031. #define DVD_FORMAT_BCA 0x03
  1032. #define DVD_FORMAT_MANUFACTURING 0x04
  1033. #pragma pack(push, dvd_struct_header, 1)
  1034. typedef struct _READ_DVD_STRUCTURES_HEADER {
  1035. UCHAR Length[2];
  1036. UCHAR Reserved[2];
  1037. UCHAR Data[0];
  1038. } READ_DVD_STRUCTURES_HEADER, *PREAD_DVD_STRUCTURES_HEADER;
  1039. #pragma pack(pop, dvd_struct_header)
  1040. //
  1041. // DiskKey, BCA & Manufacturer information will provide byte arrays as their
  1042. // data.
  1043. //
  1044. //
  1045. // CDVD 0.9 Send & Report Key Definitions and Structures
  1046. //
  1047. #define DVD_REPORT_AGID 0x00
  1048. #define DVD_CHALLENGE_KEY 0x01
  1049. #define DVD_KEY_1 0x02
  1050. #define DVD_KEY_2 0x03
  1051. #define DVD_TITLE_KEY 0x04
  1052. #define DVD_REPORT_ASF 0x05
  1053. #define DVD_INVALIDATE_AGID 0x3F
  1054. #pragma pack(push, dvdstuff, 1)
  1055. typedef struct _CDVD_KEY_HEADER {
  1056. UCHAR DataLength[2];
  1057. UCHAR Reserved[2];
  1058. UCHAR Data[0];
  1059. } CDVD_KEY_HEADER, *PCDVD_KEY_HEADER;
  1060. typedef struct _CDVD_REPORT_AGID_DATA {
  1061. UCHAR Reserved1[3];
  1062. UCHAR Reserved2 : 6;
  1063. UCHAR AGID : 2;
  1064. } CDVD_REPORT_AGID_DATA, *PCDVD_REPORT_AGID_DATA;
  1065. typedef struct _CDVD_CHALLENGE_KEY_DATA {
  1066. UCHAR ChallengeKeyValue[10];
  1067. UCHAR Reserved[2];
  1068. } CDVD_CHALLENGE_KEY_DATA, *PCDVD_CHALLENGE_KEY_DATA;
  1069. typedef struct _CDVD_KEY_DATA {
  1070. UCHAR Key[5];
  1071. UCHAR Reserved[3];
  1072. } CDVD_KEY_DATA, *PCDVD_KEY_DATA;
  1073. typedef struct _CDVD_REPORT_ASF_DATA {
  1074. UCHAR Reserved1[3];
  1075. UCHAR Success : 1;
  1076. UCHAR Reserved2 : 7;
  1077. } CDVD_REPORT_ASF_DATA, *PCDVD_REPORT_ASF_DATA;
  1078. typedef struct _CDVD_TITLE_KEY_HEADER {
  1079. UCHAR DataLength[2];
  1080. UCHAR Reserved1[1];
  1081. UCHAR Reserved2 : 3;
  1082. UCHAR CGMS : 2;
  1083. UCHAR CP_SEC : 1;
  1084. UCHAR CPM : 1;
  1085. UCHAR Zero : 1;
  1086. CDVD_KEY_DATA TitleKey;
  1087. } CDVD_TITLE_KEY_HEADER, *PCDVD_TITLE_KEY_HEADER;
  1088. #pragma pack(pop, dvdstuff)
  1089. //
  1090. // Read Formatted Capacity Data - returned in Big Endian Format
  1091. //
  1092. #pragma pack(push, formatted_capacity, 1)
  1093. typedef struct _FORMATTED_CAPACITY_DESCRIPTOR {
  1094. UCHAR NumberOfBlocks[4];
  1095. UCHAR Maximum : 1;
  1096. UCHAR Valid : 1;
  1097. UCHAR BlockLength[3];
  1098. } FORMATTED_CAPACITY_DESCRIPTOR, *PFORMATTED_CAPACITY_DESCRIPTOR;
  1099. typedef struct _FORMATTED_CAPACITY_LIST {
  1100. UCHAR Reserved[3];
  1101. UCHAR CapacityListLength;
  1102. FORMATTED_CAPACITY_DESCRIPTOR Descriptors[0];
  1103. } FORMATTED_CAPACITY_LIST, *PFORMATTED_CAPACITY_LIST;
  1104. #pragma pack(pop, formatted_capacity)
  1105. //
  1106. // PLAY_CD definitions and constants
  1107. //
  1108. #define CD_EXPECTED_SECTOR_ANY 0x0
  1109. #define CD_EXPECTED_SECTOR_CDDA 0x1
  1110. #define CD_EXPECTED_SECTOR_MODE1 0x2
  1111. #define CD_EXPECTED_SECTOR_MODE2 0x3
  1112. #define CD_EXPECTED_SECTOR_MODE2_FORM1 0x4
  1113. #define CD_EXPECTED_SECTOR_MODE2_FORM2 0x5
  1114. //
  1115. // Read Disk Information Definitions and Capabilities
  1116. //
  1117. #define DISK_STATUS_EMPTY 0x00
  1118. #define DISK_STATUS_INCOMPLETE 0x01
  1119. #define DISK_STATUS_COMPLETE 0x02
  1120. #define LAST_SESSION_EMPTY 0x00
  1121. #define LAST_SESSION_INCOMPLETE 0x01
  1122. #define LAST_SESSION_COMPLETE 0x03
  1123. #define DISK_TYPE_CDDA 0x01
  1124. #define DISK_TYPE_CDI 0x10
  1125. #define DISK_TYPE_XA 0x20
  1126. #define DISK_TYPE_UNDEFINED 0xFF
  1127. #pragma pack(push, discinfo, 1)
  1128. typedef struct _OPC_TABLE_ENTRY {
  1129. UCHAR Speed[2];
  1130. UCHAR OPCValue[6];
  1131. } OPC_TABLE_ENTRY, *POPC_TABLE_ENTRY;
  1132. typedef struct _DISC_INFORMATION {
  1133. UCHAR Length[2];
  1134. UCHAR DiscStatus : 2;
  1135. UCHAR LastSessionStatus : 2;
  1136. UCHAR Erasable : 1;
  1137. UCHAR Reserved1 : 3;
  1138. UCHAR FirstTrackNumber;
  1139. UCHAR NumberOfSessionsLsb;
  1140. UCHAR LastSessionFirstTrackLsb;
  1141. UCHAR LastSessionLastTrackLsb;
  1142. UCHAR MrwStatus : 2;
  1143. UCHAR MrwDirtyBit : 1;
  1144. UCHAR Reserved2 : 2;
  1145. UCHAR URU : 1;
  1146. UCHAR DBC_V : 1;
  1147. UCHAR DID_V : 1;
  1148. UCHAR DiscType;
  1149. UCHAR NumberOfSessionsMsb;
  1150. UCHAR LastSessionFirstTrackMsb;
  1151. UCHAR LastSessionLastTrackMsb;
  1152. UCHAR DiskIdentification[4];
  1153. UCHAR LastSessionLeadIn[4]; // HMSF
  1154. UCHAR LastPossibleLeadOutStartTime[4]; // HMSF
  1155. UCHAR DiskBarCode[8];
  1156. UCHAR Reserved4;
  1157. UCHAR NumberOPCEntries;
  1158. OPC_TABLE_ENTRY OPCTable[ 1 ]; // can be many of these here....
  1159. } DISC_INFORMATION, *PDISC_INFORMATION;
  1160. // TODO: Deprecate DISK_INFORMATION
  1161. //#if PRAGMA_DEPRECATED_DDK
  1162. //#pragma deprecated(_DISK_INFORMATION) // Use DISC_INFORMATION, note size change
  1163. //#pragma deprecated( DISK_INFORMATION) // Use DISC_INFORMATION, note size change
  1164. //#pragma deprecated(PDISK_INFORMATION) // Use DISC_INFORMATION, note size change
  1165. //#endif
  1166. typedef struct _DISK_INFORMATION {
  1167. UCHAR Length[2];
  1168. UCHAR DiskStatus : 2;
  1169. UCHAR LastSessionStatus : 2;
  1170. UCHAR Erasable : 1;
  1171. UCHAR Reserved1 : 3;
  1172. UCHAR FirstTrackNumber;
  1173. UCHAR NumberOfSessions;
  1174. UCHAR LastSessionFirstTrack;
  1175. UCHAR LastSessionLastTrack;
  1176. UCHAR Reserved2 : 5;
  1177. UCHAR GEN : 1;
  1178. UCHAR DBC_V : 1;
  1179. UCHAR DID_V : 1;
  1180. UCHAR DiskType;
  1181. UCHAR Reserved3[3];
  1182. UCHAR DiskIdentification[4];
  1183. UCHAR LastSessionLeadIn[4]; // MSF
  1184. UCHAR LastPossibleStartTime[4]; // MSF
  1185. UCHAR DiskBarCode[8];
  1186. UCHAR Reserved4;
  1187. UCHAR NumberOPCEntries;
  1188. OPC_TABLE_ENTRY OPCTable[0];
  1189. } DISK_INFORMATION, *PDISK_INFORMATION;
  1190. #pragma pack(pop, discinfo)
  1191. //
  1192. // Read Header definitions and structures
  1193. //
  1194. #pragma pack(push, cdheader, 1)
  1195. typedef struct _DATA_BLOCK_HEADER {
  1196. UCHAR DataMode;
  1197. UCHAR Reserved[4];
  1198. union {
  1199. UCHAR LogicalBlockAddress[4];
  1200. struct {
  1201. UCHAR Reserved;
  1202. UCHAR M;
  1203. UCHAR S;
  1204. UCHAR F;
  1205. } MSF;
  1206. };
  1207. } DATA_BLOCK_HEADER, *PDATA_BLOCK_HEADER;
  1208. #pragma pack(pop, cdheader)
  1209. #define DATA_BLOCK_MODE0 0x0
  1210. #define DATA_BLOCK_MODE1 0x1
  1211. #define DATA_BLOCK_MODE2 0x2
  1212. //
  1213. // Read TOC Format Codes
  1214. //
  1215. #define READ_TOC_FORMAT_TOC 0x00
  1216. #define READ_TOC_FORMAT_SESSION 0x01
  1217. #define READ_TOC_FORMAT_FULL_TOC 0x02
  1218. #define READ_TOC_FORMAT_PMA 0x03
  1219. #define READ_TOC_FORMAT_ATIP 0x04
  1220. // TODO: Deprecate TRACK_INFORMATION structure, use TRACK_INFORMATION2 instead
  1221. #pragma pack(push, track_info, 1)
  1222. typedef struct _TRACK_INFORMATION {
  1223. UCHAR Length[2];
  1224. UCHAR TrackNumber;
  1225. UCHAR SessionNumber;
  1226. UCHAR Reserved1;
  1227. UCHAR TrackMode : 4;
  1228. UCHAR Copy : 1;
  1229. UCHAR Damage : 1;
  1230. UCHAR Reserved2 : 2;
  1231. UCHAR DataMode : 4;
  1232. UCHAR FP : 1;
  1233. UCHAR Packet : 1;
  1234. UCHAR Blank : 1;
  1235. UCHAR RT : 1;
  1236. UCHAR NWA_V : 1;
  1237. UCHAR Reserved3 : 7;
  1238. UCHAR TrackStartAddress[4];
  1239. UCHAR NextWritableAddress[4];
  1240. UCHAR FreeBlocks[4];
  1241. UCHAR FixedPacketSize[4];
  1242. } TRACK_INFORMATION, *PTRACK_INFORMATION;
  1243. typedef struct _TRACK_INFORMATION2 {
  1244. UCHAR Length[2];
  1245. UCHAR TrackNumberLsb;
  1246. UCHAR SessionNumberLsb;
  1247. UCHAR Reserved4;
  1248. UCHAR TrackMode : 4;
  1249. UCHAR Copy : 1;
  1250. UCHAR Damage : 1;
  1251. UCHAR Reserved5 : 2;
  1252. UCHAR DataMode : 4;
  1253. UCHAR FixedPacket : 1;
  1254. UCHAR Packet : 1;
  1255. UCHAR Blank : 1;
  1256. UCHAR ReservedTrack : 1;
  1257. UCHAR NWA_V : 1;
  1258. UCHAR LRA_V : 1;
  1259. UCHAR Reserved6 : 6;
  1260. UCHAR TrackStartAddress[4];
  1261. UCHAR NextWritableAddress[4];
  1262. UCHAR FreeBlocks[4];
  1263. UCHAR FixedPacketSize[4]; // blocking factor
  1264. UCHAR TrackSize[4];
  1265. UCHAR LastRecordedAddress[4];
  1266. UCHAR TrackNumberMsb;
  1267. UCHAR SessionNumberMsb;
  1268. UCHAR Reserved7[2];
  1269. } TRACK_INFORMATION2, *PTRACK_INFORMATION2;
  1270. #pragma pack(pop, track_info)
  1271. //
  1272. // Command Descriptor Block constants.
  1273. //
  1274. #define CDB6GENERIC_LENGTH 6
  1275. #define CDB10GENERIC_LENGTH 10
  1276. #define CDB12GENERIC_LENGTH 12
  1277. #define SETBITON 1
  1278. #define SETBITOFF 0
  1279. //
  1280. // Mode Sense/Select page constants.
  1281. //
  1282. #define MODE_PAGE_ERROR_RECOVERY 0x01
  1283. #define MODE_PAGE_DISCONNECT 0x02
  1284. #define MODE_PAGE_FORMAT_DEVICE 0x03 // disk
  1285. #define MODE_PAGE_MRW 0x03 // cdrom
  1286. #define MODE_PAGE_RIGID_GEOMETRY 0x04
  1287. #define MODE_PAGE_FLEXIBILE 0x05 // disk
  1288. #define MODE_PAGE_WRITE_PARAMETERS 0x05 // cdrom
  1289. #define MODE_PAGE_VERIFY_ERROR 0x07
  1290. #define MODE_PAGE_CACHING 0x08
  1291. #define MODE_PAGE_PERIPHERAL 0x09
  1292. #define MODE_PAGE_CONTROL 0x0A
  1293. #define MODE_PAGE_MEDIUM_TYPES 0x0B
  1294. #define MODE_PAGE_NOTCH_PARTITION 0x0C
  1295. #define MODE_PAGE_CD_AUDIO_CONTROL 0x0E
  1296. #define MODE_PAGE_DATA_COMPRESS 0x0F
  1297. #define MODE_PAGE_DEVICE_CONFIG 0x10
  1298. #define MODE_PAGE_MEDIUM_PARTITION 0x11
  1299. #define MODE_PAGE_CDVD_FEATURE_SET 0x18
  1300. #define MODE_PAGE_POWER_CONDITION 0x1A
  1301. #define MODE_PAGE_FAULT_REPORTING 0x1C
  1302. #define MODE_PAGE_CDVD_INACTIVITY 0x1D // cdrom
  1303. #define MODE_PAGE_ELEMENT_ADDRESS 0x1D
  1304. #define MODE_PAGE_TRANSPORT_GEOMETRY 0x1E
  1305. #define MODE_PAGE_DEVICE_CAPABILITIES 0x1F
  1306. #define MODE_PAGE_CAPABILITIES 0x2A // cdrom
  1307. #define MODE_SENSE_RETURN_ALL 0x3f
  1308. #define MODE_SENSE_CURRENT_VALUES 0x00
  1309. #define MODE_SENSE_CHANGEABLE_VALUES 0x40
  1310. #define MODE_SENSE_DEFAULT_VAULES 0x80
  1311. #define MODE_SENSE_SAVED_VALUES 0xc0
  1312. //
  1313. // SCSI CDB operation codes
  1314. //
  1315. // 6-byte commands:
  1316. #define SCSIOP_TEST_UNIT_READY 0x00
  1317. #define SCSIOP_REZERO_UNIT 0x01
  1318. #define SCSIOP_REWIND 0x01
  1319. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  1320. #define SCSIOP_REQUEST_SENSE 0x03
  1321. #define SCSIOP_FORMAT_UNIT 0x04
  1322. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  1323. #define SCSIOP_REASSIGN_BLOCKS 0x07
  1324. #define SCSIOP_INIT_ELEMENT_STATUS 0x07
  1325. #define SCSIOP_READ6 0x08
  1326. #define SCSIOP_RECEIVE 0x08
  1327. #define SCSIOP_WRITE6 0x0A
  1328. #define SCSIOP_PRINT 0x0A
  1329. #define SCSIOP_SEND 0x0A
  1330. #define SCSIOP_SEEK6 0x0B
  1331. #define SCSIOP_TRACK_SELECT 0x0B
  1332. #define SCSIOP_SLEW_PRINT 0x0B
  1333. #define SCSIOP_SEEK_BLOCK 0x0C
  1334. #define SCSIOP_PARTITION 0x0D
  1335. #define SCSIOP_READ_REVERSE 0x0F
  1336. #define SCSIOP_WRITE_FILEMARKS 0x10
  1337. #define SCSIOP_FLUSH_BUFFER 0x10
  1338. #define SCSIOP_SPACE 0x11
  1339. #define SCSIOP_INQUIRY 0x12
  1340. #define SCSIOP_VERIFY6 0x13
  1341. #define SCSIOP_RECOVER_BUF_DATA 0x14
  1342. #define SCSIOP_MODE_SELECT 0x15
  1343. #define SCSIOP_RESERVE_UNIT 0x16
  1344. #define SCSIOP_RELEASE_UNIT 0x17
  1345. #define SCSIOP_COPY 0x18
  1346. #define SCSIOP_ERASE 0x19
  1347. #define SCSIOP_MODE_SENSE 0x1A
  1348. #define SCSIOP_START_STOP_UNIT 0x1B
  1349. #define SCSIOP_STOP_PRINT 0x1B
  1350. #define SCSIOP_LOAD_UNLOAD 0x1B
  1351. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  1352. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  1353. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  1354. // 10-byte commands
  1355. #define SCSIOP_READ_FORMATTED_CAPACITY 0x23
  1356. #define SCSIOP_READ_CAPACITY 0x25
  1357. #define SCSIOP_READ 0x28
  1358. #define SCSIOP_WRITE 0x2A
  1359. #define SCSIOP_SEEK 0x2B
  1360. #define SCSIOP_LOCATE 0x2B
  1361. #define SCSIOP_POSITION_TO_ELEMENT 0x2B
  1362. #define SCSIOP_WRITE_VERIFY 0x2E
  1363. #define SCSIOP_VERIFY 0x2F
  1364. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  1365. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  1366. #define SCSIOP_SEARCH_DATA_LOW 0x32
  1367. #define SCSIOP_SET_LIMITS 0x33
  1368. #define SCSIOP_READ_POSITION 0x34
  1369. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  1370. #define SCSIOP_COMPARE 0x39
  1371. #define SCSIOP_COPY_COMPARE 0x3A
  1372. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  1373. #define SCSIOP_READ_DATA_BUFF 0x3C
  1374. #define SCSIOP_CHANGE_DEFINITION 0x40
  1375. #define SCSIOP_READ_SUB_CHANNEL 0x42
  1376. #define SCSIOP_READ_TOC 0x43
  1377. #define SCSIOP_READ_HEADER 0x44
  1378. #define SCSIOP_PLAY_AUDIO 0x45
  1379. #define SCSIOP_GET_CONFIGURATION 0x46
  1380. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  1381. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  1382. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  1383. #define SCSIOP_GET_EVENT_STATUS 0x4A
  1384. #define SCSIOP_PAUSE_RESUME 0x4B
  1385. #define SCSIOP_LOG_SELECT 0x4C
  1386. #define SCSIOP_LOG_SENSE 0x4D
  1387. #define SCSIOP_STOP_PLAY_SCAN 0x4E
  1388. #define SCSIOP_READ_DISK_INFORMATION 0x51
  1389. #define SCSIOP_READ_DISC_INFORMATION 0x51 // proper use of disc over disk
  1390. #define SCSIOP_READ_TRACK_INFORMATION 0x52
  1391. #define SCSIOP_RESERVE_TRACK_RZONE 0x53
  1392. #define SCSIOP_SEND_OPC_INFORMATION 0x54 // optimum power calibration
  1393. #define SCSIOP_MODE_SELECT10 0x55
  1394. #define SCSIOP_RESERVE_UNIT10 0x56
  1395. #define SCSIOP_RELEASE_UNIT10 0x57
  1396. #define SCSIOP_MODE_SENSE10 0x5A
  1397. #define SCSIOP_CLOSE_TRACK_SESSION 0x5B
  1398. #define SCSIOP_READ_BUFFER_CAPACITY 0x5C
  1399. #define SCSIOP_SEND_CUE_SHEET 0x5D
  1400. #define SCSIOP_PERSISTENT_RESERVE_IN 0x5E
  1401. #define SCSIOP_PERSISTENT_RESERVE_OUT 0x5F
  1402. // 12-byte commands
  1403. #define SCSIOP_REPORT_LUNS 0xA0
  1404. #define SCSIOP_BLANK 0xA1
  1405. #define SCSIOP_SEND_EVENT 0xA2
  1406. #define SCSIOP_SEND_KEY 0xA3
  1407. #define SCSIOP_REPORT_KEY 0xA4
  1408. #define SCSIOP_MOVE_MEDIUM 0xA5
  1409. #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
  1410. #define SCSIOP_EXCHANGE_MEDIUM 0xA6
  1411. #define SCSIOP_SET_READ_AHEAD 0xA7
  1412. #define SCSIOP_READ_DVD_STRUCTURE 0xAD
  1413. #define SCSIOP_REQUEST_VOL_ELEMENT 0xB5
  1414. #define SCSIOP_SEND_VOLUME_TAG 0xB6
  1415. #define SCSIOP_READ_ELEMENT_STATUS 0xB8
  1416. #define SCSIOP_READ_CD_MSF 0xB9
  1417. #define SCSIOP_SCAN_CD 0xBA
  1418. #define SCSIOP_SET_CD_SPEED 0xBB
  1419. #define SCSIOP_PLAY_CD 0xBC
  1420. #define SCSIOP_MECHANISM_STATUS 0xBD
  1421. #define SCSIOP_READ_CD 0xBE
  1422. #define SCSIOP_SEND_DVD_STRUCTURE 0xBF
  1423. #define SCSIOP_INIT_ELEMENT_RANGE 0xE7
  1424. //
  1425. // If the IMMED bit is 1, status is returned as soon
  1426. // as the operation is initiated. If the IMMED bit
  1427. // is 0, status is not returned until the operation
  1428. // is completed.
  1429. //
  1430. #define CDB_RETURN_ON_COMPLETION 0
  1431. #define CDB_RETURN_IMMEDIATE 1
  1432. // end_ntminitape
  1433. //
  1434. // CDB Force media access used in extended read and write commands.
  1435. //
  1436. #define CDB_FORCE_MEDIA_ACCESS 0x08
  1437. //
  1438. // Denon CD ROM operation codes
  1439. //
  1440. #define SCSIOP_DENON_EJECT_DISC 0xE6
  1441. #define SCSIOP_DENON_STOP_AUDIO 0xE7
  1442. #define SCSIOP_DENON_PLAY_AUDIO 0xE8
  1443. #define SCSIOP_DENON_READ_TOC 0xE9
  1444. #define SCSIOP_DENON_READ_SUBCODE 0xEB
  1445. //
  1446. // SCSI Bus Messages
  1447. //
  1448. #define SCSIMESS_ABORT 0x06
  1449. #define SCSIMESS_ABORT_WITH_TAG 0x0D
  1450. #define SCSIMESS_BUS_DEVICE_RESET 0X0C
  1451. #define SCSIMESS_CLEAR_QUEUE 0X0E
  1452. #define SCSIMESS_COMMAND_COMPLETE 0X00
  1453. #define SCSIMESS_DISCONNECT 0X04
  1454. #define SCSIMESS_EXTENDED_MESSAGE 0X01
  1455. #define SCSIMESS_IDENTIFY 0X80
  1456. #define SCSIMESS_IDENTIFY_WITH_DISCON 0XC0
  1457. #define SCSIMESS_IGNORE_WIDE_RESIDUE 0X23
  1458. #define SCSIMESS_INITIATE_RECOVERY 0X0F
  1459. #define SCSIMESS_INIT_DETECTED_ERROR 0X05
  1460. #define SCSIMESS_LINK_CMD_COMP 0X0A
  1461. #define SCSIMESS_LINK_CMD_COMP_W_FLAG 0X0B
  1462. #define SCSIMESS_MESS_PARITY_ERROR 0X09
  1463. #define SCSIMESS_MESSAGE_REJECT 0X07
  1464. #define SCSIMESS_NO_OPERATION 0X08
  1465. #define SCSIMESS_HEAD_OF_QUEUE_TAG 0X21
  1466. #define SCSIMESS_ORDERED_QUEUE_TAG 0X22
  1467. #define SCSIMESS_SIMPLE_QUEUE_TAG 0X20
  1468. #define SCSIMESS_RELEASE_RECOVERY 0X10
  1469. #define SCSIMESS_RESTORE_POINTERS 0X03
  1470. #define SCSIMESS_SAVE_DATA_POINTER 0X02
  1471. #define SCSIMESS_TERMINATE_IO_PROCESS 0X11
  1472. //
  1473. // SCSI Extended Message operation codes
  1474. //
  1475. #define SCSIMESS_MODIFY_DATA_POINTER 0X00
  1476. #define SCSIMESS_SYNCHRONOUS_DATA_REQ 0X01
  1477. #define SCSIMESS_WIDE_DATA_REQUEST 0X03
  1478. //
  1479. // SCSI Extended Message Lengths
  1480. //
  1481. #define SCSIMESS_MODIFY_DATA_LENGTH 5
  1482. #define SCSIMESS_SYNCH_DATA_LENGTH 3
  1483. #define SCSIMESS_WIDE_DATA_LENGTH 2
  1484. //
  1485. // SCSI extended message structure
  1486. //
  1487. #pragma pack(push, scsi_mess, 1)
  1488. typedef struct _SCSI_EXTENDED_MESSAGE {
  1489. UCHAR InitialMessageCode;
  1490. UCHAR MessageLength;
  1491. UCHAR MessageType;
  1492. union _EXTENDED_ARGUMENTS {
  1493. struct {
  1494. UCHAR Modifier[4];
  1495. } Modify;
  1496. struct {
  1497. UCHAR TransferPeriod;
  1498. UCHAR ReqAckOffset;
  1499. } Synchronous;
  1500. struct{
  1501. UCHAR Width;
  1502. } Wide;
  1503. }ExtendedArguments;
  1504. }SCSI_EXTENDED_MESSAGE, *PSCSI_EXTENDED_MESSAGE;
  1505. #pragma pack(pop, scsi_mess)
  1506. //
  1507. // SCSI bus status codes.
  1508. //
  1509. #define SCSISTAT_GOOD 0x00
  1510. #define SCSISTAT_CHECK_CONDITION 0x02
  1511. #define SCSISTAT_CONDITION_MET 0x04
  1512. #define SCSISTAT_BUSY 0x08
  1513. #define SCSISTAT_INTERMEDIATE 0x10
  1514. #define SCSISTAT_INTERMEDIATE_COND_MET 0x14
  1515. #define SCSISTAT_RESERVATION_CONFLICT 0x18
  1516. #define SCSISTAT_COMMAND_TERMINATED 0x22
  1517. #define SCSISTAT_QUEUE_FULL 0x28
  1518. //
  1519. // Enable Vital Product Data Flag (EVPD)
  1520. // used with INQUIRY command.
  1521. //
  1522. #define CDB_INQUIRY_EVPD 0x01
  1523. //
  1524. // Defines for format CDB
  1525. //
  1526. #define LUN0_FORMAT_SAVING_DEFECT_LIST 0
  1527. #define USE_DEFAULTMSB 0
  1528. #define USE_DEFAULTLSB 0
  1529. #define START_UNIT_CODE 0x01
  1530. #define STOP_UNIT_CODE 0x00
  1531. // begin_ntminitape
  1532. //
  1533. // Inquiry buffer structure. This is the data returned from the target
  1534. // after it receives an inquiry.
  1535. //
  1536. // This structure may be extended by the number of bytes specified
  1537. // in the field AdditionalLength. The defined size constant only
  1538. // includes fields through ProductRevisionLevel.
  1539. //
  1540. // The NT SCSI drivers are only interested in the first 36 bytes of data.
  1541. //
  1542. #define INQUIRYDATABUFFERSIZE 36
  1543. #pragma pack(push, inquiry, 1)
  1544. typedef struct _INQUIRYDATA {
  1545. UCHAR DeviceType : 5;
  1546. UCHAR DeviceTypeQualifier : 3;
  1547. UCHAR DeviceTypeModifier : 7;
  1548. UCHAR RemovableMedia : 1;
  1549. union {
  1550. UCHAR Versions;
  1551. struct {
  1552. UCHAR ANSIVersion : 3;
  1553. UCHAR ECMAVersion : 3;
  1554. UCHAR ISOVersion : 2;
  1555. };
  1556. };
  1557. UCHAR ResponseDataFormat : 4;
  1558. UCHAR HiSupport : 1;
  1559. UCHAR NormACA : 1;
  1560. UCHAR TerminateTask : 1;
  1561. UCHAR AERC : 1;
  1562. UCHAR AdditionalLength;
  1563. UCHAR Reserved;
  1564. UCHAR Addr16 : 1; // defined only for SIP devices.
  1565. UCHAR Addr32 : 1; // defined only for SIP devices.
  1566. UCHAR AckReqQ: 1; // defined only for SIP devices.
  1567. UCHAR MediumChanger : 1;
  1568. UCHAR MultiPort : 1;
  1569. UCHAR ReservedBit2 : 1;
  1570. UCHAR EnclosureServices : 1;
  1571. UCHAR ReservedBit3 : 1;
  1572. UCHAR SoftReset : 1;
  1573. UCHAR CommandQueue : 1;
  1574. UCHAR TransferDisable : 1; // defined only for SIP devices.
  1575. UCHAR LinkedCommands : 1;
  1576. UCHAR Synchronous : 1; // defined only for SIP devices.
  1577. UCHAR Wide16Bit : 1; // defined only for SIP devices.
  1578. UCHAR Wide32Bit : 1; // defined only for SIP devices.
  1579. UCHAR RelativeAddressing : 1;
  1580. UCHAR VendorId[8];
  1581. UCHAR ProductId[16];
  1582. UCHAR ProductRevisionLevel[4];
  1583. UCHAR VendorSpecific[20];
  1584. UCHAR Reserved3[40];
  1585. } INQUIRYDATA, *PINQUIRYDATA;
  1586. #pragma pack(pop, inquiry)
  1587. //
  1588. // Inquiry defines. Used to interpret data returned from target as result
  1589. // of inquiry command.
  1590. //
  1591. // DeviceType field
  1592. //
  1593. #define DIRECT_ACCESS_DEVICE 0x00 // disks
  1594. #define SEQUENTIAL_ACCESS_DEVICE 0x01 // tapes
  1595. #define PRINTER_DEVICE 0x02 // printers
  1596. #define PROCESSOR_DEVICE 0x03 // scanners, printers, etc
  1597. #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04 // worms
  1598. #define READ_ONLY_DIRECT_ACCESS_DEVICE 0x05 // cdroms
  1599. #define SCANNER_DEVICE 0x06 // scanners
  1600. #define OPTICAL_DEVICE 0x07 // optical disks
  1601. #define MEDIUM_CHANGER 0x08 // jukebox
  1602. #define COMMUNICATION_DEVICE 0x09 // network
  1603. #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
  1604. #define DEVICE_QUALIFIER_ACTIVE 0x00
  1605. #define DEVICE_QUALIFIER_NOT_ACTIVE 0x01
  1606. #define DEVICE_QUALIFIER_NOT_SUPPORTED 0x03
  1607. //
  1608. // DeviceTypeQualifier field
  1609. //
  1610. #define DEVICE_CONNECTED 0x00
  1611. //
  1612. // Vital Product Data Pages
  1613. //
  1614. //
  1615. // Unit Serial Number Page (page code 0x80)
  1616. //
  1617. // Provides a product serial number for the target or the logical unit.
  1618. //
  1619. #pragma pack(push, vpd_media_sn, 1)
  1620. typedef struct _VPD_MEDIA_SERIAL_NUMBER_PAGE {
  1621. UCHAR DeviceType : 5;
  1622. UCHAR DeviceTypeQualifier : 3;
  1623. UCHAR PageCode;
  1624. UCHAR Reserved;
  1625. UCHAR PageLength;
  1626. UCHAR SerialNumber[0];
  1627. } VPD_MEDIA_SERIAL_NUMBER_PAGE, *PVPD_MEDIA_SERIAL_NUMBER_PAGE;
  1628. #pragma pack(pop, vpd_media_sn)
  1629. #pragma pack(push, vpd_sn, 1)
  1630. typedef struct _VPD_SERIAL_NUMBER_PAGE {
  1631. UCHAR DeviceType : 5;
  1632. UCHAR DeviceTypeQualifier : 3;
  1633. UCHAR PageCode;
  1634. UCHAR Reserved;
  1635. UCHAR PageLength;
  1636. UCHAR SerialNumber[0];
  1637. } VPD_SERIAL_NUMBER_PAGE, *PVPD_SERIAL_NUMBER_PAGE;
  1638. #pragma pack(pop, vpd_sn)
  1639. //
  1640. // Device Identification Page (page code 0x83)
  1641. // Provides the means to retrieve zero or more identification descriptors
  1642. // applying to the logical unit.
  1643. //
  1644. #pragma pack(push, vpd_stuff, 1)
  1645. typedef enum _VPD_CODE_SET {
  1646. VpdCodeSetReserved = 0,
  1647. VpdCodeSetBinary = 1,
  1648. VpdCodeSetAscii = 2
  1649. } VPD_CODE_SET, *PVPD_CODE_SET;
  1650. typedef enum _VPD_ASSOCIATION {
  1651. VpdAssocDevice = 0,
  1652. VpdAssocPort = 1,
  1653. VpdAssocReserved1 = 3,
  1654. VpdAssocReserved2 = 4
  1655. } VPD_ASSOCIATION, *PVPD_ASSOCIATION;
  1656. typedef enum _VPD_IDENTIFIER_TYPE {
  1657. VpdIdentifierTypeVendorSpecific = 0,
  1658. VpdIdentifierTypeVendorId = 1,
  1659. VpdIdentifierTypeEUI64 = 2,
  1660. VpdIdentifierTypeFCPHName = 3,
  1661. VpdIdentifierTypePortRelative = 4
  1662. } VPD_IDENTIFIER_TYPE, *PVPD_IDENTIFIER_TYPE;
  1663. typedef struct _VPD_IDENTIFICATION_DESCRIPTOR {
  1664. UCHAR CodeSet : 4; // VPD_CODE_SET
  1665. UCHAR Reserved : 4;
  1666. UCHAR IdentifierType : 4; // VPD_IDENTIFIER_TYPE
  1667. UCHAR Association : 2;
  1668. UCHAR Reserved2 : 2;
  1669. UCHAR Reserved3;
  1670. UCHAR IdentifierLength;
  1671. UCHAR Identifier[0];
  1672. } VPD_IDENTIFICATION_DESCRIPTOR, *PVPD_IDENTIFICATION_DESCRIPTOR;
  1673. typedef struct _VPD_IDENTIFICATION_PAGE {
  1674. UCHAR DeviceType : 5;
  1675. UCHAR DeviceTypeQualifier : 3;
  1676. UCHAR PageCode;
  1677. UCHAR Reserved;
  1678. UCHAR PageLength;
  1679. //
  1680. // The following field is actually a variable length array of identification
  1681. // descriptors. Unfortunately there's no C notation for an array of
  1682. // variable length structures so we're forced to just pretend.
  1683. //
  1684. // VPD_IDENTIFICATION_DESCRIPTOR Descriptors[0];
  1685. UCHAR Descriptors[0];
  1686. } VPD_IDENTIFICATION_PAGE, *PVPD_IDENTIFICATION_PAGE;
  1687. //
  1688. // Supported Vital Product Data Pages Page (page code 0x00)
  1689. // Contains a list of the vital product data page cods supported by the target
  1690. // or logical unit.
  1691. //
  1692. typedef struct _VPD_SUPPORTED_PAGES_PAGE {
  1693. UCHAR DeviceType : 5;
  1694. UCHAR DeviceTypeQualifier : 3;
  1695. UCHAR PageCode;
  1696. UCHAR Reserved;
  1697. UCHAR PageLength;
  1698. UCHAR SupportedPageList[0];
  1699. } VPD_SUPPORTED_PAGES_PAGE, *PVPD_SUPPORTED_PAGES_PAGE;
  1700. #pragma pack(pop, vpd_stuff)
  1701. #define VPD_MAX_BUFFER_SIZE 0xff
  1702. #define VPD_SUPPORTED_PAGES 0x00
  1703. #define VPD_SERIAL_NUMBER 0x80
  1704. #define VPD_DEVICE_IDENTIFIERS 0x83
  1705. #define VPD_MEDIA_SERIAL_NUMBER 0x84
  1706. //
  1707. // Persistent Reservation Definitions.
  1708. //
  1709. //
  1710. // PERSISTENT_RESERVE_* definitions
  1711. //
  1712. #define RESERVATION_ACTION_READ_KEYS 0x00
  1713. #define RESERVATION_ACTION_READ_RESERVATIONS 0x01
  1714. #define RESERVATION_ACTION_REGISTER 0x00
  1715. #define RESERVATION_ACTION_RESERVE 0x01
  1716. #define RESERVATION_ACTION_RELEASE 0x02
  1717. #define RESERVATION_ACTION_CLEAR 0x03
  1718. #define RESERVATION_ACTION_PREEMPT 0x04
  1719. #define RESERVATION_ACTION_PREEMPT_ABORT 0x05
  1720. #define RESERVATION_ACTION_REGISTER_IGNORE_EXISTING 0x06
  1721. #define RESERVATION_SCOPE_LU 0x00
  1722. #define RESERVATION_SCOPE_ELEMENT 0x02
  1723. #define RESERVATION_TYPE_WRITE_EXCLUSIVE 0x01
  1724. #define RESERVATION_TYPE_EXCLUSIVE 0x03
  1725. #define RESERVATION_TYPE_WRITE_EXCLUSIVE_REGISTRANTS 0x05
  1726. #define RESERVATION_TYPE_EXCLUSIVE_REGISTRANTS 0x06
  1727. //
  1728. // Structures for reserve in command.
  1729. //
  1730. #pragma pack(push, reserve_in_stuff, 1)
  1731. typedef struct {
  1732. UCHAR Generation[4];
  1733. UCHAR AdditionalLength[4];
  1734. UCHAR ReservationKeyList[0][8];
  1735. } PRI_REGISTRATION_LIST, *PPRI_REGISTRATION_LIST;
  1736. typedef struct {
  1737. UCHAR ReservationKey[8];
  1738. UCHAR ScopeSpecificAddress[4];
  1739. UCHAR Reserved;
  1740. UCHAR Type : 4;
  1741. UCHAR Scope : 4;
  1742. UCHAR Obsolete[2];
  1743. } PRI_RESERVATION_DESCRIPTOR, *PPRI_RESERVATION_DESCRIPTOR;
  1744. typedef struct {
  1745. UCHAR Generation[4];
  1746. UCHAR AdditionalLength[4];
  1747. PRI_RESERVATION_DESCRIPTOR Reservations[0];
  1748. } PRI_RESERVATION_LIST, *PPRI_RESERVATION_LIST;
  1749. #pragma pack(pop, reserve_in_stuff)
  1750. //
  1751. // Structures for reserve out command.
  1752. //
  1753. #pragma pack(push, reserve_out_stuff, 1)
  1754. typedef struct {
  1755. UCHAR ReservationKey[8];
  1756. UCHAR ServiceActionReservationKey[8];
  1757. UCHAR ScopeSpecificAddress[4];
  1758. UCHAR ActivatePersistThroughPowerLoss : 1;
  1759. UCHAR Reserved1 : 7;
  1760. UCHAR Reserved2;
  1761. UCHAR Obsolete[2];
  1762. } PRO_PARAMETER_LIST, *PPRO_PARAMETER_LIST;
  1763. #pragma pack(pop, reserve_out_stuff)
  1764. //
  1765. // Sense Data Format
  1766. //
  1767. #pragma pack(push, sensedata, 1)
  1768. typedef struct _SENSE_DATA {
  1769. UCHAR ErrorCode:7;
  1770. UCHAR Valid:1;
  1771. UCHAR SegmentNumber;
  1772. UCHAR SenseKey:4;
  1773. UCHAR Reserved:1;
  1774. UCHAR IncorrectLength:1;
  1775. UCHAR EndOfMedia:1;
  1776. UCHAR FileMark:1;
  1777. UCHAR Information[4];
  1778. UCHAR AdditionalSenseLength;
  1779. UCHAR CommandSpecificInformation[4];
  1780. UCHAR AdditionalSenseCode;
  1781. UCHAR AdditionalSenseCodeQualifier;
  1782. UCHAR FieldReplaceableUnitCode;
  1783. UCHAR SenseKeySpecific[3];
  1784. } SENSE_DATA, *PSENSE_DATA;
  1785. #pragma pack(pop, sensedata)
  1786. //
  1787. // Default request sense buffer size
  1788. //
  1789. #define SENSE_BUFFER_SIZE 18
  1790. //
  1791. // Maximum request sense buffer size
  1792. //
  1793. #define MAX_SENSE_BUFFER_SIZE 255
  1794. //
  1795. // Maximum number of additional sense bytes.
  1796. //
  1797. #define MAX_ADDITIONAL_SENSE_BYTES (MAX_SENSE_BUFFER_SIZE - SENSE_BUFFER_SIZE)
  1798. //
  1799. // Sense codes
  1800. //
  1801. #define SCSI_SENSE_NO_SENSE 0x00
  1802. #define SCSI_SENSE_RECOVERED_ERROR 0x01
  1803. #define SCSI_SENSE_NOT_READY 0x02
  1804. #define SCSI_SENSE_MEDIUM_ERROR 0x03
  1805. #define SCSI_SENSE_HARDWARE_ERROR 0x04
  1806. #define SCSI_SENSE_ILLEGAL_REQUEST 0x05
  1807. #define SCSI_SENSE_UNIT_ATTENTION 0x06
  1808. #define SCSI_SENSE_DATA_PROTECT 0x07
  1809. #define SCSI_SENSE_BLANK_CHECK 0x08
  1810. #define SCSI_SENSE_UNIQUE 0x09
  1811. #define SCSI_SENSE_COPY_ABORTED 0x0A
  1812. #define SCSI_SENSE_ABORTED_COMMAND 0x0B
  1813. #define SCSI_SENSE_EQUAL 0x0C
  1814. #define SCSI_SENSE_VOL_OVERFLOW 0x0D
  1815. #define SCSI_SENSE_MISCOMPARE 0x0E
  1816. #define SCSI_SENSE_RESERVED 0x0F
  1817. //
  1818. // Additional tape bit
  1819. //
  1820. #define SCSI_ILLEGAL_LENGTH 0x20
  1821. #define SCSI_EOM 0x40
  1822. #define SCSI_FILE_MARK 0x80
  1823. //
  1824. // Additional Sense codes
  1825. //
  1826. #define SCSI_ADSENSE_NO_SENSE 0x00
  1827. #define SCSI_ADSENSE_NO_SEEK_COMPLETE 0x02
  1828. #define SCSI_ADSENSE_LUN_NOT_READY 0x04
  1829. #define SCSI_ADSENSE_WRITE_ERROR 0x0C
  1830. #define SCSI_ADSENSE_TRACK_ERROR 0x14
  1831. #define SCSI_ADSENSE_SEEK_ERROR 0x15
  1832. #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
  1833. #define SCSI_ADSENSE_REC_DATA_ECC 0x18
  1834. #define SCSI_ADSENSE_PARAMETER_LIST_LENGTH 0x1A
  1835. #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
  1836. #define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
  1837. #define SCSI_ADSENSE_INVALID_CDB 0x24
  1838. #define SCSI_ADSENSE_INVALID_LUN 0x25
  1839. #define SCSI_ADSENSE_INVALID_FIELD_PARAMETER_LIST 0x26
  1840. #define SCSI_ADSENSE_WRITE_PROTECT 0x27
  1841. #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
  1842. #define SCSI_ADSENSE_BUS_RESET 0x29
  1843. #define SCSI_ADSENSE_PARAMETERS_CHANGED 0x2A
  1844. #define SCSI_ADSENSE_INSUFFICIENT_TIME_FOR_OPERATION 0x2E
  1845. #define SCSI_ADSENSE_INVALID_MEDIA 0x30
  1846. #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
  1847. #define SCSI_ADSENSE_POSITION_ERROR 0x3b
  1848. #define SCSI_ADSENSE_OPERATOR_REQUEST 0x5a // see below
  1849. #define SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED 0x5d
  1850. #define SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK 0x64
  1851. #define SCSI_ADSENSE_COPY_PROTECTION_FAILURE 0x6f
  1852. #define SCSI_ADSENSE_POWER_CALIBRATION_ERROR 0x73
  1853. #define SCSI_ADSENSE_VENDOR_UNIQUE 0x80 // and higher
  1854. #define SCSI_ADSENSE_MUSIC_AREA 0xA0
  1855. #define SCSI_ADSENSE_DATA_AREA 0xA1
  1856. #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
  1857. // for legacy apps:
  1858. #define SCSI_ADWRITE_PROTECT SCSI_ADSENSE_WRITE_PROTECT
  1859. #define SCSI_FAILURE_PREDICTION_THRESHOLD_EXCEEDED SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED
  1860. //
  1861. // SCSI_ADSENSE_LUN_NOT_READY (0x04) qualifiers
  1862. //
  1863. #define SCSI_SENSEQ_CAUSE_NOT_REPORTABLE 0x00
  1864. #define SCSI_SENSEQ_BECOMING_READY 0x01
  1865. #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED 0x02
  1866. #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
  1867. #define SCSI_SENSEQ_FORMAT_IN_PROGRESS 0x04
  1868. #define SCSI_SENSEQ_REBUILD_IN_PROGRESS 0x05
  1869. #define SCSI_SENSEQ_RECALCULATION_IN_PROGRESS 0x06
  1870. #define SCSI_SENSEQ_OPERATION_IN_PROGRESS 0x07
  1871. #define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS 0x08
  1872. //
  1873. // SCSI_ADSENSE_WRITE_ERROR (0x0C) qualifiers
  1874. //
  1875. #define SCSI_SENSEQ_LOSS_OF_STREAMING 0x09
  1876. #define SCSI_SENSEQ_PADDING_BLOCKS_ADDED 0x0A
  1877. //
  1878. // SCSI_ADSENSE_NO_SENSE (0x00) qualifiers
  1879. //
  1880. #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
  1881. #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
  1882. #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
  1883. #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
  1884. //
  1885. // SCSI_ADSENSE_ILLEGAL_BLOCK (0x21) qualifiers
  1886. //
  1887. #define SCSI_SENSEQ_ILLEGAL_ELEMENT_ADDR 0x01
  1888. //
  1889. // SCSI_ADSENSE_POSITION_ERROR (0x3b) qualifiers
  1890. //
  1891. #define SCSI_SENSEQ_DESTINATION_FULL 0x0d
  1892. #define SCSI_SENSEQ_SOURCE_EMPTY 0x0e
  1893. //
  1894. // SCSI_ADSENSE_INVALID_MEDIA (0x30) qualifiers
  1895. //
  1896. #define SCSI_SENSEQ_INCOMPATIBLE_MEDIA_INSTALLED 0x00
  1897. #define SCSI_SENSEQ_UNKNOWN_FORMAT 0x01
  1898. #define SCSI_SENSEQ_INCOMPATIBLE_FORMAT 0x02
  1899. #define SCSI_SENSEQ_CLEANING_CARTRIDGE_INSTALLED 0x03
  1900. //
  1901. // SCSI_ADSENSE_OPERATOR_REQUEST (0x5a) qualifiers
  1902. //
  1903. #define SCSI_SENSEQ_STATE_CHANGE_INPUT 0x00 // generic request
  1904. #define SCSI_SENSEQ_MEDIUM_REMOVAL 0x01
  1905. #define SCSI_SENSEQ_WRITE_PROTECT_ENABLE 0x02
  1906. #define SCSI_SENSEQ_WRITE_PROTECT_DISABLE 0x03
  1907. //
  1908. // SCSI_ADSENSE_COPY_PROTECTION_FAILURE (0x6f) qualifiers
  1909. //
  1910. #define SCSI_SENSEQ_AUTHENTICATION_FAILURE 0x00
  1911. #define SCSI_SENSEQ_KEY_NOT_PRESENT 0x01
  1912. #define SCSI_SENSEQ_KEY_NOT_ESTABLISHED 0x02
  1913. #define SCSI_SENSEQ_READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION 0x03
  1914. #define SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT 0x04
  1915. #define SCSI_SENSEQ_LOGICAL_UNIT_RESET_COUNT_ERROR 0x05
  1916. //
  1917. // SCSI_ADSENSE_POWER_CALIBRATION_ERROR (0x73) qualifiers
  1918. //
  1919. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_ALMOST_FULL 0x01
  1920. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_FULL 0x02
  1921. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_ERROR 0x03
  1922. #define SCSI_SENSEQ_PMA_RMA_UPDATE_FAILURE 0x04
  1923. #define SCSI_SENSEQ_PMA_RMA_IS_FULL 0x05
  1924. #define SCSI_SENSEQ_PMA_RMA_ALMOST_FULL 0x06
  1925. // end_ntminitape
  1926. //
  1927. // SCSI IO Device Control Codes
  1928. //
  1929. #define FILE_DEVICE_SCSI 0x0000001b
  1930. #define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
  1931. #define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
  1932. #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
  1933. //
  1934. // SMART support in atapi
  1935. //
  1936. #define IOCTL_SCSI_MINIPORT_SMART_VERSION ((FILE_DEVICE_SCSI << 16) + 0x0500)
  1937. #define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501)
  1938. #define IOCTL_SCSI_MINIPORT_READ_SMART_ATTRIBS ((FILE_DEVICE_SCSI << 16) + 0x0502)
  1939. #define IOCTL_SCSI_MINIPORT_READ_SMART_THRESHOLDS ((FILE_DEVICE_SCSI << 16) + 0x0503)
  1940. #define IOCTL_SCSI_MINIPORT_ENABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0504)
  1941. #define IOCTL_SCSI_MINIPORT_DISABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0505)
  1942. #define IOCTL_SCSI_MINIPORT_RETURN_STATUS ((FILE_DEVICE_SCSI << 16) + 0x0506)
  1943. #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTOSAVE ((FILE_DEVICE_SCSI << 16) + 0x0507)
  1944. #define IOCTL_SCSI_MINIPORT_SAVE_ATTRIBUTE_VALUES ((FILE_DEVICE_SCSI << 16) + 0x0508)
  1945. #define IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS ((FILE_DEVICE_SCSI << 16) + 0x0509)
  1946. #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTO_OFFLINE ((FILE_DEVICE_SCSI << 16) + 0x050a)
  1947. #define IOCTL_SCSI_MINIPORT_READ_SMART_LOG ((FILE_DEVICE_SCSI << 16) + 0x050b)
  1948. #define IOCTL_SCSI_MINIPORT_WRITE_SMART_LOG ((FILE_DEVICE_SCSI << 16) + 0x050c)
  1949. //
  1950. // CLUSTER support
  1951. // deliberately skipped some values to allow for expansion above.
  1952. //
  1953. #define IOCTL_SCSI_MINIPORT_NOT_QUORUM_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0520)
  1954. #define IOCTL_SCSI_MINIPORT_NOT_CLUSTER_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0521)
  1955. // begin_ntminitape
  1956. //
  1957. // Read Capacity Data - returned in Big Endian format
  1958. //
  1959. #pragma pack(push, read_capacity, 1)
  1960. typedef struct _READ_CAPACITY_DATA {
  1961. ULONG LogicalBlockAddress;
  1962. ULONG BytesPerBlock;
  1963. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  1964. #pragma pack(pop, read_capacity)
  1965. //
  1966. // Read Block Limits Data - returned in Big Endian format
  1967. // This structure returns the maximum and minimum block
  1968. // size for a TAPE device.
  1969. //
  1970. #pragma pack(push, read_block_limits, 1)
  1971. typedef struct _READ_BLOCK_LIMITS {
  1972. UCHAR Reserved;
  1973. UCHAR BlockMaximumSize[3];
  1974. UCHAR BlockMinimumSize[2];
  1975. } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
  1976. #pragma pack(pop, read_block_limits)
  1977. //
  1978. // Mode data structures.
  1979. //
  1980. //
  1981. // Define Mode parameter header.
  1982. //
  1983. #pragma pack(push, mode_params, 1)
  1984. typedef struct _MODE_PARAMETER_HEADER {
  1985. UCHAR ModeDataLength;
  1986. UCHAR MediumType;
  1987. UCHAR DeviceSpecificParameter;
  1988. UCHAR BlockDescriptorLength;
  1989. }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
  1990. typedef struct _MODE_PARAMETER_HEADER10 {
  1991. UCHAR ModeDataLength[2];
  1992. UCHAR MediumType;
  1993. UCHAR DeviceSpecificParameter;
  1994. UCHAR Reserved[2];
  1995. UCHAR BlockDescriptorLength[2];
  1996. }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
  1997. #pragma pack(pop, mode_params)
  1998. #define MODE_FD_SINGLE_SIDE 0x01
  1999. #define MODE_FD_DOUBLE_SIDE 0x02
  2000. #define MODE_FD_MAXIMUM_TYPE 0x1E
  2001. #define MODE_DSP_FUA_SUPPORTED 0x10
  2002. #define MODE_DSP_WRITE_PROTECT 0x80
  2003. //
  2004. // Define the mode parameter block.
  2005. //
  2006. #pragma pack(push, mode_params_block, 1)
  2007. typedef struct _MODE_PARAMETER_BLOCK {
  2008. UCHAR DensityCode;
  2009. UCHAR NumberOfBlocks[3];
  2010. UCHAR Reserved;
  2011. UCHAR BlockLength[3];
  2012. }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
  2013. #pragma pack(pop, mode_params_block)
  2014. //
  2015. // Define Disconnect-Reconnect page.
  2016. //
  2017. #pragma pack(push, mode_page_disconnect, 1)
  2018. typedef struct _MODE_DISCONNECT_PAGE {
  2019. UCHAR PageCode : 6;
  2020. UCHAR Reserved : 1;
  2021. UCHAR PageSavable : 1;
  2022. UCHAR PageLength;
  2023. UCHAR BufferFullRatio;
  2024. UCHAR BufferEmptyRatio;
  2025. UCHAR BusInactivityLimit[2];
  2026. UCHAR BusDisconnectTime[2];
  2027. UCHAR BusConnectTime[2];
  2028. UCHAR MaximumBurstSize[2];
  2029. UCHAR DataTransferDisconnect : 2;
  2030. UCHAR Reserved2[3];
  2031. }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
  2032. #pragma pack(pop, mode_page_disconnect)
  2033. //
  2034. // Define mode caching page.
  2035. //
  2036. #pragma pack(push, mode_page_caching, 1)
  2037. typedef struct _MODE_CACHING_PAGE {
  2038. UCHAR PageCode : 6;
  2039. UCHAR Reserved : 1;
  2040. UCHAR PageSavable : 1;
  2041. UCHAR PageLength;
  2042. UCHAR ReadDisableCache : 1;
  2043. UCHAR MultiplicationFactor : 1;
  2044. UCHAR WriteCacheEnable : 1;
  2045. UCHAR Reserved2 : 5;
  2046. UCHAR WriteRetensionPriority : 4;
  2047. UCHAR ReadRetensionPriority : 4;
  2048. UCHAR DisablePrefetchTransfer[2];
  2049. UCHAR MinimumPrefetch[2];
  2050. UCHAR MaximumPrefetch[2];
  2051. UCHAR MaximumPrefetchCeiling[2];
  2052. }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
  2053. #pragma pack(pop, mode_page_caching)
  2054. //
  2055. // Define write parameters cdrom page
  2056. //
  2057. #pragma pack(push, mode_page_wp2, 1)
  2058. typedef struct _MODE_CDROM_WRITE_PARAMETERS_PAGE2 {
  2059. UCHAR PageCode : 6; // 0x05
  2060. UCHAR Reserved : 1;
  2061. UCHAR PageSavable : 1;
  2062. UCHAR PageLength; // 0x32 ??
  2063. UCHAR WriteType : 4;
  2064. UCHAR TestWrite : 1;
  2065. UCHAR LinkSizeValid : 1;
  2066. UCHAR BufferUnderrunFreeEnabled : 1;
  2067. UCHAR Reserved2 : 1;
  2068. UCHAR TrackMode : 4;
  2069. UCHAR Copy : 1;
  2070. UCHAR FixedPacket : 1;
  2071. UCHAR MultiSession : 2;
  2072. UCHAR DataBlockType : 4;
  2073. UCHAR Reserved3 : 4;
  2074. UCHAR LinkSize;
  2075. UCHAR Reserved4;
  2076. UCHAR HostApplicationCode : 6;
  2077. UCHAR Reserved5 : 2;
  2078. UCHAR SessionFormat;
  2079. UCHAR Reserved6;
  2080. UCHAR PacketSize[4];
  2081. UCHAR AudioPauseLength[2];
  2082. UCHAR MediaCatalogNumber[16];
  2083. UCHAR ISRC[16];
  2084. UCHAR SubHeaderData[4];
  2085. } MODE_CDROM_WRITE_PARAMETERS_PAGE2, *PMODE_CDROM_WRITE_PARAMETERS_PAGE2;
  2086. #pragma pack(pop, mode_page_wp2)
  2087. #ifndef DEPRECATE_DDK_FUNCTIONS
  2088. // this structure is being retired due to missing fields and overly
  2089. // complex data definitions for the MCN and ISRC.
  2090. #pragma pack(push, mode_page_wp, 1)
  2091. typedef struct _MODE_CDROM_WRITE_PARAMETERS_PAGE {
  2092. UCHAR PageLength; // 0x32 ??
  2093. UCHAR WriteType : 4;
  2094. UCHAR TestWrite : 1;
  2095. UCHAR LinkSizeValid : 1;
  2096. UCHAR BufferUnderrunFreeEnabled : 1;
  2097. UCHAR Reserved2 : 1;
  2098. UCHAR TrackMode : 4;
  2099. UCHAR Copy : 1;
  2100. UCHAR FixedPacket : 1;
  2101. UCHAR MultiSession : 2;
  2102. UCHAR DataBlockType : 4;
  2103. UCHAR Reserved3 : 4;
  2104. UCHAR LinkSize;
  2105. UCHAR Reserved4;
  2106. UCHAR HostApplicationCode : 6;
  2107. UCHAR Reserved5 : 2;
  2108. UCHAR SessionFormat;
  2109. UCHAR Reserved6;
  2110. UCHAR PacketSize[4];
  2111. UCHAR AudioPauseLength[2];
  2112. UCHAR Reserved7 : 7;
  2113. UCHAR MediaCatalogNumberValid : 1;
  2114. UCHAR MediaCatalogNumber[13];
  2115. UCHAR MediaCatalogNumberZero;
  2116. UCHAR MediaCatalogNumberAFrame;
  2117. UCHAR Reserved8 : 7;
  2118. UCHAR ISRCValid : 1;
  2119. UCHAR ISRCCountry[2];
  2120. UCHAR ISRCOwner[3];
  2121. UCHAR ISRCRecordingYear[2];
  2122. UCHAR ISRCSerialNumber[5];
  2123. UCHAR ISRCZero;
  2124. UCHAR ISRCAFrame;
  2125. UCHAR ISRCReserved;
  2126. UCHAR SubHeaderData[4];
  2127. } MODE_CDROM_WRITE_PARAMETERS_PAGE, *PMODE_CDROM_WRITE_PARAMETERS_PAGE;
  2128. #pragma pack(pop, mode_page_wp)
  2129. #endif //ifndef DEPRECATE_DDK_FUNCTIONS
  2130. //
  2131. // Define the MRW mode page for CDROM device types
  2132. //
  2133. #pragma pack(push, mode_page_mrw, 1)
  2134. typedef struct _MODE_MRW_PAGE {
  2135. UCHAR PageCode : 6; // 0x03
  2136. UCHAR Reserved : 1;
  2137. UCHAR PageSavable : 1;
  2138. UCHAR PageLength; //0x06
  2139. UCHAR Reserved1;
  2140. UCHAR LbaSpace : 1;
  2141. UCHAR Reserved2 : 7;
  2142. UCHAR Reserved3[4];
  2143. } MODE_MRW_PAGE, *PMODE_MRW_PAGE;
  2144. #pragma pack(pop, mode_page_mrw)
  2145. //
  2146. // Define mode flexible disk page.
  2147. //
  2148. #pragma pack(push, mode_page_flex, 1)
  2149. typedef struct _MODE_FLEXIBLE_DISK_PAGE {
  2150. UCHAR PageCode : 6;
  2151. UCHAR Reserved : 1;
  2152. UCHAR PageSavable : 1;
  2153. UCHAR PageLength;
  2154. UCHAR TransferRate[2];
  2155. UCHAR NumberOfHeads;
  2156. UCHAR SectorsPerTrack;
  2157. UCHAR BytesPerSector[2];
  2158. UCHAR NumberOfCylinders[2];
  2159. UCHAR StartWritePrecom[2];
  2160. UCHAR StartReducedCurrent[2];
  2161. UCHAR StepRate[2];
  2162. UCHAR StepPluseWidth;
  2163. UCHAR HeadSettleDelay[2];
  2164. UCHAR MotorOnDelay;
  2165. UCHAR MotorOffDelay;
  2166. UCHAR Reserved2 : 5;
  2167. UCHAR MotorOnAsserted : 1;
  2168. UCHAR StartSectorNumber : 1;
  2169. UCHAR TrueReadySignal : 1;
  2170. UCHAR StepPlusePerCyclynder : 4;
  2171. UCHAR Reserved3 : 4;
  2172. UCHAR WriteCompenstation;
  2173. UCHAR HeadLoadDelay;
  2174. UCHAR HeadUnloadDelay;
  2175. UCHAR Pin2Usage : 4;
  2176. UCHAR Pin34Usage : 4;
  2177. UCHAR Pin1Usage : 4;
  2178. UCHAR Pin4Usage : 4;
  2179. UCHAR MediumRotationRate[2];
  2180. UCHAR Reserved4[2];
  2181. } MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
  2182. #pragma pack(pop, mode_page_flex)
  2183. //
  2184. // Define mode format page.
  2185. //
  2186. #pragma pack(push, mode_page_format, 1)
  2187. typedef struct _MODE_FORMAT_PAGE {
  2188. UCHAR PageCode : 6;
  2189. UCHAR Reserved : 1;
  2190. UCHAR PageSavable : 1;
  2191. UCHAR PageLength;
  2192. UCHAR TracksPerZone[2];
  2193. UCHAR AlternateSectorsPerZone[2];
  2194. UCHAR AlternateTracksPerZone[2];
  2195. UCHAR AlternateTracksPerLogicalUnit[2];
  2196. UCHAR SectorsPerTrack[2];
  2197. UCHAR BytesPerPhysicalSector[2];
  2198. UCHAR Interleave[2];
  2199. UCHAR TrackSkewFactor[2];
  2200. UCHAR CylinderSkewFactor[2];
  2201. UCHAR Reserved2 : 4;
  2202. UCHAR SurfaceFirst : 1;
  2203. UCHAR RemovableMedia : 1;
  2204. UCHAR HardSectorFormating : 1;
  2205. UCHAR SoftSectorFormating : 1;
  2206. UCHAR Reserved3[3];
  2207. } MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
  2208. #pragma pack(pop, mode_page_format)
  2209. //
  2210. // Define rigid disk driver geometry page.
  2211. //
  2212. #pragma pack(push, mode_page_geometry, 1)
  2213. typedef struct _MODE_RIGID_GEOMETRY_PAGE {
  2214. UCHAR PageCode : 6;
  2215. UCHAR Reserved : 1;
  2216. UCHAR PageSavable : 1;
  2217. UCHAR PageLength;
  2218. UCHAR NumberOfCylinders[3];
  2219. UCHAR NumberOfHeads;
  2220. UCHAR StartWritePrecom[3];
  2221. UCHAR StartReducedCurrent[3];
  2222. UCHAR DriveStepRate[2];
  2223. UCHAR LandZoneCyclinder[3];
  2224. UCHAR RotationalPositionLock : 2;
  2225. UCHAR Reserved2 : 6;
  2226. UCHAR RotationOffset;
  2227. UCHAR Reserved3;
  2228. UCHAR RoataionRate[2];
  2229. UCHAR Reserved4[2];
  2230. }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
  2231. #pragma pack(pop, mode_page_geometry)
  2232. //
  2233. // Define read write recovery page
  2234. //
  2235. #pragma pack(push, mode_page_rw_recovery, 1)
  2236. typedef struct _MODE_READ_WRITE_RECOVERY_PAGE {
  2237. UCHAR PageCode : 6;
  2238. UCHAR Reserved1 : 1;
  2239. UCHAR PSBit : 1;
  2240. UCHAR PageLength;
  2241. UCHAR DCRBit : 1;
  2242. UCHAR DTEBit : 1;
  2243. UCHAR PERBit : 1;
  2244. UCHAR EERBit : 1;
  2245. UCHAR RCBit : 1;
  2246. UCHAR TBBit : 1;
  2247. UCHAR ARRE : 1;
  2248. UCHAR AWRE : 1;
  2249. UCHAR ReadRetryCount;
  2250. UCHAR Reserved4[4];
  2251. UCHAR WriteRetryCount;
  2252. UCHAR Reserved5[3];
  2253. } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
  2254. #pragma pack(pop, mode_page_rw_recovery)
  2255. //
  2256. // Define read recovery page - cdrom
  2257. //
  2258. #pragma pack(push, mode_page_r_recovery, 1)
  2259. typedef struct _MODE_READ_RECOVERY_PAGE {
  2260. UCHAR PageCode : 6;
  2261. UCHAR Reserved1 : 1;
  2262. UCHAR PSBit : 1;
  2263. UCHAR PageLength;
  2264. UCHAR DCRBit : 1;
  2265. UCHAR DTEBit : 1;
  2266. UCHAR PERBit : 1;
  2267. UCHAR Reserved2 : 1;
  2268. UCHAR RCBit : 1;
  2269. UCHAR TBBit : 1;
  2270. UCHAR Reserved3 : 2;
  2271. UCHAR ReadRetryCount;
  2272. UCHAR Reserved4[4];
  2273. } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
  2274. #pragma pack(pop, mode_page_r_recovery)
  2275. //
  2276. // Define Informational Exception Control Page. Used for failure prediction
  2277. //
  2278. #pragma pack(push, mode_page_xcpt, 1)
  2279. typedef struct _MODE_INFO_EXCEPTIONS
  2280. {
  2281. UCHAR PageCode : 6;
  2282. UCHAR Reserved1 : 1;
  2283. UCHAR PSBit : 1;
  2284. UCHAR PageLength;
  2285. union
  2286. {
  2287. UCHAR Flags;
  2288. struct
  2289. {
  2290. UCHAR LogErr : 1;
  2291. UCHAR Reserved2 : 1;
  2292. UCHAR Test : 1;
  2293. UCHAR Dexcpt : 1;
  2294. UCHAR Reserved3 : 3;
  2295. UCHAR Perf : 1;
  2296. };
  2297. };
  2298. UCHAR ReportMethod : 4;
  2299. UCHAR Reserved4 : 4;
  2300. UCHAR IntervalTimer[4];
  2301. UCHAR ReportCount[4];
  2302. } MODE_INFO_EXCEPTIONS, *PMODE_INFO_EXCEPTIONS;
  2303. #pragma pack(pop, mode_page_xcpt)
  2304. //
  2305. // Begin C/DVD 0.9 definitions
  2306. //
  2307. //
  2308. // Power Condition Mode Page Format
  2309. //
  2310. #pragma pack(push, mode_page_power, 1)
  2311. typedef struct _POWER_CONDITION_PAGE {
  2312. UCHAR PageCode : 6; // 0x1A
  2313. UCHAR Reserved : 1;
  2314. UCHAR PSBit : 1;
  2315. UCHAR PageLength; // 0x0A
  2316. UCHAR Reserved2;
  2317. UCHAR Standby : 1;
  2318. UCHAR Idle : 1;
  2319. UCHAR Reserved3 : 6;
  2320. UCHAR IdleTimer[4];
  2321. UCHAR StandbyTimer[4];
  2322. } POWER_CONDITION_PAGE, *PPOWER_CONDITION_PAGE;
  2323. #pragma pack(pop, mode_page_power)
  2324. //
  2325. // CD-Audio Control Mode Page Format
  2326. //
  2327. #pragma pack(push, mode_page_cdaudio, 1)
  2328. typedef struct _CDDA_OUTPUT_PORT {
  2329. UCHAR ChannelSelection : 4;
  2330. UCHAR Reserved : 4;
  2331. UCHAR Volume;
  2332. } CDDA_OUTPUT_PORT, *PCDDA_OUTPUT_PORT;
  2333. typedef struct _CDAUDIO_CONTROL_PAGE {
  2334. UCHAR PageCode : 6; // 0x0E
  2335. UCHAR Reserved : 1;
  2336. UCHAR PSBit : 1;
  2337. UCHAR PageLength; // 0x0E
  2338. UCHAR Reserved2 : 1;
  2339. UCHAR StopOnTrackCrossing : 1; // Default 0
  2340. UCHAR Immediate : 1; // Always 1
  2341. UCHAR Reserved3 : 5;
  2342. UCHAR Reserved4[3];
  2343. UCHAR Obsolete[2];
  2344. CDDA_OUTPUT_PORT CDDAOutputPorts[4];
  2345. } CDAUDIO_CONTROL_PAGE, *PCDAUDIO_CONTROL_PAGE;
  2346. #pragma pack(pop, mode_page_cdaudio)
  2347. #define CDDA_CHANNEL_MUTED 0x0
  2348. #define CDDA_CHANNEL_ZERO 0x1
  2349. #define CDDA_CHANNEL_ONE 0x2
  2350. #define CDDA_CHANNEL_TWO 0x4
  2351. #define CDDA_CHANNEL_THREE 0x8
  2352. //
  2353. // C/DVD Feature Set Support & Version Page
  2354. //
  2355. #pragma pack(push, mode_page_features, 1)
  2356. typedef struct _CDVD_FEATURE_SET_PAGE {
  2357. UCHAR PageCode : 6; // 0x18
  2358. UCHAR Reserved : 1;
  2359. UCHAR PSBit : 1;
  2360. UCHAR PageLength; // 0x16
  2361. UCHAR CDAudio[2];
  2362. UCHAR EmbeddedChanger[2];
  2363. UCHAR PacketSMART[2];
  2364. UCHAR PersistantPrevent[2];
  2365. UCHAR EventStatusNotification[2];
  2366. UCHAR DigitalOutput[2];
  2367. UCHAR CDSequentialRecordable[2];
  2368. UCHAR DVDSequentialRecordable[2];
  2369. UCHAR RandomRecordable[2];
  2370. UCHAR KeyExchange[2];
  2371. UCHAR Reserved2[2];
  2372. } CDVD_FEATURE_SET_PAGE, *PCDVD_FEATURE_SET_PAGE;
  2373. #pragma pack(pop, mode_page_features)
  2374. //
  2375. // CDVD Inactivity Time-out Page Format
  2376. //
  2377. #pragma pack(push, mode_page_timeout, 1)
  2378. typedef struct _CDVD_INACTIVITY_TIMEOUT_PAGE {
  2379. UCHAR PageCode : 6; // 0x1D
  2380. UCHAR Reserved : 1;
  2381. UCHAR PSBit : 1;
  2382. UCHAR PageLength; // 0x08
  2383. UCHAR Reserved2[2];
  2384. UCHAR SWPP : 1;
  2385. UCHAR DISP : 1;
  2386. UCHAR Reserved3 : 6;
  2387. UCHAR Reserved4;
  2388. UCHAR GroupOneMinimumTimeout[2];
  2389. UCHAR GroupTwoMinimumTimeout[2];
  2390. } CDVD_INACTIVITY_TIMEOUT_PAGE, *PCDVD_INACTIVITY_TIMEOUT_PAGE;
  2391. #pragma pack(pop, mode_page_timeout)
  2392. //
  2393. // CDVD Capabilities & Mechanism Status Page
  2394. //
  2395. #define CDVD_LMT_CADDY 0
  2396. #define CDVD_LMT_TRAY 1
  2397. #define CDVD_LMT_POPUP 2
  2398. #define CDVD_LMT_RESERVED1 3
  2399. #define CDVD_LMT_CHANGER_INDIVIDUAL 4
  2400. #define CDVD_LMT_CHANGER_CARTRIDGE 5
  2401. #define CDVD_LMT_RESERVED2 6
  2402. #define CDVD_LMT_RESERVED3 7
  2403. #pragma pack(push, mode_page_capabilities, 1)
  2404. typedef struct _CDVD_CAPABILITIES_PAGE {
  2405. UCHAR PageCode : 6; // 0x2A
  2406. UCHAR Reserved : 1;
  2407. UCHAR PSBit : 1; // offset 0
  2408. UCHAR PageLength; // >= 0x18 // offset 1
  2409. UCHAR CDRRead : 1;
  2410. UCHAR CDERead : 1;
  2411. UCHAR Method2 : 1;
  2412. UCHAR DVDROMRead : 1;
  2413. UCHAR DVDRRead : 1;
  2414. UCHAR DVDRAMRead : 1;
  2415. UCHAR Reserved2 : 2; // offset 2
  2416. UCHAR CDRWrite : 1;
  2417. UCHAR CDEWrite : 1;
  2418. UCHAR TestWrite : 1;
  2419. UCHAR Reserved3 : 1;
  2420. UCHAR DVDRWrite : 1;
  2421. UCHAR DVDRAMWrite : 1;
  2422. UCHAR Reserved4 : 2; // offset 3
  2423. UCHAR AudioPlay : 1;
  2424. UCHAR Composite : 1;
  2425. UCHAR DigitalPortOne : 1;
  2426. UCHAR DigitalPortTwo : 1;
  2427. UCHAR Mode2Form1 : 1;
  2428. UCHAR Mode2Form2 : 1;
  2429. UCHAR MultiSession : 1;
  2430. UCHAR BufferUnderrunFree : 1; // offset 4
  2431. UCHAR CDDA : 1;
  2432. UCHAR CDDAAccurate : 1;
  2433. UCHAR RWSupported : 1;
  2434. UCHAR RWDeinterleaved : 1;
  2435. UCHAR C2Pointers : 1;
  2436. UCHAR ISRC : 1;
  2437. UCHAR UPC : 1;
  2438. UCHAR ReadBarCodeCapable : 1; // offset 5
  2439. UCHAR Lock : 1;
  2440. UCHAR LockState : 1;
  2441. UCHAR PreventJumper : 1;
  2442. UCHAR Eject : 1;
  2443. UCHAR Reserved6 : 1;
  2444. UCHAR LoadingMechanismType : 3; // offset 6
  2445. UCHAR SeparateVolume : 1;
  2446. UCHAR SeperateChannelMute : 1;
  2447. UCHAR SupportsDiskPresent : 1;
  2448. UCHAR SWSlotSelection : 1;
  2449. UCHAR SideChangeCapable : 1;
  2450. UCHAR RWInLeadInReadable : 1;
  2451. UCHAR Reserved7 : 2; // offset 7
  2452. union {
  2453. UCHAR ReadSpeedMaximum[2];
  2454. UCHAR ObsoleteReserved[2]; // offset 8
  2455. };
  2456. UCHAR NumberVolumeLevels[2]; // offset 10
  2457. UCHAR BufferSize[2]; // offset 12
  2458. union {
  2459. UCHAR ReadSpeedCurrent[2];
  2460. UCHAR ObsoleteReserved2[2]; // offset 14
  2461. };
  2462. UCHAR ObsoleteReserved3; // offset 16
  2463. UCHAR Reserved8 : 1;
  2464. UCHAR BCK : 1;
  2465. UCHAR RCK : 1;
  2466. UCHAR LSBF : 1;
  2467. UCHAR Length : 2;
  2468. UCHAR Reserved9 : 2; // offset 17
  2469. union {
  2470. UCHAR WriteSpeedMaximum[2];
  2471. UCHAR ObsoleteReserved4[2]; // offset 18
  2472. };
  2473. union {
  2474. UCHAR WriteSpeedCurrent[2];
  2475. UCHAR ObsoleteReserved11[2]; // offset 20
  2476. };
  2477. //
  2478. // NOTE: This mode page is two bytes too small in the release
  2479. // version of the Windows2000 DDK. it also incorrectly
  2480. // put the CopyManagementRevision at offset 20 instead
  2481. // of offset 22, so fix that with a nameless union (for
  2482. // backwards-compatibility with those who "fixed" it on
  2483. // their own by looking at Reserved10[]).
  2484. //
  2485. union {
  2486. UCHAR CopyManagementRevision[2]; // offset 22
  2487. UCHAR Reserved10[2];
  2488. };
  2489. //UCHAR Reserved12[2]; // offset 24
  2490. } CDVD_CAPABILITIES_PAGE, *PCDVD_CAPABILITIES_PAGE;
  2491. #pragma pack(pop, mode_page_capabilities)
  2492. #pragma pack(push, lun_list, 1)
  2493. typedef struct _LUN_LIST {
  2494. UCHAR LunListLength[4]; // sizeof LunSize * 8
  2495. UCHAR Reserved[4];
  2496. UCHAR Lun[0][8]; // 4 level of addressing. 2 bytes each.
  2497. } LUN_LIST, *PLUN_LIST;
  2498. #pragma pack(pop, lun_list)
  2499. #define LOADING_MECHANISM_CADDY 0x00
  2500. #define LOADING_MECHANISM_TRAY 0x01
  2501. #define LOADING_MECHANISM_POPUP 0x02
  2502. #define LOADING_MECHANISM_INDIVIDUAL_CHANGER 0x04
  2503. #define LOADING_MECHANISM_CARTRIDGE_CHANGER 0x05
  2504. //
  2505. // end C/DVD 0.9 mode page definitions
  2506. //
  2507. // Mode parameter list block descriptor -
  2508. // set the block length for reading/writing
  2509. //
  2510. //
  2511. #define MODE_BLOCK_DESC_LENGTH 8
  2512. #define MODE_HEADER_LENGTH 4
  2513. #define MODE_HEADER_LENGTH10 8
  2514. #pragma pack(push, mode_parm_rw, 1)
  2515. typedef struct _MODE_PARM_READ_WRITE {
  2516. MODE_PARAMETER_HEADER ParameterListHeader; // List Header Format
  2517. MODE_PARAMETER_BLOCK ParameterListBlock; // List Block Descriptor
  2518. } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
  2519. #pragma pack(pop, mode_parm_rw)
  2520. // end_ntminitape
  2521. //
  2522. // CDROM audio control (0x0E)
  2523. //
  2524. #define CDB_AUDIO_PAUSE 0
  2525. #define CDB_AUDIO_RESUME 1
  2526. #define CDB_DEVICE_START 0x11
  2527. #define CDB_DEVICE_STOP 0x10
  2528. #define CDB_EJECT_MEDIA 0x10
  2529. #define CDB_LOAD_MEDIA 0x01
  2530. #define CDB_SUBCHANNEL_HEADER 0x00
  2531. #define CDB_SUBCHANNEL_BLOCK 0x01
  2532. #define CDROM_AUDIO_CONTROL_PAGE 0x0E
  2533. #define MODE_SELECT_IMMEDIATE 0x04
  2534. #define MODE_SELECT_PFBIT 0x10
  2535. #define CDB_USE_MSF 0x01
  2536. #pragma pack(push, audio_output, 1)
  2537. typedef struct _PORT_OUTPUT {
  2538. UCHAR ChannelSelection;
  2539. UCHAR Volume;
  2540. } PORT_OUTPUT, *PPORT_OUTPUT;
  2541. typedef struct _AUDIO_OUTPUT {
  2542. UCHAR CodePage;
  2543. UCHAR ParameterLength;
  2544. UCHAR Immediate;
  2545. UCHAR Reserved[2];
  2546. UCHAR LbaFormat;
  2547. UCHAR LogicalBlocksPerSecond[2];
  2548. PORT_OUTPUT PortOutput[4];
  2549. } AUDIO_OUTPUT, *PAUDIO_OUTPUT;
  2550. #pragma pack(pop, audio_output)
  2551. //
  2552. // Multisession CDROM
  2553. //
  2554. #define GET_LAST_SESSION 0x01
  2555. #define GET_SESSION_DATA 0x02;
  2556. //
  2557. // Atapi 2.5 changer
  2558. //
  2559. #pragma pack(push, chgr_stuff, 1)
  2560. typedef struct _MECHANICAL_STATUS_INFORMATION_HEADER {
  2561. UCHAR CurrentSlot : 5;
  2562. UCHAR ChangerState : 2;
  2563. UCHAR Fault : 1;
  2564. UCHAR Reserved : 5;
  2565. UCHAR MechanismState : 3;
  2566. UCHAR CurrentLogicalBlockAddress[3];
  2567. UCHAR NumberAvailableSlots;
  2568. UCHAR SlotTableLength[2];
  2569. } MECHANICAL_STATUS_INFORMATION_HEADER, *PMECHANICAL_STATUS_INFORMATION_HEADER;
  2570. typedef struct _SLOT_TABLE_INFORMATION {
  2571. UCHAR DiscChanged : 1;
  2572. UCHAR Reserved : 6;
  2573. UCHAR DiscPresent : 1;
  2574. UCHAR Reserved2[3];
  2575. } SLOT_TABLE_INFORMATION, *PSLOT_TABLE_INFORMATION;
  2576. typedef struct _MECHANICAL_STATUS {
  2577. MECHANICAL_STATUS_INFORMATION_HEADER MechanicalStatusHeader;
  2578. SLOT_TABLE_INFORMATION SlotTableInfo[1];
  2579. } MECHANICAL_STATUS, *PMECHANICAL_STATUS;
  2580. #pragma pack(pop, chgr_stuff)
  2581. // begin_ntminitape
  2582. //
  2583. // Tape definitions
  2584. //
  2585. #pragma pack(push, tape_position, 1)
  2586. typedef struct _TAPE_POSITION_DATA {
  2587. UCHAR Reserved1:2;
  2588. UCHAR BlockPositionUnsupported:1;
  2589. UCHAR Reserved2:3;
  2590. UCHAR EndOfPartition:1;
  2591. UCHAR BeginningOfPartition:1;
  2592. UCHAR PartitionNumber;
  2593. USHORT Reserved3;
  2594. UCHAR FirstBlock[4];
  2595. UCHAR LastBlock[4];
  2596. UCHAR Reserved4;
  2597. UCHAR NumberOfBlocks[3];
  2598. UCHAR NumberOfBytes[4];
  2599. } TAPE_POSITION_DATA, *PTAPE_POSITION_DATA;
  2600. #pragma pack(pop, tape_position)
  2601. //
  2602. // This structure is used to convert little endian
  2603. // ULONGs to SCSI CDB big endians values.
  2604. //
  2605. #pragma pack(push, byte_stuff, 1)
  2606. typedef union _EIGHT_BYTE {
  2607. struct {
  2608. UCHAR Byte0;
  2609. UCHAR Byte1;
  2610. UCHAR Byte2;
  2611. UCHAR Byte3;
  2612. UCHAR Byte4;
  2613. UCHAR Byte5;
  2614. UCHAR Byte6;
  2615. UCHAR Byte7;
  2616. };
  2617. ULONGLONG AsULongLong;
  2618. } EIGHT_BYTE, *PEIGHT_BYTE;
  2619. typedef union _FOUR_BYTE {
  2620. struct {
  2621. UCHAR Byte0;
  2622. UCHAR Byte1;
  2623. UCHAR Byte2;
  2624. UCHAR Byte3;
  2625. };
  2626. ULONG AsULong;
  2627. } FOUR_BYTE, *PFOUR_BYTE;
  2628. typedef union _TWO_BYTE {
  2629. struct {
  2630. UCHAR Byte0;
  2631. UCHAR Byte1;
  2632. };
  2633. USHORT AsUShort;
  2634. } TWO_BYTE, *PTWO_BYTE;
  2635. #pragma pack(pop, byte_stuff)
  2636. //
  2637. // Byte reversing macro for converting
  2638. // between big- and little-endian formats
  2639. //
  2640. #define REVERSE_BYTES_QUAD(Destination, Source) { \
  2641. PEIGHT_BYTE d = (PEIGHT_BYTE)(Destination); \
  2642. PEIGHT_BYTE s = (PEIGHT_BYTE)(Source); \
  2643. d->Byte7 = s->Byte0; \
  2644. d->Byte6 = s->Byte1; \
  2645. d->Byte5 = s->Byte2; \
  2646. d->Byte4 = s->Byte3; \
  2647. d->Byte3 = s->Byte4; \
  2648. d->Byte2 = s->Byte5; \
  2649. d->Byte1 = s->Byte6; \
  2650. d->Byte0 = s->Byte7; \
  2651. }
  2652. #define REVERSE_BYTES(Destination, Source) { \
  2653. PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
  2654. PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
  2655. d->Byte3 = s->Byte0; \
  2656. d->Byte2 = s->Byte1; \
  2657. d->Byte1 = s->Byte2; \
  2658. d->Byte0 = s->Byte3; \
  2659. }
  2660. #define REVERSE_BYTES_SHORT(Destination, Source) { \
  2661. PTWO_BYTE d = (PTWO_BYTE)(Destination); \
  2662. PTWO_BYTE s = (PTWO_BYTE)(Source); \
  2663. d->Byte1 = s->Byte0; \
  2664. d->Byte0 = s->Byte1; \
  2665. }
  2666. //
  2667. // Byte reversing macro for converting
  2668. // USHORTS from big to little endian in place
  2669. //
  2670. #define REVERSE_SHORT(Short) { \
  2671. UCHAR tmp; \
  2672. PTWO_BYTE w = (PTWO_BYTE)(Short); \
  2673. tmp = w->Byte0; \
  2674. w->Byte0 = w->Byte1; \
  2675. w->Byte1 = tmp; \
  2676. }
  2677. //
  2678. // Byte reversing macro for convering
  2679. // ULONGS between big & little endian in place
  2680. //
  2681. #define REVERSE_LONG(Long) { \
  2682. UCHAR tmp; \
  2683. PFOUR_BYTE l = (PFOUR_BYTE)(Long); \
  2684. tmp = l->Byte3; \
  2685. l->Byte3 = l->Byte0; \
  2686. l->Byte0 = tmp; \
  2687. tmp = l->Byte2; \
  2688. l->Byte2 = l->Byte1; \
  2689. l->Byte1 = tmp; \
  2690. }
  2691. //
  2692. // This macro has the effect of Bit = log2(Data)
  2693. //
  2694. #define WHICH_BIT(Data, Bit) { \
  2695. UCHAR tmp; \
  2696. for (tmp = 0; tmp < 32; tmp++) { \
  2697. if (((Data) >> tmp) == 1) { \
  2698. break; \
  2699. } \
  2700. } \
  2701. ASSERT(tmp != 32); \
  2702. (Bit) = tmp; \
  2703. }
  2704. // end_ntminitape
  2705. #pragma pack(pop, _scsi_) // restore original packing level
  2706. #if _MSC_VER >= 1200
  2707. #pragma warning(pop) // un-sets any local warning changes
  2708. #else
  2709. #pragma warning(default:4200) // array[0] is not a warning for this file
  2710. #endif
  2711. #endif // !defined _NTSCSI_