Author: janderwald
Date: Wed Jul 31 18:21:24 2013
New Revision: 59605
URL:
http://svn.reactos.org/svn/reactos?rev=59605&view=rev
Log:
[LIBUSB]
- Perform intialization of root hub in a worker thread
- Should help ReactOS to continue booting when an usb controller causes hangs
Modified:
trunk/reactos/lib/drivers/libusb/hub_controller.cpp
trunk/reactos/lib/drivers/libusb/libusb.h
Modified: trunk/reactos/lib/drivers/libusb/hub_controller.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/hub_con…
==============================================================================
--- trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/libusb/hub_controller.cpp [iso-8859-1] Wed Jul 31 18:21:24
2013
@@ -3351,6 +3351,31 @@
return STATUS_SUCCESS;
}
+
+WORKER_THREAD_ROUTINE InitRootHub;
+
+VOID
+NTAPI
+InitRootHub(IN PVOID Context)
+{
+ PINIT_ROOT_HUB_CONTEXT WorkItem;
+
+ //
+ // get context
+ //
+ WorkItem = (PINIT_ROOT_HUB_CONTEXT)Context;
+
+ //
+ // perform callback
+ //
+ WorkItem->CallbackRoutine(WorkItem->CallbackContext);
+
+ //
+ // free contextg
+ //
+ ExFreePoolWithTag(Context, TAG_USBLIB);
+}
+
NTSTATUS
USB_BUSIFFN
USBHI_RootHubInitNotification(
@@ -3359,6 +3384,7 @@
PRH_INIT_CALLBACK CallbackRoutine)
{
CHubController * Controller;
+ PINIT_ROOT_HUB_CONTEXT WorkItem;
DPRINT("USBHI_RootHubInitNotification %p \n", CallbackContext);
@@ -3374,9 +3400,26 @@
Controller->SetNotification(CallbackContext, CallbackRoutine);
//
- // FIXME: determine when to perform callback
- //
- CallbackRoutine(CallbackContext);
+ // Create and initialize work item data
+ //
+ WorkItem = (PINIT_ROOT_HUB_CONTEXT)ExAllocatePoolWithTag(NonPagedPool,
sizeof(INIT_ROOT_HUB_CONTEXT), TAG_USBLIB);
+ if (!WorkItem)
+ {
+ DPRINT1("Failed to allocate memory!n");
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ //
+ // init context
+ //
+ WorkItem->CallbackRoutine = CallbackRoutine;
+ WorkItem->CallbackContext = CallbackContext;
+
+ //
+ // Queue the work item to handle initializing the device
+ //
+ ExInitializeWorkItem(&WorkItem->WorkItem, InitRootHub, (PVOID)WorkItem);
+ ExQueueWorkItem(&WorkItem->WorkItem, DelayedWorkQueue);
//
// done
Modified: trunk/reactos/lib/drivers/libusb/libusb.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/libusb/libusb.…
==============================================================================
--- trunk/reactos/lib/drivers/libusb/libusb.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/libusb/libusb.h [iso-8859-1] Wed Jul 31 18:21:24 2013
@@ -52,6 +52,14 @@
PDISPATCHIRP Dispatcher; // dispatches the code
}COMMON_DEVICE_EXTENSION, *PCOMMON_DEVICE_EXTENSION;
+
+typedef struct _WORK_ITEM_DATA
+{
+ WORK_QUEUE_ITEM WorkItem; // work item
+ PVOID CallbackContext; // callback context
+ PRH_INIT_CALLBACK CallbackRoutine; // callback routine
+} INIT_ROOT_HUB_CONTEXT, *PINIT_ROOT_HUB_CONTEXT;
+
//
// tag for allocations
//