Index: trunk/include/VBox/vusb.h
===================================================================
--- trunk/include/VBox/vusb.h	(revision 93913)
+++ trunk/include/VBox/vusb.h	(revision 93914)
@@ -564,367 +564,4 @@
 
 
-
-/**
- * VBox USB port bitmap.
- *
- * Bit 0 == Port 0, ... , Bit 127 == Port 127.
- */
-typedef struct VUSBPORTBITMAP
-{
-    /** 128 bits */
-    char ach[16];
-} VUSBPORTBITMAP;
-/** Pointer to a VBox USB port bitmap. */
-typedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
-
-#ifndef RDESKTOP
-
-/**
- * The VUSB RootHub port interface provided by the HCI (down).
- * Pair with VUSBIROOTCONNECTOR
- */
-typedef struct VUSBIROOTHUBPORT
-{
-    /**
-     * Get the number of available ports in the hub.
-     *
-     * @returns The number of ports available.
-     * @param   pInterface      Pointer to this structure.
-     * @param   pAvailable      Bitmap indicating the available ports. Set bit == available port.
-     */
-    DECLR3CALLBACKMEMBER(unsigned, pfnGetAvailablePorts,(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable));
-
-    /**
-     * Gets the supported USB versions.
-     *
-     * @returns The mask of supported USB versions.
-     * @param   pInterface      Pointer to this structure.
-     */
-    DECLR3CALLBACKMEMBER(uint32_t, pfnGetUSBVersions,(PVUSBIROOTHUBPORT pInterface));
-
-    /**
-     * A device is being attached to a port in the roothub.
-     *
-     * @param   pInterface      Pointer to this structure.
-     * @param   pDev            Pointer to the device being attached.
-     * @param   uPort           The port number assigned to the device.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnAttach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
-
-    /**
-     * A device is being detached from a port in the roothub.
-     *
-     * @param   pInterface      Pointer to this structure.
-     * @param   pDev            Pointer to the device being detached.
-     * @param   uPort           The port number assigned to the device.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnDetach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
-
-    /**
-     * Reset the root hub.
-     *
-     * @returns VBox status code.
-     * @param   pInterface      Pointer to this structure.
-     * @param   pResetOnLinux   Whether or not to do real reset on linux.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux));
-
-    /**
-     * Transfer completion callback routine.
-     *
-     * VUSB will call this when a transfer have been completed
-     * in a one or another way.
-     *
-     * @param   pInterface      Pointer to this structure.
-     * @param   pUrb            Pointer to the URB in question.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnXferCompletion,(PVUSBIROOTHUBPORT pInterface, PVUSBURB urb));
-
-    /**
-     * Handle transfer errors.
-     *
-     * VUSB calls this when a transfer attempt failed. This function will respond
-     * indicating whether to retry or complete the URB with failure.
-     *
-     * @returns Retry indicator.
-     * @param   pInterface      Pointer to this structure.
-     * @param   pUrb            Pointer to the URB in question.
-     */
-    DECLR3CALLBACKMEMBER(bool, pfnXferError,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
-
-    /**
-     * Processes a new frame if periodic frame processing is enabled.
-     *
-     * @returns Flag whether there was activity which influences the frame rate.
-     * @param   pInterface      Pointer to this structure.
-     * @param   u32FrameNo      The frame number.
-     */
-    DECLR3CALLBACKMEMBER(bool, pfnStartFrame, (PVUSBIROOTHUBPORT pInterface, uint32_t u32FrameNo));
-
-    /**
-     * Informs the callee about a change in the frame rate due to too many idle cycles or
-     * when seeing activity after some idle time.
-     *
-     * @returns nothing.
-     * @param   pInterface      Pointer to this structure.
-     * @param   u32FrameRate    The new frame rate.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnFrameRateChanged, (PVUSBIROOTHUBPORT pInterface, uint32_t u32FrameRate));
-
-    /** Alignment dummy. */
-    RTR3PTR Alignment;
-
-} VUSBIROOTHUBPORT;
-/** VUSBIROOTHUBPORT interface ID. */
-# define VUSBIROOTHUBPORT_IID                   "6571aece-6c33-4714-a8ac-9508a3b8b429"
-
-/** Pointer to a VUSB RootHub connector interface. */
-typedef struct VUSBIROOTHUBCONNECTOR *PVUSBIROOTHUBCONNECTOR;
-/**
- * The VUSB RootHub connector interface provided by the VBox USB RootHub driver
- * (up).
- * Pair with VUSBIROOTHUBPORT.
- */
-typedef struct VUSBIROOTHUBCONNECTOR
-{
-    /**
-     * Sets the URB parameters for the caller.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   cbHci       Size of the data private to the HCI for each URB when allocated.
-     * @param   cbHciTd     Size of one transfer descriptor. The number of transfer descriptors
-     *                      is given VUSBIROOTHUBCONNECTOR::pfnNewUrb for each URB to calculate the
-     *                      final amount of memory required for the TDs.
-     *
-     * @note This must be called before starting to allocate any URB or otherwise there will be no
-     *       data available for the HCI.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetUrbParams, (PVUSBIROOTHUBCONNECTOR pInterface, size_t cbHci, size_t cbHciTd));
-
-    /**
-     * Allocates a new URB for a transfer.
-     *
-     * Either submit using pfnSubmitUrb or free using VUSBUrbFree().
-     *
-     * @returns Pointer to a new URB.
-     * @returns NULL on failure - try again later.
-     *          This will not fail if the device wasn't found. We'll fail it
-     *          at submit time, since that makes the usage of this api simpler.
-     * @param   pInterface  Pointer to this struct.
-     * @param   DstAddress  The destination address of the URB.
-     * @param   pDev        Optional device pointer the URB is for.
-     * @param   enmType     Type of the URB.
-     * @param   enmDir      Data transfer direction.
-     * @param   cbData      The amount of data space required.
-     * @param   cTds        The amount of TD space.
-     * @param   pszTag      Custom URB tag assigned by the caller, only for
-     *                      logged builds and optional.
-     *
-     * @note pDev should be NULL in most cases. The only useful case is for USB3 where
-     *       it is required for the SET_ADDRESS request because USB3 uses unicast traffic.
-     */
-    DECLR3CALLBACKMEMBER(PVUSBURB, pfnNewUrb,(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, PVUSBIDEVICE pDev,
-                                              VUSBXFERTYPE enmType, VUSBDIRECTION enmDir, uint32_t cbData, uint32_t cTds, const char *pszTag));
-
-    /**
-     * Free an URB not submitted yet.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pUrb        Pointer to the URB to free returned by VUSBIROOTHUBCONNECTOR::pfnNewUrb.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnFreeUrb, (PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb));
-
-    /**
-     * Submits a URB for transfer.
-     * The transfer will do asynchronously if possible.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pUrb        Pointer to the URB returned by pfnNewUrb.
-     *                      The URB will be freed in case of failure.
-     * @param   pLed        Pointer to USB Status LED
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSubmitUrb,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed));
-
-    /**
-     * Call to service asynchronous URB completions in a polling fashion.
-     *
-     * Reaped URBs will be finished by calling the completion callback,
-     * thus there is no return code or input or anything from this function
-     * except for potential state changes elsewhere.
-     *
-     * @returns VINF_SUCCESS if no URBs are pending upon return.
-     * @returns VERR_TIMEOUT if one or more URBs are still in flight upon returning.
-     * @returns Other VBox status code.
-     *
-     * @param   pInterface  Pointer to this struct.
-     * @param   pDevice     Pointer to a USB device.
-     * @param   cMillies    Number of milliseconds to poll for completion.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnReapAsyncUrbs,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice, RTMSINTERVAL cMillies));
-
-    /**
-     * Cancels and completes - with CRC failure - all URBs queued on an endpoint.
-     * This is done in response to guest URB cancellation.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pUrb        Pointer to a previously submitted URB.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnCancelUrbsEp,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb));
-
-    /**
-     * Cancels and completes - with CRC failure - all in-flight async URBs.
-     * This is typically done before saving a state.
-     *
-     * @param   pInterface  Pointer to this struct.
-     */
-    DECLR3CALLBACKMEMBER(void, pfnCancelAllUrbs,(PVUSBIROOTHUBCONNECTOR pInterface));
-
-    /**
-     * Cancels and completes - with CRC failure - all URBs queued on an endpoint.
-     * This is done in response to a guest endpoint/pipe abort.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pDevice     Pointer to a USB device.
-     * @param   EndPt       Endpoint number.
-     * @param   enmDir      Endpoint direction.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnAbortEp,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice, int EndPt, VUSBDIRECTION enmDir));
-
-    /**
-     * Attach the device to the root hub.
-     * The device must not be attached to any hub for this call to succeed.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pDevice     Pointer to the device (interface) to attach.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
-
-    /**
-     * Detach the device from the root hub.
-     * The device must already be attached for this call to succeed.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pDevice     Pointer to the device (interface) to detach.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
-
-    /**
-     * Sets periodic frame processing.
-     *
-     * @returns VBox status code.
-     * @param   pInterface  Pointer to this struct.
-     * @param   uFrameRate  The target frame rate in Hertz, 0 disables periodic frame processing.
-     *                      The real frame rate might be lower if there is no activity for a certain period or
-     *                      higher if there is a need for catching up with where the guest expects the device to be.
-     */
-    DECLR3CALLBACKMEMBER(int, pfnSetPeriodicFrameProcessing, (PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uFrameRate));
-
-    /**
-     * Returns the current frame rate for the periodic frame processing.
-     *
-     * @returns Frame rate for periodic frame processing.
-     * @retval  0 if disabled.
-     * @param   pInterface  Pointer to this struct.
-     */
-    DECLR3CALLBACKMEMBER(uint32_t, pfnGetPeriodicFrameRate, (PVUSBIROOTHUBCONNECTOR pInterface));
-
-    /**
-     * Updates the internally stored isochronous scheduling frame for a given
-     * endpoint and returns the delta between the current and previous frame.
-     *
-     * @returns Delta between currently and previously scheduled frame.
-     * @retval  0 if no previous frame was set.
-     * @param   pInterface  Pointer to this struct.
-     * @param   pDevice     Pointer to a USB device.
-     * @param   EndPt       Endpoint number.
-     * @param   enmDir      Endpoint direction.
-     * @param   uNewFrameID The frame ID of a new transfer.
-     * @param   uBits       The number of significant bits in frame ID.
-     */
-    DECLR3CALLBACKMEMBER(uint32_t, pfnUpdateIsocFrameDelta, (PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice,
-                                                             int EndPt, VUSBDIRECTION enmDir, uint16_t uNewFrameID, uint8_t uBits));
-
-    /** Alignment dummy. */
-    RTR3PTR Alignment;
-
-} VUSBIROOTHUBCONNECTOR;
-AssertCompileSizeAlignment(VUSBIROOTHUBCONNECTOR, 8);
-/** VUSBIROOTHUBCONNECTOR interface ID. */
-# define VUSBIROOTHUBCONNECTOR_IID              "662d7822-b9c6-43b5-88b6-5d59f0106e46"
-
-
-# ifdef IN_RING3
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSetUrbParams */
-DECLINLINE(int) VUSBIRhSetUrbParams(PVUSBIROOTHUBCONNECTOR pInterface, size_t cbHci, size_t cbHciTd)
-{
-    return pInterface->pfnSetUrbParams(pInterface, cbHci, cbHciTd);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
-DECLINLINE(PVUSBURB) VUSBIRhNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, PVUSBIDEVICE pDev,
-                                   VUSBXFERTYPE enmType, VUSBDIRECTION enmDir, uint32_t cbData, uint32_t cTds, const char *pszTag)
-{
-    return pInterface->pfnNewUrb(pInterface, DstAddress, pDev, enmType, enmDir, cbData, cTds, pszTag);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnFreeUrb */
-DECLINLINE(int) VUSBIRhFreeUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb)
-{
-    return pInterface->pfnFreeUrb(pInterface, pUrb);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
-DECLINLINE(int) VUSBIRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed)
-{
-    return pInterface->pfnSubmitUrb(pInterface, pUrb, pLed);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
-DECLINLINE(void) VUSBIRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice, RTMSINTERVAL cMillies)
-{
-    pInterface->pfnReapAsyncUrbs(pInterface, pDevice, cMillies);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
-DECLINLINE(void) VUSBIRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
-{
-    pInterface->pfnCancelAllUrbs(pInterface);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
-DECLINLINE(int) VUSBIRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
-{
-    return pInterface->pfnAttachDevice(pInterface, pDevice);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
-DECLINLINE(int) VUSBIRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
-{
-    return pInterface->pfnDetachDevice(pInterface, pDevice);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSetPeriodicFrameProcessing */
-DECLINLINE(int) VUSBIRhSetPeriodicFrameProcessing(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uFrameRate)
-{
-    return pInterface->pfnSetPeriodicFrameProcessing(pInterface, uFrameRate);
-}
-
-/** @copydoc VUSBIROOTHUBCONNECTOR::pfnGetPeriodicFrameRate */
-DECLINLINE(uint32_t) VUSBIRhGetPeriodicFrameRate(PVUSBIROOTHUBCONNECTOR pInterface)
-{
-    return pInterface->pfnGetPeriodicFrameRate(pInterface);
-}
-# endif /* IN_RING3 */
-
-#endif /* ! RDESKTOP */
-
-
 /**
  * VUSB device reset completion callback function.
@@ -932,4 +569,5 @@
  *
  * @param   pDevice Pointer to the virtual USB device core.
+ * @param   uPort   The port of the device which completed the reset.
  * @param   rc      The VBox status code of the reset operation.
  * @param   pvUser  User specific argument.
@@ -937,7 +575,8 @@
  * @thread  The reset thread or EMT.
  */
-typedef DECLCALLBACKTYPE(void, FNVUSBRESETDONE,(PVUSBIDEVICE pDevice, int rc, void *pvUser));
+typedef DECLCALLBACKTYPE(void, FNVUSBRESETDONE,(PVUSBIDEVICE pDevice, uint32_t uPort, int rc, void *pvUser));
 /** Pointer to a device reset completion callback function (FNUSBRESETDONE). */
 typedef FNVUSBRESETDONE *PFNVUSBRESETDONE;
+
 
 /**
@@ -965,4 +604,507 @@
     VUSB_DEVICE_STATE_32BIT_HACK = 0x7fffffff
 } VUSBDEVICESTATE;
+
+
+/** Maximum number of USB devices supported. */
+#define VUSB_DEVICES_MAX            128
+/** An invalid device port. */
+#define VUSB_DEVICE_PORT_INVALID    UINT32_MAX
+
+/**
+ * VBox USB port bitmap.
+ *
+ * Bit 0 == Port 0, ... , Bit 127 == Port 127.
+ */
+typedef struct VUSBPORTBITMAP
+{
+    /** 128 bits */
+    char ach[VUSB_DEVICES_MAX / 8];
+} VUSBPORTBITMAP;
+/** Pointer to a VBox USB port bitmap. */
+typedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
+AssertCompile(sizeof(VUSBPORTBITMAP) * 8 >= VUSB_DEVICES_MAX);
+
+#ifndef RDESKTOP
+
+/**
+ * The VUSB RootHub port interface provided by the HCI (down).
+ * Pair with VUSBIROOTCONNECTOR
+ */
+typedef struct VUSBIROOTHUBPORT
+{
+    /**
+     * Get the number of available ports in the hub.
+     *
+     * @returns The number of ports available.
+     * @param   pInterface      Pointer to this structure.
+     * @param   pAvailable      Bitmap indicating the available ports. Set bit == available port.
+     */
+    DECLR3CALLBACKMEMBER(unsigned, pfnGetAvailablePorts,(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable));
+
+    /**
+     * Gets the supported USB versions.
+     *
+     * @returns The mask of supported USB versions.
+     * @param   pInterface      Pointer to this structure.
+     */
+    DECLR3CALLBACKMEMBER(uint32_t, pfnGetUSBVersions,(PVUSBIROOTHUBPORT pInterface));
+
+    /**
+     * A device is being attached to a port in the roothub.
+     *
+     * @param   pInterface      Pointer to this structure.
+     * @param   uPort           The port number assigned to the device.
+     * @param   enmSpeed        The speed of the device being attached.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnAttach,(PVUSBIROOTHUBPORT pInterface, uint32_t uPort, VUSBSPEED enmSpeed));
+
+    /**
+     * A device is being detached from a port in the roothub.
+     *
+     * @param   pInterface      Pointer to this structure.
+     * @param   uPort           The port number assigned to the device.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnDetach,(PVUSBIROOTHUBPORT pInterface, uint32_t uPort));
+
+    /**
+     * Reset the root hub.
+     *
+     * @returns VBox status code.
+     * @param   pInterface      Pointer to this structure.
+     * @param   fResetOnLinux   Whether or not to do real reset on linux.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux));
+
+    /**
+     * Transfer completion callback routine.
+     *
+     * VUSB will call this when a transfer have been completed
+     * in a one or another way.
+     *
+     * @param   pInterface      Pointer to this structure.
+     * @param   pUrb            Pointer to the URB in question.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnXferCompletion,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
+
+    /**
+     * Handle transfer errors.
+     *
+     * VUSB calls this when a transfer attempt failed. This function will respond
+     * indicating whether to retry or complete the URB with failure.
+     *
+     * @returns Retry indicator.
+     * @param   pInterface      Pointer to this structure.
+     * @param   pUrb            Pointer to the URB in question.
+     */
+    DECLR3CALLBACKMEMBER(bool, pfnXferError,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
+
+    /**
+     * Processes a new frame if periodic frame processing is enabled.
+     *
+     * @returns Flag whether there was activity which influences the frame rate.
+     * @param   pInterface      Pointer to this structure.
+     * @param   u32FrameNo      The frame number.
+     */
+    DECLR3CALLBACKMEMBER(bool, pfnStartFrame, (PVUSBIROOTHUBPORT pInterface, uint32_t u32FrameNo));
+
+    /**
+     * Informs the callee about a change in the frame rate due to too many idle cycles or
+     * when seeing activity after some idle time.
+     *
+     * @returns nothing.
+     * @param   pInterface      Pointer to this structure.
+     * @param   u32FrameRate    The new frame rate.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnFrameRateChanged, (PVUSBIROOTHUBPORT pInterface, uint32_t u32FrameRate));
+
+    /** Alignment dummy. */
+    RTR3PTR Alignment;
+
+} VUSBIROOTHUBPORT;
+/** VUSBIROOTHUBPORT interface ID. */
+# define VUSBIROOTHUBPORT_IID                   "2ece01c2-4dbf-4bd5-96ca-09fc14164cd4"
+
+/** Pointer to a VUSB RootHub connector interface. */
+typedef struct VUSBIROOTHUBCONNECTOR *PVUSBIROOTHUBCONNECTOR;
+/**
+ * The VUSB RootHub connector interface provided by the VBox USB RootHub driver
+ * (up).
+ * Pair with VUSBIROOTHUBPORT.
+ */
+typedef struct VUSBIROOTHUBCONNECTOR
+{
+    /**
+     * Sets the URB parameters for the caller.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   cbHci       Size of the data private to the HCI for each URB when allocated.
+     * @param   cbHciTd     Size of one transfer descriptor. The number of transfer descriptors
+     *                      is given VUSBIROOTHUBCONNECTOR::pfnNewUrb for each URB to calculate the
+     *                      final amount of memory required for the TDs.
+     *
+     * @note This must be called before starting to allocate any URB or otherwise there will be no
+     *       data available for the HCI.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetUrbParams, (PVUSBIROOTHUBCONNECTOR pInterface, size_t cbHci, size_t cbHciTd));
+
+    /**
+     * Resets the roothub.
+     *
+     * @returns VBox status code.
+     * @param   pInterface      Pointer to this struct.
+     * @param   fResetOnLinux   Whether or not to do real reset on linux.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnReset, (PVUSBIROOTHUBCONNECTOR pInterface, bool fResetOnLinux));
+
+    /**
+     * Powers on the roothub.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnPowerOn, (PVUSBIROOTHUBCONNECTOR pInterface));
+
+    /**
+     * Power off the roothub.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnPowerOff, (PVUSBIROOTHUBCONNECTOR pInterface));
+
+    /**
+     * Allocates a new URB for a transfer.
+     *
+     * Either submit using pfnSubmitUrb or free using VUSBUrbFree().
+     *
+     * @returns Pointer to a new URB.
+     * @returns NULL on failure - try again later.
+     *          This will not fail if the device wasn't found. We'll fail it
+     *          at submit time, since that makes the usage of this api simpler.
+     * @param   pInterface  Pointer to this struct.
+     * @param   DstAddress  The destination address of the URB.
+     * @param   uPort       Optional port of the device the URB is for, use VUSB_DEVICE_PORT_INVALID to indicate to use the destination address.
+     * @param   enmType     Type of the URB.
+     * @param   enmDir      Data transfer direction.
+     * @param   cbData      The amount of data space required.
+     * @param   cTds        The amount of TD space.
+     * @param   pszTag      Custom URB tag assigned by the caller, only for
+     *                      logged builds and optional.
+     *
+     * @note pDev should be NULL in most cases. The only useful case is for USB3 where
+     *       it is required for the SET_ADDRESS request because USB3 uses unicast traffic.
+     */
+    DECLR3CALLBACKMEMBER(PVUSBURB, pfnNewUrb,(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t uPort,
+                                              VUSBXFERTYPE enmType, VUSBDIRECTION enmDir, uint32_t cbData, uint32_t cTds, const char *pszTag));
+
+    /**
+     * Free an URB not submitted yet.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   pUrb        Pointer to the URB to free returned by VUSBIROOTHUBCONNECTOR::pfnNewUrb.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnFreeUrb, (PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb));
+
+    /**
+     * Submits a URB for transfer.
+     * The transfer will do asynchronously if possible.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   pUrb        Pointer to the URB returned by pfnNewUrb.
+     *                      The URB will be freed in case of failure.
+     * @param   pLed        Pointer to USB Status LED
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSubmitUrb,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed));
+
+    /**
+     * Call to service asynchronous URB completions in a polling fashion.
+     *
+     * Reaped URBs will be finished by calling the completion callback,
+     * thus there is no return code or input or anything from this function
+     * except for potential state changes elsewhere.
+     *
+     * @returns VINF_SUCCESS if no URBs are pending upon return.
+     * @returns VERR_TIMEOUT if one or more URBs are still in flight upon returning.
+     * @returns Other VBox status code.
+     *
+     * @param   pInterface  Pointer to this struct.
+     * @param   uPort       Port of the device to reap URBs on.
+     * @param   cMillies    Number of milliseconds to poll for completion.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnReapAsyncUrbs,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort, RTMSINTERVAL cMillies));
+
+    /**
+     * Cancels and completes - with CRC failure - all URBs queued on an endpoint.
+     * This is done in response to guest URB cancellation.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   pUrb        Pointer to a previously submitted URB.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnCancelUrbsEp,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb));
+
+    /**
+     * Cancels and completes - with CRC failure - all in-flight async URBs.
+     * This is typically done before saving a state.
+     *
+     * @param   pInterface  Pointer to this struct.
+     */
+    DECLR3CALLBACKMEMBER(void, pfnCancelAllUrbs,(PVUSBIROOTHUBCONNECTOR pInterface));
+
+    /**
+     * Cancels and completes - with CRC failure - all URBs queued on an endpoint.
+     * This is done in response to a guest endpoint/pipe abort.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   uPort       Port of the device.
+     * @param   EndPt       Endpoint number.
+     * @param   enmDir      Endpoint direction.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnAbortEp,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort, int EndPt, VUSBDIRECTION enmDir));
+
+    /**
+     * Attach the device to the root hub.
+     * The device must not be attached to any hub for this call to succeed.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   uPort       Port of the device to attach.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Detach the device from the root hub.
+     * The device must already be attached for this call to succeed.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   uPort       Port of the device to detach.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Sets periodic frame processing.
+     *
+     * @returns VBox status code.
+     * @param   pInterface  Pointer to this struct.
+     * @param   uFrameRate  The target frame rate in Hertz, 0 disables periodic frame processing.
+     *                      The real frame rate might be lower if there is no activity for a certain period or
+     *                      higher if there is a need for catching up with where the guest expects the device to be.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnSetPeriodicFrameProcessing, (PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uFrameRate));
+
+    /**
+     * Returns the current frame rate for the periodic frame processing.
+     *
+     * @returns Frame rate for periodic frame processing.
+     * @retval  0 if disabled.
+     * @param   pInterface  Pointer to this struct.
+     */
+    DECLR3CALLBACKMEMBER(uint32_t, pfnGetPeriodicFrameRate, (PVUSBIROOTHUBCONNECTOR pInterface));
+
+    /**
+     * Updates the internally stored isochronous scheduling frame for a given
+     * endpoint and returns the delta between the current and previous frame.
+     *
+     * @returns Delta between currently and previously scheduled frame.
+     * @retval  0 if no previous frame was set.
+     * @param   pInterface  Pointer to this struct.
+     * @param   uPort       Port of the device.
+     * @param   EndPt       Endpoint number.
+     * @param   enmDir      Endpoint direction.
+     * @param   uNewFrameID The frame ID of a new transfer.
+     * @param   uBits       The number of significant bits in frame ID.
+     */
+    DECLR3CALLBACKMEMBER(uint32_t, pfnUpdateIsocFrameDelta, (PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort,
+                                                             int EndPt, VUSBDIRECTION enmDir, uint16_t uNewFrameID, uint8_t uBits));
+
+    /**
+     * Resets the device.
+     *
+     * Since a device reset shall take at least 10ms from the guest point of view,
+     * it must be performed asynchronously. We create a thread which performs this
+     * operation and ensures it will take at least 10ms.
+     *
+     * At times - like init - a synchronous reset is required, this can be done
+     * by passing NULL for pfnDone.
+     *
+     * -- internal stuff, move it --
+     * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
+     * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
+     * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
+     * -- internal stuff, move it --
+     *
+     * @returns VBox status code.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to reset.
+     * @param   fResetOnLinux   Set if we can permit a real reset and a potential logical
+     *                          device reconnect on linux hosts.
+     * @param   pfnDone         Pointer to the completion routine. If NULL a synchronous
+     *                          reset  is performed not respecting the 10ms.
+     * @param   pvUser          User argument to the completion routine.
+     * @param   pVM             The cross context VM structure.  Required if pfnDone
+     *                          is not NULL.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnDevReset,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort, bool fResetOnLinux,
+                                           PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM));
+
+    /**
+     * Powers on the device.
+     *
+     * @returns VBox status code.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to power on.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnDevPowerOn,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Powers off the device.
+     *
+     * @returns VBox status code.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to power off.
+     */
+    DECLR3CALLBACKMEMBER(int, pfnDevPowerOff,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Get the state of the device.
+     *
+     * @returns Device state.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to get the state for.
+     */
+    DECLR3CALLBACKMEMBER(VUSBDEVICESTATE, pfnDevGetState,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Returns whether the device implements the saved state handlers
+     * and doesn't need to get detached.
+     *
+     * @returns true if the device supports saving the state, false otherwise.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to query saved state support for.
+     */
+    DECLR3CALLBACKMEMBER(bool, pfnDevIsSavedStateSupported,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+    /**
+     * Get the speed the device is operating at.
+     *
+     * @returns Device state.
+     * @param   pInterface      Pointer to this struct.
+     * @param   uPort           Port of the device to query the speed for.
+     */
+    DECLR3CALLBACKMEMBER(VUSBSPEED, pfnDevGetSpeed,(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort));
+
+} VUSBIROOTHUBCONNECTOR;
+AssertCompileSizeAlignment(VUSBIROOTHUBCONNECTOR, 8);
+/** VUSBIROOTHUBCONNECTOR interface ID. */
+# define VUSBIROOTHUBCONNECTOR_IID              "662d7822-b9c6-43b5-88b6-5d59f0106e46"
+
+
+# ifdef IN_RING3
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSetUrbParams */
+DECLINLINE(int) VUSBIRhSetUrbParams(PVUSBIROOTHUBCONNECTOR pInterface, size_t cbHci, size_t cbHciTd)
+{
+    return pInterface->pfnSetUrbParams(pInterface, cbHci, cbHciTd);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
+DECLINLINE(PVUSBURB) VUSBIRhNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t uPort,
+                                   VUSBXFERTYPE enmType, VUSBDIRECTION enmDir, uint32_t cbData, uint32_t cTds, const char *pszTag)
+{
+    return pInterface->pfnNewUrb(pInterface, DstAddress, uPort, enmType, enmDir, cbData, cTds, pszTag);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnFreeUrb */
+DECLINLINE(int) VUSBIRhFreeUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb)
+{
+    return pInterface->pfnFreeUrb(pInterface, pUrb);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
+DECLINLINE(int) VUSBIRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed)
+{
+    return pInterface->pfnSubmitUrb(pInterface, pUrb, pLed);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
+DECLINLINE(void) VUSBIRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort, RTMSINTERVAL cMillies)
+{
+    pInterface->pfnReapAsyncUrbs(pInterface, uPort, cMillies);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
+DECLINLINE(void) VUSBIRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
+{
+    pInterface->pfnCancelAllUrbs(pInterface);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
+DECLINLINE(int) VUSBIRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnAttachDevice(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
+DECLINLINE(int) VUSBIRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDetachDevice(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSetPeriodicFrameProcessing */
+DECLINLINE(int) VUSBIRhSetPeriodicFrameProcessing(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uFrameRate)
+{
+    return pInterface->pfnSetPeriodicFrameProcessing(pInterface, uFrameRate);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnGetPeriodicFrameRate */
+DECLINLINE(uint32_t) VUSBIRhGetPeriodicFrameRate(PVUSBIROOTHUBCONNECTOR pInterface)
+{
+    return pInterface->pfnGetPeriodicFrameRate(pInterface);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevReset */
+DECLINLINE(int) VUSBIRhDevReset(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort, bool fResetOnLinux,
+                                PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM)
+{
+    return pInterface->pfnDevReset(pInterface, uPort, fResetOnLinux, pfnDone, pvUser, pVM);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevPowerOn */
+DECLINLINE(int) VUSBIRhDevPowerOn(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDevPowerOn(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevPowerOff */
+DECLINLINE(int) VUSBIRhDevPowerOff(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDevPowerOff(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevGetState */
+DECLINLINE(VUSBDEVICESTATE) VUSBIRhDevGetState(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDevGetState(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevGetState */
+DECLINLINE(bool) VUSBIRhDevIsSavedStateSupported(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDevIsSavedStateSupported(pInterface, uPort);
+}
+
+/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDevGetSpeed */
+DECLINLINE(VUSBSPEED) VUSBIRhDevGetSpeed(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t uPort)
+{
+    return pInterface->pfnDevGetSpeed(pInterface, uPort);
+}
+# endif /* IN_RING3 */
+
+#endif /* ! RDESKTOP */
+
 
 #ifndef RDESKTOP
