Author: janderwald
Date: Fri Apr 29 02:46:04 2011
New Revision: 51489
URL:
http://svn.reactos.org/svn/reactos?rev=51489&view=rev
Log:
[USBEHCI_NEW]
- Implement SelectInterface / SelectConfiguration based on mjmartin usbehci driver
- Initialization runs untill SelectInterface request
- Tested with WinXP SP2
Modified:
branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp
branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp
branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp
Modified: branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1]
(original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.cpp [iso-8859-1] Fri Apr
29 02:46:04 2011
@@ -63,6 +63,7 @@
NTSTATUS HandleClassDevice(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleGetStatusFromDevice(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleSelectConfiguration(IN OUT PIRP Irp, PURB Urb);
+ NTSTATUS HandleSelectInterface(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleClassOther(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleBulkOrInterruptTransfer(IN OUT PIRP Irp, PURB Urb);
@@ -936,29 +937,87 @@
IN OUT PIRP Irp,
PURB Urb)
{
- //
- // sanity checks
- //
-
- //
- // FIXME: support devices
- //
- PC_ASSERT(Urb->UrbHeader.UsbdDeviceHandle == NULL);
-
- //
- // FIXME: support setting device to unconfigured state
- //
- PC_ASSERT(Urb->UrbSelectConfiguration.ConfigurationDescriptor);
-
- //
- // set device handle
- //
- Urb->UrbSelectConfiguration.ConfigurationHandle =
(PVOID)ROOTHUB2_CONFIGURATION_DESCRIPTOR;
-
- //
- // TODO: copy interface info
- //
- return STATUS_SUCCESS;
+ PUSBDEVICE UsbDevice;
+
+ //
+ // is the request for the Root Hub
+ //
+ if (Urb->UrbHeader.UsbdDeviceHandle == NULL)
+ {
+ //
+ // FIXME: support setting device to unconfigured state
+ //
+ PC_ASSERT(Urb->UrbSelectConfiguration.ConfigurationDescriptor);
+
+ //
+ // set device handle
+ //
+ Urb->UrbSelectConfiguration.ConfigurationHandle =
(PVOID)ROOTHUB2_CONFIGURATION_DESCRIPTOR;
+
+ //
+ // TODO: copy interface info
+ //
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ //
+ // check if this is a valid usb device handle
+ //
+ PC_ASSERT(ValidateUsbDevice(PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle)));
+
+ //
+ // get device
+ //
+ UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
+
+ //
+ // select configuration
+ //
+ return
UsbDevice->SelectConfiguration(Urb->UrbSelectConfiguration.ConfigurationDescriptor,
&Urb->UrbSelectConfiguration.Interface,
&Urb->UrbSelectConfiguration.ConfigurationHandle);
+ }
+}
+
+//-----------------------------------------------------------------------------------------
+NTSTATUS
+CHubController::HandleSelectInterface(
+ IN OUT PIRP Irp,
+ PURB Urb)
+{
+ PUSBDEVICE UsbDevice;
+
+ //
+ // sanity check
+ //
+ PC_ASSERT(Urb->UrbSelectInterface.ConfigurationHandle);
+
+ //
+ // is the request for the Root Hub
+ //
+ if (Urb->UrbHeader.UsbdDeviceHandle == NULL)
+ {
+ //
+ // no op for root hub
+ //
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ //
+ // check if this is a valid usb device handle
+ //
+ PC_ASSERT(ValidateUsbDevice(PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle)));
+
+ //
+ // get device
+ //
+ UsbDevice = PUSBDEVICE(Urb->UrbHeader.UsbdDeviceHandle);
+
+ //
+ // select interface
+ //
+ return
UsbDevice->SelectInterface(Urb->UrbSelectInterface.ConfigurationHandle,
&Urb->UrbSelectInterface.Interface);
+ }
}
//-----------------------------------------------------------------------------------------
@@ -1249,7 +1308,7 @@
CtrlSetup.wValue.LowByte = Urb->UrbControlDescriptorRequest.Index;
CtrlSetup.wValue.HiByte =
Urb->UrbControlDescriptorRequest.DescriptorType;
CtrlSetup.wIndex.W = Urb->UrbControlDescriptorRequest.LanguageId;
- CtrlSetup.wLength =
Urb->UrbControlDescriptorRequest.TransferBufferLength;
+ CtrlSetup.wLength =
(USHORT)Urb->UrbControlDescriptorRequest.TransferBufferLength;
CtrlSetup.bmRequestType.B = 0x80;
//
@@ -1317,6 +1376,9 @@
case URB_FUNCTION_SELECT_CONFIGURATION:
Status = HandleSelectConfiguration(Irp, Urb);
break;
+ case URB_FUNCTION_SELECT_INTERFACE:
+ Status = HandleSelectInterface(Irp, Urb);
+ break;
case URB_FUNCTION_CLASS_OTHER:
Status = HandleClassOther(Irp, Urb);
break;
@@ -1898,7 +1960,7 @@
//
// now set the device address
//
- Status = UsbDevice->SetDeviceAddress(DeviceAddress);
+ Status = UsbDevice->SetDeviceAddress((UCHAR)DeviceAddress);
if (NT_SUCCESS(Status))
break;
Modified: branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/interfaces.h [iso-8859-1] Fri Apr 29
02:46:04 2011
@@ -386,6 +386,7 @@
virtual NTSTATUS InitializeWithSetupPacket(IN PDMAMEMORYMANAGER DmaManager,
IN PUSB_DEFAULT_PIPE_SETUP_PACKET
SetupPacket,
IN UCHAR DeviceAddress,
+ IN OPTIONAL PUSB_ENDPOINT_DESCRIPTOR
EndpointDescriptor,
IN OUT ULONG TransferBufferLength,
IN OUT PMDL TransferBuffer) = 0;
@@ -796,13 +797,13 @@
IN ULONG BufferLength,
OUT PULONG OutBufferLength) = 0;
-//----------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------------
//
// Description: returns length of configuration descriptors
//
virtual ULONG GetConfigurationDescriptorsLength() = 0;
-//----------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------------
//
// SubmitSetupPacket
//
@@ -812,7 +813,24 @@
IN OUT ULONG BufferLength,
OUT PVOID Buffer) = 0;
-
+//-----------------------------------------------------------------------------------------
+//
+// SelectConfiguration
+//
+// Description: selects a configuration
+
+ virtual NTSTATUS SelectConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR
ConfigurationDescriptor,
+ IN PUSBD_INTERFACE_INFORMATION Interface,
+ OUT USBD_CONFIGURATION_HANDLE
*ConfigurationHandle) = 0;
+
+//-----------------------------------------------------------------------------------------
+//
+// SelectConfiguration
+//
+// Description: selects a interface of an configuration
+
+ virtual NTSTATUS SelectInterface(IN USBD_CONFIGURATION_HANDLE ConfigurationHandle,
+ IN OUT PUSBD_INTERFACE_INFORMATION Interface) = 0;
};
typedef IUSBDevice *PUSBDEVICE;
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_device.cpp [iso-8859-1] Fri Apr 29
02:46:04 2011
@@ -68,11 +68,12 @@
virtual VOID GetConfigurationDescriptors(IN PUSB_CONFIGURATION_DESCRIPTOR
ConfigDescriptorBuffer, IN ULONG BufferLength, OUT PULONG OutBufferLength);
virtual ULONG GetConfigurationDescriptorsLength();
virtual NTSTATUS SubmitSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, OUT
ULONG BufferLength, OUT PVOID Buffer);
-
+ virtual NTSTATUS SelectConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR
ConfigurationDescriptor, IN PUSBD_INTERFACE_INFORMATION Interface, OUT
USBD_CONFIGURATION_HANDLE *ConfigurationHandle);
+ virtual NTSTATUS SelectInterface(IN USBD_CONFIGURATION_HANDLE ConfigurationHandle, IN
OUT PUSBD_INTERFACE_INFORMATION Interface);
// local function
virtual NTSTATUS CommitIrp(PIRP Irp);
- virtual NTSTATUS CommitSetupPacket(PUSB_DEFAULT_PIPE_SETUP_PACKET Packet, IN ULONG
BufferLength, IN OUT PMDL Mdl);
+ virtual NTSTATUS CommitSetupPacket(PUSB_DEFAULT_PIPE_SETUP_PACKET Packet, IN OPTIONAL
PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor, IN ULONG BufferLength, IN OUT PMDL Mdl);
virtual NTSTATUS CreateConfigurationDescriptor(ULONG ConfigurationIndex);
virtual NTSTATUS CreateDeviceDescriptor();
virtual VOID DumpDeviceDescriptor(PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
@@ -90,6 +91,7 @@
ULONG m_Port;
UCHAR m_DeviceAddress;
PVOID m_Data;
+ UCHAR m_ConfigurationIndex;
KSPIN_LOCK m_Lock;
USB_DEVICE_DESCRIPTOR m_DeviceDescriptor;
ULONG m_PortStatus;
@@ -338,7 +340,7 @@
//
// set device address
//
- Status = CommitSetupPacket(CtrlSetup, 0, 0);
+ Status = CommitSetupPacket(CtrlSetup, 0, 0, 0);
//
// free setup packet
@@ -440,8 +442,10 @@
UCHAR
CUSBDevice::GetConfigurationValue()
{
- UNIMPLEMENTED
- return 0x1;
+ //
+ // return configuration index
+ //
+ return m_ConfigurationIndex;
}
//----------------------------------------------------------------------------------------
@@ -527,7 +531,8 @@
//----------------------------------------------------------------------------------------
NTSTATUS
CUSBDevice::CommitSetupPacket(
- PUSB_DEFAULT_PIPE_SETUP_PACKET Packet,
+ IN PUSB_DEFAULT_PIPE_SETUP_PACKET Packet,
+ IN OPTIONAL PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor,
IN ULONG BufferLength,
IN OUT PMDL Mdl)
{
@@ -559,7 +564,7 @@
//
// initialize request
//
- Status = Request->InitializeWithSetupPacket(m_DmaManager, Packet, m_DeviceAddress,
BufferLength, Mdl);
+ Status = Request->InitializeWithSetupPacket(m_DmaManager, Packet, m_DeviceAddress,
EndpointDescriptor, BufferLength, Mdl);
if (!NT_SUCCESS(Status))
{
//
@@ -642,7 +647,7 @@
//
// commit setup packet
//
- Status = CommitSetupPacket(&CtrlSetup, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
+ Status = CommitSetupPacket(&CtrlSetup, 0, sizeof(USB_DEVICE_DESCRIPTOR), Mdl);
//
// now free the mdl
@@ -734,7 +739,7 @@
//
// commit packet
//
- Status = CommitSetupPacket(&CtrlSetup, PAGE_SIZE, Mdl);
+ Status = CommitSetupPacket(&CtrlSetup, 0, PAGE_SIZE, Mdl);
if (!NT_SUCCESS(Status))
{
//
@@ -1039,7 +1044,7 @@
//
// commit setup packet
//
- Status = CommitSetupPacket(SetupPacket, BufferLength, Mdl);
+ Status = CommitSetupPacket(SetupPacket, 0, BufferLength, Mdl);
//
// free mdl
@@ -1051,6 +1056,184 @@
//
return Status;
}
+
+//----------------------------------------------------------------------------------------
+NTSTATUS
+CUSBDevice::SelectConfiguration(
+ IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
+ IN PUSBD_INTERFACE_INFORMATION InterfaceInfo,
+ OUT USBD_CONFIGURATION_HANDLE *ConfigurationHandle)
+{
+ ULONG ConfigurationIndex = 0;
+ ULONG InterfaceIndex, PipeIndex;
+ USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
+ NTSTATUS Status;
+
+ //
+ // FIXME: support multiple configurations
+ //
+ PC_ASSERT(m_DeviceDescriptor.bNumConfigurations == 1);
+ PC_ASSERT(ConfigurationDescriptor->iConfiguration ==
m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor.iConfiguration);
+
+ //
+ // sanity check
+ //
+ PC_ASSERT(ConfigurationDescriptor->bNumInterfaces <=
m_ConfigurationDescriptors[ConfigurationIndex].ConfigurationDescriptor.bNumInterfaces);
+
+ //
+ // copy interface info and pipe info
+ //
+ 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);
+#ifdef _MSC_VER
+ PC_ASSERT(InterfaceInfo->Length == FIELD_OFFSET(USBD_INTERFACE_INFORMATION,
Pipes[InterfaceInfo->NumberOfPipes]));
+#endif
+
+ //
+ // 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->Reserved = 0;
+
+ //
+ // copy endpoint info
+ //
+ for(PipeIndex = 0; PipeIndex < InterfaceInfo->NumberOfPipes; PipeIndex++)
+ {
+ //
+ // 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;
+ }
+
+ //
+ // move offset
+ //
+ InterfaceInfo =
(PUSBD_INTERFACE_INFORMATION)((ULONG_PTR)PtrToUlong(InterfaceInfo) +
InterfaceInfo->Length);
+ }
+
+ //
+ // now build setup packet
+ //
+ RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
+ CtrlSetup.bRequest = USB_REQUEST_SET_CONFIGURATION;
+ CtrlSetup.wValue.W = ConfigurationDescriptor->iConfiguration;
+
+ //
+ // select configuration
+ //
+ Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
+
+ //
+ // informal debug print
+ //
+ DPRINT1("CUsbDevice::SelectConfiguration New Configuration %x Old Configuration
%x Result %x\n", ConfigurationDescriptor->iConfiguration, m_ConfigurationIndex,
Status);
+
+ if (NT_SUCCESS(Status))
+ {
+ //
+ // store configuration device index
+ //
+ m_ConfigurationIndex = ConfigurationDescriptor->iConfiguration;
+
+ //
+ // store configuration handle
+ //
+ *ConfigurationHandle = &m_ConfigurationDescriptors[ConfigurationIndex];
+ }
+
+ //
+ // done
+ //
+ return Status;
+}
+
+//----------------------------------------------------------------------------------------
+NTSTATUS
+CUSBDevice::SelectInterface(
+ IN USBD_CONFIGURATION_HANDLE ConfigurationHandle,
+ IN OUT PUSBD_INTERFACE_INFORMATION InterfaceInfo)
+{
+ ULONG ConfigurationIndex = 0;
+ PUSB_CONFIGURATION Configuration;
+ ULONG PipeIndex;
+ USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
+ NTSTATUS Status;
+
+ //
+ // FIXME support multiple configurations
+ //
+ PC_ASSERT(&m_ConfigurationDescriptors[ConfigurationIndex] ==
(PUSB_CONFIGURATION)ConfigurationHandle);
+
+ //
+ // get configuration struct
+ //
+ Configuration = (PUSB_CONFIGURATION)ConfigurationHandle;
+
+ //
+ // sanity checks
+ //
+ PC_ASSERT(Configuration->ConfigurationDescriptor.bNumInterfaces >
InterfaceInfo->InterfaceNumber);
+
PC_ASSERT(Configuration->Interfaces[InterfaceInfo->InterfaceNumber].InterfaceDescriptor.bNumEndpoints
== InterfaceInfo->NumberOfPipes);
+#ifdef _MSC_VER
+ 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
+ //
+ 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
+ //
+ }
+ }
+
+ //
+ // initialize setup packet
+ //
+ RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
+ CtrlSetup.bRequest = USB_REQUEST_SET_INTERFACE;
+ CtrlSetup.wValue.W = InterfaceInfo->AlternateSetting;
+ CtrlSetup.wIndex.W = InterfaceInfo->InterfaceNumber;
+ CtrlSetup.bmRequestType.B = 0x01;
+
+ //
+ // issue request
+ //
+ Status = CommitSetupPacket(&CtrlSetup, 0, 0, 0);
+
+ //
+ // informal debug print
+ //
+ DPRINT1("CUSBDevice::SelectInterface AlternateSetting %x InterfaceNumber %x
Status %x\n", InterfaceInfo->AlternateSetting, InterfaceInfo->InterfaceNumber,
Status);
+
+ //
+ // done
+ //
+ return Status;
+}
+
//----------------------------------------------------------------------------------------
NTSTATUS
CreateUSBDevice(
Modified: branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/usb_request.cpp [iso-8859-1] Fri Apr 29
02:46:04 2011
@@ -36,7 +36,7 @@
}
// IUSBRequest interface functions
- virtual NTSTATUS InitializeWithSetupPacket(IN PDMAMEMORYMANAGER DmaManager, IN
PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN UCHAR DeviceAddress, IN OUT ULONG
TransferBufferLength, IN OUT PMDL TransferBuffer);
+ virtual NTSTATUS InitializeWithSetupPacket(IN PDMAMEMORYMANAGER DmaManager, IN
PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN UCHAR DeviceAddress, IN OPTIONAL
PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor, IN OUT ULONG TransferBufferLength, IN OUT
PMDL TransferBuffer);
virtual NTSTATUS InitializeWithIrp(IN PDMAMEMORYMANAGER DmaManager, IN OUT PIRP
Irp);
virtual VOID CompletionCallback(IN NTSTATUS NtStatusCode, IN ULONG UrbStatusCode, IN
struct _QUEUE_HEAD *QueueHead);
virtual VOID CancelCallback(IN NTSTATUS NtStatusCode, IN struct _QUEUE_HEAD
*QueueHead);
@@ -104,6 +104,11 @@
UCHAR m_DeviceAddress;
//
+ // store end point address
+ //
+ PUSB_ENDPOINT_DESCRIPTOR m_EndpointDescriptor;
+
+ //
// DMA queue head
//
PQUEUE_HEAD m_QueueHead;
@@ -143,6 +148,7 @@
IN PDMAMEMORYMANAGER DmaManager,
IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket,
IN UCHAR DeviceAddress,
+ IN OPTIONAL PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor,
IN OUT ULONG TransferBufferLength,
IN OUT PMDL TransferBuffer)
{
@@ -160,6 +166,7 @@
m_TransferBufferLength = TransferBufferLength;
m_TransferBufferMDL = TransferBuffer;
m_DeviceAddress = DeviceAddress;
+ m_EndpointDescriptor = EndpointDescriptor;
//
// allocate completion event
@@ -243,6 +250,11 @@
PC_ASSERT(Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL);
//
+ // get endpoint descriptor
+ //
+ m_EndpointDescriptor =
(PUSB_ENDPOINT_DESCRIPTOR)Urb->UrbBulkOrInterruptTransfer.PipeHandle;
+
+ //
// get mdl buffer
//
m_TransferBufferMDL =
Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL;
@@ -590,8 +602,14 @@
//
QueueHead->EndPointCharacteristics.DeviceAddress = GetDeviceAddress();
- //if (PipeHandle)
- // QueueHead->EndPointCharacteristics.EndPointNumber =
((PUSB_ENDPOINT_DESCRIPTOR)PipeHandle)->bEndpointAddress & 0x0F;
+ if (m_EndpointDescriptor)
+ {
+ //
+ // set endpoint address and max packet length
+ //
+ QueueHead->EndPointCharacteristics.EndPointNumber =
m_EndpointDescriptor->bEndpointAddress & 0x0F;
+ QueueHead->EndPointCharacteristics.MaximumPacketLength =
m_EndpointDescriptor->wMaxPacketSize;
+ }
QueueHead->Token.Bits.DataToggle = TRUE;