1 | /** @file
|
---|
2 | * TM - Time Monitor.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 | #ifndef __VBox_tm_h__
|
---|
23 | #define __VBox_tm_h__
|
---|
24 |
|
---|
25 | #include <VBox/cdefs.h>
|
---|
26 | #include <VBox/types.h>
|
---|
27 |
|
---|
28 | __BEGIN_DECLS
|
---|
29 |
|
---|
30 | /** @defgroup grp_tm The Time Monitor API
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 | /** Enable a timer hack which improves the timer response/resolution a bit. */
|
---|
35 | #define VBOX_HIGH_RES_TIMERS_HACK
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Clock type.
|
---|
40 | */
|
---|
41 | typedef enum TMCLOCK
|
---|
42 | {
|
---|
43 | /** Real host time.
|
---|
44 | * This clock ticks all the time, so use with care. */
|
---|
45 | TMCLOCK_REAL = 0,
|
---|
46 | /** Virtual guest time.
|
---|
47 | * This clock only ticks when the guest is running. It's implemented
|
---|
48 | * as an offset to real time. */
|
---|
49 | TMCLOCK_VIRTUAL,
|
---|
50 | #if 1
|
---|
51 | /** Virtual guest synchronized timer time.
|
---|
52 | * This is a special clock and timer queue for synchronizing virtual timers and
|
---|
53 | * virtual time sources. This clock is trying to keep up with TMCLOCK_VIRTUAL,
|
---|
54 | * but will wait for timers to be executed. If it lags too far behind TMCLOCK_VIRTUAL,
|
---|
55 | * it will try speed up to close the distance. */
|
---|
56 | TMCLOCK_VIRTUAL_SYNC,
|
---|
57 | #endif
|
---|
58 | /** Virtual CPU timestamp. (Running only when we're executing guest code.) */
|
---|
59 | TMCLOCK_TSC,
|
---|
60 | /** Number of clocks. */
|
---|
61 | TMCLOCK_MAX
|
---|
62 | } TMCLOCK;
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | /** @name Real Clock Methods
|
---|
67 | * @{
|
---|
68 | */
|
---|
69 | /**
|
---|
70 | * Gets the current TMCLOCK_REAL time.
|
---|
71 | *
|
---|
72 | * @returns Real time.
|
---|
73 | * @param pVM The VM handle.
|
---|
74 | */
|
---|
75 | TMDECL(uint64_t) TMRealGet(PVM pVM);
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Gets the frequency of the TMCLOCK_REAL clock.
|
---|
79 | *
|
---|
80 | * @returns frequency.
|
---|
81 | * @param pVM The VM handle.
|
---|
82 | */
|
---|
83 | TMDECL(uint64_t) TMRealGetFreq(PVM pVM);
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 |
|
---|
87 | /** @name Virtual Clock Methods
|
---|
88 | * @{
|
---|
89 | */
|
---|
90 | /**
|
---|
91 | * Gets the current TMCLOCK_VIRTUAL time.
|
---|
92 | *
|
---|
93 | * @returns The timestamp.
|
---|
94 | * @param pVM VM handle.
|
---|
95 | *
|
---|
96 | * @remark While the flow of time will never go backwards, the speed of the
|
---|
97 | * progress varies due to inaccurate RTTimeNanoTS and TSC. The latter can be
|
---|
98 | * influenced by power saving (SpeedStep, PowerNow!), while the former
|
---|
99 | * makes use of TSC and kernel timers.
|
---|
100 | */
|
---|
101 | TMDECL(uint64_t) TMVirtualGet(PVM pVM);
|
---|
102 |
|
---|
103 | /**
|
---|
104 | * Gets the current TMCLOCK_VIRTUAL_SYNC time.
|
---|
105 | *
|
---|
106 | * @returns The timestamp.
|
---|
107 | * @param pVM VM handle.
|
---|
108 | *
|
---|
109 | */
|
---|
110 | TMDECL(uint64_t) TMVirtualGetSync(PVM pVM);
|
---|
111 |
|
---|
112 | /**
|
---|
113 | * Gets the current TMCLOCK_VIRTUAL frequency.
|
---|
114 | *
|
---|
115 | * @returns The freqency.
|
---|
116 | * @param pVM VM handle.
|
---|
117 | */
|
---|
118 | TMDECL(uint64_t) TMVirtualGetFreq(PVM pVM);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Resumes the virtual clock.
|
---|
122 | *
|
---|
123 | * @returns VINF_SUCCESS on success.
|
---|
124 | * @returns VINF_INTERNAL_ERROR and VBOX_STRICT assertion if called out of order.
|
---|
125 | * @param pVM VM handle.
|
---|
126 | */
|
---|
127 | TMDECL(int) TMVirtualResume(PVM pVM);
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * Pauses the virtual clock.
|
---|
131 | *
|
---|
132 | * @returns VINF_SUCCESS on success.
|
---|
133 | * @returns VINF_INTERNAL_ERROR and VBOX_STRICT assertion if called out of order.
|
---|
134 | * @param pVM VM handle.
|
---|
135 | */
|
---|
136 | TMDECL(int) TMVirtualPause(PVM pVM);
|
---|
137 |
|
---|
138 | /**
|
---|
139 | * Converts from virtual ticks to nanoseconds.
|
---|
140 | *
|
---|
141 | * @returns nanoseconds.
|
---|
142 | * @param pVM The VM handle.
|
---|
143 | * @param u64VirtualTicks The virtual ticks to convert.
|
---|
144 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
145 | * without any adjustments.
|
---|
146 | */
|
---|
147 | TMDECL(uint64_t) TMVirtualToNano(PVM pVM, uint64_t u64VirtualTicks);
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Converts from virtual ticks to microseconds.
|
---|
151 | *
|
---|
152 | * @returns microseconds.
|
---|
153 | * @param pVM The VM handle.
|
---|
154 | * @param u64VirtualTicks The virtual ticks to convert.
|
---|
155 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
156 | * without any adjustments.
|
---|
157 | */
|
---|
158 | TMDECL(uint64_t) TMVirtualToMicro(PVM pVM, uint64_t u64VirtualTicks);
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Converts from virtual ticks to milliseconds.
|
---|
162 | *
|
---|
163 | * @returns milliseconds.
|
---|
164 | * @param pVM The VM handle.
|
---|
165 | * @param u64VirtualTicks The virtual ticks to convert.
|
---|
166 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
167 | * without any adjustments.
|
---|
168 | */
|
---|
169 | TMDECL(uint64_t) TMVirtualToMilli(PVM pVM, uint64_t u64VirtualTicks);
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Converts from nanoseconds to virtual ticks.
|
---|
173 | *
|
---|
174 | * @returns virtual ticks.
|
---|
175 | * @param pVM The VM handle.
|
---|
176 | * @param u64NanoTS The nanosecond value ticks to convert.
|
---|
177 | * @remark There could be rounding and overflow errors here.
|
---|
178 | */
|
---|
179 | TMDECL(uint64_t) TMVirtualFromNano(PVM pVM, uint64_t u64NanoTS);
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * Converts from microseconds to virtual ticks.
|
---|
183 | *
|
---|
184 | * @returns virtual ticks.
|
---|
185 | * @param pVM The VM handle.
|
---|
186 | * @param u64MicroTS The microsecond value ticks to convert.
|
---|
187 | * @remark There could be rounding and overflow errors here.
|
---|
188 | */
|
---|
189 | TMDECL(uint64_t) TMVirtualFromMicro(PVM pVM, uint64_t u64MicroTS);
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Converts from milliseconds to virtual ticks.
|
---|
193 | *
|
---|
194 | * @returns virtual ticks.
|
---|
195 | * @param pVM The VM handle.
|
---|
196 | * @param u64MilliTS The millisecond value ticks to convert.
|
---|
197 | * @remark There could be rounding and overflow errors here.
|
---|
198 | */
|
---|
199 | TMDECL(uint64_t) TMVirtualFromMilli(PVM pVM, uint64_t u64MilliTS);
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Gets the current warp drive percent.
|
---|
203 | *
|
---|
204 | * @returns The warp drive percent.
|
---|
205 | * @param pVM The VM handle.
|
---|
206 | */
|
---|
207 | TMDECL(uint32_t) TMVirtualGetWarpDrive(PVM pVM);
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Sets the warp drive percent of the virtual time.
|
---|
211 | *
|
---|
212 | * @returns VBox status code.
|
---|
213 | * @param pVM The VM handle.
|
---|
214 | * @param u32Percent The new percentage. 100 means normal operation.
|
---|
215 | */
|
---|
216 | TMDECL(int) TMVirtualSetWarpDrive(PVM pVM, uint32_t u32Percent);
|
---|
217 |
|
---|
218 | /** @} */
|
---|
219 |
|
---|
220 |
|
---|
221 | /** @name CPU Clock Methods
|
---|
222 | * @{
|
---|
223 | */
|
---|
224 | /**
|
---|
225 | * Resumes the CPU timestamp counter ticking.
|
---|
226 | *
|
---|
227 | * @returns VBox status code.
|
---|
228 | * @param pVM The VM to operate on.
|
---|
229 | */
|
---|
230 | TMDECL(int) TMCpuTickResume(PVM pVM);
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Pauses the CPU timestamp counter ticking.
|
---|
234 | *
|
---|
235 | * @returns VBox status code.
|
---|
236 | * @param pVM The VM to operate on.
|
---|
237 | */
|
---|
238 | TMDECL(int) TMCpuTickPause(PVM pVM);
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * Read the current CPU timstamp counter.
|
---|
242 | *
|
---|
243 | * @returns Gets the CPU tsc.
|
---|
244 | * @param pVM The VM to operate on.
|
---|
245 | */
|
---|
246 | TMDECL(uint64_t) TMCpuTickGet(PVM pVM);
|
---|
247 |
|
---|
248 | /**
|
---|
249 | * Sets the current CPU timestamp counter.
|
---|
250 | *
|
---|
251 | * @returns VBox status code.
|
---|
252 | * @param pVM The VM to operate on.
|
---|
253 | * @param u64Tick The new timestamp value.
|
---|
254 | */
|
---|
255 | TMDECL(int) TMCpuTickSet(PVM pVM, uint64_t u64Tick);
|
---|
256 |
|
---|
257 | /**
|
---|
258 | * Get the timestamp frequency.
|
---|
259 | *
|
---|
260 | * @returns Number of ticks per second.
|
---|
261 | * @param pVM The VM.
|
---|
262 | */
|
---|
263 | TMDECL(uint64_t) TMCpuTicksPerSecond(PVM pVM);
|
---|
264 |
|
---|
265 | /** @} */
|
---|
266 |
|
---|
267 |
|
---|
268 | /** @name Timer Methods
|
---|
269 | * @{
|
---|
270 | */
|
---|
271 | /**
|
---|
272 | * Device timer callback function.
|
---|
273 | *
|
---|
274 | * @param pDevIns Device instance of the device which registered the timer.
|
---|
275 | * @param pTimer The timer handle.
|
---|
276 | */
|
---|
277 | typedef DECLCALLBACK(void) FNTMTIMERDEV(PPDMDEVINS pDevIns, PTMTIMER pTimer);
|
---|
278 | /** Pointer to a device timer callback function. */
|
---|
279 | typedef FNTMTIMERDEV *PFNTMTIMERDEV;
|
---|
280 |
|
---|
281 | /**
|
---|
282 | * Driver timer callback function.
|
---|
283 | *
|
---|
284 | * @param pDrvIns Device instance of the device which registered the timer.
|
---|
285 | * @param pTimer The timer handle.
|
---|
286 | */
|
---|
287 | typedef DECLCALLBACK(void) FNTMTIMERDRV(PPDMDRVINS pDrvIns, PTMTIMER pTimer);
|
---|
288 | /** Pointer to a driver timer callback function. */
|
---|
289 | typedef FNTMTIMERDRV *PFNTMTIMERDRV;
|
---|
290 |
|
---|
291 | /**
|
---|
292 | * Service timer callback function.
|
---|
293 | *
|
---|
294 | * @param pSrvIns Service instance of the device which registered the timer.
|
---|
295 | * @param pTimer The timer handle.
|
---|
296 | */
|
---|
297 | typedef DECLCALLBACK(void) FNTMTIMERSRV(PPDMSRVINS pSrvIns, PTMTIMER pTimer);
|
---|
298 | /** Pointer to a service timer callback function. */
|
---|
299 | typedef FNTMTIMERSRV *PFNTMTIMERSRV;
|
---|
300 |
|
---|
301 | /**
|
---|
302 | * Internal timer callback function.
|
---|
303 | *
|
---|
304 | * @param pVM The VM.
|
---|
305 | * @param pTimer The timer handle.
|
---|
306 | * @param pvUser User argument specified upon timer creation.
|
---|
307 | */
|
---|
308 | typedef DECLCALLBACK(void) FNTMTIMERINT(PVM pVM, PTMTIMER pTimer, void *pvUser);
|
---|
309 | /** Pointer to internal timer callback function. */
|
---|
310 | typedef FNTMTIMERINT *PFNTMTIMERINT;
|
---|
311 |
|
---|
312 | /**
|
---|
313 | * External timer callback function.
|
---|
314 | *
|
---|
315 | * @param pvUser User argument as specified when the timer was created.
|
---|
316 | */
|
---|
317 | typedef DECLCALLBACK(void) FNTMTIMEREXT(void *pvUser);
|
---|
318 | /** Pointer to an external timer callback function. */
|
---|
319 | typedef FNTMTIMEREXT *PFNTMTIMEREXT;
|
---|
320 |
|
---|
321 |
|
---|
322 | /**
|
---|
323 | * Gets the host context ring-3 pointer of the timer.
|
---|
324 | *
|
---|
325 | * @returns HC R3 pointer.
|
---|
326 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
327 | */
|
---|
328 | TMDECL(PTMTIMERR3) TMTimerR3Ptr(PTMTIMER pTimer);
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Gets the host context ring-0 pointer of the timer.
|
---|
332 | *
|
---|
333 | * @returns HC R0 pointer.
|
---|
334 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
335 | */
|
---|
336 | TMDECL(PTMTIMERR0) TMTimerR0Ptr(PTMTIMER pTimer);
|
---|
337 |
|
---|
338 | /**
|
---|
339 | * Gets the GC pointer of the timer.
|
---|
340 | *
|
---|
341 | * @returns GC pointer.
|
---|
342 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
343 | */
|
---|
344 | TMDECL(PTMTIMERGC) TMTimerGCPtr(PTMTIMER pTimer);
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * Gets the GC pointer of the timer.
|
---|
348 | *
|
---|
349 | * @returns GC pointer.
|
---|
350 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
351 | * @deprecated
|
---|
352 | */
|
---|
353 | DECLINLINE(PTMTIMERHC) TMTimerHCPtr(PTMTIMER pTimer)
|
---|
354 | {
|
---|
355 | return (PTMTIMERHC)TMTimerR3Ptr(pTimer);
|
---|
356 | }
|
---|
357 |
|
---|
358 | /**
|
---|
359 | * Destroy a timer
|
---|
360 | *
|
---|
361 | * @returns VBox status.
|
---|
362 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
363 | */
|
---|
364 | TMDECL(int) TMTimerDestroy(PTMTIMER pTimer);
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * Arm a timer with a (new) expire time.
|
---|
368 | *
|
---|
369 | * @returns VBox status.
|
---|
370 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
371 | * @param u64Expire New expire time.
|
---|
372 | */
|
---|
373 | TMDECL(int) TMTimerSet(PTMTIMER pTimer, uint64_t u64Expire);
|
---|
374 |
|
---|
375 | /**
|
---|
376 | * Arm a timer with a (new) expire time relative to current clock.
|
---|
377 | *
|
---|
378 | * @returns VBox status.
|
---|
379 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
380 | * @param cMilliesToNext Number of millieseconds to the next tick.
|
---|
381 | */
|
---|
382 | TMDECL(int) TMTimerSetMillies(PTMTIMER pTimer, uint32_t cMilliesToNext);
|
---|
383 |
|
---|
384 | /**
|
---|
385 | * Get the current clock time.
|
---|
386 | * Handy for calculating the new expire time.
|
---|
387 | *
|
---|
388 | * @returns Current clock time.
|
---|
389 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
390 | */
|
---|
391 | TMDECL(uint64_t) TMTimerGet(PTMTIMER pTimer);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Get the current clock time as nanoseconds.
|
---|
395 | *
|
---|
396 | * @returns The timer clock as nanoseconds.
|
---|
397 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
398 | */
|
---|
399 | TMDECL(uint64_t) TMTimerGetNano(PTMTIMER pTimer);
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Get the current clock time as microseconds.
|
---|
403 | *
|
---|
404 | * @returns The timer clock as microseconds.
|
---|
405 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
406 | */
|
---|
407 | TMDECL(uint64_t) TMTimerGetMicro(PTMTIMER pTimer);
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * Get the current clock time as milliseconds.
|
---|
411 | *
|
---|
412 | * @returns The timer clock as milliseconds.
|
---|
413 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
414 | */
|
---|
415 | TMDECL(uint64_t) TMTimerGetMilli(PTMTIMER pTimer);
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Get the freqency of the timer clock.
|
---|
419 | *
|
---|
420 | * @returns Clock frequency (as Hz of course).
|
---|
421 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
422 | */
|
---|
423 | TMDECL(uint64_t) TMTimerGetFreq(PTMTIMER pTimer);
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * Get the expire time of the timer.
|
---|
427 | * Only valid for active timers.
|
---|
428 | *
|
---|
429 | * @returns Expire time of the timer.
|
---|
430 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
431 | */
|
---|
432 | TMDECL(uint64_t) TMTimerGetExpire(PTMTIMER pTimer);
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * Converts the specified timer clock time to nanoseconds.
|
---|
436 | *
|
---|
437 | * @returns nanoseconds.
|
---|
438 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
439 | * @param u64Ticks The clock ticks.
|
---|
440 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
441 | * without any adjustments.
|
---|
442 | */
|
---|
443 | TMDECL(uint64_t) TMTimerToNano(PTMTIMER pTimer, uint64_t u64Ticks);
|
---|
444 |
|
---|
445 | /**
|
---|
446 | * Converts the specified timer clock time to microseconds.
|
---|
447 | *
|
---|
448 | * @returns microseconds.
|
---|
449 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
450 | * @param u64Ticks The clock ticks.
|
---|
451 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
452 | * without any adjustments.
|
---|
453 | */
|
---|
454 | TMDECL(uint64_t) TMTimerToMicro(PTMTIMER pTimer, uint64_t u64Ticks);
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Converts the specified timer clock time to milliseconds.
|
---|
458 | *
|
---|
459 | * @returns milliseconds.
|
---|
460 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
461 | * @param u64Ticks The clock ticks.
|
---|
462 | * @remark There could be rounding errors here. We just do a simple integere divide
|
---|
463 | * without any adjustments.
|
---|
464 | */
|
---|
465 | TMDECL(uint64_t) TMTimerToMilli(PTMTIMER pTimer, uint64_t u64Ticks);
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * Converts the specified nanosecond timestamp to timer clock ticks.
|
---|
469 | *
|
---|
470 | * @returns timer clock ticks.
|
---|
471 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
472 | * @param u64NanoTS The nanosecond value ticks to convert.
|
---|
473 | * @remark There could be rounding and overflow errors here.
|
---|
474 | */
|
---|
475 | TMDECL(uint64_t) TMTimerFromNano(PTMTIMER pTimer, uint64_t u64NanoTS);
|
---|
476 |
|
---|
477 | /**
|
---|
478 | * Converts the specified microsecond timestamp to timer clock ticks.
|
---|
479 | *
|
---|
480 | * @returns timer clock ticks.
|
---|
481 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
482 | * @param u64MicroTS The microsecond value ticks to convert.
|
---|
483 | * @remark There could be rounding and overflow errors here.
|
---|
484 | */
|
---|
485 | TMDECL(uint64_t) TMTimerFromMicro(PTMTIMER pTimer, uint64_t u64MicroTS);
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Converts the specified millisecond timestamp to timer clock ticks.
|
---|
489 | *
|
---|
490 | * @returns timer clock ticks.
|
---|
491 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
492 | * @param u64MilliTS The millisecond value ticks to convert.
|
---|
493 | * @remark There could be rounding and overflow errors here.
|
---|
494 | */
|
---|
495 | TMDECL(uint64_t) TMTimerFromMilli(PTMTIMER pTimer, uint64_t u64MilliTS);
|
---|
496 |
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Stop the timer.
|
---|
500 | * Use TMR3TimerArm() to "un-stop" the timer.
|
---|
501 | *
|
---|
502 | * @returns VBox status.
|
---|
503 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
504 | */
|
---|
505 | TMDECL(int) TMTimerStop(PTMTIMER pTimer);
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * Checks if a timer is active or not.
|
---|
509 | *
|
---|
510 | * @returns True if active.
|
---|
511 | * @returns False if not active.
|
---|
512 | * @param pTimer Timer handle as returned by one of the create functions.
|
---|
513 | */
|
---|
514 | TMDECL(bool) TMTimerIsActive(PTMTIMER pTimer);
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Set FF if we've passed the next virtual event.
|
---|
518 | *
|
---|
519 | * This function is called before FFs are checked in the inner execution EM loops.
|
---|
520 | *
|
---|
521 | * @returns Virtual timer ticks to the next event.
|
---|
522 | * @thread The emulation thread.
|
---|
523 | */
|
---|
524 | TMDECL(uint64_t) TMTimerPoll(PVM pVM);
|
---|
525 |
|
---|
526 | /** @} */
|
---|
527 |
|
---|
528 |
|
---|
529 | #ifdef IN_RING3
|
---|
530 | /** @defgroup grp_tm_r3 The TM Host Context Ring-3 API
|
---|
531 | * @ingroup grp_tm
|
---|
532 | * @{
|
---|
533 | */
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Initializes the TM.
|
---|
537 | *
|
---|
538 | * @returns VBox status code.
|
---|
539 | * @param pVM The VM to operate on.
|
---|
540 | */
|
---|
541 | TMR3DECL(int) TMR3Init(PVM pVM);
|
---|
542 |
|
---|
543 | /**
|
---|
544 | * Applies relocations to data and code managed by this
|
---|
545 | * component. This function will be called at init and
|
---|
546 | * whenever the VMM need to relocate it self inside the GC.
|
---|
547 | *
|
---|
548 | * @param pVM The VM.
|
---|
549 | * @param offDelta Relocation delta relative to old location.
|
---|
550 | */
|
---|
551 | TMR3DECL(void) TMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Terminates the TM.
|
---|
555 | *
|
---|
556 | * Termination means cleaning up and freeing all resources,
|
---|
557 | * the VM it self is at this point powered off or suspended.
|
---|
558 | *
|
---|
559 | * @returns VBox status code.
|
---|
560 | * @param pVM The VM to operate on.
|
---|
561 | */
|
---|
562 | TMR3DECL(int) TMR3Term(PVM pVM);
|
---|
563 |
|
---|
564 | /**
|
---|
565 | * The VM is being reset.
|
---|
566 | *
|
---|
567 | * For the TM component this means that a rescheduling is preformed,
|
---|
568 | * the FF is cleared and but without running the queues. We'll have to
|
---|
569 | * check if this makes sense or not, but it seems like a good idea now....
|
---|
570 | *
|
---|
571 | * @param pVM VM handle.
|
---|
572 | */
|
---|
573 | TMR3DECL(void) TMR3Reset(PVM pVM);
|
---|
574 |
|
---|
575 | /**
|
---|
576 | * Resolve a builtin GC symbol.
|
---|
577 | * Called by PDM when loading or relocating GC modules.
|
---|
578 | *
|
---|
579 | * @returns VBox status
|
---|
580 | * @param pVM VM Handle.
|
---|
581 | * @param pszSymbol Symbol to resolv
|
---|
582 | * @param pGCPtrValue Where to store the symbol value.
|
---|
583 | * @remark This has to work before TMR3Relocate() is called.
|
---|
584 | */
|
---|
585 | TMR3DECL(int) TMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
|
---|
586 |
|
---|
587 | /**
|
---|
588 | * Creates a device timer.
|
---|
589 | *
|
---|
590 | * @returns VBox status.
|
---|
591 | * @param pVM The VM to create the timer in.
|
---|
592 | * @param pDevIns Device instance.
|
---|
593 | * @param enmClock The clock to use on this timer.
|
---|
594 | * @param pfnCallback Callback function.
|
---|
595 | * @param pszDesc Pointer to description string which must stay around
|
---|
596 | * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
|
---|
597 | * @param ppTimer Where to store the timer on success.
|
---|
598 | */
|
---|
599 | TMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer);
|
---|
600 |
|
---|
601 | /**
|
---|
602 | * Creates a driver timer.
|
---|
603 | *
|
---|
604 | * @returns VBox status.
|
---|
605 | * @param pVM The VM to create the timer in.
|
---|
606 | * @param pDrvIns Driver instance.
|
---|
607 | * @param enmClock The clock to use on this timer.
|
---|
608 | * @param pfnCallback Callback function.
|
---|
609 | * @param pszDesc Pointer to description string which must stay around
|
---|
610 | * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
|
---|
611 | * @param ppTimer Where to store the timer on success.
|
---|
612 | */
|
---|
613 | TMR3DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERHC ppTimer);
|
---|
614 |
|
---|
615 | /**
|
---|
616 | * Creates an internal timer.
|
---|
617 | *
|
---|
618 | * @returns VBox status.
|
---|
619 | * @param pVM The VM to create the timer in.
|
---|
620 | * @param enmClock The clock to use on this timer.
|
---|
621 | * @param pfnCallback Callback function.
|
---|
622 | * @param pvUser User argument to be passed to the callback.
|
---|
623 | * @param pszDesc Pointer to description string which must stay around
|
---|
624 | * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
|
---|
625 | * @param ppTimer Where to store the timer on success.
|
---|
626 | */
|
---|
627 | TMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERHC ppTimer);
|
---|
628 |
|
---|
629 | /**
|
---|
630 | * Creates an external timer.
|
---|
631 | *
|
---|
632 | * @returns Timer handle on success.
|
---|
633 | * @returns NULL on failure.
|
---|
634 | * @param pVM The VM to create the timer in.
|
---|
635 | * @param enmClock The clock to use on this timer.
|
---|
636 | * @param pfnCallback Callback function.
|
---|
637 | * @param pvUser User argument.
|
---|
638 | * @param pszDesc Pointer to description string which must stay around
|
---|
639 | * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
|
---|
640 | */
|
---|
641 | TMR3DECL(PTMTIMERHC) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
|
---|
642 |
|
---|
643 | /**
|
---|
644 | * Destroy all timers owned by a device.
|
---|
645 | *
|
---|
646 | * @returns VBox status.
|
---|
647 | * @param pVM VM handle.
|
---|
648 | * @param pDevIns Device which timers should be destroyed.
|
---|
649 | */
|
---|
650 | TMR3DECL(int) TMR3TimerDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
|
---|
651 |
|
---|
652 |
|
---|
653 | /**
|
---|
654 | * Destroy all timers owned by a driver.
|
---|
655 | *
|
---|
656 | * @returns VBox status.
|
---|
657 | * @param pVM VM handle.
|
---|
658 | * @param pDrvIns Driver which timers should be destroyed.
|
---|
659 | */
|
---|
660 | TMR3DECL(int) TMR3TimerDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
|
---|
661 |
|
---|
662 | /**
|
---|
663 | * Saves the state of a timer to a saved state.
|
---|
664 | *
|
---|
665 | * @returns VBox status.
|
---|
666 | * @param pTimer Timer to save.
|
---|
667 | * @param pSSM Save State Manager handle.
|
---|
668 | */
|
---|
669 | TMR3DECL(int) TMR3TimerSave(PTMTIMERHC pTimer, PSSMHANDLE pSSM);
|
---|
670 |
|
---|
671 | /**
|
---|
672 | * Loads the state of a timer from a saved state.
|
---|
673 | *
|
---|
674 | * @returns VBox status.
|
---|
675 | * @param pTimer Timer to restore.
|
---|
676 | * @param pSSM Save State Manager handle.
|
---|
677 | */
|
---|
678 | TMR3DECL(int) TMR3TimerLoad(PTMTIMERHC pTimer, PSSMHANDLE pSSM);
|
---|
679 |
|
---|
680 | /**
|
---|
681 | * Schedules and runs any pending timers.
|
---|
682 | *
|
---|
683 | * This is normally called from a forced action handler in EMT.
|
---|
684 | *
|
---|
685 | * @param pVM The VM to run the timers for.
|
---|
686 | * @thread The emulation thread.
|
---|
687 | */
|
---|
688 | TMR3DECL(void) TMR3TimerQueuesDo(PVM pVM);
|
---|
689 |
|
---|
690 |
|
---|
691 | /** @} */
|
---|
692 | #endif
|
---|
693 |
|
---|
694 |
|
---|
695 | #ifdef IN_GC
|
---|
696 | /** @defgroup grp_tm_gc The TM Guest Context API
|
---|
697 | * @ingroup grp_tm
|
---|
698 | * @{
|
---|
699 | */
|
---|
700 |
|
---|
701 |
|
---|
702 | /** @} */
|
---|
703 | #endif
|
---|
704 |
|
---|
705 | /** @} */
|
---|
706 |
|
---|
707 | __END_DECLS
|
---|
708 |
|
---|
709 | #endif
|
---|
710 |
|
---|