VirtualBox

source: vbox/trunk/include/VBox/tm.h@ 8006

Last change on this file since 8006 was 7757, checked in by vboxsync, 16 years ago

TMCLOCK_VIRTUAL_SYNC remark.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.1 KB
Line 
1/** @file
2 * TM - Time Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_tm_h
27#define ___VBox_tm_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31#ifdef IN_RING3
32# include <iprt/time.h>
33#endif
34
35__BEGIN_DECLS
36
37/** @defgroup grp_tm The Time Monitor API
38 * @{
39 */
40
41/** Enable a timer hack which improves the timer response/resolution a bit. */
42#define VBOX_HIGH_RES_TIMERS_HACK
43
44
45/**
46 * Clock type.
47 */
48typedef enum TMCLOCK
49{
50 /** Real host time.
51 * This clock ticks all the time, so use with care. */
52 TMCLOCK_REAL = 0,
53 /** Virtual guest time.
54 * This clock only ticks when the guest is running. It's implemented
55 * as an offset to real time. */
56 TMCLOCK_VIRTUAL,
57 /** Virtual guest synchronized timer time.
58 * This is a special clock and timer queue for synchronizing virtual timers and
59 * virtual time sources. This clock is trying to keep up with TMCLOCK_VIRTUAL,
60 * but will wait for timers to be executed. If it lags too far behind TMCLOCK_VIRTUAL,
61 * it will try speed up to close the distance.
62 * @remarks Do not use this unless you *must*. */
63 TMCLOCK_VIRTUAL_SYNC,
64 /** Virtual CPU timestamp. (Running only when we're executing guest code.) */
65 TMCLOCK_TSC,
66 /** Number of clocks. */
67 TMCLOCK_MAX
68} TMCLOCK;
69
70
71/** @name Real Clock Methods
72 * @{
73 */
74TMDECL(uint64_t) TMRealGet(PVM pVM);
75TMDECL(uint64_t) TMRealGetFreq(PVM pVM);
76/** @} */
77
78
79/** @name Virtual Clock Methods
80 * @{
81 */
82TMDECL(uint64_t) TMVirtualGet(PVM pVM);
83TMDECL(uint64_t) TMVirtualGetEx(PVM pVM, bool fCheckTimers);
84TMDECL(uint64_t) TMVirtualSyncGetLag(PVM pVM);
85TMDECL(uint32_t) TMVirtualSyncGetCatchUpPct(PVM pVM);
86TMDECL(uint64_t) TMVirtualGetFreq(PVM pVM);
87TMDECL(uint64_t) TMVirtualSyncGetEx(PVM pVM, bool fCheckTimers);
88TMDECL(uint64_t) TMVirtualSyncGet(PVM pVM);
89TMDECL(int) TMVirtualResume(PVM pVM);
90TMDECL(int) TMVirtualPause(PVM pVM);
91TMDECL(uint64_t) TMVirtualToNano(PVM pVM, uint64_t u64VirtualTicks);
92TMDECL(uint64_t) TMVirtualToMicro(PVM pVM, uint64_t u64VirtualTicks);
93TMDECL(uint64_t) TMVirtualToMilli(PVM pVM, uint64_t u64VirtualTicks);
94TMDECL(uint64_t) TMVirtualFromNano(PVM pVM, uint64_t u64NanoTS);
95TMDECL(uint64_t) TMVirtualFromMicro(PVM pVM, uint64_t u64MicroTS);
96TMDECL(uint64_t) TMVirtualFromMilli(PVM pVM, uint64_t u64MilliTS);
97TMDECL(uint32_t) TMVirtualGetWarpDrive(PVM pVM);
98TMDECL(int) TMVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent);
99/** @} */
100
101
102/** @name CPU Clock Methods
103 * @{
104 */
105TMDECL(int) TMCpuTickResume(PVM pVM);
106TMDECL(int) TMCpuTickPause(PVM pVM);
107TMDECL(uint64_t) TMCpuTickGet(PVM pVM);
108TMDECL(bool) TMCpuTickCanUseRealTSC(PVM pVM, uint64_t *poffRealTSC);
109TMDECL(int) TMCpuTickSet(PVM pVM, uint64_t u64Tick);
110TMDECL(uint64_t) TMCpuTicksPerSecond(PVM pVM);
111/** @} */
112
113
114/** @name Timer Methods
115 * @{
116 */
117/**
118 * Device timer callback function.
119 *
120 * @param pDevIns Device instance of the device which registered the timer.
121 * @param pTimer The timer handle.
122 */
123typedef DECLCALLBACK(void) FNTMTIMERDEV(PPDMDEVINS pDevIns, PTMTIMER pTimer);
124/** Pointer to a device timer callback function. */
125typedef FNTMTIMERDEV *PFNTMTIMERDEV;
126
127/**
128 * Driver timer callback function.
129 *
130 * @param pDrvIns Device instance of the device which registered the timer.
131 * @param pTimer The timer handle.
132 */
133typedef DECLCALLBACK(void) FNTMTIMERDRV(PPDMDRVINS pDrvIns, PTMTIMER pTimer);
134/** Pointer to a driver timer callback function. */
135typedef FNTMTIMERDRV *PFNTMTIMERDRV;
136
137/**
138 * Service timer callback function.
139 *
140 * @param pSrvIns Service instance of the device which registered the timer.
141 * @param pTimer The timer handle.
142 */
143typedef DECLCALLBACK(void) FNTMTIMERSRV(PPDMSRVINS pSrvIns, PTMTIMER pTimer);
144/** Pointer to a service timer callback function. */
145typedef FNTMTIMERSRV *PFNTMTIMERSRV;
146
147/**
148 * Internal timer callback function.
149 *
150 * @param pVM The VM.
151 * @param pTimer The timer handle.
152 * @param pvUser User argument specified upon timer creation.
153 */
154typedef DECLCALLBACK(void) FNTMTIMERINT(PVM pVM, PTMTIMER pTimer, void *pvUser);
155/** Pointer to internal timer callback function. */
156typedef FNTMTIMERINT *PFNTMTIMERINT;
157
158/**
159 * External timer callback function.
160 *
161 * @param pvUser User argument as specified when the timer was created.
162 */
163typedef DECLCALLBACK(void) FNTMTIMEREXT(void *pvUser);
164/** Pointer to an external timer callback function. */
165typedef FNTMTIMEREXT *PFNTMTIMEREXT;
166
167TMDECL(PTMTIMERR3) TMTimerR3Ptr(PTMTIMER pTimer);
168TMDECL(PTMTIMERR0) TMTimerR0Ptr(PTMTIMER pTimer);
169TMDECL(PTMTIMERGC) TMTimerGCPtr(PTMTIMER pTimer);
170TMDECL(int) TMTimerDestroy(PTMTIMER pTimer);
171TMDECL(int) TMTimerSet(PTMTIMER pTimer, uint64_t u64Expire);
172TMDECL(int) TMTimerSetMillies(PTMTIMER pTimer, uint32_t cMilliesToNext);
173TMDECL(int) TMTimerSetMicro(PTMTIMER pTimer, uint64_t cMicrosToNext);
174TMDECL(int) TMTimerSetNano(PTMTIMER pTimer, uint64_t cNanosToNext);
175TMDECL(uint64_t) TMTimerGet(PTMTIMER pTimer);
176TMDECL(uint64_t) TMTimerGetNano(PTMTIMER pTimer);
177TMDECL(uint64_t) TMTimerGetMicro(PTMTIMER pTimer);
178TMDECL(uint64_t) TMTimerGetMilli(PTMTIMER pTimer);
179TMDECL(uint64_t) TMTimerGetFreq(PTMTIMER pTimer);
180TMDECL(uint64_t) TMTimerGetExpire(PTMTIMER pTimer);
181TMDECL(uint64_t) TMTimerToNano(PTMTIMER pTimer, uint64_t u64Ticks);
182TMDECL(uint64_t) TMTimerToMicro(PTMTIMER pTimer, uint64_t u64Ticks);
183TMDECL(uint64_t) TMTimerToMilli(PTMTIMER pTimer, uint64_t u64Ticks);
184TMDECL(uint64_t) TMTimerFromNano(PTMTIMER pTimer, uint64_t u64NanoTS);
185TMDECL(uint64_t) TMTimerFromMicro(PTMTIMER pTimer, uint64_t u64MicroTS);
186TMDECL(uint64_t) TMTimerFromMilli(PTMTIMER pTimer, uint64_t u64MilliTS);
187TMDECL(int) TMTimerStop(PTMTIMER pTimer);
188TMDECL(bool) TMTimerIsActive(PTMTIMER pTimer);
189TMDECL(uint64_t) TMTimerPoll(PVM pVM);
190TMDECL(uint64_t) TMTimerPollGIP(PVM pVM, uint64_t *pu64Delta);
191
192/** @} */
193
194
195#ifdef IN_RING3
196/** @defgroup grp_tm_r3 The TM Host Context Ring-3 API
197 * @ingroup grp_tm
198 * @{
199 */
200TMR3DECL(int) TMR3Init(PVM pVM);
201TMR3DECL(int) TMR3InitFinalize(PVM pVM);
202TMR3DECL(void) TMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
203TMR3DECL(int) TMR3Term(PVM pVM);
204TMR3DECL(void) TMR3Reset(PVM pVM);
205TMR3DECL(int) TMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
206TMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer);
207TMR3DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer);
208TMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer);
209TMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
210TMR3DECL(int) TMR3TimerDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
211TMR3DECL(int) TMR3TimerDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
212TMR3DECL(int) TMR3TimerSave(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
213TMR3DECL(int) TMR3TimerLoad(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
214TMR3DECL(void) TMR3TimerQueuesDo(PVM pVM);
215TMR3DECL(PRTTIMESPEC) TMR3UTCNow(PVM pVM, PRTTIMESPEC pTime);
216/** @} */
217#endif /* IN_RING3 */
218
219
220/** @} */
221
222__END_DECLS
223
224#endif
225
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use