3 Copyright (C) Microsoft Corporation, 1991 - 1999
11 THESE ARE EXPORTED CLASSPNP FUNCTIONS (and their subroutines)
12 WHICH ARE NOW OBSOLETE.
13 BUT WE NEED TO KEEP THEM AROUND FOR LEGACY REASONS.
29 PIRP NTAPI
ClassRemoveCScanList(IN PCSCAN_LIST List
);
30 VOID NTAPI
ClasspInitializeCScanList(IN PCSCAN_LIST List
);
33 #pragma alloc_text(PAGE, ClassDeleteSrbLookasideList)
34 #pragma alloc_text(PAGE, ClassInitializeSrbLookasideList)
37 typedef struct _CSCAN_LIST_ENTRY
{
39 ULONGLONG BlockNumber
;
40 } CSCAN_LIST_ENTRY
, *PCSCAN_LIST_ENTRY
;
45 * This is a legacy exported function.
46 * It is called by storage miniport driver that have their own
47 * StartIo routine when the transfer size is too large for the hardware.
48 * We map it to our new read/write handler.
50 VOID NTAPI
ClassSplitRequest(IN PDEVICE_OBJECT Fdo
, IN PIRP Irp
, IN ULONG MaximumBytes
)
52 PFUNCTIONAL_DEVICE_EXTENSION fdoExt
= Fdo
->DeviceExtension
;
53 PCLASS_PRIVATE_FDO_DATA fdoData
= fdoExt
->PrivateFdoData
;
55 if (MaximumBytes
> fdoData
->HwMaxXferLen
) {
56 DBGERR(("ClassSplitRequest - driver requesting split to size that "
57 "hardware is unable to handle!\n"));
60 if (MaximumBytes
< fdoData
->HwMaxXferLen
){
61 DBGWARN(("ClassSplitRequest - driver requesting smaller HwMaxXferLen "
63 fdoData
->HwMaxXferLen
= MAX(MaximumBytes
, PAGE_SIZE
);
66 ServiceTransferRequest(Fdo
, Irp
);
69 /*++////////////////////////////////////////////////////////////////////////////
71 ClassIoCompleteAssociated()
75 This routine executes when the port driver has completed a request.
76 It looks at the SRB status in the completing SRB and if not success
77 it checks for valid request sense buffer information. If valid, the
78 info is used to update status with more precise message of type of
79 error. This routine deallocates the SRB. This routine is used for
80 requests which were build by split request. After it has processed
81 the request it decrements the Irp count in the master Irp. If the
82 count goes to zero then the master Irp is completed.
86 Fdo - Supplies the functional device object which represents the target.
88 Irp - Supplies the Irp which has completed.
90 Context - Supplies a pointer to the SRB.
99 ClassIoCompleteAssociated(
100 IN PDEVICE_OBJECT Fdo
,
105 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension
= Fdo
->DeviceExtension
;
107 PIO_STACK_LOCATION irpStack
= IoGetCurrentIrpStackLocation(Irp
);
108 PSCSI_REQUEST_BLOCK srb
= Context
;
110 PIRP originalIrp
= Irp
->AssociatedIrp
.MasterIrp
;
116 DBGWARN(("ClassIoCompleteAssociated is OBSOLETE !"));
119 // Check SRB status for success of completing request.
122 if (SRB_STATUS(srb
->SrbStatus
) != SRB_STATUS_SUCCESS
) {
126 DebugPrint((2,"ClassIoCompleteAssociated: IRP %p, SRB %p", Irp
, srb
));
129 // Release the queue if it is frozen.
132 if (srb
->SrbStatus
& SRB_STATUS_QUEUE_FROZEN
) {
133 ClassReleaseQueue(Fdo
);
136 retry
= ClassInterpretSenseInfo(
139 irpStack
->MajorFunction
,
140 irpStack
->MajorFunction
== IRP_MJ_DEVICE_CONTROL
?
141 irpStack
->Parameters
.DeviceIoControl
.IoControlCode
:
144 ((ULONG
)(ULONG_PTR
)irpStack
->Parameters
.Others
.Argument4
),
149 // If the status is verified required and the this request
150 // should bypass verify required then retry the request.
153 if (irpStack
->Flags
& SL_OVERRIDE_VERIFY_VOLUME
&&
154 status
== STATUS_VERIFY_REQUIRED
) {
156 status
= STATUS_IO_DEVICE_ERROR
;
160 if (retry
&& ((*(PCHAR
*)&irpStack
->Parameters
.Others
.Argument4
)--)) {
163 // Retry request. If the class driver has supplied a StartIo,
164 // call it directly for retries.
167 DebugPrint((1, "Retry request %p\n", Irp
));
169 if (PORT_ALLOCATED_SENSE(fdoExtension
, srb
)) {
170 FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension
, srb
);
173 RetryRequest(Fdo
, Irp
, srb
, TRUE
, retryInterval
);
175 return STATUS_MORE_PROCESSING_REQUIRED
;
181 // Set status for successful request.
184 status
= STATUS_SUCCESS
;
186 } // end if (SRB_STATUS(srb->SrbStatus) ...
189 // Return SRB to list.
192 if (PORT_ALLOCATED_SENSE(fdoExtension
, srb
)) {
193 FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension
, srb
);
196 ClassFreeOrReuseSrb(fdoExtension
, srb
);
199 // Set status in completing IRP.
202 Irp
->IoStatus
.Status
= status
;
204 DebugPrint((2, "ClassIoCompleteAssociated: Partial xfer IRP %p\n", Irp
));
207 // Get next stack location. This original request is unused
208 // except to keep track of the completing partial IRPs so the
209 // stack location is valid.
212 irpStack
= IoGetNextIrpStackLocation(originalIrp
);
215 // Update status only if error so that if any partial transfer
216 // completes with error, then the original IRP will return with
217 // error. If any of the asynchronous partial transfer IRPs fail,
218 // with an error then the original IRP will return 0 bytes transfered.
219 // This is an optimization for successful transfers.
222 if (!NT_SUCCESS(status
)) {
224 originalIrp
->IoStatus
.Status
= status
;
225 originalIrp
->IoStatus
.Information
= 0;
228 // Set the hard error if necessary.
231 if (IoIsErrorUserInduced(status
)) {
234 // Store DeviceObject for filesystem.
237 IoSetHardErrorOrVerifyDevice(originalIrp
, Fdo
);
242 // Decrement and get the count of remaining IRPs.
245 irpCount
= InterlockedDecrement(
246 (PLONG
)&irpStack
->Parameters
.Others
.Argument1
);
248 DebugPrint((2, "ClassIoCompleteAssociated: Partial IRPs left %d\n",
252 // Ensure that the irpCount doesn't go negative. This was happening once
253 // because classpnp would get confused if it ran out of resources when
254 // splitting the request.
257 ASSERT(irpCount
>= 0);
262 // All partial IRPs have completed.
266 "ClassIoCompleteAssociated: All partial IRPs complete %p\n",
269 if (fdoExtension
->CommonExtension
.DriverExtension
->InitData
.ClassStartIo
) {
272 // Acquire a separate copy of the remove lock so the debugging code
273 // works okay and we don't have to hold up the completion of this
274 // irp until after we start the next packet(s).
279 ClassAcquireRemoveLock(Fdo
, (PIRP
)&uniqueAddress
);
280 ClassReleaseRemoveLock(Fdo
, originalIrp
);
281 ClassCompleteRequest(Fdo
, originalIrp
, IO_DISK_INCREMENT
);
283 KeRaiseIrql(DISPATCH_LEVEL
, &oldIrql
);
284 IoStartNextPacket(Fdo
, FALSE
);
285 KeLowerIrql(oldIrql
);
287 ClassReleaseRemoveLock(Fdo
, (PIRP
)&uniqueAddress
);
292 // just complete this request
295 ClassReleaseRemoveLock(Fdo
, originalIrp
);
296 ClassCompleteRequest(Fdo
, originalIrp
, IO_DISK_INCREMENT
);
303 // Deallocate IRP and indicate the I/O system should not attempt any more
308 return STATUS_MORE_PROCESSING_REQUIRED
;
310 } // end ClassIoCompleteAssociated()
312 /*++////////////////////////////////////////////////////////////////////////////
318 This is a wrapper around the delayed retry DPC routine, RetryRequestDPC.
319 This reinitializes the necessary fields, queues the request, and sets
320 a timer to call the DPC if someone hasn't already done so.
324 DeviceObject - Supplies the device object associated with this request.
326 Irp - Supplies the request to be retried.
328 Srb - Supplies a Pointer to the SCSI request block to be retied.
330 Assocaiated - Indicates this is an assocatied Irp created by split request.
332 RetryInterval - How long, in seconds, before retrying the request.
342 PDEVICE_OBJECT DeviceObject
,
344 PSCSI_REQUEST_BLOCK Srb
,
349 PIO_STACK_LOCATION currentIrpStack
= IoGetCurrentIrpStackLocation(Irp
);
350 PIO_STACK_LOCATION nextIrpStack
= IoGetNextIrpStackLocation(Irp
);
351 ULONG transferByteCount
;
353 // This function is obsolete but is still used by some of our class drivers.
354 // DBGWARN(("RetryRequest is OBSOLETE !"));
357 // Determine the transfer count of the request. If this is a read or a
358 // write then the transfer count is in the Irp stack. Otherwise assume
359 // the MDL contains the correct length. If there is no MDL then the
360 // transfer length must be zero.
363 if (currentIrpStack
->MajorFunction
== IRP_MJ_READ
||
364 currentIrpStack
->MajorFunction
== IRP_MJ_WRITE
) {
366 transferByteCount
= currentIrpStack
->Parameters
.Read
.Length
;
368 } else if (Irp
->MdlAddress
!= NULL
) {
371 // Note this assumes that only read and write requests are spilt and
372 // other request do not need to be. If the data buffer address in
373 // the MDL and the SRB don't match then transfer length is most
377 ASSERT(Srb
->DataBuffer
== MmGetMdlVirtualAddress(Irp
->MdlAddress
));
378 transferByteCount
= Irp
->MdlAddress
->ByteCount
;
382 transferByteCount
= 0;
386 // this is a safety net. this should not normally be hit, since we are
387 // not guaranteed to be an fdoExtension
390 ASSERT(!TEST_FLAG(Srb
->SrbFlags
, SRB_FLAGS_FREE_SENSE_BUFFER
));
393 // Reset byte count of transfer in SRB Extension.
396 Srb
->DataTransferLength
= transferByteCount
;
399 // Zero SRB statuses.
402 Srb
->SrbStatus
= Srb
->ScsiStatus
= 0;
405 // Set the no disconnect flag, disable synchronous data transfers and
406 // disable tagged queuing. This fixes some errors.
407 // NOTE: Cannot clear these flags, just add to them
410 SET_FLAG(Srb
->SrbFlags
, SRB_FLAGS_DISABLE_DISCONNECT
);
411 SET_FLAG(Srb
->SrbFlags
, SRB_FLAGS_DISABLE_SYNCH_TRANSFER
);
412 CLEAR_FLAG(Srb
->SrbFlags
, SRB_FLAGS_QUEUE_ACTION_ENABLE
);
414 Srb
->QueueTag
= SP_UNTAGGED
;
417 // Set up major SCSI function.
420 nextIrpStack
->MajorFunction
= IRP_MJ_SCSI
;
423 // Save SRB address in next stack for port driver.
426 nextIrpStack
->Parameters
.Scsi
.Srb
= Srb
;
429 IoSetCompletionRoutine(Irp
, ClassIoComplete
, Srb
, TRUE
, TRUE
, TRUE
);
432 LARGE_INTEGER retry100ns
;
433 retry100ns
.QuadPart
= RetryInterval
; // seconds
434 retry100ns
.QuadPart
*= (LONGLONG
)1000 * 1000 * 10;
436 ClassRetryRequest(DeviceObject
, Irp
, retry100ns
);
439 } // end RetryRequest()
447 This routine allocates an SRB for the specified request then calls
448 ClasspBuildRequestEx to create a SCSI operation to read or write the device.
450 If no SRB is available then the request will be queued to be issued later
451 when requests are available. Drivers which do not want the queueing
452 behavior should allocate the SRB themselves and call ClasspBuildRequestEx
457 Fdo - Supplies the functional device object associated with this request.
459 Irp - Supplies the request to be retried.
463 If the IRP is for a disk transfer, the byteoffset field
464 will already have been adjusted to make it relative to
465 the beginning of the disk.
480 PFUNCTIONAL_DEVICE_EXTENSION fdoExtension
= Fdo
->DeviceExtension
;
482 PSCSI_REQUEST_BLOCK srb
;
484 // This function is obsolete, but still called by CDROM.SYS .
485 // DBGWARN(("ClassBuildRequest is OBSOLETE !"));
491 srb
= ClasspAllocateSrb(fdoExtension
);
494 return STATUS_INSUFFICIENT_RESOURCES
;
497 ClasspBuildRequestEx(fdoExtension
, Irp
, srb
);
498 return STATUS_SUCCESS
;
500 } // end ClassBuildRequest()
504 ClasspBuildRequestEx(
505 IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
,
507 IN PSCSI_REQUEST_BLOCK Srb
512 ClasspBuildRequestEx()
516 This routine allocates and builds an Srb for a read or write request.
517 The block address and length are supplied by the Irp. The retry count
518 is stored in the current stack for use by ClassIoComplete which
519 processes these requests when they complete. The Irp is ready to be
520 passed to the port driver when this routine returns.
524 FdoExtension - Supplies the device extension associated with this request.
526 Irp - Supplies the request to be issued.
528 Srb - Supplies an SRB to be used for the request.
532 If the IRP is for a disk transfer, the byteoffset field
533 will already have been adjusted to make it relative to
534 the beginning of the disk.
543 PIO_STACK_LOCATION currentIrpStack
= IoGetCurrentIrpStackLocation(Irp
);
544 PIO_STACK_LOCATION nextIrpStack
= IoGetNextIrpStackLocation(Irp
);
546 LARGE_INTEGER startingOffset
= currentIrpStack
->Parameters
.Read
.ByteOffset
;
549 ULONG logicalBlockAddress
;
550 USHORT transferBlocks
;
552 // This function is obsolete, but still called by CDROM.SYS .
553 // DBGWARN(("ClasspBuildRequestEx is OBSOLETE !"));
559 RtlZeroMemory(Srb
, sizeof(SCSI_REQUEST_BLOCK
));
562 // Calculate relative sector address.
565 logicalBlockAddress
=
566 (ULONG
)(Int64ShrlMod32(startingOffset
.QuadPart
,
567 FdoExtension
->SectorShift
));
570 // Write length to SRB.
573 Srb
->Length
= sizeof(SCSI_REQUEST_BLOCK
);
576 // Set up IRP Address.
579 Srb
->OriginalRequest
= Irp
;
582 // Set up target ID and logical unit number.
585 Srb
->Function
= SRB_FUNCTION_EXECUTE_SCSI
;
586 Srb
->DataBuffer
= MmGetMdlVirtualAddress(Irp
->MdlAddress
);
589 // Save byte count of transfer in SRB Extension.
592 Srb
->DataTransferLength
= currentIrpStack
->Parameters
.Read
.Length
;
595 // Initialize the queue actions field.
598 Srb
->QueueAction
= SRB_SIMPLE_TAG_REQUEST
;
601 // Queue sort key is Relative Block Address.
604 Srb
->QueueSortKey
= logicalBlockAddress
;
607 // Indicate auto request sense by specifying buffer and size.
610 Srb
->SenseInfoBuffer
= FdoExtension
->SenseData
;
611 Srb
->SenseInfoBufferLength
= SENSE_BUFFER_SIZE
;
614 // Set timeout value of one unit per 64k bytes of data.
617 Srb
->TimeOutValue
= ((Srb
->DataTransferLength
+ 0xFFFF) >> 16) *
618 FdoExtension
->TimeOutValue
;
624 Srb
->SrbStatus
= Srb
->ScsiStatus
= 0;
628 // Indicate that 10-byte CDB's will be used.
634 // Fill in CDB fields.
637 cdb
= (PCDB
)Srb
->Cdb
;
639 transferBlocks
= (USHORT
)(currentIrpStack
->Parameters
.Read
.Length
>>
640 FdoExtension
->SectorShift
);
643 // Move little endian values into CDB in big endian format.
646 cdb
->CDB10
.LogicalBlockByte0
= ((PFOUR_BYTE
)&logicalBlockAddress
)->Byte3
;
647 cdb
->CDB10
.LogicalBlockByte1
= ((PFOUR_BYTE
)&logicalBlockAddress
)->Byte2
;
648 cdb
->CDB10
.LogicalBlockByte2
= ((PFOUR_BYTE
)&logicalBlockAddress
)->Byte1
;
649 cdb
->CDB10
.LogicalBlockByte3
= ((PFOUR_BYTE
)&logicalBlockAddress
)->Byte0
;
651 cdb
->CDB10
.TransferBlocksMsb
= ((PFOUR_BYTE
)&transferBlocks
)->Byte1
;
652 cdb
->CDB10
.TransferBlocksLsb
= ((PFOUR_BYTE
)&transferBlocks
)->Byte0
;
655 // Set transfer direction flag and Cdb command.
658 if (currentIrpStack
->MajorFunction
== IRP_MJ_READ
) {
660 DebugPrint((3, "ClassBuildRequest: Read Command\n"));
662 SET_FLAG(Srb
->SrbFlags
, SRB_FLAGS_DATA_IN
);
663 cdb
->CDB10
.OperationCode
= SCSIOP_READ
;
667 DebugPrint((3, "ClassBuildRequest: Write Command\n"));
669 SET_FLAG(Srb
->SrbFlags
, SRB_FLAGS_DATA_OUT
);
670 cdb
->CDB10
.OperationCode
= SCSIOP_WRITE
;
674 // If this is not a write-through request, then allow caching.
677 if (!(currentIrpStack
->Flags
& SL_WRITE_THROUGH
)) {
679 SET_FLAG(Srb
->SrbFlags
, SRB_FLAGS_ADAPTER_CACHE_ENABLE
);
684 // If write caching is enable then force media access in the
688 if (FdoExtension
->DeviceFlags
& DEV_WRITE_CACHE
) {
689 cdb
->CDB10
.ForceUnitAccess
= TRUE
;
693 if(TEST_FLAG(Irp
->Flags
, (IRP_PAGING_IO
| IRP_SYNCHRONOUS_PAGING_IO
))) {
694 SET_FLAG(Srb
->SrbFlags
, SRB_CLASS_FLAGS_PAGING
);
698 // OR in the default flags from the device object.
701 SET_FLAG(Srb
->SrbFlags
, FdoExtension
->SrbFlags
);
704 // Set up major SCSI function.
707 nextIrpStack
->MajorFunction
= IRP_MJ_SCSI
;
710 // Save SRB address in next stack for port driver.
713 nextIrpStack
->Parameters
.Scsi
.Srb
= Srb
;
716 // Save retry count in current IRP stack.
719 currentIrpStack
->Parameters
.Others
.Argument4
= (PVOID
)MAXIMUM_RETRIES
;
722 // Set up IoCompletion routine address.
725 IoSetCompletionRoutine(Irp
, ClassIoComplete
, Srb
, TRUE
, TRUE
, TRUE
);
729 VOID NTAPI
ClasspInsertCScanList(IN PLIST_ENTRY ListHead
, IN PCSCAN_LIST_ENTRY Entry
)
733 DBGWARN(("ClasspInsertCScanList is OBSOLETE !"));
736 // Iterate through the list. Insert this entry in the sorted list in
737 // order (after other requests for the same block). At each stop if
738 // blockNumber(Entry) >= blockNumber(t) then move on.
741 for(t
= (PCSCAN_LIST_ENTRY
) ListHead
->Flink
;
742 t
!= (PCSCAN_LIST_ENTRY
) ListHead
;
743 t
= (PCSCAN_LIST_ENTRY
) t
->Entry
.Flink
) {
745 if(Entry
->BlockNumber
< t
->BlockNumber
) {
748 // Set the pointers in entry to the right location.
751 Entry
->Entry
.Flink
= &(t
->Entry
);
752 Entry
->Entry
.Blink
= t
->Entry
.Blink
;
755 // Set the pointers in the surrounding elements to refer to us.
758 t
->Entry
.Blink
->Flink
= &(Entry
->Entry
);
759 t
->Entry
.Blink
= &(Entry
->Entry
);
765 // Insert this entry at the tail of the list. If the list was empty this
766 // will also be the head of the list.
769 InsertTailList(ListHead
, &(Entry
->Entry
));
773 VOID NTAPI
ClassInsertCScanList(IN PCSCAN_LIST List
, IN PIRP Irp
, IN ULONGLONG BlockNumber
, IN BOOLEAN LowPriority
)
778 This routine inserts an entry into the CScan list based on it's block number
779 and priority. It is assumed that the caller is providing synchronization
780 to the access of the list.
782 Low priority requests are always scheduled to run on the next sweep across
783 the disk. Normal priority requests will be inserted into the current or
784 next sweep based on the standard C-SCAN algorithm.
788 List - the list to insert into
790 Irp - the irp to be inserted.
792 BlockNumber - the block number for this request.
794 LowPriority - indicates that the request is lower priority and should be
795 done on the next sweep across the disk.
803 PCSCAN_LIST_ENTRY entry
= (PCSCAN_LIST_ENTRY
)Irp
->Tail
.Overlay
.DriverContext
;
805 DBGWARN(("ClassInsertCScanList is OBSOLETE !"));
808 // Set the block number in the entry. We need this to keep the list sorted.
810 entry
->BlockNumber
= BlockNumber
;
813 // If it's a normal priority request and further down the disk than our
814 // current position then insert this entry into the current sweep.
817 if((LowPriority
!= TRUE
) && (BlockNumber
> List
->BlockNumber
)) {
818 ClasspInsertCScanList(&(List
->CurrentSweep
), entry
);
820 ClasspInsertCScanList(&(List
->NextSweep
), entry
);
825 VOID NTAPI
ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
,
826 IN PSCSI_REQUEST_BLOCK Srb
)
831 This routine will attempt to reuse the provided SRB to start a blocked
833 If there is no need to reuse the request it will be returned
834 to the SRB lookaside list.
838 Fdo - the device extension
840 Srb - the SRB which is to be reused or freed.
849 PCOMMON_DEVICE_EXTENSION commonExt
= &FdoExtension
->CommonExtension
;
853 // This function is obsolete, but still called by DISK.SYS .
854 // DBGWARN(("ClassFreeOrReuseSrb is OBSOLETE !"));
857 // safety net. this should never occur. if it does, it's a potential
860 ASSERT(!TEST_FLAG(Srb
->SrbFlags
, SRB_FLAGS_FREE_SENSE_BUFFER
));
862 if (commonExt
->IsSrbLookasideListInitialized
){
864 * Put the SRB back in our lookaside list.
866 * BUGBUG - Some class drivers use ClassIoComplete
867 * to complete SRBs that they themselves allocated.
868 * So we may be putting a "foreign" SRB
869 * (e.g. with a different pool tag) into our lookaside list.
871 ClasspFreeSrb(FdoExtension
, Srb
);
874 DBGERR(("ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!"));;
879 /*++////////////////////////////////////////////////////////////////////////////
881 ClassDeleteSrbLookasideList()
885 This routine deletes a lookaside listhead for srbs, and should be called
886 only during the final removal.
888 If called at other times, the caller is responsible for
889 synchronization and removal issues.
893 CommonExtension - Pointer to the CommonExtension containing the listhead.
900 VOID NTAPI
ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension
)
904 // This function is obsolete, but is still called by some of our code.
905 // DBGWARN(("ClassDeleteSrbLookasideList is OBSOLETE !"));
907 if (CommonExtension
->IsSrbLookasideListInitialized
){
908 CommonExtension
->IsSrbLookasideListInitialized
= FALSE
;
909 ExDeleteNPagedLookasideList(&CommonExtension
->SrbLookasideList
);
912 DBGWARN(("ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist"));
916 /*++////////////////////////////////////////////////////////////////////////////
918 ClassInitializeSrbLookasideList()
922 This routine sets up a lookaside listhead for srbs, and should be called
923 only from the ClassInitDevice() routine to prevent race conditions.
925 If called from other locations, the caller is responsible for
926 synchronization and removal issues.
930 CommonExtension - Pointer to the CommonExtension containing the listhead.
932 NumberElements - Supplies the maximum depth of the lookaside list.
937 The Windows 2000 version of classpnp did not return any status value from
942 VOID NTAPI
ClassInitializeSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension
,
943 IN ULONG NumberElements
)
947 // This function is obsolete, but still called by DISK.SYS .
948 // DBGWARN(("ClassInitializeSrbLookasideList is OBSOLETE !"));
950 ASSERT(!CommonExtension
->IsSrbLookasideListInitialized
);
951 if (!CommonExtension
->IsSrbLookasideListInitialized
){
953 ExInitializeNPagedLookasideList(&CommonExtension
->SrbLookasideList
,
957 sizeof(SCSI_REQUEST_BLOCK
),
959 (USHORT
)NumberElements
);
961 CommonExtension
->IsSrbLookasideListInitialized
= TRUE
;
966 VOID NTAPI
ClasspInitializeCScanList(IN PCSCAN_LIST List
)
969 RtlZeroMemory(List
, sizeof(CSCAN_LIST
));
970 InitializeListHead(&(List
->CurrentSweep
));
971 InitializeListHead(&(List
->NextSweep
));
974 VOID NTAPI
ClasspStartNextSweep(PCSCAN_LIST List
)
976 ASSERT(IsListEmpty(&(List
->CurrentSweep
)) == TRUE
);
979 // If the next sweep is empty then there's nothing to do.
982 if(IsListEmpty(&(List
->NextSweep
))) {
987 // Copy the next sweep list head into the current sweep list head.
990 List
->CurrentSweep
= List
->NextSweep
;
993 // Unlink the next sweep list from the list head now that we have a copy
997 InitializeListHead(&(List
->NextSweep
));
1000 // Update the next sweep list to point back to the current sweep list head.
1003 List
->CurrentSweep
.Flink
->Blink
= &(List
->CurrentSweep
);
1004 List
->CurrentSweep
.Blink
->Flink
= &(List
->CurrentSweep
);
1009 PIRP NTAPI
ClassRemoveCScanList(IN PCSCAN_LIST List
)
1011 PCSCAN_LIST_ENTRY entry
;
1014 // If the current sweep is empty then promote the next sweep.
1017 if(IsListEmpty(&(List
->CurrentSweep
))) {
1018 ClasspStartNextSweep(List
);
1022 // If the current sweep is still empty then we're done.
1025 if(IsListEmpty(&(List
->CurrentSweep
))) {
1030 // Remove the head entry from the current sweep. Record it's block number
1031 // so that nothing before it on the disk gets into the current sweep.
1034 entry
= (PCSCAN_LIST_ENTRY
) RemoveHeadList(&(List
->CurrentSweep
));
1036 List
->BlockNumber
= entry
->BlockNumber
;
1038 return CONTAINING_RECORD(entry
, IRP
, Tail
.Overlay
.DriverContext
);