mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 12:23:25 +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:
@@ -60,13 +60,15 @@ USBSTOR_GetDescriptor(
|
||||
//
|
||||
// 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
|
||||
|
||||
@@ -124,6 +124,7 @@ USBSTOR_FdoHandleStartDevice(
|
||||
IN PFDO_DEVICE_EXTENSION DeviceExtension,
|
||||
IN OUT PIRP Irp)
|
||||
{
|
||||
PUSB_INTERFACE_DESCRIPTOR InterfaceDesc;
|
||||
NTSTATUS Status;
|
||||
UCHAR Index = 0;
|
||||
|
||||
@@ -158,6 +159,18 @@ USBSTOR_FdoHandleStartDevice(
|
||||
//
|
||||
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 @@ USBSTOR_FdoHandlePnp(
|
||||
//
|
||||
// just forward irp to lower device
|
||||
//
|
||||
//IoSkipCurrentIrpStackLocation(Irp);
|
||||
Status = USBSTOR_SyncForwardIrp(DeviceExtension->LowerDeviceObject, Irp);
|
||||
break;
|
||||
}
|
||||
|
||||
+38
-27
@@ -258,19 +258,20 @@ USBSTOR_DataCompletionRoutine(
|
||||
//
|
||||
// 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 @@ USBSTOR_DataCompletionRoutine(
|
||||
// call driver
|
||||
//
|
||||
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
||||
|
||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
}
|
||||
|
||||
@@ -330,12 +332,15 @@ USBSTOR_CBWCompletionRoutine(
|
||||
//
|
||||
// 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 @@ USBSTOR_CBWCompletionRoutine(
|
||||
//
|
||||
// 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 @@ USBSTOR_CBWCompletionRoutine(
|
||||
// call driver
|
||||
//
|
||||
IoCallDriver(Context->FDODeviceExtension->LowerDeviceObject, Irp);
|
||||
|
||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||
}
|
||||
|
||||
@@ -427,12 +436,14 @@ USBSTOR_SendRequest(
|
||||
//
|
||||
// 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
|
||||
@@ -478,7 +489,6 @@ USBSTOR_SendRequest(
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// get next stack location
|
||||
//
|
||||
@@ -822,6 +832,7 @@ USBSTOR_SendReadCmd(
|
||||
//
|
||||
// FIXME: support more logical blocks
|
||||
//
|
||||
DPRINT1("Request->DataTransferLength %x, PDODeviceExtension->BlockLength %x\n", Request->DataTransferLength, PDODeviceExtension->BlockLength);
|
||||
ASSERT(Request->DataTransferLength == PDODeviceExtension->BlockLength);
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user