VirtualBox

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

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

Added TMTimerSetNano and TMTimerSetMicro.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.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 (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);
436TMDECL(int) TMTimerSetMicro(PTMTIMER pTimer, uint64_t cMicrosToNext);
437TMDECL(int) TMTimerSetNano(PTMTIMER pTimer, uint64_t cNanosToNext);
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 * @param pVM Pointer to the shared VM structure.
577 * @thread The emulation thread.
578 */
579TMDECL(uint64_t) TMTimerPoll(PVM pVM);
580
581/**
582 * Set FF if we've passed the next virtual event.
583 *
584 * This function is called before FFs are checked in the inner execution EM loops.
585 *
586 * @returns The GIP timestamp of the next event.
587 * 0 if the next event has already expired.
588 * @param pVM Pointer to the shared VM structure.
589 * @param pu64Delta Where to store the delta.
590 * @thread The emulation thread.
591 */
592TMDECL(uint64_t) TMTimerPollGIP(PVM pVM, uint64_t *pu64Delta);
593
594/** @} */
595
596
597#ifdef IN_RING3
598/** @defgroup grp_tm_r3 The TM Host Context Ring-3 API
599 * @ingroup grp_tm
600 * @{
601 */
602
603/**
604 * Initializes the TM.
605 *
606 * @returns VBox status code.
607 * @param pVM The VM to operate on.
608 */
609TMR3DECL(int) TMR3Init(PVM pVM);
610
611/**
612 * Finalizes the TM initialization.
613 *
614 * @returns VBox status code.
615 * @param pVM The VM to operate on.
616 */
617TMR3DECL(int) TMR3InitFinalize(PVM pVM);
618
619/**
620 * Applies relocations to data and code managed by this
621 * component. This function will be called at init and
622 * whenever the VMM need to relocate it self inside the GC.
623 *
624 * @param pVM The VM.
625 * @param offDelta Relocation delta relative to old location.
626 */
627TMR3DECL(void) TMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
628
629/**
630 * Terminates the TM.
631 *
632 * Termination means cleaning up and freeing all resources,
633 * the VM it self is at this point powered off or suspended.
634 *
635 * @returns VBox status code.
636 * @param pVM The VM to operate on.
637 */
638TMR3DECL(int) TMR3Term(PVM pVM);
639
640/**
641 * The VM is being reset.
642 *
643 * For the TM component this means that a rescheduling is preformed,
644 * the FF is cleared and but without running the queues. We'll have to
645 * check if this makes sense or not, but it seems like a good idea now....
646 *
647 * @param pVM VM handle.
648 */
649TMR3DECL(void) TMR3Reset(PVM pVM);
650
651/**
652 * Resolve a builtin GC symbol.
653 * Called by PDM when loading or relocating GC modules.
654 *
655 * @returns VBox status
656 * @param pVM VM Handle.
657 * @param pszSymbol Symbol to resolv
658 * @param pGCPtrValue Where to store the symbol value.
659 * @remark This has to work before TMR3Relocate() is called.
660 */
661TMR3DECL(int) TMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
662
663/**
664 * Creates a device timer.
665 *
666 * @returns VBox status.
667 * @param pVM The VM to create the timer in.
668 * @param pDevIns Device instance.
669 * @param enmClock The clock to use on this timer.
670 * @param pfnCallback Callback function.
671 * @param pszDesc Pointer to description string which must stay around
672 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
673 * @param ppTimer Where to store the timer on success.
674 */
675TMR3DECL(int) TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer);
676
677/**
678 * Creates a driver timer.
679 *
680 * @returns VBox status.
681 * @param pVM The VM to create the timer in.
682 * @param pDrvIns Driver instance.
683 * @param enmClock The clock to use on this timer.
684 * @param pfnCallback Callback function.
685 * @param pszDesc Pointer to description string which must stay around
686 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
687 * @param ppTimer Where to store the timer on success.
688 */
689TMR3DECL(int) TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, const char *pszDesc, PPTMTIMERR3 ppTimer);
690
691/**
692 * Creates an internal timer.
693 *
694 * @returns VBox status.
695 * @param pVM The VM to create the timer in.
696 * @param enmClock The clock to use on this timer.
697 * @param pfnCallback Callback function.
698 * @param pvUser User argument to be passed to the callback.
699 * @param pszDesc Pointer to description string which must stay around
700 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
701 * @param ppTimer Where to store the timer on success.
702 */
703TMR3DECL(int) TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer);
704
705/**
706 * Creates an external timer.
707 *
708 * @returns Timer handle on success.
709 * @returns NULL on failure.
710 * @param pVM The VM to create the timer in.
711 * @param enmClock The clock to use on this timer.
712 * @param pfnCallback Callback function.
713 * @param pvUser User argument.
714 * @param pszDesc Pointer to description string which must stay around
715 * until the timer is fully destroyed (i.e. a bit after TMTimerDestroy()).
716 */
717TMR3DECL(PTMTIMERR3) TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
718
719/**
720 * Destroy all timers owned by a device.
721 *
722 * @returns VBox status.
723 * @param pVM VM handle.
724 * @param pDevIns Device which timers should be destroyed.
725 */
726TMR3DECL(int) TMR3TimerDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
727
728/**
729 * Destroy all timers owned by a driver.
730 *
731 * @returns VBox status.
732 * @param pVM VM handle.
733 * @param pDrvIns Driver which timers should be destroyed.
734 */
735TMR3DECL(int) TMR3TimerDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
736
737/**
738 * Saves the state of a timer to a saved state.
739 *
740 * @returns VBox status.
741 * @param pTimer Timer to save.
742 * @param pSSM Save State Manager handle.
743 */
744TMR3DECL(int) TMR3TimerSave(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
745
746/**
747 * Loads the state of a timer from a saved state.
748 *
749 * @returns VBox status.
750 * @param pTimer Timer to restore.
751 * @param pSSM Save State Manager handle.
752 */
753TMR3DECL(int) TMR3TimerLoad(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
754
755/**
756 * Schedules and runs any pending timers.
757 *
758 * This is normally called from a forced action handler in EMT.
759 *
760 * @param pVM The VM to run the timers for.
761 * @thread The emulation thread.
762 */
763TMR3DECL(void) TMR3TimerQueuesDo(PVM pVM);
764
765/**
766 * Get the real world UTC time adjusted for VM lag.
767 *
768 * @returns pTime.
769 * @param pVM The VM instance.
770 * @param pTime Where to store the time.
771 */
772TMR3DECL(PRTTIMESPEC) TMR3UTCNow(PVM pVM, PRTTIMESPEC pTime);
773
774/** @} */
775#endif
776
777
778#ifdef IN_GC
779/** @defgroup grp_tm_gc The TM Guest Context API
780 * @ingroup grp_tm
781 * @{
782 */
783
784
785/** @} */
786#endif
787
788/** @} */
789
790__END_DECLS
791
792#endif
793
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