Author: mjmartin Date: Fri May 13 09:14:28 2011 New Revision: 51691
URL: http://svn.reactos.org/svn/reactos?rev=51691&view=rev Log: [USBSTOR] - Add a check at USBSTOR_FdoHandleStartDevice to make sure the device uses Bulk Transfers. - Use macros for initializing the Urbs. The macros ensure that the proper fields of the URB are set correctly. Fixes failing of getting device descriptor and getting devices BlockLength.
Modified: branches/usb-bringup/drivers/usb/usbstor/descriptor.c branches/usb-bringup/drivers/usb/usbstor/fdo.c branches/usb-bringup/drivers/usb/usbstor/scsi.c
Modified: branches/usb-bringup/drivers/usb/usbstor/descriptor.c URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/... ============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/descriptor.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/descriptor.c [iso-8859-1] Fri May 13 09:14:28 2011 @@ -60,13 +60,15 @@ // // initialize urb // - Urb->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE; - Urb->UrbHeader.Length = sizeof(URB); - Urb->UrbControlDescriptorRequest.DescriptorType = DescriptorType; - Urb->UrbControlDescriptorRequest.TransferBuffer = Descriptor; - Urb->UrbControlDescriptorRequest.TransferBufferLength = DescriptorLength; - Urb->UrbControlDescriptorRequest.Index = DescriptorIndex; - Urb->UrbControlDescriptorRequest.LanguageId = LanguageId; + UsbBuildGetDescriptorRequest(Urb, + sizeof(Urb->UrbControlDescriptorRequest), + DescriptorType, + DescriptorIndex, + LanguageId, + Descriptor, + NULL, + DescriptorLength, + NULL);
// // submit urb
Modified: branches/usb-bringup/drivers/usb/usbstor/fdo.c URL: http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbstor/... ============================================================================== --- branches/usb-bringup/drivers/usb/usbstor/fdo.c [iso-8859-1] (original) +++ branches/usb-bringup/drivers/usb/usbstor/fdo.c [iso-8859-1] Fri May 13 09:14:28 2011 @@ -124,6 +124,7 @@ IN PFDO_DEVICE_EXTENSION DeviceExtension, IN OUT PIRP Irp) { + PUSB_INTERFACE_DESCRIPTOR InterfaceDesc; NTSTATUS Status; UCHAR Index = 0;
@@ -157,6 +158,18 @@ // dump device descriptor // USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor); + + // + // Check that this device uses bulk transfers and is SCSI + // + InterfaceDesc = (PUSB_INTERFACE_DESCRIPTOR)((ULONG_PTR)DeviceExtension->ConfigurationDescriptor + sizeof(USB_CONFIGURATION_DESCRIPTOR)); + DPRINT1("bInterfaceSubClass %x\n", InterfaceDesc->bInterfaceSubClass); + if (InterfaceDesc->bInterfaceProtocol != 0x50) + { + DPRINT1("USB Device is not a bulk only device and is not currently supported\n"); + return STATUS_NOT_SUPPORTED; + } +
// // now select an interface @@ -290,6 +303,7 @@ // // just forward irp to lower device // + //IoSkipCurrentIrpStackLocation(Irp); Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp); break; }
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 09:14:28 2011 @@ -258,19 +258,20 @@ // // get next stack location // + IoStack = IoGetNextIrpStackLocation(Irp);
// // now initialize the urb for sending the csw // - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = NULL; - Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; - + UsbBuildInterruptOrBulkTransferRequest(&Context->Urb, + sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), + Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle, + Context->csw, + NULL, + 512, //FIXME + USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, + NULL);
// // initialize stack location @@ -291,6 +292,7 @@ // call driver // IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp); + return STATUS_MORE_PROCESSING_REQUIRED; }
@@ -330,12 +332,15 @@ // // now initialize the urb for sending data // - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = Context->TransferBufferMDL; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = Context->TransferDataLength; - Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; + + UsbBuildInterruptOrBulkTransferRequest(&Context->Urb, + sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), + Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle, + NULL, + Context->TransferBufferMDL, + Context->TransferDataLength, + USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, + NULL);
// // setup completion routine @@ -347,12 +352,15 @@ // // now initialize the urb for sending the csw // - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME - Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK; + + UsbBuildInterruptOrBulkTransferRequest(&Context->Urb, + sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), + Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle, + Context->csw, + NULL, + 512, //FIXME + USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK, + NULL);
// // setup completion routine @@ -373,6 +381,7 @@ // call driver // IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp); + return STATUS_MORE_PROCESSING_REQUIRED; }
@@ -427,12 +436,14 @@ // // now initialize the urb // - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB); - Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER; - Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = (PVOID)Context->cbw; - Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = sizeof(CBW); - Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK; + UsbBuildInterruptOrBulkTransferRequest(&Context->Urb, + sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER), + FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle, + Context->cbw, + NULL, + sizeof(CBW), + USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK, + NULL);
// // initialize rest of context @@ -477,7 +488,6 @@ FreeItem(Context); return STATUS_INSUFFICIENT_RESOURCES; } -
// // get next stack location @@ -822,6 +832,7 @@ // // FIXME: support more logical blocks // + DPRINT1("Request->DataTransferLength %x, PDODeviceExtension->BlockLength %x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength); ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength);
//