~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/VMM/VMMR3/TM.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-07-04 13:02:31 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110704130231-l843es6wqhx614n7
Tags: 4.0.10-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Add the Modaliases control field manually for maximum backportability.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1342
1342
}
1343
1343
 
1344
1344
 
 
1345
 
 
1346
 
 
1347
/**
 
1348
 * Creates a USB device timer.
 
1349
 *
 
1350
 * @returns VBox status.
 
1351
 * @param   pVM             The VM to create the timer in.
 
1352
 * @param   pUsbIns         The USB device instance.
 
1353
 * @param   enmClock        The clock to use on this timer.
 
1354
 * @param   pfnCallback     Callback function.
 
1355
 * @param   pvUser          The user argument to the callback.
 
1356
 * @param   fFlags          Timer creation flags, see grp_tm_timer_flags.
 
1357
 * @param   pszDesc         Pointer to description string which must stay around
 
1358
 *                          until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
 
1359
 * @param   ppTimer         Where to store the timer on success.
 
1360
 */
 
1361
VMM_INT_DECL(int) TMR3TimerCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, TMCLOCK enmClock,
 
1362
                                     PFNTMTIMERUSB pfnCallback, void *pvUser,
 
1363
                                     uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer)
 
1364
{
 
1365
    AssertReturn(!(fFlags & ~(TMTIMER_FLAGS_NO_CRIT_SECT)), VERR_INVALID_PARAMETER);
 
1366
 
 
1367
    /*
 
1368
     * Allocate and init stuff.
 
1369
     */
 
1370
    int rc = tmr3TimerCreate(pVM, enmClock, pszDesc, ppTimer);
 
1371
    if (RT_SUCCESS(rc))
 
1372
    {
 
1373
        (*ppTimer)->enmType         = TMTIMERTYPE_USB;
 
1374
        (*ppTimer)->u.Usb.pfnTimer  = pfnCallback;
 
1375
        (*ppTimer)->u.Usb.pUsbIns   = pUsbIns;
 
1376
        (*ppTimer)->pvUser          = pvUser;
 
1377
        //if (!(fFlags & TMTIMER_FLAGS_NO_CRIT_SECT))
 
1378
        //{
 
1379
        //    if (pDevIns->pCritSectR3)
 
1380
        //        (*ppTimer)->pCritSect = pUsbIns->pCritSectR3;
 
1381
        //    else
 
1382
        //        (*ppTimer)->pCritSect = IOMR3GetCritSect(pVM);
 
1383
        //}
 
1384
        Log(("TM: Created USB device timer %p clock %d callback %p '%s'\n", (*ppTimer), enmClock, pfnCallback, pszDesc));
 
1385
    }
 
1386
 
 
1387
    return rc;
 
1388
}
 
1389
 
 
1390
 
1345
1391
/**
1346
1392
 * Creates a driver timer.
1347
1393
 *
1639
1685
 
1640
1686
 
1641
1687
/**
 
1688
 * Destroy all timers owned by a USB device.
 
1689
 *
 
1690
 * @returns VBox status.
 
1691
 * @param   pVM             VM handle.
 
1692
 * @param   pUsbIns         USB device which timers should be destroyed.
 
1693
 */
 
1694
VMM_INT_DECL(int) TMR3TimerDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns)
 
1695
{
 
1696
    LogFlow(("TMR3TimerDestroyUsb: pUsbIns=%p\n", pUsbIns));
 
1697
    if (!pUsbIns)
 
1698
        return VERR_INVALID_PARAMETER;
 
1699
 
 
1700
    tmTimerLock(pVM);
 
1701
    PTMTIMER    pCur = pVM->tm.s.pCreated;
 
1702
    while (pCur)
 
1703
    {
 
1704
        PTMTIMER pDestroy = pCur;
 
1705
        pCur = pDestroy->pBigNext;
 
1706
        if (    pDestroy->enmType == TMTIMERTYPE_USB
 
1707
            &&  pDestroy->u.Usb.pUsbIns == pUsbIns)
 
1708
        {
 
1709
            int rc = TMR3TimerDestroy(pDestroy);
 
1710
            AssertRC(rc);
 
1711
        }
 
1712
    }
 
1713
    tmTimerUnlock(pVM);
 
1714
 
 
1715
    LogFlow(("TMR3TimerDestroyUsb: returns VINF_SUCCESS\n"));
 
1716
    return VINF_SUCCESS;
 
1717
}
 
1718
 
 
1719
 
 
1720
/**
1642
1721
 * Destroy all timers owned by a driver.
1643
1722
 *
1644
1723
 * @returns VBox status.
1928
2007
            switch (pTimer->enmType)
1929
2008
            {
1930
2009
                case TMTIMERTYPE_DEV:       pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer, pTimer->pvUser); break;
 
2010
                case TMTIMERTYPE_USB:       pTimer->u.Usb.pfnTimer(pTimer->u.Usb.pUsbIns, pTimer, pTimer->pvUser); break;
1931
2011
                case TMTIMERTYPE_DRV:       pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer, pTimer->pvUser); break;
1932
2012
                case TMTIMERTYPE_INTERNAL:  pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->pvUser); break;
1933
2013
                case TMTIMERTYPE_EXTERNAL:  pTimer->u.External.pfnTimer(pTimer->pvUser); break;
2110
2190
            switch (pTimer->enmType)
2111
2191
            {
2112
2192
                case TMTIMERTYPE_DEV:       pTimer->u.Dev.pfnTimer(pTimer->u.Dev.pDevIns, pTimer, pTimer->pvUser); break;
 
2193
                case TMTIMERTYPE_USB:       pTimer->u.Usb.pfnTimer(pTimer->u.Usb.pUsbIns, pTimer, pTimer->pvUser); break;
2113
2194
                case TMTIMERTYPE_DRV:       pTimer->u.Drv.pfnTimer(pTimer->u.Drv.pDrvIns, pTimer, pTimer->pvUser); break;
2114
2195
                case TMTIMERTYPE_INTERNAL:  pTimer->u.Internal.pfnTimer(pVM, pTimer, pTimer->pvUser); break;
2115
2196
                case TMTIMERTYPE_EXTERNAL:  pTimer->u.External.pfnTimer(pTimer->pvUser); break;