From 5e9036e712c9707f1b49dc9955ebb2db59b2fb35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Sat, 30 Oct 2010 00:03:28 +0000 Subject: [PATCH] [CLASSPNP] - fix a whole bunch of function prototype. (how does t even work in trunk?) [CMAKE] - add classpnp.sys to build svn path=/branches/cmake-bringup/; revision=49345 --- drivers/storage/CMakeLists.txt | 1 + drivers/storage/classpnp/CMakeLists.txt | 42 ++++ drivers/storage/classpnp/autorun.c | 293 +++++++++++++----------- drivers/storage/classpnp/class.c | 77 ++++++- drivers/storage/classpnp/classp.h | 16 +- drivers/storage/classpnp/classwmi.c | 13 +- drivers/storage/classpnp/lock.c | 14 +- drivers/storage/classpnp/obsolete.c | 77 ++++--- drivers/storage/classpnp/power.c | 78 ++++--- drivers/storage/classpnp/utils.c | 15 +- 10 files changed, 391 insertions(+), 235 deletions(-) create mode 100644 drivers/storage/classpnp/CMakeLists.txt diff --git a/drivers/storage/CMakeLists.txt b/drivers/storage/CMakeLists.txt index 8bc4e3d09fc..724a1d90658 100644 --- a/drivers/storage/CMakeLists.txt +++ b/drivers/storage/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(class) +add_subdirectory(classpnp) add_subdirectory(floppy) add_subdirectory(ide) add_subdirectory(port) diff --git a/drivers/storage/classpnp/CMakeLists.txt b/drivers/storage/classpnp/CMakeLists.txt new file mode 100644 index 00000000000..cf664289d67 --- /dev/null +++ b/drivers/storage/classpnp/CMakeLists.txt @@ -0,0 +1,42 @@ + +include_directories(../inc) + +add_definitions( + -DCLASS_GLOBAL_BREAK_ON_LOST_IRPS=0 + -DCLASS_GLOBAL_SECONDS_TO_WAIT_FOR_SYNCHRONOUS_SRB=100 + -DCLASS_GLOBAL_USE_DELAYED_RETRY=1 + -DCLASS_GLOBAL_BUFFERED_DEBUG_PRINT=0 + -DCLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFER_SIZE=512 + -DCLASS_GLOBAL_BUFFERED_DEBUG_PRINT_BUFFERS=512 +) + +list(APPEND SOURCE + autorun.c + class.c + classwmi.c + clntirp.c + create.c + data.c + debug.c + dictlib.c + lock.c + obsolete.c + power.c + retry.c + utils.c + xferpkt.c + class.rc +) + +spec2def(classpnp ${CMAKE_CURRENT_SOURCE_DIR}/class.spec ${CMAKE_CURRENT_BINARY_DIR}/class.def) + +add_library(classpnp SHARED ${SOURCE}) +target_link_libraries(classpnp ${CMAKE_CURRENT_BINARY_DIR}/class.def pseh libcntpr) +add_dependencies(classpnp classpnp_def) + +set_module_type(classpnp kernelmodedriver) + +add_importlibs(classpnp hal ntoskrnl) + +add_minicd_target(classpnp reactos classpnp.sys) +add_livecd_target(classpnp reactos/system32/drivers) \ No newline at end of file diff --git a/drivers/storage/classpnp/autorun.c b/drivers/storage/classpnp/autorun.c index 0d2f36d4a52..5715402967c 100644 --- a/drivers/storage/classpnp/autorun.c +++ b/drivers/storage/classpnp/autorun.c @@ -148,14 +148,14 @@ ClassSendEjectionNotification( // ejection request occured, we could see if any locks for the media // existed. if locked, broadcast. if not, we send the eject irp. // - + // // for now, just always broadcast. make this a public routine, // so class drivers can add special hacks to broadcast this for their // non-MMC-compliant devices also from sense codes. // - DBGTRACE(ClassDebugTrace, ("ClassSendEjectionNotification: media EJECT_REQUEST")); + DBGTRACE(ClassDebugTrace, ("ClassSendEjectionNotification: media EJECT_REQUEST")); ClasspSendNotification(FdoExtension, &GUID_IO_MEDIA_EJECT_REQUEST, 0, @@ -174,7 +174,7 @@ ClasspSendNotification( { PTARGET_DEVICE_CUSTOM_NOTIFICATION notification; ULONG requiredSize; - + requiredSize = (sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION) - sizeof(UCHAR)) + ExtraDataSize; @@ -186,11 +186,11 @@ ClasspSendNotification( requiredSize)); return; } - + notification = ExAllocatePoolWithTag(NonPagedPool, requiredSize, 'oNcS'); - + // // if none allocated, exit // @@ -202,7 +202,7 @@ ClasspSendNotification( // // Prepare and send the request! // - + RtlZeroMemory(notification, requiredSize); notification->Version = 1; notification->Size = (USHORT)(requiredSize); @@ -214,7 +214,7 @@ ClasspSendNotification( IoReportTargetDeviceChangeAsynchronous(FdoExtension->LowerPdo, notification, NULL, NULL); - + ExFreePool(notification); notification = NULL; return; @@ -236,7 +236,7 @@ Routine Description: Arguments: FdoExtension - the device - + DataBuffer - the resulting data from a GESN event. requires at least EIGHT valid bytes (header == 4, data == 4) @@ -245,14 +245,14 @@ Arguments: event was of the DEVICE BUSY class, else true. Return Value: - + None - + Notes: 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). - + The call to StartNextPacket may occur before this routine is completed. the operational change notifications are informational in nature, and 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 a device supports software write protect, it is expected that the application can handle such a case. - + 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 operation. unfortunately, there is no simple way to notify a class driver which wants to know that the device behavior requires updating. - + Not ready events may be sent every second. For example, if we were to minimize the number of asynchronous notifications, an application may register just after a large busy time was reported. This would then @@ -339,7 +339,7 @@ ClasspInterpretGesnData( lowestSetBit ^= (info->Gesn.EventMask); if (thisEventBit != lowestSetBit) { - + // // HACKHACK - REF #0001 // 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, " "removing GESN hack (%x, %x)\n", thisEventBit, info->Gesn.EventMask)); - + info->Gesn.HackEventMask = FALSE; } else if (thisEvent == 0) { - + // // HACKHACK - REF #0001 // note: this hack prevents poorly implemented firmware from constantly @@ -409,13 +409,13 @@ ClasspInterpretGesnData( &GUID_IO_GENERIC_GESN_EVENT, sizeof(NOTIFICATION_EVENT_STATUS_HEADER) + dataLength, Header) -*/ +*/ switch (Header->NotificationClass) { case NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS: { // 0x3 - - PNOTIFICATION_EXTERNAL_STATUS externalInfo = + + PNOTIFICATION_EXTERNAL_STATUS externalInfo = (PNOTIFICATION_EXTERNAL_STATUS)(Header->ClassEventData); DEVICE_EVENT_EXTERNAL_REQUEST externalData; @@ -424,12 +424,12 @@ ClasspInterpretGesnData( // about keys being pressed, and not released. this makes keys // single-function, but simplifies the code significantly. // - + if (externalInfo->ExternalEvent != NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN) { break; } - + *ResendImmediately = TRUE; KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => GESN::EXTERNAL: Event: %x Status %x Req %x\n", @@ -447,28 +447,28 @@ ClasspInterpretGesnData( KeQuerySystemTime(&(externalData.SystemTime)); externalData.SystemTime.QuadPart *= (LONGLONG)KeQueryTimeIncrement(); - DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media DEVICE_EXTERNAL_REQUEST")); + DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media DEVICE_EXTERNAL_REQUEST")); ClasspSendNotification(FdoExtension, &GUID_IO_DEVICE_EXTERNAL_REQUEST, sizeof(DEVICE_EVENT_EXTERNAL_REQUEST), &externalData); return; } - + case NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS: { // 0x4 - + PNOTIFICATION_MEDIA_STATUS mediaInfo = (PNOTIFICATION_MEDIA_STATUS)(Header->ClassEventData); - + if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NO_CHANGE) { break; } - + *ResendImmediately = TRUE; KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => GESN::MEDIA: Event: %x Status %x\n", mediaInfo->MediaEvent, mediaInfo->MediaStatus)); - + if ((mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_NEW_MEDIA) || (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE)) { @@ -489,29 +489,29 @@ ClasspInterpretGesnData( TRUE); } else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL) { - + ClasspSetMediaChangeStateEx(FdoExtension, MediaNotPresent, FALSE, TRUE); - + } else if (mediaInfo->MediaEvent == NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST) { KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugError, "Classpnp => GESN Ejection request received!\n")); ClassSendEjectionNotification(FdoExtension); - + } break; } - + case NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS: { // lowest priority events... - + PNOTIFICATION_BUSY_STATUS busyInfo = (PNOTIFICATION_BUSY_STATUS)(Header->ClassEventData); DEVICE_EVENT_BECOMING_READY busyData; - + // // NOTE: we never actually need to immediately retry for these // events: if one exists, the device is busy, and if not, @@ -521,7 +521,7 @@ ClasspInterpretGesnData( if (busyInfo->DeviceBusyStatus == NOTIFICATION_BUSY_STATUS_NO_EVENT) { break; } - + // // else we want to report the approximated time till it's ready. // @@ -531,28 +531,28 @@ ClasspInterpretGesnData( busyData.Reason = busyInfo->DeviceBusyStatus; busyData.Estimated100msToReady = (busyInfo->Time[0] << 8) | (busyInfo->Time[1] & 0xff); - + KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => GESN::BUSY: Event: %x Status %x Time %x\n", busyInfo->DeviceBusyEvent, busyInfo->DeviceBusyStatus, busyData.Estimated100msToReady )); - DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media BECOMING_READY")); + DBGTRACE(ClassDebugTrace, ("ClasspInterpretGesnData: media BECOMING_READY")); ClasspSendNotification(FdoExtension, &GUID_IO_DEVICE_BECOMING_READY, sizeof(DEVICE_EVENT_BECOMING_READY), &busyData); break; } - + default: { - + break; } - - } // end switch on notification class + + } // end switch on notification class return; } @@ -577,7 +577,7 @@ Arguments: MediaPresent - indicates whether the device has media inserted into it (TRUE) or not (FALSE). - + Return Value: none @@ -656,7 +656,7 @@ ClasspInternalSetMediaChangeState( sizeof(ULONG), &data); - } + } else if (NewState == MediaNotPresent) { DBGTRACE(ClassDebugTrace, ("ClasspInternalSetMediaChangeState: media REMOVAL")); @@ -673,7 +673,7 @@ ClasspInternalSetMediaChangeState( return; } - + return; } // end ClasspInternalSetMediaChangeState() @@ -769,7 +769,10 @@ ClasspSetMediaChangeStateEx( return; } // end ClassSetMediaChangeStateEx() + +SCSIPORTAPI VOID +NTAPI ClassSetMediaChangeState( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN MEDIA_CHANGE_DETECTION_STATE NewState, @@ -833,11 +836,11 @@ ClasspMediaChangeDetectionCompletion( /* * 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/?). * ClassInterpretSenseInfo would then call ClassSendStartUnit to spin the media up, which defeats the * 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. * (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 @@ -846,15 +849,15 @@ ClasspMediaChangeDetectionCompletion( 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))){ - + 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)){ Srb->SrbStatus = SRB_STATUS_SUCCESS; } - } - + } + // // use ClassInterpretSenseInfo() to check for media state, and also @@ -873,15 +876,15 @@ ClasspMediaChangeDetectionCompletion( &status, NULL); - } + } else { - + fdoData->LoggedTURFailureSinceLastIO = FALSE; - + if (!info->Gesn.Supported) { DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded and GESN NOT supported, setting MediaPresent.")); - + // // success != media for GESN case // @@ -893,7 +896,7 @@ ClasspMediaChangeDetectionCompletion( DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - succeeded (GESN supported).")); } } - + if (info->Gesn.Supported) { if (status == STATUS_DATA_OVERRUN) { @@ -901,7 +904,7 @@ ClasspMediaChangeDetectionCompletion( status = STATUS_SUCCESS; } - if (!NT_SUCCESS(status)) { + if (!NT_SUCCESS(status)) { DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion: GESN failed with status %x", status)); } else { @@ -909,7 +912,7 @@ ClasspMediaChangeDetectionCompletion( // for GESN, need to interpret the results of the data. // this may also require an immediate retry // - + if (Irp->IoStatus.Information == 8 ) { ClasspInterpretGesnData(fdoExtension, (PVOID)info->Gesn.Buffer, @@ -946,7 +949,7 @@ ClasspMediaChangeDetectionCompletion( // if (retryImmediately) { - + info->MediaChangeRetryCount++; if (info->MediaChangeRetryCount > MAXIMUM_IMMEDIATE_MCN_RETRIES) { ASSERT(!"Recursing too often in MCN?"); @@ -955,7 +958,7 @@ ClasspMediaChangeDetectionCompletion( } } else { - + info->MediaChangeRetryCount = 0; } @@ -970,7 +973,7 @@ ClasspMediaChangeDetectionCompletion( ClassAcquireRemoveLock(DeviceObject, (PIRP)(&uniqueValue)); ClassReleaseRemoveLock(DeviceObject, Irp); - + // // set the irp as not in use // @@ -992,18 +995,18 @@ ClasspMediaChangeDetectionCompletion( else { DBGTRACE(ClassDebugMCN, ("ClasspMediaChangeDetectionCompletion - not retrying immediately")); } - + // // release the temporary remove lock // - + ClassReleaseRemoveLock(DeviceObject, (PIRP)(&uniqueValue)); } DBGTRACE(ClassDebugMCN, ("< ClasspMediaChangeDetectionCompletion")); return STATUS_MORE_PROCESSING_REQUIRED; -} +} /*++//////////////////////////////////////////////////////////////////////////// @@ -1015,8 +1018,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -1057,7 +1060,7 @@ ClasspPrepareMcnIrp( if (status == REMOVE_COMPLETE) { ASSERT(status != REMOVE_COMPLETE); return NULL; - } + } else if (status == REMOVE_PENDING) { ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp); return NULL; @@ -1105,12 +1108,12 @@ ClasspPrepareMcnIrp( srb->ScsiStatus = 0; srb->OriginalRequest = irp; srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE; - + srb->SrbFlags = FdoExtension->SrbFlags; SET_FLAG(srb->SrbFlags, Info->SrbFlags); srb->TimeOutValue = FdoExtension->TimeOutValue * 2; - + if (srb->TimeOutValue == 0) { if (FdoExtension->TimeOutValue == 0) { @@ -1119,9 +1122,9 @@ ClasspPrepareMcnIrp( "ClassSendTestUnitIrp: FdoExtension->TimeOutValue " "is set to zero?! -- resetting to 10\n")); srb->TimeOutValue = 10 * 2; // reasonable default - + } else { - + KdPrintEx((DPFLTR_CLASSPNP_ID, DPFLTR_ERROR_LEVEL, "ClassSendTestUnitIrp: Someone set " "srb->TimeOutValue to zero?! -- resetting to %x\n", @@ -1131,9 +1134,9 @@ ClasspPrepareMcnIrp( } } - + if (!UseGesn) { - + srb->CdbLength = 6; srb->DataTransferLength = 0; SET_FLAG(srb->SrbFlags, SRB_FLAGS_NO_DATA_TRANSFER); @@ -1142,16 +1145,16 @@ ClasspPrepareMcnIrp( srb->DataBuffer = NULL; srb->DataTransferLength = 0; irp->MdlAddress = NULL; - + cdb = (PCDB) &srb->Cdb[0]; cdb->CDB6GENERIC.OperationCode = SCSIOP_TEST_UNIT_READY; } else { - + ASSERT(Info->Gesn.Buffer); srb->TimeOutValue = GESN_TIMEOUT_VALUE; // much shorter timeout for GESN - + srb->CdbLength = 10; SET_FLAG(srb->SrbFlags, SRB_FLAGS_DATA_IN); nextIrpStack->Parameters.DeviceIoControl.IoControlCode = @@ -1194,8 +1197,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -1346,7 +1349,7 @@ ClasspSendMediaStateIrp( // device object directly or to the device's StartIo // routine (which doesn't acquire the lock). // - + requestPending = TRUE; DBGTRACE(ClassDebugMCN, (" ClasspSendMediaStateIrp - calling IoCallDriver.")); @@ -1365,7 +1368,7 @@ ClasspSendMediaStateIrp( } DBGTRACE(ClassDebugMCN, ("< ClasspSendMediaStateIrp")); - + return; } // end ClasspSendMediaStateIrp() @@ -1388,7 +1391,9 @@ Return Value: none --*/ +SCSIPORTAPI VOID +NTAPI ClassCheckMediaState( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -1429,7 +1434,7 @@ ClassResetMediaChangeTimer() Routine Description: Resets the media change count down timer to the default number of seconds. - + Arguments: FdoExtension - the device to reset the timer for @@ -1439,7 +1444,9 @@ Return Value: None --*/ +SCSIPORTAPI VOID +NTAPI ClassResetMediaChangeTimer( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -1463,8 +1470,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -1502,11 +1509,11 @@ ClasspInitializePolling( /* * 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. */ irp = IoAllocateIrp((CCHAR)(fdo->StackSize+1), FALSE); - + if (irp != NULL) { PVOID buffer; @@ -1627,7 +1634,7 @@ ClasspInitializePolling( "ClasspInitializePolling: GESN *NOT* available " "for %p\n", FdoExtension->DeviceObject)); } - + ASSERT(info->Gesn.Supported == 0); ASSERT(info->Gesn.Buffer == NULL); ASSERT(info->Gesn.BufferSize == 0); @@ -1654,7 +1661,7 @@ ClasspInitializeGesn( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMEDIA_CHANGE_DETECTION_INFO Info ) -{ +{ PNOTIFICATION_EVENT_STATUS_HEADER header; CLASS_DETECTION_STATE detectionState = ClassDetectionUnknown; PSTORAGE_ADAPTER_DESCRIPTOR adapterDescriptor; @@ -1665,7 +1672,7 @@ ClasspInitializeGesn( ULONG i; ULONG atapiResets; - + PAGED_CODE(); ASSERT(Info == FdoExtension->MediaChangeDetectionInfo); @@ -1677,7 +1684,7 @@ ClasspInitializeGesn( CLASSP_REG_SUBKEY_NAME, CLASSP_REG_MMC_DETECTION_VALUE_NAME, (PULONG)&detectionState); - + if (detectionState == ClassDetectionUnsupported) { goto ExitWithError; } @@ -1688,7 +1695,7 @@ ClasspInitializeGesn( if (TEST_FLAG(FdoExtension->PrivateFdoData->HackFlags, FDO_HACK_GESN_IS_BAD)) { - + detectionState = ClassDetectionUnsupported; ClassSetDeviceParameter(FdoExtension, CLASSP_REG_SUBKEY_NAME, @@ -1700,7 +1707,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. // @@ -1743,7 +1750,7 @@ ClasspInitializeGesn( atapiResets = 0; retryImmediately = TRUE; for (i = 0; i < 16 && retryImmediately == TRUE; i++) { - + irp = ClasspPrepareMcnIrp(FdoExtension, Info, TRUE); if (irp == NULL) { status = STATUS_INSUFFICIENT_RESOURCES; @@ -1751,19 +1758,19 @@ ClasspInitializeGesn( } ASSERT(TEST_FLAG(Info->MediaChangeSrb.SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE)); - + // // replace the completion routine with a different one this time... // - + IoSetCompletionRoutine(irp, ClassSignalCompletion, &event, TRUE, TRUE, TRUE); KeInitializeEvent(&event, SynchronizationEvent, FALSE); - + status = IoCallDriver(FdoExtension->CommonExtension.LowerDeviceObject, irp); - + if (status == STATUS_PENDING) { status = KeWaitForSingleObject(&event, Executive, @@ -1773,7 +1780,7 @@ ClasspInitializeGesn( ASSERT(NT_SUCCESS(status)); } ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp); - + if (SRB_STATUS(Info->MediaChangeSrb.SrbStatus) != SRB_STATUS_SUCCESS) { ClassInterpretSenseInfo(FdoExtension->DeviceObject, &(Info->MediaChangeSrb), @@ -1808,18 +1815,18 @@ ClasspInitializeGesn( if (status == STATUS_DATA_OVERRUN) { status = STATUS_SUCCESS; } - + if ((status == STATUS_INVALID_DEVICE_REQUEST) || (status == STATUS_TIMEOUT) || (status == STATUS_IO_DEVICE_ERROR) || (status == STATUS_IO_TIMEOUT) ) { - + // // with these error codes, we don't ever want to try this command // again on this device, since it reacts poorly. // - + ClassSetDeviceParameter(FdoExtension, CLASSP_REG_SUBKEY_NAME, CLASSP_REG_MMC_DETECTION_VALUE_NAME, @@ -1829,9 +1836,9 @@ ClasspInitializeGesn( status, FdoExtension->DeviceObject)); goto ExitWithError; - + } - + if (!NT_SUCCESS(status)) { // @@ -1844,21 +1851,21 @@ ClasspInitializeGesn( status, FdoExtension->DeviceObject)); goto ExitWithError; } - + if (i == 0) { // // the first time, the request was just retrieving a mask of // available bits. use this to mask future requests. // - + header = (PNOTIFICATION_EVENT_STATUS_HEADER)(Info->Gesn.Buffer); - + KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => Fdo %p supports event mask %x\n", FdoExtension->DeviceObject, header->SupportedEventClasses)); - - + + if (TEST_FLAG(header->SupportedEventClasses, NOTIFICATION_MEDIA_STATUS_CLASS_MASK)) { KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, @@ -1879,13 +1886,13 @@ ClasspInitializeGesn( // therefore, we should not bother querying for the other, // unknown events. clear all but the above flags. // - + Info->Gesn.EventMask &= NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK | NOTIFICATION_MEDIA_STATUS_CLASS_MASK | NOTIFICATION_DEVICE_BUSY_CLASS_MASK ; - - + + // // HACKHACK - REF #0001 // Some devices will *never* report an event if we've also requested @@ -1899,7 +1906,7 @@ ClasspInitializeGesn( // drives, default to enabling the hack until we find evidence of // proper firmware. // - + if (CountOfSetBitsUChar(Info->Gesn.EventMask) == 1) { KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => GESN hack %s for FDO %p\n", @@ -1912,7 +1919,7 @@ ClasspInitializeGesn( } } else { - + // // not the first time looping through, so interpret the results. // @@ -1935,13 +1942,13 @@ ClasspInitializeGesn( // 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. // - + if (TEST_FLAG(Info->Gesn.EventMask, NOTIFICATION_MEDIA_STATUS_CLASS_MASK) && TEST_FLAG(Info->Gesn.EventMask, NOTIFICATION_DEVICE_BUSY_CLASS_MASK) ) { - + KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => Enabling GESN support for fdo %p\n", FdoExtension->DeviceObject)); @@ -1955,7 +1962,7 @@ ClasspInitializeGesn( return STATUS_SUCCESS; } - + KdPrintEx((DPFLTR_CLASSPNP_ID, ClassDebugMCN, "Classpnp => GESN available but not enabled for fdo %p\n", FdoExtension->DeviceObject)); @@ -1994,16 +2001,18 @@ Routine Description: Arguments: FdoExtension is the device to poll - + 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 it down. Return Value: --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassInitializeTestUnitPolling( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN BOOLEAN AllowDriveToSleep @@ -2022,22 +2031,24 @@ Routine Description: 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 the device-specific key to potentially override that setting. - + If MCN is to be enabled, all neccessary structures and memory are allocated and initialized. - + This routine MUST be called only from the ClassInit() callback. Arguments: FdoExtension - the device to initialize MCN for, if appropriate - + EventPrefix - unused, legacy argument. Set to zero. Return Value: --*/ +SCSIPORTAPI VOID +NTAPI ClassInitializeMediaChangeDetection( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PUCHAR EventPrefix @@ -2108,7 +2119,7 @@ ClassInitializeMediaChangeDetection( if (disabled) { return; } - + // // if the drive is not a CDROM, allow the drive to sleep // @@ -2661,7 +2672,7 @@ ClasspIsMediaChangeDisabledForClass( } ZwClose(serviceKey); - + DebugPrint((ClassDebugMCN, "ClassCheckServiceMCN: " "Autoplay for device %p is %s\n", FdoExtension->DeviceObject, @@ -2687,13 +2698,15 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: --*/ +SCSIPORTAPI VOID +NTAPI ClassEnableMediaChangeDetection( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -2769,15 +2782,17 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: --*/ ULONG BreakOnMcnDisable = FALSE; +SCSIPORTAPI VOID +NTAPI ClassDisableMediaChangeDetection( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -2822,7 +2837,9 @@ Arguments: Return Value: --*/ +SCSIPORTAPI VOID +NTAPI ClassCleanupMediaChangeDetection( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -2836,7 +2853,7 @@ ClassCleanupMediaChangeDetection( } FdoExtension->MediaChangeDetectionInfo = NULL; - + if (info->Gesn.Buffer) { ExFreePool(info->Gesn.Buffer); } @@ -2856,8 +2873,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -3050,8 +3067,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -3197,8 +3214,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -3247,8 +3264,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -3300,8 +3317,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -3433,7 +3450,9 @@ Arguments: Return Value: --*/ +SCSIPORTAPI VOID +NTAPI ClassNotifyFailurePredicted( PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PUCHAR Buffer, @@ -3516,7 +3535,9 @@ Return Value: NT Status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSetFailurePredictionPoll( PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, FAILURE_PREDICTION_METHOD FailurePredictionMethod, diff --git a/drivers/storage/classpnp/class.c b/drivers/storage/classpnp/class.c index 0a1c28ea9c5..e6d6b9610e3 100644 --- a/drivers/storage/classpnp/class.c +++ b/drivers/storage/classpnp/class.c @@ -115,7 +115,9 @@ Return Value: A valid return code for a DriverEntry routine. --*/ +SCSIPORTAPI ULONG +NTAPI ClassInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -130,7 +132,7 @@ ClassInitialize( NTSTATUS status; PAGED_CODE(); - + DebugPrint((3,"\n\nSCSI Class Driver\n")); ClasspInitializeDebugGlobals(); @@ -361,7 +363,9 @@ Return Value: Status Code --*/ +SCSIPORTAPI ULONG +NTAPI ClassInitializeEx( IN PDRIVER_OBJECT DriverObject, IN LPGUID Guid, @@ -1725,7 +1729,10 @@ Return Value: Status is returned. --*/ -NTSTATUS ClassReadDriveCapacity(IN PDEVICE_OBJECT Fdo) +SCSIPORTAPI +NTSTATUS +NTAPI +ClassReadDriveCapacity(IN PDEVICE_OBJECT Fdo) { READ_CAPACITY_DATA readCapacityBuffer = {0}; NTSTATUS status; @@ -2008,7 +2015,9 @@ Return Value: None. --*/ +SCSIPORTAPI VOID +NTAPI ClassSendStartUnit( IN PDEVICE_OBJECT Fdo ) @@ -2161,7 +2170,9 @@ Return Value: None. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassAsynchronousCompletion( PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -2427,7 +2438,9 @@ Return Value: NT status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassIoComplete( IN PDEVICE_OBJECT Fdo, IN PIRP Irp, @@ -2643,7 +2656,9 @@ Return Value: Srb->DataTransferLength --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSendSrbSynchronous( PDEVICE_OBJECT Fdo, PSCSI_REQUEST_BLOCK Srb, @@ -2989,7 +3004,9 @@ Return Value: FALSE: Drivers should not retry this request. --*/ +SCSIPORTAPI BOOLEAN +NTAPI ClassInterpretSenseInfo( IN PDEVICE_OBJECT Fdo, IN PSCSI_REQUEST_BLOCK Srb, @@ -4053,7 +4070,7 @@ ClassInterpretSenseInfo( /* * 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). */ if ((((PCDB)Srb->Cdb)->CDB10.OperationCode == SCSIOP_TEST_UNIT_READY) && logError){ @@ -4061,7 +4078,7 @@ ClassInterpretSenseInfo( logError = FALSE; } else { - fdoData->LoggedTURFailureSinceLastIO = TRUE; + fdoData->LoggedTURFailureSinceLastIO = TRUE; } } if (logError){ @@ -4120,7 +4137,10 @@ Return Value: Length of the transferred data is returned. --*/ -ULONG ClassModeSense( IN PDEVICE_OBJECT Fdo, +SCSIPORTAPI +ULONG +NTAPI +ClassModeSense( IN PDEVICE_OBJECT Fdo, IN PCHAR ModeSenseBuffer, IN ULONG Length, IN UCHAR PageMode) @@ -4206,7 +4226,9 @@ Return Value: then NULL is return. --*/ +SCSIPORTAPI PVOID +NTAPI ClassFindModePage( IN PCHAR ModeSenseBuffer, IN ULONG Length, @@ -4317,7 +4339,9 @@ Return Value: or returns a status value to indicate why it failed. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSendSrbAsynchronous( PDEVICE_OBJECT Fdo, PSCSI_REQUEST_BLOCK Srb, @@ -4585,7 +4609,9 @@ Return Value: Returns back a STATUS_PENDING or a completion status. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassDeviceControl( PDEVICE_OBJECT DeviceObject, PIRP Irp @@ -5608,6 +5634,7 @@ Return Value: --*/ NTSTATUS +NTAPI ClassShutdownFlush( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp @@ -5680,7 +5707,9 @@ Return Value: NTSTATUS --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassCreateDeviceObject( IN PDRIVER_OBJECT DriverObject, IN PCCHAR ObjectNameBuffer, @@ -5977,7 +6006,9 @@ Return Value: Returns a status indicating success or failure of the operation. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassClaimDevice( IN PDEVICE_OBJECT LowerDeviceObject, IN BOOLEAN Release @@ -6108,7 +6139,9 @@ Return Value: Returns back a STATUS_PENDING or a completion status. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassInternalIoControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp @@ -6180,7 +6213,9 @@ Return Value: None, but it sets a new default timeout for a class of devices. --*/ +SCSIPORTAPI ULONG +NTAPI ClassQueryTimeOutRegistryValue( IN PDEVICE_OBJECT DeviceObject ) @@ -6287,7 +6322,9 @@ Return Value: NT status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassCheckVerifyComplete( IN PDEVICE_OBJECT Fdo, IN PIRP Irp, @@ -6352,7 +6389,9 @@ Return Value: buffer allocated on behalf of the caller. --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassGetDescriptor( IN PDEVICE_OBJECT DeviceObject, IN PSTORAGE_PROPERTY_ID PropertyId, @@ -6501,7 +6540,9 @@ Return Value: STATUS_MORE_PROCESSING_REQUIRED --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSignalCompletion( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -6588,7 +6629,9 @@ Return Value: None --*/ +SCSIPORTAPI VOID +NTAPI ClassMarkChildrenMissing( IN PFUNCTIONAL_DEVICE_EXTENSION Fdo ) @@ -6640,7 +6683,9 @@ Return Value: to PNP. --*/ +SCSIPORTAPI BOOLEAN +NTAPI ClassMarkChildMissing( IN PPHYSICAL_DEVICE_EXTENSION Child, IN BOOLEAN AcquireChildLock @@ -6894,7 +6939,9 @@ Return Value: none --*/ +SCSIPORTAPI VOID +NTAPI ClassInvalidateBusRelations( IN PDEVICE_OBJECT Fdo ) @@ -6949,7 +6996,9 @@ Return Value: status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassRemoveDevice( IN PDEVICE_OBJECT DeviceObject, IN UCHAR RemoveType @@ -7213,7 +7262,9 @@ Return Value: Either NULL if none, or a pointer to the driver extension --*/ +SCSIPORTAPI PCLASS_DRIVER_EXTENSION +NTAPI ClassGetDriverExtension( IN PDRIVER_OBJECT DriverObject ) @@ -7297,7 +7348,9 @@ Return Value: None --*/ +SCSIPORTAPI VOID +NTAPI ClassUpdateInformationInRegistry( IN PDEVICE_OBJECT Fdo, IN PCHAR DeviceName, @@ -7634,7 +7687,9 @@ Arguments: Return Value: --*/ +SCSIPORTAPI VOID +NTAPI ClassSendDeviceIoControlSynchronous( IN ULONG IoControlCode, IN PDEVICE_OBJECT TargetDeviceObject, @@ -7891,7 +7946,9 @@ Arguments: Return Value: --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassForwardIrpSynchronous( IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PIRP Irp @@ -7920,7 +7977,9 @@ Arguments: Return Value: --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSendIrpSynchronous( IN PDEVICE_OBJECT TargetDeviceObject, IN PIRP Irp @@ -8019,7 +8078,9 @@ Return Value: the VPB, or NULL if none. --*/ +SCSIPORTAPI PVPB +NTAPI ClassGetVpb( IN PDEVICE_OBJECT DeviceObject ) @@ -8128,7 +8189,9 @@ Return Value: None. --*/ +SCSIPORTAPI VOID +NTAPI ClassReleaseQueue( IN PDEVICE_OBJECT Fdo ) @@ -8448,7 +8511,9 @@ Return Value: None --*/ +SCSIPORTAPI VOID +NTAPI ClassAcquireChildLock( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) @@ -8490,7 +8555,9 @@ Return Value: None. --*/ +SCSIPORTAPI VOID +NTAPI ClassReleaseChildLock( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension ) diff --git a/drivers/storage/classpnp/classp.h b/drivers/storage/classpnp/classp.h index 43dc218a309..7c37a2674dc 100644 --- a/drivers/storage/classpnp/classp.h +++ b/drivers/storage/classpnp/classp.h @@ -424,7 +424,7 @@ struct _CLASS_PRIVATE_FDO_DATA { BOOLEAN TimerStarted; BOOLEAN LoggedTURFailureSinceLastIO; - + // // privately allocated release queue irp // protected by fdoExtension->ReleaseQueueSpinLock @@ -508,6 +508,7 @@ static inline BOOLEAN SimpleIsSlistEmpty(SINGLE_LIST_ENTRY *SListHdr) } NTSTATUS +NTAPI DriverEntry( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath @@ -555,12 +556,6 @@ ClassDeviceControlDispatch( PIRP Irp ); -NTSTATUS -ClassDeviceControl( - PDEVICE_OBJECT DeviceObject, - PIRP Irp - ); - NTSTATUS ClassDispatchPnp( PDEVICE_OBJECT DeviceObject, @@ -573,12 +568,7 @@ ClassPnpStartDevice( ); NTSTATUS -ClassInternalIoControl ( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp - ); - -NTSTATUS +NTAPI ClassShutdownFlush( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp diff --git a/drivers/storage/classpnp/classwmi.c b/drivers/storage/classpnp/classwmi.c index bbd43a6999d..6cfdb89e15c 100644 --- a/drivers/storage/classpnp/classwmi.c +++ b/drivers/storage/classpnp/classwmi.c @@ -256,14 +256,14 @@ ClassSystemControl( ClassQueryWmiRegInfoEx = commonExtension->IsFdo ? driverExtension->ClassFdoQueryWmiRegInfoEx : driverExtension->ClassPdoQueryWmiRegInfoEx; - + if (ClassQueryWmiRegInfoEx == NULL) { status = classWmiInfo->ClassQueryWmiRegInfo( DeviceObject, &nameFlags, &name); - + RtlInitUnicodeString(&mofName, MOFRESOURCENAME); } else { RtlInitUnicodeString(&mofName, L""); @@ -545,13 +545,13 @@ Arguments: DeviceObject - Supplies a pointer to the device object for this request. Irp - Supplies the Irp making the request. - + Status - Status to complete the irp with. STATUS_BUFFER_TOO_SMALL is used to indicate that more buffer is required for the data requested. - + BufferUsed - number of bytes of actual data to return (not including WMI specific structures) - + PriorityBoost - priority boost to pass to ClassCompleteRequest Return Value: @@ -561,6 +561,7 @@ Return Value: --*/ SCSIPORTAPI NTSTATUS +NTAPI ClassWmiCompleteRequest( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -724,7 +725,9 @@ Return Value: status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassWmiFireEvent( IN PDEVICE_OBJECT DeviceObject, IN LPGUID Guid, diff --git a/drivers/storage/classpnp/lock.c b/drivers/storage/classpnp/lock.c index deea29eead6..27060a1210d 100644 --- a/drivers/storage/classpnp/lock.c +++ b/drivers/storage/classpnp/lock.c @@ -78,7 +78,9 @@ Return Value: lock. --*/ +SCSIPORTAPI ULONG +NTAPI ClassAcquireRemoveLockEx( IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PVOID Tag, @@ -123,14 +125,14 @@ ClassAcquireRemoveLockEx( &oldIrql); commonExtension->RemoveTrackingUntrackedCount++; - + DebugPrint((ClassDebugWarning, ">>>>>ClassAcquireRemoveLock: " "Cannot track Tag %p - currently %d untracked requsts\n", Tag, commonExtension->RemoveTrackingUntrackedCount)); KeReleaseSpinLock(&commonExtension->RemoveTrackingSpinlock, oldIrql); - } + } else { PREMOVE_TRACKING_BLOCK *removeTrackingList = (PREMOVE_TRACKING_BLOCK)&commonExtension->RemoveTrackingList; @@ -208,7 +210,9 @@ Return Value: none --*/ +SCSIPORTAPI VOID +NTAPI ClassReleaseRemoveLock( IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag @@ -361,9 +365,9 @@ Routine Description: Arguments: DeviceObject - the device object that was handling this request - + Irp - the irp to be completed by IoCompleteRequest - + PriorityBoost - the priority boost to pass to IoCompleteRequest Return Value: @@ -371,7 +375,9 @@ Return Value: none --*/ +SCSIPORTAPI VOID +NTAPI ClassCompleteRequest( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, diff --git a/drivers/storage/classpnp/obsolete.c b/drivers/storage/classpnp/obsolete.c index 1dec49c4306..ed0b774d46c 100644 --- a/drivers/storage/classpnp/obsolete.c +++ b/drivers/storage/classpnp/obsolete.c @@ -51,7 +51,10 @@ typedef struct _CSCAN_LIST_ENTRY { * StartIo routine when the transfer size is too large for the hardware. * We map it to our new read/write handler. */ -VOID ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes) +SCSIPORTAPI +VOID +NTAPI +ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes) { PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension; PCLASS_PRIVATE_FDO_DATA fdoData = fdoExt->PrivateFdoData; @@ -68,7 +71,7 @@ VOID ClassSplitRequest(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN ULONG MaximumBytes } ServiceTransferRequest(Fdo, Irp); -} +} /*++//////////////////////////////////////////////////////////////////////////// @@ -99,7 +102,9 @@ Return Value: NT status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassIoCompleteAssociated( IN PDEVICE_OBJECT Fdo, IN PIRP Irp, @@ -476,7 +481,9 @@ Return Value: NT Status --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassBuildRequest( PDEVICE_OBJECT Fdo, PIRP Irp @@ -739,13 +746,13 @@ VOID ClasspInsertCScanList(IN PLIST_ENTRY ListHead, IN PCSCAN_LIST_ENTRY Entry) DBGWARN(("ClasspInsertCScanList is OBSOLETE !")); // - // Iterate through the list. Insert this entry in the sorted list in - // order (after other requests for the same block). At each stop if + // Iterate through the list. Insert this entry in the sorted list in + // order (after other requests for the same block). At each stop if // blockNumber(Entry) >= blockNumber(t) then move on. // - for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink; - t != (PCSCAN_LIST_ENTRY) ListHead; + for(t = (PCSCAN_LIST_ENTRY) ListHead->Flink; + t != (PCSCAN_LIST_ENTRY) ListHead; t = (PCSCAN_LIST_ENTRY) t->Entry.Flink) { if(Entry->BlockNumber < t->BlockNumber) { @@ -768,7 +775,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. // @@ -787,25 +794,25 @@ Routine Description: to the access of the list. 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. Arguments: List - the list to insert into - + Irp - the irp to be inserted. - + BlockNumber - the block number for this request. - - LowPriority - indicates that the request is lower priority and should be - done on the next sweep across the disk. + + LowPriority - indicates that the request is lower priority and should be + done on the next sweep across the disk. Return Value: none - ---*/ + +--*/ { PCSCAN_LIST_ENTRY entry = (PCSCAN_LIST_ENTRY)Irp->Tail.Overlay.DriverContext; @@ -817,7 +824,7 @@ Return Value: 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. // @@ -838,22 +845,22 @@ VOID ClassFreeOrReuseSrb( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, Routine Description: - This routine will attempt to reuse the provided SRB to start a blocked - read/write request. + This routine will attempt to reuse the provided SRB to start a blocked + read/write request. If there is no need to reuse the request it will be returned to the SRB lookaside list. Arguments: Fdo - the device extension - + Srb - the SRB which is to be reused or freed. - + Return Value: none. - ---*/ + +--*/ { PCLASS_PRIVATE_FDO_DATA privateData = FdoExtension->PrivateFdoData; @@ -869,7 +876,7 @@ Return Value: // memory leak. // ASSERT(!TEST_FLAG(Srb->SrbFlags, SRB_FLAGS_FREE_SENSE_BUFFER)); - + if (commonExt->IsSrbLookasideListInitialized){ /* * Put the SRB back in our lookaside list. @@ -896,7 +903,7 @@ Routine Description: This routine deletes a lookaside listhead for srbs, and should be called only during the final removal. - + If called at other times, the caller is responsible for synchronization and removal issues. @@ -909,7 +916,10 @@ Return Value: None --*/ -VOID ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension) +SCSIPORTAPI +VOID +NTAPI +ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension) { PAGED_CODE(); @@ -923,7 +933,7 @@ VOID ClassDeleteSrbLookasideList(IN PCOMMON_DEVICE_EXTENSION CommonExtension) else { DBGWARN(("ClassDeleteSrbLookasideList: attempt to delete uninitialized or freed srblookasidelist")); } -} +} /*++//////////////////////////////////////////////////////////////////////////// @@ -934,7 +944,7 @@ Routine Description: This routine sets up a lookaside listhead for srbs, and should be called only from the ClassInitDevice() routine to prevent race conditions. - + If called from other locations, the caller is responsible for synchronization and removal issues. @@ -944,7 +954,7 @@ Arguments: NumberElements - Supplies the maximum depth of the lookaside list. - + Note: The Windows 2000 version of classpnp did not return any status value from @@ -952,7 +962,10 @@ Note: --*/ -VOID ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtension, +SCSIPORTAPI +VOID +NTAPI +ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN ULONG NumberElements) { PAGED_CODE(); @@ -973,8 +986,8 @@ VOID ClassInitializeSrbLookasideList( IN PCOMMON_DEVICE_EXTENSION CommonExtens CommonExtension->IsSrbLookasideListInitialized = TRUE; } - -} + +} @@ -1008,7 +1021,7 @@ VOID ClasspStartNextSweep(PCSCAN_LIST List) 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. // diff --git a/drivers/storage/classpnp/power.c b/drivers/storage/classpnp/power.c index 26d4d0172c2..fdbb581437f 100644 --- a/drivers/storage/classpnp/power.c +++ b/drivers/storage/classpnp/power.c @@ -77,8 +77,8 @@ Routine Description: Arguments: - DeviceObject - - Irp - + DeviceObject - + Irp - Return Value: @@ -151,7 +151,7 @@ Return Value: STATUS_MORE_PROCESSING_REQUIRED or STATUS_SUCCESS - + --*/ NTSTATUS ClasspPowerUpCompletion( @@ -389,7 +389,7 @@ ClasspPowerUpCompletion( break; } - + // reset retries Context->RetryCount = MAXIMUM_RETRIES; @@ -406,7 +406,7 @@ ClasspPowerUpCompletionFailure: 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; @@ -466,7 +466,7 @@ ClasspPowerUpCompletionFailure: // Indicate to Po that we've been successfully powered up so // it can do it's notification stuff. // - + PoSetPowerState(DeviceObject, currentStack->Parameters.Power.Type, currentStack->Parameters.Power.State); @@ -623,45 +623,45 @@ ClasspPowerDownCompletion( // // 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 | 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; - + RtlZeroMemory(cdb, sizeof(CDB)); cdb->SYNCHRONIZE_CACHE10.OperationCode = SCSIOP_SYNCHRONIZE_CACHE; - + IoSetCompletionRoutine(Irp, ClasspPowerDownCompletion, Context, TRUE, TRUE, TRUE); - + 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++; @@ -671,7 +671,7 @@ ClasspPowerDownCompletion( // no break in case the device doesn't like synch_cache commands } - + case PowerDownDeviceFlushed2: { PCDB cdb; @@ -843,9 +843,9 @@ ClasspPowerDownCompletion( // if (!NT_SUCCESS(status)) { - + PSENSE_DATA senseBuffer = Context->Srb.SenseInfoBuffer; - + if (TEST_FLAG(Context->Srb.SrbStatus, SRB_STATUS_AUTOSENSE_VALID) && ((senseBuffer->SenseKey & 0xf) == SCSI_SENSE_NOT_READY) && @@ -881,7 +881,7 @@ ClasspPowerDownCompletion( DebugPrint((1, "(%p)\tPoCallDriver returned %lx\n", Irp, status)); break; } - + // else fall through w/o sending the power irp, since the device // is reporting an error that would be "really bad" to power down // during. @@ -900,7 +900,7 @@ ClasspPowerDownCompletion( if (Context->QueueLocked) { DebugPrint((1, "(%p)\tUnlocking queue\n", Irp)); - + Context->Srb.Length = sizeof(SCSI_REQUEST_BLOCK); Context->Srb.SrbStatus = Context->Srb.ScsiStatus = 0; @@ -956,7 +956,7 @@ ClasspPowerDownCompletion( Irp->IoStatus.Information = 0; if (NT_SUCCESS(status)) { - + // // Set the new power state // @@ -989,7 +989,7 @@ Routine Description: This routine reduces the number of useless spinups and spindown requests sent to a given device by ignoring transitions to power states we are currently in. - + ISSUE-2000/02/20-henrygab - by ignoring spin-up requests, we may be allowing the drive @@ -1046,7 +1046,7 @@ ClasspPowerHandler( irpStack->Parameters.Power.State.SystemState)); switch (irpStack->Parameters.Power.ShutdownType){ - + case PowerActionSleep: case PowerActionHibernate: if (fdoData->HotplugInfo.MediaRemovable || fdoData->HotplugInfo.MediaHotplug){ @@ -1060,7 +1060,7 @@ ClasspPowerHandler( } break; } - + break; } @@ -1311,7 +1311,7 @@ ClassMinimalPowerHandler( if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) { - PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = + PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension; // @@ -1319,9 +1319,9 @@ ClassMinimalPowerHandler( // if (irpStack->MinorFunction == IRP_MN_SET_POWER){ PVPB vpb; - + switch (irpStack->Parameters.Power.ShutdownType){ - + case PowerActionSleep: case PowerActionHibernate: // @@ -1331,11 +1331,11 @@ ClassMinimalPowerHandler( // vpb = ClassGetVpb(fdoExtension->DeviceObject); if (vpb && (vpb->Flags & VPB_MOUNTED)){ - SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME); - } + SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME); + } break; } - } + } } IoCopyCurrentIrpStackLocationToNext(Irp); @@ -1345,7 +1345,7 @@ ClassMinimalPowerHandler( if (irpStack->MinorFunction != IRP_MN_SET_POWER && irpStack->MinorFunction != IRP_MN_QUERY_POWER) { - + NOTHING; } else { @@ -1371,7 +1371,7 @@ Routine Description: 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 commands, but i digress). - + Determines proper use of spinup, spindown, and queue locking based upon ScanForSpecialFlags in the FdoExtension. This is the most common power handler passed into classpnp.sys @@ -1387,7 +1387,9 @@ Return Value: None --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassSpinDownPowerHandler( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp @@ -1449,12 +1451,14 @@ Routine Description: This routine is an outdated call. To achieve equivalent functionality, the driver should set the following flags in ScanForSpecialFlags in the FdoExtension: - + CLASS_SPECIAL_DISABLE_SPIN_UP CLASS_SPECIAL_NO_QUEUE_LOCK --*/ +SCSIPORTAPI NTSTATUS +NTAPI ClassStopUnitPowerHandler( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp diff --git a/drivers/storage/classpnp/utils.c b/drivers/storage/classpnp/utils.c index 43dd04916d1..f452d5fee65 100644 --- a/drivers/storage/classpnp/utils.c +++ b/drivers/storage/classpnp/utils.c @@ -55,7 +55,10 @@ BOOLEAN ClasspMyStringMatches(IN PCHAR StringToMatch OPTIONAL, IN PCHAR TargetSt } -VOID ClassGetDeviceParameter( +SCSIPORTAPI +VOID +NTAPI +ClassGetDeviceParameter( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, @@ -140,7 +143,10 @@ VOID ClassGetDeviceParameter( } // end ClassGetDeviceParameter() -NTSTATUS ClassSetDeviceParameter( +SCSIPORTAPI +NTSTATUS +NTAPI +ClassSetDeviceParameter( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, @@ -218,7 +224,10 @@ NTSTATUS ClassSetDeviceParameter( * hardware based upon id strings. it does not check the registry. */ -VOID ClassScanForSpecial( +SCSIPORTAPI +VOID +NTAPI +ClassScanForSpecial( IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[], IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function) -- 2.17.1