VirtualBox

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

Last change on this file since 6981 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

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