[APPHELP_APITEST] Add tests for SdbGetMatchingExe, to test matching on version resour...
[reactos.git] / reactos / drivers / storage / inc / class.h
1 /*++
2
3 Copyright (c) 1991 Microsoft Corporation
4
5 Module Name:
6
7 class.h
8
9 Abstract:
10
11 These are the structures and defines that are used in the
12 SCSI class drivers.
13
14 Author:
15
16 Mike Glass (mglass)
17 Jeff Havens (jhavens)
18
19 Revision History:
20
21 --*/
22
23 #ifndef _CLASS_
24
25 #include <ntdddisk.h>
26 #include <ntddcdrm.h>
27 #include <ntddtape.h>
28 #include <ntddchgr.h>
29 #include <ntddstor.h>
30 #include "ntddscsi.h"
31 #include <stdio.h>
32
33 // begin_ntminitape
34
35 #if DBG
36
37 #define DebugPrint(x) ScsiDebugPrint x
38
39 #else
40
41 #define DebugPrint(x)
42
43 #endif // DBG
44
45 // end_ntminitape
46
47 #ifdef POOL_TAGGING
48 #undef ExAllocatePool
49 #undef ExAllocatePoolWithQuota
50 #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'HscS')
51 #define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,'HscS')
52 #endif
53
54 #define MAXIMUM_RETRIES 4
55
56 typedef
57 VOID
58 (*PCLASS_ERROR) (
59 IN PDEVICE_OBJECT DeviceObject,
60 IN PSCSI_REQUEST_BLOCK Srb,
61 IN OUT NTSTATUS *Status,
62 IN OUT BOOLEAN *Retry
63 );
64
65 typedef struct _DEVICE_EXTENSION {
66
67 //
68 // Back pointer to device object
69 //
70
71 PDEVICE_OBJECT DeviceObject;
72
73 //
74 // Pointer to port device object
75 //
76
77 PDEVICE_OBJECT PortDeviceObject;
78
79 //
80 // Length of partition in bytes
81 //
82
83 LARGE_INTEGER PartitionLength;
84
85 //
86 // Number of bytes before start of partition
87 //
88
89 LARGE_INTEGER StartingOffset;
90
91 //
92 // Bytes to skew all requests, since DM Driver has been placed on an IDE drive.
93 //
94
95 ULONG DMByteSkew;
96
97 //
98 // Sectors to skew all requests.
99 //
100
101 ULONG DMSkew;
102
103 //
104 // Flag to indicate whether DM driver has been located on an IDE drive.
105 //
106
107 BOOLEAN DMActive;
108
109 //
110 // Pointer to the specific class error routine.
111 //
112
113 PCLASS_ERROR ClassError;
114
115 //
116 // SCSI port driver capabilities
117 //
118
119 PIO_SCSI_CAPABILITIES PortCapabilities;
120
121 //
122 // Buffer for drive parameters returned in IO device control.
123 //
124
125 PDISK_GEOMETRY DiskGeometry;
126
127 //
128 // Back pointer to device object of physical device
129 //
130
131 PDEVICE_OBJECT PhysicalDevice;
132
133 //
134 // Request Sense Buffer
135 //
136
137 PSENSE_DATA SenseData;
138
139 //
140 // Request timeout in seconds;
141 //
142
143 ULONG TimeOutValue;
144
145 //
146 // System device number
147 //
148
149 ULONG DeviceNumber;
150
151 //
152 // Add default Srb Flags.
153 //
154
155 ULONG SrbFlags;
156
157 //
158 // Total number of SCSI protocol errors on the device.
159 //
160
161 ULONG ErrorCount;
162
163 //
164 // Spinlock for split requests
165 //
166
167 KSPIN_LOCK SplitRequestSpinLock;
168
169 //
170 // Zone header and spin lock for zoned SRB requests.
171 //
172
173 PZONE_HEADER SrbZone;
174
175 PKSPIN_LOCK SrbZoneSpinLock;
176
177 //
178 // Lock count for removable media.
179 //
180
181 LONG LockCount;
182
183 //
184 // Scsi port number
185 //
186
187 UCHAR PortNumber;
188
189 //
190 // SCSI path id
191 //
192
193 UCHAR PathId;
194
195 //
196 // SCSI bus target id
197 //
198
199 UCHAR TargetId;
200
201 //
202 // SCSI bus logical unit number
203 //
204
205 UCHAR Lun;
206
207 //
208 // Log2 of sector size
209 //
210
211 UCHAR SectorShift;
212
213 //
214 // Flag to indicate that the device has write caching enabled.
215 //
216
217 BOOLEAN WriteCache;
218
219 //
220 // Build SCSI 1 or SCSI 2 CDBs
221 //
222
223 BOOLEAN UseScsi1;
224
225 } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
226
227 //
228 // Define context structure for asynchronous completions.
229 //
230
231 typedef struct _COMPLETION_CONTEXT {
232 PDEVICE_OBJECT DeviceObject;
233 SCSI_REQUEST_BLOCK Srb;
234 }COMPLETION_CONTEXT, *PCOMPLETION_CONTEXT;
235
236 \f
237 NTSTATUS
238 ScsiClassGetCapabilities(
239 IN PDEVICE_OBJECT PortDeviceObject,
240 OUT PIO_SCSI_CAPABILITIES *PortCapabilities
241 );
242
243 NTSTATUS
244 ScsiClassGetInquiryData(
245 IN PDEVICE_OBJECT PortDeviceObject,
246 IN PSCSI_ADAPTER_BUS_INFO *ConfigInfo
247 );
248
249 NTSTATUS
250 ScsiClassReadDriveCapacity(
251 IN PDEVICE_OBJECT DeviceObject
252 );
253
254 VOID
255 ScsiClassReleaseQueue(
256 IN PDEVICE_OBJECT DeviceObject
257 );
258
259 NTSTATUS
260 ScsiClassRemoveDevice(
261 IN PDEVICE_OBJECT PortDeviceObject,
262 IN UCHAR PathId,
263 IN UCHAR TargetId,
264 IN UCHAR Lun
265 );
266
267 NTSTATUS
268 ScsiClassAsynchronousCompletion(
269 PDEVICE_OBJECT DeviceObject,
270 PIRP Irp,
271 PVOID Context
272 );
273
274 VOID
275 ScsiClassSplitRequest(
276 IN PDEVICE_OBJECT DeviceObject,
277 IN PIRP Irp,
278 IN ULONG MaximumBytes
279 );
280
281 NTSTATUS
282 ScsiClassDeviceControl(
283 PDEVICE_OBJECT DeviceObject,
284 PIRP Irp
285 );
286
287 NTSTATUS
288 ScsiClassIoComplete(
289 IN PDEVICE_OBJECT DeviceObject,
290 IN PIRP Irp,
291 IN PVOID Context
292 );
293
294 NTSTATUS
295 ScsiClassIoCompleteAssociated(
296 IN PDEVICE_OBJECT DeviceObject,
297 IN PIRP Irp,
298 IN PVOID Context
299 );
300
301 BOOLEAN
302 ScsiClassInterpretSenseInfo(
303 IN PDEVICE_OBJECT DeviceObject,
304 IN PSCSI_REQUEST_BLOCK Srb,
305 IN UCHAR MajorFunctionCode,
306 IN ULONG IoDeviceCode,
307 IN ULONG RetryCount,
308 OUT NTSTATUS *Status
309 );
310
311 NTSTATUS
312 ScsiClassSendSrbSynchronous(
313 PDEVICE_OBJECT DeviceObject,
314 PSCSI_REQUEST_BLOCK Srb,
315 PVOID BufferAddress,
316 ULONG BufferLength,
317 BOOLEAN WriteToDevice
318 );
319
320 NTSTATUS
321 ScsiClassSendSrbAsynchronous(
322 PDEVICE_OBJECT DeviceObject,
323 PSCSI_REQUEST_BLOCK Srb,
324 PIRP Irp,
325 PVOID BufferAddress,
326 ULONG BufferLength,
327 BOOLEAN WriteToDevice
328 );
329
330 VOID
331 ScsiClassBuildRequest(
332 PDEVICE_OBJECT DeviceObject,
333 PIRP Irp
334 );
335
336 ULONG
337 ScsiClassModeSense(
338 IN PDEVICE_OBJECT DeviceObject,
339 IN PCHAR ModeSenseBuffer,
340 IN ULONG Length,
341 IN UCHAR PageMode
342 );
343
344 BOOLEAN
345 ScsiClassModeSelect(
346 IN PDEVICE_OBJECT DeviceObject,
347 IN PCHAR ModeSelectBuffer,
348 IN ULONG Length,
349 IN BOOLEAN SavePage
350 );
351
352 PVOID
353 ScsiClassFindModePage(
354 IN PCHAR ModeSenseBuffer,
355 IN ULONG Length,
356 IN UCHAR PageMode
357 );
358
359 NTSTATUS
360 ScsiClassClaimDevice(
361 IN PDEVICE_OBJECT PortDeviceObject,
362 IN PSCSI_INQUIRY_DATA LunInfo,
363 IN BOOLEAN Release,
364 OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL
365 );
366
367 NTSTATUS
368 ScsiClassInternalIoControl (
369 IN PDEVICE_OBJECT DeviceObject,
370 IN PIRP Irp
371 );
372
373 #endif /* _CLASS_ */
374