VirtualBox

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

Last change on this file since 2623 was 2623, checked in by vboxsync, 18 years ago

Fixed UTC typo.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette