VirtualBox

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

Last change on this file since 4693 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

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