Author: mjmartin
Date: Sun May 8 12:42:15 2011
New Revision: 51642
URL:
http://svn.reactos.org/svn/reactos?rev=51642&view=rev
Log:
[USBEHCI_NEW]
- When clearing feature port reset, remove the flag from Change and if the port is
hardware enabled set the enable flag in Status.
- When checking port status, if Change has any flags set an SCE request most be completed.
Verified while writing usbhub driver in xp.
- Probably fixes a case where an endless loop of completing SCE requests.
Modified:
branches/usb-bringup/drivers/usb/usbehci_new/hardware.cpp
branches/usb-bringup/drivers/usb/usbehci_new/hub_controller.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] Sun May 8
12:42:15 2011
@@ -713,7 +713,7 @@
if (PortId > m_Capabilities.HCSParams.PortCount)
return STATUS_UNSUCCESSFUL;
-
+
//
// Get the value of the Port Status and Control Register
//
@@ -799,12 +799,18 @@
Value &= ~EHCI_PRT_RESET;
EHCI_WRITE_REGISTER_ULONG(EHCI_PORTSC + (4 * PortId), Value);
KeStallExecutionProcessor(100);
-
- //
- // update port status
- //
- m_PortStatus[PortId].PortChange &= ~USB_PORT_STATUS_RESET;
+ }
+
+ Value = EHCI_READ_REGISTER_ULONG(EHCI_PORTSC + (4 * PortId));
+ //
+ // update port status
+ //
+ m_PortStatus[PortId].PortChange &= ~USB_PORT_STATUS_RESET;
+ if (Value & EHCI_PRT_ENABLED)
m_PortStatus[PortId].PortStatus |= USB_PORT_STATUS_ENABLE;
+ else
+ {
+ DPRINT1("Port is not enabled.\n");
}
}
@@ -843,7 +849,7 @@
//
DPRINT1("PORT_ENABLE not supported for EHCI\n");
}
-
+
if (Feature == PORT_RESET)
{
if (Value & EHCI_PRT_SLOWSPEEDLINE)
@@ -870,7 +876,7 @@
m_SCECallBack(m_SCEContext);
}
}
-
+
if (Feature == PORT_POWER)
DPRINT1("PORT_POWER Not implemented\n");
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] Sun May
8 12:42:15 2011
@@ -67,7 +67,7 @@
NTSTATUS HandleClassOther(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleClassInterface(IN OUT PIRP Irp, PURB Urb);
NTSTATUS HandleBulkOrInterruptTransfer(IN OUT PIRP Irp, PURB Urb);
-
+
friend VOID StatusChangeEndpointCallBack(PVOID Context);
// constructor / destructor
@@ -305,31 +305,30 @@
DPRINT1("SCE Request %p TransferBufferLength %lu Flags %x MDL %p\n",
Urb->UrbBulkOrInterruptTransfer.TransferBuffer,
Urb->UrbBulkOrInterruptTransfer.TransferBufferLength,
Urb->UrbBulkOrInterruptTransfer.TransferFlags,
Urb->UrbBulkOrInterruptTransfer.TransferBufferMDL);
TransferBuffer = (PUCHAR)Urb->UrbBulkOrInterruptTransfer.TransferBuffer;
+
+ //
+ // Loop the ports
+ //
for (PortId = 0; PortId < PortCount; PortId++)
{
m_Hardware->GetPortStatus(PortId, &PortStatus, &PortChange);
DPRINT1("Port %d: Status %x, Change %x\n", PortId, PortStatus,
PortChange);
- //
- // Loop the ports
- //
- if ((PortStatus & USB_PORT_STATUS_CONNECT) && (PortChange &
USB_PORT_STATUS_CONNECT))
- {
- DPRINT1("Device is connected on port %d\n", PortId);
+
+ //
+ // If theres a flag in PortChange return TRUE so the SCE Irp will be completed
+ //
+ if (PortChange != 0)
+ {
+ DPRINT1("Change state on port %d\n", PortId);
// Set the value for the port number
*TransferBuffer = 1 << ((PortId + 1) & 7);
Changed = TRUE;
}
}
- //
- // If there were changes then return TRUE
- //
- if (Changed != 0)
- return TRUE;
-
- return FALSE;
+ return Changed;
}
//-----------------------------------------------------------------------------------------
@@ -777,6 +776,7 @@
ASSERT(m_PendingSCEIrp == NULL);
if (QueryStatusChageEndpoint(Irp))
{
+ StatusChangeEndpointCallBack(this);
return STATUS_SUCCESS;
}
@@ -2094,7 +2094,7 @@
if (NT_SUCCESS(Status))
break;
- }while(Index++ < 3 );
+ }while(Index++ < 3 );
//
// check for failure
@@ -2706,11 +2706,6 @@
DPRINT1("USBHI_SetDeviceHandleData %p\n", UsbDevicePdo);
//
- // fixup device stack voodoo part #1
- //
- UsbDevicePdo->StackSize++;
-
- //
// sanity check
//
PC_ASSERT(UsbDevicePdo->AttachedDevice);
@@ -3152,6 +3147,11 @@
DPRINT1("CHubController::CreatePDO: DeviceName %wZ\n", &DeviceName);
+ //
+ // fixup device stack voodoo part #1
+ //
+ (*OutDeviceObject)->StackSize++;
+
/* done */
return Status;
}