ntddscsi.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntddscsi.h
  5. Abstract:
  6. This is the include file that defines all constants and types for
  7. accessing the SCSI port adapters.
  8. Author:
  9. Jeff Havens
  10. Revision History:
  11. --*/
  12. //
  13. // Interface GUIDs
  14. //
  15. // need these GUIDs outside conditional includes so that user can
  16. // #include <ntddscsi.h> in precompiled header
  17. // #include <initguid.h> in a single source file
  18. // #include <ntddscsi.h> in that source file a second time to instantiate the GUIDs
  19. //
  20. #ifdef DEFINE_GUID
  21. //
  22. // Make sure FAR is defined...
  23. //
  24. #ifndef FAR
  25. #ifdef _WIN32
  26. #define FAR
  27. #else
  28. #define FAR _far
  29. #endif
  30. #endif
  31. DEFINE_GUID(ScsiRawInterfaceGuid, 0x53f56309L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  32. DEFINE_GUID(WmiScsiAddressGuid, 0x53f5630fL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  33. #endif
  34. #ifndef _NTDDSCSIH_
  35. #define _NTDDSCSIH_
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. //
  40. // Device Name - this string is the name of the device. It is the name
  41. // that should be passed to NtOpenFile when accessing the device.
  42. //
  43. // Note: For devices that support multiple units, it should be suffixed
  44. // with the Ascii representation of the unit number.
  45. //
  46. #define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
  47. #define DD_SCSI_DEVICE_NAME "\\Device\\ScsiPort"
  48. //
  49. // NtDeviceIoControlFile IoControlCode values for this device.
  50. //
  51. // Warning: Remember that the low two bits of the code specify how the
  52. // buffers are passed to the driver!
  53. //
  54. #define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  55. #define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  56. #define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
  57. #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
  58. #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  59. #define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS)
  60. #define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS)
  61. #define IOCTL_SCSI_GET_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS)
  62. #define IOCTL_SCSI_FREE_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0409, METHOD_BUFFERED, FILE_ANY_ACCESS)
  63. #define IOCTL_IDE_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x040a, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  64. #define IOCTL_ATA_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x040b, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  65. #define IOCTL_ATA_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x040c, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  66. //
  67. // Define the SCSI pass through structure.
  68. //
  69. typedef struct _SCSI_PASS_THROUGH {
  70. USHORT Length;
  71. UCHAR ScsiStatus;
  72. UCHAR PathId;
  73. UCHAR TargetId;
  74. UCHAR Lun;
  75. UCHAR CdbLength;
  76. UCHAR SenseInfoLength;
  77. UCHAR DataIn;
  78. ULONG DataTransferLength;
  79. ULONG TimeOutValue;
  80. ULONG_PTR DataBufferOffset;
  81. ULONG SenseInfoOffset;
  82. UCHAR Cdb[16];
  83. }SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
  84. //
  85. // Define the SCSI pass through direct structure.
  86. //
  87. typedef struct _SCSI_PASS_THROUGH_DIRECT {
  88. USHORT Length;
  89. UCHAR ScsiStatus;
  90. UCHAR PathId;
  91. UCHAR TargetId;
  92. UCHAR Lun;
  93. UCHAR CdbLength;
  94. UCHAR SenseInfoLength;
  95. UCHAR DataIn;
  96. ULONG DataTransferLength;
  97. ULONG TimeOutValue;
  98. PVOID DataBuffer;
  99. ULONG SenseInfoOffset;
  100. UCHAR Cdb[16];
  101. }SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
  102. //
  103. // Define the SCSI pass through direct structure for Win64 (thunking).
  104. //
  105. #if defined(_WIN64)
  106. typedef struct _SCSI_PASS_THROUGH32 {
  107. USHORT Length;
  108. UCHAR ScsiStatus;
  109. UCHAR PathId;
  110. UCHAR TargetId;
  111. UCHAR Lun;
  112. UCHAR CdbLength;
  113. UCHAR SenseInfoLength;
  114. UCHAR DataIn;
  115. ULONG DataTransferLength;
  116. ULONG TimeOutValue;
  117. ULONG32 DataBufferOffset;
  118. ULONG SenseInfoOffset;
  119. UCHAR Cdb[16];
  120. }SCSI_PASS_THROUGH32, *PSCSI_PASS_THROUGH32;
  121. //
  122. // Define the SCSI pass through direct structure.
  123. //
  124. typedef struct _SCSI_PASS_THROUGH_DIRECT32 {
  125. USHORT Length;
  126. UCHAR ScsiStatus;
  127. UCHAR PathId;
  128. UCHAR TargetId;
  129. UCHAR Lun;
  130. UCHAR CdbLength;
  131. UCHAR SenseInfoLength;
  132. UCHAR DataIn;
  133. ULONG DataTransferLength;
  134. ULONG TimeOutValue;
  135. VOID * POINTER_32 DataBuffer;
  136. ULONG SenseInfoOffset;
  137. UCHAR Cdb[16];
  138. }SCSI_PASS_THROUGH_DIRECT32, *PSCSI_PASS_THROUGH_DIRECT32;
  139. #endif
  140. //
  141. // ATA pass through structure
  142. //
  143. typedef struct _ATA_PASS_THROUGH_EX {
  144. USHORT Length;
  145. USHORT AtaFlags;
  146. UCHAR PathId;
  147. UCHAR TargetId;
  148. UCHAR Lun;
  149. UCHAR ReservedAsUchar;
  150. ULONG DataTransferLength;
  151. ULONG TimeOutValue;
  152. ULONG ReservedAsUlong;
  153. ULONG_PTR DataBufferOffset;
  154. UCHAR PreviousTaskFile[8];
  155. UCHAR CurrentTaskFile[8];
  156. } ATA_PASS_THROUGH_EX, *PATA_PASS_THROUGH_EX;
  157. //
  158. // ATA pass through direct structure.
  159. //
  160. typedef struct _ATA_PASS_THROUGH_DIRECT {
  161. USHORT Length;
  162. USHORT AtaFlags;
  163. UCHAR PathId;
  164. UCHAR TargetId;
  165. UCHAR Lun;
  166. UCHAR ReservedAsUchar;
  167. ULONG DataTransferLength;
  168. ULONG TimeOutValue;
  169. ULONG ReservedAsUlong;
  170. PVOID DataBuffer;
  171. UCHAR PreviousTaskFile[8];
  172. UCHAR CurrentTaskFile[8];
  173. } ATA_PASS_THROUGH_DIRECT, *PATA_PASS_THROUGH_DIRECT;
  174. //
  175. // Define the ATA pass through direct structure for Win64 (thunking).
  176. //
  177. #if defined(_WIN64)
  178. typedef struct _ATA_PASS_THROUGH_EX32 {
  179. USHORT Length;
  180. USHORT AtaFlags;
  181. UCHAR PathId;
  182. UCHAR TargetId;
  183. UCHAR Lun;
  184. UCHAR ReservedAsUchar;
  185. ULONG DataTransferLength;
  186. ULONG TimeOutValue;
  187. ULONG ReservedAsUlong;
  188. ULONG32 DataBufferOffset;
  189. UCHAR PreviousTaskFile[8];
  190. UCHAR CurrentTaskFile[8];
  191. } ATA_PASS_THROUGH_EX32, *PATA_PASS_THROUGH_EX32;
  192. //
  193. // ATA pass through direct structure.
  194. //
  195. typedef struct _ATA_PASS_THROUGH_DIRECT32 {
  196. USHORT Length;
  197. USHORT AtaFlags;
  198. UCHAR PathId;
  199. UCHAR TargetId;
  200. UCHAR Lun;
  201. UCHAR ReservedAsUchar;
  202. ULONG DataTransferLength;
  203. ULONG TimeOutValue;
  204. ULONG ReservedAsUlong;
  205. VOID * POINTER_32 DataBuffer;
  206. UCHAR PreviousTaskFile[8];
  207. UCHAR CurrentTaskFile[8];
  208. } ATA_PASS_THROUGH_DIRECT32, *PATA_PASS_THROUGH_DIRECT32;
  209. #endif
  210. //
  211. // ATA Pass Through Flags
  212. //
  213. #define ATA_FLAGS_DRDY_REQUIRED (1 << 0)
  214. #define ATA_FLAGS_DATA_IN (1 << 1)
  215. #define ATA_FLAGS_DATA_OUT (1 << 2)
  216. #define ATA_FLAGS_48BIT_COMMAND (1 << 3)
  217. #define ATA_FLAGS_USE_DMA (1 << 4)
  218. //
  219. // Define SCSI information.
  220. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  221. //
  222. typedef struct _SCSI_BUS_DATA {
  223. UCHAR NumberOfLogicalUnits;
  224. UCHAR InitiatorBusId;
  225. ULONG InquiryDataOffset;
  226. }SCSI_BUS_DATA, *PSCSI_BUS_DATA;
  227. //
  228. // Define SCSI adapter bus information structure..
  229. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  230. //
  231. typedef struct _SCSI_ADAPTER_BUS_INFO {
  232. UCHAR NumberOfBuses;
  233. SCSI_BUS_DATA BusData[1];
  234. } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
  235. //
  236. // Define SCSI adapter bus information.
  237. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  238. //
  239. typedef struct _SCSI_INQUIRY_DATA {
  240. UCHAR PathId;
  241. UCHAR TargetId;
  242. UCHAR Lun;
  243. BOOLEAN DeviceClaimed;
  244. ULONG InquiryDataLength;
  245. ULONG NextInquiryDataOffset;
  246. UCHAR InquiryData[1];
  247. }SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
  248. //
  249. // Define header for I/O control SRB.
  250. //
  251. typedef struct _SRB_IO_CONTROL {
  252. ULONG HeaderLength;
  253. UCHAR Signature[8];
  254. ULONG Timeout;
  255. ULONG ControlCode;
  256. ULONG ReturnCode;
  257. ULONG Length;
  258. } SRB_IO_CONTROL, *PSRB_IO_CONTROL;
  259. //
  260. // SCSI port driver capabilities structure.
  261. //
  262. typedef struct _IO_SCSI_CAPABILITIES {
  263. //
  264. // Length of this structure
  265. //
  266. ULONG Length;
  267. //
  268. // Maximum transfer size in single SRB
  269. //
  270. ULONG MaximumTransferLength;
  271. //
  272. // Maximum number of physical pages per data buffer
  273. //
  274. ULONG MaximumPhysicalPages;
  275. //
  276. // Async calls from port to class
  277. //
  278. ULONG SupportedAsynchronousEvents;
  279. //
  280. // Alignment mask for data transfers.
  281. //
  282. ULONG AlignmentMask;
  283. //
  284. // Supports tagged queuing
  285. //
  286. BOOLEAN TaggedQueuing;
  287. //
  288. // Host adapter scans down for bios devices.
  289. //
  290. BOOLEAN AdapterScansDown;
  291. //
  292. // The host adapter uses programmed I/O.
  293. //
  294. BOOLEAN AdapterUsesPio;
  295. } IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
  296. typedef struct _SCSI_ADDRESS {
  297. ULONG Length;
  298. UCHAR PortNumber;
  299. UCHAR PathId;
  300. UCHAR TargetId;
  301. UCHAR Lun;
  302. }SCSI_ADDRESS, *PSCSI_ADDRESS;
  303. //
  304. // Define structure for returning crash dump pointers.
  305. //
  306. struct _ADAPTER_OBJECT;
  307. typedef struct _DUMP_POINTERS {
  308. struct _ADAPTER_OBJECT *AdapterObject;
  309. PVOID MappedRegisterBase;
  310. PVOID DumpData;
  311. PVOID CommonBufferVa;
  312. LARGE_INTEGER CommonBufferPa;
  313. ULONG CommonBufferSize;
  314. BOOLEAN AllocateCommonBuffers;
  315. BOOLEAN UseDiskDump;
  316. UCHAR Spare1[2];
  317. PVOID DeviceObject;
  318. } DUMP_POINTERS, *PDUMP_POINTERS;
  319. //
  320. // Define values for pass-through DataIn field.
  321. //
  322. #define SCSI_IOCTL_DATA_OUT 0
  323. #define SCSI_IOCTL_DATA_IN 1
  324. #define SCSI_IOCTL_DATA_UNSPECIFIED 2
  325. #ifdef __cplusplus
  326. }
  327. #endif
  328. #endif