aboutsummaryrefslogtreecommitdiffstats
path: root/cpus.c
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2010-03-29 19:24:00 +0000
committerBlue Swirl <blauwirbel@gmail.com>2010-03-29 19:24:00 +0000
commit29e922b61fb3d93836825ca9731bb2cadbb6ed72 (patch)
treeb461e05df4e043c3015857ca95fbfdf704bab059 /cpus.c
parent5c4532ee7894277d8d54db108e891c4204d15f1d (diff)
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 <blauwirbel@gmail.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c16
1 files changed, 16 insertions, 0 deletions
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);
+}