VirtualBox

Changeset 2464 in vbox


Ignore:
Timestamp:
May 3, 2007 3:09:01 PM (18 years ago)
Author:
vboxsync
Message:

Added TMR3UCTNow, exported it as a DevHlp and made VMMDev use it as time source. TMR3UCTNow adjust for lag we intend to catchup so the guest time wont run ahead of real-world time.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdm.h

    r2292 r2464  
    49414941    DECLR3CALLBACKMEMBER(int, pfnCritSectInit,(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName));
    49424942
     4943    /**
     4944     * Get the real world UCT time adjusted for VM lag.
     4945     *
     4946     * @returns pTime.
     4947     * @param   pDevIns         Device instance.
     4948     * @param   pTime           Where to store the time.
     4949     */
     4950    DECLR3CALLBACKMEMBER(PRTTIMESPEC, pfnUCTNow,(PPDMDEVINS pDevIns, PRTTIMESPEC pTime));
     4951
     4952    /** Space reserved for future members.
     4953     * @{ */
     4954    DECLR3CALLBACKMEMBER(void, pfnReserved1,(void));
     4955    DECLR3CALLBACKMEMBER(void, pfnReserved2,(void));
     4956    DECLR3CALLBACKMEMBER(void, pfnReserved3,(void));
     4957    DECLR3CALLBACKMEMBER(void, pfnReserved4,(void));
     4958    DECLR3CALLBACKMEMBER(void, pfnReserved5,(void));
     4959    DECLR3CALLBACKMEMBER(void, pfnReserved6,(void));
     4960    DECLR3CALLBACKMEMBER(void, pfnReserved7,(void));
     4961    DECLR3CALLBACKMEMBER(void, pfnReserved8,(void));
     4962    DECLR3CALLBACKMEMBER(void, pfnReserved9,(void));
     4963    DECLR3CALLBACKMEMBER(void, pfnReserved10,(void));
     4964    /** @} */
     4965
    49434966
    49444967    /** API available to trusted devices only.
     
    52635286
    52645287/** Current PDMDEVHLP version number. */
    5265 #define PDM_DEVHLP_VERSION  0xf2010000
     5288#define PDM_DEVHLP_VERSION  0xf2020000
    52665289
    52675290
     
    58085831
    58095832/**
     5833 * @copydoc PDMDEVHLP::pfnUCTNow
     5834 */
     5835DECLINLINE(PRTTIMESPEC) PDMDevHlpUCTNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
     5836{
     5837    return pDevIns->pDevHlp->pfnUCTNow(pDevIns, pTime);
     5838}
     5839
     5840/**
    58105841 * @copydoc PDMDEVHLP::pfnGetVM
    58115842 */
  • trunk/include/VBox/tm.h

    r2248 r2464  
    2525#include <VBox/cdefs.h>
    2626#include <VBox/types.h>
     27#ifdef IN_RING3
     28# include <iprt/time.h>
     29#endif
    2730
    2831__BEGIN_DECLS
     
    723726TMR3DECL(void) TMR3TimerQueuesDo(PVM pVM);
    724727
     728/**
     729 * Get the real world UCT time adjusted for VM lag.
     730 *
     731 * @returns pTime.
     732 * @param   pVM             The VM instance.
     733 * @param   pTime           Where to store the time.
     734 */
     735TMR3DECL(PRTTIMESPEC) TMR3UCTNow(PVM pVM, PRTTIMESPEC pTime);
    725736
    726737/** @} */
  • trunk/src/VBox/Devices/VMMDev/VBoxDev.cpp

    r2053 r2464  
    364364        else
    365365        {
    366             pData->hostTime = RTTimeSpecGetMilli(RTTimeNow(&now));
     366            pData->hostTime = RTTimeSpecGetMilli(PDMDevHlpUCTNow(pDevIns, &now));
    367367            *pu32 = (uint32_t)(pData->hostTime >> 32);
    368368        }
     
    630630                VMMDevReqHostTime *hostTimeReq = (VMMDevReqHostTime*)requestHeader;
    631631                RTTIMESPEC now;
    632                 hostTimeReq->time = RTTimeSpecGetMilli(RTTimeNow(&now));
     632                hostTimeReq->time = RTTimeSpecGetMilli(PDMDevHlpUCTNow(pDevIns, &now));
    633633                requestHeader->rc = VINF_SUCCESS;
    634634            }
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r2452 r2464  
    126126static DECLCALLBACK(void) pdmR3DevHlp_STAMRegisterV(PPDMDEVINS pDevIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit, const char *pszDesc, const char *pszName, va_list args);
    127127static DECLCALLBACK(int) pdmR3DevHlp_CritSectInit(PPDMDEVINS pDevIns, PPDMCRITSECT pCritSect, const char *pszName);
     128static DECLCALLBACK(PRTTIMESPEC) pdmR3DevHlp_UCTNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime);
    128129
    129130static DECLCALLBACK(PVM) pdmR3DevHlp_GetVM(PPDMDEVINS pDevIns);
     
    307308    pdmR3DevHlp_PDMQueueCreate,
    308309    pdmR3DevHlp_CritSectInit,
     310    pdmR3DevHlp_UCTNow,
     311    0,
     312    0,
     313    0,
     314    0,
     315    0,
     316    0,
     317    0,
     318    0,
     319    0,
     320    0,
    309321    pdmR3DevHlp_GetVM,
    310322    pdmR3DevHlp_PCIBusRegister,
     
    380392    pdmR3DevHlp_PDMQueueCreate,
    381393    pdmR3DevHlp_CritSectInit,
     394    pdmR3DevHlp_UCTNow,
     395    0,
     396    0,
     397    0,
     398    0,
     399    0,
     400    0,
     401    0,
     402    0,
     403    0,
     404    0,
    382405    pdmR3DevHlp_Untrusted_GetVM,
    383406    pdmR3DevHlp_Untrusted_PCIBusRegister,
     
    22712294
    22722295
     2296/** @copydoc PDMDEVHLP::pfnUCTNow */
     2297static DECLCALLBACK(PRTTIMESPEC) pdmR3DevHlp_UCTNow(PPDMDEVINS pDevIns, PRTTIMESPEC pTime)
     2298{
     2299    PDMDEV_ASSERT_DEVINS(pDevIns);
     2300    LogFlow(("pdmR3DevHlp_UCTNow: caller='%s'/%d: pTime=%p\n",
     2301             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pTime));
     2302
     2303    pTime = TMR3UCTNow(pDevIns->Internal.s.pVMHC, pTime);
     2304
     2305    LogFlow(("pdmR3DevHlp_UCTNow: caller='%s'/%d: returns %RU64\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, RTTimeSpecGetNano(pTime)));
     2306    return pTime;
     2307}
     2308
     2309
    22732310/** @copydoc PDMDEVHLP::pfnGetVM */
    22742311static DECLCALLBACK(PVM) pdmR3DevHlp_GetVM(PPDMDEVINS pDevIns)
  • trunk/src/VBox/VMM/TM.cpp

    r2283 r2464  
    16151615
    16161616/**
     1617 * Get the real world UCT time adjusted for VM lag.
     1618 *
     1619 * @returns pTime.
     1620 * @param   pVM             The VM instance.
     1621 * @param   pTime           Where to store the time.
     1622 */
     1623TMR3DECL(PRTTIMESPEC) TMR3UCTNow(PVM pVM, PRTTIMESPEC pTime)
     1624{
     1625    RTTimeNow(pTime);
     1626    RTTimeSpecSubNano(pTime, pVM->tm.s.offVirtualSync - pVM->tm.s.offVirtualSyncGivenUp);
     1627    return pTime;
     1628}
     1629
     1630
     1631/**
    16171632 * Display all timers.
    16181633 *
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