Author: mjmartin
Date: Wed May 4 12:58:42 2011
New Revision: 51576
URL:
http://svn.reactos.org/svn/reactos?rev=51576&view=rev
Log:
[USBHUB_NEW]
- Change parameter name for DeviceObject in functions to clearify which device object is
to received IRPs.
- Fix a typo in GetPortStatusAndChange that caused the function to return nothing for
status and change.
- Call QueryStatusChangeEndpoint to send the first SCE request in Query Bus Releations.
- Complete implementation of StatusChangeEndpointCompletion. Queue a work item for
DeviceStatusChangeThread, which will be used to initialize the usb device and create
related device objects.
Modified:
branches/usb-bringup/drivers/usb/usbhub_new/fdo.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] Wed May 4 12:58:42
2011
@@ -1,4 +1,4 @@
-/*
+/*
* PROJECT: ReactOS Universal Serial Bus Hub Driver
* LICENSE: GPL - See COPYING in the top level directory
* FILE: drivers/usb/usbhub/fdo.c
@@ -14,8 +14,12 @@
#include "usbhub.h"
NTSTATUS
+QueryStatusChangeEndpoint(
+ IN PDEVICE_OBJECT DeviceObject);
+
+NTSTATUS
SubmitRequestToRootHub(
- IN PDEVICE_OBJECT DeviceObject,
+ IN PDEVICE_OBJECT RootHubDeviceObject,
IN ULONG IoControlCode,
OUT PVOID OutParameter1,
OUT PVOID OutParameter2)
@@ -32,7 +36,7 @@
// Build Control Request
//
Irp = IoBuildDeviceIoControlRequest(IoControlCode,
- DeviceObject,
+ RootHubDeviceObject,
NULL, 0,
NULL, 0,
TRUE,
@@ -61,7 +65,7 @@
//
// Call RootHub
//
- Status = IoCallDriver(DeviceObject, Irp);
+ Status = IoCallDriver(RootHubDeviceObject, Irp);
if (Status == STATUS_PENDING)
{
@@ -73,172 +77,12 @@
return Status;
}
-NTSTATUS
-StatusChangeEndpointCompletion(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp,
- PVOID Context)
-{
- PHUB_DEVICE_EXTENSION HubDeviceExtension;
- LONG i;
-
- HubDeviceExtension =
(PHUB_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
-
- //
- // Determine which port has changed
- //
- for (i=0; i < HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; i++)
- {
- DPRINT1("Port %x HubDeviceExtension->PortStatus %x\n",i+1,
HubDeviceExtension->PortStatusChange[i].Status);
- DPRINT1("Port %x HubDeviceExtension->PortChange %x\n",i+1,
HubDeviceExtension->PortStatusChange[i].Change);
- //
- // FIXME: Call function to check port before creating device object for it
- //
- }
-
- //
- // Free the Irp and return more processing required so the IO Manger doesnât try to
free it
- //
- IoFreeIrp(Irp);
-
- return STATUS_MORE_PROCESSING_REQUIRED;
-}
-
-NTSTATUS
-QueryStatusChangeEndpoint(
- PDEVICE_OBJECT DeviceObject)
-{
- NTSTATUS Status;
- PIO_STACK_LOCATION Stack;
- PHUB_DEVICE_EXTENSION HubDeviceExtension;
-
- HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-
- HubDeviceExtension->PendingSCEUrb;
- RtlZeroMemory(&HubDeviceExtension->PendingSCEUrb,
- sizeof(URB));
-
- //
- // Create URB for Status Change Endpoint request
- //
- UsbBuildInterruptOrBulkTransferRequest(&HubDeviceExtension->PendingSCEUrb,
- sizeof(struct
_URB_BULK_OR_INTERRUPT_TRANSFER),
- HubDeviceExtension->PipeHandle,
- HubDeviceExtension->PortStatusChange,
- NULL,
- sizeof(USHORT) * 2 *
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts,
- USBD_TRANSFER_DIRECTION_IN |
USBD_SHORT_TRANSFER_OK,
- NULL);
-
- //
- // Set the device handle to null for roothub
- //
- HubDeviceExtension->PendingSCEUrb.UrbHeader.UsbdDeviceHandle = NULL;
-
- //
- // Allocate an Irp
- //
- HubDeviceExtension->PendingSCEIrp =
IoAllocateIrp(HubDeviceExtension->RootHubPhysicalDeviceObject->StackSize,
- FALSE);
-
- if (!HubDeviceExtension->PendingSCEIrp)
- {
- DPRINT1("USBHUB: Failed to allocate IRP for SCE request!\n");
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- //
- // Initialize the IRP
- //
- HubDeviceExtension->PendingSCEIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
- HubDeviceExtension->PendingSCEIrp->IoStatus.Information = 0;
- HubDeviceExtension->PendingSCEIrp->Flags = 0;
- HubDeviceExtension->PendingSCEIrp->UserBuffer = NULL;
-
- //
- // Get the Next Stack Location and Initialize it
- //
- Stack = IoGetNextIrpStackLocation(HubDeviceExtension->PendingSCEIrp);
- Stack->DeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
- Stack->Parameters.Others.Argument1 = &HubDeviceExtension->PendingSCEUrb;
- Stack->Parameters.Others.Argument2 = NULL;
- Stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
- Stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
-
- //
- // Set the completion routine for when device is connected to root hub
- //
- IoSetCompletionRoutine(HubDeviceExtension->PendingSCEIrp,
- (PIO_COMPLETION_ROUTINE) StatusChangeEndpointCompletion,
- DeviceObject,
- TRUE,
- TRUE,
- TRUE);
-
- Status = IoCallDriver(HubDeviceExtension->RootHubPhysicalDeviceObject,
HubDeviceExtension->PendingSCEIrp);
- DPRINT1("SCE request status %x\n", Status);
-
- return STATUS_PENDING;
-}
-
-NTSTATUS
-QueryInterface(
- IN PDEVICE_OBJECT DeviceObject,
- IN CONST GUID InterfaceType,
- IN LONG Size,
- IN LONG Version,
- OUT PVOID Interface)
-{
- KEVENT Event;
- PIRP Irp;
- IO_STATUS_BLOCK IoStatus;
- NTSTATUS Status;
- PIO_STACK_LOCATION Stack = NULL;
-
- //
- // Initialize the Event used to wait for Irp completion
- //
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- //
- // Build Control Request
- //
- Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
- DeviceObject,
- NULL,
- 0,
- NULL,
- &Event,
- &IoStatus);
-
- //
- // Get Next Stack Location and Initialize it.
- //
- Stack = IoGetNextIrpStackLocation(Irp);
- Stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
- Stack->Parameters.QueryInterface.InterfaceType=
&InterfaceType;//USB_BUS_INTERFACE_HUB_GUID;
- Stack->Parameters.QueryInterface.Size = Size;
- Stack->Parameters.QueryInterface.Version = Version;
- Stack->Parameters.QueryInterface.Interface = Interface;
- Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
-
- Status = IoCallDriver(DeviceObject, Irp);
-
- if (Status == STATUS_PENDING)
- {
- DPRINT("Operation pending\n");
- KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
- Status = IoStatus.Status;
- }
-
- return Status;
-}
-
-NTSTATUS
+
+NTSTATUS
GetPortStatusAndChange(
- IN PDEVICE_OBJECT DeviceObject,
+ IN PDEVICE_OBJECT RootHubDeviceObject,
IN ULONG PortId,
- OUT PORT_STATUS_CHANGE *StatusChange)
+ OUT PPORT_STATUS_CHANGE StatusChange)
{
NTSTATUS Status;
PURB Urb;
@@ -269,7 +113,7 @@
USB_REQUEST_GET_STATUS,
0,
PortId,
- &StatusChange,
+ StatusChange,
0,
sizeof(PORT_STATUS_CHANGE),
0);
@@ -277,7 +121,7 @@
//
// Query the Root Hub
//
- Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb,
NULL);
+ Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB,
Urb, NULL);
//
// Free URB
@@ -289,9 +133,9 @@
NTSTATUS
SetPortFeature(
- PDEVICE_OBJECT DeviceObject,
- ULONG PortId,
- ULONG Feature)
+ IN PDEVICE_OBJECT RootHubDeviceObject,
+ IN ULONG PortId,
+ IN ULONG Feature)
{
NTSTATUS Status;
PURB Urb;
@@ -329,7 +173,7 @@
//
// Query the Root Hub
//
- Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb,
NULL);
+ Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB,
Urb, NULL);
//
// Free URB
@@ -341,9 +185,9 @@
NTSTATUS
ClearPortFeature(
- PDEVICE_OBJECT DeviceObject,
- ULONG PortId,
- ULONG Feature)
+ IN PDEVICE_OBJECT RootHubDeviceObject,
+ IN ULONG PortId,
+ IN ULONG Feature)
{
NTSTATUS Status;
PURB Urb;
@@ -381,7 +225,7 @@
//
// Query the Root Hub
//
- Status = SubmitRequestToRootHub(DeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB, Urb,
NULL);
+ Status = SubmitRequestToRootHub(RootHubDeviceObject, IOCTL_INTERNAL_USB_SUBMIT_URB,
Urb, NULL);
//
// Free URB
@@ -391,14 +235,273 @@
return Status;
}
+VOID NTAPI
+DeviceStatusChangeThread(
+ IN PVOID Context)
+{
+ NTSTATUS Status;
+ PDEVICE_OBJECT DeviceObject;
+ PHUB_DEVICE_EXTENSION HubDeviceExtension;
+ PWORK_ITEM_DATA WorkItemData;
+ PORT_STATUS_CHANGE PortStatus;
+ LONG PortId, i;
+
+ WorkItemData = (PWORK_ITEM_DATA)Context;
+ DeviceObject = (PDEVICE_OBJECT)WorkItemData->Context;
+ HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ //
+ // Itterate all ports
+ //
+ for (PortId = 1; PortId <= HubDeviceExtension->UsbExtHubInfo.NumberOfPorts;
PortId++)
+ {
+ PortStatus.Change = 0;
+ PortStatus.Status = 0;
+ //
+ // Get Port Status
+ //
+ Status =
GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId,
&PortStatus);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to get port status for port %d, Status %x\n",
PortId, Status);
+ // FIXME: Do we really want to halt further SCE requests?
+ return;
+ }
+
+ //
+ // Check for new device connection
+ //
+ if (PortStatus.Change == USB_PORT_STATUS_CONNECT)
+ {
+ //
+ // Clear Connection Status
+ //
+ Status = ClearPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject,
PortId, C_PORT_CONNECTION);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to clear connection change for port %d\n",
PortId);
+ // FIXME: Do we really want to halt further SCE requests?
+ return;
+ }
+
+ //
+ // Get Port Status and ensure it updated
+ //
+ Status =
GetPortStatusAndChange(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId,
&PortStatus);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to get port status for port %d, Status %x\n",
PortId, Status);
+ // FIXME: Do we really want to halt further SCE requests?
+ return;
+ }
+
+ if (PortStatus.Change != 0)
+ {
+ DPRINT1("Port %d did not clear Connection Change!\n");
+ // FIXME: Do we really want to halt further SCE requests?
+ return;
+ }
+
+ //
+ // FIXME: Create the device object and enable the port
+ //
+ //CreateUsbChildDeviceObject
+ }
+ }
+
+ //
+ // Send another SCE Request
+ //
+ QueryStatusChangeEndpoint(DeviceObject);
+
+ ExFreePool(WorkItemData);
+}
+
+NTSTATUS
+StatusChangeEndpointCompletion(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp,
+ IN PVOID Context)
+{
+ PDEVICE_OBJECT RealDeviceObject;
+ PHUB_DEVICE_EXTENSION HubDeviceExtension;
+ PWORK_ITEM_DATA WorkItemData;
+ LONG i;
+
+ RealDeviceObject = (PDEVICE_OBJECT)Context;
+ HubDeviceExtension = (PHUB_DEVICE_EXTENSION)RealDeviceObject->DeviceExtension;
+
+ //
+ // Determine which port has changed
+ //
+ for (i=0; i < HubDeviceExtension->UsbExtHubInfo.NumberOfPorts; i++)
+ {
+ DPRINT1("Port %x HubDeviceExtension->PortStatus %x\n",i+1,
HubDeviceExtension->PortStatusChange[i].Status);
+ DPRINT1("Port %x HubDeviceExtension->PortChange %x\n",i+1,
HubDeviceExtension->PortStatusChange[i].Change);
+ }
+
+ //
+ // Free the Irp and return more processing required so the IO Manger doesnât try to
free it
+ //
+ IoFreeIrp(Irp);
+
+ //
+ // Create and initialize work item data
+ //
+ WorkItemData = ExAllocatePoolWithTag(NonPagedPool, sizeof(WORK_ITEM_DATA),
USB_HUB_TAG);
+ if (!WorkItemData)
+ {
+ DPRINT1("Failed to allocate memory!n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ WorkItemData->Context = RealDeviceObject;
+ ExInitializeWorkItem(&WorkItemData->WorkItem,
(PWORKER_THREAD_ROUTINE)DeviceStatusChangeThread, (PVOID)WorkItemData);
+
+ //
+ // Queue the work item to handle initializing the device
+ //
+ ExQueueWorkItem(&WorkItemData->WorkItem, DelayedWorkQueue);
+
+ return STATUS_MORE_PROCESSING_REQUIRED;
+}
+
+NTSTATUS
+QueryStatusChangeEndpoint(
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ NTSTATUS Status;
+ PIO_STACK_LOCATION Stack;
+ PHUB_DEVICE_EXTENSION HubDeviceExtension;
+
+ HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+
+ //
+ // Initialize URB for Status Change Endpoint request
+ //
+ UsbBuildInterruptOrBulkTransferRequest(&HubDeviceExtension->PendingSCEUrb,
+ sizeof(struct
_URB_BULK_OR_INTERRUPT_TRANSFER),
+ HubDeviceExtension->PipeHandle,
+ HubDeviceExtension->PortStatusChange,
+ NULL,
+ sizeof(USHORT) * 2 *
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts,
+ USBD_TRANSFER_DIRECTION_IN |
USBD_SHORT_TRANSFER_OK,
+ NULL);
+
+ //
+ // Set the device handle to null for roothub
+ //
+ HubDeviceExtension->PendingSCEUrb.UrbHeader.UsbdDeviceHandle = NULL;
+
+ //
+ // Allocate an Irp
+ //
+ HubDeviceExtension->PendingSCEIrp =
IoAllocateIrp(HubDeviceExtension->RootHubPhysicalDeviceObject->StackSize,
+ FALSE);
+
+ if (!HubDeviceExtension->PendingSCEIrp)
+ {
+ DPRINT1("USBHUB: Failed to allocate IRP for SCE request!\n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // Initialize the IRP
+ //
+ HubDeviceExtension->PendingSCEIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ HubDeviceExtension->PendingSCEIrp->IoStatus.Information = 0;
+ HubDeviceExtension->PendingSCEIrp->Flags = 0;
+ HubDeviceExtension->PendingSCEIrp->UserBuffer = NULL;
+
+ //
+ // Get the Next Stack Location and Initialize it
+ //
+ Stack = IoGetNextIrpStackLocation(HubDeviceExtension->PendingSCEIrp);
+ Stack->DeviceObject = HubDeviceExtension->RootHubPhysicalDeviceObject;
+ Stack->Parameters.Others.Argument1 = &HubDeviceExtension->PendingSCEUrb;
+ Stack->Parameters.Others.Argument2 = NULL;
+ Stack->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL;
+ Stack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
+
+ //
+ // Set the completion routine for when device is connected to root hub
+ //
+ IoSetCompletionRoutine(HubDeviceExtension->PendingSCEIrp,
+ (PIO_COMPLETION_ROUTINE) StatusChangeEndpointCompletion,
+ DeviceObject,
+ TRUE,
+ TRUE,
+ TRUE);
+
+ //
+ // Send to RootHub
+ //
+ Status = IoCallDriver(HubDeviceExtension->RootHubPhysicalDeviceObject,
HubDeviceExtension->PendingSCEIrp);
+
+ return STATUS_PENDING;
+}
+
+NTSTATUS
+QueryInterface(
+ IN PDEVICE_OBJECT DeviceObject,
+ IN CONST GUID InterfaceType,
+ IN LONG Size,
+ IN LONG Version,
+ OUT PVOID Interface)
+{
+ KEVENT Event;
+ PIRP Irp;
+ IO_STATUS_BLOCK IoStatus;
+ NTSTATUS Status;
+ PIO_STACK_LOCATION Stack = NULL;
+
+ //
+ // Initialize the Event used to wait for Irp completion
+ //
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ //
+ // Build Control Request
+ //
+ Irp = IoBuildSynchronousFsdRequest(IRP_MJ_PNP,
+ DeviceObject,
+ NULL,
+ 0,
+ NULL,
+ &Event,
+ &IoStatus);
+
+ //
+ // Get Next Stack Location and Initialize it.
+ //
+ Stack = IoGetNextIrpStackLocation(Irp);
+ Stack->MinorFunction = IRP_MN_QUERY_INTERFACE;
+ Stack->Parameters.QueryInterface.InterfaceType=
&InterfaceType;//USB_BUS_INTERFACE_HUB_GUID;
+ Stack->Parameters.QueryInterface.Size = Size;
+ Stack->Parameters.QueryInterface.Version = Version;
+ Stack->Parameters.QueryInterface.Interface = Interface;
+ Stack->Parameters.QueryInterface.InterfaceSpecificData = NULL;
+
+ Status = IoCallDriver(DeviceObject, Irp);
+
+ if (Status == STATUS_PENDING)
+ {
+ DPRINT("Operation pending\n");
+ KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
+ Status = IoStatus.Status;
+ }
+
+ return Status;
+}
+
NTSTATUS
GetUsbDeviceDescriptor(
- PDEVICE_OBJECT ChildDeviceObject,
- UCHAR DescriptorType,
- UCHAR Index,
- USHORT LangId,
- PVOID TransferBuffer,
- ULONG TransferBufferLength)
+ IN PDEVICE_OBJECT ChildDeviceObject,
+ IN UCHAR DescriptorType,
+ IN UCHAR Index,
+ IN USHORT LangId,
+ OUT PVOID TransferBuffer,
+ IN ULONG TransferBufferLength)
{
NTSTATUS Status;
PURB Urb;
@@ -508,7 +611,6 @@
ULONG NeededSize;
HubDeviceExtension = (PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- DPRINT1("Query Bus Relations\n");
//
// Count the number of children
@@ -554,8 +656,9 @@
*pDeviceRelations = DeviceRelations;
//
- // FIXME: Send the first SCE Request
- //
+ // Send the first SCE Request
+ //
+ QueryStatusChangeEndpoint(DeviceObject);
return STATUS_SUCCESS;
}
@@ -582,7 +685,6 @@
ULONG Result = 0;
PUSB_INTERFACE_DESCRIPTOR Pid;
ULONG PortId;
-
USBD_INTERFACE_LIST_ENTRY InterfaceList[2] = {{NULL, NULL}, {NULL, NULL}};
PURB ConfigUrb = NULL;
@@ -629,7 +731,7 @@
//
// Get the Hub Interface
//
- Status = QueryInterface(HubDeviceExtension->RootHubPhysicalDeviceObject,
+ Status = QueryInterface(HubDeviceExtension->RootHubPhysicalDeviceObject,
USB_BUS_INTERFACE_HUB_GUID,
sizeof(USB_BUS_INTERFACE_HUB_V5),
5,
@@ -678,7 +780,6 @@
&HubDeviceExtension->DeviceInformation,
sizeof(USB_DEVICE_INFORMATION_0),
&Result);
-
DPRINT1("Status %x, Result 0x%08lx\n", Status, Result);
DPRINT1("InformationLevel %x\n",
HubDeviceExtension->DeviceInformation.InformationLevel);
@@ -687,7 +788,6 @@
DPRINT1("DeviceDescriptor %x\n",
HubDeviceExtension->DeviceInformation.DeviceDescriptor);
DPRINT1("HubAddress %x\n",
HubDeviceExtension->DeviceInformation.HubAddress);
DPRINT1("NumberofPipes %x\n",
HubDeviceExtension->DeviceInformation.NumberOfOpenPipes);
-
//
// Get Root Hubs Device Descriptor
@@ -746,10 +846,10 @@
DumpConfigurationDescriptor(&HubDeviceExtension->HubConfigDescriptor);
Status =
HubDeviceExtension->HubInterface.GetExtendedHubInformation(HubDeviceExtension->RootHubPhysicalDeviceObject,
-
HubDeviceExtension->RootHubPhysicalDeviceObject,
-
&HubDeviceExtension->UsbExtHubInfo,
-
sizeof(USB_EXTHUB_INFORMATION_0),
- &Result);
+
HubDeviceExtension->RootHubPhysicalDeviceObject,
+
&HubDeviceExtension->UsbExtHubInfo,
+
sizeof(USB_EXTHUB_INFORMATION_0),
+
&Result);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to extended hub information. Unable to determine the
number of ports!\n");
@@ -764,7 +864,7 @@
UsbBuildVendorRequest(Urb,
URB_FUNCTION_CLASS_DEVICE,
sizeof(Urb->UrbControlVendorClassRequest),
- USBD_TRANSFER_DIRECTION_IN,
+ USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK,
0,
USB_DEVICE_CLASS_RESERVED,
0,
@@ -781,6 +881,9 @@
Urb,
NULL);
+ //
+ // FIXME: This is returning nothing.
+ //
DPRINT1("bDescriptorType %x\n",
HubDeviceExtension->HubDescriptor.bDescriptorType);
if (!NT_SUCCESS(Status))
@@ -794,16 +897,25 @@
// Allocate memory for PortStatusChange to hold 2 USHORTs for each port on
hub
//
HubDeviceExtension->PortStatusChange =
ExAllocatePoolWithTag(NonPagedPool,
- sizeof(ULONG) *
HubDeviceExtension->HubDescriptor.bNumberOfPorts,
+ sizeof(ULONG) *
HubDeviceExtension->UsbExtHubInfo.NumberOfPorts,
USB_HUB_TAG);
+
+ //
+ // Initialize the Hub
+ //
+ Status =
HubDeviceExtension->HubInterface.Initialize20Hub(HubDeviceExtension->RootHubPhysicalDeviceObject,
+
HubDeviceExtension->RootHubHandle, 1);
+ DPRINT1("Status %x\n", Status);
//
// Get the first Configuration Descriptor
//
Pid =
USBD_ParseConfigurationDescriptorEx(&HubDeviceExtension->HubConfigDescriptor,
&HubDeviceExtension->HubConfigDescriptor,
- -1, -1, -1, -1, -1);
+ -1, -1, -1, -1, -1);
+
ASSERT(Pid != NULL);
+
InterfaceList[0].InterfaceDescriptor = Pid;
ConfigUrb =
USBD_CreateConfigurationRequestEx(&HubDeviceExtension->HubConfigDescriptor,
(PUSBD_INTERFACE_LIST_ENTRY)&InterfaceList);
@@ -821,19 +933,15 @@
ExFreePool(ConfigUrb);
//
- // Initialize the Hub
- //
- Status =
HubDeviceExtension->HubInterface.Initialize20Hub(HubDeviceExtension->RootHubPhysicalDeviceObject,
-
HubDeviceExtension->RootHubHandle, 1);
- DPRINT1("Status %x\n", Status);
-
- //
// Enable power on all ports
//
- for (PortId = 0; PortId <
HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++)
- {
- SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject,
PortId, PORT_POWER);
- }
+ for (PortId = 1; PortId <=
HubDeviceExtension->HubDescriptor.bNumberOfPorts; PortId++)
+ {
+ Status =
SetPortFeature(HubDeviceExtension->RootHubPhysicalDeviceObject, PortId, PORT_POWER);
+ if (!NT_SUCCESS(Status))
+ DPRINT1("Failed to power on port %d\n", PortId);
+ }
+
ExFreePool(Urb);
break;
}
@@ -859,7 +967,7 @@
}
default:
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / Unknown
type 0x%lx\n",
- Stack->Parameters.QueryDeviceRelations.Type);
+ Stack->Parameters.QueryDeviceRelations.Type);
return ForwardIrpAndForget(DeviceObject, Irp);
}
break;
@@ -885,6 +993,7 @@
return ForwardIrpAndForget(DeviceObject, Irp);
}
}
+
Irp->IoStatus.Information = Information;
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -893,8 +1002,8 @@
NTSTATUS
USBHUB_FdoHandleDeviceControl(
- PDEVICE_OBJECT DeviceObject,
- PIRP Irp)
+ IN PDEVICE_OBJECT DeviceObject,
+ IN PIRP Irp)
{
DPRINT1("FdoHandleDeviceControl\n");
UNIMPLEMENTED
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] Wed May 4 12:58:42
2011
@@ -36,6 +36,12 @@
USHORT Status;
USHORT Change;
} PORT_STATUS_CHANGE, *PPORT_STATUS_CHANGE;
+
+typedef struct _WORK_ITEM_DATA
+{
+ WORK_QUEUE_ITEM WorkItem;
+ PVOID Context;
+} WORK_ITEM_DATA, *PWORK_ITEM_DATA;
typedef struct
{