IN ULONG CountDown
);
-VOID
-NTAPI
-ClasspFailurePredict(
- IN PDEVICE_OBJECT DeviceObject,
- IN PFAILURE_PREDICTION_INFO Info
- );
+IO_WORKITEM_ROUTINE ClasspFailurePredict;
NTSTATUS
NTAPI
SET_FLAG(FdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME);
}
- InterlockedIncrement(&FdoExtension->MediaChangeCount);
+ InterlockedIncrement((PLONG)&FdoExtension->MediaChangeCount);
ClasspSetMediaChangeStateEx(FdoExtension,
MediaPresent,
FALSE,
)
{
#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;
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;
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));
/*
* 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;
}
}
// 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,
// 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);
}
//
//
ASSERT(IoGetNextIrpStackLocation(Irp));
- IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = Srb;
+ IoGetNextIrpStackLocation(Irp)->Parameters.Scsi.Srb = srb;
//
// Reset the MCN timer.
//
PWSTR nullMultiSz;
- PUCHAR vendorId;
- PUCHAR productId;
- PUCHAR revisionId;
+ PCSTR vendorId;
+ PCSTR productId;
+ PCSTR revisionId;
ULONG length;
ULONG offset;
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);
}
deviceString.Length = (USHORT)( length );
deviceString.MaximumLength = deviceString.Length + 1;
- deviceString.Buffer = (PUCHAR)ExAllocatePoolWithTag( NonPagedPool,
- deviceString.MaximumLength,
- CLASS_TAG_AUTORUN_DISABLE
- );
+ deviceString.Buffer = ExAllocatePoolWithTag( NonPagedPool,
+ deviceString.MaximumLength,
+ CLASS_TAG_AUTORUN_DISABLE
+ );
if (deviceString.Buffer == NULL) {
DebugPrint((ClassDebugMCN,
"ClassMediaChangeDisabledForHardware: Unable to alloc "
//
ClassDisableMediaChangeDetection(FdoExtension);
- InterlockedIncrement(&(fsContext->McnDisableCount));
+ InterlockedIncrement((PLONG)&fsContext->McnDisableCount);
} else {
LEAVE;
}
- InterlockedDecrement(&(fsContext->McnDisableCount));
+ InterlockedDecrement((PLONG)&fsContext->McnDisableCount);
ClassEnableMediaChangeDetection(FdoExtension);
}
// 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",
DebugPrint((1, "ClassTimerTick: Couldn't allocate "
"item - try again in one minute\n"));
- InterlockedExchange(&info->CountDown, 60);
+ InterlockedExchange((PLONG)&info->CountDown, 60);
} else {
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;
NTSTATUS status;
- ASSERT(Info != NULL);
+ ASSERT(info != NULL);
DebugPrint((1, "ClasspFailurePredict: Polling for failure\n"));
// 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)) {
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) {
status = IoAllocateDriverObjectExtension(DriverObject,
CLASS_DRIVER_EXTENSION_KEY,
sizeof(CLASS_DRIVER_EXTENSION),
- &driverExtension);
+ (PVOID *)&driverExtension);
if(NT_SUCCESS(status)) {
if (NT_SUCCESS(status)) {
IoAdjustPagingPathCount(
- &commonExtension->PagingPathCount,
+ (PLONG)&commonExtension->PagingPathCount,
irpStack->Parameters.UsageNotification.InPath);
if (irpStack->Parameters.UsageNotification.InPath) {
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
);
}
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
);
}
status = ClassGetDescriptor(
commonExtension->LowerDeviceObject,
&propertyId,
- &fdoExtension->AdapterDescriptor);
+ (PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->AdapterDescriptor);
if(!NT_SUCCESS(status)) {
status = ClassGetDescriptor(
commonExtension->LowerDeviceObject,
&propertyId,
- &fdoExtension->DeviceDescriptor);
+ (PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->DeviceDescriptor);
if(!NT_SUCCESS(status)) {
ClassAcquireRemoveLock(Fdo, irp);
IoSetCompletionRoutine(irp,
- (PIO_COMPLETION_ROUTINE)ClassAsynchronousCompletion,
+ ClassAsynchronousCompletion,
context,
TRUE,
TRUE,
// 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));
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.
IN BOOLEAN Use6Byte
)
{
- PUCHAR limit;
+ PCHAR limit;
ULONG parameterHeaderLength;
PVOID result = NULL;
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;
// one.
//
- if(InterlockedIncrement(&(fdoExtension->EnumerationInterlock)) == 1) {
+ if(InterlockedIncrement((PLONG)&fdoExtension->EnumerationInterlock) == 1) {
status = driverExtension->InitData.ClassEnumerateDevice(Fdo);
}
Fdo,
BusRelations,
(PDEVICE_RELATIONS*)&Irp->IoStatus.Information);
- InterlockedDecrement(&(fdoExtension->EnumerationInterlock));
+ InterlockedDecrement((PLONG)&fdoExtension->EnumerationInterlock);
return Irp->IoStatus.Status;
} // end ClassPnpQueryFdoRelations()
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)) {
* 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
NTSTATUS status;
SCSI_ADDRESS scsiAddress;
OBJECT_ATTRIBUTES objectAttributes;
- PUCHAR buffer;
+ PSTR buffer;
STRING string;
UNICODE_STRING unicodeName;
UNICODE_STRING unicodeRegistryPath;
RtlInitUnicodeString(&unicodeName, L"DeviceName");
- sprintf(buffer, "%s%d", DeviceName, DeviceNumber);
+ sprintf(buffer, "%s%lu", DeviceName, DeviceNumber);
RtlInitString(&string, buffer);
status = RtlAnsiStringToUnicodeString(&unicodeData,
&string,
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;
KIRQL irql;
- commonExtension = DeviceObject->DeviceExtension;
+ commonExtension = deviceObject->DeviceExtension;
ASSERT(commonExtension->IsFdo);
- fdoExtension = DeviceObject->DeviceExtension;
+ fdoExtension = deviceObject->DeviceExtension;
fdoData = fdoExtension->PrivateFdoData;
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
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;
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: {
// 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
// the queue.
//
- Context->InUse = FALSE;
- Context = NULL;
+ context->InUse = FALSE;
+ context = NULL;
//
// Set the new power state
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);
// 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);
// we're done.
//
- Context->FinalStatus = Irp->IoStatus.Status;
+ context->FinalStatus = Irp->IoStatus.Status;
goto ClasspPowerUpCompletionFailure;
}
// 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));
// 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;
}
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;
-
- nextStack->Parameters.Scsi.Srb = &(Context->Srb);
+ 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->MajorFunction = IRP_MJ_SCSI;
- Context->PowerChangeState.PowerUp = PowerUpDeviceStarted;
+ context->PowerChangeState.PowerUp = PowerUpDeviceStarted;
IoSetCompletionRoutine(Irp,
ClasspPowerUpCompletion,
- Context,
+ context,
TRUE,
TRUE,
TRUE);
// 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
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;
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: {
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",
Irp->IoStatus.Status));
DebugPrint((1, "(%p)\tSrb status was %lx\n",
Irp,
- Context->Srb.SrbStatus));
+ context->Srb.SrbStatus));
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
// the queue.
//
- Context->InUse = FALSE;
- Context = NULL;
+ context->InUse = FALSE;
+ context = NULL;
//
// Set the new power state
return STATUS_MORE_PROCESSING_REQUIRED;
} else {
- Context->QueueLocked = (UCHAR) Context->Options.LockQueue;
+ context->QueueLocked = (UCHAR) context->Options.LockQueue;
}
if (!TEST_FLAG(fdoExtension->PrivateFdoData->HackFlags,
//
// send SCSIOP_SYNCHRONIZE_CACHE
//
-
- Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
- Context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
-
- Context->Srb.TimeOutValue = fdoExtension->TimeOutValue;
-
- Context->Srb.SrbFlags = SRB_FLAGS_NO_DATA_TRANSFER |
+
+ context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
+ context->Srb.Function = SRB_FUNCTION_EXECUTE_SCSI;
+
+ context->Srb.TimeOutValue = fdoExtension->TimeOutValue;
+
+ 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.CdbLength = 10;
-
- cdb = (PCDB) Context->Srb.Cdb;
-
+
+ context->Srb.SrbStatus = context->Srb.ScsiStatus = 0;
+ context->Srb.DataTransferLength = 0;
+
+ context->Srb.CdbLength = 10;
+
+ 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);
-
+
DebugPrint((1, "(%p)\tIoCallDriver returned %lx\n", Irp, status));
break;
-
+
} else {
-
+
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
// 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;
"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));
// 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
// 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;
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);
// 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));
// 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
//
if (!NT_SUCCESS(status)) {
-
- PSENSE_DATA senseBuffer = Context->Srb.SenseInfoBuffer;
-
- if (TEST_FLAG(Context->Srb.SrbStatus,
+
+ PSENSE_DATA senseBuffer = context->Srb.SenseInfoBuffer;
+
+ 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;
}
}
IoSetCompletionRoutine(Irp,
ClasspPowerDownCompletion,
- Context,
+ context,
TRUE,
TRUE,
TRUE);
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.SrbStatus = Context->Srb.ScsiStatus = 0;
- Context->Srb.DataTransferLength = 0;
+ context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK);
+
+ 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);
// 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);