mirror of
https://github.com/reactos/reactos.git
synced 2024-07-12 07:35:10 +00:00
[CLASSPNP]
- Do not disable compiler warnings - Fix a ton of them svn path=/trunk/; revision=60922
This commit is contained in:
parent
6e52c95041
commit
82703397cf
|
@ -34,11 +34,8 @@ add_library(classpnp SHARED
|
|||
|
||||
if(ARCH STREQUAL "i386")
|
||||
# FIXME: http://www.cmake.org/Bug/view.php?id=12998
|
||||
if(MSVC)
|
||||
#add_target_compile_flags(classpnp "/Gz")
|
||||
set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "/Gz")
|
||||
else()
|
||||
set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "-w")
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "-Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=switch")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -103,12 +103,7 @@ ClasspSendMediaStateIrp(
|
|||
IN ULONG CountDown
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ClasspFailurePredict(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PFAILURE_PREDICTION_INFO Info
|
||||
);
|
||||
IO_WORKITEM_ROUTINE ClasspFailurePredict;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -489,7 +484,7 @@ ClasspInterpretGesnData(
|
|||
SET_FLAG(FdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME);
|
||||
|
||||
}
|
||||
InterlockedIncrement(&FdoExtension->MediaChangeCount);
|
||||
InterlockedIncrement((PLONG)&FdoExtension->MediaChangeCount);
|
||||
ClasspSetMediaChangeStateEx(FdoExtension,
|
||||
MediaPresent,
|
||||
FALSE,
|
||||
|
@ -599,7 +594,7 @@ ClasspInternalSetMediaChangeState(
|
|||
)
|
||||
{
|
||||
#if DBG
|
||||
PUCHAR states[] = {"Unknown", "Present", "Not Present"};
|
||||
PCSTR states[] = {"Unknown", "Present", "Not Present"};
|
||||
#endif
|
||||
MEDIA_CHANGE_DETECTION_STATE oldMediaState;
|
||||
PMEDIA_CHANGE_DETECTION_INFO info = FdoExtension->MediaChangeDetectionInfo;
|
||||
|
@ -818,9 +813,10 @@ NTAPI
|
|||
ClasspMediaChangeDetectionCompletion(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PSCSI_REQUEST_BLOCK Srb
|
||||
PVOID Context
|
||||
)
|
||||
{
|
||||
PSCSI_REQUEST_BLOCK srb = Context;
|
||||
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
|
||||
PCLASS_PRIVATE_FDO_DATA fdoData;
|
||||
PMEDIA_CHANGE_DETECTION_INFO info;
|
||||
|
@ -840,7 +836,7 @@ ClasspMediaChangeDetectionCompletion(
|
|||
info = fdoExtension->MediaChangeDetectionInfo;
|
||||
|
||||
ASSERT(info->MediaChangeIrp != NULL);
|
||||
ASSERT(!TEST_FLAG(Srb->SrbStatus, SRB_STATUS_QUEUE_FROZEN));
|
||||
ASSERT(!TEST_FLAG(srb->SrbStatus, SRB_STATUS_QUEUE_FROZEN));
|
||||
DBGTRACE(ClassDebugMCN, ("> ClasspMediaChangeDetectionCompletion: Device %p completed MCN irp %p.", DeviceObject, Irp));
|
||||
|
||||
/*
|
||||
|
@ -855,15 +851,15 @@ ClasspMediaChangeDetectionCompletion(
|
|||
* This hack only applies to drives with the CAUSE_NOT_REPORTABLE_HACK bit set; this
|
||||
* is set by disk.sys when HackCauseNotReportableHack is set for the drive in its BadControllers list.
|
||||
*/
|
||||
if ((SRB_STATUS(Srb->SrbStatus) != SRB_STATUS_SUCCESS) &&
|
||||
if ((SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) &&
|
||||
TEST_FLAG(fdoExtension->ScanForSpecialFlags, CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK) &&
|
||||
(Srb->SenseInfoBufferLength >= RTL_SIZEOF_THROUGH_FIELD(SENSE_DATA, AdditionalSenseCode))){
|
||||
(srb->SenseInfoBufferLength >= RTL_SIZEOF_THROUGH_FIELD(SENSE_DATA, AdditionalSenseCode))){
|
||||
|
||||
PSENSE_DATA senseData = Srb->SenseInfoBuffer;
|
||||
PSENSE_DATA senseData = srb->SenseInfoBuffer;
|
||||
|
||||
if ((senseData->SenseKey == SCSI_SENSE_NOT_READY) &&
|
||||
(senseData->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY)){
|
||||
Srb->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
srb->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -873,12 +869,12 @@ ClasspMediaChangeDetectionCompletion(
|
|||
// to call ClassError() with correct parameters.
|
||||
//
|
||||
status = STATUS_SUCCESS;
|
||||
if (SRB_STATUS(Srb->SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
if (SRB_STATUS(srb->SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
|
||||
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - failed - srb status=%s, sense=%s/%s/%s.", DBGGETSRBSTATUSSTR(Srb), DBGGETSENSECODESTR(Srb), DBGGETADSENSECODESTR(Srb), DBGGETADSENSEQUALIFIERSTR(Srb)));
|
||||
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - failed - srb status=%s, sense=%s/%s/%s.", DBGGETSRBSTATUSSTR(srb), DBGGETSENSECODESTR(srb), DBGGETADSENSECODESTR(srb), DBGGETADSENSEQUALIFIERSTR(srb)));
|
||||
|
||||
ClassInterpretSenseInfo(DeviceObject,
|
||||
Srb,
|
||||
srb,
|
||||
IRP_MJ_SCSI,
|
||||
0,
|
||||
0,
|
||||
|
@ -936,8 +932,8 @@ ClasspMediaChangeDetectionCompletion(
|
|||
// free port-allocated sense buffer, if any.
|
||||
//
|
||||
|
||||
if (PORT_ALLOCATED_SENSE(fdoExtension, Srb)) {
|
||||
FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, Srb);
|
||||
if (PORT_ALLOCATED_SENSE(fdoExtension, srb)) {
|
||||
FREE_PORT_ALLOCATED_SENSE_BUFFER(fdoExtension, srb);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -945,7 +941,7 @@ ClasspMediaChangeDetectionCompletion(
|
|||
//
|
||||
|
||||
ASSERT(IoGetNextIrpStackLocation(Irp));
|
||||
IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = Srb;
|
||||
IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = srb;
|
||||
|
||||
//
|
||||
// Reset the MCN timer.
|
||||
|
@ -2394,9 +2390,9 @@ ClasspIsMediaChangeDisabledDueToHardwareLimitation(
|
|||
//
|
||||
|
||||
PWSTR nullMultiSz;
|
||||
PUCHAR vendorId;
|
||||
PUCHAR productId;
|
||||
PUCHAR revisionId;
|
||||
PCSTR vendorId;
|
||||
PCSTR productId;
|
||||
PCSTR revisionId;
|
||||
ULONG length;
|
||||
ULONG offset;
|
||||
|
||||
|
@ -2417,21 +2413,21 @@ ClasspIsMediaChangeDisabledDueToHardwareLimitation(
|
|||
if (deviceDescriptor->VendorIdOffset == 0) {
|
||||
vendorId = NULL;
|
||||
} else {
|
||||
vendorId = (PUCHAR) deviceDescriptor + deviceDescriptor->VendorIdOffset;
|
||||
vendorId = (PCSTR) deviceDescriptor + deviceDescriptor->VendorIdOffset;
|
||||
length = strlen(vendorId);
|
||||
}
|
||||
|
||||
if ( deviceDescriptor->ProductIdOffset == 0 ) {
|
||||
productId = NULL;
|
||||
} else {
|
||||
productId = (PUCHAR) deviceDescriptor + deviceDescriptor->ProductIdOffset;
|
||||
productId = (PCSTR) deviceDescriptor + deviceDescriptor->ProductIdOffset;
|
||||
length += strlen(productId);
|
||||
}
|
||||
|
||||
if ( deviceDescriptor->ProductRevisionOffset == 0 ) {
|
||||
revisionId = NULL;
|
||||
} else {
|
||||
revisionId = (PUCHAR) deviceDescriptor + deviceDescriptor->ProductRevisionOffset;
|
||||
revisionId = (PCSTR) deviceDescriptor + deviceDescriptor->ProductRevisionOffset;
|
||||
length += strlen(revisionId);
|
||||
}
|
||||
|
||||
|
@ -2441,7 +2437,7 @@ ClasspIsMediaChangeDisabledDueToHardwareLimitation(
|
|||
|
||||
deviceString.Length = (USHORT)( length );
|
||||
deviceString.MaximumLength = deviceString.Length + 1;
|
||||
deviceString.Buffer = (PUCHAR)ExAllocatePoolWithTag( NonPagedPool,
|
||||
deviceString.Buffer = ExAllocatePoolWithTag( NonPagedPool,
|
||||
deviceString.MaximumLength,
|
||||
CLASS_TAG_AUTORUN_DISABLE
|
||||
);
|
||||
|
@ -2941,7 +2937,7 @@ ClasspMcnControl(
|
|||
//
|
||||
|
||||
ClassDisableMediaChangeDetection(FdoExtension);
|
||||
InterlockedIncrement(&(fsContext->McnDisableCount));
|
||||
InterlockedIncrement((PLONG)&fsContext->McnDisableCount);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -2950,7 +2946,7 @@ ClasspMcnControl(
|
|||
LEAVE;
|
||||
}
|
||||
|
||||
InterlockedDecrement(&(fsContext->McnDisableCount));
|
||||
InterlockedDecrement((PLONG)&fsContext->McnDisableCount);
|
||||
ClassEnableMediaChangeDetection(FdoExtension);
|
||||
}
|
||||
|
||||
|
@ -3144,7 +3140,7 @@ ClasspTimerTick(
|
|||
// resets CountDown uses InterlockedExchange which is also
|
||||
// atomic.
|
||||
//
|
||||
countDown = InterlockedDecrement(&info->CountDown);
|
||||
countDown = InterlockedDecrement((PLONG)&info->CountDown);
|
||||
if (countDown == 0) {
|
||||
|
||||
DebugPrint((4, "ClasspTimerTick: Send FP irp for %p\n",
|
||||
|
@ -3165,7 +3161,7 @@ ClasspTimerTick(
|
|||
|
||||
DebugPrint((1, "ClassTimerTick: Couldn't allocate "
|
||||
"item - try again in one minute\n"));
|
||||
InterlockedExchange(&info->CountDown, 60);
|
||||
InterlockedExchange((PLONG)&info->CountDown, 60);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -3343,9 +3339,10 @@ VOID
|
|||
NTAPI
|
||||
ClasspFailurePredict(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PFAILURE_PREDICTION_INFO Info
|
||||
IN PVOID Context
|
||||
)
|
||||
{
|
||||
PFAILURE_PREDICTION_INFO info = Context;
|
||||
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
|
||||
PIO_WORKITEM workItem;
|
||||
STORAGE_PREDICT_FAILURE checkFailure;
|
||||
|
@ -3353,7 +3350,7 @@ ClasspFailurePredict(
|
|||
|
||||
NTSTATUS status;
|
||||
|
||||
ASSERT(Info != NULL);
|
||||
ASSERT(info != NULL);
|
||||
|
||||
DebugPrint((1, "ClasspFailurePredict: Polling for failure\n"));
|
||||
|
||||
|
@ -3364,8 +3361,8 @@ ClasspFailurePredict(
|
|||
// the lock.
|
||||
//
|
||||
|
||||
InterlockedExchange(&Info->CountDown, Info->Period);
|
||||
workItem = InterlockedExchangePointer(&(Info->WorkQueueItem), NULL);
|
||||
InterlockedExchange((PLONG)&info->CountDown, info->Period);
|
||||
workItem = InterlockedExchangePointer(&info->WorkQueueItem, NULL);
|
||||
|
||||
if (ClasspCanSendPollingIrp(fdoExtension)) {
|
||||
|
||||
|
@ -3613,11 +3610,11 @@ ClassSetFailurePredictionPoll(
|
|||
|
||||
if (PollingPeriod != 0) {
|
||||
|
||||
InterlockedExchange(&info->Period, PollingPeriod);
|
||||
InterlockedExchange((PLONG)&info->Period, PollingPeriod);
|
||||
|
||||
}
|
||||
|
||||
InterlockedExchange(&info->CountDown, info->Period);
|
||||
InterlockedExchange((PLONG)&info->CountDown, info->Period);
|
||||
|
||||
info->Method = FailurePredictionMethod;
|
||||
if (FailurePredictionMethod != FailurePredictionNone) {
|
||||
|
|
|
@ -238,7 +238,7 @@ ClassInitialize(
|
|||
status = IoAllocateDriverObjectExtension(DriverObject,
|
||||
CLASS_DRIVER_EXTENSION_KEY,
|
||||
sizeof(CLASS_DRIVER_EXTENSION),
|
||||
&driverExtension);
|
||||
(PVOID *)&driverExtension);
|
||||
|
||||
if(NT_SUCCESS(status)) {
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ ClassDispatchPnp(
|
|||
if (NT_SUCCESS(status)) {
|
||||
|
||||
IoAdjustPagingPathCount(
|
||||
&commonExtension->PagingPathCount,
|
||||
(PLONG)&commonExtension->PagingPathCount,
|
||||
irpStack->Parameters.UsageNotification.InPath);
|
||||
|
||||
if (irpStack->Parameters.UsageNotification.InPath) {
|
||||
|
@ -1097,13 +1097,13 @@ ClassDispatchPnp(
|
|||
case DeviceUsageTypeHibernation: {
|
||||
|
||||
IoAdjustPagingPathCount(
|
||||
&commonExtension->HibernationPathCount,
|
||||
(PLONG)&commonExtension->HibernationPathCount,
|
||||
irpStack->Parameters.UsageNotification.InPath
|
||||
);
|
||||
status = ClassForwardIrpSynchronous(commonExtension, Irp);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
IoAdjustPagingPathCount(
|
||||
&commonExtension->HibernationPathCount,
|
||||
(PLONG)&commonExtension->HibernationPathCount,
|
||||
!irpStack->Parameters.UsageNotification.InPath
|
||||
);
|
||||
}
|
||||
|
@ -1113,13 +1113,13 @@ ClassDispatchPnp(
|
|||
|
||||
case DeviceUsageTypeDumpFile: {
|
||||
IoAdjustPagingPathCount(
|
||||
&commonExtension->DumpPathCount,
|
||||
(PLONG)&commonExtension->DumpPathCount,
|
||||
irpStack->Parameters.UsageNotification.InPath
|
||||
);
|
||||
status = ClassForwardIrpSynchronous(commonExtension, Irp);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
IoAdjustPagingPathCount(
|
||||
&commonExtension->DumpPathCount,
|
||||
(PLONG)&commonExtension->DumpPathCount,
|
||||
!irpStack->Parameters.UsageNotification.InPath
|
||||
);
|
||||
}
|
||||
|
@ -1362,7 +1362,7 @@ NTSTATUS NTAPI ClassPnpStartDevice(IN PDEVICE_OBJECT DeviceObject)
|
|||
status = ClassGetDescriptor(
|
||||
commonExtension->LowerDeviceObject,
|
||||
&propertyId,
|
||||
&fdoExtension->AdapterDescriptor);
|
||||
(PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->AdapterDescriptor);
|
||||
|
||||
if(!NT_SUCCESS(status)) {
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ NTSTATUS NTAPI ClassPnpStartDevice(IN PDEVICE_OBJECT DeviceObject)
|
|||
status = ClassGetDescriptor(
|
||||
commonExtension->LowerDeviceObject,
|
||||
&propertyId,
|
||||
&fdoExtension->DeviceDescriptor);
|
||||
(PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->DeviceDescriptor);
|
||||
|
||||
if(!NT_SUCCESS(status)) {
|
||||
|
||||
|
@ -2113,7 +2113,7 @@ ClassSendStartUnit(
|
|||
ClassAcquireRemoveLock(Fdo, irp);
|
||||
|
||||
IoSetCompletionRoutine(irp,
|
||||
(PIO_COMPLETION_ROUTINE)ClassAsynchronousCompletion,
|
||||
ClassAsynchronousCompletion,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
|
@ -3453,7 +3453,7 @@ ClassInterpretSenseInfo(
|
|||
// count for the physical device
|
||||
//
|
||||
|
||||
count = InterlockedIncrement(&fdoExtension->MediaChangeCount);
|
||||
count = InterlockedIncrement((PLONG)&fdoExtension->MediaChangeCount);
|
||||
DebugPrint((ClassDebugSenseInfo, "ClassInterpretSenseInfo: "
|
||||
"Media change count for device %d incremented to %#lx\n",
|
||||
fdoExtension->DeviceNumber, count));
|
||||
|
@ -3918,7 +3918,7 @@ ClassInterpretSenseInfo(
|
|||
ULONG totalSize;
|
||||
ULONG senseBufferSize = 0;
|
||||
IO_ERROR_LOG_PACKET staticErrLogEntry = {0};
|
||||
CLASS_ERROR_LOG_DATA staticErrLogData = {0};
|
||||
CLASS_ERROR_LOG_DATA staticErrLogData = { { { 0 } } };
|
||||
|
||||
//
|
||||
// Calculate the total size of the error log entry.
|
||||
|
@ -4215,7 +4215,7 @@ ClassFindModePage(
|
|||
IN BOOLEAN Use6Byte
|
||||
)
|
||||
{
|
||||
PUCHAR limit;
|
||||
PCHAR limit;
|
||||
ULONG parameterHeaderLength;
|
||||
PVOID result = NULL;
|
||||
|
||||
|
@ -6516,9 +6516,11 @@ NTAPI
|
|||
ClassSignalCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PKEVENT Event
|
||||
IN PVOID Context
|
||||
)
|
||||
{
|
||||
PKEVENT Event = Context;
|
||||
|
||||
KeSetEvent(Event, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
|
@ -6566,7 +6568,7 @@ ClassPnpQueryFdoRelations(
|
|||
// one.
|
||||
//
|
||||
|
||||
if(InterlockedIncrement(&(fdoExtension->EnumerationInterlock)) == 1) {
|
||||
if(InterlockedIncrement((PLONG)&fdoExtension->EnumerationInterlock) == 1) {
|
||||
status = driverExtension->InitData.ClassEnumerateDevice(Fdo);
|
||||
}
|
||||
|
||||
|
@ -6576,7 +6578,7 @@ ClassPnpQueryFdoRelations(
|
|||
Fdo,
|
||||
BusRelations,
|
||||
(PDEVICE_RELATIONS*)&Irp->IoStatus.Information);
|
||||
InterlockedDecrement(&(fdoExtension->EnumerationInterlock));
|
||||
InterlockedDecrement((PLONG)&fdoExtension->EnumerationInterlock);
|
||||
|
||||
return Irp->IoStatus.Status;
|
||||
} // end ClassPnpQueryFdoRelations()
|
||||
|
@ -6929,10 +6931,10 @@ ClassInvalidateBusRelations(
|
|||
ASSERT_FDO(Fdo);
|
||||
ASSERT(driverExtension->InitData.ClassEnumerateDevice != NULL);
|
||||
|
||||
if(InterlockedIncrement(&(fdoExtension->EnumerationInterlock)) == 1) {
|
||||
if(InterlockedIncrement((PLONG)&fdoExtension->EnumerationInterlock) == 1) {
|
||||
status = driverExtension->InitData.ClassEnumerateDevice(Fdo);
|
||||
}
|
||||
InterlockedDecrement(&(fdoExtension->EnumerationInterlock));
|
||||
InterlockedDecrement((PLONG)&fdoExtension->EnumerationInterlock);
|
||||
|
||||
if(!NT_SUCCESS(status)) {
|
||||
|
||||
|
@ -7124,7 +7126,7 @@ ClassRemoveDevice(
|
|||
* to delete it ourselves.
|
||||
*/
|
||||
ClassAcquireChildLock(fdoExtension);
|
||||
while (child = ClassRemoveChild(fdoExtension, NULL, FALSE)){
|
||||
while ((child = ClassRemoveChild(fdoExtension, NULL, FALSE))){
|
||||
|
||||
//
|
||||
// Yank the pdo. This routine will unlink the device from the
|
||||
|
@ -7332,7 +7334,7 @@ ClassUpdateInformationInRegistry(
|
|||
NTSTATUS status;
|
||||
SCSI_ADDRESS scsiAddress;
|
||||
OBJECT_ATTRIBUTES objectAttributes;
|
||||
PUCHAR buffer;
|
||||
PSTR buffer;
|
||||
STRING string;
|
||||
UNICODE_STRING unicodeName;
|
||||
UNICODE_STRING unicodeRegistryPath;
|
||||
|
@ -7447,7 +7449,7 @@ ClassUpdateInformationInRegistry(
|
|||
|
||||
RtlInitUnicodeString(&unicodeName, L"DeviceName");
|
||||
|
||||
sprintf(buffer, "%s%d", DeviceName, DeviceNumber);
|
||||
sprintf(buffer, "%s%lu", DeviceName, DeviceNumber);
|
||||
RtlInitString(&string, buffer);
|
||||
status = RtlAnsiStringToUnicodeString(&unicodeData,
|
||||
&string,
|
||||
|
@ -8704,11 +8706,12 @@ VOID
|
|||
NTAPI
|
||||
ClasspRetryRequestDpc(
|
||||
IN PKDPC Dpc,
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PVOID Context,
|
||||
IN PVOID Arg1,
|
||||
IN PVOID Arg2
|
||||
)
|
||||
{
|
||||
PDEVICE_OBJECT deviceObject = Context;
|
||||
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
|
||||
PCOMMON_DEVICE_EXTENSION commonExtension;
|
||||
PCLASS_PRIVATE_FDO_DATA fdoData;
|
||||
|
@ -8716,9 +8719,9 @@ ClasspRetryRequestDpc(
|
|||
KIRQL irql;
|
||||
|
||||
|
||||
commonExtension = DeviceObject->DeviceExtension;
|
||||
commonExtension = deviceObject->DeviceExtension;
|
||||
ASSERT(commonExtension->IsFdo);
|
||||
fdoExtension = DeviceObject->DeviceExtension;
|
||||
fdoExtension = deviceObject->DeviceExtension;
|
||||
fdoData = fdoExtension->PrivateFdoData;
|
||||
|
||||
|
||||
|
|
|
@ -508,25 +508,11 @@ static inline BOOLEAN SimpleIsSlistEmpty(SINGLE_LIST_ENTRY *SListHdr)
|
|||
return (SListHdr->Next == NULL);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
DriverEntry(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN PUNICODE_STRING RegistryPath
|
||||
);
|
||||
DRIVER_INITIALIZE DriverEntry;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ClassUnload(
|
||||
IN PDRIVER_OBJECT DriverObject
|
||||
);
|
||||
DRIVER_UNLOAD ClassUnload;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassCreateClose(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassCreateClose;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -550,26 +536,11 @@ ClasspEjectionControl(
|
|||
IN BOOLEAN Lock
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassReadWrite(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassReadWrite;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassDeviceControlDispatch(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassDeviceControlDispatch;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassDispatchPnp(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassDispatchPnp;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -584,31 +555,15 @@ ClassShutdownFlush(
|
|||
IN PIRP Irp
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassSystemControl(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassSystemControl;
|
||||
|
||||
//
|
||||
// Class internal routines
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassAddDevice(
|
||||
IN PDRIVER_OBJECT DriverObject,
|
||||
IN OUT PDEVICE_OBJECT PhysicalDeviceObject
|
||||
);
|
||||
DRIVER_ADD_DEVICE ClassAddDevice;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClasspSendSynchronousCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context
|
||||
);
|
||||
IO_COMPLETION_ROUTINE ClasspSendSynchronousCompletion;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -658,12 +613,7 @@ ClassQueryPnpCapabilities(
|
|||
IN PDEVICE_CAPABILITIES Capabilities
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ClasspStartIo(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp
|
||||
);
|
||||
DRIVER_STARTIO ClasspStartIo;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -767,13 +717,7 @@ ClasspFreeReleaseRequest(
|
|||
IN PDEVICE_OBJECT Fdo
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassReleaseQueueCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context
|
||||
);
|
||||
IO_COMPLETION_ROUTINE ClassReleaseQueueCompletion;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -792,12 +736,7 @@ ClasspDisablePowerNotification(
|
|||
// class power routines
|
||||
//
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassDispatchPower(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp
|
||||
);
|
||||
DRIVER_DISPATCH ClassDispatchPower;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
|
@ -832,14 +771,7 @@ ClasspRetryDpcTimer(
|
|||
IN PCLASS_PRIVATE_FDO_DATA FdoData
|
||||
);
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
ClasspRetryRequestDpc(
|
||||
IN PKDPC Dpc,
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PVOID Arg1,
|
||||
IN PVOID Arg2
|
||||
);
|
||||
KDEFERRED_ROUTINE ClasspRetryRequestDpc;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
|
|
@ -27,7 +27,7 @@ Revision History:
|
|||
|
||||
ULONG BreakOnClose = 0;
|
||||
|
||||
PUCHAR LockTypeStrings[] = {
|
||||
PCSTR LockTypeStrings[] = {
|
||||
"Simple",
|
||||
"Secure",
|
||||
"Internal"
|
||||
|
@ -194,10 +194,10 @@ Return Value:
|
|||
|
||||
status = AllocateDictionaryEntry(
|
||||
&commonExtension->FileObjectDictionary,
|
||||
(ULONGLONG) irpStack->FileObject,
|
||||
(ULONG_PTR)irpStack->FileObject,
|
||||
sizeof(FILE_OBJECT_EXTENSION),
|
||||
CLASS_TAG_FILE_OBJECT_EXTENSION,
|
||||
&fsContext);
|
||||
(PVOID *)&fsContext);
|
||||
|
||||
if(NT_SUCCESS(status)) {
|
||||
|
||||
|
@ -340,7 +340,7 @@ ClasspCleanupProtectedLocks(
|
|||
|
||||
do {
|
||||
|
||||
InterlockedDecrement(&FsContext->LockCount);
|
||||
InterlockedDecrement((PLONG)&FsContext->LockCount);
|
||||
|
||||
newDeviceLockCount =
|
||||
InterlockedDecrement(&fdoExtension->ProtectedLockCount);
|
||||
|
@ -977,5 +977,5 @@ ClasspGetFsContext(
|
|||
{
|
||||
PAGED_CODE();
|
||||
return GetDictionaryEntry(&(CommonExtension->FileObjectDictionary),
|
||||
(ULONGLONG) FileObject);
|
||||
(ULONG_PTR)FileObject);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,9 @@ Revision History:
|
|||
#define CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS 512
|
||||
#endif // CLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS
|
||||
|
||||
#ifdef ALLOC_DATA_PRAGMA
|
||||
#pragma data_seg("NONPAGE")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -178,8 +180,8 @@ Revision History:
|
|||
//
|
||||
|
||||
ULONG index;
|
||||
PUCHAR buffer;
|
||||
index = InterlockedIncrement(&ClasspnpGlobals.Index);
|
||||
PSTR buffer;
|
||||
index = InterlockedIncrement((PLONG)&ClasspnpGlobals.Index);
|
||||
index %= ClasspnpGlobals.NumberOfBuffers;
|
||||
index *= (ULONG)ClasspnpGlobals.EachBufferSize;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ VOID ClassDebugPrint(CLASS_DEBUG_LEVEL DebugPrintLevel, PCCHAR DebugMessage, ...
|
|||
|
||||
ULONG Index; // index into buffer
|
||||
KSPIN_LOCK SpinLock;
|
||||
PUCHAR Buffer; // requires spinlock to access
|
||||
PSTR Buffer; // requires spinlock to access
|
||||
ULONG NumberOfBuffers; // number of buffers available
|
||||
SIZE_T EachBufferSize; // size of each buffer
|
||||
|
||||
|
|
|
@ -33,21 +33,9 @@ ClasspPowerHandler(
|
|||
IN CLASS_POWER_OPTIONS Options
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClasspPowerDownCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PCLASS_POWER_CONTEXT Context
|
||||
);
|
||||
IO_COMPLETION_ROUTINE ClasspPowerDownCompletion;
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClasspPowerUpCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PCLASS_POWER_CONTEXT Context
|
||||
);
|
||||
IO_COMPLETION_ROUTINE ClasspPowerUpCompletion;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
@ -159,9 +147,10 @@ NTAPI
|
|||
ClasspPowerUpCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PCLASS_POWER_CONTEXT Context
|
||||
IN PVOID CompletionContext
|
||||
)
|
||||
{
|
||||
PCLASS_POWER_CONTEXT context = CompletionContext;
|
||||
PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
|
||||
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
|
@ -173,20 +162,20 @@ ClasspPowerUpCompletion(
|
|||
|
||||
DebugPrint((1, "ClasspPowerUpCompletion: Device Object %p, Irp %p, "
|
||||
"Context %p\n",
|
||||
DeviceObject, Irp, Context));
|
||||
DeviceObject, Irp, context));
|
||||
|
||||
ASSERT(!TEST_FLAG(Context->Srb.SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
|
||||
ASSERT(!TEST_FLAG(Context->Srb.SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
|
||||
ASSERT(Context->Options.PowerDown == FALSE);
|
||||
ASSERT(Context->Options.HandleSpinUp);
|
||||
ASSERT(!TEST_FLAG(context->Srb.SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
|
||||
ASSERT(!TEST_FLAG(context->Srb.SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
|
||||
ASSERT(context->Options.PowerDown == FALSE);
|
||||
ASSERT(context->Options.HandleSpinUp);
|
||||
|
||||
if(Irp->PendingReturned) {
|
||||
IoMarkIrpPending(Irp);
|
||||
}
|
||||
|
||||
Context->PowerChangeState.PowerUp++;
|
||||
context->PowerChangeState.PowerUp++;
|
||||
|
||||
switch(Context->PowerChangeState.PowerUp) {
|
||||
switch(context->PowerChangeState.PowerUp) {
|
||||
|
||||
case PowerUpDeviceLocked: {
|
||||
|
||||
|
@ -203,13 +192,13 @@ ClasspPowerUpCompletion(
|
|||
// request unless we can ignore failed locks
|
||||
//
|
||||
|
||||
if((Context->Options.LockQueue == TRUE) &&
|
||||
if((context->Options.LockQueue == TRUE) &&
|
||||
(!NT_SUCCESS(Irp->IoStatus.Status))) {
|
||||
|
||||
DebugPrint((1, "(%p)\tIrp status was %lx\n",
|
||||
Irp, Irp->IoStatus.Status));
|
||||
DebugPrint((1, "(%p)\tSrb status was %lx\n",
|
||||
Irp, Context->Srb.SrbStatus));
|
||||
Irp, context->Srb.SrbStatus));
|
||||
|
||||
//
|
||||
// Lock was not successful - throw down the power IRP
|
||||
|
@ -217,8 +206,8 @@ ClasspPowerUpCompletion(
|
|||
// the queue.
|
||||
//
|
||||
|
||||
Context->InUse = FALSE;
|
||||
Context = NULL;
|
||||
context->InUse = FALSE;
|
||||
context = NULL;
|
||||
|
||||
//
|
||||
// Set the new power state
|
||||
|
@ -255,16 +244,16 @@ ClasspPowerUpCompletion(
|
|||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
|
||||
} else {
|
||||
Context->QueueLocked = (UCHAR) Context->Options.LockQueue;
|
||||
context->QueueLocked = (UCHAR) context->Options.LockQueue;
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||
|
||||
Context->PowerChangeState.PowerUp = PowerUpDeviceLocked;
|
||||
context->PowerChangeState.PowerUp = PowerUpDeviceLocked;
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerUpCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
@ -287,42 +276,42 @@ ClasspPowerUpCompletion(
|
|||
// Issue the start unit command to the device.
|
||||
//
|
||||
|
||||
Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
Context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
|
||||
Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0;
|
||||
Context->Srb.DataTransferLength = 0;
|
||||
context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
|
||||
context->Srb.DataTransferLength = 0;
|
||||
|
||||
Context->Srb.TimeOutValue = START_UNIT_TIMEOUT;
|
||||
context->Srb.TimeOutValue = START_UNIT_TIMEOUT;
|
||||
|
||||
Context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
SRB_FLAGS_DISABLE_AUTOSENSE |
|
||||
SRB_FLAGS_DISABLE_SYNCH_TRANSFER |
|
||||
SRB_FLAGS_NO_QUEUE_FREEZE;
|
||||
|
||||
if(Context->Options.LockQueue) {
|
||||
SET_FLAG(Context->Srb.SrbFlags, SRB_FLAGS_BYPASS_LOCKED_QUEUE);
|
||||
if(context->Options.LockQueue) {
|
||||
SET_FLAG(context->Srb.SrbFlags, SRB_FLAGS_BYPASS_LOCKED_QUEUE);
|
||||
}
|
||||
|
||||
Context->Srb.CdbLength = 6;
|
||||
context->Srb.CdbLength = 6;
|
||||
|
||||
cdb = (PCDB) (Context->Srb.Cdb);
|
||||
cdb = (PCDB) (context->Srb.Cdb);
|
||||
RtlZeroMemory(cdb, sizeof(CDB));
|
||||
|
||||
|
||||
cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
|
||||
cdb->START_STOP.Start = 1;
|
||||
|
||||
Context->PowerChangeState.PowerUp = PowerUpDeviceOn;
|
||||
context->PowerChangeState.PowerUp = PowerUpDeviceOn;
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerUpCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
nextStack->Parameters.Scsi.Srb = &(Context->Srb);
|
||||
nextStack->Parameters.Scsi.Srb = &(context->Srb);
|
||||
nextStack->MajorFunction = IRP_MJ_SCSI;
|
||||
|
||||
status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
|
||||
|
@ -335,7 +324,7 @@ ClasspPowerUpCompletion(
|
|||
// we're done.
|
||||
//
|
||||
|
||||
Context->FinalStatus = Irp->IoStatus.Status;
|
||||
context->FinalStatus = Irp->IoStatus.Status;
|
||||
goto ClasspPowerUpCompletionFailure;
|
||||
}
|
||||
|
||||
|
@ -348,32 +337,32 @@ ClasspPowerUpCompletion(
|
|||
// First deal with an error if one occurred.
|
||||
//
|
||||
|
||||
if(SRB_STATUS(Context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
if(SRB_STATUS(context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
|
||||
BOOLEAN retry;
|
||||
|
||||
DebugPrint((1, "%p\tError occured when issuing START_UNIT "
|
||||
"command to device. Srb %p, Status %x\n",
|
||||
Irp,
|
||||
&Context->Srb,
|
||||
Context->Srb.SrbStatus));
|
||||
&context->Srb,
|
||||
context->Srb.SrbStatus));
|
||||
|
||||
ASSERT(!(TEST_FLAG(Context->Srb.SrbStatus,
|
||||
ASSERT(!(TEST_FLAG(context->Srb.SrbStatus,
|
||||
SRB_STATUS_QUEUE_FROZEN)));
|
||||
ASSERT(Context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
ASSERT(context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
|
||||
Context->RetryInterval = 0;
|
||||
context->RetryInterval = 0;
|
||||
|
||||
retry = ClassInterpretSenseInfo(
|
||||
commonExtension->DeviceObject,
|
||||
&Context->Srb,
|
||||
&context->Srb,
|
||||
IRP_MJ_SCSI,
|
||||
IRP_MJ_POWER,
|
||||
MAXIMUM_RETRIES - Context->RetryCount,
|
||||
MAXIMUM_RETRIES - context->RetryCount,
|
||||
&status,
|
||||
&Context->RetryInterval);
|
||||
&context->RetryInterval);
|
||||
|
||||
if((retry == TRUE) && (Context->RetryCount-- != 0)) {
|
||||
if((retry == TRUE) && (context->RetryCount-- != 0)) {
|
||||
|
||||
DebugPrint((1, "(%p)\tRetrying failed request\n", Irp));
|
||||
|
||||
|
@ -382,18 +371,18 @@ ClasspPowerUpCompletion(
|
|||
// next time.
|
||||
//
|
||||
|
||||
Context->PowerChangeState.PowerUp--;
|
||||
context->PowerChangeState.PowerUp--;
|
||||
|
||||
RetryPowerRequest(commonExtension->DeviceObject,
|
||||
Irp,
|
||||
Context);
|
||||
context);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// reset retries
|
||||
Context->RetryCount = MAXIMUM_RETRIES;
|
||||
context->RetryCount = MAXIMUM_RETRIES;
|
||||
|
||||
}
|
||||
|
||||
|
@ -401,22 +390,22 @@ ClasspPowerUpCompletionFailure:
|
|||
|
||||
DebugPrint((1, "(%p)\tPreviously spun device up\n", Irp));
|
||||
|
||||
if (Context->QueueLocked) {
|
||||
if (context->QueueLocked) {
|
||||
DebugPrint((1, "(%p)\tUnlocking queue\n", Irp));
|
||||
|
||||
Context->Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
|
||||
Context->Srb.SrbFlags = SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0;
|
||||
Context->Srb.DataTransferLength = 0;
|
||||
context->Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
|
||||
context->Srb.SrbFlags = SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
|
||||
context->Srb.DataTransferLength = 0;
|
||||
|
||||
nextStack->Parameters.Scsi.Srb = &(Context->Srb);
|
||||
nextStack->Parameters.Scsi.Srb = &(context->Srb);
|
||||
nextStack->MajorFunction = IRP_MJ_SCSI;
|
||||
|
||||
Context->PowerChangeState.PowerUp = PowerUpDeviceStarted;
|
||||
context->PowerChangeState.PowerUp = PowerUpDeviceStarted;
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerUpCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
@ -439,21 +428,21 @@ ClasspPowerUpCompletionFailure:
|
|||
// error conditions ....
|
||||
//
|
||||
|
||||
if (Context->QueueLocked) {
|
||||
if (context->QueueLocked) {
|
||||
DebugPrint((1, "(%p)\tPreviously unlocked queue\n", Irp));
|
||||
ASSERT(NT_SUCCESS(Irp->IoStatus.Status));
|
||||
ASSERT(Context->Srb.SrbStatus == SRB_STATUS_SUCCESS);
|
||||
ASSERT(context->Srb.SrbStatus == SRB_STATUS_SUCCESS);
|
||||
} else {
|
||||
DebugPrint((1, "(%p)\tFall-through (queue not locked)\n", Irp));
|
||||
}
|
||||
|
||||
DebugPrint((1, "(%p)\tFreeing srb and completing\n", Irp));
|
||||
Context->InUse = FALSE;
|
||||
context->InUse = FALSE;
|
||||
|
||||
status = Context->FinalStatus;
|
||||
status = context->FinalStatus;
|
||||
Irp->IoStatus.Status = status;
|
||||
|
||||
Context = NULL;
|
||||
context = NULL;
|
||||
|
||||
//
|
||||
// Set the new power state
|
||||
|
@ -528,9 +517,10 @@ NTAPI
|
|||
ClasspPowerDownCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PCLASS_POWER_CONTEXT Context
|
||||
IN PVOID CompletionContext
|
||||
)
|
||||
{
|
||||
PCLASS_POWER_CONTEXT context = CompletionContext;
|
||||
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
|
||||
PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
|
||||
|
||||
|
@ -541,20 +531,20 @@ ClasspPowerDownCompletion(
|
|||
|
||||
DebugPrint((1, "ClasspPowerDownCompletion: Device Object %p, "
|
||||
"Irp %p, Context %p\n",
|
||||
DeviceObject, Irp, Context));
|
||||
DeviceObject, Irp, context));
|
||||
|
||||
ASSERT(!TEST_FLAG(Context->Srb.SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
|
||||
ASSERT(!TEST_FLAG(Context->Srb.SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
|
||||
ASSERT(Context->Options.PowerDown == TRUE);
|
||||
ASSERT(Context->Options.HandleSpinDown);
|
||||
ASSERT(!TEST_FLAG(context->Srb.SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
|
||||
ASSERT(!TEST_FLAG(context->Srb.SrbFlags, SRB_FLAGS_PORT_DRIVER_ALLOCSENSE));
|
||||
ASSERT(context->Options.PowerDown == TRUE);
|
||||
ASSERT(context->Options.HandleSpinDown);
|
||||
|
||||
if(Irp->PendingReturned) {
|
||||
IoMarkIrpPending(Irp);
|
||||
}
|
||||
|
||||
Context->PowerChangeState.PowerDown2++;
|
||||
context->PowerChangeState.PowerDown2++;
|
||||
|
||||
switch(Context->PowerChangeState.PowerDown2) {
|
||||
switch(context->PowerChangeState.PowerDown2) {
|
||||
|
||||
case PowerDownDeviceLocked2: {
|
||||
|
||||
|
@ -562,7 +552,7 @@ ClasspPowerDownCompletion(
|
|||
|
||||
DebugPrint((1, "(%p)\tPreviously sent power lock\n", Irp));
|
||||
|
||||
if((Context->Options.LockQueue == TRUE) &&
|
||||
if((context->Options.LockQueue == TRUE) &&
|
||||
(!NT_SUCCESS(Irp->IoStatus.Status))) {
|
||||
|
||||
DebugPrint((1, "(%p)\tIrp status was %lx\n",
|
||||
|
@ -570,7 +560,7 @@ ClasspPowerDownCompletion(
|
|||
Irp->IoStatus.Status));
|
||||
DebugPrint((1, "(%p)\tSrb status was %lx\n",
|
||||
Irp,
|
||||
Context->Srb.SrbStatus));
|
||||
context->Srb.SrbStatus));
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||
|
||||
|
@ -580,8 +570,8 @@ ClasspPowerDownCompletion(
|
|||
// the queue.
|
||||
//
|
||||
|
||||
Context->InUse = FALSE;
|
||||
Context = NULL;
|
||||
context->InUse = FALSE;
|
||||
context = NULL;
|
||||
|
||||
//
|
||||
// Set the new power state
|
||||
|
@ -617,7 +607,7 @@ ClasspPowerDownCompletion(
|
|||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
|
||||
} else {
|
||||
Context->QueueLocked = (UCHAR) Context->Options.LockQueue;
|
||||
context->QueueLocked = (UCHAR) context->Options.LockQueue;
|
||||
}
|
||||
|
||||
if (!TEST_FLAG(fdoExtension->PrivateFdoData->HackFlags,
|
||||
|
@ -627,35 +617,35 @@ ClasspPowerDownCompletion(
|
|||
// send SCSIOP_SYNCHRONIZE_CACHE
|
||||
//
|
||||
|
||||
Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
Context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
|
||||
Context->Srb.TimeOutValue = fdoExtension->TimeOutValue;
|
||||
context->Srb.TimeOutValue = fdoExtension->TimeOutValue;
|
||||
|
||||
Context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
SRB_FLAGS_DISABLE_AUTOSENSE |
|
||||
SRB_FLAGS_DISABLE_SYNCH_TRANSFER |
|
||||
SRB_FLAGS_NO_QUEUE_FREEZE |
|
||||
SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
|
||||
Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0;
|
||||
Context->Srb.DataTransferLength = 0;
|
||||
context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
|
||||
context->Srb.DataTransferLength = 0;
|
||||
|
||||
Context->Srb.CdbLength = 10;
|
||||
context->Srb.CdbLength = 10;
|
||||
|
||||
cdb = (PCDB) Context->Srb.Cdb;
|
||||
cdb = (PCDB) context->Srb.Cdb;
|
||||
|
||||
RtlZeroMemory(cdb, sizeof(CDB));
|
||||
cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE;
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerDownCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
nextStack->Parameters.Scsi.Srb = &(Context->Srb);
|
||||
nextStack->Parameters.Scsi.Srb = &(context->Srb);
|
||||
nextStack->MajorFunction = IRP_MJ_SCSI;
|
||||
|
||||
status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
|
||||
|
@ -667,8 +657,8 @@ ClasspPowerDownCompletion(
|
|||
|
||||
DebugPrint((1, "(%p)\tPower Down: not sending SYNCH_CACHE\n",
|
||||
DeviceObject));
|
||||
Context->PowerChangeState.PowerDown2++;
|
||||
Context->Srb.SrbStatus = SRB_STATUS_SUCCESS;
|
||||
context->PowerChangeState.PowerDown2++;
|
||||
context->Srb.SrbStatus = SRB_STATUS_SUCCESS;
|
||||
// and fall through....
|
||||
}
|
||||
// no break in case the device doesn't like synch_cache commands
|
||||
|
@ -686,7 +676,7 @@ ClasspPowerDownCompletion(
|
|||
// SCSIOP_SYNCHRONIZE_CACHE was sent
|
||||
//
|
||||
|
||||
if(SRB_STATUS(Context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
if(SRB_STATUS(context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
|
||||
BOOLEAN retry;
|
||||
|
||||
|
@ -694,24 +684,24 @@ ClasspPowerDownCompletion(
|
|||
"SYNCHRONIZE_CACHE command to device. "
|
||||
"Srb %p, Status %lx\n",
|
||||
Irp,
|
||||
&Context->Srb,
|
||||
Context->Srb.SrbStatus));
|
||||
&context->Srb,
|
||||
context->Srb.SrbStatus));
|
||||
|
||||
ASSERT(!(TEST_FLAG(Context->Srb.SrbStatus,
|
||||
ASSERT(!(TEST_FLAG(context->Srb.SrbStatus,
|
||||
SRB_STATUS_QUEUE_FROZEN)));
|
||||
ASSERT(Context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
ASSERT(context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
|
||||
Context->RetryInterval = 0;
|
||||
context->RetryInterval = 0;
|
||||
retry = ClassInterpretSenseInfo(
|
||||
commonExtension->DeviceObject,
|
||||
&Context->Srb,
|
||||
&context->Srb,
|
||||
IRP_MJ_SCSI,
|
||||
IRP_MJ_POWER,
|
||||
MAXIMUM_RETRIES - Context->RetryCount,
|
||||
MAXIMUM_RETRIES - context->RetryCount,
|
||||
&status,
|
||||
&Context->RetryInterval);
|
||||
&context->RetryInterval);
|
||||
|
||||
if((retry == TRUE) && (Context->RetryCount-- != 0)) {
|
||||
if((retry == TRUE) && (context->RetryCount-- != 0)) {
|
||||
|
||||
DebugPrint((1, "(%p)\tRetrying failed request\n", Irp));
|
||||
|
||||
|
@ -720,15 +710,15 @@ ClasspPowerDownCompletion(
|
|||
// the next time.
|
||||
//
|
||||
|
||||
Context->PowerChangeState.PowerDown2--;
|
||||
context->PowerChangeState.PowerDown2--;
|
||||
RetryPowerRequest(commonExtension->DeviceObject,
|
||||
Irp,
|
||||
Context);
|
||||
context);
|
||||
break;
|
||||
}
|
||||
|
||||
DebugPrint((1, "(%p)\tSYNCHRONIZE_CACHE not retried\n", Irp));
|
||||
Context->RetryCount = MAXIMUM_RETRIES;
|
||||
context->RetryCount = MAXIMUM_RETRIES;
|
||||
|
||||
} // end !SRB_STATUS_SUCCESS
|
||||
|
||||
|
@ -744,23 +734,23 @@ ClasspPowerDownCompletion(
|
|||
// Issue the start unit command to the device.
|
||||
//
|
||||
|
||||
Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
Context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
|
||||
Context->Srb.TimeOutValue = START_UNIT_TIMEOUT;
|
||||
context->Srb.TimeOutValue = START_UNIT_TIMEOUT;
|
||||
|
||||
Context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
|
||||
SRB_FLAGS_DISABLE_AUTOSENSE |
|
||||
SRB_FLAGS_DISABLE_SYNCH_TRANSFER |
|
||||
SRB_FLAGS_NO_QUEUE_FREEZE |
|
||||
SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
|
||||
Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0;
|
||||
Context->Srb.DataTransferLength = 0;
|
||||
context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
|
||||
context->Srb.DataTransferLength = 0;
|
||||
|
||||
Context->Srb.CdbLength = 6;
|
||||
context->Srb.CdbLength = 6;
|
||||
|
||||
cdb = (PCDB) Context->Srb.Cdb;
|
||||
cdb = (PCDB) context->Srb.Cdb;
|
||||
RtlZeroMemory(cdb, sizeof(CDB));
|
||||
|
||||
cdb->START_STOP.OperationCode = SCSIOP_START_STOP_UNIT;
|
||||
|
@ -769,12 +759,12 @@ ClasspPowerDownCompletion(
|
|||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerDownCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
||||
nextStack->Parameters.Scsi.Srb = &(Context->Srb);
|
||||
nextStack->Parameters.Scsi.Srb = &(context->Srb);
|
||||
nextStack->MajorFunction = IRP_MJ_SCSI;
|
||||
|
||||
status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
|
||||
|
@ -792,31 +782,31 @@ ClasspPowerDownCompletion(
|
|||
// stop was sent
|
||||
//
|
||||
|
||||
if(SRB_STATUS(Context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
if(SRB_STATUS(context->Srb.SrbStatus) != SRB_STATUS_SUCCESS) {
|
||||
|
||||
BOOLEAN retry;
|
||||
|
||||
DebugPrint((1, "(%p)\tError occured when issueing STOP_UNIT "
|
||||
"command to device. Srb %p, Status %lx\n",
|
||||
Irp,
|
||||
&Context->Srb,
|
||||
Context->Srb.SrbStatus));
|
||||
&context->Srb,
|
||||
context->Srb.SrbStatus));
|
||||
|
||||
ASSERT(!(TEST_FLAG(Context->Srb.SrbStatus,
|
||||
ASSERT(!(TEST_FLAG(context->Srb.SrbStatus,
|
||||
SRB_STATUS_QUEUE_FROZEN)));
|
||||
ASSERT(Context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
ASSERT(context->Srb.Function == SRB_FUNCTION_EXECUTE_SCSI);
|
||||
|
||||
Context->RetryInterval = 0;
|
||||
context->RetryInterval = 0;
|
||||
retry = ClassInterpretSenseInfo(
|
||||
commonExtension->DeviceObject,
|
||||
&Context->Srb,
|
||||
&context->Srb,
|
||||
IRP_MJ_SCSI,
|
||||
IRP_MJ_POWER,
|
||||
MAXIMUM_RETRIES - Context->RetryCount,
|
||||
MAXIMUM_RETRIES - context->RetryCount,
|
||||
&status,
|
||||
&Context->RetryInterval);
|
||||
&context->RetryInterval);
|
||||
|
||||
if((retry == TRUE) && (Context->RetryCount-- != 0)) {
|
||||
if((retry == TRUE) && (context->RetryCount-- != 0)) {
|
||||
|
||||
DebugPrint((1, "(%p)\tRetrying failed request\n", Irp));
|
||||
|
||||
|
@ -825,15 +815,15 @@ ClasspPowerDownCompletion(
|
|||
// the next time.
|
||||
//
|
||||
|
||||
Context->PowerChangeState.PowerDown2--;
|
||||
context->PowerChangeState.PowerDown2--;
|
||||
RetryPowerRequest(commonExtension->DeviceObject,
|
||||
Irp,
|
||||
Context);
|
||||
context);
|
||||
break;
|
||||
}
|
||||
|
||||
DebugPrint((1, "(%p)\tSTOP_UNIT not retried\n", Irp));
|
||||
Context->RetryCount = MAXIMUM_RETRIES;
|
||||
context->RetryCount = MAXIMUM_RETRIES;
|
||||
|
||||
} // end !SRB_STATUS_SUCCESS
|
||||
|
||||
|
@ -847,17 +837,17 @@ ClasspPowerDownCompletion(
|
|||
|
||||
if (!NT_SUCCESS(status)) {
|
||||
|
||||
PSENSE_DATA senseBuffer = Context->Srb.SenseInfoBuffer;
|
||||
PSENSE_DATA senseBuffer = context->Srb.SenseInfoBuffer;
|
||||
|
||||
if (TEST_FLAG(Context->Srb.SrbStatus,
|
||||
if (TEST_FLAG(context->Srb.SrbStatus,
|
||||
SRB_STATUS_AUTOSENSE_VALID) &&
|
||||
((senseBuffer->SenseKey & 0xf) == SCSI_SENSE_NOT_READY) &&
|
||||
(senseBuffer->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY) &&
|
||||
(senseBuffer->AdditionalSenseCodeQualifier == SCSI_SENSEQ_FORMAT_IN_PROGRESS)
|
||||
) {
|
||||
ignoreError = FALSE;
|
||||
Context->FinalStatus = STATUS_DEVICE_BUSY;
|
||||
status = Context->FinalStatus;
|
||||
context->FinalStatus = STATUS_DEVICE_BUSY;
|
||||
status = context->FinalStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -874,7 +864,7 @@ ClasspPowerDownCompletion(
|
|||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerDownCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
@ -900,23 +890,23 @@ ClasspPowerDownCompletion(
|
|||
|
||||
DebugPrint((1, "(%p)\tPreviously sent power irp\n", Irp));
|
||||
|
||||
if (Context->QueueLocked) {
|
||||
if (context->QueueLocked) {
|
||||
|
||||
DebugPrint((1, "(%p)\tUnlocking queue\n", Irp));
|
||||
|
||||
Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
|
||||
|
||||
Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0;
|
||||
Context->Srb.DataTransferLength = 0;
|
||||
context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
|
||||
context->Srb.DataTransferLength = 0;
|
||||
|
||||
Context->Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
|
||||
Context->Srb.SrbFlags = SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
nextStack->Parameters.Scsi.Srb = &(Context->Srb);
|
||||
context->Srb.Function = SRB_FUNCTION_UNLOCK_QUEUE;
|
||||
context->Srb.SrbFlags = SRB_FLAGS_BYPASS_LOCKED_QUEUE;
|
||||
nextStack->Parameters.Scsi.Srb = &(context->Srb);
|
||||
nextStack->MajorFunction = IRP_MJ_SCSI;
|
||||
|
||||
IoSetCompletionRoutine(Irp,
|
||||
ClasspPowerDownCompletion,
|
||||
Context,
|
||||
context,
|
||||
TRUE,
|
||||
TRUE,
|
||||
TRUE);
|
||||
|
@ -938,18 +928,18 @@ ClasspPowerDownCompletion(
|
|||
// error conditions ....
|
||||
//
|
||||
|
||||
if (Context->QueueLocked == FALSE) {
|
||||
if (context->QueueLocked == FALSE) {
|
||||
DebugPrint((1, "(%p)\tFall through (queue not locked)\n", Irp));
|
||||
} else {
|
||||
DebugPrint((1, "(%p)\tPreviously unlocked queue\n", Irp));
|
||||
ASSERT(NT_SUCCESS(Irp->IoStatus.Status));
|
||||
ASSERT(Context->Srb.SrbStatus == SRB_STATUS_SUCCESS);
|
||||
ASSERT(context->Srb.SrbStatus == SRB_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DebugPrint((1, "(%p)\tFreeing srb and completing\n", Irp));
|
||||
Context->InUse = FALSE;
|
||||
status = Context->FinalStatus; // allow failure to propogate
|
||||
Context = NULL;
|
||||
context->InUse = FALSE;
|
||||
status = context->FinalStatus; // allow failure to propogate
|
||||
context = NULL;
|
||||
|
||||
if(Irp->PendingReturned) {
|
||||
IoMarkIrpPending(Irp);
|
||||
|
|
|
@ -31,7 +31,7 @@ Revision History:
|
|||
#endif
|
||||
|
||||
// custom string match -- careful!
|
||||
BOOLEAN NTAPI ClasspMyStringMatches(IN PCHAR StringToMatch OPTIONAL, IN PCHAR TargetString)
|
||||
BOOLEAN NTAPI ClasspMyStringMatches(IN PCSTR StringToMatch OPTIONAL, IN PCSTR TargetString)
|
||||
{
|
||||
ULONG length; // strlen returns an int, not size_t (!)
|
||||
PAGED_CODE();
|
||||
|
@ -217,10 +217,10 @@ VOID NTAPI ClassScanForSpecial(
|
|||
IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function)
|
||||
{
|
||||
PSTORAGE_DEVICE_DESCRIPTOR deviceDescriptor;
|
||||
PUCHAR vendorId;
|
||||
PUCHAR productId;
|
||||
PUCHAR productRevision;
|
||||
UCHAR nullString[] = "";
|
||||
PCSTR vendorId;
|
||||
PCSTR productId;
|
||||
PCSTR productRevision;
|
||||
CHAR nullString[] = "";
|
||||
//ULONG j;
|
||||
|
||||
PAGED_CODE();
|
||||
|
@ -242,21 +242,21 @@ VOID NTAPI ClassScanForSpecial(
|
|||
|
||||
if (deviceDescriptor->VendorIdOffset != 0 &&
|
||||
deviceDescriptor->VendorIdOffset != -1) {
|
||||
vendorId = ((PUCHAR)deviceDescriptor);
|
||||
vendorId = ((PCSTR)deviceDescriptor);
|
||||
vendorId += deviceDescriptor->VendorIdOffset;
|
||||
} else {
|
||||
vendorId = nullString;
|
||||
}
|
||||
if (deviceDescriptor->ProductIdOffset != 0 &&
|
||||
deviceDescriptor->ProductIdOffset != -1) {
|
||||
productId = ((PUCHAR)deviceDescriptor);
|
||||
productId = ((PCSTR)deviceDescriptor);
|
||||
productId += deviceDescriptor->ProductIdOffset;
|
||||
} else {
|
||||
productId = nullString;
|
||||
}
|
||||
if (deviceDescriptor->VendorIdOffset != 0 &&
|
||||
deviceDescriptor->VendorIdOffset != -1) {
|
||||
productRevision = ((PUCHAR)deviceDescriptor);
|
||||
productRevision = ((PCSTR)deviceDescriptor);
|
||||
productRevision += deviceDescriptor->ProductRevisionOffset;
|
||||
} else {
|
||||
productRevision = nullString;
|
||||
|
@ -342,7 +342,7 @@ ClasspPerfIncrementErrorCount(
|
|||
KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
|
||||
|
||||
fdoData->Perf.SuccessfulIO = 0; // implicit interlock
|
||||
errors = InterlockedIncrement(&FdoExtension->ErrorCount);
|
||||
errors = InterlockedIncrement((PLONG)&FdoExtension->ErrorCount);
|
||||
|
||||
if (errors >= CLASS_ERROR_LEVEL_1) {
|
||||
|
||||
|
@ -405,7 +405,7 @@ ClasspPerfIncrementSuccessfulIo(
|
|||
return;
|
||||
}
|
||||
|
||||
succeeded = InterlockedIncrement(&fdoData->Perf.SuccessfulIO);
|
||||
succeeded = InterlockedIncrement((PLONG)&fdoData->Perf.SuccessfulIO);
|
||||
if (succeeded < fdoData->Perf.ReEnableThreshhold) {
|
||||
return;
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ ClasspPerfIncrementSuccessfulIo(
|
|||
fdoData->Perf.SuccessfulIO = 0; // implicit interlock
|
||||
|
||||
ASSERT(FdoExtension->ErrorCount > 0);
|
||||
errors = InterlockedDecrement(&FdoExtension->ErrorCount);
|
||||
errors = InterlockedDecrement((PLONG)&FdoExtension->ErrorCount);
|
||||
|
||||
//
|
||||
// note: do in reverse order of the sets "just in case"
|
||||
|
|
|
@ -107,7 +107,7 @@ NTSTATUS NTAPI InitializeTransferPackets(PDEVICE_OBJECT Fdo)
|
|||
while (fdoData->NumFreeTransferPackets < MIN_INITIAL_TRANSFER_PACKETS){
|
||||
PTRANSFER_PACKET pkt = NewTransferPacket(Fdo);
|
||||
if (pkt){
|
||||
InterlockedIncrement(&fdoData->NumTotalTransferPackets);
|
||||
InterlockedIncrement((PLONG)&fdoData->NumTotalTransferPackets);
|
||||
EnqueueFreeTransferPacket(Fdo, pkt);
|
||||
}
|
||||
else {
|
||||
|
@ -142,9 +142,9 @@ VOID NTAPI DestroyAllTransferPackets(PDEVICE_OBJECT Fdo)
|
|||
|
||||
ASSERT(IsListEmpty(&fdoData->DeferredClientIrpList));
|
||||
|
||||
while (pkt = DequeueFreeTransferPacket(Fdo, FALSE)){
|
||||
while ((pkt = DequeueFreeTransferPacket(Fdo, FALSE))){
|
||||
DestroyTransferPacket(pkt);
|
||||
InterlockedDecrement(&fdoData->NumTotalTransferPackets);
|
||||
InterlockedDecrement((PLONG)&fdoData->NumTotalTransferPackets);
|
||||
}
|
||||
|
||||
ASSERT(fdoData->NumTotalTransferPackets == 0);
|
||||
|
@ -225,7 +225,7 @@ VOID NTAPI EnqueueFreeTransferPacket(PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt)
|
|||
ASSERT(!Pkt->SlistEntry.Next);
|
||||
|
||||
InterlockedPushEntrySList(&fdoData->FreeTransferPacketsList, &Pkt->SlistEntry);
|
||||
newNumPkts = InterlockedIncrement(&fdoData->NumFreeTransferPackets);
|
||||
newNumPkts = InterlockedIncrement((PLONG)&fdoData->NumFreeTransferPackets);
|
||||
ASSERT(newNumPkts <= fdoData->NumTotalTransferPackets);
|
||||
|
||||
/*
|
||||
|
@ -264,7 +264,7 @@ VOID NTAPI EnqueueFreeTransferPacket(PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt)
|
|||
pktToDelete = DequeueFreeTransferPacket(Fdo, FALSE);
|
||||
if (pktToDelete){
|
||||
SimplePushSlist(&pktList, &pktToDelete->SlistEntry);
|
||||
InterlockedDecrement(&fdoData->NumTotalTransferPackets);
|
||||
InterlockedDecrement((PLONG)&fdoData->NumTotalTransferPackets);
|
||||
}
|
||||
else {
|
||||
DBGTRACE(ClassDebugTrace, ("Extremely unlikely condition (non-fatal): %d packets dequeued at once for Fdo %p. NumTotalTransferPackets=%d (1).", MaxWorkingSetTransferPackets, Fdo, fdoData->NumTotalTransferPackets));
|
||||
|
@ -273,7 +273,7 @@ VOID NTAPI EnqueueFreeTransferPacket(PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt)
|
|||
}
|
||||
KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
|
||||
|
||||
while (slistEntry = SimplePopSlist(&pktList)){
|
||||
while ((slistEntry = SimplePopSlist(&pktList))){
|
||||
pktToDelete = CONTAINING_RECORD(slistEntry, TRANSFER_PACKET, SlistEntry);
|
||||
DestroyTransferPacket(pktToDelete);
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ VOID NTAPI EnqueueFreeTransferPacket(PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt)
|
|||
|
||||
pktToDelete = DequeueFreeTransferPacket(Fdo, FALSE);
|
||||
if (pktToDelete){
|
||||
InterlockedDecrement(&fdoData->NumTotalTransferPackets);
|
||||
InterlockedDecrement((PLONG)&fdoData->NumTotalTransferPackets);
|
||||
}
|
||||
else {
|
||||
DBGTRACE(ClassDebugTrace, ("Extremely unlikely condition (non-fatal): %d packets dequeued at once for Fdo %p. NumTotalTransferPackets=%d (2).", MinWorkingSetTransferPackets, Fdo, fdoData->NumTotalTransferPackets));
|
||||
|
@ -333,7 +333,7 @@ PTRANSFER_PACKET NTAPI DequeueFreeTransferPacket(PDEVICE_OBJECT Fdo, BOOLEAN All
|
|||
slistEntry->Next = NULL;
|
||||
pkt = CONTAINING_RECORD(slistEntry, TRANSFER_PACKET, SlistEntry);
|
||||
ASSERT(fdoData->NumFreeTransferPackets > 0);
|
||||
InterlockedDecrement(&fdoData->NumFreeTransferPackets);
|
||||
InterlockedDecrement((PLONG)&fdoData->NumFreeTransferPackets);
|
||||
}
|
||||
else {
|
||||
if (AllocIfNeeded){
|
||||
|
@ -345,7 +345,7 @@ PTRANSFER_PACKET NTAPI DequeueFreeTransferPacket(PDEVICE_OBJECT Fdo, BOOLEAN All
|
|||
*/
|
||||
pkt = NewTransferPacket(Fdo);
|
||||
if (pkt){
|
||||
InterlockedIncrement(&fdoData->NumTotalTransferPackets);
|
||||
InterlockedIncrement((PLONG)&fdoData->NumTotalTransferPackets);
|
||||
fdoData->DbgPeakNumTransferPackets = max(fdoData->DbgPeakNumTransferPackets, fdoData->NumTotalTransferPackets);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1134,12 +1134,7 @@ NTAPI
|
|||
ClassReleaseChildLock(
|
||||
_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ClassSignalCompletion(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
PKEVENT Event);
|
||||
IO_COMPLETION_ROUTINE ClassSignalCompletion;
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
|
|
Loading…
Reference in a new issue