tm.h revision c0eb823dba9ba8afc2aa44bc80e46c7212690d72
/** @file
* TM - Time Manager. (VMM)
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_tm_h
#define ___VBox_tm_h
#ifdef IN_RING3
#endif
/** @defgroup grp_tm The Time Manager API
* @{
*/
/** Enable a timer hack which improves the timer response/resolution a bit. */
#define VBOX_HIGH_RES_TIMERS_HACK
/**
* Clock type.
*/
typedef enum TMCLOCK
{
/** Real host time.
* This clock ticks all the time, so use with care. */
TMCLOCK_REAL = 0,
/** Virtual guest time.
* This clock only ticks when the guest is running. It's implemented
* as an offset to monotonic real time (GIP). */
/** Virtual guest synchronized timer time.
* This is a special clock and timer queue for synchronizing virtual timers
* and virtual time sources. This clock is trying to keep up with
* TMCLOCK_VIRTUAL, but will wait for timers to be executed. If it lags
* too far behind TMCLOCK_VIRTUAL, it will try speed up to close the
* distance.
* @remarks Do not use this unless you really *must*. */
/** Virtual CPU timestamp.
* By default this is a function of TMCLOCK_VIRTUAL_SYNC and the virtual
* CPU frequency. */
/** Number of clocks. */
} TMCLOCK;
/** @defgroup grp_tm_timer_flags Timer flags.
* @{ */
/** Use the default critical section for the class of timers. */
#define TMTIMER_FLAGS_DEFAULT_CRIT_SECT 0
/** No critical section needed or a custom one is set using
* TMR3TimerSetCritSect(). */
#define TMTIMER_FLAGS_NO_CRIT_SECT RT_BIT_32(0)
/** @} */
#ifdef IN_RING3
#endif
#ifdef IN_RING3
VMMR3DECL(int) TMR3GetCpuLoadTimes(PVM pVM, VMCPUID idCpu, uint64_t *pcNsTotal, uint64_t *pcNsExecuting,
#endif
/** @name Real Clock Methods
* @{
*/
/** @} */
/** @name Virtual Clock Methods
* @{
*/
/** @} */
/** @name CPU Clock Methods
* @{
*/
VMM_INT_DECL(uint64_t) TMCpuTickGetDeadlineAndTscOffset(PVMCPU pVCpu, bool *pfOffsettedTsc, uint64_t *poffRealTSC);
/** @} */
/** @name Timer Methods
* @{
*/
/**
* Device timer callback function.
*
* @param pDevIns Device instance of the device which registered the timer.
* @param pTimer The timer handle.
* @param pvUser User argument specified upon timer creation.
*/
/** Pointer to a device timer callback function. */
typedef FNTMTIMERDEV *PFNTMTIMERDEV;
/**
* Device timer callback function.
*
* @param pUsbIns The USB device instance the timer is associated
* with.
* @param pTimer The timer handle.
* @param pvUser User argument specified upon timer creation.
*/
/** Pointer to a timer callback for a USB device. */
typedef FNTMTIMERUSB *PFNTMTIMERUSB;
/**
* Driver timer callback function.
*
* @param pDrvIns Device instance of the device which registered the timer.
* @param pTimer The timer handle.
* @param pvUser User argument specified upon timer creation.
*/
/** Pointer to a driver timer callback function. */
typedef FNTMTIMERDRV *PFNTMTIMERDRV;
/**
* Service timer callback function.
*
* @param pSrvIns Service instance of the device which registered the timer.
* @param pTimer The timer handle.
*/
/** Pointer to a service timer callback function. */
typedef FNTMTIMERSRV *PFNTMTIMERSRV;
/**
* Internal timer callback function.
*
* @param pVM The VM.
* @param pTimer The timer handle.
* @param pvUser User argument specified upon timer creation.
*/
/** Pointer to internal timer callback function. */
typedef FNTMTIMERINT *PFNTMTIMERINT;
/**
* External timer callback function.
*
* @param pvUser User argument as specified when the timer was created.
*/
/** Pointer to an external timer callback function. */
typedef FNTMTIMEREXT *PFNTMTIMEREXT;
/** @} */
#ifdef IN_RING3
/** @defgroup grp_tm_r3 The TM Host Context Ring-3 API
* @ingroup grp_tm
* @{
*/
VMM_INT_DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
VMM_INT_DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
VMMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer);
VMMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
/** @} */
#endif /* IN_RING3 */
/** @} */
#endif