VirtualBox

Changeset 93979 in vbox


Ignore:
Timestamp:
Feb 28, 2022 1:16:30 PM (3 years ago)
Author:
vboxsync
Message:

Devices/USB: Get rid of the VUSBHUB structure which was mostly meaningless as roothubs were supported only since forever, bugref:10196

Location:
trunk/src/VBox/Devices/USB
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r93974 r93979  
    343343static int vusbHubAttach(PVUSBROOTHUB pThis, PVUSBDEV pDev)
    344344{
    345     LogFlow(("vusbHubAttach: pThis=%p[%s] pDev=%p[%s]\n", pThis, pThis->Hub.pszName, pDev, pDev->pUsbIns->pszName));
    346 
    347     PVUSBHUB pHub = &pThis->Hub;
     345    LogFlow(("vusbHubAttach: pThis=%p[%s] pDev=%p[%s]\n", pThis, pThis->pszName, pDev, pDev->pUsbIns->pszName));
    348346
    349347    /*
     
    357355    }
    358356    ASMBitClear(&pThis->Bitmap, iPort);
    359     pHub->cDevices++;
     357    pThis->cDevices++;
    360358    pDev->i16Port = iPort;
    361359
    362360    /* Call the device attach helper, so it can initialize its state. */
    363     int rc = vusbDevAttach(pDev, pHub);
     361    int rc = vusbDevAttach(pDev, pThis);
    364362    if (RT_SUCCESS(rc))
    365363    {
     
    378376        {
    379377            LogRel(("VUSB: Attached '%s' to port %d on %s (%sSpeed)\n", pDev->pUsbIns->pszName,
    380                     iPort, pHub->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed)));
     378                    iPort, pThis->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed)));
    381379            return VINF_SUCCESS;
    382380        }
     
    392390
    393391    ASMBitSet(&pThis->Bitmap, iPort);
    394     pHub->cDevices--;
     392    pThis->cDevices--;
    395393    pDev->i16Port = -1;
    396394    LogRel(("VUSB: Failed to attach '%s' to port %d, rc=%Rrc\n", pDev->pUsbIns->pszName, iPort, rc));
     
    409407static int vusbHubDetach(PVUSBROOTHUB pThis, PVUSBDEV pDev)
    410408{
    411     PVUSBHUB pHub = &pThis->Hub;
    412 
    413409    Assert(pDev->i16Port != -1);
    414410
     
    423419    pThis->pIRhPort->pfnDetach(pThis->pIRhPort, uPort);
    424420    ASMBitSet(&pThis->Bitmap, uPort);
    425     pHub->cDevices--;
     421    pThis->cDevices--;
    426422
    427423    /* Check that it's attached and remove it. */
     
    480476    RT_NOREF(iPort);
    481477    PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB);
    482     PVUSBHUB pHub = &pThis->Hub;
    483478    PVUSBDEV pDev = (PVUSBDEV)pUsbIns->pvVUsbDev2;
    484479    Assert(pDev);
    485480
    486     LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pHub->pszName));
     481    LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pThis->pszName));
    487482
    488483    /*
     
    544539    }
    545540    else
    546         vusbUrbPoolFree(&pRh->Hub.Dev.UrbPool, pUrb);
     541        vusbUrbPoolFree(&pRh->Dev.UrbPool, pUrb);
    547542}
    548543
     
    555550{
    556551    RT_NOREF(pszTag);
    557     PVUSBURBPOOL pUrbPool = &pRh->Hub.Dev.UrbPool;
     552    PVUSBURBPOOL pUrbPool = &pRh->Dev.UrbPool;
    558553
    559554    if (RT_UNLIKELY(cbData > (32 * _1M)))
     
    822817    LogFlow(("vusR3bRhPowerOn: pRh=%p\n", pRh));
    823818
    824     Assert(     pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
    825            &&   pRh->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
    826 
    827     if (pRh->Hub.Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)
    828         pRh->Hub.Dev.enmState = VUSB_DEVICE_STATE_POWERED;
     819    Assert(     pRh->Dev.enmState != VUSB_DEVICE_STATE_DETACHED
     820           &&   pRh->Dev.enmState != VUSB_DEVICE_STATE_RESET);
     821
     822    if (pRh->Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)
     823        pRh->Dev.enmState = VUSB_DEVICE_STATE_POWERED;
    829824
    830825    return VINF_SUCCESS;
     
    838833    LogFlow(("vusbR3RhDevPowerOff: pThis=%p\n", pThis));
    839834
    840     Assert(     pThis->Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED
    841            &&   pThis->Hub.Dev.enmState != VUSB_DEVICE_STATE_RESET);
     835    Assert(     pThis->Dev.enmState != VUSB_DEVICE_STATE_DETACHED
     836           &&   pThis->Dev.enmState != VUSB_DEVICE_STATE_RESET);
    842837
    843838    /*
     
    848843        VUSBIRhReapAsyncUrbs(&pThis->IRhConnector, uPort, 0);
    849844
    850     pThis->Hub.Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
     845    pThis->Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;
    851846    return VINF_SUCCESS;
    852847}
     
    949944    else
    950945    {
    951         vusbDevRetain(&pRh->Hub.Dev);
    952         pUrb->pVUsb->pDev = &pRh->Hub.Dev;
     946        vusbDevRetain(&pRh->Dev);
     947        pUrb->pVUsb->pDev = &pRh->Dev;
    953948        Log(("vusb: pRh=%p: SUBMIT: Address %i not found!!!\n", pRh, pUrb->DstAddress));
    954949
     
    11011096    PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort);
    11021097
    1103     if (&pRh->Hub != pDev->pHub)
     1098    if (pDev->pHub != pRh)
    11041099        AssertFailedReturn(VERR_INVALID_PARAMETER);
    11051100
     
    14941489    PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
    14951490    PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIROOTHUBCONNECTOR, &pRh->IRhConnector);
    1496     PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIDEVICE, &pRh->Hub.Dev.IDevice);
    14971491    return NULL;
    14981492}
     
    15151509    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    15161510
    1517     vusbUrbPoolDestroy(&pRh->Hub.Dev.UrbPool);
    1518     if (pRh->Hub.pszName)
    1519     {
    1520         RTStrFree(pRh->Hub.pszName);
    1521         pRh->Hub.pszName = NULL;
     1511    vusbUrbPoolDestroy(&pRh->Dev.UrbPool);
     1512    if (pRh->pszName)
     1513    {
     1514        RTStrFree(pRh->pszName);
     1515        pRh->pszName = NULL;
    15221516    }
    15231517    if (pRh->hSniffer != VUSBSNIFFER_NIL)
     
    15791573    pDrvIns->IBase.pfnQueryInterface    = vusbRhQueryInterface;
    15801574    /* the usb device */
    1581     pThis->Hub.Dev.enmState             = VUSB_DEVICE_STATE_ATTACHED;
    1582     pThis->Hub.Dev.cRefs                = 1;
    1583     /* the hub */
    1584     pThis->Hub.pRootHub                 = pThis;
     1575    pThis->Dev.enmState                 = VUSB_DEVICE_STATE_ATTACHED;
     1576    pThis->Dev.cRefs                    = 1;
    15851577    //pThis->hub.cPorts                - later
    1586     pThis->Hub.cDevices                 = 0;
    1587     pThis->Hub.Dev.pHub                 = &pThis->Hub;
    1588     RTStrAPrintf(&pThis->Hub.pszName, "RootHub#%d", pDrvIns->iInstance);
     1578    pThis->cDevices                     = 0;
     1579    pThis->Dev.pHub                     = pThis;
     1580    RTStrAPrintf(&pThis->pszName, "RootHub#%d", pDrvIns->iInstance);
    15891581    /* misc */
    15901582    pThis->pDrvIns                      = pDrvIns;
     
    16271619     * ASSUME that the number of ports reported now at creation time is the max number.
    16281620     */
    1629     pThis->Hub.cPorts = pThis->pIRhPort->pfnGetAvailablePorts(pThis->pIRhPort, &pThis->Bitmap);
    1630     Log(("vusbRhConstruct: cPorts=%d\n", pThis->Hub.cPorts));
     1621    pThis->cPorts = pThis->pIRhPort->pfnGetAvailablePorts(pThis->pIRhPort, &pThis->Bitmap);
     1622    Log(("vusbRhConstruct: cPorts=%d\n", pThis->cPorts));
    16311623
    16321624    /*
     
    16371629    Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions));
    16381630
    1639     rc = vusbUrbPoolInit(&pThis->Hub.Dev.UrbPool);
     1631    rc = vusbUrbPoolInit(&pThis->Dev.UrbPool);
    16401632    if (RT_FAILURE(rc))
    16411633        return rc;
     
    16571649     */
    16581650    PCPDMUSBHUBHLP pHlpUsb; /* not used currently */
    1659     rc = PDMDrvHlpUSBRegisterHub(pDrvIns, pThis->fHcVersions, pThis->Hub.cPorts, &g_vusbHubReg, &pHlpUsb);
     1651    rc = PDMDrvHlpUSBRegisterHub(pDrvIns, pThis->fHcVersions, pThis->cPorts, &g_vusbHubReg, &pHlpUsb);
    16601652    if (RT_FAILURE(rc))
    16611653        return rc;
     
    18001792                           "/VUSB/%d/FramesProcessedClbk",     pDrvIns->iInstance);
    18011793#endif
    1802     PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->Hub.Dev.UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.",
     1794    PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->Dev.UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.",
    18031795                           "/VUSB/%d/cUrbsInPool",             pDrvIns->iInstance);
    18041796
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r93977 r93979  
    309309    if (pDev->pUsbIns->pReg->pfnUsbSetConfiguration)
    310310    {
    311         RTCritSectEnter(&pDev->pHub->pRootHub->CritSectDevices);
     311        RTCritSectEnter(&pDev->pHub->CritSectDevices);
    312312        int rc = vusbDevIoThreadExecSync(pDev, (PFNRT)pDev->pUsbIns->pReg->pfnUsbSetConfiguration, 5,
    313313                                         pDev->pUsbIns, pNewCfgDesc->Core.bConfigurationValue,
    314314                                         pDev->pCurCfgDesc, pDev->paIfStates, pNewCfgDesc);
    315         RTCritSectLeave(&pDev->pHub->pRootHub->CritSectDevices);
     315        RTCritSectLeave(&pDev->pHub->CritSectDevices);
    316316        if (RT_FAILURE(rc))
    317317        {
     
    459459    if (pDev->pUsbIns->pReg->pfnUsbSetInterface)
    460460    {
    461         RTCritSectEnter(&pDev->pHub->pRootHub->CritSectDevices);
     461        RTCritSectEnter(&pDev->pHub->CritSectDevices);
    462462        int rc = vusbDevIoThreadExecSync(pDev, (PFNRT)pDev->pUsbIns->pReg->pfnUsbSetInterface, 3, pDev->pUsbIns, iIf, iAlt);
    463         RTCritSectLeave(&pDev->pHub->pRootHub->CritSectDevices);
     463        RTCritSectLeave(&pDev->pHub->CritSectDevices);
    464464        if (RT_FAILURE(rc))
    465465        {
     
    533533                &&  pDev->pUsbIns->pReg->pfnUsbClearHaltedEndpoint)
    534534            {
    535                 RTCritSectEnter(&pDev->pHub->pRootHub->CritSectDevices);
     535                RTCritSectEnter(&pDev->pHub->CritSectDevices);
    536536                int rc = vusbDevIoThreadExecSync(pDev, (PFNRT)pDev->pUsbIns->pReg->pfnUsbClearHaltedEndpoint,
    537537                                                 2, pDev->pUsbIns, pSetup->wIndex);
    538                 RTCritSectLeave(&pDev->pHub->pRootHub->CritSectDevices);
     538                RTCritSectLeave(&pDev->pHub->CritSectDevices);
    539539                return RT_SUCCESS(rc);
    540540            }
     
    12461246 * @returns VBox status code.
    12471247 * @param   pDev        The device to attach.
    1248  * @param   pHub        THe hub to attach to.
    1249  */
    1250 int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub)
     1248 * @param   pHub        The roothub to attach to.
     1249 */
     1250int vusbDevAttach(PVUSBDEV pDev, PVUSBROOTHUB pHub)
    12511251{
    12521252    AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r93974 r93979  
    44 *
    55 * This subsystem implements USB devices in a host controller independent
    6  * way.  All the host controller code has to do is use VUSBHUB for its
     6 * way.  All the host controller code has to do is use VUSBROOTHUB for its
    77 * root hub implementation and any emulated USB device may be plugged into
    88 * the virtual bus.
     
    5757/** Pointer to a Virtual USB device (core). */
    5858typedef struct VUSBDEV *PVUSBDEV;
    59 /** Pointer to a VUSB hub device. */
    60 typedef struct VUSBHUB *PVUSBHUB;
    6159/** Pointer to a VUSB root hub. */
    6260typedef struct VUSBROOTHUB *PVUSBROOTHUB;
     
    222220{
    223221    /** The device interface exposed to the HCI. */
    224     VUSBIDEVICE         IDevice;
     222    VUSBIDEVICE                 IDevice;
    225223    /** Pointer to the PDM USB device instance. */
    226     PPDMUSBINS          pUsbIns;
    227     /** Pointer to the hub this device is attached to. */
    228     PVUSBHUB            pHub;
     224    PPDMUSBINS                  pUsbIns;
     225    /** Pointer to the roothub this device is attached to. */
     226    PVUSBROOTHUB                pHub;
    229227    /** The device state. */
    230     VUSBDEVICESTATE volatile enmState;
     228    VUSBDEVICESTATE volatile    enmState;
    231229    /** Reference counter to protect the device structure from going away. */
    232     uint32_t volatile        cRefs;
     230    uint32_t volatile           cRefs;
    233231
    234232    /** The device address. */
     
    296294DECLINLINE(bool) vusbDevIsRh(PVUSBDEV pDev)
    297295{
    298     return (pDev->pHub == (PVUSBHUB)pDev);
     296    return (pDev->pHub == (PVUSBROOTHUB)pDev);
    299297}
    300298
     
    302300void vusbDevMapEndpoint(PVUSBDEV dev, PCVUSBDESCENDPOINTEX ep);
    303301int vusbDevDetach(PVUSBDEV pDev);
    304 int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub);
     302int vusbDevAttach(PVUSBDEV pDev, PVUSBROOTHUB pHub);
    305303DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev);
    306304size_t vusbDevMaxInterfaces(PVUSBDEV dev);
     
    317315 */
    318316
    319 
    320 /** A VUSB Hub Device - Hub and roothub drivers need to use this struct
    321  * @todo eliminate this (PDM  / roothubs only).
    322  */
    323 typedef struct VUSBHUB
    324 {
    325     VUSBDEV             Dev;
    326     PVUSBROOTHUB        pRootHub;
    327     uint16_t            cPorts;
    328     uint16_t            cDevices;
    329     /** Name of the hub. Used for logging. */
    330     char               *pszName;
    331 } VUSBHUB;
    332 AssertCompileSizeAlignment(VUSBHUB, 8);
    333317
    334318/** @} */
     
    371355typedef struct VUSBROOTHUB
    372356{
    373     /** The HUB.
    374      * @todo remove this? */
    375     VUSBHUB                     Hub;
     357    /** VUSB device data for the roothub @todo Remove. */
     358    VUSBDEV                     Dev;
    376359    /** Pointer to the driver instance. */
    377360    PPDMDRVINS                  pDrvIns;
     
    389372    /** Structure after a saved state load to re-attach devices. */
    390373    PVUSBROOTHUBLOAD            pLoad;
     374
     375    /** Number of ports this roothub offers. */
     376    uint16_t                    cPorts;
     377    /** Number of devices attached to this roothub currently. */
     378    uint16_t                    cDevices;
     379    /** Name of the roothub. Used for logging. */
     380    char                        *pszName;
    391381
    392382#if HC_ARCH_BITS == 32
     
    631621    if (!pDev->pHub)
    632622        return NULL;
    633     return pDev->pHub->pRootHub;
     623    return pDev->pHub;
    634624}
    635625
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette