VirtualBox

source: vbox/trunk/src/VBox/VMM/TMInternal.h@ 19502

Last change on this file since 19502 was 19499, checked in by vboxsync, 16 years ago

TMInternal.h: Made TMTIMER::offShcduleNext volatile and switched from ASMAtomicXchgSize to ASMAtomicXchgU32 for updating the state.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.7 KB
Line 
1/* $Id: TMInternal.h 19499 2009-05-07 18:10:25Z vboxsync $ */
2/** @file
3 * TM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___TMInternal_h
23#define ___TMInternal_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <iprt/time.h>
28#include <iprt/timer.h>
29#include <iprt/assert.h>
30#include <VBox/stam.h>
31#include <VBox/pdmcritsect.h>
32
33__BEGIN_DECLS
34
35
36/** @defgroup grp_tm_int Internal
37 * @ingroup grp_tm
38 * @internal
39 * @{
40 */
41
42/** Frequency of the real clock. */
43#define TMCLOCK_FREQ_REAL UINT32_C(1000)
44/** Frequency of the virtual clock. */
45#define TMCLOCK_FREQ_VIRTUAL UINT32_C(1000000000)
46
47
48/**
49 * Timer type.
50 */
51typedef enum TMTIMERTYPE
52{
53 /** Device timer. */
54 TMTIMERTYPE_DEV = 1,
55 /** Driver timer. */
56 TMTIMERTYPE_DRV,
57 /** Internal timer . */
58 TMTIMERTYPE_INTERNAL,
59 /** External timer. */
60 TMTIMERTYPE_EXTERNAL
61} TMTIMERTYPE;
62
63/**
64 * Timer state
65 */
66typedef enum TMTIMERSTATE
67{
68 /** Timer is stopped. */
69 TMTIMERSTATE_STOPPED = 1,
70 /** Timer is active. */
71 TMTIMERSTATE_ACTIVE,
72 /** Timer is expired, is being delivered. */
73 TMTIMERSTATE_EXPIRED,
74
75 /** Timer is stopped but still in the active list.
76 * Currently in the ScheduleTimers list. */
77 TMTIMERSTATE_PENDING_STOP,
78 /** Timer is stopped but needs unlinking from the ScheduleTimers list.
79 * Currently in the ScheduleTimers list. */
80 TMTIMERSTATE_PENDING_STOP_SCHEDULE,
81 /** Timer is being modified and will soon be pending scheduling.
82 * Currently in the ScheduleTimers list. */
83 TMTIMERSTATE_PENDING_SCHEDULE_SET_EXPIRE,
84 /** Timer is pending scheduling.
85 * Currently in the ScheduleTimers list. */
86 TMTIMERSTATE_PENDING_SCHEDULE,
87 /** Timer is being modified and will soon be pending rescheduling.
88 * Currently in the ScheduleTimers list and the active list. */
89 TMTIMERSTATE_PENDING_RESCHEDULE_SET_EXPIRE,
90 /** Timer is modified and is now pending rescheduling.
91 * Currently in the ScheduleTimers list and the active list. */
92 TMTIMERSTATE_PENDING_RESCHEDULE,
93 /** Timer is destroyed but needs to be replaced from the
94 * active to the free list.
95 * Currently in the ScheduleTimers list and the active list. */
96 TMTIMERSTATE_PENDING_STOP_DESTROY,
97 /** Timer is destroyed but needs moving to the free list.
98 * Currently in the ScheduleTimers list. */
99 TMTIMERSTATE_PENDING_DESTROY,
100 /** Timer is free. */
101 TMTIMERSTATE_FREE
102} TMTIMERSTATE;
103
104
105/**
106 * Internal representation of a timer.
107 *
108 * For correct serialization (without the use of semaphores and
109 * other blocking/slow constructs) certain rules applies to updating
110 * this structure:
111 * - For thread other than EMT only u64Expire, enmState and pScheduleNext*
112 * are changeable. Everything else is out of bounds.
113 * - Updating of u64Expire timer can only happen in the TMTIMERSTATE_STOPPED
114 * and TMTIMERSTATE_PENDING_RESCHEDULING_SET_EXPIRE states.
115 * - Timers in the TMTIMERSTATE_EXPIRED state are only accessible from EMT.
116 * - Actual destruction of a timer can only be done at scheduling time.
117 */
118typedef struct TMTIMER
119{
120 /** Expire time. */
121 volatile uint64_t u64Expire;
122 /** Clock to apply to u64Expire. */
123 TMCLOCK enmClock;
124 /** Timer callback type. */
125 TMTIMERTYPE enmType;
126 /** Type specific data. */
127 union
128 {
129 /** TMTIMERTYPE_DEV. */
130 struct
131 {
132 /** Callback. */
133 R3PTRTYPE(PFNTMTIMERDEV) pfnTimer;
134 /** Device instance. */
135 PPDMDEVINSR3 pDevIns;
136 } Dev;
137
138 /** TMTIMERTYPE_DRV. */
139 struct
140 {
141 /** Callback. */
142 R3PTRTYPE(PFNTMTIMERDRV) pfnTimer;
143 /** Device instance. */
144 R3PTRTYPE(PPDMDRVINS) pDrvIns;
145 } Drv;
146
147 /** TMTIMERTYPE_INTERNAL. */
148 struct
149 {
150 /** Callback. */
151 R3PTRTYPE(PFNTMTIMERINT) pfnTimer;
152 /** User argument. */
153 RTR3PTR pvUser;
154 } Internal;
155
156 /** TMTIMERTYPE_EXTERNAL. */
157 struct
158 {
159 /** Callback. */
160 R3PTRTYPE(PFNTMTIMEREXT) pfnTimer;
161 /** User data. */
162 RTR3PTR pvUser;
163 } External;
164 } u;
165
166 /** Timer state. */
167 volatile TMTIMERSTATE enmState;
168 /** Timer relative offset to the next timer in the schedule list. */
169 int32_t volatile offScheduleNext;
170
171 /** Timer relative offset to the next timer in the chain. */
172 int32_t offNext;
173 /** Timer relative offset to the previous timer in the chain. */
174 int32_t offPrev;
175
176 /** Pointer to the next timer in the list of created or free timers. (TM::pTimers or TM::pFree) */
177 PTMTIMERR3 pBigNext;
178 /** Pointer to the previous timer in the list of all created timers. (TM::pTimers) */
179 PTMTIMERR3 pBigPrev;
180 /** Pointer to the timer description. */
181 R3PTRTYPE(const char *) pszDesc;
182 /** Pointer to the VM the timer belongs to - R3 Ptr. */
183 PVMR3 pVMR3;
184 /** Pointer to the VM the timer belongs to - R0 Ptr. */
185 PVMR0 pVMR0;
186 /** Pointer to the VM the timer belongs to - RC Ptr. */
187 PVMRC pVMRC;
188#if HC_ARCH_BITS == 64
189 RTRCPTR padding0; /**< pad structure to multiple of 8 bytes. */
190#endif
191} TMTIMER;
192AssertCompileMemberSize(TMTIMER, enmState, sizeof(uint32_t));
193
194
195/**
196 * Updates a timer state in the correct atomic manner.
197 */
198#if 1
199# define TM_SET_STATE(pTimer, state) \
200 ASMAtomicWriteU32((uint32_t volatile *)&(pTimer)->enmState, state)
201#else
202# define TM_SET_STATE(pTimer, state) \
203 do { \
204 uint32_t uOld1 = (pTimer)->enmState; \
205 Log(("%s: %p: %d -> %d\n", __FUNCTION__, (pTimer), (pTimer)->enmState, state)); \
206 uint32_t uOld2 = ASMAtomicXchgU32((uint32_t volatile *)&(pTimer)->enmState, state); \
207 Assert(uOld1 == uOld2); \
208 } while (0)
209#endif
210
211/**
212 * Tries to updates a timer state in the correct atomic manner.
213 */
214#if 1
215# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
216 (fRc) = ASMAtomicCmpXchgU32((uint32_t volatile *)&(pTimer)->enmState, StateNew, StateOld)
217#else
218# define TM_TRY_SET_STATE(pTimer, StateNew, StateOld, fRc) \
219 do { (fRc) = ASMAtomicCmpXchgU32((uint32_t volatile *)&(pTimer)->enmState, StateNew, StateOld); \
220 Log(("%s: %p: %d -> %d %RTbool\n", __FUNCTION__, (pTimer), StateOld, StateNew, fRc)); \
221 } while (0)
222#endif
223
224/** Get the previous timer. */
225#define TMTIMER_GET_PREV(pTimer) ((PTMTIMER)((pTimer)->offPrev ? (intptr_t)(pTimer) + (pTimer)->offPrev : 0))
226/** Get the next timer. */
227#define TMTIMER_GET_NEXT(pTimer) ((PTMTIMER)((pTimer)->offNext ? (intptr_t)(pTimer) + (pTimer)->offNext : 0))
228/** Set the previous timer link. */
229#define TMTIMER_SET_PREV(pTimer, pPrev) ((pTimer)->offPrev = (pPrev) ? (intptr_t)(pPrev) - (intptr_t)(pTimer) : 0)
230/** Set the next timer link. */
231#define TMTIMER_SET_NEXT(pTimer, pNext) ((pTimer)->offNext = (pNext) ? (intptr_t)(pNext) - (intptr_t)(pTimer) : 0)
232
233
234/**
235 * A timer queue.
236 *
237 * This is allocated on the hyper heap.
238 */
239typedef struct TMTIMERQUEUE
240{
241 /** The cached expire time for this queue.
242 * Updated by EMT when scheduling the queue or modifying the head timer.
243 * Assigned UINT64_MAX when there is no head timer. */
244 uint64_t u64Expire;
245 /** Doubly linked list of active timers.
246 *
247 * When no scheduling is pending, this list is will be ordered by expire time (ascending).
248 * Access is serialized by only letting the emulation thread (EMT) do changes.
249 *
250 * The offset is relative to the queue structure.
251 */
252 int32_t offActive;
253 /** List of timers pending scheduling of some kind.
254 *
255 * Timer stats allowed in the list are TMTIMERSTATE_PENDING_STOPPING,
256 * TMTIMERSTATE_PENDING_DESTRUCTION, TMTIMERSTATE_PENDING_STOPPING_DESTRUCTION,
257 * TMTIMERSTATE_PENDING_RESCHEDULING and TMTIMERSTATE_PENDING_SCHEDULE.
258 *
259 * The offset is relative to the queue structure.
260 */
261 int32_t volatile offSchedule;
262 /** The clock for this queue. */
263 TMCLOCK enmClock;
264 /** Pad the structure up to 32 bytes. */
265 uint32_t au32Padding[3];
266} TMTIMERQUEUE;
267
268/** Pointer to a timer queue. */
269typedef TMTIMERQUEUE *PTMTIMERQUEUE;
270
271/** Get the head of the active timer list. */
272#define TMTIMER_GET_HEAD(pQueue) ((PTMTIMER)((pQueue)->offActive ? (intptr_t)(pQueue) + (pQueue)->offActive : 0))
273/** Set the head of the active timer list. */
274#define TMTIMER_SET_HEAD(pQueue, pHead) ((pQueue)->offActive = pHead ? (intptr_t)pHead - (intptr_t)(pQueue) : 0)
275
276
277/**
278 * Converts a TM pointer into a VM pointer.
279 * @returns Pointer to the VM structure the TM is part of.
280 * @param pTM Pointer to TM instance data.
281 */
282#define TM2VM(pTM) ( (PVM)((char*)pTM - pTM->offVM) )
283
284
285/**
286 * TM VM Instance data.
287 * Changes to this must checked against the padding of the cfgm union in VM!
288 */
289typedef struct TM
290{
291 /** Offset to the VM structure.
292 * See TM2VM(). */
293 RTUINT offVM;
294
295 /** Set if we fully virtualize the TSC, i.e. intercept all rdtsc instructions.
296 * Config variable: TSCVirtualized (bool) */
297 bool fTSCVirtualized;
298 /** Set if we use the real TSC as time source or if we use the virtual clock.
299 * If fTSCVirtualized is set we maintain a offset to the TSC and pausing/resuming the
300 * ticking. fTSCVirtualized = false implies fTSCUseRealTSC = true.
301 * Config variable: TSCUseRealTSC (bool) */
302 bool fTSCUseRealTSC;
303 /** Flag indicating that the host TSC is suitable for use in AMD-V and VT-x mode.
304 * Config variable: MaybeUseOffsettedHostTSC (boolean) */
305 bool fMaybeUseOffsettedHostTSC;
306 /** Whether the TSC is tied to the execution of code.
307 * Config variable: TSCTiedToExecution (bool) */
308 bool fTSCTiedToExecution;
309 /** Modifier for fTSCTiedToExecution which pauses the TSC while halting if true.
310 * Config variable: TSCNotTiedToHalt (bool) */
311 bool fTSCNotTiedToHalt;
312 bool afAlignment0[6]; /**< alignment padding */
313 /** The number of CPU clock ticks per second (TMCLOCK_TSC).
314 * Config variable: TSCTicksPerSecond (64-bit unsigned int)
315 * The config variable implies fTSCVirtualized = true and fTSCUseRealTSC = false. */
316 uint64_t cTSCTicksPerSecond;
317
318 /** Virtual time ticking enabled indicator (counter for each VCPU). (TMCLOCK_VIRTUAL) */
319 uint32_t volatile cVirtualTicking;
320 /** Virtual time is not running at 100%. */
321 bool fVirtualWarpDrive;
322 /** Virtual timer synchronous time ticking enabled indicator (bool). (TMCLOCK_VIRTUAL_SYNC) */
323 bool volatile fVirtualSyncTicking;
324 /** Virtual timer synchronous time catch-up active. */
325 bool volatile fVirtualSyncCatchUp;
326 bool afAlignment[5]; /**< alignment padding */
327 /** WarpDrive percentage.
328 * 100% is normal (fVirtualSyncNormal == true). When other than 100% we apply
329 * this percentage to the raw time source for the period it's been valid in,
330 * i.e. since u64VirtualWarpDriveStart. */
331 uint32_t u32VirtualWarpDrivePercentage;
332
333 /** The offset of the virtual clock relative to it's timesource.
334 * Only valid if fVirtualTicking is set. */
335 uint64_t u64VirtualOffset;
336 /** The guest virtual time when fVirtualTicking is cleared. */
337 uint64_t u64Virtual;
338 /** When the Warp drive was started or last adjusted.
339 * Only valid when fVirtualWarpDrive is set. */
340 uint64_t u64VirtualWarpDriveStart;
341 /** The previously returned nano TS.
342 * This handles TSC drift on SMP systems and expired interval.
343 * This is a valid range u64NanoTS to u64NanoTS + 1000000000 (ie. 1sec). */
344 uint64_t volatile u64VirtualRawPrev;
345 /** The ring-3 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
346 RTTIMENANOTSDATAR3 VirtualGetRawDataR3;
347 /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
348 RTTIMENANOTSDATAR0 VirtualGetRawDataR0;
349 /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */
350 RTTIMENANOTSDATARC VirtualGetRawDataRC;
351 /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
352 R3PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR3;
353 /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
354 R0PTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawR0;
355 /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */
356 RCPTRTYPE(PFNTIMENANOTSINTERNAL) pfnVirtualGetRawRC;
357 /** Alignment. */
358 RTRCPTR AlignmentRCPtr;
359 /** The guest virtual timer synchronous time when fVirtualSyncTicking is cleared. */
360 uint64_t volatile u64VirtualSync;
361 /** The offset of the timer synchronous virtual clock (TMCLOCK_VIRTUAL_SYNC) relative
362 * to the virtual clock (TMCLOCK_VIRTUAL).
363 * (This is accessed by the timer thread and must be updated atomically.) */
364 uint64_t volatile offVirtualSync;
365 /** The offset into offVirtualSync that's been irrevocably given up by failed catch-up attempts.
366 * Thus the current lag is offVirtualSync - offVirtualSyncGivenUp. */
367 uint64_t offVirtualSyncGivenUp;
368 /** The TMCLOCK_VIRTUAL at the previous TMVirtualGetSync call when catch-up is active. */
369 uint64_t volatile u64VirtualSyncCatchUpPrev;
370 /** The current catch-up percentage. */
371 uint32_t volatile u32VirtualSyncCatchUpPercentage;
372 /** How much slack when processing timers. */
373 uint32_t u32VirtualSyncScheduleSlack;
374 /** When to stop catch-up. */
375 uint64_t u64VirtualSyncCatchUpStopThreshold;
376 /** When to give up catch-up. */
377 uint64_t u64VirtualSyncCatchUpGiveUpThreshold;
378/** @def TM_MAX_CATCHUP_PERIODS
379 * The number of catchup rates. */
380#define TM_MAX_CATCHUP_PERIODS 10
381 /** The agressivness of the catch-up relative to how far we've lagged behind.
382 * The idea is to have increasing catch-up percentage as the lag increases. */
383 struct TMCATCHUPPERIOD
384 {
385 uint64_t u64Start; /**< When this period starts. (u64VirtualSyncOffset). */
386 uint32_t u32Percentage; /**< The catch-up percent to apply. */
387 uint32_t u32Alignment; /**< Structure alignment */
388 } aVirtualSyncCatchUpPeriods[TM_MAX_CATCHUP_PERIODS];
389
390 /** The UTC offset in ns.
391 * This is *NOT* for converting UTC to local time. It is for converting real
392 * world UTC time to VM UTC time. This feature is indented for doing date
393 * testing of software and similar.
394 * @todo Implement warpdrive on UTC. */
395 int64_t offUTC;
396
397 /** Timer queues for the different clock types - R3 Ptr */
398 R3PTRTYPE(PTMTIMERQUEUE) paTimerQueuesR3;
399 /** Timer queues for the different clock types - R0 Ptr */
400 R0PTRTYPE(PTMTIMERQUEUE) paTimerQueuesR0;
401 /** Timer queues for the different clock types - RC Ptr */
402 RCPTRTYPE(PTMTIMERQUEUE) paTimerQueuesRC;
403
404 /** Pointer to our RC mapping of the GIP. */
405 RCPTRTYPE(void *) pvGIPRC;
406 /** Pointer to our R3 mapping of the GIP. */
407 R3PTRTYPE(void *) pvGIPR3;
408
409 /** Pointer to a singly linked list of free timers.
410 * This chain is using the TMTIMER::pBigNext members.
411 * Only accessible from the emulation thread. */
412 PTMTIMERR3 pFree;
413
414 /** Pointer to a doubly linked list of created timers.
415 * This chain is using the TMTIMER::pBigNext and TMTIMER::pBigPrev members.
416 * Only accessible from the emulation thread. */
417 PTMTIMERR3 pCreated;
418
419 /** The schedulation timer timer handle (runtime timer).
420 * This timer will do freqent check on pending queue schedulations and
421 * raise VM_FF_TIMER to pull EMTs attention to them.
422 */
423 R3PTRTYPE(PRTTIMER) pTimer;
424 /** Interval in milliseconds of the pTimer timer. */
425 uint32_t u32TimerMillies;
426
427 /** Makes sure only one EMT is running the queues. */
428 bool volatile fRunningQueues;
429
430 /** Lock serializing EMT access to TM. */
431 PDMCRITSECT EmtLock;
432
433 /** TMR3TimerQueuesDo
434 * @{ */
435 STAMPROFILE StatDoQueues;
436 STAMPROFILEADV StatDoQueuesSchedule;
437 STAMPROFILEADV StatDoQueuesRun;
438 /** @} */
439 /** tmSchedule
440 * @{ */
441 STAMPROFILE StatScheduleOneRZ;
442 STAMPROFILE StatScheduleOneR3;
443 STAMCOUNTER StatScheduleSetFF;
444 STAMCOUNTER StatPostponedR3;
445 STAMCOUNTER StatPostponedRZ;
446 /** @} */
447 /** Read the time
448 * @{ */
449 STAMCOUNTER StatVirtualGet;
450 STAMCOUNTER StatVirtualGetSetFF;
451 STAMCOUNTER StatVirtualGetSync;
452 STAMCOUNTER StatVirtualGetSyncSetFF;
453 STAMCOUNTER StatVirtualPause;
454 STAMCOUNTER StatVirtualResume;
455 /* @} */
456 /** TMTimerPoll
457 * @{ */
458 STAMCOUNTER StatPollAlreadySet;
459 STAMCOUNTER StatPollVirtual;
460 STAMCOUNTER StatPollVirtualSync;
461 STAMCOUNTER StatPollMiss;
462 /** @} */
463 /** TMTimerSet
464 * @{ */
465 STAMPROFILE StatTimerSetRZ;
466 STAMPROFILE StatTimerSetR3;
467 /** @} */
468 /** TMTimerStop
469 * @{ */
470 STAMPROFILE StatTimerStopRZ;
471 STAMPROFILE StatTimerStopR3;
472 /** @} */
473 /** VirtualSync - Running and Catching Up
474 * @{ */
475 STAMCOUNTER StatVirtualSyncRun;
476 STAMCOUNTER StatVirtualSyncRunRestart;
477 STAMPROFILE StatVirtualSyncRunSlack;
478 STAMCOUNTER StatVirtualSyncRunStop;
479 STAMCOUNTER StatVirtualSyncRunStoppedAlready;
480 STAMCOUNTER StatVirtualSyncGiveUp;
481 STAMCOUNTER StatVirtualSyncGiveUpBeforeStarting;
482 STAMPROFILEADV StatVirtualSyncCatchup;
483 STAMCOUNTER aStatVirtualSyncCatchupInitial[TM_MAX_CATCHUP_PERIODS];
484 STAMCOUNTER aStatVirtualSyncCatchupAdjust[TM_MAX_CATCHUP_PERIODS];
485 /** @} */
486 /** The timer callback. */
487 STAMCOUNTER StatTimerCallbackSetFF;
488
489 /** @name Reasons for refusing TSC offsetting in TMCpuTickCanUseRealTSC.
490 * @{ */
491 STAMCOUNTER StatTSCNotFixed;
492 STAMCOUNTER StatTSCNotTicking;
493 STAMCOUNTER StatTSCCatchupLE010;
494 STAMCOUNTER StatTSCCatchupLE025;
495 STAMCOUNTER StatTSCCatchupLE100;
496 STAMCOUNTER StatTSCCatchupOther;
497 STAMCOUNTER StatTSCWarp;
498 STAMCOUNTER StatTSCSyncNotTicking;
499 /** @} */
500} TM;
501/** Pointer to TM VM instance data. */
502typedef TM *PTM;
503
504/**
505 * TM VMCPU Instance data.
506 * Changes to this must checked against the padding of the tm union in VM!
507 */
508typedef struct TMCPU
509{
510 /** Offset to the VMCPU structure.
511 * See TMCPU2VM(). */
512 RTUINT offVMCPU;
513
514 /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */
515 bool fTSCTicking;
516 bool afAlignment0[3]; /**< alignment padding */
517
518 /** The offset between the host TSC and the Guest TSC.
519 * Only valid if fTicking is set and and fTSCUseRealTSC is clear. */
520 uint64_t u64TSCOffset;
521
522 /** The guest TSC when fTicking is cleared. */
523 uint64_t u64TSC;
524
525} TMCPU;
526/** Pointer to TM VMCPU instance data. */
527typedef TMCPU *PTMCPU;
528
529#if 0 /* enable this to rule out locking bugs on single cpu guests. */
530# define tmLock(pVM) VINF_SUCCESS
531# define tmTryLock(pVM) VINF_SUCCESS
532# define tmUnlock(pVM) ((void)0)
533# define TM_ASSERT_EMT_LOCK(pVM) VM_ASSERT_EMT(pVM)
534#else
535int tmLock(PVM pVM);
536int tmTryLock(PVM pVM);
537void tmUnlock(PVM pVM);
538/** Checks that the caller owns the EMT lock. */
539#define TM_ASSERT_EMT_LOCK(pVM) Assert(PDMCritSectIsOwner(&pVM->tm.s.EmtLock))
540#endif
541
542const char *tmTimerState(TMTIMERSTATE enmState);
543void tmTimerQueueSchedule(PVM pVM, PTMTIMERQUEUE pQueue);
544#ifdef VBOX_STRICT
545void tmTimerQueuesSanityChecks(PVM pVM, const char *pszWhere);
546#endif
547
548int tmCpuTickPause(PVM pVM, PVMCPU pVCpu);
549int tmCpuTickResume(PVM pVM, PVMCPU pVCpu);
550
551DECLEXPORT(void) tmVirtualNanoTSBad(PRTTIMENANOTSDATA pData, uint64_t u64NanoTS, uint64_t u64DeltaPrev, uint64_t u64PrevNanoTS);
552DECLEXPORT(uint64_t) tmVirtualNanoTSRediscover(PRTTIMENANOTSDATA pData);
553
554
555/** @} */
556
557__END_DECLS
558
559#endif
560
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