TMInternal.h revision 43747b1f0bc8302a238fb35e55857a5e9aa1933d
/** Timer is expired, getting expire and unlinking. */ /** Timer is expired and is being delivered. */ /** Timer is stopped but still in the active list. * Currently in the ScheduleTimers list. */ /** Timer is stopped but needs unlinking from the ScheduleTimers list. * Currently in the ScheduleTimers list. */ /** Timer is being modified and will soon be pending scheduling. * Currently in the ScheduleTimers list. */ /** Timer is pending scheduling. * Currently in the ScheduleTimers list. */ /** Timer is being modified and will soon be pending rescheduling. * Currently in the ScheduleTimers list and the active list. */ /** Timer is modified and is now pending rescheduling. * Currently in the ScheduleTimers list and the active list. */ /** Timer is being destroyed. */ /** Predicate that returns true if the give state is pending scheduling or * rescheduling of any kind. Will reference the argument more than once! */ * Internal representation of a timer. * For correct serialization (without the use of semaphores and * other blocking/slow constructs) certain rules applies to updating * - For thread other than EMT only u64Expire, enmState and pScheduleNext* * are changeable. Everything else is out of bounds. * - Updating of u64Expire timer can only happen in the TMTIMERSTATE_STOPPED * and TMTIMERSTATE_PENDING_RESCHEDULING_SET_EXPIRE states. * - Timers in the TMTIMERSTATE_EXPIRED state are only accessible from EMT. * - Actual destruction of a timer can only be done at scheduling time. /** Clock to apply to u64Expire. */ /** Timer callback type. */ /** Type specific data. */ /** TMTIMERTYPE_INTERNAL. */ /** TMTIMERTYPE_EXTERNAL. */ /** Timer relative offset to the next timer in the schedule list. */ /** Timer relative offset to the next timer in the chain. */ /** Timer relative offset to the previous timer in the chain. */ /** Pointer to the VM the timer belongs to - R3 Ptr. */ /** Pointer to the VM the timer belongs to - R0 Ptr. */ /** Pointer to the VM the timer belongs to - RC Ptr. */ /** The timer frequency hint. This is 0 if not hint was given. */ /** The critical section associated with the lock. */ /** Pointer to the next timer in the list of created or free timers. (TM::pTimers or TM::pFree) */ /** Pointer to the previous timer in the list of all created timers. (TM::pTimers) */ /** Pointer to the timer description. */ * Updates a timer state in the correct atomic manner. * Tries to updates a timer state in the correct atomic manner. /** Get the previous timer. */ /** Get the next timer. */ /** Set the previous timer link. */ /** Set the next timer link. */ * This is allocated on the hyper heap. /** The cached expire time for this queue. * Updated by EMT when scheduling the queue or modifying the head timer. * Assigned UINT64_MAX when there is no head timer. */ /** Doubly linked list of active timers. * When no scheduling is pending, this list is will be ordered by expire time (ascending). * Access is serialized by only letting the emulation thread (EMT) do changes. * The offset is relative to the queue structure. /** List of timers pending scheduling of some kind. * Timer stats allowed in the list are TMTIMERSTATE_PENDING_STOPPING, * TMTIMERSTATE_PENDING_DESTRUCTION, TMTIMERSTATE_PENDING_STOPPING_DESTRUCTION, * TMTIMERSTATE_PENDING_RESCHEDULING and TMTIMERSTATE_PENDING_SCHEDULE. * The offset is relative to the queue structure. /** The clock for this queue. */ /** Pad the structure up to 32 bytes. */ /** Pointer to a timer queue. */ /** Get the head of the active timer list. */ /** Set the head of the active timer list. */ * Mainly used by tmR3CpuLoadTimer. /** The percent of the period spent executing guest code. */ /** The percent of the period spent halted. */ /** The percent of the period spent on other things. */ /** Explicit alignment padding */ /** Previous cNsTotal value. */ /** Previous cNsExecuting value. */ /** Previous cNsHalted value. */ /** Pointer to a CPU load data set. */ * Converts a TM pointer into a VM pointer. * @returns Pointer to the VM structure the TM is part of. * @param pTM Pointer to TM instance data. * Changes to this must checked against the padding of the cfgm union in VM! /** Offset to the VM structure. /** Set if we fully virtualize the TSC, i.e. intercept all rdtsc instructions. * Config variable: TSCVirtualized (bool) */ /** Set if we use the real TSC as time source or if we use the virtual clock. * If fTSCVirtualized is set we maintain a offset to the TSC and pausing/resuming the * ticking. fTSCVirtualized = false implies fTSCUseRealTSC = true. * Config variable: TSCUseRealTSC (bool) */ /** Flag indicating that the host TSC is suitable for use in AMD-V and VT-x mode. * Config variable: MaybeUseOffsettedHostTSC (boolean) */ /** Whether the TSC is tied to the execution of code. * Config variable: TSCTiedToExecution (bool) */ /** Modifier for fTSCTiedToExecution which pauses the TSC while halting if true. * Config variable: TSCNotTiedToHalt (bool) */ /** The ID of the virtual CPU that normally runs the timers. */ /** The number of CPU clock ticks per second (TMCLOCK_TSC). * Config variable: TSCTicksPerSecond (64-bit unsigned int) * The config variable implies fTSCVirtualized = true and fTSCUseRealTSC = false. */ /** Virtual time ticking enabled indicator (counter for each VCPU). (TMCLOCK_VIRTUAL) */ /** Virtual time is not running at 100%. */ /** Virtual timer synchronous time ticking enabled indicator (bool). (TMCLOCK_VIRTUAL_SYNC) */ /** Virtual timer synchronous time catch-up active. */ /** WarpDrive percentage. * 100% is normal (fVirtualSyncNormal == true). When other than 100% we apply * this percentage to the raw time source for the period it's been valid in, * i.e. since u64VirtualWarpDriveStart. */ /** The offset of the virtual clock relative to it's timesource. * Only valid if fVirtualTicking is set. */ /** The guest virtual time when fVirtualTicking is cleared. */ /** When the Warp drive was started or last adjusted. * Only valid when fVirtualWarpDrive is set. */ /** The previously returned nano TS. * This handles TSC drift on SMP systems and expired interval. * This is a valid range u64NanoTS to u64NanoTS + 1000000000 (ie. 1sec). */ /** The ring-3 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */ /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */ /** The ring-0 data structure for the RTTimeNanoTS workers used by tmVirtualGetRawNanoTS. */ /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */ /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */ /** Pointer to the ring-3 tmVirtualGetRawNanoTS worker function. */ /** The guest virtual timer synchronous time when fVirtualSyncTicking is cleared. */ /** The offset of the timer synchronous virtual clock (TMCLOCK_VIRTUAL_SYNC) relative * to the virtual clock (TMCLOCK_VIRTUAL). * (This is accessed by the timer thread and must be updated atomically.) */ /** The offset into offVirtualSync that's been irrevocably given up by failed catch-up attempts. * Thus the current lag is offVirtualSync - offVirtualSyncGivenUp. */ /** The TMCLOCK_VIRTUAL at the previous TMVirtualGetSync call when catch-up is active. */ /** The current catch-up percentage. */ /** How much slack when processing timers. */ /** When to stop catch-up. */ /** When to give up catch-up. */ /** @def TM_MAX_CATCHUP_PERIODS * The number of catchup rates. */ /** The aggressiveness of the catch-up relative to how far we've lagged behind. * The idea is to have increasing catch-up percentage as the lag increases. */ /** The current max timer Hz hint. */ /** Whether to recalulate the HzHint next time its queried. */ /** @cfgm{TM/HostHzMax, uint32_t, Hz, 0, UINT32_MAX, 20000} * The max host Hz frequency hint returned by TMCalcHostTimerFrequency. */ * The number of Hz TMCalcHostTimerFrequency adds for the timer CPU. */ * The number of Hz TMCalcHostTimerFrequency adds for the other CPUs. */ * The fudge factor (expressed in percent) that catch-up percentages below * 100% is multiplied by. */ * The fudge factor (expressed in percent) that catch-up percentages * 100%-199% is multiplied by. */ * The fudge factor (expressed in percent) that catch-up percentages * 200%-399% is multiplied by. */ /** The UTC offset in ns. * This is *NOT* for converting UTC to local time. It is for converting real * world UTC time to VM UTC time. This feature is indented for doing date * testing of software and similar. * @todo Implement warpdrive on UTC. */ /** Timer queues for the different clock types - R3 Ptr */ /** Timer queues for the different clock types - R0 Ptr */ /** Timer queues for the different clock types - RC Ptr */ /** Pointer to our RC mapping of the GIP. */ /** Pointer to our R3 mapping of the GIP. */ /** Pointer to a singly linked list of free timers. * This chain is using the TMTIMER::pBigNext members. * Only accessible from the emulation thread. */ /** Pointer to a doubly linked list of created timers. * This chain is using the TMTIMER::pBigNext and TMTIMER::pBigPrev members. * Only accessible from the emulation thread. */ /** The schedule timer timer handle (runtime timer). * This timer will do frequent check on pending queue schedules and * raise VM_FF_TIMER to pull EMTs attention to them. /** Interval in milliseconds of the pTimer timer. */ /** Indicates that queues are being run. */ /** Indicates that the virtual sync queue is being run. */ /** Lock serializing access to the timer lists. */ /** Lock serializing access to the VirtualSync clock. */ /** CPU load state for all the virtual CPUs (tmR3CpuLoadTimer). */ /** VirtualSync - Running and Catching Up /** TMR3VirtualSyncFF (non dedicated EMT). */ /** The timer callback. */ /** Calls to TMCpuTickSet. */ /** @name Reasons for refusing TSC offsetting in TMCpuTickCanUseRealTSC. /** Pointer to TM VM instance data. */ * TM VMCPU Instance data. * Changes to this must checked against the padding of the tm union in VM! /** Offset to the VMCPU structure. /** CPU timestamp ticking enabled indicator (bool). (RDTSC) */ /** The offset between the raw TSC source and the Guest TSC. * Only valid if fTicking is set and and fTSCUseRealTSC is clear. */ /** The guest TSC when fTicking is cleared. */ /** The last seen TSC by the guest. */ /** The nanosecond timestamp of the CPU start or resume. * This is recalculated when the VM is started so that * cNsTotal = RTTimeNanoTS() - u64NsTsStartCpu. */ /** The nanosecond timestamp of the last start-execute notification. */ /** The nanosecond timestamp of the last start-halt notification. */ /** The cNsXXX generation. */ /** Explicit alignment padding. */ /** The number of nanoseconds total run time. * @remarks This is updated when cNsExecuting and cNsHalted are updated. */ /** The number of nanoseconds spent executing. */ /** The number of nanoseconds being halted. */ /** The number of nanoseconds spent on other things. * @remarks This is updated when cNsExecuting and cNsHalted are updated. */ /** The number of halts. */ /** The number of guest execution runs. */ /** Resettable version of cNsTotal. */ /** Resettable version of cNsExecuting. */ /** Long execution intervals. */ /** Short execution intervals . */ /** Tiny execution intervals . */ /** Resettable version of cNsHalted. */ /** Resettable version of cNsOther. */ /** CPU load state for this virtual CPU (tmR3CpuLoadTimer). */ /** Pointer to TM VMCPU instance data. */ #
if 0
/* enable this to rule out locking bugs on single cpu guests. *//** Checks that the caller owns the timer lock. */