[DDK]
[reactos.git] / reactos / include / ddk / classpnp.h
1
2 #pragma once
3
4 #define _CLASS_
5
6 #include <ntdddisk.h>
7 #include <ntddcdrm.h>
8 #include <ntddtape.h>
9 #include <ntddscsi.h>
10 #include <ntddstor.h>
11
12 #include <stdio.h>
13
14 #include <scsi.h>
15
16 #define DEBUG_BUFFER_LENGTH 256
17
18 #define SRB_CLASS_FLAGS_LOW_PRIORITY 0x10000000
19 #define SRB_CLASS_FLAGS_PERSISTANT 0x20000000
20 #define SRB_CLASS_FLAGS_PAGING 0x40000000
21 #define SRB_CLASS_FLAGS_FREE_MDL 0x80000000
22
23 #define IS_CLEANUP_REQUEST(majorFunction) \
24 ((majorFunction == IRP_MJ_CLOSE) || \
25 (majorFunction == IRP_MJ_CLEANUP) || \
26 (majorFunction == IRP_MJ_SHUTDOWN))
27
28 #define DO_MCD(fdoExtension) \
29 (((fdoExtension)->MediaChangeDetectionInfo != NULL) && \
30 ((fdoExtension)->MediaChangeDetectionInfo->MediaChangeDetectionDisableCount == 0))
31
32 #define IS_SCSIOP_READ(opCode) \
33 ((opCode == SCSIOP_READ6) || \
34 (opCode == SCSIOP_READ) || \
35 (opCode == SCSIOP_READ12) || \
36 (opCode == SCSIOP_READ16))
37
38 #define IS_SCSIOP_WRITE(opCode) \
39 ((opCode == SCSIOP_WRITE6) || \
40 (opCode == SCSIOP_WRITE) || \
41 (opCode == SCSIOP_WRITE12) || \
42 (opCode == SCSIOP_WRITE16))
43
44 #define IS_SCSIOP_READWRITE(opCode) (IS_SCSIOP_READ(opCode) || IS_SCSIOP_WRITE(opCode))
45
46 #define MAXIMUM_RETRIES 4
47
48 #define CLASS_DRIVER_EXTENSION_KEY ((PVOID) ClassInitialize)
49
50 #define NO_REMOVE 0
51 #define REMOVE_PENDING 1
52 #define REMOVE_COMPLETE 2
53
54 #define ClassAcquireRemoveLock(devobj, tag) \
55 ClassAcquireRemoveLockEx(devobj, tag, __FILE__, __LINE__)
56
57 #define START_UNIT_TIMEOUT (60 * 4)
58
59 #define MEDIA_CHANGE_DEFAULT_TIME 1
60 #define MEDIA_CHANGE_TIMEOUT_TIME 300
61
62 #define MAXIMUM_RETRY_FOR_SINGLE_IO_IN_100NS_UNITS 0x3b9aca00
63
64 #ifdef ALLOCATE_SRB_FROM_POOL
65
66 #define ClasspAllocateSrb(ext)
67 ExAllocatePoolWithTag(NonPagedPool, \
68 sizeof(SCSI_REQUEST_BLOCK), \
69 'sBRS')
70
71 #define ClasspFreeSrb(ext, srb) ExFreePool((srb));
72
73 #else /* ALLOCATE_SRB_FROM_POOL */
74
75 #define ClasspAllocateSrb(ext) \
76 ExAllocateFromNPagedLookasideList( \
77 &((ext)->CommonExtension.SrbLookasideList))
78
79 #define ClasspFreeSrb(ext, srb) \
80 ExFreeToNPagedLookasideList( \
81 &((ext)->CommonExtension.SrbLookasideList), \
82 (srb))
83
84 #endif /* ALLOCATE_SRB_FROM_POOL */
85
86 #define CLASS_WORKING_SET_MAXIMUM 2048
87
88 #define CLASS_INTERPRET_SENSE_INFO2_MAXIMUM_HISTORY_COUNT 30000
89
90 #define CLASS_SPECIAL_DISABLE_SPIN_DOWN 0x00000001
91 #define CLASS_SPECIAL_DISABLE_SPIN_UP 0x00000002
92 #define CLASS_SPECIAL_NO_QUEUE_LOCK 0x00000008
93 #define CLASS_SPECIAL_DISABLE_WRITE_CACHE 0x00000010
94 #define CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK 0x00000020
95 #if ((NTDDI_VERSION == NTDDI_WIN2KSP3) || (OSVER(NTDDI_VERSION) == NTDDI_WINXP))
96 #define CLASS_SPECIAL_DISABLE_WRITE_CACHE_NOT_SUPPORTED 0x00000040
97 #endif
98 #define CLASS_SPECIAL_MODIFY_CACHE_UNSUCCESSFUL 0x00000040
99 #define CLASS_SPECIAL_FUA_NOT_SUPPORTED 0x00000080
100 #define CLASS_SPECIAL_VALID_MASK 0x000000FB
101 #define CLASS_SPECIAL_RESERVED (~CLASS_SPECIAL_VALID_MASK)
102
103 #define DEV_WRITE_CACHE 0x00000001
104 #define DEV_USE_SCSI1 0x00000002
105 #define DEV_SAFE_START_UNIT 0x00000004
106 #define DEV_NO_12BYTE_CDB 0x00000008
107 #define DEV_POWER_PROTECTED 0x00000010
108 #define DEV_USE_16BYTE_CDB 0x00000020
109
110 #define GUID_CLASSPNP_QUERY_REGINFOEX {0x00e34b11, 0x2444, 0x4745, {0xa5, 0x3d, 0x62, 0x01, 0x00, 0xcd, 0x82, 0xf7}}
111 #define GUID_CLASSPNP_SENSEINFO2 {0x509a8c5f, 0x71d7, 0x48f6, {0x82, 0x1e, 0x17, 0x3c, 0x49, 0xbf, 0x2f, 0x18}}
112 #define GUID_CLASSPNP_WORKING_SET {0x105701b0, 0x9e9b, 0x47cb, {0x97, 0x80, 0x81, 0x19, 0x8a, 0xf7, 0xb5, 0x24}}
113
114 #define DEFAULT_FAILURE_PREDICTION_PERIOD 60 * 60 * 1
115
116 typedef enum _MEDIA_CHANGE_DETECTION_STATE {
117 MediaUnknown,
118 MediaPresent,
119 MediaNotPresent,
120 MediaUnavailable
121 } MEDIA_CHANGE_DETECTION_STATE, *PMEDIA_CHANGE_DETECTION_STATE;
122
123 typedef enum _CLASS_DEBUG_LEVEL {
124 ClassDebugError = 0,
125 ClassDebugWarning = 1,
126 ClassDebugTrace = 2,
127 ClassDebugInfo = 3,
128 ClassDebugMediaLocks = 8,
129 ClassDebugMCN = 9,
130 ClassDebugDelayedRetry = 10,
131 ClassDebugSenseInfo = 11,
132 ClassDebugRemoveLock = 12,
133 ClassDebugExternal4 = 13,
134 ClassDebugExternal3 = 14,
135 ClassDebugExternal2 = 15,
136 ClassDebugExternal1 = 16
137 } CLASS_DEBUG_LEVEL, *PCLASS_DEBUG_LEVEL;
138
139 typedef enum {
140 EventGeneration,
141 DataBlockCollection
142 } CLASSENABLEDISABLEFUNCTION;
143
144 typedef enum {
145 FailurePredictionNone = 0,
146 FailurePredictionIoctl,
147 FailurePredictionSmart,
148 FailurePredictionSense
149 } FAILURE_PREDICTION_METHOD, *PFAILURE_PREDICTION_METHOD;
150
151 typedef enum {
152 PowerDownDeviceInitial,
153 PowerDownDeviceLocked,
154 PowerDownDeviceStopped,
155 PowerDownDeviceOff,
156 PowerDownDeviceUnlocked
157 } CLASS_POWER_DOWN_STATE;
158
159 typedef enum {
160 PowerDownDeviceInitial2,
161 PowerDownDeviceLocked2,
162 PowerDownDeviceFlushed2,
163 PowerDownDeviceStopped2,
164 PowerDownDeviceOff2,
165 PowerDownDeviceUnlocked2
166 } CLASS_POWER_DOWN_STATE2;
167
168 typedef enum {
169 PowerUpDeviceInitial,
170 PowerUpDeviceLocked,
171 PowerUpDeviceOn,
172 PowerUpDeviceStarted,
173 PowerUpDeviceUnlocked
174 } CLASS_POWER_UP_STATE;
175
176 struct _CLASS_INIT_DATA;
177 typedef struct _CLASS_INIT_DATA CLASS_INIT_DATA, *PCLASS_INIT_DATA;
178
179 struct _CLASS_PRIVATE_FDO_DATA;
180 typedef struct _CLASS_PRIVATE_FDO_DATA CLASS_PRIVATE_FDO_DATA, *PCLASS_PRIVATE_FDO_DATA;
181
182 struct _CLASS_PRIVATE_PDO_DATA;
183 typedef struct _CLASS_PRIVATE_PDO_DATA CLASS_PRIVATE_PDO_DATA, *PCLASS_PRIVATE_PDO_DATA;
184
185 struct _CLASS_PRIVATE_COMMON_DATA;
186 typedef struct _CLASS_PRIVATE_COMMON_DATA CLASS_PRIVATE_COMMON_DATA, *PCLASS_PRIVATE_COMMON_DATA;
187
188 struct _MEDIA_CHANGE_DETECTION_INFO;
189 typedef struct _MEDIA_CHANGE_DETECTION_INFO MEDIA_CHANGE_DETECTION_INFO, *PMEDIA_CHANGE_DETECTION_INFO;
190
191 struct _DICTIONARY_HEADER;
192 typedef struct _DICTIONARY_HEADER DICTIONARY_HEADER, *PDICTIONARY_HEADER;
193
194 typedef struct _DICTIONARY {
195 ULONGLONG Signature;
196 PDICTIONARY_HEADER List;
197 KSPIN_LOCK SpinLock;
198 } DICTIONARY, *PDICTIONARY;
199
200 typedef struct _CLASSPNP_SCAN_FOR_SPECIAL_INFO {
201 PCHAR VendorId;
202 PCHAR ProductId;
203 PCHAR ProductRevision;
204 ULONG_PTR Data;
205 } CLASSPNP_SCAN_FOR_SPECIAL_INFO, *PCLASSPNP_SCAN_FOR_SPECIAL_INFO;
206
207 typedef VOID
208 (NTAPI *PCLASS_ERROR)(
209 PDEVICE_OBJECT DeviceObject,
210 PSCSI_REQUEST_BLOCK Srb,
211 NTSTATUS *Status,
212 BOOLEAN *Retry);
213
214 typedef NTSTATUS
215 (NTAPI *PCLASS_ADD_DEVICE)(
216 PDRIVER_OBJECT DriverObject,
217 PDEVICE_OBJECT Pdo);
218
219 typedef NTSTATUS
220 (NTAPI *PCLASS_POWER_DEVICE)(
221 PDEVICE_OBJECT DeviceObject,
222 PIRP Irp);
223
224 typedef NTSTATUS
225 (NTAPI *PCLASS_START_DEVICE)(
226 PDEVICE_OBJECT DeviceObject);
227
228 typedef NTSTATUS
229 (NTAPI *PCLASS_STOP_DEVICE)(
230 PDEVICE_OBJECT DeviceObject,
231 UCHAR Type);
232
233 typedef NTSTATUS
234 (NTAPI *PCLASS_INIT_DEVICE)(
235 PDEVICE_OBJECT DeviceObject);
236
237 typedef NTSTATUS
238 (NTAPI *PCLASS_ENUM_DEVICE)(
239 PDEVICE_OBJECT DeviceObject);
240
241 typedef NTSTATUS
242 (NTAPI *PCLASS_READ_WRITE)(
243 PDEVICE_OBJECT DeviceObject,
244 PIRP Irp);
245
246 typedef NTSTATUS
247 (NTAPI *PCLASS_DEVICE_CONTROL)(
248 PDEVICE_OBJECT DeviceObject,
249 PIRP Irp);
250
251 typedef NTSTATUS
252 (NTAPI *PCLASS_SHUTDOWN_FLUSH)(
253 PDEVICE_OBJECT DeviceObject,
254 PIRP Irp);
255
256 typedef NTSTATUS
257 (NTAPI *PCLASS_CREATE_CLOSE)(
258 PDEVICE_OBJECT DeviceObject,
259 PIRP Irp);
260
261 typedef NTSTATUS
262 (NTAPI *PCLASS_QUERY_ID)(
263 PDEVICE_OBJECT DeviceObject,
264 BUS_QUERY_ID_TYPE IdType,
265 PUNICODE_STRING IdString);
266
267 typedef NTSTATUS
268 (NTAPI *PCLASS_REMOVE_DEVICE)(
269 PDEVICE_OBJECT DeviceObject,
270 UCHAR Type);
271
272 typedef VOID
273 (NTAPI *PCLASS_UNLOAD)(
274 PDRIVER_OBJECT DriverObject);
275
276 typedef NTSTATUS
277 (NTAPI *PCLASS_QUERY_PNP_CAPABILITIES)(
278 PDEVICE_OBJECT PhysicalDeviceObject,
279 PDEVICE_CAPABILITIES Capabilities);
280
281 typedef VOID
282 (NTAPI *PCLASS_TICK)(
283 PDEVICE_OBJECT DeviceObject);
284
285 typedef NTSTATUS
286 (NTAPI *PCLASS_QUERY_WMI_REGINFO_EX)(
287 PDEVICE_OBJECT DeviceObject,
288 ULONG *RegFlags,
289 PUNICODE_STRING Name,
290 PUNICODE_STRING MofResouceName);
291
292 typedef NTSTATUS
293 (NTAPI *PCLASS_QUERY_WMI_REGINFO)(
294 PDEVICE_OBJECT DeviceObject,
295 ULONG *RegFlags,
296 PUNICODE_STRING Name);
297
298 typedef NTSTATUS
299 (NTAPI *PCLASS_QUERY_WMI_DATABLOCK)(
300 PDEVICE_OBJECT DeviceObject,
301 PIRP Irp,
302 ULONG GuidIndex,
303 ULONG BufferAvail,
304 PUCHAR Buffer);
305
306 typedef NTSTATUS
307 (NTAPI *PCLASS_SET_WMI_DATABLOCK)(
308 PDEVICE_OBJECT DeviceObject,
309 PIRP Irp,
310 ULONG GuidIndex,
311 ULONG BufferSize,
312 PUCHAR Buffer);
313
314 typedef NTSTATUS
315 (NTAPI *PCLASS_SET_WMI_DATAITEM)(
316 PDEVICE_OBJECT DeviceObject,
317 PIRP Irp,
318 ULONG GuidIndex,
319 ULONG DataItemId,
320 ULONG BufferSize,
321 PUCHAR Buffer);
322
323 typedef NTSTATUS
324 (NTAPI *PCLASS_EXECUTE_WMI_METHOD)(
325 PDEVICE_OBJECT DeviceObject,
326 PIRP Irp,
327 ULONG GuidIndex,
328 ULONG MethodId,
329 ULONG InBufferSize,
330 ULONG OutBufferSize,
331 PUCHAR Buffer);
332
333 typedef NTSTATUS
334 (NTAPI *PCLASS_WMI_FUNCTION_CONTROL)(
335 PDEVICE_OBJECT DeviceObject,
336 PIRP Irp,
337 ULONG GuidIndex,
338 CLASSENABLEDISABLEFUNCTION Function,
339 BOOLEAN Enable);
340
341 typedef struct _SRB_HISTORY_ITEM {
342 LARGE_INTEGER TickCountSent;
343 LARGE_INTEGER TickCountCompleted;
344 ULONG MillisecondsDelayOnRetry;
345 SENSE_DATA NormalizedSenseData;
346 UCHAR SrbStatus;
347 UCHAR ClassDriverUse;
348 } SRB_HISTORY_ITEM, *PSRB_HISTORY_ITEM;
349
350 typedef struct _SRB_HISTORY {
351 ULONG_PTR ClassDriverUse[4];
352 ULONG TotalHistoryCount;
353 ULONG UsedHistoryCount;
354 SRB_HISTORY_ITEM History[1];
355 } SRB_HISTORY, *PSRB_HISTORY;
356
357 typedef BOOLEAN
358 (NTAPI *PCLASS_INTERPRET_SENSE_INFO)(
359 PDEVICE_OBJECT Fdo,
360 PIRP OriginalRequest,
361 PSCSI_REQUEST_BLOCK Srb,
362 UCHAR MajorFunctionCode,
363 ULONG IoDeviceCode,
364 ULONG PreviousRetryCount,
365 SRB_HISTORY *RequestHistory,
366 NTSTATUS *Status,
367 LONGLONG *RetryIn100nsUnits);
368
369 typedef VOID
370 (NTAPI *PCLASS_COMPRESS_RETRY_HISTORY_DATA)(
371 PDEVICE_OBJECT DeviceObject,
372 PSRB_HISTORY RequestHistory);
373
374 typedef struct {
375 GUID Guid;
376 ULONG InstanceCount;
377 ULONG Flags;
378 } GUIDREGINFO, *PGUIDREGINFO;
379
380 typedef struct _CLASS_WMI_INFO {
381 ULONG GuidCount;
382 PGUIDREGINFO GuidRegInfo;
383 PCLASS_QUERY_WMI_REGINFO ClassQueryWmiRegInfo;
384 PCLASS_QUERY_WMI_DATABLOCK ClassQueryWmiDataBlock;
385 PCLASS_SET_WMI_DATABLOCK ClassSetWmiDataBlock;
386 PCLASS_SET_WMI_DATAITEM ClassSetWmiDataItem;
387 PCLASS_EXECUTE_WMI_METHOD ClassExecuteWmiMethod;
388 PCLASS_WMI_FUNCTION_CONTROL ClassWmiFunctionControl;
389 } CLASS_WMI_INFO, *PCLASS_WMI_INFO;
390
391 typedef struct _CLASS_DEV_INFO {
392 ULONG DeviceExtensionSize;
393 DEVICE_TYPE DeviceType;
394 UCHAR StackSize;
395 ULONG DeviceCharacteristics;
396 PCLASS_ERROR ClassError;
397 PCLASS_READ_WRITE ClassReadWriteVerification;
398 PCLASS_DEVICE_CONTROL ClassDeviceControl;
399 PCLASS_SHUTDOWN_FLUSH ClassShutdownFlush;
400 PCLASS_CREATE_CLOSE ClassCreateClose;
401 PCLASS_INIT_DEVICE ClassInitDevice;
402 PCLASS_START_DEVICE ClassStartDevice;
403 PCLASS_POWER_DEVICE ClassPowerDevice;
404 PCLASS_STOP_DEVICE ClassStopDevice;
405 PCLASS_REMOVE_DEVICE ClassRemoveDevice;
406 PCLASS_QUERY_PNP_CAPABILITIES ClassQueryPnpCapabilities;
407 CLASS_WMI_INFO ClassWmiInfo;
408 } CLASS_DEV_INFO, *PCLASS_DEV_INFO;
409
410 struct _CLASS_INIT_DATA {
411 ULONG InitializationDataSize;
412 CLASS_DEV_INFO FdoData;
413 CLASS_DEV_INFO PdoData;
414 PCLASS_ADD_DEVICE ClassAddDevice;
415 PCLASS_ENUM_DEVICE ClassEnumerateDevice;
416 PCLASS_QUERY_ID ClassQueryId;
417 PDRIVER_STARTIO ClassStartIo;
418 PCLASS_UNLOAD ClassUnload;
419 PCLASS_TICK ClassTick;
420 };
421
422 typedef struct _FILE_OBJECT_EXTENSION {
423 PFILE_OBJECT FileObject;
424 PDEVICE_OBJECT DeviceObject;
425 ULONG LockCount;
426 ULONG McnDisableCount;
427 } FILE_OBJECT_EXTENSION, *PFILE_OBJECT_EXTENSION;
428
429 typedef struct _CLASS_WORKING_SET {
430 ULONG Size;
431 ULONG XferPacketsWorkingSetMaximum;
432 ULONG XferPacketsWorkingSetMinimum;
433 } CLASS_WORKING_SET, *PCLASS_WORKING_SET;
434
435 typedef struct _CLASS_INTERPRET_SENSE_INFO2 {
436 ULONG Size;
437 ULONG HistoryCount;
438 PCLASS_COMPRESS_RETRY_HISTORY_DATA Compress;
439 PCLASS_INTERPRET_SENSE_INFO Interpret;
440 } CLASS_INTERPRET_SENSE_INFO2, *PCLASS_INTERPRET_SENSE_INFO2;
441
442 C_ASSERT((MAXULONG - sizeof(SRB_HISTORY)) / 30000 >= sizeof(SRB_HISTORY_ITEM));
443
444 typedef struct _CLASS_DRIVER_EXTENSION {
445 UNICODE_STRING RegistryPath;
446 CLASS_INIT_DATA InitData;
447 ULONG DeviceCount;
448 #if (NTDDI_VERSION >= NTDDI_WINXP)
449 PCLASS_QUERY_WMI_REGINFO_EX ClassFdoQueryWmiRegInfoEx;
450 PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx;
451 #endif
452 #if (NTDDI_VERSION >= NTDDI_VISTA)
453 REGHANDLE EtwHandle;
454 PDRIVER_DISPATCH DeviceMajorFunctionTable[IRP_MJ_MAXIMUM_FUNCTION + 1];
455 PDRIVER_DISPATCH MpDeviceMajorFunctionTable[IRP_MJ_MAXIMUM_FUNCTION + 1];
456 PCLASS_INTERPRET_SENSE_INFO2 InterpretSenseInfo;
457 PCLASS_WORKING_SET WorkingSet;
458 #endif
459 } CLASS_DRIVER_EXTENSION, *PCLASS_DRIVER_EXTENSION;
460
461 typedef struct _COMMON_DEVICE_EXTENSION {
462 ULONG Version;
463 PDEVICE_OBJECT DeviceObject;
464 PDEVICE_OBJECT LowerDeviceObject;
465 struct _FUNCTIONAL_DEVICE_EXTENSION *PartitionZeroExtension;
466 PCLASS_DRIVER_EXTENSION DriverExtension;
467 LONG RemoveLock;
468 KEVENT RemoveEvent;
469 KSPIN_LOCK RemoveTrackingSpinlock;
470 PVOID RemoveTrackingList;
471 LONG RemoveTrackingUntrackedCount;
472 PVOID DriverData;
473 _ANONYMOUS_STRUCT struct {
474 BOOLEAN IsFdo:1;
475 BOOLEAN IsInitialized:1;
476 BOOLEAN IsSrbLookasideListInitialized:1;
477 } DUMMYSTRUCTNAME;
478 UCHAR PreviousState;
479 UCHAR CurrentState;
480 ULONG IsRemoved;
481 UNICODE_STRING DeviceName;
482 struct _PHYSICAL_DEVICE_EXTENSION *ChildList;
483 ULONG PartitionNumber;
484 LARGE_INTEGER PartitionLength;
485 LARGE_INTEGER StartingOffset;
486 PCLASS_DEV_INFO DevInfo;
487 ULONG PagingPathCount;
488 ULONG DumpPathCount;
489 ULONG HibernationPathCount;
490 KEVENT PathCountEvent;
491 #ifndef ALLOCATE_SRB_FROM_POOL
492 NPAGED_LOOKASIDE_LIST SrbLookasideList;
493 #endif
494 UNICODE_STRING MountedDeviceInterfaceName;
495 ULONG GuidCount;
496 PGUIDREGINFO GuidRegInfo;
497 DICTIONARY FileObjectDictionary;
498 #if (NTDDI_VERSION >= NTDDI_WINXP)
499 PCLASS_PRIVATE_COMMON_DATA PrivateCommonData;
500 #else
501 ULONG_PTR Reserved1;
502 #endif
503 #if (NTDDI_VERSION >= NTDDI_VISTA)
504 PDRIVER_DISPATCH *DispatchTable;
505 #else
506 ULONG_PTR Reserved2;
507 #endif
508 ULONG_PTR Reserved3;
509 ULONG_PTR Reserved4;
510 } COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
511
512 typedef struct _PHYSICAL_DEVICE_EXTENSION {
513 _ANONYMOUS_UNION union {
514 _ANONYMOUS_STRUCT struct {
515 ULONG Version;
516 PDEVICE_OBJECT DeviceObject;
517 } DUMMYSTRUCTNAME;
518 COMMON_DEVICE_EXTENSION CommonExtension;
519 } DUMMYUNIONNAME;
520 BOOLEAN IsMissing;
521 BOOLEAN IsEnumerated;
522 #if (NTDDI_VERSION >= NTDDI_WINXP)
523 PCLASS_PRIVATE_PDO_DATA PrivatePdoData;
524 #else
525 ULONG_PTR Reserved1;
526 #endif
527 ULONG_PTR Reserved2;
528 ULONG_PTR Reserved3;
529 ULONG_PTR Reserved4;
530 } PHYSICAL_DEVICE_EXTENSION, *PPHYSICAL_DEVICE_EXTENSION;
531
532 struct _FAILURE_PREDICTION_INFO;
533 typedef struct _FAILURE_PREDICTION_INFO *PFAILURE_PREDICTION_INFO;
534
535 typedef struct _CLASS_POWER_OPTIONS {
536 ULONG PowerDown:1;
537 ULONG LockQueue:1;
538 ULONG HandleSpinDown:1;
539 ULONG HandleSpinUp:1;
540 ULONG Reserved:27;
541 } CLASS_POWER_OPTIONS, *PCLASS_POWER_OPTIONS;
542
543 typedef struct _CLASS_POWER_CONTEXT {
544 union {
545 CLASS_POWER_DOWN_STATE PowerDown;
546 CLASS_POWER_DOWN_STATE2 PowerDown2;
547 CLASS_POWER_UP_STATE PowerUp;
548 } PowerChangeState;
549 CLASS_POWER_OPTIONS Options;
550 BOOLEAN InUse;
551 BOOLEAN QueueLocked;
552 NTSTATUS FinalStatus;
553 ULONG RetryCount;
554 ULONG RetryInterval;
555 PIO_COMPLETION_ROUTINE CompletionRoutine;
556 PDEVICE_OBJECT DeviceObject;
557 PIRP Irp;
558 SCSI_REQUEST_BLOCK Srb;
559 } CLASS_POWER_CONTEXT, *PCLASS_POWER_CONTEXT;
560
561 typedef struct _COMPLETION_CONTEXT {
562 PDEVICE_OBJECT DeviceObject;
563 SCSI_REQUEST_BLOCK Srb;
564 } COMPLETION_CONTEXT, *PCOMPLETION_CONTEXT;
565
566 SCSIPORTAPI
567 ULONG
568 NTAPI
569 ClassInitialize(
570 PVOID Argument1,
571 PVOID Argument2,
572 PCLASS_INIT_DATA InitializationData);
573
574 typedef struct _CLASS_QUERY_WMI_REGINFO_EX_LIST {
575 ULONG Size;
576 PCLASS_QUERY_WMI_REGINFO_EX ClassFdoQueryWmiRegInfoEx;
577 PCLASS_QUERY_WMI_REGINFO_EX ClassPdoQueryWmiRegInfoEx;
578 } CLASS_QUERY_WMI_REGINFO_EX_LIST, *PCLASS_QUERY_WMI_REGINFO_EX_LIST;
579
580 SCSIPORTAPI
581 ULONG
582 NTAPI
583 ClassInitializeEx(
584 PDRIVER_OBJECT DriverObject,
585 LPGUID Guid,
586 PVOID Data);
587
588 SCSIPORTAPI
589 NTSTATUS
590 NTAPI
591 ClassCreateDeviceObject(
592 PDRIVER_OBJECT DriverObject,
593 PCCHAR ObjectNameBuffer,
594 PDEVICE_OBJECT LowerDeviceObject,
595 BOOLEAN IsFdo,
596 PDEVICE_OBJECT *DeviceObject);
597
598 SCSIPORTAPI
599 NTSTATUS
600 NTAPI
601 ClassReadDriveCapacity(
602 PDEVICE_OBJECT DeviceObject);
603
604 SCSIPORTAPI
605 VOID
606 NTAPI
607 ClassReleaseQueue(
608 PDEVICE_OBJECT DeviceObject);
609
610 SCSIPORTAPI
611 VOID
612 NTAPI
613 ClassSplitRequest(
614 PDEVICE_OBJECT DeviceObject,
615 PIRP Irp,
616 ULONG MaximumBytes);
617
618 SCSIPORTAPI
619 NTSTATUS
620 NTAPI
621 ClassDeviceControl(
622 PDEVICE_OBJECT DeviceObject,
623 PIRP Irp);
624
625 SCSIPORTAPI
626 BOOLEAN
627 NTAPI
628 ClassInterpretSenseInfo(
629 PDEVICE_OBJECT DeviceObject,
630 PSCSI_REQUEST_BLOCK Srb,
631 UCHAR MajorFunctionCode,
632 ULONG IoDeviceCode,
633 ULONG RetryCount,
634 NTSTATUS *Status,
635 ULONG *RetryInterval);
636
637 VOID
638 NTAPI
639 ClassSendDeviceIoControlSynchronous(
640 ULONG IoControlCode,
641 PDEVICE_OBJECT TargetDeviceObject,
642 PVOID Buffer,
643 ULONG InputBufferLength,
644 ULONG OutputBufferLength,
645 BOOLEAN InternalDeviceIoControl,
646 PIO_STATUS_BLOCK IoStatus);
647
648 SCSIPORTAPI
649 NTSTATUS
650 NTAPI
651 ClassSendIrpSynchronous(
652 PDEVICE_OBJECT TargetDeviceObject,
653 PIRP Irp);
654
655 SCSIPORTAPI
656 NTSTATUS
657 NTAPI
658 ClassForwardIrpSynchronous(
659 PCOMMON_DEVICE_EXTENSION CommonExtension,
660 PIRP Irp);
661
662 SCSIPORTAPI
663 NTSTATUS
664 NTAPI
665 ClassSendSrbSynchronous(
666 PDEVICE_OBJECT DeviceObject,
667 PSCSI_REQUEST_BLOCK Srb,
668 PVOID BufferAddress,
669 ULONG BufferLength,
670 BOOLEAN WriteToDevice);
671
672 SCSIPORTAPI
673 NTSTATUS
674 NTAPI
675 ClassSendSrbAsynchronous(
676 PDEVICE_OBJECT DeviceObject,
677 PSCSI_REQUEST_BLOCK Srb,
678 PIRP Irp,
679 PVOID BufferAddress,
680 ULONG BufferLength,
681 BOOLEAN WriteToDevice);
682
683 SCSIPORTAPI
684 NTSTATUS
685 NTAPI
686 ClassBuildRequest(
687 PDEVICE_OBJECT DeviceObject,
688 PIRP Irp);
689
690 SCSIPORTAPI
691 ULONG
692 NTAPI
693 ClassModeSense(
694 PDEVICE_OBJECT DeviceObject,
695 PCHAR ModeSenseBuffer,
696 ULONG Length,
697 UCHAR PageMode);
698
699 SCSIPORTAPI
700 PVOID
701 NTAPI
702 ClassFindModePage(
703 PCHAR ModeSenseBuffer,
704 ULONG Length,
705 UCHAR PageMode,
706 BOOLEAN Use6Byte);
707
708 SCSIPORTAPI
709 NTSTATUS
710 NTAPI
711 ClassClaimDevice(
712 PDEVICE_OBJECT LowerDeviceObject,
713 BOOLEAN Release);
714
715 SCSIPORTAPI
716 VOID
717 NTAPI
718 ClassInitializeSrbLookasideList(
719 PCOMMON_DEVICE_EXTENSION CommonExtension,
720 ULONG NumberElements);
721
722 SCSIPORTAPI
723 VOID
724 NTAPI
725 ClassDeleteSrbLookasideList(
726 PCOMMON_DEVICE_EXTENSION CommonExtension);
727
728 SCSIPORTAPI
729 ULONG
730 NTAPI
731 ClassQueryTimeOutRegistryValue(
732 PDEVICE_OBJECT DeviceObject);
733
734 SCSIPORTAPI
735 NTSTATUS
736 NTAPI
737 ClassGetDescriptor(
738 PDEVICE_OBJECT DeviceObject,
739 PSTORAGE_PROPERTY_ID PropertyId,
740 PVOID *Descriptor);
741
742 SCSIPORTAPI
743 VOID
744 NTAPI
745 ClassInvalidateBusRelations(
746 PDEVICE_OBJECT Fdo);
747
748 SCSIPORTAPI
749 VOID
750 NTAPI
751 ClassMarkChildrenMissing(
752 PFUNCTIONAL_DEVICE_EXTENSION Fdo);
753
754 SCSIPORTAPI
755 BOOLEAN
756 NTAPI
757 ClassMarkChildMissing(
758 PPHYSICAL_DEVICE_EXTENSION PdoExtension,
759 BOOLEAN AcquireChildLock);
760
761 SCSIPORTAPI
762 VOID
763 NTAPI
764 ClassDebugPrint(
765 CLASS_DEBUG_LEVEL DebugPrintLevel,
766 PCCHAR DebugMessage,
767 ...);
768
769 SCSIPORTAPI
770 PCLASS_DRIVER_EXTENSION
771 NTAPI
772 ClassGetDriverExtension(
773 PDRIVER_OBJECT DriverObject);
774
775 SCSIPORTAPI
776 VOID
777 NTAPI
778 ClassCompleteRequest(
779 PDEVICE_OBJECT DeviceObject,
780 PIRP Irp,
781 CCHAR PriorityBoost);
782
783 SCSIPORTAPI
784 VOID
785 NTAPI
786 ClassReleaseRemoveLock(
787 PDEVICE_OBJECT DeviceObject,
788 PIRP Tag);
789
790 SCSIPORTAPI
791 ULONG
792 NTAPI
793 ClassAcquireRemoveLockEx(
794 PDEVICE_OBJECT DeviceObject,
795 PVOID Tag,
796 PCSTR File,
797 ULONG Line);
798
799 SCSIPORTAPI
800 VOID
801 NTAPI
802 ClassUpdateInformationInRegistry(
803 PDEVICE_OBJECT Fdo,
804 PCHAR DeviceName,
805 ULONG DeviceNumber,
806 PINQUIRYDATA InquiryData,
807 ULONG InquiryDataLength);
808
809 SCSIPORTAPI
810 NTSTATUS
811 NTAPI
812 ClassWmiCompleteRequest(
813 PDEVICE_OBJECT DeviceObject,
814 PIRP Irp,
815 NTSTATUS Status,
816 ULONG BufferUsed,
817 CCHAR PriorityBoost);
818
819 SCSIPORTAPI
820 NTSTATUS
821 NTAPI
822 ClassWmiFireEvent(
823 PDEVICE_OBJECT DeviceObject,
824 LPGUID Guid,
825 ULONG InstanceIndex,
826 ULONG EventDataSize,
827 PVOID EventData);
828
829 SCSIPORTAPI
830 VOID
831 NTAPI
832 ClassResetMediaChangeTimer(
833 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
834
835 SCSIPORTAPI
836 VOID
837 NTAPI
838 ClassInitializeMediaChangeDetection(
839 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
840 PUCHAR EventPrefix);
841
842 SCSIPORTAPI
843 NTSTATUS
844 NTAPI
845 ClassInitializeTestUnitPolling(
846 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
847 BOOLEAN AllowDriveToSleep);
848
849 SCSIPORTAPI
850 PVPB
851 NTAPI
852 ClassGetVpb(
853 PDEVICE_OBJECT DeviceObject);
854
855 SCSIPORTAPI
856 NTSTATUS
857 NTAPI
858 ClassSpinDownPowerHandler(
859 PDEVICE_OBJECT DeviceObject,
860 PIRP Irp);
861
862 NTSTATUS
863 NTAPI
864 ClassStopUnitPowerHandler(
865 PDEVICE_OBJECT DeviceObject,
866 PIRP Irp);
867
868 NTSTATUS
869 NTAPI
870 ClassSetFailurePredictionPoll(
871 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
872 FAILURE_PREDICTION_METHOD FailurePredictionMethod,
873 ULONG PollingPeriod);
874
875 VOID
876 NTAPI
877 ClassNotifyFailurePredicted(
878 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
879 PUCHAR Buffer,
880 ULONG BufferSize,
881 BOOLEAN LogError,
882 ULONG UniqueErrorValue,
883 UCHAR PathId,
884 UCHAR TargetId,
885 UCHAR Lun);
886
887 SCSIPORTAPI
888 VOID
889 NTAPI
890 ClassAcquireChildLock(
891 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
892
893 SCSIPORTAPI
894 VOID
895 NTAPI
896 ClassReleaseChildLock(
897 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
898
899 VOID
900 NTAPI
901 ClassSendStartUnit(
902 PDEVICE_OBJECT DeviceObject);
903
904 SCSIPORTAPI
905 NTSTATUS
906 NTAPI
907 ClassRemoveDevice(
908 PDEVICE_OBJECT DeviceObject,
909 UCHAR RemoveType);
910
911 SCSIPORTAPI
912 VOID
913 NTAPI
914 ClassCheckMediaState(
915 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
916
917 SCSIPORTAPI
918 VOID
919 NTAPI
920 ClassSetMediaChangeState(
921 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
922 MEDIA_CHANGE_DETECTION_STATE State,
923 BOOLEAN Wait);
924
925 SCSIPORTAPI
926 VOID
927 NTAPI
928 ClassEnableMediaChangeDetection(
929 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
930
931 SCSIPORTAPI
932 VOID
933 NTAPI
934 ClassDisableMediaChangeDetection(
935 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
936
937 SCSIPORTAPI
938 VOID
939 NTAPI
940 ClassCleanupMediaChangeDetection(
941 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
942
943 VOID
944 NTAPI
945 ClassGetDeviceParameter(
946 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
947 PWSTR SubkeyName,
948 PWSTR ParameterName,
949 PULONG ParameterValue);
950
951 NTSTATUS
952 NTAPI
953 ClassSetDeviceParameter(
954 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
955 PWSTR SubkeyName,
956 PWSTR ParameterName,
957 ULONG ParameterValue);
958
959 #if (NTDDI_VERSION >= NTDDI_VISTA)
960
961 PFILE_OBJECT_EXTENSION
962 NTAPI
963 ClassGetFsContext(
964 PCOMMON_DEVICE_EXTENSION CommonExtension,
965 PFILE_OBJECT FileObject);
966
967 VOID
968 NTAPI
969 ClassSendNotification(
970 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
971 const GUID *Guid,
972 ULONG ExtraDataSize,
973 PVOID ExtraData);
974
975 #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
976
977 static __inline
978 BOOLEAN
979 PORT_ALLOCATED_SENSE(
980 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
981 PSCSI_REQUEST_BLOCK Srb)
982 {
983 return ((BOOLEAN)((TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE) &&
984 TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER)) &&
985 (Srb->SenseInfoBuffer != FdoExtension->SenseData)));
986 }
987
988 static __inline
989 VOID
990 FREE_PORT_ALLOCATED_SENSE_BUFFER(
991 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
992 PSCSI_REQUEST_BLOCK Srb)
993 {
994 ASSERT(TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
995 ASSERT(TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
996 ASSERT(Srb->SenseInfoBuffer != FdoExtension->SenseData);
997
998 ExFreePool(Srb->SenseInfoBuffer);
999 Srb->SenseInfoBuffer = FdoExtension->SenseData;
1000 Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
1001 CLEAR_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER);
1002 return;
1003 }
1004
1005 typedef VOID
1006 (NTAPI *PCLASS_SCAN_FOR_SPECIAL_HANDLER)(
1007 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1008 ULONG_PTR Data);
1009
1010 VOID
1011 NTAPI
1012 ClassScanForSpecial(
1013 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
1014 CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[],
1015 PCLASS_SCAN_FOR_SPECIAL_HANDLER Function);