From 29e922b61fb3d93836825ca9731bb2cadbb6ed72 Mon Sep 17 00:00:00 2001 From: Blue Swirl Date: Mon, 29 Mar 2010 19:24:00 +0000 Subject: Compile qemu-timer only once Arrange various declarations so that also non-CPU code can access them, adjust users. Move CPU specific code to cpus.c. Signed-off-by: Blue Swirl --- cpus.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cpus.c') diff --git a/cpus.c b/cpus.c index 9a8c2f7ae..a2e0642a4 100644 --- a/cpus.c +++ b/cpus.c @@ -771,3 +771,19 @@ void set_cpu_log(const char *optarg) } cpu_set_log(mask); } + +/* Return the virtual CPU time, based on the instruction counter. */ +int64_t cpu_get_icount(void) +{ + int64_t icount; + CPUState *env = cpu_single_env;; + + icount = qemu_icount; + if (env) { + if (!can_do_io(env)) { + fprintf(stderr, "Bad clock read\n"); + } + icount -= (env->icount_decr.u16.low + env->icount_extra); + } + return qemu_icount_bias + (icount << icount_time_shift); +} -- cgit v1.2.3