Sync with trunk r58033.
[reactos.git] / drivers / storage / classpnp / classp.h
1 /*++
2
3 Copyright (C) Microsoft Corporation, 1991 - 1999
4
5 Module Name:
6
7 classp.h
8
9 Abstract:
10
11 Private header file for classpnp.sys modules. This contains private
12 structure and function declarations as well as constant values which do
13 not need to be exported.
14
15 Author:
16
17 Environment:
18
19 kernel mode only
20
21 Notes:
22
23
24 Revision History:
25
26 --*/
27
28 #include <stddef.h>
29 #include <stdarg.h>
30 #include <ntddk.h>
31
32 #include <scsi.h>
33 #include <wmidata.h>
34 #include <classpnp.h>
35
36 #if CLASS_INIT_GUID
37 #include <initguid.h>
38 #endif
39
40 #include <mountdev.h>
41 #include <ioevent.h>
42 #include <pseh/pseh2.h>
43
44 #include "wmistr.h"
45
46 extern CLASSPNP_SCAN_FOR_SPECIAL_INFO ClassBadItems[];
47
48 extern GUID ClassGuidQueryRegInfoEx;
49
50
51 #define CLASSP_REG_SUBKEY_NAME (L"Classpnp")
52
53 #define CLASSP_REG_HACK_VALUE_NAME (L"HackMask")
54 #define CLASSP_REG_MMC_DETECTION_VALUE_NAME (L"MMCDetectionState")
55 #define CLASSP_REG_WRITE_CACHE_VALUE_NAME (L"WriteCacheEnableOverride")
56 #define CLASSP_REG_PERF_RESTORE_VALUE_NAME (L"RestorePerfAtCount")
57 #define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME (L"UserRemovalPolicy")
58
59 #define CLASS_PERF_RESTORE_MINIMUM (0x10)
60 #define CLASS_ERROR_LEVEL_1 (0x4)
61 #define CLASS_ERROR_LEVEL_2 (0x8)
62
63 #define FDO_HACK_CANNOT_LOCK_MEDIA (0x00000001)
64 #define FDO_HACK_GESN_IS_BAD (0x00000002)
65 #define FDO_HACK_NO_SYNC_CACHE (0x00000004)
66
67 #define FDO_HACK_VALID_FLAGS (0x00000007)
68 #define FDO_HACK_INVALID_FLAGS (~FDO_HACK_VALID_FLAGS)
69
70 /*
71 * Lots of retries of synchronized SCSI commands that devices may not
72 * even support really slows down the system (especially while booting).
73 * (Even GetDriveCapacity may be failed on purpose if an external disk is powered off).
74 * If a disk cannot return a small initialization buffer at startup
75 * in two attempts (with delay interval) then we cannot expect it to return
76 * data consistently with four retries.
77 * So don't set the retry counts as high here as for data SRBs.
78 *
79 * If we find that these requests are failing consecutively,
80 * despite the retry interval, on otherwise reliable media,
81 * then we should either increase the retry interval for
82 * that failure or (by all means) increase these retry counts as appropriate.
83 */
84 #define NUM_LOCKMEDIAREMOVAL_RETRIES 1
85 #define NUM_MODESENSE_RETRIES 1
86 #define NUM_DRIVECAPACITY_RETRIES 1
87
88
89 #define CLASS_FILE_OBJECT_EXTENSION_KEY 'eteP'
90 #define CLASSP_VOLUME_VERIFY_CHECKED 0x34
91
92 #define CLASS_TAG_PRIVATE_DATA 'CPcS'
93 #define CLASS_TAG_PRIVATE_DATA_FDO 'FPcS'
94 #define CLASS_TAG_PRIVATE_DATA_PDO 'PPcS'
95
96 struct _MEDIA_CHANGE_DETECTION_INFO {
97
98 //
99 // Mutex to synchronize enable/disable requests and media state changes
100 //
101
102 KMUTEX MediaChangeMutex;
103
104 //
105 // The current state of the media (present, not present, unknown)
106 // protected by MediaChangeSynchronizationEvent
107 //
108
109 MEDIA_CHANGE_DETECTION_STATE MediaChangeDetectionState;
110
111 //
112 // This is a count of how many time MCD has been disabled. if it is
113 // set to zero, then we'll poll the device for MCN events with the
114 // then-current method (ie. TEST UNIT READY or GESN). this is
115 // protected by MediaChangeMutex
116 //
117
118 LONG MediaChangeDetectionDisableCount;
119
120
121 //
122 // The timer value to support media change events. This is a countdown
123 // value used to determine when to poll the device for a media change.
124 // The max value for the timer is 255 seconds. This is not protected
125 // by an event -- simply InterlockedExchanged() as needed.
126 //
127
128 LONG MediaChangeCountDown;
129
130 //
131 // recent changes allowed instant retries of the MCN irp. Since this
132 // could cause an infinite loop, keep a count of how many times we've
133 // retried immediately so that we can catch if the count exceeds an
134 // arbitrary limit.
135 //
136
137 LONG MediaChangeRetryCount;
138
139 //
140 // use GESN if it's available
141 //
142
143 struct {
144 BOOLEAN Supported;
145 BOOLEAN HackEventMask;
146 UCHAR EventMask;
147 UCHAR NoChangeEventMask;
148 PUCHAR Buffer;
149 PMDL Mdl;
150 ULONG BufferSize;
151 } Gesn;
152
153 //
154 // If this value is one, then the irp is currently in use.
155 // If this value is zero, then the irp is available.
156 // Use InterlockedCompareExchange() to set from "available" to "in use".
157 // ASSERT that InterlockedCompareExchange() showed previous value of
158 // "in use" when changing back to "available" state.
159 // This also implicitly protects the MediaChangeSrb and SenseBuffer
160 //
161
162 LONG MediaChangeIrpInUse;
163
164 //
165 // Pointer to the irp to be used for media change detection.
166 // protected by Interlocked MediaChangeIrpInUse
167 //
168
169 PIRP MediaChangeIrp;
170
171 //
172 // The srb for the media change detection.
173 // protected by Interlocked MediaChangeIrpInUse
174 //
175
176 SCSI_REQUEST_BLOCK MediaChangeSrb;
177 PUCHAR SenseBuffer;
178 ULONG SrbFlags;
179
180 //
181 // Second timer to keep track of how long the media change IRP has been
182 // in use. If this value exceeds the timeout (#defined) then we should
183 // print out a message to the user and set the MediaChangeIrpLost flag
184 // protected by using Interlocked() operations in ClasspSendMediaStateIrp,
185 // the only routine which should modify this value.
186 //
187
188 LONG MediaChangeIrpTimeInUse;
189
190 //
191 // Set by CdRomTickHandler when we determine that the media change irp has
192 // been lost
193 //
194
195 BOOLEAN MediaChangeIrpLost;
196
197 };
198
199 typedef enum {
200 SimpleMediaLock,
201 SecureMediaLock,
202 InternalMediaLock
203 } MEDIA_LOCK_TYPE, *PMEDIA_LOCK_TYPE;
204
205 typedef struct _FAILURE_PREDICTION_INFO {
206 FAILURE_PREDICTION_METHOD Method;
207 ULONG CountDown; // Countdown timer
208 ULONG Period; // Countdown period
209
210 PIO_WORKITEM WorkQueueItem;
211
212 KEVENT Event;
213 } FAILURE_PREDICTION_INFO, *PFAILURE_PREDICTION_INFO;
214
215
216
217 //
218 // This struct must always fit within four PVOIDs of info,
219 // as it uses the irp's "PVOID DriverContext[4]" to store
220 // this info
221 //
222 typedef struct _CLASS_RETRY_INFO {
223 struct _CLASS_RETRY_INFO *Next;
224 } CLASS_RETRY_INFO, *PCLASS_RETRY_INFO;
225
226
227
228 typedef struct _CSCAN_LIST {
229
230 //
231 // The current block which has an outstanding request.
232 //
233
234 ULONGLONG BlockNumber;
235
236 //
237 // The list of blocks past the CurrentBlock to which we're going to do
238 // i/o. This list is maintained in sorted order.
239 //
240
241 LIST_ENTRY CurrentSweep;
242
243 //
244 // The list of blocks behind the current block for which we'll have to
245 // wait until the next scan across the disk. This is kept as a stack,
246 // the cost of sorting it is taken when it's moved over to be the
247 // running list.
248 //
249
250 LIST_ENTRY NextSweep;
251
252 } CSCAN_LIST, *PCSCAN_LIST;
253
254 //
255 // add to the front of this structure to help prevent illegal
256 // snooping by other utilities.
257 //
258
259
260
261 typedef enum _CLASS_DETECTION_STATE {
262 ClassDetectionUnknown = 0,
263 ClassDetectionUnsupported = 1,
264 ClassDetectionSupported = 2
265 } CLASS_DETECTION_STATE, *PCLASS_DETECTION_STATE;
266
267
268 typedef struct _CLASS_ERROR_LOG_DATA {
269 LARGE_INTEGER TickCount; // Offset 0x00
270 ULONG PortNumber; // Offset 0x08
271
272 UCHAR ErrorPaging : 1; // Offset 0x0c
273 UCHAR ErrorRetried : 1;
274 UCHAR ErrorUnhandled : 1;
275 UCHAR ErrorReserved : 5;
276
277 UCHAR Reserved[3];
278
279 SCSI_REQUEST_BLOCK Srb; // Offset 0x10
280
281 /*
282 * We define the SenseData as the default length.
283 * Since the sense data returned by the port driver may be longer,
284 * SenseData must be at the end of this structure.
285 * For our internal error log, we only log the default length.
286 */
287 SENSE_DATA SenseData; // Offset 0x50 for x86 (or 0x68 for ia64) (ULONG32 Alignment required!)
288 } CLASS_ERROR_LOG_DATA, *PCLASS_ERROR_LOG_DATA;
289
290 #define NUM_ERROR_LOG_ENTRIES 16
291
292
293
294 typedef struct _TRANSFER_PACKET {
295
296 LIST_ENTRY AllPktsListEntry; // entry in fdoData's static AllTransferPacketsList
297 SINGLE_LIST_ENTRY SlistEntry; // for when in free list (use fast slist)
298
299 PIRP Irp;
300 PDEVICE_OBJECT Fdo;
301
302 /*
303 * This is the client IRP that this TRANSFER_PACKET is currently
304 * servicing.
305 */
306 PIRP OriginalIrp;
307 BOOLEAN CompleteOriginalIrpWhenLastPacketCompletes;
308
309 /*
310 * Stuff for retrying the transfer.
311 */
312 ULONG NumRetries;
313 KTIMER RetryTimer;
314 KDPC RetryTimerDPC;
315 ULONG RetryIntervalSec;
316
317 /*
318 * Event for synchronizing the transfer (optional).
319 * (Note that we can't have the event in the packet itself because
320 * by the time a thread waits on an event the packet may have
321 * been completed and re-issued.
322 */
323 PKEVENT SyncEventPtr;
324
325 /*
326 * Stuff for retrying during extreme low-memory stress
327 * (when we retry 1 page at a time).
328 */
329 BOOLEAN InLowMemRetry;
330 PUCHAR LowMemRetry_remainingBufPtr;
331 ULONG LowMemRetry_remainingBufLen;
332 LARGE_INTEGER LowMemRetry_nextChunkTargetLocation;
333
334 /*
335 * Fields used for cancelling the packet.
336 */
337 // BOOLEAN Cancelled;
338 // KEVENT CancelledEvent;
339
340 /*
341 * We keep the buffer and length values here as well
342 * as in the SRB because some miniports return
343 * the transferred length in SRB.DataTransferLength,
344 * and if the SRB failed we need that value again for the retry.
345 * We don't trust the lower stack to preserve any of these values in the SRB.
346 */
347 PUCHAR BufPtrCopy;
348 ULONG BufLenCopy;
349 LARGE_INTEGER TargetLocationCopy;
350
351 /*
352 * This is a standard SCSI structure that receives a detailed
353 * report about a SCSI error on the hardware.
354 */
355 SENSE_DATA SrbErrorSenseData;
356
357 /*
358 * This is the SRB block for this TRANSFER_PACKET.
359 * For IOCTLs, the SRB block includes two DWORDs for
360 * device object and ioctl code; so these must
361 * immediately follow the SRB block.
362 */
363 SCSI_REQUEST_BLOCK Srb;
364 // ULONG SrbIoctlDevObj; // not handling ioctls yet
365 // ULONG SrbIoctlCode;
366
367 } TRANSFER_PACKET, *PTRANSFER_PACKET;
368
369 /*
370 * MIN_INITIAL_TRANSFER_PACKETS is the minimum number of packets that
371 * we preallocate at startup for each device (we need at least one packet
372 * to guarantee forward progress during memory stress).
373 * MIN_WORKINGSET_TRANSFER_PACKETS is the number of TRANSFER_PACKETs
374 * we allow to build up and remain for each device;
375 * we _lazily_ work down to this number when they're not needed.
376 * MAX_WORKINGSET_TRANSFER_PACKETS is the number of TRANSFER_PACKETs
377 * that we _immediately_ reduce to when they are not needed.
378 *
379 * The absolute maximum number of packets that we will allocate is
380 * whatever is required by the current activity, up to the memory limit;
381 * as soon as stress ends, we snap down to MAX_WORKINGSET_TRANSFER_PACKETS;
382 * we then lazily work down to MIN_WORKINGSET_TRANSFER_PACKETS.
383 */
384 #define MIN_INITIAL_TRANSFER_PACKETS 1
385 #define MIN_WORKINGSET_TRANSFER_PACKETS_Consumer 4
386 #define MAX_WORKINGSET_TRANSFER_PACKETS_Consumer 64
387 #define MIN_WORKINGSET_TRANSFER_PACKETS_Server 64
388 #define MAX_WORKINGSET_TRANSFER_PACKETS_Server 1024
389 #define MIN_WORKINGSET_TRANSFER_PACKETS_Enterprise 256
390 #define MAX_WORKINGSET_TRANSFER_PACKETS_Enterprise 2048
391
392
393 //
394 // add to the front of this structure to help prevent illegal
395 // snooping by other utilities.
396 //
397 struct _CLASS_PRIVATE_FDO_DATA {
398
399 //
400 // this private structure allows us to
401 // dynamically re-enable the perf benefits
402 // lost due to transient error conditions.
403 // in w2k, a reboot was required. :(
404 //
405 struct {
406 ULONG OriginalSrbFlags;
407 ULONG SuccessfulIO;
408 ULONG ReEnableThreshhold; // 0 means never
409 } Perf;
410
411 ULONG_PTR HackFlags;
412
413 STORAGE_HOTPLUG_INFO HotplugInfo;
414
415 // Legacy. Still used by obsolete legacy code.
416 struct {
417 LARGE_INTEGER Delta; // in ticks
418 LARGE_INTEGER Tick; // when it should fire
419 PCLASS_RETRY_INFO ListHead; // singly-linked list
420 ULONG Granularity; // static
421 KSPIN_LOCK Lock; // protective spin lock
422 KDPC Dpc; // DPC routine object
423 KTIMER Timer; // timer to fire DPC
424 } Retry;
425
426 BOOLEAN TimerStarted;
427 BOOLEAN LoggedTURFailureSinceLastIO;
428
429 //
430 // privately allocated release queue irp
431 // protected by fdoExtension->ReleaseQueueSpinLock
432 //
433 BOOLEAN ReleaseQueueIrpAllocated;
434 PIRP ReleaseQueueIrp;
435
436 /*
437 * Queues for TRANSFER_PACKETs that contextualize the IRPs and SRBs
438 * that we send down to the port driver.
439 * (The free list is an slist so that we can use fast
440 * interlocked operations on it; but the relatively-static
441 * AllTransferPacketsList list has to be
442 * a doubly-linked list since we have to dequeue from the middle).
443 */
444 LIST_ENTRY AllTransferPacketsList;
445 SLIST_HEADER FreeTransferPacketsList;
446 ULONG NumFreeTransferPackets;
447 ULONG NumTotalTransferPackets;
448 ULONG DbgPeakNumTransferPackets;
449
450 /*
451 * Queue for deferred client irps
452 */
453 LIST_ENTRY DeferredClientIrpList;
454
455 /*
456 * Precomputed maximum transfer length for the hardware.
457 */
458 ULONG HwMaxXferLen;
459
460 /*
461 * SCSI_REQUEST_BLOCK template preconfigured with the constant values.
462 * This is slapped into the SRB in the TRANSFER_PACKET for each transfer.
463 */
464 SCSI_REQUEST_BLOCK SrbTemplate;
465
466 KSPIN_LOCK SpinLock;
467
468 /*
469 * Circular array of timestamped logs of errors that occurred on this device.
470 */
471 ULONG ErrorLogNextIndex;
472 CLASS_ERROR_LOG_DATA ErrorLogs[NUM_ERROR_LOG_ENTRIES];
473
474 };
475
476
477 #define MIN(a, b) ((a) < (b) ? (a) : (b))
478 #define MAX(a, b) ((a) > (b) ? (a) : (b))
479
480
481 #define NOT_READY_RETRY_INTERVAL 10
482 #define MINIMUM_RETRY_UNITS ((LONGLONG)32)
483
484
485 /*
486 * Simple singly-linked-list queuing macros, with no synchronization.
487 */
488 static inline VOID SimpleInitSlistHdr(SINGLE_LIST_ENTRY *SListHdr)
489 {
490 SListHdr->Next = NULL;
491 }
492 static inline VOID SimplePushSlist(SINGLE_LIST_ENTRY *SListHdr, SINGLE_LIST_ENTRY *SListEntry)
493 {
494 SListEntry->Next = SListHdr->Next;
495 SListHdr->Next = SListEntry;
496 }
497 static inline SINGLE_LIST_ENTRY *SimplePopSlist(SINGLE_LIST_ENTRY *SListHdr)
498 {
499 SINGLE_LIST_ENTRY *sListEntry = SListHdr->Next;
500 if (sListEntry){
501 SListHdr->Next = sListEntry->Next;
502 sListEntry->Next = NULL;
503 }
504 return sListEntry;
505 }
506 static inline BOOLEAN SimpleIsSlistEmpty(SINGLE_LIST_ENTRY *SListHdr)
507 {
508 return (SListHdr->Next == NULL);
509 }
510
511 NTSTATUS
512 NTAPI
513 DriverEntry(
514 IN PDRIVER_OBJECT DriverObject,
515 IN PUNICODE_STRING RegistryPath
516 );
517
518 VOID
519 NTAPI
520 ClassUnload(
521 IN PDRIVER_OBJECT DriverObject
522 );
523
524 NTSTATUS
525 NTAPI
526 ClassCreateClose(
527 IN PDEVICE_OBJECT DeviceObject,
528 IN PIRP Irp
529 );
530
531 NTSTATUS
532 NTAPI
533 ClasspCreateClose(
534 IN PDEVICE_OBJECT DeviceObject,
535 IN PIRP Irp
536 );
537
538 VOID
539 NTAPI
540 ClasspCleanupProtectedLocks(
541 IN PFILE_OBJECT_EXTENSION FsContext
542 );
543
544 NTSTATUS
545 NTAPI
546 ClasspEjectionControl(
547 IN PDEVICE_OBJECT Fdo,
548 IN PIRP Irp,
549 IN MEDIA_LOCK_TYPE LockType,
550 IN BOOLEAN Lock
551 );
552
553 NTSTATUS
554 NTAPI
555 ClassReadWrite(
556 IN PDEVICE_OBJECT DeviceObject,
557 IN PIRP Irp
558 );
559
560 NTSTATUS
561 NTAPI
562 ClassDeviceControlDispatch(
563 PDEVICE_OBJECT DeviceObject,
564 PIRP Irp
565 );
566
567 NTSTATUS
568 NTAPI
569 ClassDispatchPnp(
570 PDEVICE_OBJECT DeviceObject,
571 PIRP Irp
572 );
573
574 NTSTATUS
575 NTAPI
576 ClassPnpStartDevice(
577 IN PDEVICE_OBJECT DeviceObject
578 );
579
580 NTSTATUS
581 NTAPI
582 ClassShutdownFlush(
583 IN PDEVICE_OBJECT DeviceObject,
584 IN PIRP Irp
585 );
586
587 NTSTATUS
588 NTAPI
589 ClassSystemControl(
590 IN PDEVICE_OBJECT DeviceObject,
591 IN PIRP Irp
592 );
593
594 //
595 // Class internal routines
596 //
597
598 NTSTATUS
599 NTAPI
600 ClassAddDevice(
601 IN PDRIVER_OBJECT DriverObject,
602 IN OUT PDEVICE_OBJECT PhysicalDeviceObject
603 );
604
605 NTSTATUS
606 NTAPI
607 ClasspSendSynchronousCompletion(
608 IN PDEVICE_OBJECT DeviceObject,
609 IN PIRP Irp,
610 IN PVOID Context
611 );
612
613 VOID
614 NTAPI
615 RetryRequest(
616 PDEVICE_OBJECT DeviceObject,
617 PIRP Irp,
618 PSCSI_REQUEST_BLOCK Srb,
619 BOOLEAN Associated,
620 ULONG RetryInterval
621 );
622
623 NTSTATUS
624 NTAPI
625 ClassIoCompletion(
626 IN PDEVICE_OBJECT DeviceObject,
627 IN PIRP Irp,
628 IN PVOID Context
629 );
630
631 NTSTATUS
632 NTAPI
633 ClassPnpQueryFdoRelations(
634 IN PDEVICE_OBJECT Fdo,
635 IN PIRP Irp
636 );
637
638 NTSTATUS
639 NTAPI
640 ClassRetrieveDeviceRelations(
641 IN PDEVICE_OBJECT Fdo,
642 IN DEVICE_RELATION_TYPE RelationType,
643 OUT PDEVICE_RELATIONS *DeviceRelations
644 );
645
646 NTSTATUS
647 NTAPI
648 ClassGetPdoId(
649 IN PDEVICE_OBJECT Pdo,
650 IN BUS_QUERY_ID_TYPE IdType,
651 IN PUNICODE_STRING IdString
652 );
653
654 NTSTATUS
655 NTAPI
656 ClassQueryPnpCapabilities(
657 IN PDEVICE_OBJECT PhysicalDeviceObject,
658 IN PDEVICE_CAPABILITIES Capabilities
659 );
660
661 VOID
662 NTAPI
663 ClasspStartIo(
664 IN PDEVICE_OBJECT DeviceObject,
665 IN PIRP Irp
666 );
667
668 NTSTATUS
669 NTAPI
670 ClasspPagingNotificationCompletion(
671 IN PDEVICE_OBJECT DeviceObject,
672 IN PIRP Irp,
673 IN PDEVICE_OBJECT RealDeviceObject
674 );
675
676 NTSTATUS
677 NTAPI
678 ClasspMediaChangeCompletion(
679 PDEVICE_OBJECT DeviceObject,
680 PIRP Irp,
681 PVOID Context
682 );
683
684 PFILE_OBJECT_EXTENSION
685 NTAPI
686 ClasspGetFsContext(
687 IN PCOMMON_DEVICE_EXTENSION CommonExtension,
688 IN PFILE_OBJECT FileObject
689 );
690
691 NTSTATUS
692 NTAPI
693 ClasspMcnControl(
694 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
695 IN PIRP Irp,
696 IN PSCSI_REQUEST_BLOCK Srb
697 );
698
699 VOID
700 NTAPI
701 ClasspRegisterMountedDeviceInterface(
702 IN PDEVICE_OBJECT DeviceObject
703 );
704
705 NTSTATUS
706 NTAPI
707 ClasspDisableTimer(
708 PDEVICE_OBJECT DeviceObject
709 );
710
711 NTSTATUS
712 NTAPI
713 ClasspEnableTimer(
714 PDEVICE_OBJECT DeviceObject
715 );
716
717 //
718 // routines for dictionary list support
719 //
720
721 VOID
722 NTAPI
723 InitializeDictionary(
724 IN PDICTIONARY Dictionary
725 );
726
727 BOOLEAN
728 NTAPI
729 TestDictionarySignature(
730 IN PDICTIONARY Dictionary
731 );
732
733 NTSTATUS
734 NTAPI
735 AllocateDictionaryEntry(
736 IN PDICTIONARY Dictionary,
737 IN ULONGLONG Key,
738 IN ULONG Size,
739 IN ULONG Tag,
740 OUT PVOID *Entry
741 );
742
743 PVOID
744 NTAPI
745 GetDictionaryEntry(
746 IN PDICTIONARY Dictionary,
747 IN ULONGLONG Key
748 );
749
750 VOID
751 NTAPI
752 FreeDictionaryEntry(
753 IN PDICTIONARY Dictionary,
754 IN PVOID Entry
755 );
756
757
758 NTSTATUS
759 NTAPI
760 ClasspAllocateReleaseRequest(
761 IN PDEVICE_OBJECT Fdo
762 );
763
764 VOID
765 NTAPI
766 ClasspFreeReleaseRequest(
767 IN PDEVICE_OBJECT Fdo
768 );
769
770 NTSTATUS
771 NTAPI
772 ClassReleaseQueueCompletion(
773 IN PDEVICE_OBJECT DeviceObject,
774 IN PIRP Irp,
775 IN PVOID Context
776 );
777
778 VOID
779 NTAPI
780 ClasspReleaseQueue(
781 IN PDEVICE_OBJECT DeviceObject,
782 IN PIRP ReleaseQueueIrp
783 );
784
785 VOID
786 NTAPI
787 ClasspDisablePowerNotification(
788 PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
789 );
790
791 //
792 // class power routines
793 //
794
795 NTSTATUS
796 NTAPI
797 ClassDispatchPower(
798 IN PDEVICE_OBJECT DeviceObject,
799 IN PIRP Irp
800 );
801
802 NTSTATUS
803 NTAPI
804 ClassMinimalPowerHandler(
805 IN PDEVICE_OBJECT DeviceObject,
806 IN PIRP Irp
807 );
808
809 //
810 // Child list routines
811 //
812
813 VOID
814 NTAPI
815 ClassAddChild(
816 IN PFUNCTIONAL_DEVICE_EXTENSION Parent,
817 IN PPHYSICAL_DEVICE_EXTENSION Child,
818 IN BOOLEAN AcquireLock
819 );
820
821 PPHYSICAL_DEVICE_EXTENSION
822 NTAPI
823 ClassRemoveChild(
824 IN PFUNCTIONAL_DEVICE_EXTENSION Parent,
825 IN PPHYSICAL_DEVICE_EXTENSION Child,
826 IN BOOLEAN AcquireLock
827 );
828
829 VOID
830 NTAPI
831 ClasspRetryDpcTimer(
832 IN PCLASS_PRIVATE_FDO_DATA FdoData
833 );
834
835 VOID
836 NTAPI
837 ClasspRetryRequestDpc(
838 IN PKDPC Dpc,
839 IN PDEVICE_OBJECT DeviceObject,
840 IN PVOID Arg1,
841 IN PVOID Arg2
842 );
843
844 VOID
845 NTAPI
846 ClassFreeOrReuseSrb(
847 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
848 IN PSCSI_REQUEST_BLOCK Srb
849 );
850
851 VOID
852 NTAPI
853 ClassRetryRequest(
854 IN PDEVICE_OBJECT SelfDeviceObject,
855 IN PIRP Irp,
856 IN LARGE_INTEGER TimeDelta100ns // in 100ns units
857 );
858
859 VOID
860 NTAPI
861 ClasspBuildRequestEx(
862 IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
863 IN PIRP Irp,
864 IN PSCSI_REQUEST_BLOCK Srb
865 );
866
867 NTSTATUS
868 NTAPI
869 ClasspAllocateReleaseQueueIrp(
870 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
871 );
872
873 NTSTATUS
874 NTAPI
875 ClasspInitializeGesn(
876 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
877 IN PMEDIA_CHANGE_DETECTION_INFO Info
878 );
879
880 VOID
881 NTAPI
882 ClasspSendNotification(
883 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
884 IN const GUID * Guid,
885 IN ULONG ExtraDataSize,
886 IN PVOID ExtraData
887 );
888
889 VOID
890 NTAPI
891 ClassSendEjectionNotification(
892 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
893 );
894
895 VOID
896 NTAPI
897 ClasspScanForSpecialInRegistry(
898 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
899 );
900
901 VOID
902 NTAPI
903 ClasspScanForClassHacks(
904 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
905 IN ULONG_PTR Data
906 );
907
908 NTSTATUS
909 NTAPI
910 ClasspInitializeHotplugInfo(
911 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
912 );
913
914 VOID
915 NTAPI
916 ClasspPerfIncrementErrorCount(
917 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
918 );
919 VOID
920 NTAPI
921 ClasspPerfIncrementSuccessfulIo(
922 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
923 );
924
925 PTRANSFER_PACKET NTAPI NewTransferPacket(PDEVICE_OBJECT Fdo);
926 VOID NTAPI DestroyTransferPacket(PTRANSFER_PACKET Pkt);
927 VOID NTAPI EnqueueFreeTransferPacket(PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt);
928 PTRANSFER_PACKET NTAPI DequeueFreeTransferPacket(PDEVICE_OBJECT Fdo, BOOLEAN AllocIfNeeded);
929 VOID NTAPI SetupReadWriteTransferPacket(PTRANSFER_PACKET pkt, PVOID Buf, ULONG Len, LARGE_INTEGER DiskLocation, PIRP OriginalIrp);
930 VOID NTAPI SubmitTransferPacket(PTRANSFER_PACKET Pkt);
931 NTSTATUS NTAPI TransferPktComplete(IN PDEVICE_OBJECT NullFdo, IN PIRP Irp, IN PVOID Context);
932 VOID NTAPI ServiceTransferRequest(PDEVICE_OBJECT Fdo, PIRP Irp);
933 VOID NTAPI TransferPacketRetryTimerDpc(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2);
934 BOOLEAN NTAPI InterpretTransferPacketError(PTRANSFER_PACKET Pkt);
935 BOOLEAN NTAPI RetryTransferPacket(PTRANSFER_PACKET Pkt);
936 VOID NTAPI EnqueueDeferredClientIrp(PCLASS_PRIVATE_FDO_DATA FdoData, PIRP Irp);
937 PIRP NTAPI DequeueDeferredClientIrp(PCLASS_PRIVATE_FDO_DATA FdoData);
938 VOID NTAPI InitLowMemRetry(PTRANSFER_PACKET Pkt, PVOID BufPtr, ULONG Len, LARGE_INTEGER TargetLocation);
939 BOOLEAN NTAPI StepLowMemRetry(PTRANSFER_PACKET Pkt);
940 VOID NTAPI SetupEjectionTransferPacket(TRANSFER_PACKET *Pkt, BOOLEAN PreventMediaRemoval, PKEVENT SyncEventPtr, PIRP OriginalIrp);
941 VOID NTAPI SetupModeSenseTransferPacket(TRANSFER_PACKET *Pkt, PKEVENT SyncEventPtr, PVOID ModeSenseBuffer, UCHAR ModeSenseBufferLen, UCHAR PageMode, PIRP OriginalIrp);
942 VOID NTAPI SetupDriveCapacityTransferPacket(TRANSFER_PACKET *Pkt, PVOID ReadCapacityBuffer, ULONG ReadCapacityBufferLen, PKEVENT SyncEventPtr, PIRP OriginalIrp);
943 PMDL NTAPI BuildDeviceInputMdl(PVOID Buffer, ULONG BufferLen);
944 VOID NTAPI FreeDeviceInputMdl(PMDL Mdl);
945 NTSTATUS NTAPI InitializeTransferPackets(PDEVICE_OBJECT Fdo);
946 VOID NTAPI DestroyAllTransferPackets(PDEVICE_OBJECT Fdo);