[XDK/DDK]
[reactos.git] / reactos / include / ddk / storport.h
1 /*
2 * storport.h
3 *
4 * StorPort interface
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __STORPORT_H
24 #define __STORPORT_H
25
26 #include "srb.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 #if defined(_STORPORT_)
33 #define STORPORTAPI
34 #else
35 #define STORPORTAPI DECLSPEC_IMPORT
36 #endif
37
38 typedef PHYSICAL_ADDRESS STOR_PHYSICAL_ADDRESS;
39
40 typedef struct _STOR_SCATTER_GATHER_ELEMENT {
41 STOR_PHYSICAL_ADDRESS PhysicalAddress;
42 ULONG Length;
43 ULONG_PTR Reserved;
44 } STOR_SCATTER_GATHER_ELEMENT, *PSTOR_SCATTER_GATHER_ELEMENT;
45
46 typedef struct _STOR_SCATTER_GATHER_LIST {
47 ULONG NumberOfElements;
48 ULONG_PTR Reserved;
49 STOR_SCATTER_GATHER_ELEMENT List[0];
50 } STOR_SCATTER_GATHER_LIST, *PSTOR_SCATTER_GATHER_LIST;
51
52 typedef struct _SCSI_WMI_REQUEST_BLOCK {
53 USHORT Length;
54 UCHAR Function;
55 UCHAR SrbStatus;
56 UCHAR WMISubFunction;
57 UCHAR PathId;
58 UCHAR TargetId;
59 UCHAR Lun;
60 UCHAR Reserved1;
61 UCHAR WMIFlags;
62 UCHAR Reserved2[2];
63 ULONG SrbFlags;
64 ULONG DataTransferLength;
65 ULONG TimeOutValue;
66 PVOID DataBuffer;
67 PVOID DataPath;
68 PVOID Reserved3;
69 PVOID OriginalRequest;
70 PVOID SrbExtension;
71 ULONG Reserved4;
72 UCHAR Reserved5[16];
73 } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
74
75 STORPORTAPI
76 ULONG
77 NTAPI
78 StorPortInitialize(
79 _In_ PVOID Argument1,
80 _In_ PVOID Argument2,
81 _In_ PHW_INITIALIZATION_DATA HwInitializationData,
82 _In_opt_ PVOID Unused);
83
84 STORPORTAPI
85 VOID
86 NTAPI
87 StorPortFreeDeviceBase(
88 _In_ PVOID HwDeviceExtension,
89 _In_ PVOID MappedAddress);
90
91 STORPORTAPI
92 ULONG
93 NTAPI
94 StorPortGetBusData(
95 _In_ PVOID DeviceExtension,
96 _In_ ULONG BusDataType,
97 _In_ ULONG SystemIoBusNumber,
98 _In_ ULONG SlotNumber,
99 _Out_ _When_(Length != 0, _Out_writes_bytes_(Length)) PVOID Buffer,
100 _In_ ULONG Length);
101
102 STORPORTAPI
103 ULONG
104 NTAPI
105 StorPortSetBusDataByOffset(
106 _In_ PVOID DeviceExtension,
107 _In_ ULONG BusDataType,
108 _In_ ULONG SystemIoBusNumber,
109 _In_ ULONG SlotNumber,
110 _In_reads_bytes_(Length) PVOID Buffer,
111 _In_ ULONG Offset,
112 _In_ ULONG Length);
113
114 STORPORTAPI
115 PVOID
116 NTAPI
117 StorPortGetDeviceBase(
118 _In_ PVOID HwDeviceExtension,
119 _In_ INTERFACE_TYPE BusType,
120 _In_ ULONG SystemIoBusNumber,
121 _In_ SCSI_PHYSICAL_ADDRESS IoAddress,
122 _In_ ULONG NumberOfBytes,
123 _In_ BOOLEAN InIoSpace);
124
125 STORPORTAPI
126 PVOID
127 NTAPI
128 StorPortGetLogicalUnit(
129 _In_ PVOID HwDeviceExtension,
130 _In_ UCHAR PathId,
131 _In_ UCHAR TargetId,
132 _In_ UCHAR Lun);
133
134 STORPORTAPI
135 PSCSI_REQUEST_BLOCK
136 NTAPI
137 StorPortGetSrb(
138 _In_ PVOID DeviceExtension,
139 _In_ UCHAR PathId,
140 _In_ UCHAR TargetId,
141 _In_ UCHAR Lun,
142 _In_ LONG QueueTag);
143
144 STORPORTAPI
145 STOR_PHYSICAL_ADDRESS
146 NTAPI
147 StorPortGetPhysicalAddress(
148 _In_ PVOID HwDeviceExtension,
149 _In_opt_ PSCSI_REQUEST_BLOCK Srb,
150 _In_ PVOID VirtualAddress,
151 _Out_ ULONG *Length);
152
153 STORPORTAPI
154 PVOID
155 NTAPI
156 StorPortGetVirtualAddress(
157 _In_ PVOID HwDeviceExtension,
158 _In_ STOR_PHYSICAL_ADDRESS PhysicalAddress);
159
160 STORPORTAPI
161 PVOID
162 NTAPI
163 StorPortGetUncachedExtension(
164 _In_ PVOID HwDeviceExtension,
165 _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
166 _In_ ULONG NumberOfBytes);
167
168 STORPORTAPI
169 VOID
170 __cdecl
171 StorPortNotification(
172 _In_ SCSI_NOTIFICATION_TYPE NotificationType,
173 _In_ PVOID HwDeviceExtension,
174 ...);
175
176 STORPORTAPI
177 VOID
178 NTAPI
179 StorPortLogError(
180 _In_ PVOID HwDeviceExtension,
181 _In_opt_ PSCSI_REQUEST_BLOCK Srb,
182 _In_ UCHAR PathId,
183 _In_ UCHAR TargetId,
184 _In_ UCHAR Lun,
185 _In_ ULONG ErrorCode,
186 _In_ ULONG UniqueId);
187
188 STORPORTAPI
189 VOID
190 NTAPI
191 StorPortCompleteRequest(
192 _In_ PVOID HwDeviceExtension,
193 _In_ UCHAR PathId,
194 _In_ UCHAR TargetId,
195 _In_ UCHAR Lun,
196 _In_ UCHAR SrbStatus);
197
198 STORPORTAPI
199 VOID
200 NTAPI
201 StorPortMoveMemory(
202 _Out_writes_bytes_(Length) PVOID WriteBuffer,
203 _In_reads_bytes_(Length) PVOID ReadBuffer,
204 _In_ ULONG Length);
205
206 STORPORTAPI
207 VOID
208 NTAPI
209 StorPortStallExecution(
210 _In_ ULONG Delay);
211
212 STORPORTAPI
213 STOR_PHYSICAL_ADDRESS
214 NTAPI
215 StorPortConvertUlong64ToPhysicalAddress(
216 _In_ ULONG64 UlongAddress);
217
218 STORPORTAPI
219 ULONG64
220 NTAPI
221 StorPortConvertPhysicalAddressToUlong64(
222 _In_ STOR_PHYSICAL_ADDRESS Address);
223
224 STORPORTAPI
225 BOOLEAN
226 NTAPI
227 StorPortValidateRange(
228 _In_ PVOID HwDeviceExtension,
229 _In_ INTERFACE_TYPE BusType,
230 _In_ ULONG SystemIoBusNumber,
231 _In_ STOR_PHYSICAL_ADDRESS IoAddress,
232 _In_ ULONG NumberOfBytes,
233 _In_ BOOLEAN InIoSpace);
234
235 STORPORTAPI
236 VOID
237 __cdecl
238 StorPortDebugPrint(
239 _In_ ULONG DebugPrintLevel,
240 _In_ PCCHAR DebugMessage,
241 ...);
242
243 STORPORTAPI
244 UCHAR
245 NTAPI
246 StorPortReadPortUchar(
247 _In_ PVOID HwDeviceExtension,
248 _In_ PUCHAR Port);
249
250 STORPORTAPI
251 ULONG
252 NTAPI
253 StorPortReadPortUlong(
254 _In_ PVOID HwDeviceExtension,
255 _In_ PULONG Port);
256
257 STORPORTAPI
258 USHORT
259 NTAPI
260 StorPortReadPortUshort(
261 _In_ PVOID HwDeviceExtension,
262 _In_ PUSHORT Port);
263
264 STORPORTAPI
265 UCHAR
266 NTAPI
267 StorPortReadRegisterUchar(
268 _In_ PVOID HwDeviceExtension,
269 _In_ PUCHAR Register);
270
271 STORPORTAPI
272 ULONG
273 NTAPI
274 StorPortReadRegisterUlong(
275 _In_ PVOID HwDeviceExtension,
276 _In_ PULONG Register);
277
278 STORPORTAPI
279 USHORT
280 NTAPI
281 StorPortReadRegisterUshort(
282 _In_ PVOID HwDeviceExtension,
283 _In_ PUSHORT Register);
284
285 STORPORTAPI
286 VOID
287 NTAPI
288 StorPortWritePortUchar(
289 _In_ PVOID HwDeviceExtension,
290 _In_ PUCHAR Port,
291 _In_ UCHAR Value);
292
293 STORPORTAPI
294 VOID
295 NTAPI
296 StorPortWritePortUlong(
297 _In_ PVOID HwDeviceExtension,
298 _In_ PULONG Port,
299 _In_ ULONG Value);
300
301 STORPORTAPI
302 VOID
303 NTAPI
304 StorPortWritePortUshort(
305 _In_ PVOID HwDeviceExtension,
306 _In_ PUSHORT Port,
307 _In_ USHORT Value);
308
309 STORPORTAPI
310 VOID
311 NTAPI
312 StorPortWriteRegisterUchar(
313 _In_ PVOID HwDeviceExtension,
314 _In_ PUCHAR Register,
315 _In_ UCHAR Value);
316
317 STORPORTAPI
318 VOID
319 NTAPI
320 StorPortWriteRegisterUlong(
321 _In_ PVOID HwDeviceExtension,
322 _In_ PULONG Register,
323 _In_ ULONG Value);
324
325 STORPORTAPI
326 VOID
327 NTAPI
328 StorPortWriteRegisterUshort(
329 _In_ PVOID HwDeviceExtension,
330 _In_ PUSHORT Register,
331 _In_ USHORT Value);
332
333 STORPORTAPI
334 BOOLEAN
335 NTAPI
336 StorPortPauseDevice(
337 _In_ PVOID HwDeviceExtension,
338 _In_ UCHAR PathId,
339 _In_ UCHAR TargetId,
340 _In_ UCHAR Lun,
341 _In_ ULONG TimeOut);
342
343 STORPORTAPI
344 BOOLEAN
345 NTAPI
346 StorPortResumeDevice(
347 _In_ PVOID HwDeviceExtension,
348 _In_ UCHAR PathId,
349 _In_ UCHAR TargetId,
350 _In_ UCHAR Lun);
351
352 STORPORTAPI
353 BOOLEAN
354 NTAPI
355 StorPortPause(
356 _In_ PVOID HwDeviceExtension,
357 _In_ ULONG TimeOut);
358
359 STORPORTAPI
360 BOOLEAN
361 NTAPI
362 StorPortResume(
363 _In_ PVOID HwDeviceExtension);
364
365 STORPORTAPI
366 BOOLEAN
367 NTAPI
368 StorPortDeviceBusy(
369 _In_ PVOID HwDeviceExtension,
370 _In_ UCHAR PathId,
371 _In_ UCHAR TargetId,
372 _In_ UCHAR Lun,
373 _In_ ULONG RequestsToComplete);
374
375 STORPORTAPI
376 BOOLEAN
377 NTAPI
378 StorPortDeviceReady(
379 _In_ PVOID HwDeviceExtension,
380 _In_ UCHAR PathId,
381 _In_ UCHAR TargetId,
382 _In_ UCHAR Lun);
383
384 STORPORTAPI
385 BOOLEAN
386 NTAPI
387 StorPortBusy(
388 _In_ PVOID HwDeviceExtension,
389 _In_ ULONG RequestsToComplete);
390
391 STORPORTAPI
392 BOOLEAN
393 NTAPI
394 StorPortReady(
395 _In_ PVOID HwDeviceExtension);
396
397 STORPORTAPI
398 PSTOR_SCATTER_GATHER_LIST
399 NTAPI
400 StorPortGetScatterGatherList(
401 _In_ PVOID DeviceExtension,
402 _In_ PSCSI_REQUEST_BLOCK Srb);
403
404 typedef BOOLEAN
405 (NTAPI STOR_SYNCHRONIZED_ACCESS)(
406 _In_ PVOID HwDeviceExtension,
407 _In_ PVOID Context);
408 typedef STOR_SYNCHRONIZED_ACCESS *PSTOR_SYNCHRONIZED_ACCESS;
409
410 STORPORTAPI
411 VOID
412 NTAPI
413 StorPortSynchronizeAccess(
414 _In_ PVOID HwDeviceExtension,
415 _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine,
416 _In_opt_ PVOID Context);
417
418 #if DBG
419 #define DebugPrint(x) StorPortDebugPrint x
420 #else
421 #define DebugPrint(x)
422 #endif
423
424 #ifdef __cplusplus
425 }
426 #endif
427
428 #endif /* __STORPORT_H */