Author: mjmartin
Date: Thu May 12 12:58:07 2011
New Revision: 51683
URL:
http://svn.reactos.org/svn/reactos?rev=51683&view=rev
Log:
[USBHUB_NEW]
- Implement IOCTL_INTERNAL_USB_GET_PORT_STATUS.
- Fixes to comments
Modified:
branches/usb-bringup/drivers/usb/usbhub_new/fdo.c
branches/usb-bringup/drivers/usb/usbhub_new/pdo.c
branches/usb-bringup/drivers/usb/usbhub_new/usbhub.c
branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h
Modified: branches/usb-bringup/drivers/usb/usbhub_new/fdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbhub_new/fdo.c [iso-8859-1] Thu May 12 12:58:07
2011
@@ -112,7 +112,7 @@
RtlZeroMemory(Urb, sizeof(URB));
//
- // Create URB for getting Port Status
+ // Initialize URB for getting Port Status
//
UsbBuildVendorRequest(Urb,
URB_FUNCTION_CLASS_OTHER,
@@ -165,7 +165,7 @@
RtlZeroMemory(Urb, sizeof(URB));
//
- // Create URB for Clearing Port Reset
+ // Initialize URB for Clearing Port Reset
//
UsbBuildVendorRequest(Urb,
URB_FUNCTION_CLASS_OTHER,
@@ -217,7 +217,7 @@
RtlZeroMemory(Urb, sizeof(URB));
//
- // Create URB for Clearing Port Reset
+ // Initialize URB for Clearing Port Reset
//
UsbBuildVendorRequest(Urb,
URB_FUNCTION_CLASS_OTHER,
@@ -655,7 +655,7 @@
RtlZeroMemory(Urb, sizeof(URB));
//
- // Create URB for getting device descriptor
+ // Initialize URB for getting device descriptor
//
UsbBuildGetDescriptorRequest(Urb,
sizeof(Urb->UrbControlDescriptorRequest),
Modified: branches/usb-bringup/drivers/usb/usbhub_new/pdo.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbhub_new/pdo.c [iso-8859-1] Thu May 12 12:58:07
2011
@@ -26,7 +26,7 @@
// Get the original Irp
//
OriginalIrp = (PIRP)Context;
-
+
//
// Update it to match what was returned for the IRP that was passed to RootHub
//
@@ -137,7 +137,15 @@
//DPRINT1("UsbhubInternalDeviceControlPdo(%x) called\n", DeviceObject);
+ //
+ // get current stack location
+ //
Stack = IoGetCurrentIrpStackLocation(Irp);
+ ASSERT(Stack);
+
+ //
+ // Set default status
+ //
Status = Irp->IoStatus.Status;
ChildDeviceExtension = (PHUB_CHILDDEVICE_EXTENSION)DeviceObject->DeviceExtension;
@@ -173,18 +181,13 @@
case IOCTL_INTERNAL_USB_SUBMIT_URB:
{
//DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB\n");
- //
- // get current stack location
- //
- Stack = IoGetCurrentIrpStackLocation(Irp);
- ASSERT(Stack);
//
// Get the Urb
//
Urb = (PURB)Stack->Parameters.Others.Argument1;
ASSERT(Urb);
-
+
//
// Set the real device handle
//
@@ -229,8 +232,12 @@
DPRINT1("Length %x\n",
Urb->UrbBulkOrInterruptTransfer.TransferBufferLength);
DPRINT1("UrbLink %x\n",
Urb->UrbBulkOrInterruptTransfer.UrbLink);
DPRINT1("hca %x\n",
Urb->UrbBulkOrInterruptTransfer.hca);
+ if (Urb->UrbBulkOrInterruptTransfer.TransferFlags ==
USBD_SHORT_TRANSFER_OK)
+ {
+ }
*/
break;
+
}
case URB_FUNCTION_CLASS_INTERFACE:
DPRINT1("URB_FUNCTION_CLASS_INTERFACE\n");
@@ -255,8 +262,39 @@
DPRINT1("IOCTL_INTERNAL_USB_RESET_PORT\n");
break;
case IOCTL_INTERNAL_USB_GET_PORT_STATUS:
+ {
+ PORT_STATUS_CHANGE PortStatus;
+ LONG PortId;
+ PUCHAR PortStatusBits;
+
+ PortStatusBits = (PUCHAR)Stack->Parameters.Others.Argument1;
+ //
+ // USBD_PORT_ENABLED (bit 0) or USBD_PORT_CONNECTED (bit 1)
+ //
DPRINT1("IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
- break;
+ DPRINT1("Arg1 %x\n", *PortStatusBits);
+ *PortStatusBits = 0;
+ if (Stack->Parameters.Others.Argument1)
+ {
+ for (PortId = 1; PortId <=
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; PortId++)
+ {
+ Status = GetPortStatusAndChange(RootHubDeviceObject, PortId,
&PortStatus);
+ if (NT_SUCCESS(Status))
+ {
+ DPRINT1("Connect %x\n", ((PortStatus.Status &
USB_PORT_STATUS_CONNECT) << 1) << ((PortId - 1) * 2));
+ DPRINT1("Enable %x\n", ((PortStatus.Status &
USB_PORT_STATUS_ENABLE) >> 1) << ((PortId - 1) * 2));
+ *PortStatusBits +=
+ ((PortStatus.Status & USB_PORT_STATUS_CONNECT) <<
1) << ((PortId - 1) * 2) +
+ ((PortStatus.Status & USB_PORT_STATUS_ENABLE) >> 1)
<< ((PortId - 1) * 2);
+
+ }
+ }
+ }
+
+ DPRINT1("Arg1 %x\n", *PortStatusBits);
+ Status = STATUS_SUCCESS;
+ break;
+ }
case IOCTL_INTERNAL_USB_ENABLE_PORT:
DPRINT1("IOCTL_INTERNAL_USB_ENABLE_PORT\n");
break;
Modified: branches/usb-bringup/drivers/usb/usbhub_new/usbhub.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbhub_new/usbhub.c [iso-8859-1] Thu May 12 12:58:07
2011
@@ -9,8 +9,6 @@
* Johannes Anderwald (johannes.anderwald(a)reactos.org)
*/
-
-//#define NDEBUG
#include "usbhub.h"
NTSTATUS NTAPI
@@ -61,7 +59,7 @@
PDEVICE_OBJECT DeviceObject;
PHUB_DEVICE_EXTENSION HubDeviceExtension;
NTSTATUS Status;
-
+ DPRINT1("USBHUB: AddDevice\n");
//
// Create the Device Object
//
Modified: branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/usb/usbhub_…
==============================================================================
--- branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/usb/usbhub_new/usbhub.h [iso-8859-1] Thu May 12 12:58:07
2011
@@ -158,7 +158,13 @@
VOID
DumpConfigurationDescriptor(
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
-
+
VOID
DumpFullConfigurationDescriptor(
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
+
+NTSTATUS
+GetPortStatusAndChange(
+ IN PDEVICE_OBJECT RootHubDeviceObject,
+ IN ULONG PortId,
+ OUT PPORT_STATUS_CHANGE StatusChange);