SourceQuest
bringing hardware & software together
Total Enumeration
More Logging Coverage
Total Enumeration is a benefit of the enhanced logging capabilities introduced in SourceUSB 2.0. A simple way to illustrate this is to capture an enumeration log for a hot-plugged mouse and count the number of log records until the completion of the start device Irp (this indicates that the function driver is loaded and device initialization is complete).
In the first test, only Irp-based events (including URBs and USB Internal Ioctls) are logged for a total of 83 records. In the second test, Hub-Bus interface calls and Miniport-Usbport interface calls, are also logged for a combined total of 353 records. So these new log types contribute 270 records to the enumeration trace.
Hub-Bus Interface and Miniport-Usbport Interface Functions
The additional log records in SourceUSB 2.0 and newer, come from two new sources. In both cases, the log entries represent function calls at well defined interfaces in the lower levels of the USB driver stack.
The pink areas in the driver stack diagram below, represent the layers at which the new logging information is collected. The Hub-Bus Interface provides functions that the hub driver calls in response to the arrival or removal of new devices. Thus these function calls represent stages of device enumeration or removal.
The Miniport-Usbport Interface represents a table of functions which is exchanged between a miniport driver and usbport. Some of the functions are supplied to usbport.sys as handlers for events or notifications. Some of the functions are services that usbport.sys supplies to miniports. There are over 70 functions in this interface.
Filling in the Enumeration Gaps
URB logging of the hub will reveal the sequence of port events following the hot-plug of a device. However, conspicuously absent from the URB log are the initial transactions sent to endpoint 0 of the device, in response to the new connection.
Total Enumeration reveals this early stage by the CreateUsbDevice (or CreateUsbDeviceEx) function call at the Hub-Bus interface. This function will query the characteristics of the device's endpoint 0 and then open it. The very first device descriptor request is made (not using an URB) before this function returns. These steps can be traced in the log of miniport interface function calls. The screenshot below illustrates this; the yellow tinted records represent the submission of a GET_DESCRIPTOR request and the green tinted records represent the request's completion.
Following a successful CreateUsbDevice (or CreateUsbDeviceEx) call, comes an InitializeUsbDevice (or InitializeUsbDeviceEx) call to the Hub-Bus interface. This function will perform the set address request and also retrieve the first 18 bytes of the configuration descriptor. Again, both of these requests are made without using URBs so they would normally be invisible . With SourceUSB 2.0 or newer, these steps can be traced in the log of miniport interface function calls.