[USBSTOR]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 25 Jan 2012 03:39:57 +0000 (03:39 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 25 Jan 2012 03:39:57 +0000 (03:39 +0000)
- Add debug trace
[USBOHCI]
- Implement proper GetPortStatus
[USBHUB]
- Reset all connected ports before sending first SCE
- USB Devices present before booting are now detected with OHCI controller. EHCI code is present but not yet activated

svn path=/branches/usb-bringup-trunk/; revision=55167

drivers/usb/usbhub_new/fdo.c
drivers/usb/usbohci/hardware.cpp
drivers/usb/usbstor/scsi.c

index 8bb0d3b..42b7f99 100644 (file)
@@ -1443,8 +1443,37 @@ RootHubInitCallbackFunction(
     PVOID Context)
 {
     PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)Context;
+    NTSTATUS Status;
+    ULONG PortId;
+    PHUB_DEVICE_EXTENSION HubDeviceExtension;
+    PORT_STATUS_CHANGE StatusChange;
+
+    HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
 
-    DPRINT1("Sending the initial SCE Request %x\n", DeviceObject);
+    DPRINT1("RootHubInitCallbackFunction Sending the initial SCE Request %x\n", DeviceObject);
+
+    for (PortId = 1; PortId <= HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++)
+    {
+        //
+        // get port status
+        //
+        Status = GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, &StatusChange);
+        if (NT_SUCCESS(Status))
+        {
+            //
+            // is there a device connected
+            //
+            if (StatusChange.Status & USB_PORT_STATUS_CONNECT)
+            {
+                //
+                // reset port
+                //
+                Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_RESET);
+                if (!NT_SUCCESS(Status))
+                    DPRINT1("Failed to reset on port %d\n", PortId);
+            }
+        }
+    }
 
     //
     // Send the first SCE Request
@@ -1463,6 +1492,7 @@ USBHUB_FdoHandlePnp(
     PHUB_DEVICE_EXTENSION HubDeviceExtension;
     PDEVICE_OBJECT RootHubDeviceObject;
     PVOID HubInterfaceBusContext , UsbDInterfaceBusContext;
+    PORT_STATUS_CHANGE StatusChange;
 
     HubDeviceExtension = (PHUB_DEVICE_EXTENSION) DeviceObject->DeviceExtension;
 
@@ -1799,6 +1829,32 @@ USBHUB_FdoHandlePnp(
             }
             else
             {
+                //
+                // reset ports
+                //
+                for (PortId = 1; PortId <= HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++)
+                {
+                    //
+                    // get port status
+                    //
+                    Status = GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, &StatusChange);
+                    if (NT_SUCCESS(Status))
+                    {
+                        //
+                        // is there a device connected
+                        //
+                        if (StatusChange.Status & USB_PORT_STATUS_CONNECT)
+                        {
+                            //
+                            // reset port
+                            //
+                            Status = SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_RESET);
+                            if (!NT_SUCCESS(Status))
+                                DPRINT1("Failed to reset on port %d\n", PortId);
+                        }
+                    }
+                }
+
                 //
                 // Send the first SCE Request
                 //
index e2e0cdb..f3a15bc 100644 (file)
@@ -1036,11 +1036,54 @@ CUSBHardwareDevice::GetPortStatus(
     OUT USHORT *PortStatus,
     OUT USHORT *PortChange)
 {
+    ULONG Value;
+
+    if (PortId > m_NumberOfPorts)
+        return STATUS_UNSUCCESSFUL;
+
+    // init result variables
+    *PortStatus = 0;
+    *PortChange = 0;
+
     //
-    // FIXME: should read status from hardware
+    // read port status
     //
-    *PortStatus = m_PortStatus[PortId].PortStatus;
-    *PortChange = m_PortStatus[PortId].PortChange;
+    Value = READ_REGISTER_ULONG((PULONG)((PUCHAR)m_Base + OHCI_RH_PORT_STATUS(PortId)));
+    DPRINT("GetPortStatus PortId %x Value %x\n", PortId, Value);
+
+
+    // connected
+    if (Value & OHCI_RH_PORTSTATUS_CCS)
+        *PortStatus |= USB_PORT_STATUS_CONNECT;
+
+    // did a device connect?
+    if (Value & OHCI_RH_PORTSTATUS_CSC)
+        *PortChange |= USB_PORT_STATUS_CONNECT;
+
+    // port enabled
+    if (Value & OHCI_RH_PORTSTATUS_PES)
+        *PortStatus |= USB_PORT_STATUS_ENABLE;
+
+    // port enabled
+    if (Value & OHCI_RH_PORTSTATUS_PESC)
+        *PortChange |= USB_PORT_STATUS_ENABLE;
+
+    // port suspend
+    if (Value & OHCI_RH_PORTSTATUS_PSS)
+        *PortStatus |= USB_PORT_STATUS_SUSPEND;
+
+    // port suspend
+    if (Value & OHCI_RH_PORTSTATUS_PSSC)
+        *PortChange |= USB_PORT_STATUS_ENABLE;
+
+    // port reset
+    if (Value & OHCI_RH_PORTSTATUS_PSS)
+        *PortStatus |= USB_PORT_STATUS_RESET;
+
+    // port reset
+    if (Value & OHCI_RH_PORTSTATUS_PRSC)
+        *PortChange |= USB_PORT_STATUS_RESET;
+
     return STATUS_SUCCESS;
 }
 
index bd03f50..62c25de 100644 (file)
@@ -1221,7 +1221,7 @@ USBSTOR_HandleExecuteSCSI(
     }
     else
     {
-        UNIMPLEMENTED;
+        DPRINT1("UNIMPLEMENTED Operation Code %x\n", pCDB->AsByte[0]);
         Request->SrbStatus = SRB_STATUS_ERROR;
         Status = STATUS_NOT_SUPPORTED;
         DbgBreakPoint();