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