revert 49345 as requested by ros arm team.

svn path=/branches/cmake-bringup/; revision=49373
This commit is contained in:
Jérôme Gardou 2010-10-31 10:42:40 +00:00
parent d1dfa87850
commit b3346b150f
8 changed files with 235 additions and 348 deletions

View file

@ -148,14 +148,14 @@ ClassSendEjectionNotification(
// ejection request occured, we could see if any locks for the media // ejection request occured, we could see if any locks for the media
// existed. if locked, broadcast. if not, we send the eject irp. // existed. if locked, broadcast. if not, we send the eject irp.
// //
// //
// for now, just always broadcast. make this a public routine, // for now, just always broadcast. make this a public routine,
// so class drivers can add special hacks to broadcast this for their // so class drivers can add special hacks to broadcast this for their
// non-MMC-compliant devices also from sense codes. // non-MMC-compliant devices also from sense codes.
// //
DBGTRACE(ClassDebugTrace, ("ClassSendEjectionNotification: media EJECT_REQUEST")); DBGTRACE(ClassDebugTrace, ("ClassSendEjectionNotification: media EJECT_REQUEST"));
ClasspSendNotification(FdoExtension, ClasspSendNotification(FdoExtension,
&GUID_IO_MEDIA_EJECT_REQUEST, &GUID_IO_MEDIA_EJECT_REQUEST,
0, 0,
@ -174,7 +174,7 @@ ClasspSendNotification(
{ {
PTARGET_DEVICE_CUSTOM_NOTIFICATION notification; PTARGET_DEVICE_CUSTOM_NOTIFICATION notification;
ULONG requiredSize; ULONG requiredSize;
requiredSize = requiredSize =
(sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION) - sizeof(UCHAR)) + (sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION) - sizeof(UCHAR)) +
ExtraDataSize; ExtraDataSize;
@ -186,11 +186,11 @@ ClasspSendNotification(
requiredSize)); requiredSize));
return; return;
} }
notification = ExAllocatePoolWithTag(NonPagedPool, notification = ExAllocatePoolWithTag(NonPagedPool,
requiredSize, requiredSize,
'oNcS'); 'oNcS');
// //
// if none allocated, exit // if none allocated, exit
// //
@ -202,7 +202,7 @@ ClasspSendNotification(
// //
// Prepare and send the request! // Prepare and send the request!
// //
RtlZeroMemory(notification, requiredSize); RtlZeroMemory(notification, requiredSize);
notification->Version = 1; notification->Version = 1;
notification->Size = (USHORT)(requiredSize); notification->Size = (USHORT)(requiredSize);
@ -214,7 +214,7 @@ ClasspSendNotification(
IoReportTargetDeviceChangeAsynchronous(FdoExtension->LowerPdo, IoReportTargetDeviceChangeAsynchronous(FdoExtension->LowerPdo,
notification, notification,
NULL, NULL); NULL, NULL);
ExFreePool(notification); ExFreePool(notification);
notification = NULL; notification = NULL;
return; return;
@ -236,7 +236,7 @@ Routine Description:
Arguments: Arguments:
FdoExtension - the device FdoExtension - the device
DataBuffer - the resulting data from a GESN event. DataBuffer - the resulting data from a GESN event.
requires at least EIGHT valid bytes (header == 4, data == 4) requires at least EIGHT valid bytes (header == 4, data == 4)
@ -245,14 +245,14 @@ Arguments:
event was of the DEVICE BUSY class, else true. event was of the DEVICE BUSY class, else true.
Return Value: Return Value:
None None
Notes: Notes:
DataBuffer must be at least four bytes of valid data (header == 4 bytes), DataBuffer must be at least four bytes of valid data (header == 4 bytes),
and have at least eight bytes of allocated memory (all events == 4 bytes). and have at least eight bytes of allocated memory (all events == 4 bytes).
The call to StartNextPacket may occur before this routine is completed. The call to StartNextPacket may occur before this routine is completed.
the operational change notifications are informational in nature, and the operational change notifications are informational in nature, and
while useful, are not neccessary to ensure proper operation. For example, while useful, are not neccessary to ensure proper operation. For example,
@ -261,12 +261,12 @@ Notes:
IOCTL_IS_DISK_WRITABLE may be called and get an incorrect response. If IOCTL_IS_DISK_WRITABLE may be called and get an incorrect response. If
a device supports software write protect, it is expected that the a device supports software write protect, it is expected that the
application can handle such a case. application can handle such a case.
NOTE: perhaps setting the updaterequired byte to one should be done here. NOTE: perhaps setting the updaterequired byte to one should be done here.
if so, it relies upon the setting of a 32-byte value to be an atomic if so, it relies upon the setting of a 32-byte value to be an atomic
operation. unfortunately, there is no simple way to notify a class driver operation. unfortunately, there is no simple way to notify a class driver
which wants to know that the device behavior requires updating. which wants to know that the device behavior requires updating.
Not ready events may be sent every second. For example, if we were Not ready events may be sent every second. For example, if we were
to minimize the number of asynchronous notifications, an application may to minimize the number of asynchronous notifications, an application may
register just after a large busy time was reported. This would then register just after a large busy time was reported. This would then
@ -339,7 +339,7 @@ ClasspInterpretGesnData(
lowestSetBit ^= (info->Gesn.EventMask); lowestSetBit ^= (info->Gesn.EventMask);
if (thisEventBit != lowestSetBit) { if (thisEventBit != lowestSetBit) {
// //
// HACKHACK - REF #0001 // HACKHACK - REF #0001
// the first time we ever see an event set that is not the lowest // the first time we ever see an event set that is not the lowest
@ -352,11 +352,11 @@ ClasspInterpretGesnData(
"Classpnp => GESN::NONE: Compliant drive found, " "Classpnp => GESN::NONE: Compliant drive found, "
"removing GESN hack (%x, %x)\n", "removing GESN hack (%x, %x)\n",
thisEventBit, info->Gesn.EventMask)); thisEventBit, info->Gesn.EventMask));
info->Gesn.HackEventMask = FALSE; info->Gesn.HackEventMask = FALSE;
} else if (thisEvent == 0) { } else if (thisEvent == 0) {
// //
// HACKHACK - REF #0001 // HACKHACK - REF #0001
// note: this hack prevents poorly implemented firmware from constantly // note: this hack prevents poorly implemented firmware from constantly
@ -409,13 +409,13 @@ ClasspInterpretGesnData(
&GUID_IO_GENERIC_GESN_EVENT, &GUID_IO_GENERIC_GESN_EVENT,
sizeof(NOTIFICATION_EVENT_STATUS_HEADER) + dataLength, sizeof(NOTIFICATION_EVENT_STATUS_HEADER) + dataLength,
Header) Header)
*/ */
switch (Header->NotificationClass) { switch (Header->NotificationClass) {
case NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS: { // 0x3 case NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS: { // 0x3
PNOTIFICATION_EXTERNAL_STATUS externalInfo = PNOTIFICATION_EXTERNAL_STATUS externalInfo =
(PNOTIFICATION_EXTERNAL_STATUS)(Header->ClassEventData); (PNOTIFICATION_EXTERNAL_STATUS)(Header->ClassEventData);
DEVICE_EVENT_EXTERNAL_REQUEST externalData; DEVICE_EVENT_EXTERNAL_REQUEST externalData;
@ -424,12 +424,12 @@ ClasspInterpretGesnData(
// about keys being pressed, and not released. this makes keys // about keys being pressed, and not released. this makes keys
// single-function, but simplifies the code significantly. // single-function, but simplifies the code significantly.
// //
if (externalInfo->ExternalEvent != if (externalInfo->ExternalEvent !=
NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN) { NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN) {
break; break;
} }
*ResendImmediately = TRUE; *ResendImmediately = TRUE;
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN::EXTERNAL: Event: %x Status %x Req %x\n", "Classpnp => GESN::EXTERNAL: Event: %x Status %x Req %x\n",
@ -447,28 +447,28 @@ ClasspInterpretGesnData(
KeQuerySystemTime(&(externalData.SystemTime)); KeQuerySystemTime(&(externalData.SystemTime));
externalData.SystemTime.QuadPart *= (LONGLONG)KeQueryTimeIncrement(); externalData.SystemTime.QuadPart *= (LONGLONG)KeQueryTimeIncrement();
DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media DEVICE_EXTERNAL_REQUEST")); DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media DEVICE_EXTERNAL_REQUEST"));
ClasspSendNotification(FdoExtension, ClasspSendNotification(FdoExtension,
&GUID_IO_DEVICE_EXTERNAL_REQUEST, &GUID_IO_DEVICE_EXTERNAL_REQUEST,
sizeof(DEVICE_EVENT_EXTERNAL_REQUEST), sizeof(DEVICE_EVENT_EXTERNAL_REQUEST),
&externalData); &externalData);
return; return;
} }
case NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS: { // 0x4 case NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS: { // 0x4
PNOTIFICATION_MEDIA_STATUS mediaInfo = PNOTIFICATION_MEDIA_STATUS mediaInfo =
(PNOTIFICATION_MEDIA_STATUS)(Header->ClassEventData); (PNOTIFICATION_MEDIA_STATUS)(Header->ClassEventData);
if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NO_CHANGE) { if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NO_CHANGE) {
break; break;
} }
*ResendImmediately = TRUE; *ResendImmediately = TRUE;
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN::MEDIA: Event: %x Status %x\n", "Classpnp => GESN::MEDIA: Event: %x Status %x\n",
mediaInfo->MediaEvent, mediaInfo->MediaStatus)); mediaInfo->MediaEvent, mediaInfo->MediaStatus));
if ((mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NEW_MEDIA) || if ((mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NEW_MEDIA) ||
(mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE)) { (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE)) {
@ -489,29 +489,29 @@ ClasspInterpretGesnData(
TRUE); TRUE);
} else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL) { } else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL) {
ClasspSetMediaChangeStateEx(FdoExtension, ClasspSetMediaChangeStateEx(FdoExtension,
MediaNotPresent, MediaNotPresent,
FALSE, FALSE,
TRUE); TRUE);
} else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST) { } else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST) {
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugError, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugError,
"Classpnp => GESN Ejection request received!\n")); "Classpnp => GESN Ejection request received!\n"));
ClassSendEjectionNotification(FdoExtension); ClassSendEjectionNotification(FdoExtension);
} }
break; break;
} }
case NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS: { // lowest priority events... case NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS: { // lowest priority events...
PNOTIFICATION_BUSY_STATUS busyInfo = PNOTIFICATION_BUSY_STATUS busyInfo =
(PNOTIFICATION_BUSY_STATUS)(Header->ClassEventData); (PNOTIFICATION_BUSY_STATUS)(Header->ClassEventData);
DEVICE_EVENT_BECOMING_READY busyData; DEVICE_EVENT_BECOMING_READY busyData;
// //
// NOTE: we never actually need to immediately retry for these // NOTE: we never actually need to immediately retry for these
// events: if one exists, the device is busy, and if not, // events: if one exists, the device is busy, and if not,
@ -521,7 +521,7 @@ ClasspInterpretGesnData(
if (busyInfo->DeviceBusyStatus == NOTIFICATION_BUSY_STATUS_NO_EVENT) { if (busyInfo->DeviceBusyStatus == NOTIFICATION_BUSY_STATUS_NO_EVENT) {
break; break;
} }
// //
// else we want to report the approximated time till it's ready. // else we want to report the approximated time till it's ready.
// //
@ -531,28 +531,28 @@ ClasspInterpretGesnData(
busyData.Reason = busyInfo->DeviceBusyStatus; busyData.Reason = busyInfo->DeviceBusyStatus;
busyData.Estimated100msToReady = (busyInfo->Time[0] << 8) | busyData.Estimated100msToReady = (busyInfo->Time[0] << 8) |
(busyInfo->Time[1] & 0xff); (busyInfo->Time[1] & 0xff);
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN::BUSY: Event: %x Status %x Time %x\n", "Classpnp => GESN::BUSY: Event: %x Status %x Time %x\n",
busyInfo->DeviceBusyEvent, busyInfo->DeviceBusyStatus, busyInfo->DeviceBusyEvent, busyInfo->DeviceBusyStatus,
busyData.Estimated100msToReady busyData.Estimated100msToReady
)); ));
DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media BECOMING_READY")); DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media BECOMING_READY"));
ClasspSendNotification(FdoExtension, ClasspSendNotification(FdoExtension,
&GUID_IO_DEVICE_BECOMING_READY, &GUID_IO_DEVICE_BECOMING_READY,
sizeof(DEVICE_EVENT_BECOMING_READY), sizeof(DEVICE_EVENT_BECOMING_READY),
&busyData); &busyData);
break; break;
} }
default: { default: {
break; break;
} }
} // end switch on notification class } // end switch on notification class
return; return;
} }
@ -577,7 +577,7 @@ Arguments:
MediaPresent - indicates whether the device has media inserted into it MediaPresent - indicates whether the device has media inserted into it
(TRUE) or not (FALSE). (TRUE) or not (FALSE).
Return Value: Return Value:
none none
@ -656,7 +656,7 @@ ClasspInternalSetMediaChangeState(
sizeof(ULONG), sizeof(ULONG),
&data); &data);
} }
else if (NewState == MediaNotPresent) { else if (NewState == MediaNotPresent) {
DBGTRACE(ClassDebugTrace, ("ClasspInternalSetMediaChangeState: media REMOVAL")); DBGTRACE(ClassDebugTrace, ("ClasspInternalSetMediaChangeState: media REMOVAL"));
@ -673,7 +673,7 @@ ClasspInternalSetMediaChangeState(
return; return;
} }
return; return;
} // end ClasspInternalSetMediaChangeState() } // end ClasspInternalSetMediaChangeState()
@ -769,10 +769,7 @@ ClasspSetMediaChangeStateEx(
return; return;
} // end ClassSetMediaChangeStateEx() } // end ClassSetMediaChangeStateEx()
SCSIPORTAPI
VOID VOID
NTAPI
ClassSetMediaChangeState( ClassSetMediaChangeState(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN MEDIA_CHANGE_DETECTION_STATE NewState, IN MEDIA_CHANGE_DETECTION_STATE NewState,
@ -836,11 +833,11 @@ ClasspMediaChangeDetectionCompletion(
/* /*
* HACK for IoMega 2GB Jaz drive: * HACK for IoMega 2GB Jaz drive:
* This drive spins down on its own to preserve the media. * This drive spins down on its own to preserve the media.
* When spun down, TUR fails with 2/4/0 (SCSI_SENSE_NOT_READY/SCSI_ADSENSE_LUN_NOT_READY/?). * When spun down, TUR fails with 2/4/0 (SCSI_SENSE_NOT_READY/SCSI_ADSENSE_LUN_NOT_READY/?).
* ClassInterpretSenseInfo would then call ClassSendStartUnit to spin the media up, which defeats the * ClassInterpretSenseInfo would then call ClassSendStartUnit to spin the media up, which defeats the
* purpose of the spindown. * purpose of the spindown.
* So in this case, make this into a successful TUR. * So in this case, make this into a successful TUR.
* This allows the drive to stay spun down until it is actually accessed again. * This allows the drive to stay spun down until it is actually accessed again.
* (If the media were actually removed, TUR would fail with 2/3a/0 ). * (If the media were actually removed, TUR would fail with 2/3a/0 ).
* 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
@ -849,15 +846,15 @@ ClasspMediaChangeDetectionCompletion(
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;
} }
} }
// //
// use ClassInterpretSenseInfo() to check for media state, and also // use ClassInterpretSenseInfo() to check for media state, and also
@ -876,15 +873,15 @@ ClasspMediaChangeDetectionCompletion(
&status, &status,
NULL); NULL);
} }
else { else {
fdoData->LoggedTURFailureSinceLastIO = FALSE; fdoData->LoggedTURFailureSinceLastIO = FALSE;
if (!info->Gesn.Supported) { if (!info->Gesn.Supported) {
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded and GESN NOT supported, setting MediaPresent.")); DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded and GESN NOT supported, setting MediaPresent."));
// //
// success != media for GESN case // success != media for GESN case
// //
@ -896,7 +893,7 @@ ClasspMediaChangeDetectionCompletion(
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded (GESN supported).")); DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded (GESN supported)."));
} }
} }
if (info->Gesn.Supported) { if (info->Gesn.Supported) {
if (status == STATUS_DATA_OVERRUN) { if (status == STATUS_DATA_OVERRUN) {
@ -904,7 +901,7 @@ ClasspMediaChangeDetectionCompletion(
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
} }
if (!NT_SUCCESS(status)) { if (!NT_SUCCESS(status)) {
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion: GESN failed with status %x", status)); DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion: GESN failed with status %x", status));
} else { } else {
@ -912,7 +909,7 @@ ClasspMediaChangeDetectionCompletion(
// for GESN, need to interpret the results of the data. // for GESN, need to interpret the results of the data.
// this may also require an immediate retry // this may also require an immediate retry
// //
if (Irp->IoStatus.Information == 8 ) { if (Irp->IoStatus.Information == 8 ) {
ClasspInterpretGesnData(fdoExtension, ClasspInterpretGesnData(fdoExtension,
(PVOID)info->Gesn.Buffer, (PVOID)info->Gesn.Buffer,
@ -949,7 +946,7 @@ ClasspMediaChangeDetectionCompletion(
// //
if (retryImmediately) { if (retryImmediately) {
info->MediaChangeRetryCount++; info->MediaChangeRetryCount++;
if (info->MediaChangeRetryCount > MAXIMUM_IMMEDIATE_MCN_RETRIES) { if (info->MediaChangeRetryCount > MAXIMUM_IMMEDIATE_MCN_RETRIES) {
ASSERT(!"Recursing too often in MCN?"); ASSERT(!"Recursing too often in MCN?");
@ -958,7 +955,7 @@ ClasspMediaChangeDetectionCompletion(
} }
} else { } else {
info->MediaChangeRetryCount = 0; info->MediaChangeRetryCount = 0;
} }
@ -973,7 +970,7 @@ ClasspMediaChangeDetectionCompletion(
ClassAcquireRemoveLock(DeviceObject, (PIRP)(&uniqueValue)); ClassAcquireRemoveLock(DeviceObject, (PIRP)(&uniqueValue));
ClassReleaseRemoveLock(DeviceObject, Irp); ClassReleaseRemoveLock(DeviceObject, Irp);
// //
// set the irp as not in use // set the irp as not in use
// //
@ -995,18 +992,18 @@ ClasspMediaChangeDetectionCompletion(
else { else {
DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - not retrying immediately")); DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - not retrying immediately"));
} }
// //
// release the temporary remove lock // release the temporary remove lock
// //
ClassReleaseRemoveLock(DeviceObject, (PIRP)(&uniqueValue)); ClassReleaseRemoveLock(DeviceObject, (PIRP)(&uniqueValue));
} }
DBGTRACE(ClassDebugMCN, ("< ClasspMediaChangeDetectionCompletion")); DBGTRACE(ClassDebugMCN, ("< ClasspMediaChangeDetectionCompletion"));
return STATUS_MORE_PROCESSING_REQUIRED; return STATUS_MORE_PROCESSING_REQUIRED;
} }
/*++//////////////////////////////////////////////////////////////////////////// /*++////////////////////////////////////////////////////////////////////////////
@ -1018,8 +1015,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -1060,7 +1057,7 @@ ClasspPrepareMcnIrp(
if (status == REMOVE_COMPLETE) { if (status == REMOVE_COMPLETE) {
ASSERT(status != REMOVE_COMPLETE); ASSERT(status != REMOVE_COMPLETE);
return NULL; return NULL;
} }
else if (status == REMOVE_PENDING) { else if (status == REMOVE_PENDING) {
ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp); ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp);
return NULL; return NULL;
@ -1108,12 +1105,12 @@ ClasspPrepareMcnIrp(
srb->ScsiStatus = 0; srb->ScsiStatus = 0;
srb->OriginalRequest = irp; srb->OriginalRequest = irp;
srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE; srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
srb->SrbFlags = FdoExtension->SrbFlags; srb->SrbFlags = FdoExtension->SrbFlags;
SET_FLAG(srb->SrbFlags, Info->SrbFlags); SET_FLAG(srb->SrbFlags, Info->SrbFlags);
srb->TimeOutValue = FdoExtension->TimeOutValue * 2; srb->TimeOutValue = FdoExtension->TimeOutValue * 2;
if (srb->TimeOutValue == 0) { if (srb->TimeOutValue == 0) {
if (FdoExtension->TimeOutValue == 0) { if (FdoExtension->TimeOutValue == 0) {
@ -1122,9 +1119,9 @@ ClasspPrepareMcnIrp(
"ClassSendTestUnitIrp: FdoExtension->TimeOutValue " "ClassSendTestUnitIrp: FdoExtension->TimeOutValue "
"is set to zero?! -- resetting to 10\n")); "is set to zero?! -- resetting to 10\n"));
srb->TimeOutValue = 10 * 2; // reasonable default srb->TimeOutValue = 10 * 2; // reasonable default
} else { } else {
KdPrintEx((DPFLTR_CLASSPNP_ID, DPFLTR_ERROR_LEVEL, KdPrintEx((DPFLTR_CLASSPNP_ID, DPFLTR_ERROR_LEVEL,
"ClassSendTestUnitIrp: Someone set " "ClassSendTestUnitIrp: Someone set "
"srb->TimeOutValue to zero?! -- resetting to %x\n", "srb->TimeOutValue to zero?! -- resetting to %x\n",
@ -1134,9 +1131,9 @@ ClasspPrepareMcnIrp(
} }
} }
if (!UseGesn) { if (!UseGesn) {
srb->CdbLength = 6; srb->CdbLength = 6;
srb->DataTransferLength = 0; srb->DataTransferLength = 0;
SET_FLAG(srb->SrbFlags, SRB_FLAGS_NO_DATA_TRANSFER); SET_FLAG(srb->SrbFlags, SRB_FLAGS_NO_DATA_TRANSFER);
@ -1145,16 +1142,16 @@ ClasspPrepareMcnIrp(
srb->DataBuffer = NULL; srb->DataBuffer = NULL;
srb->DataTransferLength = 0; srb->DataTransferLength = 0;
irp->MdlAddress = NULL; irp->MdlAddress = NULL;
cdb = (PCDB) &srb->Cdb[0]; cdb = (PCDB) &srb->Cdb[0];
cdb->CDB6GENERIC.OperationCode = SCSIOP_TEST_UNIT_READY; cdb->CDB6GENERIC.OperationCode = SCSIOP_TEST_UNIT_READY;
} else { } else {
ASSERT(Info->Gesn.Buffer); ASSERT(Info->Gesn.Buffer);
srb->TimeOutValue = GESN_TIMEOUT_VALUE; // much shorter timeout for GESN srb->TimeOutValue = GESN_TIMEOUT_VALUE; // much shorter timeout for GESN
srb->CdbLength = 10; srb->CdbLength = 10;
SET_FLAG(srb->SrbFlags, SRB_FLAGS_DATA_IN); SET_FLAG(srb->SrbFlags, SRB_FLAGS_DATA_IN);
nextIrpStack->Parameters.DeviceIoControl.IoControlCode = nextIrpStack->Parameters.DeviceIoControl.IoControlCode =
@ -1197,8 +1194,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -1349,7 +1346,7 @@ ClasspSendMediaStateIrp(
// device object directly or to the device's StartIo // device object directly or to the device's StartIo
// routine (which doesn't acquire the lock). // routine (which doesn't acquire the lock).
// //
requestPending = TRUE; requestPending = TRUE;
DBGTRACE(ClassDebugMCN, (" ClasspSendMediaStateIrp - calling IoCallDriver.")); DBGTRACE(ClassDebugMCN, (" ClasspSendMediaStateIrp - calling IoCallDriver."));
@ -1368,7 +1365,7 @@ ClasspSendMediaStateIrp(
} }
DBGTRACE(ClassDebugMCN, ("< ClasspSendMediaStateIrp")); DBGTRACE(ClassDebugMCN, ("< ClasspSendMediaStateIrp"));
return; return;
} // end ClasspSendMediaStateIrp() } // end ClasspSendMediaStateIrp()
@ -1391,9 +1388,7 @@ Return Value:
none none
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassCheckMediaState( ClassCheckMediaState(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -1434,7 +1429,7 @@ ClassResetMediaChangeTimer()
Routine Description: Routine Description:
Resets the media change count down timer to the default number of seconds. Resets the media change count down timer to the default number of seconds.
Arguments: Arguments:
FdoExtension - the device to reset the timer for FdoExtension - the device to reset the timer for
@ -1444,9 +1439,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassResetMediaChangeTimer( ClassResetMediaChangeTimer(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -1470,8 +1463,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -1509,11 +1502,11 @@ ClasspInitializePolling(
/* /*
* Allocate an IRP to carry the Test-Unit-Ready. * Allocate an IRP to carry the Test-Unit-Ready.
* Allocate an extra IRP stack location * Allocate an extra IRP stack location
* so we can cache our device object in the top location. * so we can cache our device object in the top location.
*/ */
irp = IoAllocateIrp((CCHAR)(fdo->StackSize+1), FALSE); irp = IoAllocateIrp((CCHAR)(fdo->StackSize+1), FALSE);
if (irp != NULL) { if (irp != NULL) {
PVOID buffer; PVOID buffer;
@ -1634,7 +1627,7 @@ ClasspInitializePolling(
"ClasspInitializePolling: GESN *NOT* available " "ClasspInitializePolling: GESN *NOT* available "
"for %p\n", FdoExtension->DeviceObject)); "for %p\n", FdoExtension->DeviceObject));
} }
ASSERT(info->Gesn.Supported == 0); ASSERT(info->Gesn.Supported == 0);
ASSERT(info->Gesn.Buffer == NULL); ASSERT(info->Gesn.Buffer == NULL);
ASSERT(info->Gesn.BufferSize == 0); ASSERT(info->Gesn.BufferSize == 0);
@ -1661,7 +1654,7 @@ ClasspInitializeGesn(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN PMEDIA_CHANGE_DETECTION_INFO Info IN PMEDIA_CHANGE_DETECTION_INFO Info
) )
{ {
PNOTIFICATION_EVENT_STATUS_HEADER header; PNOTIFICATION_EVENT_STATUS_HEADER header;
CLASS_DETECTION_STATE detectionState = ClassDetectionUnknown; CLASS_DETECTION_STATE detectionState = ClassDetectionUnknown;
PSTORAGE_ADAPTER_DESCRIPTOR adapterDescriptor; PSTORAGE_ADAPTER_DESCRIPTOR adapterDescriptor;
@ -1672,7 +1665,7 @@ ClasspInitializeGesn(
ULONG i; ULONG i;
ULONG atapiResets; ULONG atapiResets;
PAGED_CODE(); PAGED_CODE();
ASSERT(Info == FdoExtension->MediaChangeDetectionInfo); ASSERT(Info == FdoExtension->MediaChangeDetectionInfo);
@ -1684,7 +1677,7 @@ ClasspInitializeGesn(
CLASSP_REG_SUBKEY_NAME, CLASSP_REG_SUBKEY_NAME,
CLASSP_REG_MMC_DETECTION_VALUE_NAME, CLASSP_REG_MMC_DETECTION_VALUE_NAME,
(PULONG)&detectionState); (PULONG)&detectionState);
if (detectionState == ClassDetectionUnsupported) { if (detectionState == ClassDetectionUnsupported) {
goto ExitWithError; goto ExitWithError;
} }
@ -1695,7 +1688,7 @@ ClasspInitializeGesn(
if (TEST_FLAG(FdoExtension->PrivateFdoData->HackFlags, if (TEST_FLAG(FdoExtension->PrivateFdoData->HackFlags,
FDO_HACK_GESN_IS_BAD)) { FDO_HACK_GESN_IS_BAD)) {
detectionState = ClassDetectionUnsupported; detectionState = ClassDetectionUnsupported;
ClassSetDeviceParameter(FdoExtension, ClassSetDeviceParameter(FdoExtension,
CLASSP_REG_SUBKEY_NAME, CLASSP_REG_SUBKEY_NAME,
@ -1707,7 +1700,7 @@ ClasspInitializeGesn(
// //
// else go through the process since we allocate buffers and // else go through the process since we allocate buffers and
// get all sorts of device settings. // get all sorts of device settings.
// //
@ -1750,7 +1743,7 @@ ClasspInitializeGesn(
atapiResets = 0; atapiResets = 0;
retryImmediately = TRUE; retryImmediately = TRUE;
for (i = 0; i < 16 && retryImmediately == TRUE; i++) { for (i = 0; i < 16 && retryImmediately == TRUE; i++) {
irp = ClasspPrepareMcnIrp(FdoExtension, Info, TRUE); irp = ClasspPrepareMcnIrp(FdoExtension, Info, TRUE);
if (irp == NULL) { if (irp == NULL) {
status = STATUS_INSUFFICIENT_RESOURCES; status = STATUS_INSUFFICIENT_RESOURCES;
@ -1758,19 +1751,19 @@ ClasspInitializeGesn(
} }
ASSERT(TEST_FLAG(Info->MediaChangeSrb.SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE)); ASSERT(TEST_FLAG(Info->MediaChangeSrb.SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE));
// //
// replace the completion routine with a different one this time... // replace the completion routine with a different one this time...
// //
IoSetCompletionRoutine(irp, IoSetCompletionRoutine(irp,
ClassSignalCompletion, ClassSignalCompletion,
&event, &event,
TRUE, TRUE, TRUE); TRUE, TRUE, TRUE);
KeInitializeEvent(&event, SynchronizationEvent, FALSE); KeInitializeEvent(&event, SynchronizationEvent, FALSE);
status = IoCallDriver(FdoExtension->CommonExtension.LowerDeviceObject, irp); status = IoCallDriver(FdoExtension->CommonExtension.LowerDeviceObject, irp);
if (status == STATUS_PENDING) { if (status == STATUS_PENDING) {
status = KeWaitForSingleObject(&event, status = KeWaitForSingleObject(&event,
Executive, Executive,
@ -1780,7 +1773,7 @@ ClasspInitializeGesn(
ASSERT(NT_SUCCESS(status)); ASSERT(NT_SUCCESS(status));
} }
ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp); ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp);
if (SRB_STATUS(Info->MediaChangeSrb.SrbStatus) != SRB_STATUS_SUCCESS) { if (SRB_STATUS(Info->MediaChangeSrb.SrbStatus) != SRB_STATUS_SUCCESS) {
ClassInterpretSenseInfo(FdoExtension->DeviceObject, ClassInterpretSenseInfo(FdoExtension->DeviceObject,
&(Info->MediaChangeSrb), &(Info->MediaChangeSrb),
@ -1815,18 +1808,18 @@ ClasspInitializeGesn(
if (status == STATUS_DATA_OVERRUN) { if (status == STATUS_DATA_OVERRUN) {
status = STATUS_SUCCESS; status = STATUS_SUCCESS;
} }
if ((status == STATUS_INVALID_DEVICE_REQUEST) || if ((status == STATUS_INVALID_DEVICE_REQUEST) ||
(status == STATUS_TIMEOUT) || (status == STATUS_TIMEOUT) ||
(status == STATUS_IO_DEVICE_ERROR) || (status == STATUS_IO_DEVICE_ERROR) ||
(status == STATUS_IO_TIMEOUT) (status == STATUS_IO_TIMEOUT)
) { ) {
// //
// with these error codes, we don't ever want to try this command // with these error codes, we don't ever want to try this command
// again on this device, since it reacts poorly. // again on this device, since it reacts poorly.
// //
ClassSetDeviceParameter(FdoExtension, ClassSetDeviceParameter(FdoExtension,
CLASSP_REG_SUBKEY_NAME, CLASSP_REG_SUBKEY_NAME,
CLASSP_REG_MMC_DETECTION_VALUE_NAME, CLASSP_REG_MMC_DETECTION_VALUE_NAME,
@ -1836,9 +1829,9 @@ ClasspInitializeGesn(
status, FdoExtension->DeviceObject)); status, FdoExtension->DeviceObject));
goto ExitWithError; goto ExitWithError;
} }
if (!NT_SUCCESS(status)) { if (!NT_SUCCESS(status)) {
// //
@ -1851,21 +1844,21 @@ ClasspInitializeGesn(
status, FdoExtension->DeviceObject)); status, FdoExtension->DeviceObject));
goto ExitWithError; goto ExitWithError;
} }
if (i == 0) { if (i == 0) {
// //
// the first time, the request was just retrieving a mask of // the first time, the request was just retrieving a mask of
// available bits. use this to mask future requests. // available bits. use this to mask future requests.
// //
header = (PNOTIFICATION_EVENT_STATUS_HEADER)(Info->Gesn.Buffer); header = (PNOTIFICATION_EVENT_STATUS_HEADER)(Info->Gesn.Buffer);
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => Fdo %p supports event mask %x\n", "Classpnp => Fdo %p supports event mask %x\n",
FdoExtension->DeviceObject, header->SupportedEventClasses)); FdoExtension->DeviceObject, header->SupportedEventClasses));
if (TEST_FLAG(header->SupportedEventClasses, if (TEST_FLAG(header->SupportedEventClasses,
NOTIFICATION_MEDIA_STATUS_CLASS_MASK)) { NOTIFICATION_MEDIA_STATUS_CLASS_MASK)) {
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
@ -1886,13 +1879,13 @@ ClasspInitializeGesn(
// therefore, we should not bother querying for the other, // therefore, we should not bother querying for the other,
// unknown events. clear all but the above flags. // unknown events. clear all but the above flags.
// //
Info->Gesn.EventMask &= Info->Gesn.EventMask &=
NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK | NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK |
NOTIFICATION_MEDIA_STATUS_CLASS_MASK | NOTIFICATION_MEDIA_STATUS_CLASS_MASK |
NOTIFICATION_DEVICE_BUSY_CLASS_MASK ; NOTIFICATION_DEVICE_BUSY_CLASS_MASK ;
// //
// HACKHACK - REF #0001 // HACKHACK - REF #0001
// Some devices will *never* report an event if we've also requested // Some devices will *never* report an event if we've also requested
@ -1906,7 +1899,7 @@ ClasspInitializeGesn(
// drives, default to enabling the hack until we find evidence of // drives, default to enabling the hack until we find evidence of
// proper firmware. // proper firmware.
// //
if (CountOfSetBitsUChar(Info->Gesn.EventMask) == 1) { if (CountOfSetBitsUChar(Info->Gesn.EventMask) == 1) {
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN hack %s for FDO %p\n", "Classpnp => GESN hack %s for FDO %p\n",
@ -1919,7 +1912,7 @@ ClasspInitializeGesn(
} }
} else { } else {
// //
// not the first time looping through, so interpret the results. // not the first time looping through, so interpret the results.
// //
@ -1942,13 +1935,13 @@ ClasspInitializeGesn(
// since we also rely upon NOT_READY events to change the cursor // since we also rely upon NOT_READY events to change the cursor
// into a "wait" cursor, we can't use GESN without NOT_READY support. // into a "wait" cursor, we can't use GESN without NOT_READY support.
// //
if (TEST_FLAG(Info->Gesn.EventMask, if (TEST_FLAG(Info->Gesn.EventMask,
NOTIFICATION_MEDIA_STATUS_CLASS_MASK) && NOTIFICATION_MEDIA_STATUS_CLASS_MASK) &&
TEST_FLAG(Info->Gesn.EventMask, TEST_FLAG(Info->Gesn.EventMask,
NOTIFICATION_DEVICE_BUSY_CLASS_MASK) NOTIFICATION_DEVICE_BUSY_CLASS_MASK)
) { ) {
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => Enabling GESN support for fdo %p\n", "Classpnp => Enabling GESN support for fdo %p\n",
FdoExtension->DeviceObject)); FdoExtension->DeviceObject));
@ -1962,7 +1955,7 @@ ClasspInitializeGesn(
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN,
"Classpnp => GESN available but not enabled for fdo %p\n", "Classpnp => GESN available but not enabled for fdo %p\n",
FdoExtension->DeviceObject)); FdoExtension->DeviceObject));
@ -2001,18 +1994,16 @@ Routine Description:
Arguments: Arguments:
FdoExtension is the device to poll FdoExtension is the device to poll
AllowDriveToSleep says whether to attempt to allow the drive to sleep AllowDriveToSleep says whether to attempt to allow the drive to sleep
or not. This only affects system-known spin down states, so if a or not. This only affects system-known spin down states, so if a
drive spins itself down, this has no effect until the system spins drive spins itself down, this has no effect until the system spins
it down. it down.
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassInitializeTestUnitPolling( ClassInitializeTestUnitPolling(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN BOOLEAN AllowDriveToSleep IN BOOLEAN AllowDriveToSleep
@ -2031,24 +2022,22 @@ Routine Description:
to autorun) for a given device. It will then check the device-type wide to autorun) for a given device. It will then check the device-type wide
key "Autorun" in the service key (for legacy reasons), and then look in key "Autorun" in the service key (for legacy reasons), and then look in
the device-specific key to potentially override that setting. the device-specific key to potentially override that setting.
If MCN is to be enabled, all neccessary structures and memory are If MCN is to be enabled, all neccessary structures and memory are
allocated and initialized. allocated and initialized.
This routine MUST be called only from the ClassInit() callback. This routine MUST be called only from the ClassInit() callback.
Arguments: Arguments:
FdoExtension - the device to initialize MCN for, if appropriate FdoExtension - the device to initialize MCN for, if appropriate
EventPrefix - unused, legacy argument. Set to zero. EventPrefix - unused, legacy argument. Set to zero.
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassInitializeMediaChangeDetection( ClassInitializeMediaChangeDetection(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN PUCHAR EventPrefix IN PUCHAR EventPrefix
@ -2119,7 +2108,7 @@ ClassInitializeMediaChangeDetection(
if (disabled) { if (disabled) {
return; return;
} }
// //
// if the drive is not a CDROM, allow the drive to sleep // if the drive is not a CDROM, allow the drive to sleep
// //
@ -2672,7 +2661,7 @@ ClasspIsMediaChangeDisabledForClass(
} }
ZwClose(serviceKey); ZwClose(serviceKey);
DebugPrint((ClassDebugMCN, "ClassCheckServiceMCN: " DebugPrint((ClassDebugMCN, "ClassCheckServiceMCN: "
"Autoplay for device %p is %s\n", "Autoplay for device %p is %s\n",
FdoExtension->DeviceObject, FdoExtension->DeviceObject,
@ -2698,15 +2687,13 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassEnableMediaChangeDetection( ClassEnableMediaChangeDetection(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -2782,17 +2769,15 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
--*/ --*/
ULONG BreakOnMcnDisable = FALSE; ULONG BreakOnMcnDisable = FALSE;
SCSIPORTAPI
VOID VOID
NTAPI
ClassDisableMediaChangeDetection( ClassDisableMediaChangeDetection(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -2837,9 +2822,7 @@ Arguments:
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassCleanupMediaChangeDetection( ClassCleanupMediaChangeDetection(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -2853,7 +2836,7 @@ ClassCleanupMediaChangeDetection(
} }
FdoExtension->MediaChangeDetectionInfo = NULL; FdoExtension->MediaChangeDetectionInfo = NULL;
if (info->Gesn.Buffer) { if (info->Gesn.Buffer) {
ExFreePool(info->Gesn.Buffer); ExFreePool(info->Gesn.Buffer);
} }
@ -2873,8 +2856,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -3067,8 +3050,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -3214,8 +3197,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -3264,8 +3247,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -3317,8 +3300,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -3450,9 +3433,7 @@ Arguments:
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassNotifyFailurePredicted( ClassNotifyFailurePredicted(
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
PUCHAR Buffer, PUCHAR Buffer,
@ -3535,9 +3516,7 @@ Return Value:
NT Status NT Status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSetFailurePredictionPoll( ClassSetFailurePredictionPoll(
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
FAILURE_PREDICTION_METHOD FailurePredictionMethod, FAILURE_PREDICTION_METHOD FailurePredictionMethod,

View file

@ -115,9 +115,7 @@ Return Value:
A valid return code for a DriverEntry routine. A valid return code for a DriverEntry routine.
--*/ --*/
SCSIPORTAPI
ULONG ULONG
NTAPI
ClassInitialize( ClassInitialize(
IN PVOID Argument1, IN PVOID Argument1,
IN PVOID Argument2, IN PVOID Argument2,
@ -132,7 +130,7 @@ ClassInitialize(
NTSTATUS status; NTSTATUS status;
PAGED_CODE(); PAGED_CODE();
DebugPrint((3,"\n\nSCSI Class Driver\n")); DebugPrint((3,"\n\nSCSI Class Driver\n"));
ClasspInitializeDebugGlobals(); ClasspInitializeDebugGlobals();
@ -363,9 +361,7 @@ Return Value:
Status Code Status Code
--*/ --*/
SCSIPORTAPI
ULONG ULONG
NTAPI
ClassInitializeEx( ClassInitializeEx(
IN PDRIVER_OBJECT DriverObject, IN PDRIVER_OBJECT DriverObject,
IN LPGUID Guid, IN LPGUID Guid,
@ -1729,10 +1725,7 @@ Return Value:
Status is returned. Status is returned.
--*/ --*/
SCSIPORTAPI NTSTATUS ClassReadDriveCapacity(IN PDEVICE_OBJECT Fdo)
NTSTATUS
NTAPI
ClassReadDriveCapacity(IN PDEVICE_OBJECT Fdo)
{ {
READ_CAPACITY_DATA readCapacityBuffer = {0}; READ_CAPACITY_DATA readCapacityBuffer = {0};
NTSTATUS status; NTSTATUS status;
@ -2015,9 +2008,7 @@ Return Value:
None. None.
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassSendStartUnit( ClassSendStartUnit(
IN PDEVICE_OBJECT Fdo IN PDEVICE_OBJECT Fdo
) )
@ -2170,9 +2161,7 @@ Return Value:
None. None.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassAsynchronousCompletion( ClassAsynchronousCompletion(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp, PIRP Irp,
@ -2438,9 +2427,7 @@ Return Value:
NT status NT status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassIoComplete( ClassIoComplete(
IN PDEVICE_OBJECT Fdo, IN PDEVICE_OBJECT Fdo,
IN PIRP Irp, IN PIRP Irp,
@ -2656,9 +2643,7 @@ Return Value:
Srb->DataTransferLength Srb->DataTransferLength
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSendSrbSynchronous( ClassSendSrbSynchronous(
PDEVICE_OBJECT Fdo, PDEVICE_OBJECT Fdo,
PSCSI_REQUEST_BLOCK Srb, PSCSI_REQUEST_BLOCK Srb,
@ -3004,9 +2989,7 @@ Return Value:
FALSE: Drivers should not retry this request. FALSE: Drivers should not retry this request.
--*/ --*/
SCSIPORTAPI
BOOLEAN BOOLEAN
NTAPI
ClassInterpretSenseInfo( ClassInterpretSenseInfo(
IN PDEVICE_OBJECT Fdo, IN PDEVICE_OBJECT Fdo,
IN PSCSI_REQUEST_BLOCK Srb, IN PSCSI_REQUEST_BLOCK Srb,
@ -4070,7 +4053,7 @@ ClassInterpretSenseInfo(
/* /*
* If logError is set, also save this log in the system's error log. * If logError is set, also save this log in the system's error log.
* But make sure we don't log TUR failures over and over * But make sure we don't log TUR failures over and over
* (e.g. if an external drive was switched off and we're still sending TUR's to it every second). * (e.g. if an external drive was switched off and we're still sending TUR's to it every second).
*/ */
if ((((PCDB)Srb->Cdb)->CDB10.OperationCode == SCSIOP_TEST_UNIT_READY) && logError){ if ((((PCDB)Srb->Cdb)->CDB10.OperationCode == SCSIOP_TEST_UNIT_READY) && logError){
@ -4078,7 +4061,7 @@ ClassInterpretSenseInfo(
logError = FALSE; logError = FALSE;
} }
else { else {
fdoData->LoggedTURFailureSinceLastIO = TRUE; fdoData->LoggedTURFailureSinceLastIO = TRUE;
} }
} }
if (logError){ if (logError){
@ -4137,10 +4120,7 @@ Return Value:
Length of the transferred data is returned. Length of the transferred data is returned.
--*/ --*/
SCSIPORTAPI ULONG ClassModeSense( IN PDEVICE_OBJECT Fdo,
ULONG
NTAPI
ClassModeSense( IN PDEVICE_OBJECT Fdo,
IN PCHAR ModeSenseBuffer, IN PCHAR ModeSenseBuffer,
IN ULONG Length, IN ULONG Length,
IN UCHAR PageMode) IN UCHAR PageMode)
@ -4226,9 +4206,7 @@ Return Value:
then NULL is return. then NULL is return.
--*/ --*/
SCSIPORTAPI
PVOID PVOID
NTAPI
ClassFindModePage( ClassFindModePage(
IN PCHAR ModeSenseBuffer, IN PCHAR ModeSenseBuffer,
IN ULONG Length, IN ULONG Length,
@ -4339,9 +4317,7 @@ Return Value:
or returns a status value to indicate why it failed. or returns a status value to indicate why it failed.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSendSrbAsynchronous( ClassSendSrbAsynchronous(
PDEVICE_OBJECT Fdo, PDEVICE_OBJECT Fdo,
PSCSI_REQUEST_BLOCK Srb, PSCSI_REQUEST_BLOCK Srb,
@ -4609,9 +4585,7 @@ Return Value:
Returns back a STATUS_PENDING or a completion status. Returns back a STATUS_PENDING or a completion status.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassDeviceControl( ClassDeviceControl(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PIRP Irp PIRP Irp
@ -5634,7 +5608,6 @@ Return Value:
--*/ --*/
NTSTATUS NTSTATUS
NTAPI
ClassShutdownFlush( ClassShutdownFlush(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp IN PIRP Irp
@ -5707,9 +5680,7 @@ Return Value:
NTSTATUS NTSTATUS
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassCreateDeviceObject( ClassCreateDeviceObject(
IN PDRIVER_OBJECT DriverObject, IN PDRIVER_OBJECT DriverObject,
IN PCCHAR ObjectNameBuffer, IN PCCHAR ObjectNameBuffer,
@ -6006,9 +5977,7 @@ Return Value:
Returns a status indicating success or failure of the operation. Returns a status indicating success or failure of the operation.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassClaimDevice( ClassClaimDevice(
IN PDEVICE_OBJECT LowerDeviceObject, IN PDEVICE_OBJECT LowerDeviceObject,
IN BOOLEAN Release IN BOOLEAN Release
@ -6139,9 +6108,7 @@ Return Value:
Returns back a STATUS_PENDING or a completion status. Returns back a STATUS_PENDING or a completion status.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassInternalIoControl( ClassInternalIoControl(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp IN PIRP Irp
@ -6213,9 +6180,7 @@ Return Value:
None, but it sets a new default timeout for a class of devices. None, but it sets a new default timeout for a class of devices.
--*/ --*/
SCSIPORTAPI
ULONG ULONG
NTAPI
ClassQueryTimeOutRegistryValue( ClassQueryTimeOutRegistryValue(
IN PDEVICE_OBJECT DeviceObject IN PDEVICE_OBJECT DeviceObject
) )
@ -6322,9 +6287,7 @@ Return Value:
NT status NT status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassCheckVerifyComplete( ClassCheckVerifyComplete(
IN PDEVICE_OBJECT Fdo, IN PDEVICE_OBJECT Fdo,
IN PIRP Irp, IN PIRP Irp,
@ -6389,9 +6352,7 @@ Return Value:
buffer allocated on behalf of the caller. buffer allocated on behalf of the caller.
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassGetDescriptor( ClassGetDescriptor(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PSTORAGE_PROPERTY_ID PropertyId, IN PSTORAGE_PROPERTY_ID PropertyId,
@ -6540,9 +6501,7 @@ Return Value:
STATUS_MORE_PROCESSING_REQUIRED STATUS_MORE_PROCESSING_REQUIRED
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSignalCompletion( ClassSignalCompletion(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,
@ -6629,9 +6588,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassMarkChildrenMissing( ClassMarkChildrenMissing(
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo IN PFUNCTIONAL_DEVICE_EXTENSION Fdo
) )
@ -6683,9 +6640,7 @@ Return Value:
to PNP. to PNP.
--*/ --*/
SCSIPORTAPI
BOOLEAN BOOLEAN
NTAPI
ClassMarkChildMissing( ClassMarkChildMissing(
IN PPHYSICAL_DEVICE_EXTENSION Child, IN PPHYSICAL_DEVICE_EXTENSION Child,
IN BOOLEAN AcquireChildLock IN BOOLEAN AcquireChildLock
@ -6939,9 +6894,7 @@ Return Value:
none none
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassInvalidateBusRelations( ClassInvalidateBusRelations(
IN PDEVICE_OBJECT Fdo IN PDEVICE_OBJECT Fdo
) )
@ -6996,9 +6949,7 @@ Return Value:
status status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassRemoveDevice( ClassRemoveDevice(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN UCHAR RemoveType IN UCHAR RemoveType
@ -7262,9 +7213,7 @@ Return Value:
Either NULL if none, or a pointer to the driver extension Either NULL if none, or a pointer to the driver extension
--*/ --*/
SCSIPORTAPI
PCLASS_DRIVER_EXTENSION PCLASS_DRIVER_EXTENSION
NTAPI
ClassGetDriverExtension( ClassGetDriverExtension(
IN PDRIVER_OBJECT DriverObject IN PDRIVER_OBJECT DriverObject
) )
@ -7348,9 +7297,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassUpdateInformationInRegistry( ClassUpdateInformationInRegistry(
IN PDEVICE_OBJECT Fdo, IN PDEVICE_OBJECT Fdo,
IN PCHAR DeviceName, IN PCHAR DeviceName,
@ -7687,9 +7634,7 @@ Arguments:
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassSendDeviceIoControlSynchronous( ClassSendDeviceIoControlSynchronous(
IN ULONG IoControlCode, IN ULONG IoControlCode,
IN PDEVICE_OBJECT TargetDeviceObject, IN PDEVICE_OBJECT TargetDeviceObject,
@ -7946,9 +7891,7 @@ Arguments:
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassForwardIrpSynchronous( ClassForwardIrpSynchronous(
IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PCOMMON_DEVICE_EXTENSION CommonExtension,
IN PIRP Irp IN PIRP Irp
@ -7977,9 +7920,7 @@ Arguments:
Return Value: Return Value:
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSendIrpSynchronous( ClassSendIrpSynchronous(
IN PDEVICE_OBJECT TargetDeviceObject, IN PDEVICE_OBJECT TargetDeviceObject,
IN PIRP Irp IN PIRP Irp
@ -8078,9 +8019,7 @@ Return Value:
the VPB, or NULL if none. the VPB, or NULL if none.
--*/ --*/
SCSIPORTAPI
PVPB PVPB
NTAPI
ClassGetVpb( ClassGetVpb(
IN PDEVICE_OBJECT DeviceObject IN PDEVICE_OBJECT DeviceObject
) )
@ -8189,9 +8128,7 @@ Return Value:
None. None.
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassReleaseQueue( ClassReleaseQueue(
IN PDEVICE_OBJECT Fdo IN PDEVICE_OBJECT Fdo
) )
@ -8511,9 +8448,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassAcquireChildLock( ClassAcquireChildLock(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )
@ -8555,9 +8490,7 @@ Return Value:
None. None.
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassReleaseChildLock( ClassReleaseChildLock(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
) )

View file

@ -424,7 +424,7 @@ struct _CLASS_PRIVATE_FDO_DATA {
BOOLEAN TimerStarted; BOOLEAN TimerStarted;
BOOLEAN LoggedTURFailureSinceLastIO; BOOLEAN LoggedTURFailureSinceLastIO;
// //
// privately allocated release queue irp // privately allocated release queue irp
// protected by fdoExtension->ReleaseQueueSpinLock // protected by fdoExtension->ReleaseQueueSpinLock
@ -508,7 +508,6 @@ static inline BOOLEAN SimpleIsSlistEmpty(SINGLE_LIST_ENTRY *SListHdr)
} }
NTSTATUS NTSTATUS
NTAPI
DriverEntry( DriverEntry(
IN PDRIVER_OBJECT DriverObject, IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath IN PUNICODE_STRING RegistryPath
@ -556,6 +555,12 @@ ClassDeviceControlDispatch(
PIRP Irp PIRP Irp
); );
NTSTATUS
ClassDeviceControl(
PDEVICE_OBJECT DeviceObject,
PIRP Irp
);
NTSTATUS NTSTATUS
ClassDispatchPnp( ClassDispatchPnp(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
@ -568,7 +573,12 @@ ClassPnpStartDevice(
); );
NTSTATUS NTSTATUS
NTAPI ClassInternalIoControl (
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ClassShutdownFlush( ClassShutdownFlush(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp IN PIRP Irp

View file

@ -256,14 +256,14 @@ ClassSystemControl(
ClassQueryWmiRegInfoEx = commonExtension->IsFdo ? ClassQueryWmiRegInfoEx = commonExtension->IsFdo ?
driverExtension->ClassFdoQueryWmiRegInfoEx : driverExtension->ClassFdoQueryWmiRegInfoEx :
driverExtension->ClassPdoQueryWmiRegInfoEx; driverExtension->ClassPdoQueryWmiRegInfoEx;
if (ClassQueryWmiRegInfoEx == NULL) if (ClassQueryWmiRegInfoEx == NULL)
{ {
status = classWmiInfo->ClassQueryWmiRegInfo( status = classWmiInfo->ClassQueryWmiRegInfo(
DeviceObject, DeviceObject,
&nameFlags, &nameFlags,
&name); &name);
RtlInitUnicodeString(&mofName, MOFRESOURCENAME); RtlInitUnicodeString(&mofName, MOFRESOURCENAME);
} else { } else {
RtlInitUnicodeString(&mofName, L""); RtlInitUnicodeString(&mofName, L"");
@ -545,13 +545,13 @@ Arguments:
DeviceObject - Supplies a pointer to the device object for this request. DeviceObject - Supplies a pointer to the device object for this request.
Irp - Supplies the Irp making the request. Irp - Supplies the Irp making the request.
Status - Status to complete the irp with. STATUS_BUFFER_TOO_SMALL is used Status - Status to complete the irp with. STATUS_BUFFER_TOO_SMALL is used
to indicate that more buffer is required for the data requested. to indicate that more buffer is required for the data requested.
BufferUsed - number of bytes of actual data to return (not including WMI BufferUsed - number of bytes of actual data to return (not including WMI
specific structures) specific structures)
PriorityBoost - priority boost to pass to ClassCompleteRequest PriorityBoost - priority boost to pass to ClassCompleteRequest
Return Value: Return Value:
@ -561,7 +561,6 @@ Return Value:
--*/ --*/
SCSIPORTAPI SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassWmiCompleteRequest( ClassWmiCompleteRequest(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,
@ -725,9 +724,7 @@ Return Value:
status status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassWmiFireEvent( ClassWmiFireEvent(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN LPGUID Guid, IN LPGUID Guid,

View file

@ -78,9 +78,7 @@ Return Value:
lock. lock.
--*/ --*/
SCSIPORTAPI
ULONG ULONG
NTAPI
ClassAcquireRemoveLockEx( ClassAcquireRemoveLockEx(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN OPTIONAL PVOID Tag, IN OPTIONAL PVOID Tag,
@ -125,14 +123,14 @@ ClassAcquireRemoveLockEx(
&oldIrql); &oldIrql);
commonExtension->RemoveTrackingUntrackedCount++; commonExtension->RemoveTrackingUntrackedCount++;
DebugPrint((ClassDebugWarning, ">>>>>ClassAcquireRemoveLock: " DebugPrint((ClassDebugWarning, ">>>>>ClassAcquireRemoveLock: "
"Cannot track Tag %p - currently %d untracked requsts\n", "Cannot track Tag %p - currently %d untracked requsts\n",
Tag, commonExtension->RemoveTrackingUntrackedCount)); Tag, commonExtension->RemoveTrackingUntrackedCount));
KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock,
oldIrql); oldIrql);
} }
else { else {
PREMOVE_TRACKING_BLOCK *removeTrackingList = PREMOVE_TRACKING_BLOCK *removeTrackingList =
(PREMOVE_TRACKING_BLOCK)&commonExtension->RemoveTrackingList; (PREMOVE_TRACKING_BLOCK)&commonExtension->RemoveTrackingList;
@ -210,9 +208,7 @@ Return Value:
none none
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassReleaseRemoveLock( ClassReleaseRemoveLock(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN OPTIONAL PIRP Tag IN OPTIONAL PIRP Tag
@ -365,9 +361,9 @@ Routine Description:
Arguments: Arguments:
DeviceObject - the device object that was handling this request DeviceObject - the device object that was handling this request
Irp - the irp to be completed by IoCompleteRequest Irp - the irp to be completed by IoCompleteRequest
PriorityBoost - the priority boost to pass to IoCompleteRequest PriorityBoost - the priority boost to pass to IoCompleteRequest
Return Value: Return Value:
@ -375,9 +371,7 @@ Return Value:
none none
--*/ --*/
SCSIPORTAPI
VOID VOID
NTAPI
ClassCompleteRequest( ClassCompleteRequest(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp, IN PIRP Irp,

View file

@ -51,10 +51,7 @@ typedef struct _CSCAN_LIST_ENTRY {
* StartIo routine when the transfer size is too large for the hardware. * StartIo routine when the transfer size is too large for the hardware.
* We map it to our new read/write handler. * We map it to our new read/write handler.
*/ */
SCSIPORTAPI VOID ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes)
VOID
NTAPI
ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes)
{ {
PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension; PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension;
PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData; PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData;
@ -71,7 +68,7 @@ ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes)
} }
ServiceTransferRequest(Fdo, Irp); ServiceTransferRequest(Fdo, Irp);
} }
/*++//////////////////////////////////////////////////////////////////////////// /*++////////////////////////////////////////////////////////////////////////////
@ -102,9 +99,7 @@ Return Value:
NT status NT status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassIoCompleteAssociated( ClassIoCompleteAssociated(
IN PDEVICE_OBJECT Fdo, IN PDEVICE_OBJECT Fdo,
IN PIRP Irp, IN PIRP Irp,
@ -481,9 +476,7 @@ Return Value:
NT Status NT Status
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassBuildRequest( ClassBuildRequest(
PDEVICE_OBJECT Fdo, PDEVICE_OBJECT Fdo,
PIRP Irp PIRP Irp
@ -746,13 +739,13 @@ VOID ClasspInsertCScanList(IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
DBGWARN(("ClasspInsertCScanList is OBSOLETE !")); DBGWARN(("ClasspInsertCScanList is OBSOLETE !"));
// //
// Iterate through the list. Insert this entry in the sorted list in // Iterate through the list. Insert this entry in the sorted list in
// order (after other requests for the same block). At each stop if // order (after other requests for the same block). At each stop if
// blockNumber(Entry) >= blockNumber(t) then move on. // blockNumber(Entry) >= blockNumber(t) then move on.
// //
for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink; for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink;
t != (PCSCAN_LIST_ENTRY) ListHead; t != (PCSCAN_LIST_ENTRY) ListHead;
t = (PCSCAN_LIST_ENTRY) t->Entry.Flink) { t = (PCSCAN_LIST_ENTRY) t->Entry.Flink) {
if(Entry->BlockNumber < t->BlockNumber) { if(Entry->BlockNumber < t->BlockNumber) {
@ -775,7 +768,7 @@ VOID ClasspInsertCScanList(IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry)
} }
// //
// Insert this entry at the tail of the list. If the list was empty this // Insert this entry at the tail of the list. If the list was empty this
// will also be the head of the list. // will also be the head of the list.
// //
@ -794,25 +787,25 @@ Routine Description:
to the access of the list. to the access of the list.
Low priority requests are always scheduled to run on the next sweep across Low priority requests are always scheduled to run on the next sweep across
the disk. Normal priority requests will be inserted into the current or the disk. Normal priority requests will be inserted into the current or
next sweep based on the standard C-SCAN algorithm. next sweep based on the standard C-SCAN algorithm.
Arguments: Arguments:
List - the list to insert into List - the list to insert into
Irp - the irp to be inserted. Irp - the irp to be inserted.
BlockNumber - the block number for this request. BlockNumber - the block number for this request.
LowPriority - indicates that the request is lower priority and should be LowPriority - indicates that the request is lower priority and should be
done on the next sweep across the disk. done on the next sweep across the disk.
Return Value: Return Value:
none none
--*/ --*/
{ {
PCSCAN_LIST_ENTRY entry = (PCSCAN_LIST_ENTRY)Irp->Tail.Overlay.DriverContext; PCSCAN_LIST_ENTRY entry = (PCSCAN_LIST_ENTRY)Irp->Tail.Overlay.DriverContext;
@ -824,7 +817,7 @@ Return Value:
entry->BlockNumber = BlockNumber; entry->BlockNumber = BlockNumber;
// //
// If it's a normal priority request and further down the disk than our // If it's a normal priority request and further down the disk than our
// current position then insert this entry into the current sweep. // current position then insert this entry into the current sweep.
// //
@ -845,22 +838,22 @@ VOID ClassFreeOrReuseSrb( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
Routine Description: Routine Description:
This routine will attempt to reuse the provided SRB to start a blocked This routine will attempt to reuse the provided SRB to start a blocked
read/write request. read/write request.
If there is no need to reuse the request it will be returned If there is no need to reuse the request it will be returned
to the SRB lookaside list. to the SRB lookaside list.
Arguments: Arguments:
Fdo - the device extension Fdo - the device extension
Srb - the SRB which is to be reused or freed. Srb - the SRB which is to be reused or freed.
Return Value: Return Value:
none. none.
--*/ --*/
{ {
PCLASS_PRIVATE_FDO_DATA privateData = FdoExtension->PrivateFdoData; PCLASS_PRIVATE_FDO_DATA privateData = FdoExtension->PrivateFdoData;
@ -876,7 +869,7 @@ Return Value:
// memory leak. // memory leak.
// //
ASSERT(!TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER)); ASSERT(!TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER));
if (commonExt->IsSrbLookasideListInitialized){ if (commonExt->IsSrbLookasideListInitialized){
/* /*
* Put the SRB back in our lookaside list. * Put the SRB back in our lookaside list.
@ -903,7 +896,7 @@ Routine Description:
This routine deletes a lookaside listhead for srbs, and should be called This routine deletes a lookaside listhead for srbs, and should be called
only during the final removal. only during the final removal.
If called at other times, the caller is responsible for If called at other times, the caller is responsible for
synchronization and removal issues. synchronization and removal issues.
@ -916,10 +909,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI VOID ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension)
VOID
NTAPI
ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension)
{ {
PAGED_CODE(); PAGED_CODE();
@ -933,7 +923,7 @@ ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension)
else { else {
DBGWARN(("ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist")); DBGWARN(("ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist"));
} }
} }
/*++//////////////////////////////////////////////////////////////////////////// /*++////////////////////////////////////////////////////////////////////////////
@ -944,7 +934,7 @@ Routine Description:
This routine sets up a lookaside listhead for srbs, and should be called This routine sets up a lookaside listhead for srbs, and should be called
only from the ClassInitDevice() routine to prevent race conditions. only from the ClassInitDevice() routine to prevent race conditions.
If called from other locations, the caller is responsible for If called from other locations, the caller is responsible for
synchronization and removal issues. synchronization and removal issues.
@ -954,7 +944,7 @@ Arguments:
NumberElements - Supplies the maximum depth of the lookaside list. NumberElements - Supplies the maximum depth of the lookaside list.
Note: Note:
The Windows 2000 version of classpnp did not return any status value from The Windows 2000 version of classpnp did not return any status value from
@ -962,10 +952,7 @@ Note:
--*/ --*/
SCSIPORTAPI VOID ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtension,
VOID
NTAPI
ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtension,
IN ULONG NumberElements) IN ULONG NumberElements)
{ {
PAGED_CODE(); PAGED_CODE();
@ -986,8 +973,8 @@ ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtension,
CommonExtension->IsSrbLookasideListInitialized = TRUE; CommonExtension->IsSrbLookasideListInitialized = TRUE;
} }
} }
@ -1021,7 +1008,7 @@ VOID ClasspStartNextSweep(PCSCAN_LIST List)
List->CurrentSweep = List->NextSweep; List->CurrentSweep = List->NextSweep;
// //
// Unlink the next sweep list from the list head now that we have a copy // Unlink the next sweep list from the list head now that we have a copy
// of it. // of it.
// //

View file

@ -77,8 +77,8 @@ Routine Description:
Arguments: Arguments:
DeviceObject - DeviceObject -
Irp - Irp -
Return Value: Return Value:
@ -151,7 +151,7 @@ Return Value:
STATUS_MORE_PROCESSING_REQUIRED or STATUS_MORE_PROCESSING_REQUIRED or
STATUS_SUCCESS STATUS_SUCCESS
--*/ --*/
NTSTATUS NTSTATUS
ClasspPowerUpCompletion( ClasspPowerUpCompletion(
@ -389,7 +389,7 @@ ClasspPowerUpCompletion(
break; break;
} }
// reset retries // reset retries
Context->RetryCount = MAXIMUM_RETRIES; Context->RetryCount = MAXIMUM_RETRIES;
@ -406,7 +406,7 @@ ClasspPowerUpCompletionFailure:
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;
@ -466,7 +466,7 @@ ClasspPowerUpCompletionFailure:
// Indicate to Po that we've been successfully powered up so // Indicate to Po that we've been successfully powered up so
// it can do it's notification stuff. // it can do it's notification stuff.
// //
PoSetPowerState(DeviceObject, PoSetPowerState(DeviceObject,
currentStack->Parameters.Power.Type, currentStack->Parameters.Power.Type,
currentStack->Parameters.Power.State); currentStack->Parameters.Power.State);
@ -623,45 +623,45 @@ 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);
DebugPrint((1, "(%p)\tIoCallDriver returned %lx\n", Irp, status)); DebugPrint((1, "(%p)\tIoCallDriver returned %lx\n", Irp, status));
break; break;
} else { } else {
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++;
@ -671,7 +671,7 @@ ClasspPowerDownCompletion(
// no break in case the device doesn't like synch_cache commands // no break in case the device doesn't like synch_cache commands
} }
case PowerDownDeviceFlushed2: { case PowerDownDeviceFlushed2: {
PCDB cdb; PCDB cdb;
@ -843,9 +843,9 @@ 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) &&
@ -881,7 +881,7 @@ ClasspPowerDownCompletion(
DebugPrint((1, "(%p)\tPoCallDriver returned %lx\n", Irp, status)); DebugPrint((1, "(%p)\tPoCallDriver returned %lx\n", Irp, status));
break; break;
} }
// else fall through w/o sending the power irp, since the device // else fall through w/o sending the power irp, since the device
// is reporting an error that would be "really bad" to power down // is reporting an error that would be "really bad" to power down
// during. // during.
@ -900,7 +900,7 @@ ClasspPowerDownCompletion(
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;
@ -956,7 +956,7 @@ ClasspPowerDownCompletion(
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
if (NT_SUCCESS(status)) { if (NT_SUCCESS(status)) {
// //
// Set the new power state // Set the new power state
// //
@ -989,7 +989,7 @@ Routine Description:
This routine reduces the number of useless spinups and spindown requests This routine reduces the number of useless spinups and spindown requests
sent to a given device by ignoring transitions to power states we are sent to a given device by ignoring transitions to power states we are
currently in. currently in.
ISSUE-2000/02/20-henrygab - by ignoring spin-up requests, we may be ISSUE-2000/02/20-henrygab - by ignoring spin-up requests, we may be
allowing the drive allowing the drive
@ -1046,7 +1046,7 @@ ClasspPowerHandler(
irpStack->Parameters.Power.State.SystemState)); irpStack->Parameters.Power.State.SystemState));
switch (irpStack->Parameters.Power.ShutdownType){ switch (irpStack->Parameters.Power.ShutdownType){
case PowerActionSleep: case PowerActionSleep:
case PowerActionHibernate: case PowerActionHibernate:
if (fdoData->HotplugInfo.MediaRemovable || fdoData->HotplugInfo.MediaHotplug){ if (fdoData->HotplugInfo.MediaRemovable || fdoData->HotplugInfo.MediaHotplug){
@ -1060,7 +1060,7 @@ ClasspPowerHandler(
} }
break; break;
} }
break; break;
} }
@ -1311,7 +1311,7 @@ ClassMinimalPowerHandler(
if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) { if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) {
PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
DeviceObject->DeviceExtension; DeviceObject->DeviceExtension;
// //
@ -1319,9 +1319,9 @@ ClassMinimalPowerHandler(
// //
if (irpStack->MinorFunction == IRP_MN_SET_POWER){ if (irpStack->MinorFunction == IRP_MN_SET_POWER){
PVPB vpb; PVPB vpb;
switch (irpStack->Parameters.Power.ShutdownType){ switch (irpStack->Parameters.Power.ShutdownType){
case PowerActionSleep: case PowerActionSleep:
case PowerActionHibernate: case PowerActionHibernate:
// //
@ -1331,11 +1331,11 @@ ClassMinimalPowerHandler(
// //
vpb = ClassGetVpb(fdoExtension->DeviceObject); vpb = ClassGetVpb(fdoExtension->DeviceObject);
if (vpb && (vpb->Flags & VPB_MOUNTED)){ if (vpb && (vpb->Flags & VPB_MOUNTED)){
SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME); SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME);
} }
break; break;
} }
} }
} }
IoCopyCurrentIrpStackLocationToNext(Irp); IoCopyCurrentIrpStackLocationToNext(Irp);
@ -1345,7 +1345,7 @@ ClassMinimalPowerHandler(
if (irpStack->MinorFunction != IRP_MN_SET_POWER && if (irpStack->MinorFunction != IRP_MN_SET_POWER &&
irpStack->MinorFunction != IRP_MN_QUERY_POWER) { irpStack->MinorFunction != IRP_MN_QUERY_POWER) {
NOTHING; NOTHING;
} else { } else {
@ -1371,7 +1371,7 @@ Routine Description:
a start and a stop to be sent to the device. (actually the starts are a start and a stop to be sent to the device. (actually the starts are
almost always optional, since most device power themselves on to process almost always optional, since most device power themselves on to process
commands, but i digress). commands, but i digress).
Determines proper use of spinup, spindown, and queue locking based upon Determines proper use of spinup, spindown, and queue locking based upon
ScanForSpecialFlags in the FdoExtension. This is the most common power ScanForSpecialFlags in the FdoExtension. This is the most common power
handler passed into classpnp.sys handler passed into classpnp.sys
@ -1387,9 +1387,7 @@ Return Value:
None None
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassSpinDownPowerHandler( ClassSpinDownPowerHandler(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp IN PIRP Irp
@ -1451,14 +1449,12 @@ Routine Description:
This routine is an outdated call. To achieve equivalent functionality, This routine is an outdated call. To achieve equivalent functionality,
the driver should set the following flags in ScanForSpecialFlags in the the driver should set the following flags in ScanForSpecialFlags in the
FdoExtension: FdoExtension:
CLASS_SPECIAL_DISABLE_SPIN_UP CLASS_SPECIAL_DISABLE_SPIN_UP
CLASS_SPECIAL_NO_QUEUE_LOCK CLASS_SPECIAL_NO_QUEUE_LOCK
--*/ --*/
SCSIPORTAPI
NTSTATUS NTSTATUS
NTAPI
ClassStopUnitPowerHandler( ClassStopUnitPowerHandler(
IN PDEVICE_OBJECT DeviceObject, IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp IN PIRP Irp

View file

@ -55,10 +55,7 @@ BOOLEAN ClasspMyStringMatches(IN PCHAR StringToMatch OPTIONAL, IN PCHAR TargetSt
} }
SCSIPORTAPI VOID ClassGetDeviceParameter(
VOID
NTAPI
ClassGetDeviceParameter(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN PWSTR SubkeyName OPTIONAL, IN PWSTR SubkeyName OPTIONAL,
IN PWSTR ParameterName, IN PWSTR ParameterName,
@ -143,10 +140,7 @@ ClassGetDeviceParameter(
} // end ClassGetDeviceParameter() } // end ClassGetDeviceParameter()
SCSIPORTAPI NTSTATUS ClassSetDeviceParameter(
NTSTATUS
NTAPI
ClassSetDeviceParameter(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN PWSTR SubkeyName OPTIONAL, IN PWSTR SubkeyName OPTIONAL,
IN PWSTR ParameterName, IN PWSTR ParameterName,
@ -224,10 +218,7 @@ ClassSetDeviceParameter(
* hardware based upon id strings. it does not check the registry. * hardware based upon id strings. it does not check the registry.
*/ */
SCSIPORTAPI VOID ClassScanForSpecial(
VOID
NTAPI
ClassScanForSpecial(
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[], IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[],
IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function) IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function)