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.

401 lines
9.8 KiB

  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. //
  218. // Define SCSI information.
  219. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  220. //
  221. typedef struct _SCSI_BUS_DATA {
  222. UCHAR NumberOfLogicalUnits;
  223. UCHAR InitiatorBusId;
  224. ULONG InquiryDataOffset;
  225. }SCSI_BUS_DATA, *PSCSI_BUS_DATA;
  226. //
  227. // Define SCSI adapter bus information structure..
  228. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  229. //
  230. typedef struct _SCSI_ADAPTER_BUS_INFO {
  231. UCHAR NumberOfBuses;
  232. SCSI_BUS_DATA BusData[1];
  233. } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
  234. //
  235. // Define SCSI adapter bus information.
  236. // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
  237. //
  238. typedef struct _SCSI_INQUIRY_DATA {
  239. UCHAR PathId;
  240. UCHAR TargetId;
  241. UCHAR Lun;
  242. BOOLEAN DeviceClaimed;
  243. ULONG InquiryDataLength;
  244. ULONG NextInquiryDataOffset;
  245. UCHAR InquiryData[1];
  246. }SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
  247. //
  248. // Define header for I/O control SRB.
  249. //
  250. typedef struct _SRB_IO_CONTROL {
  251. ULONG HeaderLength;
  252. UCHAR Signature[8];
  253. ULONG Timeout;
  254. ULONG ControlCode;
  255. ULONG ReturnCode;
  256. ULONG Length;
  257. } SRB_IO_CONTROL, *PSRB_IO_CONTROL;
  258. //
  259. // SCSI port driver capabilities structure.
  260. //
  261. typedef struct _IO_SCSI_CAPABILITIES {
  262. //
  263. // Length of this structure
  264. //
  265. ULONG Length;
  266. //
  267. // Maximum transfer size in single SRB
  268. //
  269. ULONG MaximumTransferLength;
  270. //
  271. // Maximum number of physical pages per data buffer
  272. //
  273. ULONG MaximumPhysicalPages;
  274. //
  275. // Async calls from port to class
  276. //
  277. ULONG SupportedAsynchronousEvents;
  278. //
  279. // Alignment mask for data transfers.
  280. //
  281. ULONG AlignmentMask;
  282. //
  283. // Supports tagged queuing
  284. //
  285. BOOLEAN TaggedQueuing;
  286. //
  287. // Host adapter scans down for bios devices.
  288. //
  289. BOOLEAN AdapterScansDown;
  290. //
  291. // The host adapter uses programmed I/O.
  292. //
  293. BOOLEAN AdapterUsesPio;
  294. } IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
  295. typedef struct _SCSI_ADDRESS {
  296. ULONG Length;
  297. UCHAR PortNumber;
  298. UCHAR PathId;
  299. UCHAR TargetId;
  300. UCHAR Lun;
  301. }SCSI_ADDRESS, *PSCSI_ADDRESS;
  302. //
  303. // Define structure for returning crash dump pointers.
  304. //
  305. struct _ADAPTER_OBJECT;
  306. typedef struct _DUMP_POINTERS {
  307. struct _ADAPTER_OBJECT *AdapterObject;
  308. PVOID MappedRegisterBase;
  309. PVOID DumpData;
  310. PVOID CommonBufferVa;
  311. LARGE_INTEGER CommonBufferPa;
  312. ULONG CommonBufferSize;
  313. BOOLEAN AllocateCommonBuffers;
  314. BOOLEAN UseDiskDump;
  315. UCHAR Spare1[2];
  316. PVOID DeviceObject;
  317. } DUMP_POINTERS, *PDUMP_POINTERS;
  318. //
  319. // Define values for pass-through DataIn field.
  320. //
  321. #define SCSI_IOCTL_DATA_OUT 0
  322. #define SCSI_IOCTL_DATA_IN 1
  323. #define SCSI_IOCTL_DATA_UNSPECIFIED 2
  324. #ifdef __cplusplus
  325. }
  326. #endif
  327. #endif