TMInternal.h revision f679283a4490e750884f4e8d003807ba50466fca
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TM - Internal header file.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * available from http://www.virtualbox.org. This file is free software;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * you can redistribute it and/or modify it under the terms of the GNU
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * General Public License (GPL) as published by the Free Software
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * additional information or have any questions.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** @defgroup grp_tm_int Internal
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @ingroup grp_tm
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @internal
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Frequency of the real clock. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Frequency of the virtual clock. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Timer type.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Device timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Driver timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Internal timer . */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** External timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Timer state
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is stopped. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is active. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is expired, is being delivered. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is stopped but still in the active list.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is stopped but needs unlinking from the ScheduleTimers list.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is being modified and will soon be pending scheduling.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is pending scheduling.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is being modified and will soon be pending rescheduling.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list and the active list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is modified and is now pending rescheduling.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list and the active list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is destroyed but needs to be replaced from the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * active to the free list.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list and the active list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is destroyed but needs moving to the free list.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Currently in the ScheduleTimers list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer is free. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Internal representation of a timer.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * For correct serialization (without the use of semaphores and
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * other blocking/slow constructs) certain rules applies to updating
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * this structure:
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * - For thread other than EMT only u64Expire, enmState and pScheduleNext*
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * are changeable. Everything else is out of bounds.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * - Updating of u64Expire timer can only happen in the TMTIMERSTATE_STOPPED
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * and TMTIMERSTATE_PENDING_RESCHEDULING_SET_EXPIRE states.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * - Timers in the TMTIMERSTATE_EXPIRED state are only accessible from EMT.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * - Actual destruction of a timer can only be done at scheduling time.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsynctypedef struct TMTIMER
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Expire time. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Clock to apply to u64Expire. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer callback type. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Type specific data. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTIMERTYPE_DEV. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Callback. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Device instance. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTIMERTYPE_DRV. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Callback. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Device instance. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTIMERTYPE_INTERNAL. */
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync /** Callback. */
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync /** User argument. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTIMERTYPE_EXTERNAL. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Callback. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** User data. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer state. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer relative offset to the next timer in the schedule list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer relative offset to the next timer in the chain. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer relative offset to the previous timer in the chain. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the next timer in the list of created or free timers. (TM::pTimers or TM::pFree) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the previous timer in the list of all created timers. (TM::pTimers) */
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync /** Pointer to the timer description. */
25747178cb66800d8386c20b8ffd87f78f24f4e5vboxsync /** Pointer to the VM the timer belongs to - R3 Ptr. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the VM the timer belongs to - R0 Ptr. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the VM the timer belongs to - RC Ptr. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync RTRCPTR padding0; /**< pad structure to multiple of 8 bytes. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Updates a timer state in the correct atomic manner.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync do { Log(("%s: %p: %d -> %d\n", __FUNCTION__, (pTimer), (pTimer)->enmState, state)); \
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync } while (0)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Tries to updates a timer state in the correct atomic manner.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync ASMAtomicCmpXchgSize(&(pTimer)->enmState, StateNew, StateOld, fRc)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync do { ASMAtomicCmpXchgSize(&(pTimer)->enmState, StateNew, StateOld, fRc); \
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync Log(("%s: %p: %d -> %d %RTbool\n", __FUNCTION__, (pTimer), StateOld, StateNew, fRc)); \
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync } while (0)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Get the previous timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_GET_PREV(pTimer) ((PTMTIMER)((pTimer)->offPrev ? (intptr_t)(pTimer) + (pTimer)->offPrev : 0))
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Get the next timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_GET_NEXT(pTimer) ((PTMTIMER)((pTimer)->offNext ? (intptr_t)(pTimer) + (pTimer)->offNext : 0))
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Set the previous timer link. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_SET_PREV(pTimer, pPrev) ((pTimer)->offPrev = (pPrev) ? (intptr_t)(pPrev) - (intptr_t)(pTimer) : 0)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Set the next timer link. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_SET_NEXT(pTimer, pNext) ((pTimer)->offNext = (pNext) ? (intptr_t)(pNext) - (intptr_t)(pTimer) : 0)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * A timer queue.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This is allocated on the hyper heap.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsynctypedef struct TMTIMERQUEUE
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The cached expire time for this queue.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Updated by EMT when scheduling the queue or modifying the head timer.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Assigned UINT64_MAX when there is no head timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Doubly linked list of active timers.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * When no scheduling is pending, this list is will be ordered by expire time (ascending).
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Access is serialized by only letting the emulation thread (EMT) do changes.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * The offset is relative to the queue structure.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** List of timers pending scheduling of some kind.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Timer stats allowed in the list are TMTIMERSTATE_PENDING_STOPPING,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TMTIMERSTATE_PENDING_DESTRUCTION, TMTIMERSTATE_PENDING_STOPPING_DESTRUCTION,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TMTIMERSTATE_PENDING_RESCHEDULING and TMTIMERSTATE_PENDING_SCHEDULE.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * The offset is relative to the queue structure.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The clock for this queue. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pad the structure up to 32 bytes. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Pointer to a timer queue. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Get the head of the active timer list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_GET_HEAD(pQueue) ((PTMTIMER)((pQueue)->offActive ? (intptr_t)(pQueue) + (pQueue)->offActive : 0))
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Set the head of the active timer list. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TMTIMER_SET_HEAD(pQueue, pHead) ((pQueue)->offActive = pHead ? (intptr_t)pHead - (intptr_t)(pQueue) : 0)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Converts a TM pointer into a VM pointer.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @returns Pointer to the VM structure the TM is part of.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @param pTM Pointer to TM instance data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync#define TM2VM(pTM) ( (PVM)((char*)pTM - pTM->offVM) )
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * TM VM Instance data.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Changes to this must checked against the padding of the cfgm union in VM!
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsynctypedef struct TM
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Offset to the VM structure.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * See TM2VM(). */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Flag indicating that the host TSC is suitable for use in AMD-V and VT-x mode.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Config variable: MaybeUseOffsettedHostTSC (boolean) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Set if we fully virtualize the TSC, i.e. intercept all rdtsc instructions.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Config variable: TSCVirtualized (bool) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Set if we use the real TSC as time source or if we use the virtual clock.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * If fTSCVirtualized is set we maintain a offset to the TSC and pausing/resuming the
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * ticking. fTSCVirtualized = false implies fTSCUseRealTSC = true.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Config variable: TSCUseRealTSC (bool) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The offset between the host TSC and the Guest TSC.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Only valid if fTicking is set and and fTSCUseRealTSC is clear. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The guest TSC when fTicking is cleared. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The number of CPU clock ticks per second (TMCLOCK_TSC).
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Config variable: TSCTicksPerSecond (64-bit unsigned int)
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * The config variable implies fTSCVirtualized = true and fTSCUseRealTSC = false. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Virtual time ticking enabled indicator (bool). (TMCLOCK_VIRTUAL) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Virtual time is not running at 100%. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Virtual timer synchronous time ticking enabled indicator (bool). (TMCLOCK_VIRTUAL_SYNC) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Virtual timer synchronous time catch-up active. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** WarpDrive percentage.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * 100% is normal (fVirtualSyncNormal == true). When other than 100% we apply
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * this percentage to the raw time source for the period it's been valid in,
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * i.e. since u64VirtualWarpDriveStart. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The offset of the virtual clock relative to it's timesource.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Only valid if fVirtualTicking is set. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The guest virtual time when fVirtualTicking is cleared. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** When the Warp drive was started or last adjusted.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Only valid when fVirtualWarpDrive is set. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The previously returned nano TS.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This handles TSC drift on SMP systems and expired interval.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This is a valid range u64NanoTS to u64NanoTS + 1000000000 (ie. 1sec). */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The ring-3 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync R3PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR3;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync R0PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR0;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync RCPTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawGC;
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Alignment. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The guest virtual timer synchronous time when fVirtualSyncTicking is cleared. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The offset of the timer synchronous virtual clock (TMCLOCK_VIRTUAL_SYNC) relative
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * to the virtual clock (TMCLOCK_VIRTUAL).
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * (This is accessed by the timer thread and must be updated atomically.) */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The offset into offVirtualSync that's been irrevocably given up by failed catch-up attempts.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Thus the current lag is offVirtualSync - offVirtualSyncGivenUp. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The TMCLOCK_VIRTUAL at the previous TMVirtualGetSync call when catch-up is active. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The current catch-up percentage. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** How much slack when processing timers. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** When to stop catch-up. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** When to give up catch-up. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** @def TM_MAX_CATCHUP_PERIODS
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * The number of catchup rates. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The agressivness of the catch-up relative to how far we've lagged behind.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * The idea is to have increasing catch-up percentage as the lag increases. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync uint64_t u64Start; /**< When this period starts. (u64VirtualSyncOffset). */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync uint32_t u32Percentage; /**< The catch-up percent to apply. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync } aVirtualSyncCatchUpPeriods[TM_MAX_CATCHUP_PERIODS];
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The UTC offset in ns.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This is *NOT* for converting UTC to local time. It is for converting real
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * world UTC time to VM UTC time. This feature is indented for doing date
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * testing of software and similar.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * @todo Implement warpdrive on UTC. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer queues for the different clock types - R3 Ptr */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer queues for the different clock types - R0 Ptr */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Timer queues for the different clock types - GC Ptr */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to our GC mapping of the GIP. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to our R3 mapping of the GIP. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to a singly linked list of free timers.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This chain is using the TMTIMER::pBigNext members.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Only accessible from the emulation thread. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Pointer to a doubly linked list of created timers.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This chain is using the TMTIMER::pBigNext and TMTIMER::pBigPrev members.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * Only accessible from the emulation thread. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The schedulation timer timer handle (runtime timer).
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * This timer will do freqent check on pending queue schedulations and
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync * raise VM_FF_TIMER to pull EMTs attention to them.
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Interval in milliseconds of the pTimer timer. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Alignment padding to ensure that the statistics are 64-bit aligned when using GCC. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMR3TimerQueuesDo
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** tmSchedule
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** Read the time
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTimerPoll
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTimerSet
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** TMTimerStop
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** VirtualSync - Running and Catching Up
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync STAMCOUNTER aStatVirtualSyncCatchupInitial[TM_MAX_CATCHUP_PERIODS];
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync STAMCOUNTER aStatVirtualSyncCatchupAdjust[TM_MAX_CATCHUP_PERIODS];
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync /** The timer callback. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsync/** Pointer to TM VM instance data. */
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncvoid tmTimerQueueSchedule(PVM pVM, PTMTIMERQUEUE pQueue);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncvoid tmTimerQueuesSanityChecks(PVM pVM, const char *pszWhere);
24ab761b2beb5af0393c6f2585b6351d8b3085f0vboxsyncDECLEXPORT(void) tmVirtualNanoTSBad(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS);