Author: janderwald
Date: Fri May 13 14:44:24 2011
New Revision: 51695
URL:
http://svn.reactos.org/svn/reactos?rev=51695&view=rev
Log:
[USBSTOR]
- Start implementing write command
- Disabled for now as it causes corruptions
Modified:
branches/usb-bringup/drivers/usb/usbstor/disk.c
branches/usb-bringup/drivers/usb/usbstor/scsi.c
branches/usb-bringup/drivers/usb/usbstor/usbstor.h
Modified: branches/usb-bringup/drivers/usb/usbstor/disk.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/disk.c [iso-8859-1] Fri May 13 14:44:24 2011
@@ -50,14 +50,14 @@
//
Status = USBSTOR_SendModeSenseCmd(DeviceObject, Irp);
}
- else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ)
- {
- DPRINT1("SCSIOP_READ DataTransferLength %lu\n",
Request->DataTransferLength);
-
- //
- // send read command
- //
- Status = USBSTOR_SendReadCmd(DeviceObject, Irp);
+ else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ /*||
pCDB->MODE_SENSE.OperationCode == SCSIOP_WRITE*/)
+ {
+ DPRINT1("SCSIOP_READ / SCSIOP_WRITE DataTransferLength %lu\n",
Request->DataTransferLength);
+
+ //
+ // send read / write command
+ //
+ Status = USBSTOR_SendReadWriteCmd(DeviceObject, Irp);
}
else if (pCDB->AsByte[0] == SCSIOP_MEDIUM_REMOVAL)
{
Modified: branches/usb-bringup/drivers/usb/usbstor/scsi.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/scsi.c [iso-8859-1] Fri May 13 14:44:24 2011
@@ -332,6 +332,8 @@
{
PIRP_CONTEXT Context;
PIO_STACK_LOCATION IoStack;
+ UCHAR Code;
+ USBD_PIPE_HANDLE PipeHandle;
DPRINT1("USBSTOR_CBWCompletionRoutine Irp %p Ctx %p\n", Irp, Ctx);
@@ -351,12 +353,31 @@
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 @@
}
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 @@
//
// 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 @@
//
// 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 @@
//
// 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
Modified: branches/usb-bringup/drivers/usb/usbstor/usbstor.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbstor/usbstor.h [iso-8859-1] Fri May 13 14:44:24
2011
@@ -158,11 +158,11 @@
UCHAR Reserved; // reserved 0x00
USHORT ContiguousLogicBlocks; // num of contiguous
logical blocks
UCHAR Reserved1[3]; // reserved 0x00
-}UFI_READ_CMD;
-
-C_ASSERT(sizeof(UFI_READ_CMD) == 12);
-
-#define UFI_READ_CMD_LEN (0xA)
+}UFI_READ_WRITE_CMD;
+
+C_ASSERT(sizeof(UFI_READ_WRITE_CMD) == 12);
+
+#define UFI_READ_WRITE_CMD_LEN (0xA)
//--------------------------------------------------------------------------------------------------------------------------------------------
//
@@ -375,7 +375,7 @@
IN PIRP Irp);
NTSTATUS
-USBSTOR_SendReadCmd(
+USBSTOR_SendReadWriteCmd(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);