xref: /reactos/sdk/include/psdk/ntddscsi.h (revision 901c457b)
1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the w64 mingw-runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifdef DEFINE_GUID
7 
8 #ifndef FAR
9 #define FAR
10 #endif
11 
12 DEFINE_GUID(ScsiRawInterfaceGuid,0x53f56309L,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b);
13 DEFINE_GUID(WmiScsiAddressGuid,0x53f5630fL,0xb6bf,0x11d0,0x94,0xf2,0x00,0xa0,0xc9,0x1e,0xfb,0x8b);
14 #endif /* DEFINE_GUID */
15 
16 #ifndef _NTDDSCSIH_
17 #define _NTDDSCSIH_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define IOCTL_SCSI_BASE     FILE_DEVICE_CONTROLLER
24 
25 #define DD_SCSI_DEVICE_NAME "\\Device\\ScsiPort"
26 #define DD_SCSI_DEVICE_NAME_U  L"\\Device\\ScsiPort"
27 
28 #define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE,0x0401,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
29 #define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE,0x0402,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
30 #define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE,0x0403,METHOD_BUFFERED,FILE_ANY_ACCESS)
31 #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE,0x0404,METHOD_BUFFERED,FILE_ANY_ACCESS)
32 #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE,0x0405,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
33 #define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE,0x0406,METHOD_BUFFERED,FILE_ANY_ACCESS)
34 #define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE,0x0407,METHOD_BUFFERED,FILE_ANY_ACCESS)
35 #define IOCTL_SCSI_GET_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE,0x0408,METHOD_BUFFERED,FILE_ANY_ACCESS)
36 #define IOCTL_SCSI_FREE_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE,0x0409,METHOD_BUFFERED,FILE_ANY_ACCESS)
37 #define IOCTL_SCSI_PASS_THROUGH_EX CTL_CODE(IOCTL_SCSI_BASE, 0x0411, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
38 #define IOCTL_SCSI_PASS_THROUGH_DIRECT_EX CTL_CODE(IOCTL_SCSI_BASE, 0x0412, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
39 #define IOCTL_IDE_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE,0x040a,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
40 #define IOCTL_ATA_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE,0x040b,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
41 #define IOCTL_ATA_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE,0x040c,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS)
42 
43   typedef struct _SCSI_PASS_THROUGH {
44     USHORT Length;
45     UCHAR ScsiStatus;
46     UCHAR PathId;
47     UCHAR TargetId;
48     UCHAR Lun;
49     UCHAR CdbLength;
50     UCHAR SenseInfoLength;
51     UCHAR DataIn;
52     ULONG DataTransferLength;
53     ULONG TimeOutValue;
54     ULONG_PTR DataBufferOffset;
55     ULONG SenseInfoOffset;
56     UCHAR Cdb[16];
57   }SCSI_PASS_THROUGH,*PSCSI_PASS_THROUGH;
58 
59   typedef struct _SCSI_PASS_THROUGH_DIRECT {
60     USHORT Length;
61     UCHAR ScsiStatus;
62     UCHAR PathId;
63     UCHAR TargetId;
64     UCHAR Lun;
65     UCHAR CdbLength;
66     UCHAR SenseInfoLength;
67     UCHAR DataIn;
68     ULONG DataTransferLength;
69     ULONG TimeOutValue;
70     PVOID DataBuffer;
71     ULONG SenseInfoOffset;
72     UCHAR Cdb[16];
73   }SCSI_PASS_THROUGH_DIRECT,*PSCSI_PASS_THROUGH_DIRECT;
74 
75 #if defined(_WIN64)
76   typedef struct _SCSI_PASS_THROUGH32 {
77     USHORT Length;
78     UCHAR ScsiStatus;
79     UCHAR PathId;
80     UCHAR TargetId;
81     UCHAR Lun;
82     UCHAR CdbLength;
83     UCHAR SenseInfoLength;
84     UCHAR DataIn;
85     ULONG DataTransferLength;
86     ULONG TimeOutValue;
87     ULONG32 DataBufferOffset;
88     ULONG SenseInfoOffset;
89     UCHAR Cdb[16];
90   } SCSI_PASS_THROUGH32,*PSCSI_PASS_THROUGH32;
91 
92   typedef struct _SCSI_PASS_THROUGH_DIRECT32 {
93     USHORT Length;
94     UCHAR ScsiStatus;
95     UCHAR PathId;
96     UCHAR TargetId;
97     UCHAR Lun;
98     UCHAR CdbLength;
99     UCHAR SenseInfoLength;
100     UCHAR DataIn;
101     ULONG DataTransferLength;
102     ULONG TimeOutValue;
103     VOID * POINTER_32 DataBuffer;
104     ULONG SenseInfoOffset;
105     UCHAR Cdb[16];
106   } SCSI_PASS_THROUGH_DIRECT32,*PSCSI_PASS_THROUGH_DIRECT32;
107 #endif /* _WIN64 */
108 
109 
110   typedef struct _SCSI_PASS_THROUGH_EX {
111     ULONG Version;
112     ULONG Length;
113     ULONG CdbLength;
114     ULONG StorAddressLength;
115     UCHAR ScsiStatus;
116     UCHAR SenseInfoLength;
117     UCHAR DataDirection;
118     UCHAR Reserved;
119     ULONG TimeOutValue;
120     ULONG StorAddressOffset;
121     ULONG SenseInfoOffset;
122     ULONG DataOutTransferLength;
123     ULONG DataInTransferLength;
124     ULONG_PTR DataOutBufferOffset;
125     ULONG_PTR DataInBufferOffset;
126     UCHAR Cdb[ANYSIZE_ARRAY];
127   } SCSI_PASS_THROUGH_EX, *PSCSI_PASS_THROUGH_EX;
128 
129 typedef struct _SCSI_PASS_THROUGH_DIRECT_EX
130 {
131   ULONG Version;
132   ULONG Length;
133   ULONG CdbLength;
134   ULONG StorAddressLength;
135   UCHAR ScsiStatus;
136   UCHAR SenseInfoLength;
137   UCHAR DataDirection;
138   UCHAR Reserved;
139   ULONG TimeOutValue;
140   ULONG StorAddressOffset;
141   ULONG SenseInfoOffset;
142   ULONG DataOutTransferLength;
143   ULONG DataInTransferLength;
144   PVOID DataOutBuffer;
145   PVOID DataInBuffer;
146   UCHAR Cdb[ANYSIZE_ARRAY];
147 } SCSI_PASS_THROUGH_DIRECT_EX, *PSCSI_PASS_THROUGH_DIRECT_EX;
148 
149 #if defined(_WIN64)
150 typedef struct _SCSI_PASS_THROUGH32_EX
151 {
152   ULONG Version;
153   ULONG Length;
154   ULONG CdbLength;
155   ULONG StorAddressLength;
156   UCHAR ScsiStatus;
157   UCHAR SenseInfoLength;
158   UCHAR DataDirection;
159   UCHAR Reserved;
160   ULONG TimeOutValue;
161   ULONG StorAddressOffset;
162   ULONG SenseInfoOffset;
163   ULONG DataOutTransferLength;
164   ULONG DataInTransferLength;
165   ULONG32 DataOutBufferOffset;
166   ULONG32 DataInBufferOffset;
167   UCHAR Cdb[ANYSIZE_ARRAY];
168 } SCSI_PASS_THROUGH32_EX, *PSCSI_PASS_THROUGH32_EX;
169 
170 typedef struct _SCSI_PASS_THROUGH_DIRECT32_EX
171 {
172   ULONG Version;
173   ULONG Length;
174   ULONG CdbLength;
175   ULONG StorAddressLength;
176   UCHAR ScsiStatus;
177   UCHAR SenseInfoLength;
178   UCHAR DataDirection;
179   UCHAR Reserved;
180   ULONG TimeOutValue;
181   ULONG StorAddressOffset;
182   ULONG SenseInfoOffset;
183   ULONG DataOutTransferLength;
184   ULONG DataInTransferLength;
185   VOID * POINTER_32 DataOutBuffer;
186   VOID * POINTER_32 DataInBuffer;
187   UCHAR Cdb[ANYSIZE_ARRAY];
188 } SCSI_PASS_THROUGH_DIRECT32_EX, *PSCSI_PASS_THROUGH_DIRECT32_EX;
189 #endif
190 
191   typedef struct _ATA_PASS_THROUGH_EX {
192     USHORT Length;
193     USHORT AtaFlags;
194     UCHAR PathId;
195     UCHAR TargetId;
196     UCHAR Lun;
197     UCHAR ReservedAsUchar;
198     ULONG DataTransferLength;
199     ULONG TimeOutValue;
200     ULONG ReservedAsUlong;
201     ULONG_PTR DataBufferOffset;
202     UCHAR PreviousTaskFile[8];
203     UCHAR CurrentTaskFile[8];
204   } ATA_PASS_THROUGH_EX,*PATA_PASS_THROUGH_EX;
205 
206   typedef struct _ATA_PASS_THROUGH_DIRECT {
207     USHORT Length;
208     USHORT AtaFlags;
209     UCHAR PathId;
210     UCHAR TargetId;
211     UCHAR Lun;
212     UCHAR ReservedAsUchar;
213     ULONG DataTransferLength;
214     ULONG TimeOutValue;
215     ULONG ReservedAsUlong;
216     PVOID DataBuffer;
217     UCHAR PreviousTaskFile[8];
218     UCHAR CurrentTaskFile[8];
219   } ATA_PASS_THROUGH_DIRECT,*PATA_PASS_THROUGH_DIRECT;
220 
221 #if defined(_WIN64)
222 
223   typedef struct _ATA_PASS_THROUGH_EX32 {
224     USHORT Length;
225     USHORT AtaFlags;
226     UCHAR PathId;
227     UCHAR TargetId;
228     UCHAR Lun;
229     UCHAR ReservedAsUchar;
230     ULONG DataTransferLength;
231     ULONG TimeOutValue;
232     ULONG ReservedAsUlong;
233     ULONG32 DataBufferOffset;
234     UCHAR PreviousTaskFile[8];
235     UCHAR CurrentTaskFile[8];
236   } ATA_PASS_THROUGH_EX32,*PATA_PASS_THROUGH_EX32;
237 
238   typedef struct _ATA_PASS_THROUGH_DIRECT32 {
239     USHORT Length;
240     USHORT AtaFlags;
241     UCHAR PathId;
242     UCHAR TargetId;
243     UCHAR Lun;
244     UCHAR ReservedAsUchar;
245     ULONG DataTransferLength;
246     ULONG TimeOutValue;
247     ULONG ReservedAsUlong;
248     VOID * POINTER_32 DataBuffer;
249     UCHAR PreviousTaskFile[8];
250     UCHAR CurrentTaskFile[8];
251   } ATA_PASS_THROUGH_DIRECT32,*PATA_PASS_THROUGH_DIRECT32;
252 #endif /* _WIN64 */
253 
254 #define ATA_FLAGS_DRDY_REQUIRED (1 << 0)
255 #define ATA_FLAGS_DATA_IN (1 << 1)
256 #define ATA_FLAGS_DATA_OUT (1 << 2)
257 #define ATA_FLAGS_48BIT_COMMAND (1 << 3)
258 #define ATA_FLAGS_USE_DMA (1 << 4)
259 
260   typedef struct _SCSI_BUS_DATA {
261     UCHAR NumberOfLogicalUnits;
262     UCHAR InitiatorBusId;
263     ULONG InquiryDataOffset;
264   }SCSI_BUS_DATA,*PSCSI_BUS_DATA;
265 
266   typedef struct _SCSI_ADAPTER_BUS_INFO {
267     UCHAR NumberOfBuses;
268     SCSI_BUS_DATA BusData[1];
269   } SCSI_ADAPTER_BUS_INFO,*PSCSI_ADAPTER_BUS_INFO;
270 
271   typedef struct _SCSI_INQUIRY_DATA {
272     UCHAR PathId;
273     UCHAR TargetId;
274     UCHAR Lun;
275     BOOLEAN DeviceClaimed;
276     ULONG InquiryDataLength;
277     ULONG NextInquiryDataOffset;
278     UCHAR InquiryData[1];
279   }SCSI_INQUIRY_DATA,*PSCSI_INQUIRY_DATA;
280 
281   typedef struct _SRB_IO_CONTROL {
282     ULONG HeaderLength;
283     UCHAR Signature[8];
284     ULONG Timeout;
285     ULONG ControlCode;
286     ULONG ReturnCode;
287     ULONG Length;
288   } SRB_IO_CONTROL,*PSRB_IO_CONTROL;
289 
290   typedef struct _IO_SCSI_CAPABILITIES {
291     ULONG Length;
292     ULONG MaximumTransferLength;
293     ULONG MaximumPhysicalPages;
294     ULONG SupportedAsynchronousEvents;
295     ULONG AlignmentMask;
296     BOOLEAN TaggedQueuing;
297     BOOLEAN AdapterScansDown;
298     BOOLEAN AdapterUsesPio;
299   } IO_SCSI_CAPABILITIES,*PIO_SCSI_CAPABILITIES;
300 
301   typedef struct _SCSI_ADDRESS {
302     ULONG Length;
303     UCHAR PortNumber;
304     UCHAR PathId;
305     UCHAR TargetId;
306     UCHAR Lun;
307   } SCSI_ADDRESS,*PSCSI_ADDRESS;
308 
309   struct _ADAPTER_OBJECT;
310 
311   typedef struct _DUMP_POINTERS {
312     struct _ADAPTER_OBJECT *AdapterObject;
313     PVOID MappedRegisterBase;
314     PVOID DumpData;
315     PVOID CommonBufferVa;
316     LARGE_INTEGER CommonBufferPa;
317     ULONG CommonBufferSize;
318     BOOLEAN AllocateCommonBuffers;
319     BOOLEAN UseDiskDump;
320     UCHAR Spare1[2];
321     PVOID DeviceObject;
322   } DUMP_POINTERS,*PDUMP_POINTERS;
323 
324 #define SCSI_IOCTL_DATA_OUT 0
325 #define SCSI_IOCTL_DATA_IN 1
326 #define SCSI_IOCTL_DATA_UNSPECIFIED 2
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif /* _NTDDSCSIH_ */
333 
334