mirror of
https://github.com/reactos/reactos.git
synced 2025-01-01 03:54:02 +00:00
[USBSTOR]
- Start implementing write command - Disabled for now as it causes corruptions svn path=/branches/usb-bringup/; revision=51695
This commit is contained in:
parent
89aa9d3264
commit
3f8c058a07
3 changed files with 42 additions and 16 deletions
|
@ -50,14 +50,14 @@ USBSTOR_HandleExecuteSCSI(
|
|||
//
|
||||
Status = USBSTOR_SendModeSenseCmd(DeviceObject, Irp);
|
||||
}
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ)
|
||||
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ /*|| pCDB->MODE_SENSE.OperationCode == SCSIOP_WRITE*/)
|
||||
{
|
||||
DPRINT1("SCSIOP_READ DataTransferLength %lu\n", Request->DataTransferLength);
|
||||
DPRINT1("SCSIOP_READ / SCSIOP_WRITE DataTransferLength %lu\n", Request->DataTransferLength);
|
||||
|
||||
//
|
||||
// send read command
|
||||
// send read / write command
|
||||
//
|
||||
Status = USBSTOR_SendReadCmd(DeviceObject, Irp);
|
||||
Status = USBSTOR_SendReadWriteCmd(DeviceObject, Irp);
|
||||
}
|
||||
else if (pCDB->AsByte[0] == SCSIOP_MEDIUM_REMOVAL)
|
||||
{
|
||||
|
|
|
@ -332,6 +332,8 @@ USBSTOR_CBWCompletionRoutine(
|
|||
{
|
||||
PIRP_CONTEXT Context;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
UCHAR Code;
|
||||
USBD_PIPE_HANDLE PipeHandle;
|
||||
|
||||
DPRINT1("USBSTOR_CBWCompletionRoutine Irp %p Ctx %p\n", Irp, Ctx);
|
||||
|
||||
|
@ -350,13 +352,32 @@ USBSTOR_CBWCompletionRoutine(
|
|||
//
|
||||
if (Context->TransferDataLength)
|
||||
{
|
||||
//
|
||||
// get command code
|
||||
//
|
||||
Code = Context->cbw->CommandBlock[0];
|
||||
|
||||
if (Code == SCSIOP_WRITE)
|
||||
{
|
||||
//
|
||||
// write request use bulk out pipe
|
||||
//
|
||||
PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkOutPipeIndex].PipeHandle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// default bulk in pipe
|
||||
//
|
||||
PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle;
|
||||
}
|
||||
|
||||
//
|
||||
// now initialize the urb for sending data
|
||||
//
|
||||
|
||||
UsbBuildInterruptOrBulkTransferRequest(&Context->Urb,
|
||||
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
|
||||
Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle,
|
||||
PipeHandle,
|
||||
NULL,
|
||||
Context->TransferBufferMDL,
|
||||
Context->TransferDataLength,
|
||||
|
@ -871,11 +892,11 @@ USBSTOR_SendModeSenseCmd(
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendReadCmd(
|
||||
USBSTOR_SendReadWriteCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
UFI_READ_CMD Cmd;
|
||||
UFI_READ_WRITE_CMD Cmd;
|
||||
NTSTATUS Status;
|
||||
PPDO_DEVICE_EXTENSION PDODeviceExtension;
|
||||
PCDB pCDB;
|
||||
|
@ -907,7 +928,12 @@ USBSTOR_SendReadCmd(
|
|||
//
|
||||
// informal debug print
|
||||
//
|
||||
DPRINT1("USBSTOR_SendReadCmd DataTransferLength %x, BlockLength %x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength);
|
||||
DPRINT1("USBSTOR_SendReadWriteCmd DataTransferLength %x, BlockLength %x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength);
|
||||
|
||||
//
|
||||
// sanity check
|
||||
//
|
||||
ASSERT(PDODeviceExtension->BlockLength);
|
||||
|
||||
//
|
||||
// block count
|
||||
|
@ -917,8 +943,8 @@ USBSTOR_SendReadCmd(
|
|||
//
|
||||
// initialize read cmd
|
||||
//
|
||||
RtlZeroMemory(&Cmd, sizeof(UFI_READ_CMD));
|
||||
Cmd.Code = SCSIOP_READ;
|
||||
RtlZeroMemory(&Cmd, sizeof(UFI_READ_WRITE_CMD));
|
||||
Cmd.Code = pCDB->AsByte[0];
|
||||
Cmd.LUN = (PDODeviceExtension->LUN & MAX_LUN);
|
||||
Cmd.ContiguousLogicBlocks = _byteswap_ushort(BlockCount);
|
||||
Cmd.LogicalBlockByte0 = pCDB->CDB10.LogicalBlockByte0;
|
||||
|
@ -931,7 +957,7 @@ USBSTOR_SendReadCmd(
|
|||
//
|
||||
// send request
|
||||
//
|
||||
return USBSTOR_SendRequest(DeviceObject, Irp, NULL, UFI_READ_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, (PUCHAR)Request->DataBuffer);
|
||||
return USBSTOR_SendRequest(DeviceObject, Irp, NULL, UFI_READ_WRITE_CMD_LEN, (PUCHAR)&Cmd, Request->DataTransferLength, (PUCHAR)Request->DataBuffer);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -158,11 +158,11 @@ typedef struct
|
|||
UCHAR Reserved; // reserved 0x00
|
||||
USHORT ContiguousLogicBlocks; // num of contiguous logical blocks
|
||||
UCHAR Reserved1[3]; // reserved 0x00
|
||||
}UFI_READ_CMD;
|
||||
}UFI_READ_WRITE_CMD;
|
||||
|
||||
C_ASSERT(sizeof(UFI_READ_CMD) == 12);
|
||||
C_ASSERT(sizeof(UFI_READ_WRITE_CMD) == 12);
|
||||
|
||||
#define UFI_READ_CMD_LEN (0xA)
|
||||
#define UFI_READ_WRITE_CMD_LEN (0xA)
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -375,7 +375,7 @@ USBSTOR_SendModeSenseCmd(
|
|||
IN PIRP Irp);
|
||||
|
||||
NTSTATUS
|
||||
USBSTOR_SendReadCmd(
|
||||
USBSTOR_SendReadWriteCmd(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue