Author: janderwald
Date: Fri May 13 13:37:50 2011
New Revision: 51693
URL:
http://svn.reactos.org/svn/reactos?rev=51693&view=rev
Log:
[USBSTOR]
- Handle SCSIOP_MEDIUM_REMOVAL
- Handle paging i/o requests. These request don't provide a data buffer in the srb,
but the buffer is stored in the irp' mdl
- Fix the hack for unimplemented Mode Sense command
- Usbstor now completes initializes and receives read requests
- Still need to fix read request, as Windows XP fails to recognize the disk format, WIP
Modified:
branches/usb-bringup/drivers/usb/usbstor/disk.c
branches/usb-bringup/drivers/usb/usbstor/scsi.c
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 13:37:50 2011
@@ -53,12 +53,24 @@
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_READ)
{
DPRINT1("SCSIOP_READ DataTransferLength %lu\n",
Request->DataTransferLength);
- ASSERT(Request->DataBuffer);
//
// send read command
//
Status = USBSTOR_SendReadCmd(DeviceObject, Irp);
+ }
+ else if (pCDB->AsByte[0] == SCSIOP_MEDIUM_REMOVAL)
+ {
+ DPRINT1("SCSIOP_MEDIUM_REMOVAL\n");
+
+ //
+ // just complete the request
+ //
+ Request->SrbStatus = SRB_STATUS_SUCCESS;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = Request->DataTransferLength;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
}
else if (pCDB->MODE_SENSE.OperationCode == SCSIOP_TEST_UNIT_READY)
{
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 13:37:50 2011
@@ -110,12 +110,34 @@
//
Context = (PIRP_CONTEXT)Ctx;
+ //
+ // is there a mdl
+ //
if (Context->TransferBufferMDL)
{
//
- // free mdl
- //
- IoFreeMdl(Context->TransferBufferMDL);
+ // is there an irp associated
+ //
+ if (Context->Irp)
+ {
+ //
+ // did we allocate the mdl
+ //
+ if (Context->TransferBufferMDL != Context->Irp->MdlAddress)
+ {
+ //
+ // free mdl
+ //
+ IoFreeMdl(Context->TransferBufferMDL);
+ }
+ }
+ else
+ {
+ //
+ // free mdl
+ //
+ IoFreeMdl(Context->TransferBufferMDL);
+ }
}
if (Context->Irp)
@@ -317,7 +339,6 @@
// access context
//
Context = (PIRP_CONTEXT)Ctx;
-
//
// get next stack location
@@ -461,15 +482,46 @@
if (Context->TransferDataLength)
{
//
- // allocate mdl for buffer, buffer must be allocated from NonPagedPool
- //
- Context->TransferBufferMDL = IoAllocateMdl(Context->TransferData,
Context->TransferDataLength, FALSE, FALSE, NULL);
- if (!Context->TransferBufferMDL)
+ // check if the original request already does not have an mdl associated
+ //
+ if (OriginalRequest)
{
- //
- // failed to allocate MDL
- //
- return STATUS_INSUFFICIENT_RESOURCES;
+ if (OriginalRequest->MdlAddress != NULL &&
Context->TransferData == NULL)
+ {
+ //
+ // I/O paging request
+ //
+ Context->TransferBufferMDL = OriginalRequest->MdlAddress;
+ }
+ else
+ {
+ //
+ // allocate mdl for buffer, buffer must be allocated from NonPagedPool
+ //
+ Context->TransferBufferMDL = IoAllocateMdl(Context->TransferData,
Context->TransferDataLength, FALSE, FALSE, NULL);
+ if (!Context->TransferBufferMDL)
+ {
+ //
+ // failed to allocate MDL
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ }
+ }
+ else
+ {
+ //
+ // allocate mdl for buffer, buffer must be allocated from NonPagedPool
+ //
+ Context->TransferBufferMDL = IoAllocateMdl(Context->TransferData,
Context->TransferDataLength, FALSE, FALSE, NULL);
+ if (!Context->TransferBufferMDL)
+ {
+ //
+ // failed to allocate MDL
+ //
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
}
//
@@ -656,8 +708,26 @@
PCDB pCDB;
PUFI_MODE_PARAMETER_HEADER Header;
- ASSERT(FALSE);
- return STATUS_NOT_IMPLEMENTED;
+ PIO_STACK_LOCATION IoStack;
+ PSCSI_REQUEST_BLOCK Request;
+
+ //
+ // get current stack location
+ //
+ IoStack = IoGetCurrentIrpStackLocation(Irp);
+
+ //
+ // get request block
+ //
+ Request = (PSCSI_REQUEST_BLOCK)IoStack->Parameters.Others.Argument1;
+
+ RtlZeroMemory(Request->DataBuffer, Request->DataTransferLength);
+ Request->SrbStatus = SRB_STATUS_SUCCESS;
+ Irp->IoStatus.Information = Request->DataTransferLength;
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ return STATUS_SUCCESS;
#if 0
//
@@ -808,6 +878,7 @@
ULONG BlockCount;
PIO_STACK_LOCATION IoStack;
PSCSI_REQUEST_BLOCK Request;
+ PVOID Buffer;
//
// get current stack location
@@ -830,10 +901,9 @@
PDODeviceExtension = (PPDO_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
//
- // FIXME: support more logical blocks
- //
- DPRINT1("Request->DataTransferLength %x, PDODeviceExtension->BlockLength
%x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength);
- ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength);
+ // informal debug print
+ //
+ DPRINT1("USBSTOR_SendReadCmd DataTransferLength %x, BlockLength %x\n",
Request->DataTransferLength, PDODeviceExtension->BlockLength);
//
// block count
@@ -855,7 +925,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_CMD_LEN, (PUCHAR)&Cmd,
Request->DataTransferLength, (PUCHAR)Request->DataBuffer);
}
NTSTATUS