GSoC final report for USB project.

by VardanM | August 22, 2016

Here is my final blog post in terms of GSoC, but definitely not the last one in terms of contribution to ReactOS. I’ll try to share conclusion of my work done during this summer.


First of all links


Here are the links to GIT and SVN repositories containing my commits. These repos are identical, so for review or fork you can choose the one that is more eligible for you. I myself will prefer Git.,author=vmikayelyan/reactos

What was done.


During the planning stage I didn’t expect that I am so far from Windows or… let’s say ReactOS driver development. I had some experience in Linux driver development, but this is very different. Absolutely another driver model requires lot of investigation and communication with mentor.


At the beginning of project, I have done testing of our usb stack running under win2k3 results of which is presented in my first blog post.


First of all I have noticed that ROS’s USB stack is quite “lazy”, it do not like reloading. The cause of this was missings in PnP handling of all layers of USB stack. So as part of overall stability increasion I decided to investigate and fix PnP issues. As you may know, implementation of PnP handler for bus drivers is much harder than the same task for device drivers.  This was very challenging for me, and I’ve committed a lot of time to get PnP handler working under 2k3.


PnP handler implementation was divided into two parts. First part was to make it run on 2k3, then test and integrate changes into ROS.




I was testing our ohci+hub pair injected into win2k3 usb stack. Before advancing to reload phase, I was trying to make them work with other layers of MS USB stack.


For example MS’s usbccgp was not working on top of our ohci+hub pair due to wrong handling of some PnP IRPs. The “usb: hub: FDO: Rework IRP_MN_QUERY_DEVICE_RELATIONS” commit resolved that situation and Composite USB device with its HID subdevices appears in USB device tree. The result is shown below:



Next I addressed the task of removability. At the beginning it was hanging on usbccgp removal from device manager or usb device physically disconnection.

To fix this kind of issues I’ve added(or re implemented) all the PnP handling stuff in usbhub bus driver. After these modifications the stack was easily handling surprise-removal(device disconnection from port) and usb device (but not controller) removal from device manager.

Also I have added synchronization mechanisms for shared resources management and remove-synchronization to usbhub.

Before moving driver to ReactOS, testing with Driver Verifier (DV) have been done. Seems like our usbhub was never been validated with DV. There was a number of issues in PnP handling not only in usbhub, but also in libusb. The verifier was complaining everywhere, on boot, on removal, on shutdown... I spent several days to fix all the DV reported issues. So now with our usbhub+usbohci, with enhanced I/O validation enabled DV is not complaining at all. To be honest, I should say that there are tests for OHCI which have not been performed, so this quietness of DV is only for usbhub.

There is still one pending issue related MS’s hidusb. It is not unloading from device manager because of reference hold. I have done some debugging, but postponed fixing this issue due to time limits of the project.



On ROS the PnP handing is not fully tested yet, due to some non-USB related issues:

CORE-11849 - “BSoD on shut-down after USB-flash ejection.” (Bug reported by me)


In general I’ve successfully tested physical disconnect / connect for usb-flesh, mouse and keyboard under ROS. All devices are performing well after disconnect->connect sequence.


I have been involved in issue creation, reproduction and fixing process as well. This was not less interesting than development of new features. After finalizing the commits for PnP handling, I moved to real world issues from Jira. I have created, reproduced, commented or fixed the following issues:


CORE-6257 - OS hangs during startup with connected USB drive (closed)
CORE-7743 - Many bugs related to USB (closed)
CORE-7224 - Port reset loop when USB device attached on boot (reported unreproducible)

CORE-11367 - FDODeviceExtension->ActiveSrb != NULL after ejecting USB FAT32 flash (reported unreproducible)
CORE-6831 - USB mouse is not working in VMware (commented explanation of the cause)
CORE-11538 - BSOD on startup when a PowerA Pro Elite Wireless controller is attached (fixed)

CORE-6331 -  USB-Wlan Adapter RTL8187 not working (assigned to me)


All issues are classified into HW reproducible and SW reproducible (on VM) categories. I’ve started to work on SW ones as there are easier to reproduce and work on (from time perspective). Also HW issues are unpredictable for estimation, so it is too risky to work on them in terms of GSoC. After this GSoC I’ll work on HW reproducible issues as well.


What’s next?


Also me and my mentor have prepared list of long term tasks on which I will work on later.


* Add support for posting URBs at DISPATCH_LEVEL (CORE-6331)
* Add (non-root) hub support to usbhub (CORE-6831 )
* Fix boot-from-USB support (

* Fix MS’s HIDUSB removal in 2k3.

* Fix "Official ROS testing laptop" USB support (CORE-9296)
* Implement usbxhci (large project, low priority)



Everywhere it is written “I” you can interpret it as “we”, as all time I’ve worked on this project, my mentor was standing with me and was reachable every time I had something to ask.

Thank you Tom!