mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[USBSTOR]
- Rewrite scsi method to act asynchronous svn path=/branches/usb-bringup/; revision=51673
This commit is contained in:
parent
4f76ebe078
commit
b0b03bfdd1
4 changed files with 516 additions and 585 deletions
|
@ -20,7 +20,6 @@ USBSTOR_HandleExecuteSCSI(
|
|||
{
|
||||
PCDB pCDB;
|
||||
NTSTATUS Status;
|
||||
ULONG TransferredLength;
|
||||
|
||||
//
|
||||
// get SCSI command data block
|
||||
|
@ -29,6 +28,7 @@ USBSTOR_HandleExecuteSCSI(
|
|||
|
||||
DPRINT1("USBSTOR_HandleExecuteSCSI Operation Code %x\n", pCDB->AsByte[0]);
|
||||
|
||||
|
||||
if (pCDB->AsByte[0] == SCSIOP_READ_CAPACITY)
|
||||
{
|
||||
//
|
||||
|
@ -36,43 +36,8 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
ASSERT(Request->DataBuffer);
|
||||
|
||||
if (Request->DataTransferLength == sizeof(READ_CAPACITY_DATA_EX))
|
||||
{
|
||||
//
|
||||
// retrieve capacity extended structure
|
||||
//
|
||||
Status = USBSTOR_SendCapacityCmd(DeviceObject, (PREAD_CAPACITY_DATA_EX)Request->DataBuffer, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// sanity check
|
||||
//
|
||||
ASSERT(Request->DataTransferLength == sizeof(READ_CAPACITY_DATA));
|
||||
|
||||
//
|
||||
// retrieve capacity
|
||||
//
|
||||
Status = USBSTOR_SendCapacityCmd(DeviceObject, NULL, (PREAD_CAPACITY_DATA)Request->DataBuffer);
|
||||
}
|
||||
DPRINT1("USBSTOR_SendCapacityCmd %x\n", Status);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// store returned info length
|
||||
//
|
||||
Irp->IoStatus.Information = Request->DataTransferLength;
|
||||
Request->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// failed to retrieve capacity
|
||||
//
|
||||
Irp->IoStatus.Information = 0;
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
DPRINT1("SCSIOP_READ_CAPACITY Length %\n", Request->DataTransferLength);
|
||||
Status = USBSTOR_SendCapacityCmd(DeviceObject, Irp);
|
||||
}
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_MODE_SENSE)
|
||||
{
|
||||
|
@ -83,25 +48,7 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
// send mode sense command
|
||||
//
|
||||
Status = USBSTOR_SendModeSenseCmd(DeviceObject, Request, &TransferredLength);
|
||||
DPRINT1("USBSTOR_SendModeSenseCmd Status %x BytesReturned %lu\n", Status, TransferredLength);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// store returned info length
|
||||
//
|
||||
Irp->IoStatus.Information = TransferredLength;
|
||||
Request->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// failed to retrieve sense data
|
||||
//
|
||||
Irp->IoStatus.Information = 0;
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
Status = USBSTOR_SendModeSenseCmd(DeviceObject, Irp);
|
||||
}
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ)
|
||||
{
|
||||
|
@ -111,25 +58,7 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
// send read command
|
||||
//
|
||||
Status = USBSTOR_SendReadCmd(DeviceObject, Request, &TransferredLength);
|
||||
DPRINT1("USBSTOR_SendReadCmd Status %x BytesReturned %lu\n", Status, TransferredLength);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// store returned info length
|
||||
//
|
||||
Irp->IoStatus.Information = TransferredLength;
|
||||
Request->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// failed to read
|
||||
//
|
||||
Irp->IoStatus.Information = 0;
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
Status = USBSTOR_SendReadCmd(DeviceObject, Irp);
|
||||
}
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_TEST_UNIT_READY)
|
||||
{
|
||||
|
@ -138,22 +67,7 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
// send test unit command
|
||||
//
|
||||
Status = USBSTOR_SendTestUnitCmd(DeviceObject, Request);
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
//
|
||||
// store returned info length
|
||||
//
|
||||
Request->SrbStatus = SRB_STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// test unit command failed
|
||||
//
|
||||
Request->SrbStatus = SRB_STATUS_ERROR;
|
||||
}
|
||||
Status = USBSTOR_SendTestUnitCmd(DeviceObject, Irp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -202,8 +116,7 @@ USBSTOR_HandleInternalDeviceControl(
|
|||
case SRB_FUNCTION_EXECUTE_SCSI:
|
||||
{
|
||||
DPRINT1("SRB_FUNCTION_EXECUTE_SCSI\n");
|
||||
Status = USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request, PDODeviceExtension);
|
||||
break;
|
||||
return USBSTOR_HandleExecuteSCSI(DeviceObject, Irp, Request, PDODeviceExtension);
|
||||
}
|
||||
case SRB_FUNCTION_RELEASE_DEVICE:
|
||||
{
|
||||
|
@ -280,6 +193,11 @@ USBSTOR_HandleInternalDeviceControl(
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// complete request
|
||||
//
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -165,11 +165,7 @@ USBSTOR_DispatchScsi(
|
|||
//
|
||||
// handle requests
|
||||
//
|
||||
Status = USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return Status;
|
||||
return USBSTOR_HandleInternalDeviceControl(DeviceObject, Irp);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -250,6 +250,25 @@ C_ASSERT(sizeof(UFI_TEST_UNIT_CMD) == 12);
|
|||
|
||||
#define UFI_TEST_UNIT_CMD_LEN (6)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
PCBW cbw;
|
||||
PCSW csw;
|
||||
};
|
||||
URB Urb;
|
||||
PIRP Irp;
|
||||
ULONG TransferDataLength;
|
||||
PUCHAR TransferData;
|
||||
PFDO_DEVICE_EXTENSION FDODeviceExtension;
|
||||
PPDO_DEVICE_EXTENSION PDODeviceExtension;
|
||||
PMDL TransferBufferMDL;
|
||||
PKEVENT Event;
|
||||
}IRP_CONTEXT, *PIRP_CONTEXT;
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
// fdo.c routines
|
||||
|
@ -345,26 +364,22 @@ USBSTOR_SendInquiryCmd(
|
|||
NTSTATUS
|
||||
USBSTOR_SendCapacityCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
OUT PREAD_CAPACITY_DATA_EX CapacityDataEx,
|
||||
OUT PREAD_CAPACITY_DATA CapacityData);
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendModeSenseCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request,
|
||||
OUT PULONG TransferBufferLength);
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendReadCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request,
|
||||
OUT PULONG TransferBufferLength);
|
||||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendTestUnitCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN OUT PSCSI_REQUEST_BLOCK Request);
|
||||
|
||||
IN PIRP Irp);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue