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.

4350 lines
117 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. storport.h
  5. Abstract:
  6. These are the structures and defines that are included by STORPORT miniport
  7. drivers.
  8. Authors:
  9. Revision History:
  10. --*/
  11. #ifdef _NTSCSI_
  12. #error "STORPORT.H must be included instead of SCSI.H"
  13. #endif
  14. #ifdef _NTSRB_
  15. #error "STORPORT.H must be included instead of SRB.H"
  16. #endif
  17. #ifndef _NTSTORPORT_
  18. #define _NTSTORPORT_
  19. #if _MSC_VER >= 1200
  20. #pragma warning(push)
  21. #endif
  22. #pragma warning(disable:4200) // array[0] is not a warning for this file
  23. //
  24. // For backwards compatability, use SCSIPORT definitions.
  25. //
  26. #if DBG
  27. #define DebugPrint(x) StorPortDebugPrint x
  28. #else
  29. #define DebugPrint(x)
  30. #endif
  31. //
  32. // Define SCSI maximum configuration parameters.
  33. //
  34. #define SCSI_MAXIMUM_LOGICAL_UNITS 8
  35. #define SCSI_MAXIMUM_TARGETS_PER_BUS 128
  36. #define SCSI_MAXIMUM_LUNS_PER_TARGET 255
  37. #define SCSI_MAXIMUM_BUSES 8
  38. #define SCSI_MINIMUM_PHYSICAL_BREAKS 16
  39. #define SCSI_MAXIMUM_PHYSICAL_BREAKS 255
  40. #define SCSI_COMBINE_BUS_TARGET( Bus, Target ) ( \
  41. ((((UCHAR) (Target)) & ~(0x20 - 1)) << 8) | \
  42. (((UCHAR) (Bus)) << 5) | \
  43. (((UCHAR) (Target)) & (0x20 - 1)))
  44. #define SCSI_DECODE_BUS_TARGET( Value, Bus, Target ) ( \
  45. Bus = (UCHAR) ((Value) >> 5), \
  46. Target = (UCHAR) ((((Value) >> 8) & ~(0x20 - 1)) | ((Value) & (0x20 - 1))))
  47. //
  48. // This constant is for backward compatibility.
  49. // This use to be the maximum number of targets supported.
  50. //
  51. #define SCSI_MAXIMUM_TARGETS 8
  52. typedef PHYSICAL_ADDRESS STOR_PHYSICAL_ADDRESS, *PSTOR_PHYSICAL_ADDRESS;
  53. typedef struct _ACCESS_RANGE {
  54. STOR_PHYSICAL_ADDRESS RangeStart;
  55. ULONG RangeLength;
  56. BOOLEAN RangeInMemory;
  57. } ACCESS_RANGE, *PACCESS_RANGE;
  58. typedef enum _STOR_SYNCHRONIZATION_MODEL {
  59. StorSynchronizeHalfDuplex,
  60. StorSynchronizeFullDuplex
  61. } STOR_SYNCHRONIZATION_MODEL;
  62. #define STOR_MAP_NO_BUFFERS (0)
  63. #define STOR_MAP_ALL_BUFFERS (1)
  64. #define STOR_MAP_NON_READ_WRITE_BUFFERS (2)
  65. //
  66. // Configuration information structure. Contains the information necessary
  67. // to initialize the adapter. NOTE: This structure must be a multiple of
  68. // quadwords.
  69. //
  70. typedef struct _PORT_CONFIGURATION_INFORMATION {
  71. //
  72. // Length of port configuation information strucuture.
  73. //
  74. ULONG Length;
  75. //
  76. // IO bus number (0 for machines that have only 1 IO bus
  77. //
  78. ULONG SystemIoBusNumber;
  79. //
  80. // EISA, MCA or ISA
  81. //
  82. INTERFACE_TYPE AdapterInterfaceType;
  83. //
  84. // Interrupt request level for device
  85. //
  86. ULONG BusInterruptLevel;
  87. //
  88. // Bus interrupt vector used with hardware buses which use as vector as
  89. // well as level, such as internal buses.
  90. //
  91. ULONG BusInterruptVector;
  92. //
  93. // Interrupt mode (level-sensitive or edge-triggered)
  94. //
  95. KINTERRUPT_MODE InterruptMode;
  96. //
  97. // Maximum number of bytes that can be transferred in a single SRB
  98. //
  99. ULONG MaximumTransferLength;
  100. //
  101. // Number of contiguous blocks of physical memory
  102. //
  103. ULONG NumberOfPhysicalBreaks;
  104. //
  105. // DMA channel for devices using system DMA
  106. //
  107. ULONG DmaChannel;
  108. ULONG DmaPort;
  109. DMA_WIDTH DmaWidth;
  110. DMA_SPEED DmaSpeed;
  111. //
  112. // Alignment masked required by the adapter for data transfers.
  113. //
  114. ULONG AlignmentMask;
  115. //
  116. // Number of access range elements which have been allocated.
  117. //
  118. ULONG NumberOfAccessRanges;
  119. //
  120. // Pointer to array of access range elements.
  121. //
  122. ACCESS_RANGE (*AccessRanges)[];
  123. //
  124. // Reserved field.
  125. //
  126. PVOID Reserved;
  127. //
  128. // Number of SCSI buses attached to the adapter.
  129. //
  130. UCHAR NumberOfBuses;
  131. //
  132. // SCSI bus ID for adapter
  133. //
  134. CCHAR InitiatorBusId[8];
  135. //
  136. // Indicates that the adapter does scatter/gather
  137. //
  138. BOOLEAN ScatterGather;
  139. //
  140. // Indicates that the adapter is a bus master
  141. //
  142. BOOLEAN Master;
  143. //
  144. // Host caches data or state.
  145. //
  146. BOOLEAN CachesData;
  147. //
  148. // Host adapter scans down for bios devices.
  149. //
  150. BOOLEAN AdapterScansDown;
  151. //
  152. // Primary at disk address (0x1F0) claimed.
  153. //
  154. BOOLEAN AtdiskPrimaryClaimed;
  155. //
  156. // Secondary at disk address (0x170) claimed.
  157. //
  158. BOOLEAN AtdiskSecondaryClaimed;
  159. //
  160. // The master uses 32-bit DMA addresses.
  161. //
  162. BOOLEAN Dma32BitAddresses;
  163. //
  164. // Use Demand Mode DMA rather than Single Request.
  165. //
  166. BOOLEAN DemandMode;
  167. //
  168. // Data buffers must be mapped into virtual address space.
  169. //
  170. UCHAR MapBuffers;
  171. //
  172. // The driver will need to tranlate virtual to physical addresses.
  173. //
  174. BOOLEAN NeedPhysicalAddresses;
  175. //
  176. // Supports tagged queuing
  177. //
  178. BOOLEAN TaggedQueuing;
  179. //
  180. // Supports auto request sense.
  181. //
  182. BOOLEAN AutoRequestSense;
  183. //
  184. // Supports multiple requests per logical unit.
  185. //
  186. BOOLEAN MultipleRequestPerLu;
  187. //
  188. // Support receive event function.
  189. //
  190. BOOLEAN ReceiveEvent;
  191. //
  192. // Indicates the real-mode driver has initialized the card.
  193. //
  194. BOOLEAN RealModeInitialized;
  195. //
  196. // Indicate that the miniport will not touch the data buffers directly.
  197. //
  198. BOOLEAN BufferAccessScsiPortControlled;
  199. //
  200. // Indicator for wide scsi.
  201. //
  202. UCHAR MaximumNumberOfTargets;
  203. //
  204. // Ensure quadword alignment.
  205. //
  206. UCHAR ReservedUchars[2];
  207. //
  208. // Adapter slot number
  209. //
  210. ULONG SlotNumber;
  211. //
  212. // Interrupt information for a second IRQ.
  213. //
  214. ULONG BusInterruptLevel2;
  215. ULONG BusInterruptVector2;
  216. KINTERRUPT_MODE InterruptMode2;
  217. //
  218. // DMA information for a second channel.
  219. //
  220. ULONG DmaChannel2;
  221. ULONG DmaPort2;
  222. DMA_WIDTH DmaWidth2;
  223. DMA_SPEED DmaSpeed2;
  224. //
  225. // Fields added to allow for the miniport
  226. // to update these sizes based on requirements
  227. // for large transfers ( > 64K);
  228. //
  229. ULONG DeviceExtensionSize;
  230. ULONG SpecificLuExtensionSize;
  231. ULONG SrbExtensionSize;
  232. //
  233. // Used to determine whether the system and/or the miniport support
  234. // 64-bit physical addresses. See SCSI_DMA64_* flags below.
  235. //
  236. UCHAR Dma64BitAddresses; /* New */
  237. //
  238. // Indicates that the miniport can accept a SRB_FUNCTION_RESET_DEVICE
  239. // to clear all requests to a particular LUN.
  240. //
  241. BOOLEAN ResetTargetSupported; /* New */
  242. //
  243. // Indicates that the miniport can support more than 8 logical units per
  244. // target (maximum LUN number is one less than this field).
  245. //
  246. UCHAR MaximumNumberOfLogicalUnits; /* New */
  247. //
  248. // Supports WMI?
  249. //
  250. BOOLEAN WmiDataProvider;
  251. //
  252. // STORPORT synchronization model, either half or full duplex
  253. // depending on whether the driver supports async-with-interrupt
  254. // model or not.
  255. //
  256. STOR_SYNCHRONIZATION_MODEL SynchronizationModel; // STORPORT New
  257. } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
  258. //
  259. // Version control for ConfigInfo structure.
  260. //
  261. #define CONFIG_INFO_VERSION_2 sizeof(PORT_CONFIGURATION_INFORMATION)
  262. //
  263. // Flags for controlling 64-bit DMA use (PORT_CONFIGURATION_INFORMATION field
  264. // Dma64BitAddresses)
  265. //
  266. //
  267. // Set by scsiport on entering HwFindAdapter if the system can support 64-bit
  268. // physical addresses. The miniport can use this information before calling
  269. // ScsiPortGetUncachedExtension to modify the DeviceExtensionSize,
  270. // SpecificLuExtensionSize & SrbExtensionSize fields to account for the extra
  271. // size of the scatter gather list.
  272. //
  273. #define SCSI_DMA64_SYSTEM_SUPPORTED 0x80
  274. //
  275. // Set by the miniport before calling ScsiPortGetUncachedExtension to indicate
  276. // that scsiport should provide it with 64-bit physical addresses. If the
  277. // system does not support 64-bit PA's then this bit will be ignored.
  278. //
  279. #define SCSI_DMA64_MINIPORT_SUPPORTED 0x01
  280. //
  281. // Command type (and parameter) definition(s) for AdapterControl requests.
  282. //
  283. typedef enum _SCSI_ADAPTER_CONTROL_TYPE {
  284. ScsiQuerySupportedControlTypes = 0,
  285. ScsiStopAdapter,
  286. ScsiRestartAdapter,
  287. ScsiSetBootConfig,
  288. ScsiSetRunningConfig,
  289. ScsiAdapterControlMax,
  290. MakeAdapterControlTypeSizeOfUlong = 0xffffffff
  291. } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
  292. //
  293. // Adapter control status values
  294. //
  295. typedef enum _SCSI_ADAPTER_CONTROL_STATUS {
  296. ScsiAdapterControlSuccess = 0,
  297. ScsiAdapterControlUnsuccessful
  298. } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
  299. //
  300. // Parameters for Adapter Control Functions:
  301. //
  302. //
  303. // ScsiQuerySupportedControlTypes:
  304. //
  305. typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST {
  306. //
  307. // Specifies the number of entries in the adapter control type list.
  308. //
  309. IN ULONG MaxControlType;
  310. //
  311. // The miniport will set TRUE for each control type it supports.
  312. // The number of entries in this array is defined by MaxAdapterControlType
  313. // - the miniport must not attempt to set any AC types beyond the maximum
  314. // value specified.
  315. //
  316. OUT BOOLEAN SupportedTypeList[0];
  317. } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST;
  318. //
  319. // Uninitialized flag value.
  320. //
  321. #define SP_UNINITIALIZED_VALUE ((ULONG) ~0)
  322. #define SP_UNTAGGED ((UCHAR) ~0)
  323. //
  324. // Set asynchronous events.
  325. //
  326. #define SRBEV_BUS_RESET 0x0001
  327. #define SRBEV_SCSI_ASYNC_NOTIFICATION 0x0002
  328. #define MAXIMUM_CDB_SIZE 12
  329. //
  330. // SCSI I/O Request Block
  331. //
  332. typedef struct _SCSI_REQUEST_BLOCK {
  333. USHORT Length; // offset 0
  334. UCHAR Function; // offset 2
  335. UCHAR SrbStatus; // offset 3
  336. UCHAR ScsiStatus; // offset 4
  337. UCHAR PathId; // offset 5
  338. UCHAR TargetId; // offset 6
  339. UCHAR Lun; // offset 7
  340. UCHAR QueueTag; // offset 8
  341. UCHAR QueueAction; // offset 9
  342. UCHAR CdbLength; // offset a
  343. UCHAR SenseInfoBufferLength; // offset b
  344. ULONG SrbFlags; // offset c
  345. ULONG DataTransferLength; // offset 10
  346. ULONG TimeOutValue; // offset 14
  347. PVOID DataBuffer; // offset 18
  348. PVOID SenseInfoBuffer; // offset 1c
  349. struct _SCSI_REQUEST_BLOCK *NextSrb; // offset 20
  350. PVOID OriginalRequest; // offset 24
  351. PVOID SrbExtension; // offset 28
  352. union {
  353. ULONG InternalStatus; // offset 2c
  354. ULONG QueueSortKey; // offset 2c
  355. ULONG LinkTimeoutValue; // offset 2c
  356. };
  357. #if defined(_WIN64)
  358. //
  359. // Force PVOID alignment of Cdb
  360. //
  361. ULONG Reserved;
  362. #endif
  363. UCHAR Cdb[16]; // offset 30
  364. } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
  365. #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
  366. //
  367. // SCSI I/O Request Block for WMI Requests
  368. //
  369. typedef struct _SCSI_WMI_REQUEST_BLOCK {
  370. USHORT Length;
  371. UCHAR Function; // SRB_FUNCTION_WMI
  372. UCHAR SrbStatus;
  373. UCHAR WMISubFunction;
  374. UCHAR PathId; // If SRB_WMI_FLAGS_ADAPTER_REQUEST is set in
  375. UCHAR TargetId; // WMIFlags then PathId, TargetId and Lun are
  376. UCHAR Lun; // reserved fields.
  377. UCHAR Reserved1;
  378. UCHAR WMIFlags;
  379. UCHAR Reserved2[2];
  380. ULONG SrbFlags;
  381. ULONG DataTransferLength;
  382. ULONG TimeOutValue;
  383. PVOID DataBuffer;
  384. PVOID DataPath;
  385. PVOID Reserved3;
  386. PVOID OriginalRequest;
  387. PVOID SrbExtension;
  388. ULONG Reserved4;
  389. UCHAR Reserved5[16];
  390. } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
  391. //
  392. // SRB Functions
  393. //
  394. #define SRB_FUNCTION_EXECUTE_SCSI 0x00
  395. #define SRB_FUNCTION_CLAIM_DEVICE 0x01
  396. #define SRB_FUNCTION_IO_CONTROL 0x02
  397. #define SRB_FUNCTION_RECEIVE_EVENT 0x03
  398. #define SRB_FUNCTION_RELEASE_QUEUE 0x04
  399. #define SRB_FUNCTION_ATTACH_DEVICE 0x05
  400. #define SRB_FUNCTION_RELEASE_DEVICE 0x06
  401. #define SRB_FUNCTION_SHUTDOWN 0x07
  402. #define SRB_FUNCTION_FLUSH 0x08
  403. #define SRB_FUNCTION_ABORT_COMMAND 0x10
  404. #define SRB_FUNCTION_RELEASE_RECOVERY 0x11
  405. #define SRB_FUNCTION_RESET_BUS 0x12
  406. #define SRB_FUNCTION_RESET_DEVICE 0x13
  407. #define SRB_FUNCTION_TERMINATE_IO 0x14
  408. #define SRB_FUNCTION_FLUSH_QUEUE 0x15
  409. #define SRB_FUNCTION_REMOVE_DEVICE 0x16
  410. #define SRB_FUNCTION_WMI 0x17
  411. #define SRB_FUNCTION_LOCK_QUEUE 0x18
  412. #define SRB_FUNCTION_UNLOCK_QUEUE 0x19
  413. #define SRB_FUNCTION_RESET_LOGICAL_UNIT 0x20
  414. #define SRB_FUNCTION_SET_LINK_TIMEOUT 0x21
  415. #define SRB_FUNCTION_LINK_TIMEOUT_OCCURRED 0x22
  416. #define SRB_FUNCTION_LINK_TIMEOUT_COMPLETE 0x23
  417. //
  418. // SRB Status
  419. //
  420. #define SRB_STATUS_PENDING 0x00
  421. #define SRB_STATUS_SUCCESS 0x01
  422. #define SRB_STATUS_ABORTED 0x02
  423. #define SRB_STATUS_ABORT_FAILED 0x03
  424. #define SRB_STATUS_ERROR 0x04
  425. #define SRB_STATUS_BUSY 0x05
  426. #define SRB_STATUS_INVALID_REQUEST 0x06
  427. #define SRB_STATUS_INVALID_PATH_ID 0x07
  428. #define SRB_STATUS_NO_DEVICE 0x08
  429. #define SRB_STATUS_TIMEOUT 0x09
  430. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  431. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  432. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  433. #define SRB_STATUS_BUS_RESET 0x0E
  434. #define SRB_STATUS_PARITY_ERROR 0x0F
  435. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  436. #define SRB_STATUS_NO_HBA 0x11
  437. #define SRB_STATUS_DATA_OVERRUN 0x12
  438. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  439. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  440. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  441. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  442. #define SRB_STATUS_INVALID_LUN 0x20
  443. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  444. #define SRB_STATUS_BAD_FUNCTION 0x22
  445. #define SRB_STATUS_ERROR_RECOVERY 0x23
  446. #define SRB_STATUS_NOT_POWERED 0x24
  447. #define SRB_STATUS_LINK_DOWN 0x25
  448. //
  449. // This value is used by the port driver to indicate that a non-scsi-related
  450. // error occured. Miniports must never return this status.
  451. //
  452. #define SRB_STATUS_INTERNAL_ERROR 0x30
  453. //
  454. // Srb status values 0x38 through 0x3f are reserved for internal port driver
  455. // use.
  456. //
  457. //
  458. // SRB Status Masks
  459. //
  460. #define SRB_STATUS_QUEUE_FROZEN 0x40
  461. #define SRB_STATUS_AUTOSENSE_VALID 0x80
  462. #define SRB_STATUS(Status) (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
  463. //
  464. // SRB Flag Bits
  465. //
  466. #define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002
  467. #define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004
  468. #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008
  469. #define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010
  470. #define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020
  471. #define SRB_FLAGS_DATA_IN 0x00000040
  472. #define SRB_FLAGS_DATA_OUT 0x00000080
  473. #define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
  474. #define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
  475. #define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100
  476. #define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200
  477. #define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400
  478. #define SRB_FLAGS_IS_ACTIVE 0x00010000
  479. #define SRB_FLAGS_ALLOCATED_FROM_ZONE 0x00020000
  480. #define SRB_FLAGS_SGLIST_FROM_POOL 0x00040000
  481. #define SRB_FLAGS_BYPASS_LOCKED_QUEUE 0x00080000
  482. #define SRB_FLAGS_NO_KEEP_AWAKE 0x00100000
  483. #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE 0x00200000
  484. #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT 0x00400000
  485. #define SRB_FLAGS_DONT_START_NEXT_PACKET 0x00800000
  486. #define SRB_FLAGS_PORT_DRIVER_RESERVED 0x0F000000
  487. #define SRB_FLAGS_CLASS_DRIVER_RESERVED 0xF0000000
  488. #if DBG==1
  489. //
  490. // A signature used to validate the scsi port number
  491. // at the end of a sense buffer.
  492. //
  493. #define SCSI_PORT_SIGNATURE 0x54524f50
  494. #endif
  495. //
  496. // Queue Action
  497. //
  498. #define SRB_SIMPLE_TAG_REQUEST 0x20
  499. #define SRB_HEAD_OF_QUEUE_TAG_REQUEST 0x21
  500. #define SRB_ORDERED_QUEUE_TAG_REQUEST 0x22
  501. #define SRB_WMI_FLAGS_ADAPTER_REQUEST 0x01
  502. //
  503. // SCSI Adapter Dependent Routines
  504. //
  505. typedef
  506. BOOLEAN
  507. (*PHW_INITIALIZE) (
  508. IN PVOID DeviceExtension
  509. );
  510. typedef
  511. BOOLEAN
  512. (*PHW_BUILDIO) (
  513. IN PVOID DeviceExtension,
  514. IN PSCSI_REQUEST_BLOCK Srb
  515. );
  516. typedef
  517. BOOLEAN
  518. (*PHW_STARTIO) (
  519. IN PVOID DeviceExtension,
  520. IN PSCSI_REQUEST_BLOCK Srb
  521. );
  522. typedef
  523. BOOLEAN
  524. (*PHW_INTERRUPT) (
  525. IN PVOID DeviceExtension
  526. );
  527. typedef
  528. VOID
  529. (*PHW_TIMER) (
  530. IN PVOID DeviceExtension
  531. );
  532. typedef
  533. VOID
  534. (*PHW_DMA_STARTED) (
  535. IN PVOID DeviceExtension
  536. );
  537. typedef
  538. ULONG
  539. (*PHW_FIND_ADAPTER) (
  540. IN PVOID DeviceExtension,
  541. IN PVOID HwContext,
  542. IN PVOID BusInformation,
  543. IN PCHAR ArgumentString,
  544. IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
  545. OUT PBOOLEAN Again
  546. );
  547. typedef
  548. BOOLEAN
  549. (*PHW_RESET_BUS) (
  550. IN PVOID DeviceExtension,
  551. IN ULONG PathId
  552. );
  553. typedef
  554. BOOLEAN
  555. (*PHW_ADAPTER_STATE) (
  556. IN PVOID DeviceExtension,
  557. IN PVOID Context,
  558. IN BOOLEAN SaveState
  559. );
  560. typedef
  561. SCSI_ADAPTER_CONTROL_STATUS
  562. (*PHW_ADAPTER_CONTROL) (
  563. IN PVOID DeviceExtension,
  564. IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
  565. IN PVOID Parameters
  566. );
  567. //
  568. // Port driver error codes
  569. //
  570. #define SP_BUS_PARITY_ERROR 0x0001
  571. #define SP_UNEXPECTED_DISCONNECT 0x0002
  572. #define SP_INVALID_RESELECTION 0x0003
  573. #define SP_BUS_TIME_OUT 0x0004
  574. #define SP_PROTOCOL_ERROR 0x0005
  575. #define SP_INTERNAL_ADAPTER_ERROR 0x0006
  576. #define SP_REQUEST_TIMEOUT 0x0007
  577. #define SP_IRQ_NOT_RESPONDING 0x0008
  578. #define SP_BAD_FW_WARNING 0x0009
  579. #define SP_BAD_FW_ERROR 0x000a
  580. #define SP_LOST_WMI_MINIPORT_REQUEST 0x000b
  581. //
  582. // Return values for SCSI_HW_FIND_ADAPTER.
  583. //
  584. #define SP_RETURN_NOT_FOUND 0
  585. #define SP_RETURN_FOUND 1
  586. #define SP_RETURN_ERROR 2
  587. #define SP_RETURN_BAD_CONFIG 3
  588. //
  589. // Notification Event Types
  590. //
  591. typedef enum _SCSI_NOTIFICATION_TYPE {
  592. RequestComplete,
  593. NextRequest,
  594. NextLuRequest,
  595. ResetDetected,
  596. _obsolete1, // STORPORT: CallDisableInterrupts has been removed
  597. _obsolete2, // STORPORT: CallEnableInterrupts has been removed
  598. RequestTimerCall,
  599. BusChangeDetected,
  600. WMIEvent,
  601. WMIReregister,
  602. LinkUp,
  603. LinkDown
  604. } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
  605. //
  606. // Structure passed between miniport initialization
  607. // and SCSI port initialization
  608. //
  609. typedef struct _HW_INITIALIZATION_DATA {
  610. ULONG HwInitializationDataSize;
  611. //
  612. // Adapter interface type:
  613. //
  614. // Internal
  615. // Isa
  616. // Eisa
  617. // MicroChannel
  618. // TurboChannel
  619. // PCIBus
  620. // VMEBus
  621. // NuBus
  622. // PCMCIABus
  623. // CBus
  624. // MPIBus
  625. // MPSABus
  626. //
  627. INTERFACE_TYPE AdapterInterfaceType;
  628. //
  629. // Miniport driver routines
  630. //
  631. PHW_INITIALIZE HwInitialize;
  632. PHW_STARTIO HwStartIo;
  633. PHW_INTERRUPT HwInterrupt;
  634. PHW_FIND_ADAPTER HwFindAdapter;
  635. PHW_RESET_BUS HwResetBus;
  636. PHW_DMA_STARTED HwDmaStarted;
  637. PHW_ADAPTER_STATE HwAdapterState;
  638. //
  639. // Miniport driver resources
  640. //
  641. ULONG DeviceExtensionSize;
  642. ULONG SpecificLuExtensionSize;
  643. ULONG SrbExtensionSize;
  644. ULONG NumberOfAccessRanges;
  645. PVOID Reserved;
  646. //
  647. // Data buffers must be mapped into virtual address space.
  648. //
  649. UCHAR MapBuffers;
  650. //
  651. // The driver will need to tranlate virtual to physical addresses.
  652. //
  653. BOOLEAN NeedPhysicalAddresses;
  654. //
  655. // Supports tagged queuing
  656. //
  657. BOOLEAN TaggedQueuing;
  658. //
  659. // Supports auto request sense.
  660. //
  661. BOOLEAN AutoRequestSense;
  662. //
  663. // Supports multiple requests per logical unit.
  664. //
  665. BOOLEAN MultipleRequestPerLu;
  666. //
  667. // Support receive event function.
  668. //
  669. BOOLEAN ReceiveEvent;
  670. //
  671. // Vendor identification length
  672. //
  673. USHORT VendorIdLength;
  674. //
  675. // Vendor identification
  676. //
  677. PVOID VendorId;
  678. //
  679. // Pad for alignment and future use.
  680. //
  681. USHORT ReservedUshort;
  682. //
  683. // Device identification length
  684. //
  685. USHORT DeviceIdLength;
  686. //
  687. // Device identification
  688. //
  689. PVOID DeviceId;
  690. //
  691. // Stop adapter routine.
  692. //
  693. PHW_ADAPTER_CONTROL HwAdapterControl;
  694. //
  695. // Initialize to the Build IO routine if one is supported, otherwise
  696. // should be NULL.
  697. //
  698. PHW_BUILDIO HwBuildIo; // STORPORT New
  699. } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
  700. //
  701. // Scatter/gather lists
  702. //
  703. typedef struct _STOR_SCATTER_GATHER_ELEMENT {
  704. STOR_PHYSICAL_ADDRESS PhysicalAddress;
  705. ULONG Length;
  706. ULONG_PTR Reserved;
  707. } STOR_SCATTER_GATHER_ELEMENT, *PSTOR_SCATTER_GATHER_ELEMENT;
  708. typedef struct _STOR_SCATTER_GATHER_LIST {
  709. ULONG NumberOfElements;
  710. ULONG_PTR Reserved;
  711. STOR_SCATTER_GATHER_ELEMENT List[];
  712. } STOR_SCATTER_GATHER_LIST, *PSTOR_SCATTER_GATHER_LIST;
  713. typedef
  714. BOOLEAN
  715. (*PSTOR_SYNCHRONIZED_ACCESS)(
  716. IN PVOID HwDeviceExtension,
  717. IN PVOID Context
  718. );
  719. #ifndef _NTDDK_
  720. #define STORPORT_API DECLSPEC_IMPORT
  721. #else
  722. #define STORPORT_API
  723. #endif
  724. //
  725. // Port driver routines called by miniport driver
  726. //
  727. STORPORT_API
  728. ULONG
  729. StorPortInitialize(
  730. IN PVOID Argument1,
  731. IN PVOID Argument2,
  732. IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
  733. IN PVOID HwContext
  734. );
  735. STORPORT_API
  736. VOID
  737. StorPortFreeDeviceBase(
  738. IN PVOID HwDeviceExtension,
  739. IN PVOID MappedAddress
  740. );
  741. STORPORT_API
  742. ULONG
  743. StorPortGetBusData(
  744. IN PVOID DeviceExtension,
  745. IN ULONG BusDataType,
  746. IN ULONG SystemIoBusNumber,
  747. IN ULONG SlotNumber,
  748. IN PVOID Buffer,
  749. IN ULONG Length
  750. );
  751. STORPORT_API
  752. ULONG
  753. StorPortSetBusDataByOffset(
  754. IN PVOID DeviceExtension,
  755. IN ULONG BusDataType,
  756. IN ULONG SystemIoBusNumber,
  757. IN ULONG SlotNumber,
  758. IN PVOID Buffer,
  759. IN ULONG Offset,
  760. IN ULONG Length
  761. );
  762. STORPORT_API
  763. PVOID
  764. StorPortGetDeviceBase(
  765. IN PVOID HwDeviceExtension,
  766. IN INTERFACE_TYPE BusType,
  767. IN ULONG SystemIoBusNumber,
  768. IN STOR_PHYSICAL_ADDRESS IoAddress,
  769. IN ULONG NumberOfBytes,
  770. IN BOOLEAN InIoSpace
  771. );
  772. STORPORT_API
  773. PVOID
  774. StorPortGetLogicalUnit(
  775. IN PVOID HwDeviceExtension,
  776. IN UCHAR PathId,
  777. IN UCHAR TargetId,
  778. IN UCHAR Lun
  779. );
  780. STORPORT_API
  781. PSTOR_SCATTER_GATHER_LIST
  782. StorPortGetScatterGatherList(
  783. IN PVOID HwDeviceExtension,
  784. IN PSCSI_REQUEST_BLOCK Srb
  785. );
  786. STORPORT_API
  787. STOR_PHYSICAL_ADDRESS
  788. StorPortGetPhysicalAddress(
  789. IN PVOID HwDeviceExtension,
  790. IN PSCSI_REQUEST_BLOCK Srb,
  791. IN PVOID VirtualAddress,
  792. OUT ULONG *Length
  793. );
  794. STORPORT_API
  795. PVOID
  796. StorPortGetVirtualAddress(
  797. IN PVOID HwDeviceExtension,
  798. IN STOR_PHYSICAL_ADDRESS PhysicalAddress
  799. );
  800. STORPORT_API
  801. PVOID
  802. StorPortGetUncachedExtension(
  803. IN PVOID HwDeviceExtension,
  804. IN PPORT_CONFIGURATION_INFORMATION ConfigInfo,
  805. IN ULONG NumberOfBytes
  806. );
  807. STORPORT_API
  808. BOOLEAN
  809. StorPortPauseDevice(
  810. IN PVOID HwDeviceExtension,
  811. IN UCHAR PathId,
  812. IN UCHAR TargetId,
  813. IN UCHAR Lun,
  814. IN ULONG Timeout
  815. );
  816. STORPORT_API
  817. BOOLEAN
  818. StorPortResumeDevice(
  819. IN PVOID HwDeviceExtension,
  820. IN UCHAR PathId,
  821. IN UCHAR TargetId,
  822. IN UCHAR Lun
  823. );
  824. STORPORT_API
  825. BOOLEAN
  826. StorPortPause(
  827. IN PVOID HwDeviceExtension,
  828. IN ULONG Timeout
  829. );
  830. STORPORT_API
  831. BOOLEAN
  832. StorPortResume(
  833. IN PVOID HwDeviceExtension
  834. );
  835. STORPORT_API
  836. BOOLEAN
  837. StorPortDeviceBusy(
  838. IN PVOID HwDeviceExtension,
  839. IN UCHAR PathId,
  840. IN UCHAR TargetId,
  841. IN UCHAR Lun,
  842. IN ULONG RequestsToComplete
  843. );
  844. STORPORT_API
  845. BOOLEAN
  846. StorPortDeviceReady(
  847. IN PVOID HwDeviceExtension,
  848. IN UCHAR PathId,
  849. IN UCHAR TargetId,
  850. IN UCHAR Lun
  851. );
  852. STORPORT_API
  853. BOOLEAN
  854. StorPortBusy(
  855. IN PVOID HwDeviceExtension,
  856. IN ULONG RequestsToComplete
  857. );
  858. STORPORT_API
  859. BOOLEAN
  860. StorPortReady(
  861. IN PVOID HwDeviceExtension
  862. );
  863. STORPORT_API
  864. BOOLEAN
  865. StorPortSetDeviceQueueDepth(
  866. IN PVOID HwDeviceExtension,
  867. IN UCHAR PathId,
  868. IN UCHAR TargetId,
  869. IN UCHAR Lun,
  870. IN ULONG Depth
  871. );
  872. STORPORT_API
  873. VOID
  874. StorPortNotification(
  875. IN SCSI_NOTIFICATION_TYPE NotificationType,
  876. IN PVOID HwDeviceExtension,
  877. ...
  878. );
  879. STORPORT_API
  880. VOID
  881. StorPortLogError(
  882. IN PVOID HwDeviceExtension,
  883. IN PSCSI_REQUEST_BLOCK Srb OPTIONAL,
  884. IN UCHAR PathId,
  885. IN UCHAR TargetId,
  886. IN UCHAR Lun,
  887. IN ULONG ErrorCode,
  888. IN ULONG UniqueId
  889. );
  890. STORPORT_API
  891. VOID
  892. StorPortCompleteRequest(
  893. IN PVOID HwDeviceExtension,
  894. IN UCHAR PathId,
  895. IN UCHAR TargetId,
  896. IN UCHAR Lun,
  897. IN UCHAR SrbStatus
  898. );
  899. STORPORT_API
  900. VOID
  901. StorPortMoveMemory(
  902. IN PVOID WriteBuffer,
  903. IN PVOID ReadBuffer,
  904. IN ULONG Length
  905. );
  906. STORPORT_API
  907. UCHAR
  908. StorPortReadPortUchar(
  909. IN PVOID HwDeviceExtension,
  910. IN PUCHAR Port
  911. );
  912. STORPORT_API
  913. USHORT
  914. StorPortReadPortUshort(
  915. IN PVOID HwDeviceExtension,
  916. IN PUSHORT Port
  917. );
  918. STORPORT_API
  919. ULONG
  920. StorPortReadPortUlong(
  921. IN PVOID HwDeviceExtension,
  922. IN PULONG Port
  923. );
  924. STORPORT_API
  925. VOID
  926. StorPortReadPortBufferUchar(
  927. IN PVOID HwDeviceExtension,
  928. IN PUCHAR Port,
  929. IN PUCHAR Buffer,
  930. IN ULONG Count
  931. );
  932. STORPORT_API
  933. VOID
  934. StorPortReadPortBufferUshort(
  935. IN PVOID HwDeviceExtension,
  936. IN PUSHORT Port,
  937. IN PUSHORT Buffer,
  938. IN ULONG Count
  939. );
  940. STORPORT_API
  941. VOID
  942. StorPortReadPortBufferUlong(
  943. IN PVOID HwDeviceExtension,
  944. IN PULONG Port,
  945. IN PULONG Buffer,
  946. IN ULONG Count
  947. );
  948. STORPORT_API
  949. UCHAR
  950. StorPortReadRegisterUchar(
  951. IN PVOID HwDeviceExtension,
  952. IN PUCHAR Register
  953. );
  954. STORPORT_API
  955. USHORT
  956. StorPortReadRegisterUshort(
  957. IN PVOID HwDeviceExtension,
  958. IN PUSHORT Register
  959. );
  960. STORPORT_API
  961. ULONG
  962. StorPortReadRegisterUlong(
  963. IN PVOID HwDeviceExtension,
  964. IN PULONG Register
  965. );
  966. STORPORT_API
  967. VOID
  968. StorPortReadRegisterBufferUchar(
  969. IN PVOID HwDeviceExtension,
  970. IN PUCHAR Register,
  971. IN PUCHAR Buffer,
  972. IN ULONG Count
  973. );
  974. STORPORT_API
  975. VOID
  976. StorPortReadRegisterBufferUshort(
  977. IN PVOID HwDeviceExtension,
  978. IN PUSHORT Register,
  979. IN PUSHORT Buffer,
  980. IN ULONG Count
  981. );
  982. STORPORT_API
  983. VOID
  984. StorPortReadRegisterBufferUlong(
  985. IN PVOID HwDeviceExtension,
  986. IN PULONG Register,
  987. IN PULONG Buffer,
  988. IN ULONG Count
  989. );
  990. STORPORT_API
  991. VOID
  992. StorPortStallExecution(
  993. IN ULONG Delay
  994. );
  995. STORPORT_API
  996. BOOLEAN
  997. StorPortSynchronizeAccess(
  998. IN PVOID HwDeviceExtension,
  999. IN PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine,
  1000. IN PVOID Context
  1001. );
  1002. STORPORT_API
  1003. VOID
  1004. StorPortWritePortUchar(
  1005. IN PVOID HwDeviceExtension,
  1006. IN PUCHAR Port,
  1007. IN UCHAR Value
  1008. );
  1009. STORPORT_API
  1010. VOID
  1011. StorPortWritePortUshort(
  1012. IN PVOID HwDeviceExtension,
  1013. IN PUSHORT Port,
  1014. IN USHORT Value
  1015. );
  1016. STORPORT_API
  1017. VOID
  1018. StorPortWritePortUlong(
  1019. IN PVOID HwDeviceExtension,
  1020. IN PULONG Port,
  1021. IN ULONG Value
  1022. );
  1023. STORPORT_API
  1024. VOID
  1025. StorPortWritePortBufferUchar(
  1026. IN PVOID HwDeviceExtension,
  1027. IN PUCHAR Port,
  1028. IN PUCHAR Buffer,
  1029. IN ULONG Count
  1030. );
  1031. STORPORT_API
  1032. VOID
  1033. StorPortWritePortBufferUshort(
  1034. IN PVOID HwDeviceExtension,
  1035. IN PUSHORT Port,
  1036. IN PUSHORT Buffer,
  1037. IN ULONG Count
  1038. );
  1039. STORPORT_API
  1040. VOID
  1041. StorPortWritePortBufferUlong(
  1042. IN PVOID HwDeviceExtension,
  1043. IN PULONG Port,
  1044. IN PULONG Buffer,
  1045. IN ULONG Count
  1046. );
  1047. STORPORT_API
  1048. VOID
  1049. StorPortWriteRegisterUchar(
  1050. IN PVOID HwDeviceExtension,
  1051. IN PUCHAR Register,
  1052. IN UCHAR Value
  1053. );
  1054. STORPORT_API
  1055. VOID
  1056. StorPortWriteRegisterUshort(
  1057. IN PVOID HwDeviceExtension,
  1058. IN PUSHORT Register,
  1059. IN USHORT Value
  1060. );
  1061. STORPORT_API
  1062. VOID
  1063. StorPortWriteRegisterUlong(
  1064. IN PVOID HwDeviceExtension,
  1065. IN PULONG Register,
  1066. IN ULONG Value
  1067. );
  1068. STORPORT_API
  1069. VOID
  1070. StorPortWriteRegisterBufferUchar(
  1071. IN PVOID HwDeviceExtension,
  1072. IN PUCHAR Register,
  1073. IN PUCHAR Buffer,
  1074. IN ULONG Count
  1075. );
  1076. STORPORT_API
  1077. VOID
  1078. StorPortWriteRegisterBufferUshort(
  1079. IN PVOID HwDeviceExtension,
  1080. IN PUSHORT Register,
  1081. IN PUSHORT Buffer,
  1082. IN ULONG Count
  1083. );
  1084. STORPORT_API
  1085. VOID
  1086. StorPortWriteRegisterBufferUlong(
  1087. IN PVOID HwDeviceExtension,
  1088. IN PULONG Register,
  1089. IN PULONG Buffer,
  1090. IN ULONG Count
  1091. );
  1092. STORPORT_API
  1093. STOR_PHYSICAL_ADDRESS
  1094. StorPortConvertUlongToPhysicalAddress(
  1095. ULONG_PTR UlongAddress
  1096. );
  1097. STORPORT_API
  1098. ULONG
  1099. StorPortConvertPhysicalAddressToUlong(
  1100. STOR_PHYSICAL_ADDRESS Address
  1101. );
  1102. STORPORT_API
  1103. VOID
  1104. StorPortQuerySystemTime(
  1105. OUT PLARGE_INTEGER CurrentTime
  1106. );
  1107. #define StorPortConvertPhysicalAddressToUlong(Address) ((Address).LowPart)
  1108. #define StorPortConvertPhysicalAddressToULong64(Address) ((Address).QuadPart)
  1109. #define MINIPORT_REG_SZ 1
  1110. #define MINIPORT_REG_BINARY 3
  1111. #define MINIPORT_REG_DWORD 4
  1112. STORPORT_API
  1113. PUCHAR
  1114. StorPortAllocateRegistryBuffer(
  1115. IN PVOID HwDeviceExtension,
  1116. IN PULONG Length
  1117. );
  1118. STORPORT_API
  1119. VOID
  1120. StorPortFreeRegistryBuffer(
  1121. IN PVOID HwDeviceExtension,
  1122. IN PUCHAR Buffer
  1123. );
  1124. BOOLEAN
  1125. StorPortRegistryRead(
  1126. IN PVOID HwDeviceExtension,
  1127. IN PUCHAR ValueName,
  1128. IN ULONG Global,
  1129. IN ULONG Type,
  1130. IN PUCHAR Buffer,
  1131. IN PULONG BufferLength
  1132. );
  1133. STORPORT_API
  1134. BOOLEAN
  1135. StorPortRegistryWrite(
  1136. IN PVOID HwDeviceExtension,
  1137. IN PUCHAR ValueName,
  1138. IN ULONG Global,
  1139. IN ULONG Type,
  1140. IN PUCHAR Buffer,
  1141. IN ULONG BufferLength
  1142. );
  1143. STORPORT_API
  1144. BOOLEAN
  1145. StorPortValidateRange(
  1146. IN PVOID HwDeviceExtension,
  1147. IN INTERFACE_TYPE BusType,
  1148. IN ULONG SystemIoBusNumber,
  1149. IN STOR_PHYSICAL_ADDRESS IoAddress,
  1150. IN ULONG NumberOfBytes,
  1151. IN BOOLEAN InIoSpace
  1152. );
  1153. STORPORT_API
  1154. VOID
  1155. StorPortDebugPrint(
  1156. ULONG DebugPrintLevel,
  1157. PCCHAR DebugMessage,
  1158. ...
  1159. );
  1160. //
  1161. // Command Descriptor Block. Passed by SCSI controller chip over the SCSI bus
  1162. //
  1163. typedef union _CDB {
  1164. //
  1165. // Generic 6-Byte CDB
  1166. //
  1167. struct _CDB6GENERIC {
  1168. UCHAR OperationCode;
  1169. UCHAR Immediate : 1;
  1170. UCHAR CommandUniqueBits : 4;
  1171. UCHAR LogicalUnitNumber : 3;
  1172. UCHAR CommandUniqueBytes[3];
  1173. UCHAR Link : 1;
  1174. UCHAR Flag : 1;
  1175. UCHAR Reserved : 4;
  1176. UCHAR VendorUnique : 2;
  1177. } CDB6GENERIC, *PCDB6GENERIC;
  1178. //
  1179. // Standard 6-byte CDB
  1180. //
  1181. struct _CDB6READWRITE {
  1182. UCHAR OperationCode; // 0x08, 0x0A - SCSIOP_READ, SCSIOP_WRITE
  1183. UCHAR LogicalBlockMsb1 : 5;
  1184. UCHAR LogicalUnitNumber : 3;
  1185. UCHAR LogicalBlockMsb0;
  1186. UCHAR LogicalBlockLsb;
  1187. UCHAR TransferBlocks;
  1188. UCHAR Control;
  1189. } CDB6READWRITE, *PCDB6READWRITE;
  1190. //
  1191. // SCSI-1 Inquiry CDB
  1192. //
  1193. struct _CDB6INQUIRY {
  1194. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  1195. UCHAR Reserved1 : 5;
  1196. UCHAR LogicalUnitNumber : 3;
  1197. UCHAR PageCode;
  1198. UCHAR IReserved;
  1199. UCHAR AllocationLength;
  1200. UCHAR Control;
  1201. } CDB6INQUIRY, *PCDB6INQUIRY;
  1202. //
  1203. // SCSI-3 Inquiry CDB
  1204. //
  1205. struct _CDB6INQUIRY3 {
  1206. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  1207. UCHAR EnableVitalProductData : 1;
  1208. UCHAR CommandSupportData : 1;
  1209. UCHAR Reserved1 : 6;
  1210. UCHAR PageCode;
  1211. UCHAR Reserved2;
  1212. UCHAR AllocationLength;
  1213. UCHAR Control;
  1214. } CDB6INQUIRY3, *PCDB6INQUIRY3;
  1215. struct _CDB6VERIFY {
  1216. UCHAR OperationCode; // 0x13 - SCSIOP_VERIFY
  1217. UCHAR Fixed : 1;
  1218. UCHAR ByteCompare : 1;
  1219. UCHAR Immediate : 1;
  1220. UCHAR Reserved : 2;
  1221. UCHAR LogicalUnitNumber : 3;
  1222. UCHAR VerificationLength[3];
  1223. UCHAR Control;
  1224. } CDB6VERIFY, *PCDB6VERIFY;
  1225. //
  1226. // SCSI Format CDB
  1227. //
  1228. struct _CDB6FORMAT {
  1229. UCHAR OperationCode; // 0x04 - SCSIOP_FORMAT_UNIT
  1230. UCHAR FormatControl : 5;
  1231. UCHAR LogicalUnitNumber : 3;
  1232. UCHAR FReserved1;
  1233. UCHAR InterleaveMsb;
  1234. UCHAR InterleaveLsb;
  1235. UCHAR FReserved2;
  1236. } CDB6FORMAT, *PCDB6FORMAT;
  1237. //
  1238. // Standard 10-byte CDB
  1239. struct _CDB10 {
  1240. UCHAR OperationCode;
  1241. UCHAR RelativeAddress : 1;
  1242. UCHAR Reserved1 : 2;
  1243. UCHAR ForceUnitAccess : 1;
  1244. UCHAR DisablePageOut : 1;
  1245. UCHAR LogicalUnitNumber : 3;
  1246. UCHAR LogicalBlockByte0;
  1247. UCHAR LogicalBlockByte1;
  1248. UCHAR LogicalBlockByte2;
  1249. UCHAR LogicalBlockByte3;
  1250. UCHAR Reserved2;
  1251. UCHAR TransferBlocksMsb;
  1252. UCHAR TransferBlocksLsb;
  1253. UCHAR Control;
  1254. } CDB10, *PCDB10;
  1255. //
  1256. // Standard 12-byte CDB
  1257. //
  1258. struct _CDB12 {
  1259. UCHAR OperationCode;
  1260. UCHAR RelativeAddress : 1;
  1261. UCHAR Reserved1 : 2;
  1262. UCHAR ForceUnitAccess : 1;
  1263. UCHAR DisablePageOut : 1;
  1264. UCHAR LogicalUnitNumber : 3;
  1265. UCHAR LogicalBlock[4];
  1266. UCHAR TransferLength[4];
  1267. UCHAR Reserved2;
  1268. UCHAR Control;
  1269. } CDB12, *PCDB12;
  1270. //
  1271. // CD Rom Audio CDBs
  1272. //
  1273. struct _PAUSE_RESUME {
  1274. UCHAR OperationCode; // 0x4B - SCSIOP_PAUSE_RESUME
  1275. UCHAR Reserved1 : 5;
  1276. UCHAR LogicalUnitNumber : 3;
  1277. UCHAR Reserved2[6];
  1278. UCHAR Action;
  1279. UCHAR Control;
  1280. } PAUSE_RESUME, *PPAUSE_RESUME;
  1281. //
  1282. // Read Table of Contents
  1283. //
  1284. struct _READ_TOC {
  1285. UCHAR OperationCode; // 0x43 - SCSIOP_READ_TOC
  1286. UCHAR Reserved0 : 1;
  1287. UCHAR Msf : 1;
  1288. UCHAR Reserved1 : 3;
  1289. UCHAR LogicalUnitNumber : 3;
  1290. UCHAR Format2 : 4;
  1291. UCHAR Reserved2 : 4;
  1292. UCHAR Reserved3[3];
  1293. UCHAR StartingTrack;
  1294. UCHAR AllocationLength[2];
  1295. UCHAR Control : 6;
  1296. UCHAR Format : 2;
  1297. } READ_TOC, *PREAD_TOC;
  1298. struct _READ_DISK_INFORMATION {
  1299. UCHAR OperationCode; // 0x51 - SCSIOP_READ_DISC_INFORMATION
  1300. UCHAR Reserved1 : 5;
  1301. UCHAR Lun : 3;
  1302. UCHAR Reserved2[5];
  1303. UCHAR AllocationLength[2];
  1304. UCHAR Control;
  1305. } READ_DISK_INFORMATION, *PREAD_DISK_INFORMATION;
  1306. struct _READ_TRACK_INFORMATION {
  1307. UCHAR OperationCode; // 0x52 - SCSIOP_READ_TRACK_INFORMATION
  1308. UCHAR Track : 1;
  1309. UCHAR Reserved1 : 3;
  1310. UCHAR Reserved2 : 1;
  1311. UCHAR Lun : 3;
  1312. UCHAR BlockAddress[4]; // or Track Number
  1313. UCHAR Reserved3;
  1314. UCHAR AllocationLength[2];
  1315. UCHAR Control;
  1316. } READ_TRACK_INFORMATION, *PREAD_TRACK_INFORMATION;
  1317. struct _RESERVE_TRACK_RZONE {
  1318. UCHAR OperationCode; // 0x53 - SCSIOP_RESERVE_TRACK_RZONE
  1319. UCHAR Reserved1[4];
  1320. UCHAR ReservationSize[4];
  1321. UCHAR Control;
  1322. } RESERVE_TRACK_RZONE, *PRESERVE_TRACK_RZONE;
  1323. struct _SEND_OPC_INFORMATION {
  1324. UCHAR OperationCode; // 0x54 - SCSIOP_SEND_OPC_INFORMATION
  1325. UCHAR DoOpc : 1; // perform OPC
  1326. UCHAR Reserved : 7;
  1327. UCHAR Reserved1[5];
  1328. UCHAR ParameterListLength[2];
  1329. UCHAR Reserved2;
  1330. } SEND_OPC_INFORMATION, *PSEND_OPC_INFORMATION;
  1331. struct _CLOSE_TRACK {
  1332. UCHAR OperationCode; // 0x5B - SCSIOP_CLOSE_TRACK_SESSION
  1333. UCHAR Immediate : 1;
  1334. UCHAR Reserved1 : 7;
  1335. UCHAR Track : 1;
  1336. UCHAR Session : 1;
  1337. UCHAR Reserved2 : 6;
  1338. UCHAR Reserved3;
  1339. UCHAR TrackNumber[2];
  1340. UCHAR Reserved4[3];
  1341. UCHAR Control;
  1342. } CLOSE_TRACK, *PCLOSE_TRACK;
  1343. struct _SEND_CUE_SHEET {
  1344. UCHAR OperationCode; // 0x5D - SCSIOP_SEND_CUE_SHEET
  1345. UCHAR Reserved[5];
  1346. UCHAR CueSheetSize[3];
  1347. UCHAR Control;
  1348. } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
  1349. struct _READ_HEADER {
  1350. UCHAR OperationCode; // 0x44 - SCSIOP_READ_HEADER
  1351. UCHAR Reserved1 : 1;
  1352. UCHAR Msf : 1;
  1353. UCHAR Reserved2 : 3;
  1354. UCHAR Lun : 3;
  1355. UCHAR LogicalBlockAddress[4];
  1356. UCHAR Reserved3;
  1357. UCHAR AllocationLength[2];
  1358. UCHAR Control;
  1359. } READ_HEADER, *PREAD_HEADER;
  1360. struct _PLAY_AUDIO {
  1361. UCHAR OperationCode; // 0x45 - SCSIOP_PLAY_AUDIO
  1362. UCHAR Reserved1 : 5;
  1363. UCHAR LogicalUnitNumber : 3;
  1364. UCHAR StartingBlockAddress[4];
  1365. UCHAR Reserved2;
  1366. UCHAR PlayLength[2];
  1367. UCHAR Control;
  1368. } PLAY_AUDIO, *PPLAY_AUDIO;
  1369. struct _PLAY_AUDIO_MSF {
  1370. UCHAR OperationCode; // 0x47 - SCSIOP_PLAY_AUDIO_MSF
  1371. UCHAR Reserved1 : 5;
  1372. UCHAR LogicalUnitNumber : 3;
  1373. UCHAR Reserved2;
  1374. UCHAR StartingM;
  1375. UCHAR StartingS;
  1376. UCHAR StartingF;
  1377. UCHAR EndingM;
  1378. UCHAR EndingS;
  1379. UCHAR EndingF;
  1380. UCHAR Control;
  1381. } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
  1382. struct _PLAY_CD {
  1383. UCHAR OperationCode; // 0xBC - SCSIOP_PLAY_CD
  1384. UCHAR Reserved1 : 1;
  1385. UCHAR CMSF : 1; // LBA = 0, MSF = 1
  1386. UCHAR ExpectedSectorType : 3;
  1387. UCHAR Lun : 3;
  1388. union {
  1389. struct _LBA {
  1390. UCHAR StartingBlockAddress[4];
  1391. UCHAR PlayLength[4];
  1392. } LBA;
  1393. struct _MSF {
  1394. UCHAR Reserved1;
  1395. UCHAR StartingM;
  1396. UCHAR StartingS;
  1397. UCHAR StartingF;
  1398. UCHAR EndingM;
  1399. UCHAR EndingS;
  1400. UCHAR EndingF;
  1401. UCHAR Reserved2;
  1402. } MSF;
  1403. };
  1404. UCHAR Audio : 1;
  1405. UCHAR Composite : 1;
  1406. UCHAR Port1 : 1;
  1407. UCHAR Port2 : 1;
  1408. UCHAR Reserved2 : 3;
  1409. UCHAR Speed : 1;
  1410. UCHAR Control;
  1411. } PLAY_CD, *PPLAY_CD;
  1412. struct _SCAN_CD {
  1413. UCHAR OperationCode; // 0xBA - SCSIOP_SCAN_CD
  1414. UCHAR RelativeAddress : 1;
  1415. UCHAR Reserved1 : 3;
  1416. UCHAR Direct : 1;
  1417. UCHAR Lun : 3;
  1418. UCHAR StartingAddress[4];
  1419. UCHAR Reserved2[3];
  1420. UCHAR Reserved3 : 6;
  1421. UCHAR Type : 2;
  1422. UCHAR Reserved4;
  1423. UCHAR Control;
  1424. } SCAN_CD, *PSCAN_CD;
  1425. struct _STOP_PLAY_SCAN {
  1426. UCHAR OperationCode; // 0x4E - SCSIOP_STOP_PLAY_SCAN
  1427. UCHAR Reserved1 : 5;
  1428. UCHAR Lun : 3;
  1429. UCHAR Reserved2[7];
  1430. UCHAR Control;
  1431. } STOP_PLAY_SCAN, *PSTOP_PLAY_SCAN;
  1432. //
  1433. // Read SubChannel Data
  1434. //
  1435. struct _SUBCHANNEL {
  1436. UCHAR OperationCode; // 0x42 - SCSIOP_READ_SUB_CHANNEL
  1437. UCHAR Reserved0 : 1;
  1438. UCHAR Msf : 1;
  1439. UCHAR Reserved1 : 3;
  1440. UCHAR LogicalUnitNumber : 3;
  1441. UCHAR Reserved2 : 6;
  1442. UCHAR SubQ : 1;
  1443. UCHAR Reserved3 : 1;
  1444. UCHAR Format;
  1445. UCHAR Reserved4[2];
  1446. UCHAR TrackNumber;
  1447. UCHAR AllocationLength[2];
  1448. UCHAR Control;
  1449. } SUBCHANNEL, *PSUBCHANNEL;
  1450. //
  1451. // Read CD. Used by Atapi for raw sector reads.
  1452. //
  1453. struct _READ_CD {
  1454. UCHAR OperationCode; // 0xBE - SCSIOP_READ_CD
  1455. UCHAR RelativeAddress : 1;
  1456. UCHAR Reserved0 : 1;
  1457. UCHAR ExpectedSectorType : 3;
  1458. UCHAR Lun : 3;
  1459. UCHAR StartingLBA[4];
  1460. UCHAR TransferBlocks[3];
  1461. UCHAR Reserved2 : 1;
  1462. UCHAR ErrorFlags : 2;
  1463. UCHAR IncludeEDC : 1;
  1464. UCHAR IncludeUserData : 1;
  1465. UCHAR HeaderCode : 2;
  1466. UCHAR IncludeSyncData : 1;
  1467. UCHAR SubChannelSelection : 3;
  1468. UCHAR Reserved3 : 5;
  1469. UCHAR Control;
  1470. } READ_CD, *PREAD_CD;
  1471. struct _READ_CD_MSF {
  1472. UCHAR OperationCode; // 0xB9 - SCSIOP_READ_CD_MSF
  1473. UCHAR RelativeAddress : 1;
  1474. UCHAR Reserved1 : 1;
  1475. UCHAR ExpectedSectorType : 3;
  1476. UCHAR Lun : 3;
  1477. UCHAR Reserved2;
  1478. UCHAR StartingM;
  1479. UCHAR StartingS;
  1480. UCHAR StartingF;
  1481. UCHAR EndingM;
  1482. UCHAR EndingS;
  1483. UCHAR EndingF;
  1484. UCHAR Reserved3;
  1485. UCHAR Reserved4 : 1;
  1486. UCHAR ErrorFlags : 2;
  1487. UCHAR IncludeEDC : 1;
  1488. UCHAR IncludeUserData : 1;
  1489. UCHAR HeaderCode : 2;
  1490. UCHAR IncludeSyncData : 1;
  1491. UCHAR SubChannelSelection : 3;
  1492. UCHAR Reserved5 : 5;
  1493. UCHAR Control;
  1494. } READ_CD_MSF, *PREAD_CD_MSF;
  1495. //
  1496. // Plextor Read CD-DA
  1497. //
  1498. struct _PLXTR_READ_CDDA {
  1499. UCHAR OperationCode; // Unknown -- vendor-unique?
  1500. UCHAR Reserved0 : 5;
  1501. UCHAR LogicalUnitNumber :3;
  1502. UCHAR LogicalBlockByte0;
  1503. UCHAR LogicalBlockByte1;
  1504. UCHAR LogicalBlockByte2;
  1505. UCHAR LogicalBlockByte3;
  1506. UCHAR TransferBlockByte0;
  1507. UCHAR TransferBlockByte1;
  1508. UCHAR TransferBlockByte2;
  1509. UCHAR TransferBlockByte3;
  1510. UCHAR SubCode;
  1511. UCHAR Control;
  1512. } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
  1513. //
  1514. // NEC Read CD-DA
  1515. //
  1516. struct _NEC_READ_CDDA {
  1517. UCHAR OperationCode; // Unknown -- vendor-unique?
  1518. UCHAR Reserved0;
  1519. UCHAR LogicalBlockByte0;
  1520. UCHAR LogicalBlockByte1;
  1521. UCHAR LogicalBlockByte2;
  1522. UCHAR LogicalBlockByte3;
  1523. UCHAR Reserved1;
  1524. UCHAR TransferBlockByte0;
  1525. UCHAR TransferBlockByte1;
  1526. UCHAR Control;
  1527. } NEC_READ_CDDA, *PNEC_READ_CDDA;
  1528. //
  1529. // Mode sense
  1530. //
  1531. struct _MODE_SENSE {
  1532. UCHAR OperationCode; // 0x1A - SCSIOP_MODE_SENSE
  1533. UCHAR Reserved1 : 3;
  1534. UCHAR Dbd : 1;
  1535. UCHAR Reserved2 : 1;
  1536. UCHAR LogicalUnitNumber : 3;
  1537. UCHAR PageCode : 6;
  1538. UCHAR Pc : 2;
  1539. UCHAR Reserved3;
  1540. UCHAR AllocationLength;
  1541. UCHAR Control;
  1542. } MODE_SENSE, *PMODE_SENSE;
  1543. struct _MODE_SENSE10 {
  1544. UCHAR OperationCode; // 0x5A - SCSIOP_MODE_SENSE10
  1545. UCHAR Reserved1 : 3;
  1546. UCHAR Dbd : 1;
  1547. UCHAR Reserved2 : 1;
  1548. UCHAR LogicalUnitNumber : 3;
  1549. UCHAR PageCode : 6;
  1550. UCHAR Pc : 2;
  1551. UCHAR Reserved3[4];
  1552. UCHAR AllocationLength[2];
  1553. UCHAR Control;
  1554. } MODE_SENSE10, *PMODE_SENSE10;
  1555. //
  1556. // Mode select
  1557. //
  1558. struct _MODE_SELECT {
  1559. UCHAR OperationCode; // 0x15 - SCSIOP_MODE_SELECT
  1560. UCHAR SPBit : 1;
  1561. UCHAR Reserved1 : 3;
  1562. UCHAR PFBit : 1;
  1563. UCHAR LogicalUnitNumber : 3;
  1564. UCHAR Reserved2[2];
  1565. UCHAR ParameterListLength;
  1566. UCHAR Control;
  1567. } MODE_SELECT, *PMODE_SELECT;
  1568. struct _MODE_SELECT10 {
  1569. UCHAR OperationCode; // 0x55 - SCSIOP_MODE_SELECT10
  1570. UCHAR SPBit : 1;
  1571. UCHAR Reserved1 : 3;
  1572. UCHAR PFBit : 1;
  1573. UCHAR LogicalUnitNumber : 3;
  1574. UCHAR Reserved2[5];
  1575. UCHAR ParameterListLength[2];
  1576. UCHAR Control;
  1577. } MODE_SELECT10, *PMODE_SELECT10;
  1578. struct _LOCATE {
  1579. UCHAR OperationCode; // 0x2B - SCSIOP_LOCATE
  1580. UCHAR Immediate : 1;
  1581. UCHAR CPBit : 1;
  1582. UCHAR BTBit : 1;
  1583. UCHAR Reserved1 : 2;
  1584. UCHAR LogicalUnitNumber : 3;
  1585. UCHAR Reserved3;
  1586. UCHAR LogicalBlockAddress[4];
  1587. UCHAR Reserved4;
  1588. UCHAR Partition;
  1589. UCHAR Control;
  1590. } LOCATE, *PLOCATE;
  1591. struct _LOGSENSE {
  1592. UCHAR OperationCode; // 0x4D - SCSIOP_LOG_SENSE
  1593. UCHAR SPBit : 1;
  1594. UCHAR PPCBit : 1;
  1595. UCHAR Reserved1 : 3;
  1596. UCHAR LogicalUnitNumber : 3;
  1597. UCHAR PageCode : 6;
  1598. UCHAR PCBit : 2;
  1599. UCHAR Reserved2;
  1600. UCHAR Reserved3;
  1601. UCHAR ParameterPointer[2];
  1602. UCHAR AllocationLength[2];
  1603. UCHAR Control;
  1604. } LOGSENSE, *PLOGSENSE;
  1605. struct _LOGSELECT {
  1606. UCHAR OperationCode; // 0x4C - SCSIOP_LOG_SELECT
  1607. UCHAR SPBit : 1;
  1608. UCHAR PCRBit : 1;
  1609. UCHAR Reserved1 : 3;
  1610. UCHAR LogicalUnitNumber : 3;
  1611. UCHAR Reserved : 6;
  1612. UCHAR PCBit : 2;
  1613. UCHAR Reserved2[4];
  1614. UCHAR ParameterListLength[2];
  1615. UCHAR Control;
  1616. } LOGSELECT, *PLOGSELECT;
  1617. struct _PRINT {
  1618. UCHAR OperationCode; // 0x0A - SCSIOP_PRINT
  1619. UCHAR Reserved : 5;
  1620. UCHAR LogicalUnitNumber : 3;
  1621. UCHAR TransferLength[3];
  1622. UCHAR Control;
  1623. } PRINT, *PPRINT;
  1624. struct _SEEK {
  1625. UCHAR OperationCode; // 0x2B - SCSIOP_SEEK
  1626. UCHAR Reserved1 : 5;
  1627. UCHAR LogicalUnitNumber : 3;
  1628. UCHAR LogicalBlockAddress[4];
  1629. UCHAR Reserved2[3];
  1630. UCHAR Control;
  1631. } SEEK, *PSEEK;
  1632. struct _ERASE {
  1633. UCHAR OperationCode; // 0x19 - SCSIOP_ERASE
  1634. UCHAR Long : 1;
  1635. UCHAR Immediate : 1;
  1636. UCHAR Reserved1 : 3;
  1637. UCHAR LogicalUnitNumber : 3;
  1638. UCHAR Reserved2[3];
  1639. UCHAR Control;
  1640. } ERASE, *PERASE;
  1641. struct _START_STOP {
  1642. UCHAR OperationCode; // 0x1B - SCSIOP_START_STOP_UNIT
  1643. UCHAR Immediate: 1;
  1644. UCHAR Reserved1 : 4;
  1645. UCHAR LogicalUnitNumber : 3;
  1646. UCHAR Reserved2[2];
  1647. UCHAR Start : 1;
  1648. UCHAR LoadEject : 1;
  1649. UCHAR Reserved3 : 6;
  1650. UCHAR Control;
  1651. } START_STOP, *PSTART_STOP;
  1652. struct _MEDIA_REMOVAL {
  1653. UCHAR OperationCode; // 0x1E - SCSIOP_MEDIUM_REMOVAL
  1654. UCHAR Reserved1 : 5;
  1655. UCHAR LogicalUnitNumber : 3;
  1656. UCHAR Reserved2[2];
  1657. UCHAR Prevent : 1;
  1658. UCHAR Persistant : 1;
  1659. UCHAR Reserved3 : 6;
  1660. UCHAR Control;
  1661. } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
  1662. //
  1663. // Tape CDBs
  1664. //
  1665. struct _SEEK_BLOCK {
  1666. UCHAR OperationCode; // 0x0C - SCSIOP_SEEK_BLOCK
  1667. UCHAR Immediate : 1;
  1668. UCHAR Reserved1 : 7;
  1669. UCHAR BlockAddress[3];
  1670. UCHAR Link : 1;
  1671. UCHAR Flag : 1;
  1672. UCHAR Reserved2 : 4;
  1673. UCHAR VendorUnique : 2;
  1674. } SEEK_BLOCK, *PSEEK_BLOCK;
  1675. struct _REQUEST_BLOCK_ADDRESS {
  1676. UCHAR OperationCode; // 0x02 - SCSIOP_REQUEST_BLOCK_ADDR
  1677. UCHAR Reserved1[3];
  1678. UCHAR AllocationLength;
  1679. UCHAR Link : 1;
  1680. UCHAR Flag : 1;
  1681. UCHAR Reserved2 : 4;
  1682. UCHAR VendorUnique : 2;
  1683. } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
  1684. struct _PARTITION {
  1685. UCHAR OperationCode; // 0x0D - SCSIOP_PARTITION
  1686. UCHAR Immediate : 1;
  1687. UCHAR Sel: 1;
  1688. UCHAR PartitionSelect : 6;
  1689. UCHAR Reserved1[3];
  1690. UCHAR Control;
  1691. } PARTITION, *PPARTITION;
  1692. struct _WRITE_TAPE_MARKS {
  1693. UCHAR OperationCode; // Unknown -- vendor-unique?
  1694. UCHAR Immediate : 1;
  1695. UCHAR WriteSetMarks: 1;
  1696. UCHAR Reserved : 3;
  1697. UCHAR LogicalUnitNumber : 3;
  1698. UCHAR TransferLength[3];
  1699. UCHAR Control;
  1700. } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
  1701. struct _SPACE_TAPE_MARKS {
  1702. UCHAR OperationCode; // Unknown -- vendor-unique?
  1703. UCHAR Code : 3;
  1704. UCHAR Reserved : 2;
  1705. UCHAR LogicalUnitNumber : 3;
  1706. UCHAR NumMarksMSB ;
  1707. UCHAR NumMarks;
  1708. UCHAR NumMarksLSB;
  1709. union {
  1710. UCHAR value;
  1711. struct {
  1712. UCHAR Link : 1;
  1713. UCHAR Flag : 1;
  1714. UCHAR Reserved : 4;
  1715. UCHAR VendorUnique : 2;
  1716. } Fields;
  1717. } Byte6;
  1718. } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
  1719. //
  1720. // Read tape position
  1721. //
  1722. struct _READ_POSITION {
  1723. UCHAR Operation; // 0x43 - SCSIOP_READ_POSITION
  1724. UCHAR BlockType:1;
  1725. UCHAR Reserved1:4;
  1726. UCHAR Lun:3;
  1727. UCHAR Reserved2[7];
  1728. UCHAR Control;
  1729. } READ_POSITION, *PREAD_POSITION;
  1730. //
  1731. // ReadWrite for Tape
  1732. //
  1733. struct _CDB6READWRITETAPE {
  1734. UCHAR OperationCode; // Unknown -- vendor-unique?
  1735. UCHAR VendorSpecific : 5;
  1736. UCHAR Reserved : 3;
  1737. UCHAR TransferLenMSB;
  1738. UCHAR TransferLen;
  1739. UCHAR TransferLenLSB;
  1740. UCHAR Link : 1;
  1741. UCHAR Flag : 1;
  1742. UCHAR Reserved1 : 4;
  1743. UCHAR VendorUnique : 2;
  1744. } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
  1745. //
  1746. // Medium changer CDB's
  1747. //
  1748. struct _INIT_ELEMENT_STATUS {
  1749. UCHAR OperationCode; // 0x07 - SCSIOP_INIT_ELEMENT_STATUS
  1750. UCHAR Reserved1 : 5;
  1751. UCHAR LogicalUnitNubmer : 3;
  1752. UCHAR Reserved2[3];
  1753. UCHAR Reserved3 : 7;
  1754. UCHAR NoBarCode : 1;
  1755. } INIT_ELEMENT_STATUS, *PINIT_ELEMENT_STATUS;
  1756. struct _INITIALIZE_ELEMENT_RANGE {
  1757. UCHAR OperationCode; // 0xE7 - SCSIOP_INIT_ELEMENT_RANGE
  1758. UCHAR Range : 1;
  1759. UCHAR Reserved1 : 4;
  1760. UCHAR LogicalUnitNubmer : 3;
  1761. UCHAR FirstElementAddress[2];
  1762. UCHAR Reserved2[2];
  1763. UCHAR NumberOfElements[2];
  1764. UCHAR Reserved3;
  1765. UCHAR Reserved4 : 7;
  1766. UCHAR NoBarCode : 1;
  1767. } INITIALIZE_ELEMENT_RANGE, *PINITIALIZE_ELEMENT_RANGE;
  1768. struct _POSITION_TO_ELEMENT {
  1769. UCHAR OperationCode; // 0x2B - SCSIOP_POSITION_TO_ELEMENT
  1770. UCHAR Reserved1 : 5;
  1771. UCHAR LogicalUnitNumber : 3;
  1772. UCHAR TransportElementAddress[2];
  1773. UCHAR DestinationElementAddress[2];
  1774. UCHAR Reserved2[2];
  1775. UCHAR Flip : 1;
  1776. UCHAR Reserved3 : 7;
  1777. UCHAR Control;
  1778. } POSITION_TO_ELEMENT, *PPOSITION_TO_ELEMENT;
  1779. struct _MOVE_MEDIUM {
  1780. UCHAR OperationCode; // 0xA5 - SCSIOP_MOVE_MEDIUM
  1781. UCHAR Reserved1 : 5;
  1782. UCHAR LogicalUnitNumber : 3;
  1783. UCHAR TransportElementAddress[2];
  1784. UCHAR SourceElementAddress[2];
  1785. UCHAR DestinationElementAddress[2];
  1786. UCHAR Reserved2[2];
  1787. UCHAR Flip : 1;
  1788. UCHAR Reserved3 : 7;
  1789. UCHAR Control;
  1790. } MOVE_MEDIUM, *PMOVE_MEDIUM;
  1791. struct _EXCHANGE_MEDIUM {
  1792. UCHAR OperationCode; // 0xA6 - SCSIOP_EXCHANGE_MEDIUM
  1793. UCHAR Reserved1 : 5;
  1794. UCHAR LogicalUnitNumber : 3;
  1795. UCHAR TransportElementAddress[2];
  1796. UCHAR SourceElementAddress[2];
  1797. UCHAR Destination1ElementAddress[2];
  1798. UCHAR Destination2ElementAddress[2];
  1799. UCHAR Flip1 : 1;
  1800. UCHAR Flip2 : 1;
  1801. UCHAR Reserved3 : 6;
  1802. UCHAR Control;
  1803. } EXCHANGE_MEDIUM, *PEXCHANGE_MEDIUM;
  1804. struct _READ_ELEMENT_STATUS {
  1805. UCHAR OperationCode; // 0xB8 - SCSIOP_READ_ELEMENT_STATUS
  1806. UCHAR ElementType : 4;
  1807. UCHAR VolTag : 1;
  1808. UCHAR LogicalUnitNumber : 3;
  1809. UCHAR StartingElementAddress[2];
  1810. UCHAR NumberOfElements[2];
  1811. UCHAR Reserved1;
  1812. UCHAR AllocationLength[3];
  1813. UCHAR Reserved2;
  1814. UCHAR Control;
  1815. } READ_ELEMENT_STATUS, *PREAD_ELEMENT_STATUS;
  1816. struct _SEND_VOLUME_TAG {
  1817. UCHAR OperationCode; // 0xB6 - SCSIOP_SEND_VOLUME_TAG
  1818. UCHAR ElementType : 4;
  1819. UCHAR Reserved1 : 1;
  1820. UCHAR LogicalUnitNumber : 3;
  1821. UCHAR StartingElementAddress[2];
  1822. UCHAR Reserved2;
  1823. UCHAR ActionCode : 5;
  1824. UCHAR Reserved3 : 3;
  1825. UCHAR Reserved4[2];
  1826. UCHAR ParameterListLength[2];
  1827. UCHAR Reserved5;
  1828. UCHAR Control;
  1829. } SEND_VOLUME_TAG, *PSEND_VOLUME_TAG;
  1830. struct _REQUEST_VOLUME_ELEMENT_ADDRESS {
  1831. UCHAR OperationCode; // Unknown -- vendor-unique?
  1832. UCHAR ElementType : 4;
  1833. UCHAR VolTag : 1;
  1834. UCHAR LogicalUnitNumber : 3;
  1835. UCHAR StartingElementAddress[2];
  1836. UCHAR NumberElements[2];
  1837. UCHAR Reserved1;
  1838. UCHAR AllocationLength[3];
  1839. UCHAR Reserved2;
  1840. UCHAR Control;
  1841. } REQUEST_VOLUME_ELEMENT_ADDRESS, *PREQUEST_VOLUME_ELEMENT_ADDRESS;
  1842. //
  1843. // Atapi 2.5 Changer 12-byte CDBs
  1844. //
  1845. struct _LOAD_UNLOAD {
  1846. UCHAR OperationCode; // 0xA6 - SCSIOP_LOAD_UNLOAD_SLOT
  1847. UCHAR Immediate : 1;
  1848. UCHAR Reserved1 : 4;
  1849. UCHAR Lun : 3;
  1850. UCHAR Reserved2[2];
  1851. UCHAR Start : 1;
  1852. UCHAR LoadEject : 1;
  1853. UCHAR Reserved3: 6;
  1854. UCHAR Reserved4[3];
  1855. UCHAR Slot;
  1856. UCHAR Reserved5[3];
  1857. } LOAD_UNLOAD, *PLOAD_UNLOAD;
  1858. struct _MECH_STATUS {
  1859. UCHAR OperationCode; // 0xBD - SCSIOP_MECHANISM_STATUS
  1860. UCHAR Reserved : 5;
  1861. UCHAR Lun : 3;
  1862. UCHAR Reserved1[6];
  1863. UCHAR AllocationLength[2];
  1864. UCHAR Reserved2[1];
  1865. UCHAR Control;
  1866. } MECH_STATUS, *PMECH_STATUS;
  1867. //
  1868. // C/DVD 0.9 CDBs
  1869. //
  1870. struct _SYNCHRONIZE_CACHE10 {
  1871. UCHAR OperationCode; // 0x35 - SCSIOP_SYNCHRONIZE_CACHE
  1872. UCHAR RelAddr : 1;
  1873. UCHAR Immediate : 1;
  1874. UCHAR Reserved : 3;
  1875. UCHAR Lun : 3;
  1876. UCHAR LogicalBlockAddress[4]; // Unused - set to zero
  1877. UCHAR Reserved2;
  1878. UCHAR BlockCount[2]; // Unused - set to zero
  1879. UCHAR Control;
  1880. } SYNCHRONIZE_CACHE10, *PSYNCHRONIZE_CACHE10;
  1881. struct _GET_EVENT_STATUS_NOTIFICATION {
  1882. UCHAR OperationCode; // 0x4A - SCSIOP_GET_EVENT_STATUS_NOTIFICATION
  1883. UCHAR Immediate : 1;
  1884. UCHAR Reserved : 4;
  1885. UCHAR Lun : 3;
  1886. UCHAR Reserved2[2];
  1887. UCHAR NotificationClassRequest;
  1888. UCHAR Reserved3[2];
  1889. UCHAR EventListLength[2];
  1890. UCHAR Control;
  1891. } GET_EVENT_STATUS_NOTIFICATION, *PGET_EVENT_STATUS_NOTIFICATION;
  1892. struct _READ_DVD_STRUCTURE {
  1893. UCHAR OperationCode; // 0xAD - SCSIOP_READ_DVD_STRUCTURE
  1894. UCHAR Reserved1 : 5;
  1895. UCHAR Lun : 3;
  1896. UCHAR RMDBlockNumber[4];
  1897. UCHAR LayerNumber;
  1898. UCHAR Format;
  1899. UCHAR AllocationLength[2];
  1900. UCHAR Reserved3 : 6;
  1901. UCHAR AGID : 2;
  1902. UCHAR Control;
  1903. } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
  1904. struct _SEND_DVD_STRUCTURE {
  1905. UCHAR OperationCode; // 0xBF - SCSIOP_SEND_DVD_STRUCTURE
  1906. UCHAR Reserved1 : 5;
  1907. UCHAR Lun : 3;
  1908. UCHAR Reserved2[5];
  1909. UCHAR Format;
  1910. UCHAR ParameterListLength[2];
  1911. UCHAR Reserved3;
  1912. UCHAR Control;
  1913. } SEND_DVD_STRUCTURE, *PSEND_DVD_STRUCTURE;
  1914. struct _SEND_KEY {
  1915. UCHAR OperationCode; // 0xA3 - SCSIOP_SEND_KEY
  1916. UCHAR Reserved1 : 5;
  1917. UCHAR Lun : 3;
  1918. UCHAR Reserved2[6];
  1919. UCHAR ParameterListLength[2];
  1920. UCHAR KeyFormat : 6;
  1921. UCHAR AGID : 2;
  1922. UCHAR Control;
  1923. } SEND_KEY, *PSEND_KEY;
  1924. struct _REPORT_KEY {
  1925. UCHAR OperationCode; // 0xA4 - SCSIOP_REPORT_KEY
  1926. UCHAR Reserved1 : 5;
  1927. UCHAR Lun : 3;
  1928. UCHAR LogicalBlockAddress[4]; // for title key
  1929. UCHAR Reserved2[2];
  1930. UCHAR AllocationLength[2];
  1931. UCHAR KeyFormat : 6;
  1932. UCHAR AGID : 2;
  1933. UCHAR Control;
  1934. } REPORT_KEY, *PREPORT_KEY;
  1935. struct _SET_READ_AHEAD {
  1936. UCHAR OperationCode; // 0xA7 - SCSIOP_SET_READ_AHEAD
  1937. UCHAR Reserved1 : 5;
  1938. UCHAR Lun : 3;
  1939. UCHAR TriggerLBA[4];
  1940. UCHAR ReadAheadLBA[4];
  1941. UCHAR Reserved2;
  1942. UCHAR Control;
  1943. } SET_READ_AHEAD, *PSET_READ_AHEAD;
  1944. struct _READ_FORMATTED_CAPACITIES {
  1945. UCHAR OperationCode; // 0x23 - SCSIOP_READ_FORMATTED_CAPACITY
  1946. UCHAR Reserved1 : 5;
  1947. UCHAR Lun : 3;
  1948. UCHAR Reserved2[5];
  1949. UCHAR AllocationLength[2];
  1950. UCHAR Control;
  1951. } READ_FORMATTED_CAPACITIES, *PREAD_FORMATTED_CAPACITIES;
  1952. //
  1953. // SCSI-3
  1954. //
  1955. struct _REPORT_LUNS {
  1956. UCHAR OperationCode; // 0xA0 - SCSIOP_REPORT_LUNS
  1957. UCHAR Reserved1[5];
  1958. UCHAR AllocationLength[4];
  1959. UCHAR Reserved2[1];
  1960. UCHAR Control;
  1961. } REPORT_LUNS, *PREPORT_LUNS;
  1962. struct _PERSISTENT_RESERVE_IN {
  1963. UCHAR OperationCode; // 0x5E - SCSIOP_PERSISTENT_RESERVE_IN
  1964. UCHAR ServiceAction : 5;
  1965. UCHAR Reserved1 : 3;
  1966. UCHAR Reserved2[5];
  1967. UCHAR AllocationLength[2];
  1968. UCHAR Control;
  1969. } PERSISTENT_RESERVE_IN, *PPERSISTENT_RESERVE_IN;
  1970. struct _PERSISTENT_RESERVE_OUT {
  1971. UCHAR OperationCode; // 0x5F - SCSIOP_PERSISTENT_RESERVE_OUT
  1972. UCHAR ServiceAction : 5;
  1973. UCHAR Reserved1 : 3;
  1974. UCHAR Type : 4;
  1975. UCHAR Scope : 4;
  1976. UCHAR Reserved2[4];
  1977. UCHAR ParameterListLength[2]; // 0x18
  1978. UCHAR Control;
  1979. } PERSISTENT_RESERVE_OUT, *PPERSISTENT_RESERVE_OUT;
  1980. //
  1981. // MMC / SFF-8090 commands
  1982. //
  1983. struct _GET_CONFIGURATION {
  1984. UCHAR OperationCode; // 0x46 - SCSIOP_GET_CONFIGURATION
  1985. UCHAR RequestType : 1; // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
  1986. UCHAR Reserved1 : 7; // includes obsolete LUN field
  1987. UCHAR StartingFeature[2];
  1988. UCHAR Reserved2[3];
  1989. UCHAR AllocationLength[2];
  1990. UCHAR Control;
  1991. } GET_CONFIGURATION, *PGET_CONFIGURATION;
  1992. struct _SET_CD_SPEED {
  1993. UCHAR OperationCode; // 0xB8 - SCSIOP_SET_CD_SPEED
  1994. UCHAR Reserved1;
  1995. UCHAR ReadSpeed[2]; // 1x == (75 * 2352)
  1996. UCHAR WriteSpeed[2]; // 1x == (75 * 2352)
  1997. UCHAR Reserved2[5];
  1998. UCHAR Control;
  1999. } SET_CD_SPEED, *PSET_CD_SPEED;
  2000. ULONG AsUlong[4];
  2001. UCHAR AsByte[16];
  2002. } CDB, *PCDB;
  2003. ////////////////////////////////////////////////////////////////////////////////
  2004. //
  2005. // GET_EVENT_STATUS_NOTIFICATION
  2006. //
  2007. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_MASK 0x02
  2008. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_MASK 0x04
  2009. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK 0x08
  2010. #define NOTIFICATION_MEDIA_STATUS_CLASS_MASK 0x10
  2011. #define NOTIFICATION_MULTI_HOST_CLASS_MASK 0x20
  2012. #define NOTIFICATION_DEVICE_BUSY_CLASS_MASK 0x40
  2013. #define NOTIFICATION_NO_CLASS_EVENTS 0x0
  2014. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_EVENTS 0x1
  2015. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_EVENTS 0x2
  2016. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS 0x3
  2017. #define NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS 0x4
  2018. #define NOTIFICATION_MULTI_HOST_CLASS_EVENTS 0x5
  2019. #define NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS 0x6
  2020. typedef struct _NOTIFICATION_EVENT_STATUS_HEADER {
  2021. UCHAR EventDataLength[2];
  2022. UCHAR NotificationClass : 3;
  2023. UCHAR Reserved : 4;
  2024. UCHAR NEA : 1;
  2025. UCHAR SupportedEventClasses;
  2026. UCHAR ClassEventData[0];
  2027. } NOTIFICATION_EVENT_STATUS_HEADER, *PNOTIFICATION_EVENT_STATUS_HEADER;
  2028. #define NOTIFICATION_OPERATIONAL_EVENT_NO_CHANGE 0x0
  2029. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_REQUESTED 0x1
  2030. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_OCCURRED 0x2
  2031. #define NOTIFICATION_OPERATIONAL_STATUS_AVAILABLE 0x0
  2032. #define NOTIFICATION_OPERATIONAL_STATUS_TEMPORARY_BUSY 0x1
  2033. #define NOTIFICATION_OPERATIONAL_STATUS_EXTENDED_BUSY 0x2
  2034. #define NOTIFICATION_OPERATIONAL_OPCODE_NONE
  2035. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_CHANGE 0x1
  2036. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_ADDED 0x2
  2037. #define NOTIFICATION_OPERATIONAL_OPCODE_UNIT_RESET 0x3
  2038. #define NOTIFICATION_OPERATIONAL_OPCODE_FIRMWARE_CHANGED 0x4
  2039. #define NOTIFICATION_OPERATIONAL_OPCODE_INQUIRY_CHANGED 0x5
  2040. //
  2041. // Class event data may be one (or none) of the following:
  2042. //
  2043. typedef struct _NOTIFICATION_OPERATIONAL_STATUS { // event class == 0x1
  2044. UCHAR OperationalEvent : 4;
  2045. UCHAR Reserved1 : 4;
  2046. UCHAR OperationalStatus : 4;
  2047. UCHAR Reserved2 : 3;
  2048. UCHAR PersistentPrevented : 1;
  2049. UCHAR Operation[2];
  2050. } NOTIFICATION_OPERATIONAL_STATUS, *PNOTIFICATION_OPERATIONAL_STATUS;
  2051. #define NOTIFICATION_POWER_EVENT_NO_CHANGE 0x0
  2052. #define NOTIFICATION_POWER_EVENT_CHANGE_SUCCEEDED 0x1
  2053. #define NOTIFICATION_POWER_EVENT_CHANGE_FAILED 0x2
  2054. #define NOTIFICATION_POWER_STATUS_ACTIVE 0x1
  2055. #define NOTIFICATION_POWER_STATUS_IDLE 0x2
  2056. #define NOTIFICATION_POWER_STATUS_STANDBY 0x3
  2057. #define NOTIFICATION_POWER_STATUS_SLEEP 0x4
  2058. typedef struct _NOTIFICATION_POWER_STATUS { // event class == 0x2
  2059. UCHAR PowerEvent : 4;
  2060. UCHAR Reserved : 4;
  2061. UCHAR PowerStatus;
  2062. UCHAR Reserved2[2];
  2063. } NOTIFICATION_POWER_STATUS, *PNOTIFICATION_POWER_STATUS;
  2064. #define NOTIFICATION_EXTERNAL_EVENT_NO_CHANGE 0x0
  2065. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN 0x1
  2066. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_UP 0x2
  2067. #define NOTIFICATION_EXTERNAL_EVENT_EXTERNAL 0x3 // respond with GET_CONFIGURATION?
  2068. #define NOTIFICATION_EXTERNAL_STATUS_READY 0x0
  2069. #define NOTIFICATION_EXTERNAL_STATUS_PREVENT 0x1
  2070. #define NOTIFICATION_EXTERNAL_REQUEST_NONE 0x0000
  2071. #define NOTIFICATION_EXTERNAL_REQUEST_QUEUE_OVERRUN 0x0001
  2072. #define NOTIFICATION_EXTERNAL_REQUEST_PLAY 0x0101
  2073. #define NOTIFICATION_EXTERNAL_REQUEST_REWIND_BACK 0x0102
  2074. #define NOTIFICATION_EXTERNAL_REQUEST_FAST_FORWARD 0x0103
  2075. #define NOTIFICATION_EXTERNAL_REQUEST_PAUSE 0x0104
  2076. #define NOTIFICATION_EXTERNAL_REQUEST_STOP 0x0106
  2077. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_LOW 0x0200
  2078. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_HIGH 0x02ff
  2079. typedef struct _NOTIFICATION_EXTERNAL_STATUS { // event class == 0x3
  2080. UCHAR ExternalEvent : 4;
  2081. UCHAR Reserved1 : 4;
  2082. UCHAR ExternalStatus : 4;
  2083. UCHAR Reserved2 : 3;
  2084. UCHAR PersistentPrevented : 1;
  2085. UCHAR Request[2];
  2086. } NOTIFICATION_EXTERNAL_STATUS, *PNOTIFICATION_EXTERNAL_STATUS;
  2087. #define NOTIFICATION_MEDIA_EVENT_NO_CHANGE 0x0
  2088. #define NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST 0x1
  2089. #define NOTIFICATION_MEDIA_EVENT_NEW_MEDIA 0x2
  2090. #define NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL 0x3
  2091. #define NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE 0x4
  2092. typedef struct _NOTIFICATION_MEDIA_STATUS { // event class == 0x4
  2093. UCHAR MediaEvent : 4;
  2094. UCHAR Reserved : 4;
  2095. union {
  2096. UCHAR PowerStatus; // OBSOLETE -- was improperly named in NT5 headers
  2097. UCHAR MediaStatus; // Use this for currently reserved fields
  2098. struct {
  2099. UCHAR DoorTrayOpen : 1;
  2100. UCHAR MediaPresent : 1;
  2101. UCHAR ReservedX : 6; // do not reference this directly!
  2102. };
  2103. };
  2104. UCHAR StartSlot;
  2105. UCHAR EndSlot;
  2106. } NOTIFICATION_MEDIA_STATUS, *PNOTIFICATION_MEDIA_STATUS;
  2107. #define NOTIFICATION_MULTI_HOST_EVENT_NO_CHANGE 0x0
  2108. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_REQUEST 0x1
  2109. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_GRANT 0x2
  2110. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_RELEASE 0x3
  2111. #define NOTIFICATION_MULTI_HOST_STATUS_READY 0x0
  2112. #define NOTIFICATION_MULTI_HOST_STATUS_PREVENT 0x1
  2113. #define NOTIFICATION_MULTI_HOST_PRIORITY_NO_REQUESTS 0x0
  2114. #define NOTIFICATION_MULTI_HOST_PRIORITY_LOW 0x1
  2115. #define NOTIFICATION_MULTI_HOST_PRIORITY_MEDIUM 0x2
  2116. #define NOTIFICATION_MULTI_HOST_PRIORITY_HIGH 0x3
  2117. typedef struct _NOTIFICATION_MULTI_HOST_STATUS { // event class == 0x5
  2118. UCHAR MultiHostEvent : 4;
  2119. UCHAR Reserved1 : 4;
  2120. UCHAR MultiHostStatus : 4;
  2121. UCHAR Reserved2 : 3;
  2122. UCHAR PersistentPrevented : 1;
  2123. UCHAR Priority[2];
  2124. } NOTIFICATION_MULTI_HOST_STATUS, *PNOTIFICATION_MULTI_HOST_STATUS;
  2125. #define NOTIFICATION_BUSY_EVENT_NO_CHANGE 0x0
  2126. #define NOTIFICATION_BUSY_EVENT_BUSY 0x1
  2127. #define NOTIFICATION_BUSY_STATUS_NO_EVENT 0x0
  2128. #define NOTIFICATION_BUSY_STATUS_POWER 0x1
  2129. #define NOTIFICATION_BUSY_STATUS_IMMEDIATE 0x2
  2130. #define NOTIFICATION_BUSY_STATUS_DEFERRED 0x3
  2131. typedef struct _NOTIFICATION_BUSY_STATUS { // event class == 0x6
  2132. UCHAR DeviceBusyEvent : 4;
  2133. UCHAR Reserved : 4;
  2134. UCHAR DeviceBusyStatus;
  2135. UCHAR Time[2];
  2136. } NOTIFICATION_BUSY_STATUS, *PNOTIFICATION_BUSY_STATUS;
  2137. ////////////////////////////////////////////////////////////////////////////////
  2138. //
  2139. // Read DVD Structure Definitions and Constants
  2140. //
  2141. #define DVD_FORMAT_LEAD_IN 0x00
  2142. #define DVD_FORMAT_COPYRIGHT 0x01
  2143. #define DVD_FORMAT_DISK_KEY 0x02
  2144. #define DVD_FORMAT_BCA 0x03
  2145. #define DVD_FORMAT_MANUFACTURING 0x04
  2146. typedef struct _READ_DVD_STRUCTURES_HEADER {
  2147. UCHAR Length[2];
  2148. UCHAR Reserved[2];
  2149. UCHAR Data[0];
  2150. } READ_DVD_STRUCTURES_HEADER, *PREAD_DVD_STRUCTURES_HEADER;
  2151. //
  2152. // DiskKey, BCA & Manufacturer information will provide byte arrays as their
  2153. // data.
  2154. //
  2155. //
  2156. // CDVD 0.9 Send & Report Key Definitions and Structures
  2157. //
  2158. #define DVD_REPORT_AGID 0x00
  2159. #define DVD_CHALLENGE_KEY 0x01
  2160. #define DVD_KEY_1 0x02
  2161. #define DVD_KEY_2 0x03
  2162. #define DVD_TITLE_KEY 0x04
  2163. #define DVD_REPORT_ASF 0x05
  2164. #define DVD_INVALIDATE_AGID 0x3F
  2165. typedef struct _CDVD_KEY_HEADER {
  2166. UCHAR DataLength[2];
  2167. UCHAR Reserved[2];
  2168. UCHAR Data[0];
  2169. } CDVD_KEY_HEADER, *PCDVD_KEY_HEADER;
  2170. typedef struct _CDVD_REPORT_AGID_DATA {
  2171. UCHAR Reserved1[3];
  2172. UCHAR Reserved2 : 6;
  2173. UCHAR AGID : 2;
  2174. } CDVD_REPORT_AGID_DATA, *PCDVD_REPORT_AGID_DATA;
  2175. typedef struct _CDVD_CHALLENGE_KEY_DATA {
  2176. UCHAR ChallengeKeyValue[10];
  2177. UCHAR Reserved[2];
  2178. } CDVD_CHALLENGE_KEY_DATA, *PCDVD_CHALLENGE_KEY_DATA;
  2179. typedef struct _CDVD_KEY_DATA {
  2180. UCHAR Key[5];
  2181. UCHAR Reserved[3];
  2182. } CDVD_KEY_DATA, *PCDVD_KEY_DATA;
  2183. typedef struct _CDVD_REPORT_ASF_DATA {
  2184. UCHAR Reserved1[3];
  2185. UCHAR Success : 1;
  2186. UCHAR Reserved2 : 7;
  2187. } CDVD_REPORT_ASF_DATA, *PCDVD_REPORT_ASF_DATA;
  2188. typedef struct _CDVD_TITLE_KEY_HEADER {
  2189. UCHAR DataLength[2];
  2190. UCHAR Reserved1[1];
  2191. UCHAR Reserved2 : 3;
  2192. UCHAR CGMS : 2;
  2193. UCHAR CP_SEC : 1;
  2194. UCHAR CPM : 1;
  2195. UCHAR Zero : 1;
  2196. CDVD_KEY_DATA TitleKey;
  2197. } CDVD_TITLE_KEY_HEADER, *PCDVD_TITLE_KEY_HEADER;
  2198. //
  2199. // Read Formatted Capacity Data - returned in Big Endian Format
  2200. //
  2201. typedef struct _FORMATTED_CAPACITY_DESCRIPTOR {
  2202. UCHAR NumberOfBlocks[4];
  2203. UCHAR Maximum : 1;
  2204. UCHAR Valid : 1;
  2205. UCHAR BlockLength[3];
  2206. } FORMATTED_CAPACITY_DESCRIPTOR, *PFORMATTED_CAPACITY_DESCRIPTOR;
  2207. typedef struct _FORMATTED_CAPACITY_LIST {
  2208. UCHAR Reserved[3];
  2209. UCHAR CapacityListLength;
  2210. FORMATTED_CAPACITY_DESCRIPTOR Descriptors[0];
  2211. } FORMATTED_CAPACITY_LIST, *PFORMATTED_CAPACITY_LIST;
  2212. //
  2213. // PLAY_CD definitions and constants
  2214. //
  2215. #define CD_EXPECTED_SECTOR_ANY 0x0
  2216. #define CD_EXPECTED_SECTOR_CDDA 0x1
  2217. #define CD_EXPECTED_SECTOR_MODE1 0x2
  2218. #define CD_EXPECTED_SECTOR_MODE2 0x3
  2219. #define CD_EXPECTED_SECTOR_MODE2_FORM1 0x4
  2220. #define CD_EXPECTED_SECTOR_MODE2_FORM2 0x5
  2221. //
  2222. // Read Disk Information Definitions and Capabilities
  2223. //
  2224. #define DISK_STATUS_EMPTY 0x00
  2225. #define DISK_STATUS_INCOMPLETE 0x01
  2226. #define DISK_STATUS_COMPLETE 0x02
  2227. #define LAST_SESSION_EMPTY 0x00
  2228. #define LAST_SESSION_INCOMPLETE 0x01
  2229. #define LAST_SESSION_COMPLETE 0x03
  2230. #define DISK_TYPE_CDDA 0x01
  2231. #define DISK_TYPE_CDI 0x10
  2232. #define DISK_TYPE_XA 0x20
  2233. #define DISK_TYPE_UNDEFINED 0xFF
  2234. typedef struct _OPC_TABLE_ENTRY {
  2235. UCHAR Speed[2];
  2236. UCHAR OPCValue[6];
  2237. } OPC_TABLE_ENTRY, *POPC_TABLE_ENTRY;
  2238. typedef struct _DISK_INFORMATION {
  2239. UCHAR Length[2];
  2240. UCHAR DiskStatus : 2;
  2241. UCHAR LastSessionStatus : 2;
  2242. UCHAR Erasable : 1;
  2243. UCHAR Reserved1 : 3;
  2244. UCHAR FirstTrackNumber;
  2245. UCHAR NumberOfSessions;
  2246. UCHAR LastSessionFirstTrack;
  2247. UCHAR LastSessionLastTrack;
  2248. UCHAR Reserved2 : 5;
  2249. UCHAR GEN : 1;
  2250. UCHAR DBC_V : 1;
  2251. UCHAR DID_V : 1;
  2252. UCHAR DiskType;
  2253. UCHAR Reserved3[3];
  2254. UCHAR DiskIdentification[4];
  2255. UCHAR LastSessionLeadIn[4]; // MSF
  2256. UCHAR LastPossibleStartTime[4]; // MSF
  2257. UCHAR DiskBarCode[8];
  2258. UCHAR Reserved4;
  2259. UCHAR NumberOPCEntries;
  2260. OPC_TABLE_ENTRY OPCTable[0];
  2261. } DISK_INFORMATION, *PDISK_INFORMATION;
  2262. //
  2263. // Read Header definitions and structures
  2264. //
  2265. typedef struct _DATA_BLOCK_HEADER {
  2266. UCHAR DataMode;
  2267. UCHAR Reserved[4];
  2268. union {
  2269. UCHAR LogicalBlockAddress[4];
  2270. struct {
  2271. UCHAR Reserved;
  2272. UCHAR M;
  2273. UCHAR S;
  2274. UCHAR F;
  2275. } MSF;
  2276. };
  2277. } DATA_BLOCK_HEADER, *PDATA_BLOCK_HEADER;
  2278. #define DATA_BLOCK_MODE0 0x0
  2279. #define DATA_BLOCK_MODE1 0x1
  2280. #define DATA_BLOCK_MODE2 0x2
  2281. //
  2282. // Read TOC Format Codes
  2283. //
  2284. #define READ_TOC_FORMAT_TOC 0x00
  2285. #define READ_TOC_FORMAT_SESSION 0x01
  2286. #define READ_TOC_FORMAT_FULL_TOC 0x02
  2287. #define READ_TOC_FORMAT_PMA 0x03
  2288. #define READ_TOC_FORMAT_ATIP 0x04
  2289. typedef struct _TRACK_INFORMATION {
  2290. UCHAR Length[2];
  2291. UCHAR TrackNumber;
  2292. UCHAR SessionNumber;
  2293. UCHAR Reserved1;
  2294. UCHAR TrackMode : 4;
  2295. UCHAR Copy : 1;
  2296. UCHAR Damage : 1;
  2297. UCHAR Reserved2 : 2;
  2298. UCHAR DataMode : 4;
  2299. UCHAR FP : 1;
  2300. UCHAR Packet : 1;
  2301. UCHAR Blank : 1;
  2302. UCHAR RT : 1;
  2303. UCHAR NWA_V : 1;
  2304. UCHAR Reserved3 : 7;
  2305. UCHAR TrackStartAddress[4];
  2306. UCHAR NextWritableAddress[4];
  2307. UCHAR FreeBlocks[4];
  2308. UCHAR FixedPacketSize[4];
  2309. } TRACK_INFORMATION, *PTRACK_INFORMATION;
  2310. //
  2311. // Command Descriptor Block constants.
  2312. //
  2313. #define CDB6GENERIC_LENGTH 6
  2314. #define CDB10GENERIC_LENGTH 10
  2315. #define CDB12GENERIC_LENGTH 12
  2316. #define SETBITON 1
  2317. #define SETBITOFF 0
  2318. //
  2319. // Mode Sense/Select page constants.
  2320. //
  2321. #define MODE_PAGE_ERROR_RECOVERY 0x01
  2322. #define MODE_PAGE_DISCONNECT 0x02
  2323. #define MODE_PAGE_FORMAT_DEVICE 0x03
  2324. #define MODE_PAGE_RIGID_GEOMETRY 0x04
  2325. #define MODE_PAGE_FLEXIBILE 0x05 // disk
  2326. #define MODE_PAGE_WRITE_PARAMETERS 0x05 // cdrom
  2327. #define MODE_PAGE_VERIFY_ERROR 0x07
  2328. #define MODE_PAGE_CACHING 0x08
  2329. #define MODE_PAGE_PERIPHERAL 0x09
  2330. #define MODE_PAGE_CONTROL 0x0A
  2331. #define MODE_PAGE_MEDIUM_TYPES 0x0B
  2332. #define MODE_PAGE_NOTCH_PARTITION 0x0C
  2333. #define MODE_PAGE_CD_AUDIO_CONTROL 0x0E
  2334. #define MODE_PAGE_DATA_COMPRESS 0x0F
  2335. #define MODE_PAGE_DEVICE_CONFIG 0x10
  2336. #define MODE_PAGE_MEDIUM_PARTITION 0x11
  2337. #define MODE_PAGE_CDVD_FEATURE_SET 0x18
  2338. #define MODE_PAGE_POWER_CONDITION 0x1A
  2339. #define MODE_PAGE_FAULT_REPORTING 0x1C
  2340. #define MODE_PAGE_CDVD_INACTIVITY 0x1D // cdrom
  2341. #define MODE_PAGE_ELEMENT_ADDRESS 0x1D
  2342. #define MODE_PAGE_TRANSPORT_GEOMETRY 0x1E
  2343. #define MODE_PAGE_DEVICE_CAPABILITIES 0x1F
  2344. #define MODE_PAGE_CAPABILITIES 0x2A // cdrom
  2345. #define MODE_SENSE_RETURN_ALL 0x3f
  2346. #define MODE_SENSE_CURRENT_VALUES 0x00
  2347. #define MODE_SENSE_CHANGEABLE_VALUES 0x40
  2348. #define MODE_SENSE_DEFAULT_VAULES 0x80
  2349. #define MODE_SENSE_SAVED_VALUES 0xc0
  2350. //
  2351. // SCSI CDB operation codes
  2352. //
  2353. // 6-byte commands:
  2354. #define SCSIOP_TEST_UNIT_READY 0x00
  2355. #define SCSIOP_REZERO_UNIT 0x01
  2356. #define SCSIOP_REWIND 0x01
  2357. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  2358. #define SCSIOP_REQUEST_SENSE 0x03
  2359. #define SCSIOP_FORMAT_UNIT 0x04
  2360. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  2361. #define SCSIOP_REASSIGN_BLOCKS 0x07
  2362. #define SCSIOP_INIT_ELEMENT_STATUS 0x07
  2363. #define SCSIOP_READ6 0x08
  2364. #define SCSIOP_RECEIVE 0x08
  2365. #define SCSIOP_WRITE6 0x0A
  2366. #define SCSIOP_PRINT 0x0A
  2367. #define SCSIOP_SEND 0x0A
  2368. #define SCSIOP_SEEK6 0x0B
  2369. #define SCSIOP_TRACK_SELECT 0x0B
  2370. #define SCSIOP_SLEW_PRINT 0x0B
  2371. #define SCSIOP_SEEK_BLOCK 0x0C
  2372. #define SCSIOP_PARTITION 0x0D
  2373. #define SCSIOP_READ_REVERSE 0x0F
  2374. #define SCSIOP_WRITE_FILEMARKS 0x10
  2375. #define SCSIOP_FLUSH_BUFFER 0x10
  2376. #define SCSIOP_SPACE 0x11
  2377. #define SCSIOP_INQUIRY 0x12
  2378. #define SCSIOP_VERIFY6 0x13
  2379. #define SCSIOP_RECOVER_BUF_DATA 0x14
  2380. #define SCSIOP_MODE_SELECT 0x15
  2381. #define SCSIOP_RESERVE_UNIT 0x16
  2382. #define SCSIOP_RELEASE_UNIT 0x17
  2383. #define SCSIOP_COPY 0x18
  2384. #define SCSIOP_ERASE 0x19
  2385. #define SCSIOP_MODE_SENSE 0x1A
  2386. #define SCSIOP_START_STOP_UNIT 0x1B
  2387. #define SCSIOP_STOP_PRINT 0x1B
  2388. #define SCSIOP_LOAD_UNLOAD 0x1B
  2389. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  2390. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  2391. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  2392. // 10-byte commands
  2393. #define SCSIOP_READ_FORMATTED_CAPACITY 0x23
  2394. #define SCSIOP_READ_CAPACITY 0x25
  2395. #define SCSIOP_READ 0x28
  2396. #define SCSIOP_WRITE 0x2A
  2397. #define SCSIOP_SEEK 0x2B
  2398. #define SCSIOP_LOCATE 0x2B
  2399. #define SCSIOP_POSITION_TO_ELEMENT 0x2B
  2400. #define SCSIOP_WRITE_VERIFY 0x2E
  2401. #define SCSIOP_VERIFY 0x2F
  2402. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  2403. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  2404. #define SCSIOP_SEARCH_DATA_LOW 0x32
  2405. #define SCSIOP_SET_LIMITS 0x33
  2406. #define SCSIOP_READ_POSITION 0x34
  2407. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  2408. #define SCSIOP_COMPARE 0x39
  2409. #define SCSIOP_COPY_COMPARE 0x3A
  2410. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  2411. #define SCSIOP_READ_DATA_BUFF 0x3C
  2412. #define SCSIOP_CHANGE_DEFINITION 0x40
  2413. #define SCSIOP_READ_SUB_CHANNEL 0x42
  2414. #define SCSIOP_READ_TOC 0x43
  2415. #define SCSIOP_READ_HEADER 0x44
  2416. #define SCSIOP_PLAY_AUDIO 0x45
  2417. #define SCSIOP_GET_CONFIGURATION 0x46
  2418. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  2419. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  2420. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  2421. #define SCSIOP_GET_EVENT_STATUS 0x4A
  2422. #define SCSIOP_PAUSE_RESUME 0x4B
  2423. #define SCSIOP_LOG_SELECT 0x4C
  2424. #define SCSIOP_LOG_SENSE 0x4D
  2425. #define SCSIOP_STOP_PLAY_SCAN 0x4E
  2426. #define SCSIOP_READ_DISK_INFORMATION 0x51
  2427. #define SCSIOP_READ_TRACK_INFORMATION 0x52
  2428. #define SCSIOP_RESERVE_TRACK_RZONE 0x53
  2429. #define SCSIOP_SEND_OPC_INFORMATION 0x54 // optimum power calibration
  2430. #define SCSIOP_MODE_SELECT10 0x55
  2431. #define SCSIOP_RESERVE_UNIT10 0x56
  2432. #define SCSIOP_RELEASE_UNIT10 0x57
  2433. #define SCSIOP_MODE_SENSE10 0x5A
  2434. #define SCSIOP_CLOSE_TRACK_SESSION 0x5B
  2435. #define SCSIOP_READ_BUFFER_CAPACITY 0x5C
  2436. #define SCSIOP_SEND_CUE_SHEET 0x5D
  2437. #define SCSIOP_PERSISTENT_RESERVE_IN 0x5E
  2438. #define SCSIOP_PERSISTENT_RESERVE_OUT 0x5F
  2439. // 12-byte commands
  2440. #define SCSIOP_REPORT_LUNS 0xA0
  2441. #define SCSIOP_BLANK 0xA1
  2442. #define SCSIOP_SEND_KEY 0xA3
  2443. #define SCSIOP_REPORT_KEY 0xA4
  2444. #define SCSIOP_MOVE_MEDIUM 0xA5
  2445. #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
  2446. #define SCSIOP_EXCHANGE_MEDIUM 0xA6
  2447. #define SCSIOP_SET_READ_AHEAD 0xA7
  2448. #define SCSIOP_READ_DVD_STRUCTURE 0xAD
  2449. #define SCSIOP_REQUEST_VOL_ELEMENT 0xB5
  2450. #define SCSIOP_SEND_VOLUME_TAG 0xB6
  2451. #define SCSIOP_READ_ELEMENT_STATUS 0xB8
  2452. #define SCSIOP_READ_CD_MSF 0xB9
  2453. #define SCSIOP_SCAN_CD 0xBA
  2454. #define SCSIOP_SET_CD_SPEED 0xBB
  2455. #define SCSIOP_PLAY_CD 0xBC
  2456. #define SCSIOP_MECHANISM_STATUS 0xBD
  2457. #define SCSIOP_READ_CD 0xBE
  2458. #define SCSIOP_SEND_DVD_STRUCTURE 0xBF
  2459. #define SCSIOP_INIT_ELEMENT_RANGE 0xE7
  2460. //
  2461. // If the IMMED bit is 1, status is returned as soon
  2462. // as the operation is initiated. If the IMMED bit
  2463. // is 0, status is not returned until the operation
  2464. // is completed.
  2465. //
  2466. #define CDB_RETURN_ON_COMPLETION 0
  2467. #define CDB_RETURN_IMMEDIATE 1
  2468. // end_ntminitape
  2469. //
  2470. // CDB Force media access used in extended read and write commands.
  2471. //
  2472. #define CDB_FORCE_MEDIA_ACCESS 0x08
  2473. //
  2474. // Denon CD ROM operation codes
  2475. //
  2476. #define SCSIOP_DENON_EJECT_DISC 0xE6
  2477. #define SCSIOP_DENON_STOP_AUDIO 0xE7
  2478. #define SCSIOP_DENON_PLAY_AUDIO 0xE8
  2479. #define SCSIOP_DENON_READ_TOC 0xE9
  2480. #define SCSIOP_DENON_READ_SUBCODE 0xEB
  2481. //
  2482. // SCSI Bus Messages
  2483. //
  2484. #define SCSIMESS_ABORT 0x06
  2485. #define SCSIMESS_ABORT_WITH_TAG 0x0D
  2486. #define SCSIMESS_BUS_DEVICE_RESET 0X0C
  2487. #define SCSIMESS_CLEAR_QUEUE 0X0E
  2488. #define SCSIMESS_COMMAND_COMPLETE 0X00
  2489. #define SCSIMESS_DISCONNECT 0X04
  2490. #define SCSIMESS_EXTENDED_MESSAGE 0X01
  2491. #define SCSIMESS_IDENTIFY 0X80
  2492. #define SCSIMESS_IDENTIFY_WITH_DISCON 0XC0
  2493. #define SCSIMESS_IGNORE_WIDE_RESIDUE 0X23
  2494. #define SCSIMESS_INITIATE_RECOVERY 0X0F
  2495. #define SCSIMESS_INIT_DETECTED_ERROR 0X05
  2496. #define SCSIMESS_LINK_CMD_COMP 0X0A
  2497. #define SCSIMESS_LINK_CMD_COMP_W_FLAG 0X0B
  2498. #define SCSIMESS_MESS_PARITY_ERROR 0X09
  2499. #define SCSIMESS_MESSAGE_REJECT 0X07
  2500. #define SCSIMESS_NO_OPERATION 0X08
  2501. #define SCSIMESS_HEAD_OF_QUEUE_TAG 0X21
  2502. #define SCSIMESS_ORDERED_QUEUE_TAG 0X22
  2503. #define SCSIMESS_SIMPLE_QUEUE_TAG 0X20
  2504. #define SCSIMESS_RELEASE_RECOVERY 0X10
  2505. #define SCSIMESS_RESTORE_POINTERS 0X03
  2506. #define SCSIMESS_SAVE_DATA_POINTER 0X02
  2507. #define SCSIMESS_TERMINATE_IO_PROCESS 0X11
  2508. //
  2509. // SCSI Extended Message operation codes
  2510. //
  2511. #define SCSIMESS_MODIFY_DATA_POINTER 0X00
  2512. #define SCSIMESS_SYNCHRONOUS_DATA_REQ 0X01
  2513. #define SCSIMESS_WIDE_DATA_REQUEST 0X03
  2514. //
  2515. // SCSI Extended Message Lengths
  2516. //
  2517. #define SCSIMESS_MODIFY_DATA_LENGTH 5
  2518. #define SCSIMESS_SYNCH_DATA_LENGTH 3
  2519. #define SCSIMESS_WIDE_DATA_LENGTH 2
  2520. //
  2521. // SCSI extended message structure
  2522. //
  2523. #pragma pack (1)
  2524. typedef struct _SCSI_EXTENDED_MESSAGE {
  2525. UCHAR InitialMessageCode;
  2526. UCHAR MessageLength;
  2527. UCHAR MessageType;
  2528. union _EXTENDED_ARGUMENTS {
  2529. struct {
  2530. UCHAR Modifier[4];
  2531. } Modify;
  2532. struct {
  2533. UCHAR TransferPeriod;
  2534. UCHAR ReqAckOffset;
  2535. } Synchronous;
  2536. struct{
  2537. UCHAR Width;
  2538. } Wide;
  2539. }ExtendedArguments;
  2540. }SCSI_EXTENDED_MESSAGE, *PSCSI_EXTENDED_MESSAGE;
  2541. #pragma pack ()
  2542. //
  2543. // SCSI bus status codes.
  2544. //
  2545. #define SCSISTAT_GOOD 0x00
  2546. #define SCSISTAT_CHECK_CONDITION 0x02
  2547. #define SCSISTAT_CONDITION_MET 0x04
  2548. #define SCSISTAT_BUSY 0x08
  2549. #define SCSISTAT_INTERMEDIATE 0x10
  2550. #define SCSISTAT_INTERMEDIATE_COND_MET 0x14
  2551. #define SCSISTAT_RESERVATION_CONFLICT 0x18
  2552. #define SCSISTAT_COMMAND_TERMINATED 0x22
  2553. #define SCSISTAT_QUEUE_FULL 0x28
  2554. //
  2555. // Enable Vital Product Data Flag (EVPD)
  2556. // used with INQUIRY command.
  2557. //
  2558. #define CDB_INQUIRY_EVPD 0x01
  2559. //
  2560. // Defines for format CDB
  2561. //
  2562. #define LUN0_FORMAT_SAVING_DEFECT_LIST 0
  2563. #define USE_DEFAULTMSB 0
  2564. #define USE_DEFAULTLSB 0
  2565. #define START_UNIT_CODE 0x01
  2566. #define STOP_UNIT_CODE 0x00
  2567. //
  2568. // Inquiry buffer structure. This is the data returned from the target
  2569. // after it receives an inquiry.
  2570. //
  2571. // This structure may be extended by the number of bytes specified
  2572. // in the field AdditionalLength. The defined size constant only
  2573. // includes fields through ProductRevisionLevel.
  2574. //
  2575. // The NT SCSI drivers are only interested in the first 36 bytes of data.
  2576. //
  2577. #define INQUIRYDATABUFFERSIZE 36
  2578. typedef struct _INQUIRYDATA {
  2579. UCHAR DeviceType : 5;
  2580. UCHAR DeviceTypeQualifier : 3;
  2581. UCHAR DeviceTypeModifier : 7;
  2582. UCHAR RemovableMedia : 1;
  2583. union {
  2584. UCHAR Versions;
  2585. struct {
  2586. UCHAR ANSIVersion : 3;
  2587. UCHAR ECMAVersion : 3;
  2588. UCHAR ISOVersion : 2;
  2589. };
  2590. };
  2591. UCHAR ResponseDataFormat : 4;
  2592. UCHAR HiSupport : 1;
  2593. UCHAR NormACA : 1;
  2594. UCHAR TerminateTask : 1;
  2595. UCHAR AERC : 1;
  2596. UCHAR AdditionalLength;
  2597. UCHAR Reserved;
  2598. UCHAR Addr16 : 1; // defined only for SIP devices.
  2599. UCHAR Addr32 : 1; // defined only for SIP devices.
  2600. UCHAR AckReqQ: 1; // defined only for SIP devices.
  2601. UCHAR MediumChanger : 1;
  2602. UCHAR MultiPort : 1;
  2603. UCHAR ReservedBit2 : 1;
  2604. UCHAR EnclosureServices : 1;
  2605. UCHAR ReservedBit3 : 1;
  2606. UCHAR SoftReset : 1;
  2607. UCHAR CommandQueue : 1;
  2608. UCHAR TransferDisable : 1; // defined only for SIP devices.
  2609. UCHAR LinkedCommands : 1;
  2610. UCHAR Synchronous : 1; // defined only for SIP devices.
  2611. UCHAR Wide16Bit : 1; // defined only for SIP devices.
  2612. UCHAR Wide32Bit : 1; // defined only for SIP devices.
  2613. UCHAR RelativeAddressing : 1;
  2614. UCHAR VendorId[8];
  2615. UCHAR ProductId[16];
  2616. UCHAR ProductRevisionLevel[4];
  2617. UCHAR VendorSpecific[20];
  2618. UCHAR Reserved3[40];
  2619. } INQUIRYDATA, *PINQUIRYDATA;
  2620. //
  2621. // Inquiry defines. Used to interpret data returned from target as result
  2622. // of inquiry command.
  2623. //
  2624. // DeviceType field
  2625. //
  2626. #define DIRECT_ACCESS_DEVICE 0x00 // disks
  2627. #define SEQUENTIAL_ACCESS_DEVICE 0x01 // tapes
  2628. #define PRINTER_DEVICE 0x02 // printers
  2629. #define PROCESSOR_DEVICE 0x03 // scanners, printers, etc
  2630. #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04 // worms
  2631. #define READ_ONLY_DIRECT_ACCESS_DEVICE 0x05 // cdroms
  2632. #define SCANNER_DEVICE 0x06 // scanners
  2633. #define OPTICAL_DEVICE 0x07 // optical disks
  2634. #define MEDIUM_CHANGER 0x08 // jukebox
  2635. #define COMMUNICATION_DEVICE 0x09 // network
  2636. #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
  2637. #define DEVICE_QUALIFIER_ACTIVE 0x00
  2638. #define DEVICE_QUALIFIER_NOT_ACTIVE 0x01
  2639. #define DEVICE_QUALIFIER_NOT_SUPPORTED 0x03
  2640. //
  2641. // DeviceTypeQualifier field
  2642. //
  2643. #define DEVICE_CONNECTED 0x00
  2644. //
  2645. // Vital Product Data Pages
  2646. //
  2647. //
  2648. // Unit Serial Number Page (page code 0x80)
  2649. //
  2650. // Provides a product serial number for the target or the logical unit.
  2651. //
  2652. typedef struct _VPD_SERIAL_NUMBER_PAGE {
  2653. UCHAR DeviceType : 5;
  2654. UCHAR DeviceTypeQualifier : 3;
  2655. UCHAR PageCode;
  2656. UCHAR Reserved;
  2657. UCHAR PageLength;
  2658. UCHAR SerialNumber[0];
  2659. } VPD_SERIAL_NUMBER_PAGE, *PVPD_SERIAL_NUMBER_PAGE;
  2660. //
  2661. // Device Identification Page (page code 0x83)
  2662. // Provides the means to retrieve zero or more identification descriptors
  2663. // applying to the logical unit.
  2664. //
  2665. typedef enum _VPD_CODE_SET {
  2666. VpdCodeSetReserved = 0,
  2667. VpdCodeSetBinary = 1,
  2668. VpdCodeSetAscii = 2
  2669. } VPD_CODE_SET, *PVPD_CODE_SET;
  2670. typedef enum _VPD_IDENTIFIER_TYPE {
  2671. VpdIdentifierTypeVendorSpecific = 0,
  2672. VpdIdentifierTypeVendorId = 1,
  2673. VpdIdentifierTypeEUI64 = 2,
  2674. VpdIdentifierTypeFCPHName = 3,
  2675. VpdIdentifierTypePortRelative = 4
  2676. } VPD_IDENTIFIER_TYPE, *PVPD_IDENTIFIER_TYPE;
  2677. typedef struct _VPD_IDENTIFICATION_DESCRIPTOR {
  2678. UCHAR CodeSet : 4; // VPD_CODE_SET
  2679. UCHAR Reserved : 4;
  2680. UCHAR IdentifierType : 4; // VPD_IDENTIFIER_TYPE
  2681. UCHAR Association : 2;
  2682. UCHAR Reserved2 : 2;
  2683. UCHAR Reserved3;
  2684. UCHAR IdentifierLength;
  2685. UCHAR Identifier[0];
  2686. } VPD_IDENTIFICATION_DESCRIPTOR, *PVPD_IDENTIFICATION_DESCRIPTOR;
  2687. typedef struct _VPD_IDENTIFICATION_PAGE {
  2688. UCHAR DeviceType : 5;
  2689. UCHAR DeviceTypeQualifier : 3;
  2690. UCHAR PageCode;
  2691. UCHAR Reserved;
  2692. UCHAR PageLength;
  2693. //
  2694. // The following field is actually a variable length array of identification
  2695. // descriptors. Unfortunately there's no C notation for an array of
  2696. // variable length structures so we're forced to just pretend.
  2697. //
  2698. // VPD_IDENTIFICATION_DESCRIPTOR Descriptors[0];
  2699. UCHAR Descriptors[0];
  2700. } VPD_IDENTIFICATION_PAGE, *PVPD_IDENTIFICATION_PAGE;
  2701. //
  2702. // Supported Vital Product Data Pages Page (page code 0x00)
  2703. // Contains a list of the vital product data page cods supported by the target
  2704. // or logical unit.
  2705. //
  2706. typedef struct _VPD_SUPPORTED_PAGES_PAGE {
  2707. UCHAR DeviceType : 5;
  2708. UCHAR DeviceTypeQualifier : 3;
  2709. UCHAR PageCode;
  2710. UCHAR Reserved;
  2711. UCHAR PageLength;
  2712. UCHAR SupportedPageList[0];
  2713. } VPD_SUPPORTED_PAGES_PAGE, *PVPD_SUPPORTED_PAGES_PAGE;
  2714. #define VPD_MAX_BUFFER_SIZE 0xff
  2715. #define VPD_SUPPORTED_PAGES 0x00
  2716. #define VPD_SERIAL_NUMBER 0x80
  2717. #define VPD_DEVICE_IDENTIFIERS 0x83
  2718. //
  2719. // Persistent Reservation Definitions.
  2720. //
  2721. //
  2722. // PERSISTENT_RESERVE_* definitions
  2723. //
  2724. #define RESERVATION_ACTION_READ_KEYS 0x00
  2725. #define RESERVATION_ACTION_READ_RESERVATIONS 0x01
  2726. #define RESERVATION_ACTION_REGISTER 0x00
  2727. #define RESERVATION_ACTION_RESERVE 0x01
  2728. #define RESERVATION_ACTION_RELEASE 0x02
  2729. #define RESERVATION_ACTION_CLEAR 0x03
  2730. #define RESERVATION_ACTION_PREEMPT 0x04
  2731. #define RESERVATION_ACTION_PREEMPT_ABORT 0x05
  2732. #define RESERVATION_ACTION_REGISTER_IGNORE_EXISTING 0x06
  2733. #define RESERVATION_SCOPE_LU 0x00
  2734. #define RESERVATION_SCOPE_ELEMENT 0x02
  2735. #define RESERVATION_TYPE_WRITE_EXCLUSIVE 0x01
  2736. #define RESERVATION_TYPE_EXCLUSIVE 0x03
  2737. #define RESERVATION_TYPE_WRITE_EXCLUSIVE_REGISTRANTS 0x05
  2738. #define RESERVATION_TYPE_EXCLUSIVE_REGISTRANTS 0x06
  2739. //
  2740. // Structures for reserve in command.
  2741. //
  2742. typedef struct {
  2743. UCHAR Generation[4];
  2744. UCHAR AdditionalLength[4];
  2745. UCHAR ReservationKeyList[0][8];
  2746. } PRI_REGISTRATION_LIST, *PPRI_REGISTRATION_LIST;
  2747. typedef struct {
  2748. UCHAR ReservationKey[8];
  2749. UCHAR ScopeSpecificAddress[4];
  2750. UCHAR Reserved;
  2751. UCHAR Type : 4;
  2752. UCHAR Scope : 4;
  2753. UCHAR Obsolete[2];
  2754. } PRI_RESERVATION_DESCRIPTOR, *PPRI_RESERVATION_DESCRIPTOR;
  2755. typedef struct {
  2756. UCHAR Generation[4];
  2757. UCHAR AdditionalLength[4];
  2758. PRI_RESERVATION_DESCRIPTOR Reservations[0];
  2759. } PRI_RESERVATION_LIST, *PPRI_RESERVATION_LIST;
  2760. //
  2761. // Structures for reserve out command.
  2762. //
  2763. typedef struct {
  2764. UCHAR ReservationKey[8];
  2765. UCHAR ServiceActionReservationKey[8];
  2766. UCHAR ScopeSpecificAddress[4];
  2767. UCHAR ActivatePersistThroughPowerLoss : 1;
  2768. UCHAR Reserved1 : 7;
  2769. UCHAR Reserved2;
  2770. UCHAR Obsolete[2];
  2771. } PRO_PARAMETER_LIST, *PPRO_PARAMETER_LIST;
  2772. //
  2773. // Sense Data Format
  2774. //
  2775. typedef struct _SENSE_DATA {
  2776. UCHAR ErrorCode:7;
  2777. UCHAR Valid:1;
  2778. UCHAR SegmentNumber;
  2779. UCHAR SenseKey:4;
  2780. UCHAR Reserved:1;
  2781. UCHAR IncorrectLength:1;
  2782. UCHAR EndOfMedia:1;
  2783. UCHAR FileMark:1;
  2784. UCHAR Information[4];
  2785. UCHAR AdditionalSenseLength;
  2786. UCHAR CommandSpecificInformation[4];
  2787. UCHAR AdditionalSenseCode;
  2788. UCHAR AdditionalSenseCodeQualifier;
  2789. UCHAR FieldReplaceableUnitCode;
  2790. UCHAR SenseKeySpecific[3];
  2791. } SENSE_DATA, *PSENSE_DATA;
  2792. //
  2793. // Default request sense buffer size
  2794. //
  2795. #define SENSE_BUFFER_SIZE 18
  2796. //
  2797. // Maximum request sense buffer size
  2798. //
  2799. #define MAX_SENSE_BUFFER_SIZE 255
  2800. //
  2801. // Maximum number of additional sense bytes.
  2802. //
  2803. #define MAX_ADDITIONAL_SENSE_BYTES (MAX_SENSE_BUFFER_SIZE - SENSE_BUFFER_SIZE)
  2804. //
  2805. // Sense codes
  2806. //
  2807. #define SCSI_SENSE_NO_SENSE 0x00
  2808. #define SCSI_SENSE_RECOVERED_ERROR 0x01
  2809. #define SCSI_SENSE_NOT_READY 0x02
  2810. #define SCSI_SENSE_MEDIUM_ERROR 0x03
  2811. #define SCSI_SENSE_HARDWARE_ERROR 0x04
  2812. #define SCSI_SENSE_ILLEGAL_REQUEST 0x05
  2813. #define SCSI_SENSE_UNIT_ATTENTION 0x06
  2814. #define SCSI_SENSE_DATA_PROTECT 0x07
  2815. #define SCSI_SENSE_BLANK_CHECK 0x08
  2816. #define SCSI_SENSE_UNIQUE 0x09
  2817. #define SCSI_SENSE_COPY_ABORTED 0x0A
  2818. #define SCSI_SENSE_ABORTED_COMMAND 0x0B
  2819. #define SCSI_SENSE_EQUAL 0x0C
  2820. #define SCSI_SENSE_VOL_OVERFLOW 0x0D
  2821. #define SCSI_SENSE_MISCOMPARE 0x0E
  2822. #define SCSI_SENSE_RESERVED 0x0F
  2823. //
  2824. // Additional tape bit
  2825. //
  2826. #define SCSI_ILLEGAL_LENGTH 0x20
  2827. #define SCSI_EOM 0x40
  2828. #define SCSI_FILE_MARK 0x80
  2829. //
  2830. // Additional Sense codes
  2831. //
  2832. #define SCSI_ADSENSE_NO_SENSE 0x00
  2833. #define SCSI_ADSENSE_LUN_NOT_READY 0x04
  2834. #define SCSI_ADSENSE_TRACK_ERROR 0x14
  2835. #define SCSI_ADSENSE_SEEK_ERROR 0x15
  2836. #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
  2837. #define SCSI_ADSENSE_REC_DATA_ECC 0x18
  2838. #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
  2839. #define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
  2840. #define SCSI_ADSENSE_INVALID_CDB 0x24
  2841. #define SCSI_ADSENSE_INVALID_LUN 0x25
  2842. #define SCSI_ADSENSE_WRITE_PROTECT 0x27
  2843. #define SCSI_ADWRITE_PROTECT 0x27 // Legacy define
  2844. #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
  2845. #define SCSI_ADSENSE_BUS_RESET 0x29
  2846. #define SCSI_ADSENSE_INVALID_MEDIA 0x30
  2847. #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
  2848. #define SCSI_ADSENSE_POSITION_ERROR 0x3b
  2849. #define SCSI_ADSENSE_OPERATOR_REQUEST 0x5a // see below
  2850. // the second is for legacy apps.
  2851. #define SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED 0x5d
  2852. #define SCSI_FAILURE_PREDICTION_THRESHOLD_EXCEEDED SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED
  2853. #define SCSI_ADSENSE_COPY_PROTECTION_FAILURE 0x6f
  2854. #define SCSI_ADSENSE_VENDOR_UNIQUE 0x80
  2855. #define SCSI_ADSENSE_MUSIC_AREA 0xA0
  2856. #define SCSI_ADSENSE_DATA_AREA 0xA1
  2857. #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
  2858. //
  2859. // SCSI_ADSENSE_LUN_NOT_READY (0x04) qualifiers
  2860. //
  2861. #define SCSI_SENSEQ_CAUSE_NOT_REPORTABLE 0x00
  2862. #define SCSI_SENSEQ_BECOMING_READY 0x01
  2863. #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED 0x02
  2864. #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
  2865. #define SCSI_SENSEQ_FORMAT_IN_PROGRESS 0x04
  2866. #define SCSI_SENSEQ_REBUILD_IN_PROGRESS 0x05
  2867. #define SCSI_SENSEQ_RECALCULATION_IN_PROGRESS 0x06
  2868. #define SCSI_SENSEQ_OPERATION_IN_PROGRESS 0x07
  2869. #define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS 0x08
  2870. //
  2871. // SCSI_ADSENSE_NO_SENSE (0x00) qualifiers
  2872. //
  2873. #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
  2874. #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
  2875. #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
  2876. #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
  2877. //
  2878. // SCSI_ADSENSE_ILLEGAL_BLOCK (0x21) qualifiers
  2879. //
  2880. #define SCSI_SENSEQ_ILLEGAL_ELEMENT_ADDR 0x01
  2881. //
  2882. // SCSI_ADSENSE_POSITION_ERROR (0x3b) qualifiers
  2883. //
  2884. #define SCSI_SENSEQ_DESTINATION_FULL 0x0d
  2885. #define SCSI_SENSEQ_SOURCE_EMPTY 0x0e
  2886. //
  2887. // SCSI_ADSENSE_INVALID_MEDIA (0x30) qualifiers
  2888. //
  2889. #define SCSI_SENSEQ_INCOMPATIBLE_MEDIA_INSTALLED 0x00
  2890. #define SCSI_SENSEQ_UNKNOWN_FORMAT 0x01
  2891. #define SCSI_SENSEQ_INCOMPATIBLE_FORMAT 0x02
  2892. #define SCSI_SENSEQ_CLEANING_CARTRIDGE_INSTALLED 0x03
  2893. //
  2894. // SCSI_ADSENSE_OPERATOR_REQUEST (0x5a) qualifiers
  2895. //
  2896. #define SCSI_SENSEQ_STATE_CHANGE_INPUT 0x00 // generic request
  2897. #define SCSI_SENSEQ_MEDIUM_REMOVAL 0x01
  2898. #define SCSI_SENSEQ_WRITE_PROTECT_ENABLE 0x02
  2899. #define SCSI_SENSEQ_WRITE_PROTECT_DISABLE 0x03
  2900. //
  2901. // SCSI_ADSENSE_COPY_PROTECTION_FAILURE (0x6f) qualifiers
  2902. //
  2903. #define SCSI_SENSEQ_AUTHENTICATION_FAILURE 0x00
  2904. #define SCSI_SENSEQ_KEY_NOT_PRESENT 0x01
  2905. #define SCSI_SENSEQ_KEY_NOT_ESTABLISHED 0x02
  2906. #define SCSI_SENSEQ_READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION 0x03
  2907. #define SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT 0x04
  2908. #define SCSI_SENSEQ_LOGICAL_UNIT_RESET_COUNT_ERROR 0x05
  2909. // end_ntminitape
  2910. //
  2911. // SCSI IO Device Control Codes
  2912. //
  2913. #define FILE_DEVICE_SCSI 0x0000001b
  2914. #define IOCTL_SCSI_EXECUTE_IN ((FILE_DEVICE_SCSI << 16) + 0x0011)
  2915. #define IOCTL_SCSI_EXECUTE_OUT ((FILE_DEVICE_SCSI << 16) + 0x0012)
  2916. #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
  2917. //
  2918. // SMART support in atapi
  2919. //
  2920. #define IOCTL_SCSI_MINIPORT_SMART_VERSION ((FILE_DEVICE_SCSI << 16) + 0x0500)
  2921. #define IOCTL_SCSI_MINIPORT_IDENTIFY ((FILE_DEVICE_SCSI << 16) + 0x0501)
  2922. #define IOCTL_SCSI_MINIPORT_READ_SMART_ATTRIBS ((FILE_DEVICE_SCSI << 16) + 0x0502)
  2923. #define IOCTL_SCSI_MINIPORT_READ_SMART_THRESHOLDS ((FILE_DEVICE_SCSI << 16) + 0x0503)
  2924. #define IOCTL_SCSI_MINIPORT_ENABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0504)
  2925. #define IOCTL_SCSI_MINIPORT_DISABLE_SMART ((FILE_DEVICE_SCSI << 16) + 0x0505)
  2926. #define IOCTL_SCSI_MINIPORT_RETURN_STATUS ((FILE_DEVICE_SCSI << 16) + 0x0506)
  2927. #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTOSAVE ((FILE_DEVICE_SCSI << 16) + 0x0507)
  2928. #define IOCTL_SCSI_MINIPORT_SAVE_ATTRIBUTE_VALUES ((FILE_DEVICE_SCSI << 16) + 0x0508)
  2929. #define IOCTL_SCSI_MINIPORT_EXECUTE_OFFLINE_DIAGS ((FILE_DEVICE_SCSI << 16) + 0x0509)
  2930. #define IOCTL_SCSI_MINIPORT_ENABLE_DISABLE_AUTO_OFFLINE ((FILE_DEVICE_SCSI << 16) + 0x050a)
  2931. #define IOCTL_SCSI_MINIPORT_READ_SMART_LOG ((FILE_DEVICE_SCSI << 16) + 0x050b)
  2932. #define IOCTL_SCSI_MINIPORT_WRITE_SMART_LOG ((FILE_DEVICE_SCSI << 16) + 0x050c)
  2933. //
  2934. // CLUSTER support
  2935. // deliberately skipped some values to allow for expansion above.
  2936. //
  2937. #define IOCTL_SCSI_MINIPORT_NOT_QUORUM_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0520)
  2938. #define IOCTL_SCSI_MINIPORT_NOT_CLUSTER_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0521)
  2939. //
  2940. // Read Capacity Data - returned in Big Endian format
  2941. //
  2942. typedef struct _READ_CAPACITY_DATA {
  2943. ULONG LogicalBlockAddress;
  2944. ULONG BytesPerBlock;
  2945. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  2946. //
  2947. // Read Block Limits Data - returned in Big Endian format
  2948. // This structure returns the maximum and minimum block
  2949. // size for a TAPE device.
  2950. //
  2951. typedef struct _READ_BLOCK_LIMITS {
  2952. UCHAR Reserved;
  2953. UCHAR BlockMaximumSize[3];
  2954. UCHAR BlockMinimumSize[2];
  2955. } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
  2956. //
  2957. // Mode data structures.
  2958. //
  2959. //
  2960. // Define Mode parameter header.
  2961. //
  2962. typedef struct _MODE_PARAMETER_HEADER {
  2963. UCHAR ModeDataLength;
  2964. UCHAR MediumType;
  2965. UCHAR DeviceSpecificParameter;
  2966. UCHAR BlockDescriptorLength;
  2967. }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
  2968. typedef struct _MODE_PARAMETER_HEADER10 {
  2969. UCHAR ModeDataLength[2];
  2970. UCHAR MediumType;
  2971. UCHAR DeviceSpecificParameter;
  2972. UCHAR Reserved[2];
  2973. UCHAR BlockDescriptorLength[2];
  2974. }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
  2975. #define MODE_FD_SINGLE_SIDE 0x01
  2976. #define MODE_FD_DOUBLE_SIDE 0x02
  2977. #define MODE_FD_MAXIMUM_TYPE 0x1E
  2978. #define MODE_DSP_FUA_SUPPORTED 0x10
  2979. #define MODE_DSP_WRITE_PROTECT 0x80
  2980. //
  2981. // Define the mode parameter block.
  2982. //
  2983. typedef struct _MODE_PARAMETER_BLOCK {
  2984. UCHAR DensityCode;
  2985. UCHAR NumberOfBlocks[3];
  2986. UCHAR Reserved;
  2987. UCHAR BlockLength[3];
  2988. }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
  2989. //
  2990. // Define Disconnect-Reconnect page.
  2991. //
  2992. typedef struct _MODE_DISCONNECT_PAGE {
  2993. UCHAR PageCode : 6;
  2994. UCHAR Reserved : 1;
  2995. UCHAR PageSavable : 1;
  2996. UCHAR PageLength;
  2997. UCHAR BufferFullRatio;
  2998. UCHAR BufferEmptyRatio;
  2999. UCHAR BusInactivityLimit[2];
  3000. UCHAR BusDisconnectTime[2];
  3001. UCHAR BusConnectTime[2];
  3002. UCHAR MaximumBurstSize[2];
  3003. UCHAR DataTransferDisconnect : 2;
  3004. UCHAR Reserved2[3];
  3005. }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
  3006. //
  3007. // Define mode caching page.
  3008. //
  3009. typedef struct _MODE_CACHING_PAGE {
  3010. UCHAR PageCode : 6;
  3011. UCHAR Reserved : 1;
  3012. UCHAR PageSavable : 1;
  3013. UCHAR PageLength;
  3014. UCHAR ReadDisableCache : 1;
  3015. UCHAR MultiplicationFactor : 1;
  3016. UCHAR WriteCacheEnable : 1;
  3017. UCHAR Reserved2 : 5;
  3018. UCHAR WriteRetensionPriority : 4;
  3019. UCHAR ReadRetensionPriority : 4;
  3020. UCHAR DisablePrefetchTransfer[2];
  3021. UCHAR MinimumPrefetch[2];
  3022. UCHAR MaximumPrefetch[2];
  3023. UCHAR MaximumPrefetchCeiling[2];
  3024. }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
  3025. //
  3026. // Define write parameters cdrom page
  3027. //
  3028. typedef struct _MODE_CDROM_WRITE_PARAMETERS_PAGE {
  3029. UCHAR PageLength; // 0x32 ??
  3030. UCHAR WriteType : 4;
  3031. UCHAR TestWrite : 1;
  3032. UCHAR LinkSizeValid : 1;
  3033. UCHAR BufferUnderrunFreeEnabled : 1;
  3034. UCHAR Reserved2 : 1;
  3035. UCHAR TrackMode : 4;
  3036. UCHAR Copy : 1;
  3037. UCHAR FixedPacket : 1;
  3038. UCHAR MultiSession : 2;
  3039. UCHAR DataBlockType : 4;
  3040. UCHAR Reserved3 : 4;
  3041. UCHAR LinkSize;
  3042. UCHAR Reserved4;
  3043. UCHAR HostApplicationCode : 6;
  3044. UCHAR Reserved5 : 2;
  3045. UCHAR SessionFormat;
  3046. UCHAR Reserved6;
  3047. UCHAR PacketSize[4];
  3048. UCHAR AudioPauseLength[2];
  3049. UCHAR Reserved7 : 7;
  3050. UCHAR MediaCatalogNumberValid : 1;
  3051. UCHAR MediaCatalogNumber[13];
  3052. UCHAR MediaCatalogNumberZero;
  3053. UCHAR MediaCatalogNumberAFrame;
  3054. UCHAR Reserved8 : 7;
  3055. UCHAR ISRCValid : 1;
  3056. UCHAR ISRCCountry[2];
  3057. UCHAR ISRCOwner[3];
  3058. UCHAR ISRCRecordingYear[2];
  3059. UCHAR ISRCSerialNumber[5];
  3060. UCHAR ISRCZero;
  3061. UCHAR ISRCAFrame;
  3062. UCHAR ISRCReserved;
  3063. UCHAR SubHeaderData[4];
  3064. } MODE_CDROM_WRITE_PARAMETERS_PAGE, *PMODE_CDROM_WRITE_PARAMETERS_PAGE;
  3065. //
  3066. // Define mode flexible disk page.
  3067. //
  3068. typedef struct _MODE_FLEXIBLE_DISK_PAGE {
  3069. UCHAR PageCode : 6;
  3070. UCHAR Reserved : 1;
  3071. UCHAR PageSavable : 1;
  3072. UCHAR PageLength;
  3073. UCHAR TransferRate[2];
  3074. UCHAR NumberOfHeads;
  3075. UCHAR SectorsPerTrack;
  3076. UCHAR BytesPerSector[2];
  3077. UCHAR NumberOfCylinders[2];
  3078. UCHAR StartWritePrecom[2];
  3079. UCHAR StartReducedCurrent[2];
  3080. UCHAR StepRate[2];
  3081. UCHAR StepPluseWidth;
  3082. UCHAR HeadSettleDelay[2];
  3083. UCHAR MotorOnDelay;
  3084. UCHAR MotorOffDelay;
  3085. UCHAR Reserved2 : 5;
  3086. UCHAR MotorOnAsserted : 1;
  3087. UCHAR StartSectorNumber : 1;
  3088. UCHAR TrueReadySignal : 1;
  3089. UCHAR StepPlusePerCyclynder : 4;
  3090. UCHAR Reserved3 : 4;
  3091. UCHAR WriteCompenstation;
  3092. UCHAR HeadLoadDelay;
  3093. UCHAR HeadUnloadDelay;
  3094. UCHAR Pin2Usage : 4;
  3095. UCHAR Pin34Usage : 4;
  3096. UCHAR Pin1Usage : 4;
  3097. UCHAR Pin4Usage : 4;
  3098. UCHAR MediumRotationRate[2];
  3099. UCHAR Reserved4[2];
  3100. }MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
  3101. //
  3102. // Define mode format page.
  3103. //
  3104. typedef struct _MODE_FORMAT_PAGE {
  3105. UCHAR PageCode : 6;
  3106. UCHAR Reserved : 1;
  3107. UCHAR PageSavable : 1;
  3108. UCHAR PageLength;
  3109. UCHAR TracksPerZone[2];
  3110. UCHAR AlternateSectorsPerZone[2];
  3111. UCHAR AlternateTracksPerZone[2];
  3112. UCHAR AlternateTracksPerLogicalUnit[2];
  3113. UCHAR SectorsPerTrack[2];
  3114. UCHAR BytesPerPhysicalSector[2];
  3115. UCHAR Interleave[2];
  3116. UCHAR TrackSkewFactor[2];
  3117. UCHAR CylinderSkewFactor[2];
  3118. UCHAR Reserved2 : 4;
  3119. UCHAR SurfaceFirst : 1;
  3120. UCHAR RemovableMedia : 1;
  3121. UCHAR HardSectorFormating : 1;
  3122. UCHAR SoftSectorFormating : 1;
  3123. UCHAR Reserved3[3];
  3124. }MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
  3125. //
  3126. // Define rigid disk driver geometry page.
  3127. //
  3128. typedef struct _MODE_RIGID_GEOMETRY_PAGE {
  3129. UCHAR PageCode : 6;
  3130. UCHAR Reserved : 1;
  3131. UCHAR PageSavable : 1;
  3132. UCHAR PageLength;
  3133. UCHAR NumberOfCylinders[3];
  3134. UCHAR NumberOfHeads;
  3135. UCHAR StartWritePrecom[3];
  3136. UCHAR StartReducedCurrent[3];
  3137. UCHAR DriveStepRate[2];
  3138. UCHAR LandZoneCyclinder[3];
  3139. UCHAR RotationalPositionLock : 2;
  3140. UCHAR Reserved2 : 6;
  3141. UCHAR RotationOffset;
  3142. UCHAR Reserved3;
  3143. UCHAR RoataionRate[2];
  3144. UCHAR Reserved4[2];
  3145. }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
  3146. //
  3147. // Define read write recovery page
  3148. //
  3149. typedef struct _MODE_READ_WRITE_RECOVERY_PAGE {
  3150. UCHAR PageCode : 6;
  3151. UCHAR Reserved1 : 1;
  3152. UCHAR PSBit : 1;
  3153. UCHAR PageLength;
  3154. UCHAR DCRBit : 1;
  3155. UCHAR DTEBit : 1;
  3156. UCHAR PERBit : 1;
  3157. UCHAR EERBit : 1;
  3158. UCHAR RCBit : 1;
  3159. UCHAR TBBit : 1;
  3160. UCHAR ARRE : 1;
  3161. UCHAR AWRE : 1;
  3162. UCHAR ReadRetryCount;
  3163. UCHAR Reserved4[4];
  3164. UCHAR WriteRetryCount;
  3165. UCHAR Reserved5[3];
  3166. } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
  3167. //
  3168. // Define read recovery page - cdrom
  3169. //
  3170. typedef struct _MODE_READ_RECOVERY_PAGE {
  3171. UCHAR PageCode : 6;
  3172. UCHAR Reserved1 : 1;
  3173. UCHAR PSBit : 1;
  3174. UCHAR PageLength;
  3175. UCHAR DCRBit : 1;
  3176. UCHAR DTEBit : 1;
  3177. UCHAR PERBit : 1;
  3178. UCHAR Reserved2 : 1;
  3179. UCHAR RCBit : 1;
  3180. UCHAR TBBit : 1;
  3181. UCHAR Reserved3 : 2;
  3182. UCHAR ReadRetryCount;
  3183. UCHAR Reserved4[4];
  3184. } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
  3185. //
  3186. // Define Informational Exception Control Page. Used for failure prediction
  3187. //
  3188. typedef struct _MODE_INFO_EXCEPTIONS
  3189. {
  3190. UCHAR PageCode : 6;
  3191. UCHAR Reserved1 : 1;
  3192. UCHAR PSBit : 1;
  3193. UCHAR PageLength;
  3194. union
  3195. {
  3196. UCHAR Flags;
  3197. struct
  3198. {
  3199. UCHAR LogErr : 1;
  3200. UCHAR Reserved2 : 1;
  3201. UCHAR Test : 1;
  3202. UCHAR Dexcpt : 1;
  3203. UCHAR Reserved3 : 3;
  3204. UCHAR Perf : 1;
  3205. };
  3206. };
  3207. UCHAR ReportMethod : 4;
  3208. UCHAR Reserved4 : 4;
  3209. UCHAR IntervalTimer[4];
  3210. UCHAR ReportCount[4];
  3211. } MODE_INFO_EXCEPTIONS, *PMODE_INFO_EXCEPTIONS;
  3212. //
  3213. // Begin C/DVD 0.9 definitions
  3214. //
  3215. //
  3216. // Power Condition Mode Page Format
  3217. //
  3218. typedef struct _POWER_CONDITION_PAGE {
  3219. UCHAR PageCode : 6; // 0x1A
  3220. UCHAR Reserved : 1;
  3221. UCHAR PSBit : 1;
  3222. UCHAR PageLength; // 0x0A
  3223. UCHAR Reserved2;
  3224. UCHAR Standby : 1;
  3225. UCHAR Idle : 1;
  3226. UCHAR Reserved3 : 6;
  3227. UCHAR IdleTimer[4];
  3228. UCHAR StandbyTimer[4];
  3229. } POWER_CONDITION_PAGE, *PPOWER_CONDITION_PAGE;
  3230. //
  3231. // CD-Audio Control Mode Page Format
  3232. //
  3233. typedef struct _CDDA_OUTPUT_PORT {
  3234. UCHAR ChannelSelection : 4;
  3235. UCHAR Reserved : 4;
  3236. UCHAR Volume;
  3237. } CDDA_OUTPUT_PORT, *PCDDA_OUTPUT_PORT;
  3238. typedef struct _CDAUDIO_CONTROL_PAGE {
  3239. UCHAR PageCode : 6; // 0x0E
  3240. UCHAR Reserved : 1;
  3241. UCHAR PSBit : 1;
  3242. UCHAR PageLength; // 0x0E
  3243. UCHAR Reserved2 : 1;
  3244. UCHAR StopOnTrackCrossing : 1; // Default 0
  3245. UCHAR Immediate : 1; // Always 1
  3246. UCHAR Reserved3 : 5;
  3247. UCHAR Reserved4[3];
  3248. UCHAR Obsolete[2];
  3249. CDDA_OUTPUT_PORT CDDAOutputPorts[4];
  3250. } CDAUDIO_CONTROL_PAGE, *PCDAUDIO_CONTROL_PAGE;
  3251. #define CDDA_CHANNEL_MUTED 0x0
  3252. #define CDDA_CHANNEL_ZERO 0x1
  3253. #define CDDA_CHANNEL_ONE 0x2
  3254. #define CDDA_CHANNEL_TWO 0x4
  3255. #define CDDA_CHANNEL_THREE 0x8
  3256. //
  3257. // C/DVD Feature Set Support & Version Page
  3258. //
  3259. typedef struct _CDVD_FEATURE_SET_PAGE {
  3260. UCHAR PageCode : 6; // 0x18
  3261. UCHAR Reserved : 1;
  3262. UCHAR PSBit : 1;
  3263. UCHAR PageLength; // 0x16
  3264. UCHAR CDAudio[2];
  3265. UCHAR EmbeddedChanger[2];
  3266. UCHAR PacketSMART[2];
  3267. UCHAR PersistantPrevent[2];
  3268. UCHAR EventStatusNotification[2];
  3269. UCHAR DigitalOutput[2];
  3270. UCHAR CDSequentialRecordable[2];
  3271. UCHAR DVDSequentialRecordable[2];
  3272. UCHAR RandomRecordable[2];
  3273. UCHAR KeyExchange[2];
  3274. UCHAR Reserved2[2];
  3275. } CDVD_FEATURE_SET_PAGE, *PCDVD_FEATURE_SET_PAGE;
  3276. //
  3277. // CDVD Inactivity Time-out Page Format
  3278. //
  3279. typedef struct _CDVD_INACTIVITY_TIMEOUT_PAGE {
  3280. UCHAR PageCode : 6; // 0x1D
  3281. UCHAR Reserved : 1;
  3282. UCHAR PSBit : 1;
  3283. UCHAR PageLength; // 0x08
  3284. UCHAR Reserved2[2];
  3285. UCHAR SWPP : 1;
  3286. UCHAR DISP : 1;
  3287. UCHAR Reserved3 : 6;
  3288. UCHAR Reserved4;
  3289. UCHAR GroupOneMinimumTimeout[2];
  3290. UCHAR GroupTwoMinimumTimeout[2];
  3291. } CDVD_INACTIVITY_TIMEOUT_PAGE, *PCDVD_INACTIVITY_TIMEOUT_PAGE;
  3292. //
  3293. // CDVD Capabilities & Mechanism Status Page
  3294. //
  3295. #define CDVD_LMT_CADDY 0
  3296. #define CDVD_LMT_TRAY 1
  3297. #define CDVD_LMT_POPUP 2
  3298. #define CDVD_LMT_RESERVED1 3
  3299. #define CDVD_LMT_CHANGER_INDIVIDUAL 4
  3300. #define CDVD_LMT_CHANGER_CARTRIDGE 5
  3301. #define CDVD_LMT_RESERVED2 6
  3302. #define CDVD_LMT_RESERVED3 7
  3303. typedef struct _CDVD_CAPABILITIES_PAGE {
  3304. UCHAR PageCode : 6; // 0x2A
  3305. UCHAR Reserved : 1;
  3306. UCHAR PSBit : 1; // offset 0
  3307. UCHAR PageLength; // 0x18 // offset 1
  3308. UCHAR CDRRead : 1;
  3309. UCHAR CDERead : 1;
  3310. UCHAR Method2 : 1;
  3311. UCHAR DVDROMRead : 1;
  3312. UCHAR DVDRRead : 1;
  3313. UCHAR DVDRAMRead : 1;
  3314. UCHAR Reserved2 : 2; // offset 2
  3315. UCHAR CDRWrite : 1;
  3316. UCHAR CDEWrite : 1;
  3317. UCHAR TestWrite : 1;
  3318. UCHAR Reserved3 : 1;
  3319. UCHAR DVDRWrite : 1;
  3320. UCHAR DVDRAMWrite : 1;
  3321. UCHAR Reserved4 : 2; // offset 3
  3322. UCHAR AudioPlay : 1;
  3323. UCHAR Composite : 1;
  3324. UCHAR DigitalPortOne : 1;
  3325. UCHAR DigitalPortTwo : 1;
  3326. UCHAR Mode2Form1 : 1;
  3327. UCHAR Mode2Form2 : 1;
  3328. UCHAR MultiSession : 1;
  3329. UCHAR Reserved5 : 1; // offset 4
  3330. UCHAR CDDA : 1;
  3331. UCHAR CDDAAccurate : 1;
  3332. UCHAR RWSupported : 1;
  3333. UCHAR RWDeinterleaved : 1;
  3334. UCHAR C2Pointers : 1;
  3335. UCHAR ISRC : 1;
  3336. UCHAR UPC : 1;
  3337. UCHAR ReadBarCodeCapable : 1; // offset 5
  3338. UCHAR Lock : 1;
  3339. UCHAR LockState : 1;
  3340. UCHAR PreventJumper : 1;
  3341. UCHAR Eject : 1;
  3342. UCHAR Reserved6 : 1;
  3343. UCHAR LoadingMechanismType : 3; // offset 6
  3344. UCHAR SeparateVolume : 1;
  3345. UCHAR SeperateChannelMute : 1;
  3346. UCHAR SupportsDiskPresent : 1;
  3347. UCHAR SWSlotSelection : 1;
  3348. UCHAR SideChangeCapable : 1;
  3349. UCHAR RWInLeadInReadable : 1;
  3350. UCHAR Reserved7 : 2; // offset 7
  3351. UCHAR ObsoleteReserved[2]; // offset 8
  3352. UCHAR NumberVolumeLevels[2]; // offset 10
  3353. UCHAR BufferSize[2]; // offset 12
  3354. UCHAR ObsoleteReserved2[2]; // offset 14
  3355. UCHAR ObsoleteReserved3; // offset 16
  3356. UCHAR Reserved8 : 1;
  3357. UCHAR BCK : 1;
  3358. UCHAR RCK : 1;
  3359. UCHAR LSBF : 1;
  3360. UCHAR Length : 2;
  3361. UCHAR Reserved9 : 2; // offset 17
  3362. UCHAR ObsoleteReserved4[2]; // offset 18
  3363. UCHAR ObsoleteReserved11[2]; // offset 20
  3364. //
  3365. // NOTE: This mode page is two bytes too small in the release
  3366. // version of the Windows2000 DDK. it also incorrectly
  3367. // put the CopyManagementRevision at offset 20 instead
  3368. // of offset 22, so fix that with a nameless union (for
  3369. // backwards-compatibility with those who "fixed" it on
  3370. // their own by looking at Reserved10[]).
  3371. //
  3372. union {
  3373. UCHAR CopyManagementRevision[2]; // offset 22
  3374. UCHAR Reserved10[2];
  3375. };
  3376. //UCHAR Reserved12[2]; // offset 24
  3377. } CDVD_CAPABILITIES_PAGE, *PCDVD_CAPABILITIES_PAGE;
  3378. typedef struct _LUN_LIST {
  3379. UCHAR LunListLength[4]; // sizeof LunSize * 8
  3380. UCHAR Reserved[4];
  3381. UCHAR Lun[0][8]; // 4 level of addressing. 2 bytes each.
  3382. } LUN_LIST, *PLUN_LIST;
  3383. #define LOADING_MECHANISM_CADDY 0x00
  3384. #define LOADING_MECHANISM_TRAY 0x01
  3385. #define LOADING_MECHANISM_POPUP 0x02
  3386. #define LOADING_MECHANISM_INDIVIDUAL_CHANGER 0x04
  3387. #define LOADING_MECHANISM_CARTRIDGE_CHANGER 0x05
  3388. //
  3389. // end C/DVD 0.9 mode page definitions
  3390. //
  3391. // Mode parameter list block descriptor -
  3392. // set the block length for reading/writing
  3393. //
  3394. //
  3395. #define MODE_BLOCK_DESC_LENGTH 8
  3396. #define MODE_HEADER_LENGTH 4
  3397. #define MODE_HEADER_LENGTH10 8
  3398. typedef struct _MODE_PARM_READ_WRITE {
  3399. MODE_PARAMETER_HEADER ParameterListHeader; // List Header Format
  3400. MODE_PARAMETER_BLOCK ParameterListBlock; // List Block Descriptor
  3401. } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
  3402. //
  3403. // CDROM audio control (0x0E)
  3404. //
  3405. #define CDB_AUDIO_PAUSE 0
  3406. #define CDB_AUDIO_RESUME 1
  3407. #define CDB_DEVICE_START 0x11
  3408. #define CDB_DEVICE_STOP 0x10
  3409. #define CDB_EJECT_MEDIA 0x10
  3410. #define CDB_LOAD_MEDIA 0x01
  3411. #define CDB_SUBCHANNEL_HEADER 0x00
  3412. #define CDB_SUBCHANNEL_BLOCK 0x01
  3413. #define CDROM_AUDIO_CONTROL_PAGE 0x0E
  3414. #define MODE_SELECT_IMMEDIATE 0x04
  3415. #define MODE_SELECT_PFBIT 0x10
  3416. #define CDB_USE_MSF 0x01
  3417. typedef struct _PORT_OUTPUT {
  3418. UCHAR ChannelSelection;
  3419. UCHAR Volume;
  3420. } PORT_OUTPUT, *PPORT_OUTPUT;
  3421. typedef struct _AUDIO_OUTPUT {
  3422. UCHAR CodePage;
  3423. UCHAR ParameterLength;
  3424. UCHAR Immediate;
  3425. UCHAR Reserved[2];
  3426. UCHAR LbaFormat;
  3427. UCHAR LogicalBlocksPerSecond[2];
  3428. PORT_OUTPUT PortOutput[4];
  3429. } AUDIO_OUTPUT, *PAUDIO_OUTPUT;
  3430. //
  3431. // Multisession CDROM
  3432. //
  3433. #define GET_LAST_SESSION 0x01
  3434. #define GET_SESSION_DATA 0x02;
  3435. //
  3436. // Atapi 2.5 changer
  3437. //
  3438. typedef struct _MECHANICAL_STATUS_INFORMATION_HEADER {
  3439. UCHAR CurrentSlot : 5;
  3440. UCHAR ChangerState : 2;
  3441. UCHAR Fault : 1;
  3442. UCHAR Reserved : 5;
  3443. UCHAR MechanismState : 3;
  3444. UCHAR CurrentLogicalBlockAddress[3];
  3445. UCHAR NumberAvailableSlots;
  3446. UCHAR SlotTableLength[2];
  3447. } MECHANICAL_STATUS_INFORMATION_HEADER, *PMECHANICAL_STATUS_INFORMATION_HEADER;
  3448. typedef struct _SLOT_TABLE_INFORMATION {
  3449. UCHAR DiscChanged : 1;
  3450. UCHAR Reserved : 6;
  3451. UCHAR DiscPresent : 1;
  3452. UCHAR Reserved2[3];
  3453. } SLOT_TABLE_INFORMATION, *PSLOT_TABLE_INFORMATION;
  3454. typedef struct _MECHANICAL_STATUS {
  3455. MECHANICAL_STATUS_INFORMATION_HEADER MechanicalStatusHeader;
  3456. SLOT_TABLE_INFORMATION SlotTableInfo[1];
  3457. } MECHANICAL_STATUS, *PMECHANICAL_STATUS;
  3458. //
  3459. // This structure is used to convert little endian
  3460. // ULONGs to SCSI CDB big endians values.
  3461. //
  3462. typedef union _EIGHT_BYTE {
  3463. struct {
  3464. UCHAR Byte0;
  3465. UCHAR Byte1;
  3466. UCHAR Byte2;
  3467. UCHAR Byte3;
  3468. UCHAR Byte4;
  3469. UCHAR Byte5;
  3470. UCHAR Byte6;
  3471. UCHAR Byte7;
  3472. };
  3473. ULONGLONG AsULongLong;
  3474. } EIGHT_BYTE, *PEIGHT_BYTE;
  3475. typedef union _FOUR_BYTE {
  3476. struct {
  3477. UCHAR Byte0;
  3478. UCHAR Byte1;
  3479. UCHAR Byte2;
  3480. UCHAR Byte3;
  3481. };
  3482. ULONG AsULong;
  3483. } FOUR_BYTE, *PFOUR_BYTE;
  3484. typedef union _TWO_BYTE {
  3485. struct {
  3486. UCHAR Byte0;
  3487. UCHAR Byte1;
  3488. };
  3489. USHORT AsUShort;
  3490. } TWO_BYTE, *PTWO_BYTE;
  3491. //
  3492. // Byte reversing macro for converting
  3493. // between big- and little-endian formats
  3494. //
  3495. #define REVERSE_BYTES_QUAD(Destination, Source) { \
  3496. PEIGHT_BYTE d = (PEIGHT_BYTE)(Destination); \
  3497. PEIGHT_BYTE s = (PEIGHT_BYTE)(Source); \
  3498. d->Byte7 = s->Byte0; \
  3499. d->Byte6 = s->Byte1; \
  3500. d->Byte5 = s->Byte2; \
  3501. d->Byte4 = s->Byte3; \
  3502. d->Byte3 = s->Byte4; \
  3503. d->Byte2 = s->Byte5; \
  3504. d->Byte1 = s->Byte6; \
  3505. d->Byte0 = s->Byte7; \
  3506. }
  3507. #define REVERSE_BYTES(Destination, Source) { \
  3508. PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
  3509. PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
  3510. d->Byte3 = s->Byte0; \
  3511. d->Byte2 = s->Byte1; \
  3512. d->Byte1 = s->Byte2; \
  3513. d->Byte0 = s->Byte3; \
  3514. }
  3515. #define REVERSE_BYTES_SHORT(Destination, Source) { \
  3516. PTWO_BYTE d = (PTWO_BYTE)(Destination); \
  3517. PTWO_BYTE s = (PTWO_BYTE)(Source); \
  3518. d->Byte1 = s->Byte0; \
  3519. d->Byte0 = s->Byte1; \
  3520. }
  3521. //
  3522. // Byte reversing macro for converting
  3523. // USHORTS from big to little endian in place
  3524. //
  3525. #define REVERSE_SHORT(Short) { \
  3526. UCHAR tmp; \
  3527. PTWO_BYTE w = (PTWO_BYTE)(Short); \
  3528. tmp = w->Byte0; \
  3529. w->Byte0 = w->Byte1; \
  3530. w->Byte1 = tmp; \
  3531. }
  3532. //
  3533. // Byte reversing macro for convering
  3534. // ULONGS between big & little endian in place
  3535. //
  3536. #define REVERSE_LONG(Long) { \
  3537. UCHAR tmp; \
  3538. PFOUR_BYTE l = (PFOUR_BYTE)(Long); \
  3539. tmp = l->Byte3; \
  3540. l->Byte3 = l->Byte0; \
  3541. l->Byte0 = tmp; \
  3542. tmp = l->Byte2; \
  3543. l->Byte2 = l->Byte1; \
  3544. l->Byte1 = tmp; \
  3545. }
  3546. //
  3547. // This macro has the effect of Bit = log2(Data)
  3548. //
  3549. #define WHICH_BIT(Data, Bit) { \
  3550. UCHAR tmp; \
  3551. for (tmp = 0; tmp < 32; tmp++) { \
  3552. if (((Data) >> tmp) == 1) { \
  3553. break; \
  3554. } \
  3555. } \
  3556. ASSERT(tmp != 32); \
  3557. (Bit) = tmp; \
  3558. }
  3559. //
  3560. // Include SCSIPORT definitions for backwards compatability.
  3561. //
  3562. #if defined (STOR_USE_SCSI_ALIASES)
  3563. #define ScsiPortInitialize StorPortInitialize
  3564. #define ScsiPortFreeDeviceBase StorPortFreeDeviceBase
  3565. #define ScsiPortGetBusData StorPortGetBusData
  3566. #define ScsiPortSetBusDataByOffset StorPortSetBusDataByOffset
  3567. #define ScsiPortGetDeviceBase StorPortGetDeviceBase
  3568. #define ScsiPortGetLogicalUnit StorPortGetLogicalUnit
  3569. #define ScsiPortGetSrb StorPortGetSrb
  3570. #define ScsiPortGetPhysicalAddress StorPortGetPhysicalAddress
  3571. #define ScsiPortGetVirtualAddress StorPortGetVirtualAddress
  3572. #define ScsiPortGetUncachedExtension StorPortGetUncachedExtension
  3573. #define ScsiPortFlushDma StorPortFlushDma
  3574. #define ScsiPortIoMapTransfer StorPortIoMapTransfer
  3575. #define ScsiPortNotification StorPortNotification
  3576. #define ScsiPortLogError StorPortLogError
  3577. #define ScsiPortCompleteRequest StorPortCompleteRequest
  3578. #define ScsiPortMoveMemory StorPortMoveMemory
  3579. #define ScsiPortReadPortUchar(Port) StorPortReadPortUchar(NULL, Port)
  3580. #define ScsiPortReadPortUshort(Port) StorPortReadPortUshort(NULL, Port)
  3581. #define ScsiPortReadPortUlong(Port) StorPortReadPortUlong(NULL, Port)
  3582. #define ScsiPortReadPortBufferUchar(Port, Buffer, Count) StorPortReadPortBufferUchar(NULL, Port, Buffer, Count)
  3583. #define ScsiPortReadPortBufferUshort(Port, Buffer, Count) StorPortReadPortBufferUshort(NULL, Port, Buffer, Count)
  3584. #define ScsiPortReadPortBufferUlong(Port, Buffer, Count) StorPortReadPortBufferUlong(NULL, Port, Buffer, Count)
  3585. #define ScsiPortReadRegisterUchar(Register) StorPortReadRegisterUchar(NULL, Register)
  3586. #define ScsiPortReadRegisterUshort(Register) StorPortReadRegisterUshort(NULL, Register)
  3587. #define ScsiPortReadRegisterUlong(Register) StorPortReadRegisterUlong(NULL, Register)
  3588. #define ScsiPortReadRegisterBufferUchar(Register, Buffer, Count) StorPortReadRegisterBufferUchar(NULL, Register, Buffer, Count)
  3589. #define ScsiPortReadRegisterBufferUshort(Register, Buffer, Count) StorPortReadRegisterBufferUshort(NULL, Register, Buffer, Count)
  3590. #define ScsiPortReadRegisterBufferUlong(Register, Buffer, Count) StorPortReadRegisterBufferUlong(NULL, Register, Buffer, Count)
  3591. #define ScsiPortStallExecution StorPortStallExecution
  3592. #define ScsiPortWritePortUchar(Port, Value) StorPortWritePortUchar(NULL, Port, Value)
  3593. #define ScsiPortWritePortUshort(Port, Value) StorPortWritePortUshort(NULL, Port, Value)
  3594. #define ScsiPortWritePortUlong(Port, Value) StorPortWritePortUlong(NULL, Port, Value)
  3595. #define ScsiPortWritePortBufferUchar(Port, Buffer, Count) StorPortWritePortBufferUchar(NULL, Port, Buffer, Count)
  3596. #define ScsiPortWritePortBufferUshort(Port, Buffer, Count) StorPortWritePortBufferUshort(NULL, Port, Buffer, Count)
  3597. #define ScsiPortWritePortBufferUlong(Port, Buffer, Count) StorPortWritePortBufferUlong(NULL, Port, Buffer, Count)
  3598. #define ScsiPortWriteRegisterUchar(Register, Value) StorPortWriteRegisterUchar(NULL, Register, Value)
  3599. #define ScsiPortWriteRegisterUshort(Register, Value) StorPortWriteRegisterUshort(NULL, Register, Value)
  3600. #define ScsiPortWriteRegisterUlong(Register, Value) StorPortWriteRegisterUlong(NULL, Register, Value)
  3601. #define ScsiPortWriteRegisterBufferUchar(Register, Buffer, Count) StorPortWriteRegisterBufferUchar(NULL, Register, Buffer, Count)
  3602. #define ScsiPortWriteRegisterBufferUshort(Register, Buffer, Count) StorPortWriteRegisterBufferUshort(NULL, Register, Buffer, Count)
  3603. #define ScsiPortWriteRegisterBufferUlong(Register, Buffer, Count) StorPortWriteRegisterBufferUlong(NULL, Register, Buffer, Count)
  3604. #define ScsiPortConvertUlongToPhysicalAddress StorPortConvertUlongToPhysicalAddress
  3605. #define ScsiPortConvertPhysicalAddressToUlong StorPortConvertPhysicalAddressToUlong
  3606. #define ScsiPortQuerySystemTime StorPortQuerySystemTime
  3607. #define ScsiPortValidateRange StorPortValidateRange
  3608. #define ScsiDebugPrint StorPortDebugPrint
  3609. typedef PHYSICAL_ADDRESS SCSI_PHYSICAL_ADDRESS, *PSCSI_PHYSICAL_ADDRESS;
  3610. #endif // STOR_USE_SCSI_ALIASES
  3611. #if _MSC_VER >= 1200
  3612. #pragma warning(pop) // un-sets any local warning changes
  3613. #else
  3614. #pragma warning(default:4200) // array[0] is not a warning for this file
  3615. #endif
  3616. #endif // !defined _NTSTORPORT_