diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-05-20 14:02:14 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2004-05-20 14:02:14 +0000 |
commit | 28ab0e2edb36685da7280b24e665962754d9e4ff (patch) | |
tree | 7b199a68728ce9eac44a67f8016fb282a0636df7 /linux-user | |
parent | b54ad0498e58cd81f35f815ecb887af2f44ab6f6 (diff) |
added cpu_get_tsc()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@837 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/main.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index ae4f6a5ac7..c0759bfefc 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -99,10 +99,50 @@ int cpu_get_pic_interrupt(CPUState *env) return -1; } +/* timers for rdtsc */ + +#if defined(__i386__) + +int64_t cpu_get_real_ticks(void) +{ + int64_t val; + asm volatile ("rdtsc" : "=A" (val)); + return val; +} + +#elif defined(__x86_64__) + +int64_t cpu_get_real_ticks(void) +{ + uint32_t low,high; + int64_t val; + asm volatile("rdtsc" : "=a" (low), "=d" (high)); + val = high; + val <<= 32; + val |= low; + return val; +} + +#else + +static uint64_t emu_time; + +int64_t cpu_get_real_ticks(void) +{ + return emu_time++; +} + +#endif + #ifdef TARGET_I386 /***********************************************************/ /* CPUX86 core interface */ +uint64_t cpu_get_tsc(CPUX86State *env) +{ + return cpu_get_real_ticks(); +} + static void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags) { |