Changeset 93979 in vbox for trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
- Timestamp:
- Feb 28, 2022 1:16:30 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
r93974 r93979 343 343 static int vusbHubAttach(PVUSBROOTHUB pThis, PVUSBDEV pDev) 344 344 { 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)); 348 346 349 347 /* … … 357 355 } 358 356 ASMBitClear(&pThis->Bitmap, iPort); 359 p Hub->cDevices++;357 pThis->cDevices++; 360 358 pDev->i16Port = iPort; 361 359 362 360 /* Call the device attach helper, so it can initialize its state. */ 363 int rc = vusbDevAttach(pDev, p Hub);361 int rc = vusbDevAttach(pDev, pThis); 364 362 if (RT_SUCCESS(rc)) 365 363 { … … 378 376 { 379 377 LogRel(("VUSB: Attached '%s' to port %d on %s (%sSpeed)\n", pDev->pUsbIns->pszName, 380 iPort, p Hub->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed)));378 iPort, pThis->pszName, vusbGetSpeedString(pDev->pUsbIns->enmSpeed))); 381 379 return VINF_SUCCESS; 382 380 } … … 392 390 393 391 ASMBitSet(&pThis->Bitmap, iPort); 394 p Hub->cDevices--;392 pThis->cDevices--; 395 393 pDev->i16Port = -1; 396 394 LogRel(("VUSB: Failed to attach '%s' to port %d, rc=%Rrc\n", pDev->pUsbIns->pszName, iPort, rc)); … … 409 407 static int vusbHubDetach(PVUSBROOTHUB pThis, PVUSBDEV pDev) 410 408 { 411 PVUSBHUB pHub = &pThis->Hub;412 413 409 Assert(pDev->i16Port != -1); 414 410 … … 423 419 pThis->pIRhPort->pfnDetach(pThis->pIRhPort, uPort); 424 420 ASMBitSet(&pThis->Bitmap, uPort); 425 p Hub->cDevices--;421 pThis->cDevices--; 426 422 427 423 /* Check that it's attached and remove it. */ … … 480 476 RT_NOREF(iPort); 481 477 PVUSBROOTHUB pThis = PDMINS_2_DATA(pDrvIns, PVUSBROOTHUB); 482 PVUSBHUB pHub = &pThis->Hub;483 478 PVUSBDEV pDev = (PVUSBDEV)pUsbIns->pvVUsbDev2; 484 479 Assert(pDev); 485 480 486 LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, p Hub->pszName));481 LogRel(("VUSB: Detached '%s' from port %u on %s\n", pDev->pUsbIns->pszName, pDev->i16Port, pThis->pszName)); 487 482 488 483 /* … … 544 539 } 545 540 else 546 vusbUrbPoolFree(&pRh-> Hub.Dev.UrbPool, pUrb);541 vusbUrbPoolFree(&pRh->Dev.UrbPool, pUrb); 547 542 } 548 543 … … 555 550 { 556 551 RT_NOREF(pszTag); 557 PVUSBURBPOOL pUrbPool = &pRh-> Hub.Dev.UrbPool;552 PVUSBURBPOOL pUrbPool = &pRh->Dev.UrbPool; 558 553 559 554 if (RT_UNLIKELY(cbData > (32 * _1M))) … … 822 817 LogFlow(("vusR3bRhPowerOn: pRh=%p\n", pRh)); 823 818 824 Assert( pRh-> Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED825 && 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; 829 824 830 825 return VINF_SUCCESS; … … 838 833 LogFlow(("vusbR3RhDevPowerOff: pThis=%p\n", pThis)); 839 834 840 Assert( pThis-> Hub.Dev.enmState != VUSB_DEVICE_STATE_DETACHED841 && 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); 842 837 843 838 /* … … 848 843 VUSBIRhReapAsyncUrbs(&pThis->IRhConnector, uPort, 0); 849 844 850 pThis-> Hub.Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;845 pThis->Dev.enmState = VUSB_DEVICE_STATE_ATTACHED; 851 846 return VINF_SUCCESS; 852 847 } … … 949 944 else 950 945 { 951 vusbDevRetain(&pRh-> Hub.Dev);952 pUrb->pVUsb->pDev = &pRh-> Hub.Dev;946 vusbDevRetain(&pRh->Dev); 947 pUrb->pVUsb->pDev = &pRh->Dev; 953 948 Log(("vusb: pRh=%p: SUBMIT: Address %i not found!!!\n", pRh, pUrb->DstAddress)); 954 949 … … 1101 1096 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort); 1102 1097 1103 if ( &pRh->Hub != pDev->pHub)1098 if (pDev->pHub != pRh) 1104 1099 AssertFailedReturn(VERR_INVALID_PARAMETER); 1105 1100 … … 1494 1489 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 1495 1490 PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIROOTHUBCONNECTOR, &pRh->IRhConnector); 1496 PDMIBASE_RETURN_INTERFACE(pszIID, VUSBIDEVICE, &pRh->Hub.Dev.IDevice);1497 1491 return NULL; 1498 1492 } … … 1515 1509 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 1516 1510 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; 1522 1516 } 1523 1517 if (pRh->hSniffer != VUSBSNIFFER_NIL) … … 1579 1573 pDrvIns->IBase.pfnQueryInterface = vusbRhQueryInterface; 1580 1574 /* 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; 1585 1577 //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); 1589 1581 /* misc */ 1590 1582 pThis->pDrvIns = pDrvIns; … … 1627 1619 * ASSUME that the number of ports reported now at creation time is the max number. 1628 1620 */ 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)); 1631 1623 1632 1624 /* … … 1637 1629 Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions)); 1638 1630 1639 rc = vusbUrbPoolInit(&pThis-> Hub.Dev.UrbPool);1631 rc = vusbUrbPoolInit(&pThis->Dev.UrbPool); 1640 1632 if (RT_FAILURE(rc)) 1641 1633 return rc; … … 1657 1649 */ 1658 1650 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); 1660 1652 if (RT_FAILURE(rc)) 1661 1653 return rc; … … 1800 1792 "/VUSB/%d/FramesProcessedClbk", pDrvIns->iInstance); 1801 1793 #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.", 1803 1795 "/VUSB/%d/cUrbsInPool", pDrvIns->iInstance); 1804 1796
Note:
See TracChangeset
for help on using the changeset viewer.