mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 14:53:40 +00:00
[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. svn path=/branches/usb-bringup/; revision=51691
This commit is contained in:
parent
9d7751a2f6
commit
98ed611448
3 changed files with 61 additions and 34 deletions
|
@ -60,13 +60,15 @@ USBSTOR_GetDescriptor(
|
||||||
//
|
//
|
||||||
// initialize urb
|
// initialize urb
|
||||||
//
|
//
|
||||||
Urb->UrbHeader.Function = URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE;
|
UsbBuildGetDescriptorRequest(Urb,
|
||||||
Urb->UrbHeader.Length = sizeof(URB);
|
sizeof(Urb->UrbControlDescriptorRequest),
|
||||||
Urb->UrbControlDescriptorRequest.DescriptorType = DescriptorType;
|
DescriptorType,
|
||||||
Urb->UrbControlDescriptorRequest.TransferBuffer = Descriptor;
|
DescriptorIndex,
|
||||||
Urb->UrbControlDescriptorRequest.TransferBufferLength = DescriptorLength;
|
LanguageId,
|
||||||
Urb->UrbControlDescriptorRequest.Index = DescriptorIndex;
|
Descriptor,
|
||||||
Urb->UrbControlDescriptorRequest.LanguageId = LanguageId;
|
NULL,
|
||||||
|
DescriptorLength,
|
||||||
|
NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// submit urb
|
// submit urb
|
||||||
|
|
|
@ -124,6 +124,7 @@ USBSTOR_FdoHandleStartDevice(
|
||||||
IN PFDO_DEVICE_EXTENSION DeviceExtension,
|
IN PFDO_DEVICE_EXTENSION DeviceExtension,
|
||||||
IN OUT PIRP Irp)
|
IN OUT PIRP Irp)
|
||||||
{
|
{
|
||||||
|
PUSB_INTERFACE_DESCRIPTOR InterfaceDesc;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
UCHAR Index = 0;
|
UCHAR Index = 0;
|
||||||
|
|
||||||
|
@ -158,6 +159,18 @@ USBSTOR_FdoHandleStartDevice(
|
||||||
//
|
//
|
||||||
USBSTOR_DumpDeviceDescriptor(DeviceExtension->DeviceDescriptor);
|
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
|
// now select an interface
|
||||||
//
|
//
|
||||||
|
@ -290,6 +303,7 @@ USBSTOR_FdoHandlePnp(
|
||||||
//
|
//
|
||||||
// just forward irp to lower device
|
// just forward irp to lower device
|
||||||
//
|
//
|
||||||
|
//IoSkipCurrentIrpStackLocation(Irp);
|
||||||
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,19 +258,20 @@ USBSTOR_DataCompletionRoutine(
|
||||||
//
|
//
|
||||||
// get next stack location
|
// get next stack location
|
||||||
//
|
//
|
||||||
|
|
||||||
IoStack = IoGetNextIrpStackLocation(Irp);
|
IoStack = IoGetNextIrpStackLocation(Irp);
|
||||||
|
|
||||||
//
|
//
|
||||||
// now initialize the urb for sending the csw
|
// now initialize the urb for sending the csw
|
||||||
//
|
//
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB);
|
UsbBuildInterruptOrBulkTransferRequest(&Context->Urb,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER;
|
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle;
|
Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw;
|
Context->csw,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME
|
NULL,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = NULL;
|
512, //FIXME
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK;
|
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// initialize stack location
|
// initialize stack location
|
||||||
|
@ -291,6 +292,7 @@ USBSTOR_DataCompletionRoutine(
|
||||||
// call driver
|
// call driver
|
||||||
//
|
//
|
||||||
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +332,15 @@ USBSTOR_CBWCompletionRoutine(
|
||||||
//
|
//
|
||||||
// now initialize the urb for sending data
|
// 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;
|
UsbBuildInterruptOrBulkTransferRequest(&Context->Urb,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle;
|
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferMDL = Context->TransferBufferMDL;
|
Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = Context->TransferDataLength;
|
NULL,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK;
|
Context->TransferBufferMDL,
|
||||||
|
Context->TransferDataLength,
|
||||||
|
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// setup completion routine
|
// setup completion routine
|
||||||
|
@ -347,12 +352,15 @@ USBSTOR_CBWCompletionRoutine(
|
||||||
//
|
//
|
||||||
// now initialize the urb for sending the csw
|
// 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;
|
UsbBuildInterruptOrBulkTransferRequest(&Context->Urb,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle;
|
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = Context->csw;
|
Context->FDODeviceExtension->InterfaceInformation->Pipes[Context->FDODeviceExtension->BulkInPipeIndex].PipeHandle,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = 512; //FIXME
|
Context->csw,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK;
|
NULL,
|
||||||
|
512, //FIXME
|
||||||
|
USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// setup completion routine
|
// setup completion routine
|
||||||
|
@ -373,6 +381,7 @@ USBSTOR_CBWCompletionRoutine(
|
||||||
// call driver
|
// call driver
|
||||||
//
|
//
|
||||||
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,12 +436,14 @@ USBSTOR_SendRequest(
|
||||||
//
|
//
|
||||||
// now initialize the urb
|
// now initialize the urb
|
||||||
//
|
//
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Length = sizeof(URB);
|
UsbBuildInterruptOrBulkTransferRequest(&Context->Urb,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.Hdr.Function = URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER;
|
sizeof(struct _URB_BULK_OR_INTERRUPT_TRANSFER),
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.PipeHandle = FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle;
|
FDODeviceExtension->InterfaceInformation->Pipes[FDODeviceExtension->BulkOutPipeIndex].PipeHandle,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBuffer = (PVOID)Context->cbw;
|
Context->cbw,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength = sizeof(CBW);
|
NULL,
|
||||||
Context->Urb.UrbBulkOrInterruptTransfer.TransferFlags = USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK;
|
sizeof(CBW),
|
||||||
|
USBD_TRANSFER_DIRECTION_OUT | USBD_SHORT_TRANSFER_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// initialize rest of context
|
// initialize rest of context
|
||||||
|
@ -478,7 +489,6 @@ USBSTOR_SendRequest(
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// get next stack location
|
// get next stack location
|
||||||
//
|
//
|
||||||
|
@ -822,6 +832,7 @@ USBSTOR_SendReadCmd(
|
||||||
//
|
//
|
||||||
// FIXME: support more logical blocks
|
// FIXME: support more logical blocks
|
||||||
//
|
//
|
||||||
|
DPRINT1("Request->DataTransferLength %x, PDODeviceExtension->BlockLength %x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength);
|
||||||
ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength);
|
ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue