From 8d98341ac8f2d7cd7e9d68cf9a98ba7e9c148aad Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Thu, 12 May 2011 12:58:07 +0000 Subject: [PATCH] [USBHUB_NEW] - Implement IOCTL_INTERNAL_USB_GET_PORT_STATUS. - Fixes to comments svn path=/branches/usb-bringup/; revision=51683 --- drivers/usb/usbhub_new/fdo.c | 8 ++--- drivers/usb/usbhub_new/pdo.c | 52 ++++++++++++++++++++++++++++----- drivers/usb/usbhub_new/usbhub.c | 4 +-- drivers/usb/usbhub_new/usbhub.h | 8 ++++- 4 files changed, 57 insertions(+), 15 deletions(-) diff --git a/drivers/usb/usbhub_new/fdo.c b/drivers/usb/usbhub_new/fdo.c index c2d1fbdee7a..f4f9faa6eb6 100644 --- a/drivers/usb/usbhub_new/fdo.c +++ b/drivers/usb/usbhub_new/fdo.c @@ -112,7 +112,7 @@ GetPortStatusAndChange( 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 @@ SetPortFeature( 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 @@ ClearPortFeature( 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 @@ GetUsbDeviceDescriptor( RtlZeroMemory(Urb, sizeof(URB)); // - // Create URB for getting device descriptor + // Initialize URB for getting device descriptor // UsbBuildGetDescriptorRequest(Urb, sizeof(Urb->UrbControlDescriptorRequest), diff --git a/drivers/usb/usbhub_new/pdo.c b/drivers/usb/usbhub_new/pdo.c index e336c5cf103..6632c02cde4 100644 --- a/drivers/usb/usbhub_new/pdo.c +++ b/drivers/usb/usbhub_new/pdo.c @@ -26,7 +26,7 @@ UrbCompletion( // 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 @@ USBHUB_PdoHandleInternalDeviceControl( //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 @@ USBHUB_PdoHandleInternalDeviceControl( 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 @@ USBHUB_PdoHandleInternalDeviceControl( 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 @@ USBHUB_PdoHandleInternalDeviceControl( 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"); + 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; diff --git a/drivers/usb/usbhub_new/usbhub.c b/drivers/usb/usbhub_new/usbhub.c index fd9cc30f302..2ce4f8b33a5 100644 --- a/drivers/usb/usbhub_new/usbhub.c +++ b/drivers/usb/usbhub_new/usbhub.c @@ -9,8 +9,6 @@ * Johannes Anderwald (johannes.anderwald@reactos.org) */ - -//#define NDEBUG #include "usbhub.h" NTSTATUS NTAPI @@ -61,7 +59,7 @@ USBHUB_AddDevice( PDEVICE_OBJECT DeviceObject; PHUB_DEVICE_EXTENSION HubDeviceExtension; NTSTATUS Status; - + DPRINT1("USBHUB: AddDevice\n"); // // Create the Device Object // diff --git a/drivers/usb/usbhub_new/usbhub.h b/drivers/usb/usbhub_new/usbhub.h index c84105bb1c6..ac1479c9fb5 100644 --- a/drivers/usb/usbhub_new/usbhub.h +++ b/drivers/usb/usbhub_new/usbhub.h @@ -158,7 +158,13 @@ DumpDeviceDescriptor( 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);