Author: janderwald
Date: Wed May 25 02:11:06 2011
New Revision: 51900
URL:
http://svn.reactos.org/svn/reactos?rev=51900&view=rev
Log:
[USBOHCI]
- Add glue code for supporting iso transfers
- Remove dead from Handle
- Remove broken asserts
- Add support for string descriptors
- Add support for class specific endpoint requests (Needs be ported to usbehci)
- Link to usbd driver
- Add support for retrieving string descriptor
- Rewrite configuration descriptor handling in IUSBDevice. New code is smaller, smarter
and handles a lot more cases. Needs to be ported to usbehci
- Wrap usbdlib.h include in extern c macro, it has c linkage
- Control transfers should now work
- Need to implement support for isochronous / bulk / interrupt transfers until functional
- Tested with Bluetooth USB Stick (multi function, interrupt / bulk / control /
isochronous) / USB Microphone (isochronous & control) in XP SP3
Modified:
branches/usb-bringup/drivers/usb/usbohci/CMakeLists.txt
branches/usb-bringup/drivers/usb/usbohci/hub_controller.cpp
branches/usb-bringup/drivers/usb/usbohci/usb_device.cpp
branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp
branches/usb-bringup/drivers/usb/usbohci/usbohci.h
Modified: branches/usb-bringup/drivers/usb/usbohci/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/CMakeLists.txt [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/CMakeLists.txt [iso-8859-1] Wed May 25
02:11:06 2011
@@ -30,6 +30,6 @@
endif(MSVC)
set_module_type(usbohci kernelmodedriver)
-add_importlibs(usbohci ntoskrnl ks drmk hal)
+add_importlibs(usbohci ntoskrnl ks drmk hal usbd)
add_cab_target(usbohci 2)
Modified: branches/usb-bringup/drivers/usb/usbohci/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/hub_controller.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/hub_controller.cpp [iso-8859-1] Wed May 25
02:11:06 2011
@@ -66,7 +66,9 @@
NTSTATUS HandleSelectInterface(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleClassOther(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleClassInterface(IN OUT PIRP Irp, PURB Urb);
+ NTSTATUS HandleClassEndpoint(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleBulkOrInterruptTransfer(IN OUT PIRP Irp, PURB Urb);
+ NTSTATUS HandleIsochronousTransfer(IN OUT PIRP Irp, PURB Urb);
friend VOID StatusChangeEndpointCallBack(PVOID Context);
@@ -756,6 +758,47 @@
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_IMPLEMENTED;
}
+
+//-----------------------------------------------------------------------------------------
+NTSTATUS
+CHubController::HandleIsochronousTransfer(
+ IN OUT PIRP Irp,
+ PURB Urb)
+{
+ PUSBDEVICE UsbDevice;
+ PUSB_ENDPOINT_DESCRIPTOR EndPointDesc = NULL;
+
+ //
+ // Check PipeHandle to determine if this is a Bulk or Interrupt Transfer Request
+ //
+ EndPointDesc = (PUSB_ENDPOINT_DESCRIPTOR)Urb->UrbIsochronousTransfer.PipeHandle;
+
+ if (!EndPointDesc)
+ {
+ DPRINT1("No EndpointDesc\n");
+ Urb->UrbIsochronousTransfer.Hdr.Status = USBD_STATUS_INVALID_PIPE_HANDLE;
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ //
+ // sanity checks
+ //
+ ASSERT(EndPointDesc);
+ ASSERT((EndPointDesc->bmAttributes & USB_ENDPOINT_TYPE_MASK) ==
USB_ENDPOINT_TYPE_ISOCHRONOUS);
+
+ //
+ // check if this is a valid usb device handle
+ //
+ PC_ASSERT(ValidateUsbDevice(PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle)));
+
+ //
+ // get device
+ //
+ UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
+
+ return UsbDevice->SubmitIrp(Irp);
+}
+
//-----------------------------------------------------------------------------------------
NTSTATUS
CHubController::HandleBulkOrInterruptTransfer(
@@ -794,22 +837,11 @@
//
EndPointDesc =
(PUSB_ENDPOINT_DESCRIPTOR)Urb->UrbBulkOrInterruptTransfer.PipeHandle;
- switch(EndPointDesc->bmAttributes & 0x0F)
- {
- case USB_ENDPOINT_TYPE_CONTROL:
- DPRINT1("Control Transfer is not expected!!!\n");
- return STATUS_INVALID_DEVICE_REQUEST;
- case USB_ENDPOINT_TYPE_BULK:
- DPRINT("Initiating Bulk Transfer\n");
- break;
- case USB_ENDPOINT_TYPE_ISOCHRONOUS:
- case USB_ENDPOINT_TYPE_INTERRUPT:
- DPRINT1("Not Supported\n");
- break;
- default:
- DPRINT1("Unknown EndPoint Type!\n");
- break;
- }
+ //
+ // sanity checks
+ //
+ ASSERT(EndPointDesc);
+ ASSERT((EndPointDesc->bmAttributes & USB_ENDPOINT_TYPE_MASK) ==
USB_ENDPOINT_TYPE_BULK || (EndPointDesc->bmAttributes & USB_ENDPOINT_TYPE_MASK) ==
USB_ENDPOINT_TYPE_INTERRUPT);
//
// check if this is a valid usb device handle
@@ -1199,6 +1231,7 @@
{
NTSTATUS Status = STATUS_NOT_IMPLEMENTED;
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
+ USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
PUCHAR Buffer;
PUSBDEVICE UsbDevice;
ULONG Length;
@@ -1299,8 +1332,6 @@
}
else
{
- DPRINT1("Length %u\n",
Urb->UrbControlDescriptorRequest.TransferBufferLength);
-
//
// check if this is a valid usb device handle
//
@@ -1329,11 +1360,6 @@
// perform work in IUSBDevice
//
UsbDevice->GetConfigurationDescriptors((PUSB_CONFIGURATION_DESCRIPTOR)Urb->UrbControlDescriptorRequest.TransferBuffer,
Urb->UrbControlDescriptorRequest.TransferBufferLength, &Length);
-
- //
- // sanity check
- //
- PC_ASSERT(Urb->UrbControlDescriptorRequest.TransferBufferLength >=
Length);
//
// store result size
@@ -1363,15 +1389,89 @@
UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
//
- // unimplemented
- //
- ASSERT(FALSE);
+ // generate setup packet
+ //
+ CtrlSetup.bRequest = USB_REQUEST_GET_DESCRIPTOR;
+ CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
+ CtrlSetup.wValue.HiByte =
Urb->UrbControlDescriptorRequest.DescriptorType;
+ CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
+ CtrlSetup.wLength =
(USHORT)Urb->UrbControlDescriptorRequest.TransferBufferLength;
+ CtrlSetup.bmRequestType.B = 0x80;
+
+ //
+ // submit setup packet
+ //
+ Status = UsbDevice->SubmitSetupPacket(&CtrlSetup,
Urb->UrbControlDescriptorRequest.TransferBufferLength,
Urb->UrbControlDescriptorRequest.TransferBuffer);
break;
}
default:
DPRINT1("CHubController::HandleGetDescriptor DescriptorType %x
unimplemented\n", Urb->UrbControlDescriptorRequest.DescriptorType);
break;
}
+
+ //
+ // done
+ //
+ return Status;
+}
+
+//-----------------------------------------------------------------------------------------
+NTSTATUS
+CHubController::HandleClassEndpoint(
+ IN OUT PIRP Irp,
+ IN OUT PURB Urb)
+{
+ USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
+ NTSTATUS Status;
+ PUSBDEVICE UsbDevice;
+
+ //
+ // sanity check
+ //
+ PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBuffer);
+ PC_ASSERT(Urb->UrbControlVendorClassRequest.TransferBufferLength);
+ PC_ASSERT(Urb->UrbHeader.UsbdDeviceHandle);
+
+ //
+ // check if this is a valid usb device handle
+ //
+ PC_ASSERT(ValidateUsbDevice(PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle)));
+
+ //
+ // get device
+ //
+ UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
+
+
+ DPRINT1("URB_FUNCTION_CLASS_ENDPOINT\n");
+ DPRINT1("TransferFlags %x\n",
Urb->UrbControlVendorClassRequest.TransferFlags);
+ DPRINT1("TransferBufferLength %x\n",
Urb->UrbControlVendorClassRequest.TransferBufferLength);
+ DPRINT1("TransferBuffer %x\n",
Urb->UrbControlVendorClassRequest.TransferBuffer);
+ DPRINT1("TransferBufferMDL %x\n",
Urb->UrbControlVendorClassRequest.TransferBufferMDL);
+ DPRINT1("RequestTypeReservedBits %x\n",
Urb->UrbControlVendorClassRequest.RequestTypeReservedBits);
+ DPRINT1("Request %x\n", Urb->UrbControlVendorClassRequest.Request);
+ DPRINT1("Value %x\n", Urb->UrbControlVendorClassRequest.Value);
+ DPRINT1("Index %x\n", Urb->UrbControlVendorClassRequest.Index);
+
+ //
+ // initialize setup packet
+ //
+ CtrlSetup.bmRequestType.B = 0xa2; //FIXME: Const.
+ CtrlSetup.bRequest = Urb->UrbControlVendorClassRequest.Request;
+ CtrlSetup.wValue.W = Urb->UrbControlVendorClassRequest.Value;
+ CtrlSetup.wIndex.W = Urb->UrbControlVendorClassRequest.Index;
+ CtrlSetup.wLength = Urb->UrbControlVendorClassRequest.TransferBufferLength;
+
+ //
+ // issue request
+ //
+ Status = UsbDevice->SubmitSetupPacket(&CtrlSetup,
Urb->UrbControlVendorClassRequest.TransferBufferLength,
Urb->UrbControlVendorClassRequest.TransferBuffer);
+
+ //
+ // assert on failure
+ //
+ PC_ASSERT(NT_SUCCESS(Status));
+
//
// done
@@ -1500,8 +1600,14 @@
case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
Status = HandleBulkOrInterruptTransfer(Irp, Urb);
break;
+ case URB_FUNCTION_ISOCH_TRANSFER:
+ Status = HandleIsochronousTransfer(Irp, Urb);
+ break;
case URB_FUNCTION_CLASS_INTERFACE:
Status = HandleClassInterface(Irp, Urb);
+ break;
+ case URB_FUNCTION_CLASS_ENDPOINT:
+ Status = HandleClassEndpoint(Irp, Urb);
break;
default:
DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x NOT
IMPLEMENTED\n", Urb->UrbHeader.Function);
@@ -2290,11 +2396,7 @@
PC_ASSERT(Controller->ValidateUsbDevice(OldUsbDevice));
DPRINT1("NewUsbDevice: DeviceAddress %x\n",
NewUsbDevice->GetDeviceAddress());
-
-
DPRINT1("OldUsbDevice: DeviceAddress %x\n",
OldUsbDevice->GetDeviceAddress());
-
- PC_ASSERT(FALSE);
//
// remove old device handle
Modified: branches/usb-bringup/drivers/usb/usbohci/usb_device.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/usb_device.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/usb_device.cpp [iso-8859-1] Wed May 25
02:11:06 2011
@@ -10,24 +10,6 @@
#define INITGUID
#include "usbohci.h"
-
-typedef struct _USB_ENDPOINT
-{
- USB_ENDPOINT_DESCRIPTOR EndPointDescriptor;
-} USB_ENDPOINT, *PUSB_ENDPOINT;
-
-typedef struct _USB_INTERFACE
-{
- USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- USB_ENDPOINT *EndPoints;
-} USB_INTERFACE, *PUSB_INTERFACE;
-
-typedef struct _USB_CONFIGURATION
-{
- USB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
- USB_INTERFACE *Interfaces;
-} USB_CONFIGURATION, *PUSB_CONFIGURATION;
-
class CUSBDevice : public IUSBDevice
{
@@ -97,8 +79,7 @@
ULONG m_PortStatus;
PUSBQUEUE m_Queue;
PDMAMEMORYMANAGER m_DmaManager;
-
- PUSB_CONFIGURATION m_ConfigurationDescriptors;
+ PUSB_CONFIGURATION_DESCRIPTOR *m_ConfigurationDescriptors;
};
//----------------------------------------------------------------------------------------
@@ -400,12 +381,12 @@
//
// allocate configuration descriptor
//
- m_ConfigurationDescriptors = (PUSB_CONFIGURATION) ExAllocatePoolWithTag(NonPagedPool,
sizeof(USB_CONFIGURATION) * m_DeviceDescriptor.bNumConfigurations, TAG_USBOHCI);
+ m_ConfigurationDescriptors = (PUSB_CONFIGURATION_DESCRIPTOR*)
ExAllocatePoolWithTag(NonPagedPool, sizeof(PUSB_CONFIGURATION_DESCRIPTOR) *
m_DeviceDescriptor.bNumConfigurations, TAG_USBOHCI);
//
// zero configuration descriptor
//
- RtlZeroMemory(m_ConfigurationDescriptors, sizeof(USB_CONFIGURATION) *
m_DeviceDescriptor.bNumConfigurations);
+ RtlZeroMemory(m_ConfigurationDescriptors, sizeof(PUSB_CONFIGURATION_DESCRIPTOR) *
m_DeviceDescriptor.bNumConfigurations);
//
// retrieve the configuration descriptors
@@ -683,10 +664,7 @@
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
NTSTATUS Status;
PMDL Mdl;
- ULONG InterfaceIndex, EndPointIndex;
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
- PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
- PUSB_ENDPOINT_DESCRIPTOR EndPointDescriptor;
//
@@ -783,100 +761,9 @@
PC_ASSERT(ConfigurationDescriptor->bNumInterfaces);
//
- // request is complete, initialize configuration descriptor
- //
- RtlCopyMemory(&m_ConfigurationDescriptors[Index].ConfigurationDescriptor,
ConfigurationDescriptor, ConfigurationDescriptor->bLength);
-
- //
- // now allocate interface descriptors
- //
- m_ConfigurationDescriptors[Index].Interfaces =
(PUSB_INTERFACE)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_INTERFACE) *
ConfigurationDescriptor->bNumInterfaces, TAG_USBOHCI);
- if (!m_ConfigurationDescriptors[Index].Interfaces)
- {
- //
- // failed to allocate interface descriptors
- //
- ExFreePool(Buffer);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- //
- // zero interface descriptor
- //
- RtlZeroMemory(m_ConfigurationDescriptors[Index].Interfaces, sizeof(USB_INTERFACE) *
ConfigurationDescriptor->bNumInterfaces);
-
- //
- // get first interface descriptor
- //
- InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)(ConfigurationDescriptor + 1);
-
- //
- // setup interface descriptors
- //
- for(InterfaceIndex = 0; InterfaceIndex <
ConfigurationDescriptor->bNumInterfaces; InterfaceIndex++)
- {
- //
- // sanity check
- //
- PC_ASSERT(InterfaceDescriptor->bLength == sizeof(USB_INTERFACE_DESCRIPTOR));
- PC_ASSERT(InterfaceDescriptor->bNumEndpoints);
-
- //
- // copy current interface descriptor
- //
-
RtlCopyMemory(&m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].InterfaceDescriptor,
InterfaceDescriptor, InterfaceDescriptor->bLength);
-
- //
- // allocate end point descriptors
- //
- m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints =
(PUSB_ENDPOINT)ExAllocatePoolWithTag(NonPagedPool, sizeof(USB_ENDPOINT) *
InterfaceDescriptor->bNumEndpoints, TAG_USBOHCI);
- if (!m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints)
- {
- //
- // failed to allocate endpoint
- //
- Status = STATUS_INSUFFICIENT_RESOURCES;
- break;
- }
-
- //
- // zero memory
- //
-
RtlZeroMemory(m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints,
sizeof(USB_ENDPOINT) * InterfaceDescriptor->bNumEndpoints);
-
- //
- // initialize end point descriptors
- //
- EndPointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)(InterfaceDescriptor + 1);
-
- for(EndPointIndex = 0; EndPointIndex < InterfaceDescriptor->bNumEndpoints;
EndPointIndex++)
- {
- //
- // sanity check
- //
- PC_ASSERT(EndPointDescriptor->bLength ==
sizeof(USB_ENDPOINT_DESCRIPTOR));
-
- //
- // copy endpoint descriptor
- //
-
RtlCopyMemory(&m_ConfigurationDescriptors[Index].Interfaces[InterfaceIndex].EndPoints[EndPointIndex].EndPointDescriptor,
EndPointDescriptor, EndPointDescriptor->bLength);
-
- //
- // move to next offset
- //
- EndPointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)((ULONG_PTR)EndPointDescriptor
+ EndPointDescriptor->bLength);
- }
-
- //
- // update interface descriptor offset
- //
- InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)EndPointDescriptor;
- }
-
- //
- // free buffer
- //
- ExFreePoolWithTag(Buffer, TAG_USBOHCI);
+ // store configuration descriptor
+ //
+ m_ConfigurationDescriptors[Index] = ConfigurationDescriptor;
//
// done
@@ -890,9 +777,6 @@
IN ULONG BufferLength,
OUT PULONG OutBufferLength)
{
- PVOID Buffer;
- ULONG InterfaceIndex, EndpointIndex;
-
//
// sanity check
//
@@ -911,78 +795,10 @@
PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
//
- // copy first configuration descriptor
- //
- RtlCopyMemory(ConfigDescriptorBuffer,
&m_ConfigurationDescriptors[0].ConfigurationDescriptor,
sizeof(USB_CONFIGURATION_DESCRIPTOR));
-
- //
- // subtract length
- //
- BufferLength -= sizeof(USB_CONFIGURATION_DESCRIPTOR);
- *OutBufferLength += sizeof(USB_CONFIGURATION_DESCRIPTOR);
-
- //
- // increment offset
- //
- Buffer = (PVOID)(ConfigDescriptorBuffer + 1);
-
- for(InterfaceIndex = 0; InterfaceIndex <
m_ConfigurationDescriptors[0].ConfigurationDescriptor.bNumInterfaces; InterfaceIndex++)
- {
- if (BufferLength < sizeof(USB_INTERFACE_DESCRIPTOR))
- {
- //
- // no more room in buffer
- //
- return;
- }
-
- //
- // copy interface descriptor
- //
- RtlCopyMemory(Buffer,
&m_ConfigurationDescriptors[0].Interfaces[InterfaceIndex].InterfaceDescriptor,
sizeof(USB_INTERFACE_DESCRIPTOR));
-
- //
- // increment offset
- //
- Buffer = (PVOID)((ULONG_PTR)Buffer + sizeof(USB_INTERFACE_DESCRIPTOR));
- BufferLength -= sizeof(USB_INTERFACE_DESCRIPTOR);
- *OutBufferLength += sizeof(USB_INTERFACE_DESCRIPTOR);
-
- //
- // does the interface have endpoints
- //
- if
(m_ConfigurationDescriptors[0].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints)
- {
- //
- // is enough space available
- //
- if (BufferLength < sizeof(USB_ENDPOINT_DESCRIPTOR) *
m_ConfigurationDescriptors[0].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints)
- {
- //
- // no buffer
- //
- return;
- }
-
- //
- // copy end points
- //
- for(EndpointIndex = 0; EndpointIndex <
m_ConfigurationDescriptors[0].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints;
EndpointIndex++)
- {
- //
- // copy endpoint
- //
- RtlCopyMemory(Buffer,
&m_ConfigurationDescriptors[0].Interfaces[InterfaceIndex].EndPoints[EndpointIndex].EndPointDescriptor,
sizeof(USB_ENDPOINT_DESCRIPTOR));
-
- //
- // increment buffer offset
- //
- Buffer = (PVOID)((ULONG_PTR)Buffer + sizeof(USB_ENDPOINT_DESCRIPTOR));
- BufferLength -= sizeof(USB_ENDPOINT_DESCRIPTOR);
- *OutBufferLength += sizeof(USB_ENDPOINT_DESCRIPTOR);
- }
- }
- }
+ // copy configuration descriptor
+ //
+ RtlCopyMemory(ConfigDescriptorBuffer, m_ConfigurationDescriptors[0],
min(m_ConfigurationDescriptors[0]->wTotalLength, BufferLength));
+ *OutBufferLength = m_ConfigurationDescriptors[0]->wTotalLength;
}
//----------------------------------------------------------------------------------------
@@ -994,7 +810,10 @@
//
PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
- return m_ConfigurationDescriptors[0].ConfigurationDescriptor.wTotalLength;
+ ASSERT(m_ConfigurationDescriptors[0]);
+ ASSERT(m_ConfigurationDescriptors[0]->wTotalLength);
+
+ return m_ConfigurationDescriptors[0]->wTotalLength;
}
//----------------------------------------------------------------------------------------
VOID
@@ -1074,21 +893,28 @@
IN PUSBD_INTERFACE_INFORMATION InterfaceInfo,
OUT USBD_CONFIGURATION_HANDLE *ConfigurationHandle)
{
- ULONG ConfigurationIndex = 0;
ULONG InterfaceIndex, PipeIndex;
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
NTSTATUS Status;
+ PUSB_CONFIGURATION_DESCRIPTOR CurrentConfigurationDescriptor;
+ PUSB_INTERFACE_DESCRIPTOR CurrentInterfaceDescriptor;
+ PUSB_ENDPOINT_DESCRIPTOR CurrentEndpointDescriptor;
+ PVOID StartPosition;
//
// FIXME: support multiple configurations
//
- PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
- PC_ASSERT(ConfigurationDescriptor->iConfiguration ==
m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor.iConfiguration);
+ ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
+ ASSERT(m_ConfigurationDescriptors[0]);
+ CurrentConfigurationDescriptor = m_ConfigurationDescriptors[0];
//
// sanity check
//
- PC_ASSERT(ConfigurationDescriptor->bNumInterfaces <=
m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor.bNumInterfaces);
+ PC_ASSERT(ConfigurationDescriptor->iConfiguration ==
CurrentConfigurationDescriptor->iConfiguration);
+ PC_ASSERT(ConfigurationDescriptor->bNumInterfaces <=
CurrentConfigurationDescriptor->bNumInterfaces);
+ DPRINT1("CUSBDevice::SelectConfiguration NumInterfaces %lu\n",
ConfigurationDescriptor->bNumInterfaces);
+
//
// copy interface info and pipe info
@@ -1096,36 +922,62 @@
for(InterfaceIndex = 0; InterfaceIndex <
ConfigurationDescriptor->bNumInterfaces; InterfaceIndex++)
{
//
- // sanity check: is the info pre-layed out
- //
- PC_ASSERT(InterfaceInfo->NumberOfPipes ==
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bNumEndpoints);
- PC_ASSERT(InterfaceInfo->Length != 0);
+ // find interface descriptor
+ //
+ CurrentInterfaceDescriptor =
USBD_ParseConfigurationDescriptor(CurrentConfigurationDescriptor,
InterfaceInfo->InterfaceNumber, InterfaceInfo->AlternateSetting);
+
+ //
+ // sanity check
+ //
+ ASSERT(CurrentInterfaceDescriptor);
+ ASSERT(CurrentInterfaceDescriptor->bLength != 0);
+ ASSERT(InterfaceInfo->NumberOfPipes ==
CurrentInterfaceDescriptor->bNumEndpoints);
+ ASSERT(InterfaceInfo->Length != 0);
#ifdef _MSC_VER
PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION,
Pipes[InterfaceInfo->NumberOfPipes]));
#endif
+ DPRINT1("CUSBDevice::SelectConfiguration InterfaceNumber %lu
AlternativeSetting %lu bNumEndpoints %lu\n", InterfaceInfo->InterfaceNumber,
InterfaceInfo->AlternateSetting, CurrentInterfaceDescriptor->bNumEndpoints);
+
//
// copy interface info
//
- InterfaceInfo->InterfaceHandle =
(USBD_INTERFACE_HANDLE)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex];
- InterfaceInfo->Class =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceClass;
- InterfaceInfo->SubClass =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceSubClass;
- InterfaceInfo->Protocol =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].InterfaceDescriptor.bInterfaceProtocol;
+ InterfaceInfo->InterfaceHandle =
(USBD_INTERFACE_HANDLE)CurrentInterfaceDescriptor;
+ InterfaceInfo->Class = CurrentInterfaceDescriptor->bInterfaceClass;
+ InterfaceInfo->SubClass = CurrentInterfaceDescriptor->bInterfaceSubClass;
+ InterfaceInfo->Protocol = CurrentInterfaceDescriptor->bInterfaceProtocol;
InterfaceInfo->Reserved = 0;
//
// copy endpoint info
//
+ StartPosition = CurrentInterfaceDescriptor;
for(PipeIndex = 0; PipeIndex < InterfaceInfo->NumberOfPipes; PipeIndex++)
{
//
+ // find corresponding endpoint descriptor
+ //
+ CurrentEndpointDescriptor =
(PUSB_ENDPOINT_DESCRIPTOR)USBD_ParseDescriptors(CurrentConfigurationDescriptor,
CurrentConfigurationDescriptor->wTotalLength, StartPosition,
USB_ENDPOINT_DESCRIPTOR_TYPE);
+
+ //
+ // sanity checks
+ //
+ ASSERT(CurrentEndpointDescriptor);
+ ASSERT(CurrentEndpointDescriptor->bDescriptorType ==
USB_ENDPOINT_DESCRIPTOR_TYPE);
+
+ //
// copy pipe info
//
- InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.wMaxPacketSize;
- InterfaceInfo->Pipes[PipeIndex].EndpointAddress =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress;
- InterfaceInfo->Pipes[PipeIndex].Interval =
m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bInterval;
- InterfaceInfo->Pipes[PipeIndex].PipeType =
(USBD_PIPE_TYPE)m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes;
- InterfaceInfo->Pipes[PipeIndex].PipeHandle =
(PVOID)&m_ConfigurationDescriptors[ConfigurationIndex].Interfaces[InterfaceIndex].EndPoints[PipeIndex].EndPointDescriptor;
+ InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize =
CurrentEndpointDescriptor->wMaxPacketSize;
+ InterfaceInfo->Pipes[PipeIndex].EndpointAddress =
CurrentEndpointDescriptor->bEndpointAddress;
+ InterfaceInfo->Pipes[PipeIndex].Interval =
CurrentEndpointDescriptor->bInterval;
+ InterfaceInfo->Pipes[PipeIndex].PipeType =
(USBD_PIPE_TYPE)CurrentEndpointDescriptor->bmAttributes;
+ InterfaceInfo->Pipes[PipeIndex].PipeHandle =
(PVOID)CurrentEndpointDescriptor;
+
+ //
+ // move start position beyond the current endpoint descriptor
+ //
+ StartPosition = (PVOID)(CurrentEndpointDescriptor + 1);
}
//
@@ -1161,7 +1013,7 @@
//
// store configuration handle
//
- *ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationIndex];
+ *ConfigurationHandle = m_ConfigurationDescriptors[0];
}
//
@@ -1177,65 +1029,49 @@
IN OUT PUSBD_INTERFACE_INFORMATION InterfaceInfo)
{
ULONG ConfigurationIndex = 0;
- PUSB_CONFIGURATION Configuration;
+ PUSB_CONFIGURATION_DESCRIPTOR Configuration;
ULONG PipeIndex;
USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
NTSTATUS Status;
+ PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
+ PUSB_ENDPOINT_DESCRIPTOR CurrentEndpointDescriptor;
+ PVOID StartPosition;
//
// FIXME support multiple configurations
//
- PC_ASSERT(&m_ConfigurationDescriptors[ConfigurationIndex] ==
(PUSB_CONFIGURATION)ConfigurationHandle);
+ PC_ASSERT(m_ConfigurationDescriptors[0] ==
(PUSB_CONFIGURATION_DESCRIPTOR)ConfigurationHandle);
//
// get configuration struct
//
- Configuration = (PUSB_CONFIGURATION)ConfigurationHandle;
+ Configuration = (PUSB_CONFIGURATION_DESCRIPTOR)ConfigurationHandle;
//
// sanity checks
//
- PC_ASSERT(Configuration->ConfigurationDescriptor.bNumInterfaces >
InterfaceInfo->InterfaceNumber);
-
PC_ASSERT(Configuration->Interfaces[InterfaceInfo->InterfaceNumber].InterfaceDescriptor.bNumEndpoints
== InterfaceInfo->NumberOfPipes);
+ PC_ASSERT(Configuration->bNumInterfaces > InterfaceInfo->InterfaceNumber);
#ifdef _MSC_VER
- PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION,
Pipes[InterfaceInfo->NumberOfPipes]));
+ //PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION,
Pipes[InterfaceInfo->NumberOfPipes]));
#endif
//
- // copy pipe handles
- //
- for(PipeIndex = 0; PipeIndex < InterfaceInfo->NumberOfPipes; PipeIndex++)
- {
- //
- // copy pipe handle
- //
- DPRINT1("PipeIndex %lu\n", PipeIndex);
- DPRINT1("EndpointAddress %x\n",
InterfaceInfo->Pipes[PipeIndex].EndpointAddress);
- DPRINT1("Interval %d\n", InterfaceInfo->Pipes[PipeIndex].Interval);
- DPRINT1("MaximumPacketSize %d\n",
InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize);
- DPRINT1("MaximumTransferSize %d\n",
InterfaceInfo->Pipes[PipeIndex].MaximumTransferSize);
- DPRINT1("PipeFlags %d\n",
InterfaceInfo->Pipes[PipeIndex].PipeFlags);
- DPRINT1("PipeType %dd\n",
InterfaceInfo->Pipes[PipeIndex].PipeType);
- DPRINT1("UsbEndPoint %x\n",
Configuration->Interfaces[InterfaceInfo->InterfaceNumber].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress);
-
PC_ASSERT(Configuration->Interfaces[InterfaceInfo->InterfaceNumber].EndPoints[PipeIndex].EndPointDescriptor.bEndpointAddress
== InterfaceInfo->Pipes[PipeIndex].EndpointAddress);
-
- InterfaceInfo->Pipes[PipeIndex].PipeHandle =
&Configuration->Interfaces[InterfaceInfo->InterfaceNumber].EndPoints[PipeIndex].EndPointDescriptor;
-
- if
(Configuration->Interfaces[InterfaceInfo->InterfaceNumber].EndPoints[PipeIndex].EndPointDescriptor.bmAttributes
& (USB_ENDPOINT_TYPE_ISOCHRONOUS | USB_ENDPOINT_TYPE_INTERRUPT))
- {
- //
- // FIXME: check if enough bandwidth is available
- //
- }
- }
+ // FIXME: check bandwidth
+ //
+
+ //
+ // find interface number
+ //
+ InterfaceDescriptor = USBD_ParseConfigurationDescriptor(Configuration,
InterfaceInfo->InterfaceNumber, InterfaceInfo->AlternateSetting);
+ ASSERT(InterfaceDescriptor);
//
// initialize setup packet
//
RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
CtrlSetup.bRequest = USB_REQUEST_SET_INTERFACE;
- CtrlSetup.wValue.W =
Configuration->Interfaces[InterfaceInfo->InterfaceNumber].InterfaceDescriptor.bAlternateSetting;
- CtrlSetup.wIndex.W =
Configuration->Interfaces[InterfaceInfo->InterfaceNumber].InterfaceDescriptor.bInterfaceNumber;
+ CtrlSetup.wValue.W = InterfaceDescriptor->bAlternateSetting;
+ CtrlSetup.wIndex.W = InterfaceDescriptor->bInterfaceNumber;
CtrlSetup.bmRequestType.B = 0x01;
//
@@ -1247,7 +1083,55 @@
// informal debug print
//
DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x
Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber,
Status);
-
+ DPRINT1("CUSBDevice::SelectInterface bInterfaceNumber %u bAlternateSetting %u
NumberOfPipes %u Length %lu\n",
+ InterfaceDescriptor->bInterfaceNumber,
InterfaceDescriptor->bAlternateSetting, InterfaceInfo->NumberOfPipes,
InterfaceInfo->Length);
+ InterfaceInfo->InterfaceHandle = InterfaceDescriptor;
+ InterfaceInfo->NumberOfPipes = InterfaceDescriptor->bNumEndpoints;
+
+ //
+ // are there end points
+ //
+ if (InterfaceDescriptor->bNumEndpoints)
+ {
+ //
+ // sanity check
+ //
+ ASSERT(InterfaceInfo->Length == sizeof(USBD_INTERFACE_INFORMATION) +
(InterfaceDescriptor->bNumEndpoints > 1 ? sizeof(USBD_PIPE_INFORMATION) *
(InterfaceDescriptor->bNumEndpoints - 1) : 0));
+
+ //
+ // store number of pipes
+ //
+ InterfaceInfo->NumberOfPipes = InterfaceDescriptor->bNumEndpoints;
+
+ StartPosition = InterfaceDescriptor;
+ for(PipeIndex = 0; PipeIndex < InterfaceInfo->NumberOfPipes; PipeIndex++)
+ {
+ //
+ // find corresponding endpoint descriptor
+ //
+ CurrentEndpointDescriptor =
(PUSB_ENDPOINT_DESCRIPTOR)USBD_ParseDescriptors(Configuration,
Configuration->wTotalLength, StartPosition, USB_ENDPOINT_DESCRIPTOR_TYPE);
+
+ //
+ // sanity checks
+ //
+ ASSERT(CurrentEndpointDescriptor);
+ ASSERT(CurrentEndpointDescriptor->bDescriptorType ==
USB_ENDPOINT_DESCRIPTOR_TYPE);
+
+ //
+ // copy pipe info
+ //
+ InterfaceInfo->Pipes[PipeIndex].MaximumPacketSize =
CurrentEndpointDescriptor->wMaxPacketSize;
+ InterfaceInfo->Pipes[PipeIndex].EndpointAddress =
CurrentEndpointDescriptor->bEndpointAddress;
+ InterfaceInfo->Pipes[PipeIndex].Interval =
CurrentEndpointDescriptor->bInterval;
+ InterfaceInfo->Pipes[PipeIndex].PipeType =
(USBD_PIPE_TYPE)CurrentEndpointDescriptor->bmAttributes;
+ InterfaceInfo->Pipes[PipeIndex].PipeHandle =
(PVOID)CurrentEndpointDescriptor;
+
+ //
+ // move start position beyond the current endpoint descriptor
+ //
+ StartPosition = (PVOID)(CurrentEndpointDescriptor + 1);
+ }
+ }
//
// done
//
Modified: branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/usb_queue.cpp [iso-8859-1] Wed May 25
02:11:06 2011
@@ -146,10 +146,10 @@
{
case USB_ENDPOINT_TYPE_ISOCHRONOUS:
case USB_ENDPOINT_TYPE_INTERRUPT:
+ case USB_ENDPOINT_TYPE_BULK:
/* NOT IMPLEMENTED IN QUEUE */
Status = STATUS_NOT_SUPPORTED;
break;
- case USB_ENDPOINT_TYPE_BULK:
case USB_ENDPOINT_TYPE_CONTROL:
Status = STATUS_SUCCESS;
break;
Modified: branches/usb-bringup/drivers/usb/usbohci/usbohci.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbohci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbohci/usbohci.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbohci/usbohci.h [iso-8859-1] Wed May 25 02:11:06
2011
@@ -7,6 +7,13 @@
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbioctl.h>
+
+extern
+"C"
+{
+#include <usbdlib.h>
+}
+
//
// FIXME:
// #include <usbprotocoldefs.h>