26 DPRINT(
"Allocating URB\n");
53 DPRINT(
"Allocating URB\n");
102 DPRINT(
"USBSTOR_ResetDeviceWorkItemRoutine\n");
104 FDODeviceExtension = FdoDevice->DeviceExtension;
106 for (ix = 0; ix < 3; ++ix)
113 Status =
USBSTOR_ResetPipeWithHandle(FDODeviceExtension->LowerDeviceObject, FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle);
117 Status =
USBSTOR_ResetPipeWithHandle(FDODeviceExtension->LowerDeviceObject, FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle);
127 FDODeviceExtension->
Flags &= ~USBSTOR_FDO_FLAGS_DEVICE_RESETTING;
138 DPRINT(
"USBSTOR_QueueResetPipe\n");
153 DPRINT(
"USBSTOR_QueueResetDevice\n");
182 Status =
USBSTOR_ResetPipeWithHandle(FDODeviceExtension->LowerDeviceObject, FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle);
186 Status =
USBSTOR_ResetPipeWithHandle(FDODeviceExtension->LowerDeviceObject, FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle);
192 FDODeviceExtension->LastTimerActiveSrb =
NULL;
198 FDODeviceExtension->TimerWorkQueueEnabled =
FALSE;
214 DPRINT1(
"[USBSTOR] TimerRoutine entered\n");
220 if (FDODeviceExtension->ActiveSrb && FDODeviceExtension->TimerWorkQueueEnabled)
222 if (FDODeviceExtension->LastTimerActiveSrb !=
NULL && FDODeviceExtension->LastTimerActiveSrb == FDODeviceExtension->ActiveSrb)
225 DPRINT1(
"[USBSTOR] ActiveSrb %p hang detected\n", FDODeviceExtension->ActiveSrb);
231 FDODeviceExtension->LastTimerActiveSrb = FDODeviceExtension->ActiveSrb;
237 FDODeviceExtension->LastTimerActiveSrb =
NULL;
243 if (
ResetDevice && FDODeviceExtension->TimerWorkQueueEnabled && FDODeviceExtension->SrbErrorHandlingActive ==
FALSE)
255 WorkItemData->
DeviceObject = FDODeviceExtension->FunctionalDeviceObject;
257 DPRINT1(
"[USBSTOR] Queing Timer WorkItem\n");
#define NT_SUCCESS(StatCode)
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
VOID NTAPI USBSTOR_ResetDeviceWorkItemRoutine(IN PDEVICE_OBJECT FdoDevice, IN PVOID Context)
VOID NTAPI USBSTOR_QueueResetDevice(IN PFDO_DEVICE_EXTENSION FDODeviceExtension)
NTSTATUS USBSTOR_ResetPipeWithHandle(IN PDEVICE_OBJECT DeviceObject, IN USBD_PIPE_HANDLE PipeHandle)
VOID NTAPI USBSTOR_QueueResetPipe(IN PFDO_DEVICE_EXTENSION FDODeviceExtension)
VOID NTAPI USBSTOR_ResetPipeWorkItemRoutine(IN PDEVICE_OBJECT FdoDevice, IN PVOID Ctx)
VOID NTAPI USBSTOR_TimerWorkerRoutine(IN PVOID Context)
NTSTATUS USBSTOR_GetEndpointStatus(IN PDEVICE_OBJECT DeviceObject, IN UCHAR bEndpointAddress, OUT PUSHORT Value)
VOID NTAPI USBSTOR_TimerRoutine(PDEVICE_OBJECT DeviceObject, PVOID Context)
NTSTATUS USBSTOR_SyncUrbRequest(IN PDEVICE_OBJECT DeviceObject, OUT PURB UrbRequest)
NTSTATUS USBSTOR_ResetDevice(IN PDEVICE_OBJECT DeviceObject, IN PFDO_DEVICE_EXTENSION DeviceExtension)
VOID USBSTOR_QueueNextRequest(IN PDEVICE_OBJECT DeviceObject)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
PVOID AllocateItem(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes)
VOID FreeItem(IN PVOID Item)
DWORD ResetDevice(DWORD private_handle)
#define ExFreePoolWithTag(_P, _T)
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
PDEVICE_OBJECT DeviceObject
WORK_QUEUE_ITEM WorkQueueItem
COMMON_DEVICE_EXTENSION Common
struct _URB_PIPE_REQUEST UrbPipeRequest
#define STATUS_INSUFFICIENT_RESOURCES
NTSTATUS USBSTOR_SendCSWRequest(PFDO_DEVICE_EXTENSION FDODeviceExtension, PIRP Irp)
#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
#define UsbBuildGetStatusRequest(urb, op, index, transferBuffer, transferBufferMDL, link)
#define USBSTOR_FDO_FLAGS_DEVICE_RESETTING
struct _ERRORHANDLER_WORKITEM_DATA * PERRORHANDLER_WORKITEM_DATA
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
#define ExInitializeWorkItem(Item, Routine, Context)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql