#ifndef QEMU_TIMER_H
#define QEMU_TIMER_H
#include "qemu-common.h"
/* timers */
#ifndef VBOX
/* The real time clock should be used only for stuff which does not
change the virtual machine state, as it is run even if the virtual
machine is stopped. The real time clock has a frequency of 1000
Hz. */
/* The virtual clock is only run during the emulation. It is stopped
when the virtual machine is stopped. Virtual timers use a high
precision clock, usually cpu cycles (use ticks_per_sec). */
/* The host clock should be use for device models that emulate accurate
real time sources. It will continue to run when the virtual machine
is suspended, and it will reflect system time changes the host may
undergo (e.g. due to NTP). The host clock has the same precision as
the virtual clock. */
extern QEMUClock *host_clock;
void qemu_run_all_timers(void);
int qemu_alarm_pending(void);
int64_t qemu_next_deadline(void);
void configure_alarms(char const *opt);
void configure_icount(const char *option);
int qemu_calculate_timeout(void);
void init_clocks(void);
int init_timer_alarm(void);
void quit_timers(void);
{
return 1000000000LL;
}
/* ptimer.c */
void ptimer_stop(ptimer_state *s);
/* icount */
extern int64_t qemu_icount;
#endif /* !VBOX */
extern int use_icount;
#ifndef VBOX
extern int icount_time_shift;
extern int64_t qemu_icount_bias;
int64_t cpu_get_icount(void);
/*******************************************/
/* host CPU ticks (if available) */
#if defined(_ARCH_PPC)
{
#ifdef _ARCH_PPC64
/* This reads timebase in one 64bit go and includes Cell workaround from:
*/
"cmpwi %0,0\n\t"
"beq- $-8"
: "=r" (retval));
#else
unsigned long junk;
"mfspr %L0,268\n\t" /* mftb */
"mfspr %0,269\n\t" /* mftbu */
"cmpw %0,%1\n\t"
"bne $-16"
#endif
return retval;
}
{
return val;
}
#elif defined(__x86_64__)
{
val <<= 32;
return val;
}
{
int val;
return val;
}
{
return val;
}
{
return val;
}
{
#if defined(_LP64)
return rval;
#else
union {
struct {
} i32;
} rval;
asm volatile("rd %%tick,%1; srlx %1,32,%0"
#endif
}
/*
* binutils wants to use rdhwr only on mips32r2
* but as linux kernel emulate it, it's fine
* to use it.
*
*/
".set mips32r2\n\t" \
".set pop" \
: "=r" (value)); \
}
{
/* On kernels >= 2.6.25 rdhwr <reg>, $2 and $3 are emulated */
if (!cyc_per_count) {
}
}
{
}
#else
/* The host CPU doesn't have an easily accessible cycle counter.
Just return a monotonically increasing value. This will be
totally wrong, but hopefully better than nothing. */
{
return ticks++;
}
#endif
#endif /* !VBOX */
#ifdef NEED_CPU_H
/* Deterministic execution requires that IO only be performed on the last
instruction of a TB so that interrupts take effect immediately. */
{
if (!use_icount)
return 1;
/* If not executing code then assume we are ok. */
if (!env->current_tb)
return 1;
}
#endif
#ifndef VBOX
#ifdef CONFIG_PROFILER
{
return cpu_get_real_ticks();
}
extern int64_t tlb_flush_time;
#endif
#endif /* !VBOX */
#endif