140 DPRINT(
"USBSTOR_CSWCompletionRoutine Irp %p Ctx %p Status %x\n",
Irp, Ctx,
Irp->IoStatus.Status);
145 Context = &FDODeviceExtension->CurrentIrpContext;
154 if (
Context->StallRetryCount < 2)
166 DPRINT1(
"USBSTOR_CSWCompletionRoutine: Urb.Hdr.Status - %x\n",
Context->Urb.UrbHeader.Status);
182 if (
Request != FDODeviceExtension->ActiveSrb)
185 FDODeviceExtension->ActiveSrb->SenseInfoBufferLength =
Request->DataTransferLength;
186 Request = FDODeviceExtension->ActiveSrb;
196 DPRINT(
"USBSTOR_CSWCompletionRoutine: CSW_STATUS_COMMAND_FAILED\n");
204 Request->DataTransferLength = 0;
209 Request->SenseInfoBufferLength &&
219 Irp->IoStatus.Information =
Request->DataTransferLength;
229 Request = FDODeviceExtension->ActiveSrb;
231 Irp->IoStatus.Information = 0;
248 FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle,
251 &FDODeviceExtension->CurrentIrpContext.csw,
271 DPRINT(
"USBSTOR_DataCompletionRoutine Irp %p Ctx %p Status %x\n",
Irp, Ctx,
Irp->IoStatus.Status);
274 Context = &FDODeviceExtension->CurrentIrpContext;
280 if (
Request == FDODeviceExtension->ActiveSrb &&
281 Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL !=
Irp->MdlAddress)
288 if (
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength <
Request->DataTransferLength)
297 Request->DataTransferLength =
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength;
305 Request->DataTransferLength =
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength;
312 Irp->IoStatus.Information = 0;
343 DPRINT(
"USBSTOR_CBWCompletionRoutine Irp %p Ctx %p Status %x\n",
Irp, Ctx,
Irp->IoStatus.Status);
357 if (!
Irp->MdlAddress &&
Request == FDODeviceExtension->ActiveSrb)
368 PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkInPipeIndex].PipeHandle;
373 PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle;
379 DPRINT1(
"Warning: shouldn't be here\n");
384 if (
Request == FDODeviceExtension->ActiveSrb)
409 DPRINT1(
"USBSTOR_CBWCompletionRoutine: Mdl - %p\n",
Mdl);
431 Request = FDODeviceExtension->ActiveSrb;
433 Irp->IoStatus.Information = 0;
447 DPRINT(
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
448 Block[0] & 0xFF, Block[1] & 0xFF, Block[2] & 0xFF, Block[3] & 0xFF, Block[4] & 0xFF, Block[5] & 0xFF, Block[6] & 0xFF, Block[7] & 0xFF, Block[8] & 0xFF, Block[9] & 0xFF,
449 Block[10] & 0xFF, Block[11] & 0xFF, Block[12] & 0xFF, Block[13] & 0xFF, Block[14] & 0xFF, Block[15] & 0xFF, Block[16] & 0xFF, Block[17] & 0xFF, Block[18] & 0xFF, Block[19] & 0xFF,
450 Block[20] & 0xFF, Block[21] & 0xFF, Block[22] & 0xFF, Block[23] & 0xFF, Block[24] & 0xFF, Block[25] & 0xFF, Block[26] & 0xFF, Block[27] & 0xFF, Block[28] & 0xFF, Block[29] & 0xFF,
477 Context->cbw.LUN = PDODeviceExtension->LUN;
492 FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle,
510 DPRINT(
"USBSTOR_IssueRequestSense: \n");
512 CurrentSrb = FDODeviceExtension->ActiveSrb;
513 SenseSrb = &FDODeviceExtension->CurrentIrpContext.SenseSrb;
520 SenseSrb->
Length =
sizeof(*SenseSrb);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PSCSI_REQUEST_BLOCK Srb
#define SCSIOP_REQUEST_SENSE
#define CDB6GENERIC_LENGTH
#define NT_SUCCESS(StatCode)
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
struct _PDO_DEVICE_EXTENSION * PPDO_DEVICE_EXTENSION
#define SRB_STATUS_INVALID_LUN
#define SRB_STATUS_NO_HBA
#define SRB_STATUS_BUS_RESET
#define SRB_STATUS_INVALID_TARGET_ID
#define SRB_FUNCTION_EXECUTE_SCSI
#define SRB_STATUS_DATA_OVERRUN
#define SRB_FLAGS_DATA_OUT
#define SRB_STATUS_BAD_SRB_BLOCK_LENGTH
#define SRB_STATUS_TIMEOUT
#define SRB_STATUS_AUTOSENSE_VALID
#define SRB_FLAGS_DISABLE_AUTOSENSE
#define SRB_FLAGS_DATA_IN
#define SRB_STATUS_SELECTION_TIMEOUT
#define SRB_STATUS_BAD_FUNCTION
#define SRB_FLAGS_UNSPECIFIED_DIRECTION
#define SRB_STATUS(Status)
#define SRB_STATUS_COMMAND_TIMEOUT
#define SRB_STATUS_NO_DEVICE
#define SRB_FLAGS_NO_QUEUE_FREEZE
#define SRB_STATUS_SUCCESS
VOID NTAPI USBSTOR_QueueResetDevice(IN PFDO_DEVICE_EXTENSION FDODeviceExtension)
VOID NTAPI USBSTOR_QueueResetPipe(IN PFDO_DEVICE_EXTENSION FDODeviceExtension)
VOID USBSTOR_QueueTerminateRequest(IN PDEVICE_OBJECT FDODeviceObject, IN PIRP Irp)
VOID USBSTOR_QueueNextRequest(IN PDEVICE_OBJECT DeviceObject)
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
#define STATUS_DEVICE_DOES_NOT_EXIST
#define STATUS_MORE_PROCESSING_REQUIRED
#define STATUS_BUFFER_OVERFLOW
struct _IO_STACK_LOCATION::@1583::@1584 DeviceIoControl
struct _IO_STACK_LOCATION::@3982::@4004 Scsi
PDEVICE_OBJECT DeviceObject
union _IO_STACK_LOCATION::@1583 Parameters
struct _IO_STACK_LOCATION::@3982::@4021 Others
COMMON_DEVICE_EXTENSION Common
UCHAR SenseInfoBufferLength
ULONG TransferBufferLength
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_IO_DEVICE_ERROR
#define STATUS_INVALID_DEVICE_REQUEST
#define STATUS_DEVICE_NOT_CONNECTED
#define STATUS_IO_TIMEOUT
NTSTATUS USBSTOR_HandleExecuteSCSI(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
IO_COMPLETION_ROUTINE USBSTOR_CSWCompletionRoutine
NTSTATUS USBSTOR_SendCSWRequest(PFDO_DEVICE_EXTENSION FDODeviceExtension, PIRP Irp)
VOID DumpCBW(PUCHAR Block)
static NTSTATUS USBSTOR_IssueRequestSense(IN PFDO_DEVICE_EXTENSION FDODeviceExtension, IN PIRP Irp)
static NTSTATUS USBSTOR_SendCBWRequest(IN PFDO_DEVICE_EXTENSION FDODeviceExtension, IN PIRP Irp)
IO_COMPLETION_ROUTINE USBSTOR_CBWCompletionRoutine
static NTSTATUS USBSTOR_IssueBulkOrInterruptRequest(IN PFDO_DEVICE_EXTENSION FDODeviceExtension, IN PIRP Irp, IN USBD_PIPE_HANDLE PipeHandle, IN ULONG TransferFlags, IN ULONG TransferBufferLength, IN PVOID TransferBuffer, IN PMDL TransferBufferMDL, IN PIO_COMPLETION_ROUTINE CompletionRoutine)
static BOOLEAN USBSTOR_IsCSWValid(PIRP_CONTEXT Context)
IO_COMPLETION_ROUTINE USBSTOR_DataCompletionRoutine
static NTSTATUS USBSTOR_SrbStatusToNtStatus(IN PSCSI_REQUEST_BLOCK Srb)
#define USBD_STATUS_STALL_PID
#define USBD_TRANSFER_DIRECTION_IN
#define USBD_SHORT_TRANSFER_OK
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
#define USBD_TRANSFER_DIRECTION_OUT
#define USBD_STATUS(Status)
#define IOCTL_INTERNAL_USB_SUBMIT_URB
#define CSW_STATUS_PHASE_ERROR
#define CSW_STATUS_COMMAND_PASSED
#define CSW_STATUS_COMMAND_FAILED
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
#define STATUS_CONTINUE_COMPLETION
IO_COMPLETION_ROUTINE * PIO_COMPLETION_ROUTINE
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
#define MmGetMdlVirtualAddress(_Mdl)