Author: janderwald
Date: Thu Apr 28 16:40:07 2011
New Revision: 51477
URL:
http://svn.reactos.org/svn/reactos?rev=51477&view=rev
Log:
[USBEHCI_NEW]
- Move error checking if controller reported an error inside the door bell ring check
block
- Extend interface of IUSBRequest to include DeviceAddress, which is needed to retrieve
configuration descriptor of newly set address
- Allocate CtrlSetup from nonpaged pool
- Release setup packet on cleanup
- Devices now receive an device address
- Currently asserts while retrieving configuration descriptor as this code path is not yet
existant
*** Assertion failed: Urb->UrbHeader.UsbdDeviceHandle == NULL
*** Source File: d:\usb-bringup\drivers\usb\usbehci_new\hub_controller.cpp, line 1118
Modified:
branches/usb-bringup/drivers/usb/usbehci_new/hardware.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/hardware.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbehci…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp [iso-8859-1] Thu Apr 28
16:40:07 2011
@@ -1003,20 +1003,20 @@
//
if (CStatus & (EHCI_STS_RECL| EHCI_STS_INT | EHCI_ERROR_INT))
{
- if (CStatus & EHCI_ERROR_INT)
- {
- //
- // controller reported error
- //
- Status = STATUS_UNSUCCESSFUL;
- PC_ASSERT(FALSE);
- }
-
//
// check if there is a door bell ring in progress
//
if (This->m_DoorBellRingInProgress == FALSE)
{
+ if (CStatus & EHCI_ERROR_INT)
+ {
+ //
+ // controller reported error
+ //
+ Status = STATUS_UNSUCCESSFUL;
+ PC_ASSERT(FALSE);
+ }
+
//
// inform IUSBQueue of a completed queue head
//
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] Thu Apr 28
16:40:07 2011
@@ -385,6 +385,7 @@
virtual NTSTATUS InitializeWithSetupPacket(IN PDMAMEMORYMANAGER DmaManager,
IN PUSB_DEFAULT_PIPE_SETUP_PACKET
SetupPacket,
+ IN UCHAR DeviceAddress,
IN OUT ULONG TransferBufferLength,
IN OUT PMDL TransferBuffer) = 0;
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] Thu Apr 28
16:40:07 2011
@@ -310,26 +310,37 @@
CUSBDevice::SetDeviceAddress(
UCHAR DeviceAddress)
{
- USB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
+ PUSB_DEFAULT_PIPE_SETUP_PACKET CtrlSetup;
NTSTATUS Status;
UCHAR OldAddress;
ULONG Index;
+ DPRINT1("CUSBDevice::SetDeviceAddress Address %d\n", DeviceAddress);
+
+ CtrlSetup = (PUSB_DEFAULT_PIPE_SETUP_PACKET)ExAllocatePoolWithTag(NonPagedPool,
sizeof(USB_DEFAULT_PIPE_SETUP_PACKET), TAG_USBEHCI);
+ if (!CtrlSetup)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
//
// zero request
//
- RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
+ RtlZeroMemory(CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
//
// initialize request
//
- CtrlSetup.bRequest = USB_REQUEST_SET_ADDRESS;
- CtrlSetup.wValue.W = (USHORT)DeviceAddress;
+ CtrlSetup->bRequest = USB_REQUEST_SET_ADDRESS;
+ CtrlSetup->wValue.W = (USHORT)DeviceAddress;
//
// set device address
//
- Status = CommitSetupPacket(&CtrlSetup, 0, 0);
+ Status = CommitSetupPacket(CtrlSetup, 0, 0);
+
+ //
+ // free setup packet
+ //
+ ExFreePoolWithTag(CtrlSetup, TAG_USBEHCI);
//
// check for success
@@ -367,7 +378,7 @@
//
// failed to retrieve device descriptor
//
- DPRINT1("CUSBbDevice::SetDeviceAddress> failed to set new device address
%d, falling back to %d Error %x\n", DeviceAddress, OldAddress, Status);
+ DPRINT1("CUSBbDevice::SetDeviceAddress> failed to retrieve device
descriptor with device address set Error %x\n", Status);
m_DeviceAddress = OldAddress;
//
@@ -375,8 +386,6 @@
//
return Status;
}
-
- PC_ASSERT(FALSE);
//
// sanity checks
@@ -547,7 +556,7 @@
//
// initialize request
//
- Status = Request->InitializeWithSetupPacket(m_DmaManager, Packet, BufferLength,
Mdl);
+ Status = Request->InitializeWithSetupPacket(m_DmaManager, Packet, m_DeviceAddress,
BufferLength, Mdl);
if (!NT_SUCCESS(Status))
{
//
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] Thu Apr 28
16:40:07 2011
@@ -36,7 +36,7 @@
}
// IUSBRequest interface functions
- virtual NTSTATUS InitializeWithSetupPacket(IN PDMAMEMORYMANAGER DmaManager, IN
PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, 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 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);
@@ -57,7 +57,7 @@
NTSTATUS BuildBulkTransferQueueHead(PQUEUE_HEAD * OutHead);
NTSTATUS CreateDescriptor(PQUEUE_TRANSFER_DESCRIPTOR *OutDescriptor);
NTSTATUS CreateQueueHead(PQUEUE_HEAD *OutQueueHead);
- ULONG GetDeviceAddress();
+ UCHAR GetDeviceAddress();
NTSTATUS BuildSetupPacket();
NTSTATUS BuildSetupPacketFromURB();
@@ -97,6 +97,11 @@
// completion event for callers who initialized request with setup packet
//
PKEVENT m_CompletionEvent;
+
+ //
+ // device address for callers who initialized it with device address
+ //
+ UCHAR m_DeviceAddress;
//
// DMA queue head
@@ -137,6 +142,7 @@
CUSBRequest::InitializeWithSetupPacket(
IN PDMAMEMORYMANAGER DmaManager,
IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket,
+ IN UCHAR DeviceAddress,
IN OUT ULONG TransferBufferLength,
IN OUT PMDL TransferBuffer)
{
@@ -153,6 +159,7 @@
m_SetupPacket = SetupPacket;
m_TransferBufferLength = TransferBufferLength;
m_TransferBufferMDL = TransferBuffer;
+ m_DeviceAddress = DeviceAddress;
//
// allocate completion event
@@ -796,7 +803,7 @@
}
//----------------------------------------------------------------------------------------
-ULONG
+UCHAR
CUSBRequest::GetDeviceAddress()
{
PIO_STACK_LOCATION IoStack;
@@ -809,9 +816,9 @@
if (!m_Irp)
{
//
- // no irp is provided
- // assume it is for device address 0
- return 0;
+ // used provided address
+ //
+ return m_DeviceAddress;
}
//
@@ -1158,6 +1165,14 @@
m_DmaManager->Release(m_TransferDescriptors[2],
sizeof(QUEUE_TRANSFER_DESCRIPTOR));
m_TransferDescriptors[2] = 0;
}
+
+ if (m_DescriptorPacket)
+ {
+ //
+ // release packet descriptor
+ //
+ m_DmaManager->Release(m_DescriptorPacket,
sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
+ }
}
//-----------------------------------------------------------------------------------------