From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KqCWc-0001bt-8h for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:59:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KqCWZ-0001aS-6X for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:59:16 -0400 Received: from [199.232.76.173] (port=36806 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KqCWZ-0001aH-1Y for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:59:15 -0400 Received: from mx2.redhat.com ([66.187.237.31]:49533) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KqCWY-0001OJ-2e for qemu-devel@nongnu.org; Wed, 15 Oct 2008 15:59:14 -0400 From: Glauber Costa Date: Wed, 15 Oct 2008 19:55:14 -0200 Message-Id: <1224107718-19128-18-git-send-email-glommer@redhat.com> In-Reply-To: <1224107718-19128-1-git-send-email-glommer@redhat.com> References: <1224107718-19128-1-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 17/21] accel_trace_io Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, jan.kiszka@siemens.com, jes@sgi.com, avi@qumranet.com, Glauber Costa , dmitry.baryshkov@siemens.com From: Glauber Costa kqemu keeps trace of the last io done. Do it through an accel_wrapper. Signed-off-by: Glauber Costa --- accel.c | 2 ++ accel.h | 13 ++++++++++++- cpu-exec.c | 9 ++------- kqemu.c | 18 ++++++++++++++++++ softmmu_template.h | 10 ++++------ vl.c | 30 ++++++------------------------ 6 files changed, 44 insertions(+), 38 deletions(-) diff --git a/accel.c b/accel.c index 99a4eb1..6517af2 100644 --- a/accel.c +++ b/accel.c @@ -32,5 +32,7 @@ QEMUAccel noaccel = { .get_real_ticks = cpu_get_ticks, #endif .register_physical_memory = accel_nop, + .trace_io = accel_nop, + .break_loop = accel_nop, }; diff --git a/accel.h b/accel.h index 0811aa9..5f04163 100644 --- a/accel.h +++ b/accel.h @@ -17,7 +17,8 @@ typedef struct QEMUAccel { #endif void (*register_physical_memory)(uint64_t start_addr, ram_addr_t size, ram_addr_t phys_offset); - + void (*trace_io)(CPUState *env); + int (*break_loop)(CPUState *env); } QEMUAccel; typedef struct QEMUCont { @@ -140,4 +141,14 @@ static inline void accel_register_phys_mem(uint64_t start_addr, { current_accel->register_physical_memory(start_addr, size, phys_offset); } + +static inline void accel_trace_io(CPUState *env) +{ + current_accel->trace_io(env); +} + +static inline int accel_break_loop(CPUState *env) +{ + return current_accel->break_loop(env); +} #endif diff --git a/cpu-exec.c b/cpu-exec.c index 6d4dcdd..ce4e8a2 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -36,6 +36,7 @@ #include #include #endif +#include "accel.h" #if defined(__sparc__) && !defined(HOST_SOLARIS) // Work around ugly bugs in glibc that mangle global register contents @@ -653,13 +654,7 @@ int cpu_exec(CPUState *env1) } /* reset soft MMU for next block (it can currently only be set by a memory fault) */ -#if defined(USE_KQEMU) -#define MIN_CYCLE_BEFORE_SWITCH (100 * 1000) - if (kqemu_is_ok(env) && - (cpu_get_time_fast() - env->last_io_time) >= MIN_CYCLE_BEFORE_SWITCH) { - cpu_loop_exit(); - } -#endif + accel_break_loop(env); } /* for(;;) */ } else { env_to_regs(); diff --git a/kqemu.c b/kqemu.c index 248c4f5..58e9e3f 100644 --- a/kqemu.c +++ b/kqemu.c @@ -433,6 +433,22 @@ void kqemu_set_phys_mem(uint64_t start_addr, ram_addr_t size, } } +void kqemu_trace_io(CPUState *env) +{ + if (env) + env->last_io_time = cpu_get_time_fast(); +} + +int kqemu_break_loop(CPUState *env) +{ +#define MIN_CYCLE_BEFORE_SWITCH (100 * 1000) + if (kqemu_is_ok(env) && + (cpu_get_time_fast() - env->last_io_time) >= MIN_CYCLE_BEFORE_SWITCH) { + return 1; + } + return 0; +} + QEMUAccel kqemu_accel = { .name = "KQEMU", .cpu_interrupt = kqemu_cpu_interrupt, @@ -451,6 +467,8 @@ QEMUAccel kqemu_accel = { .get_real_ticks = cpu_get_real_ticks, #endif .register_physical_memory = kqemu_set_phys_mem, + .trace_io = kqemu_trace_io, + .break_loop = kqemu_break_loop, }; struct fpstate { diff --git a/softmmu_template.h b/softmmu_template.h index 98dd378..4945352 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -47,6 +47,8 @@ #define ADDR_READ addr_read #endif +#include "accel.h" + static DATA_TYPE glue(glue(slow_ld, SUFFIX), MMUSUFFIX)(target_ulong addr, int mmu_idx, void *retaddr); @@ -75,9 +77,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(target_phys_addr_t physaddr, res |= (uint64_t)io_mem_read[index][2](io_mem_opaque[index], physaddr + 4) << 32; #endif #endif /* SHIFT > 2 */ -#ifdef USE_KQEMU - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return res; } @@ -220,9 +220,7 @@ static inline void glue(io_write, SUFFIX)(target_phys_addr_t physaddr, io_mem_write[index][2](io_mem_opaque[index], physaddr + 4, val >> 32); #endif #endif /* SHIFT > 2 */ -#ifdef USE_KQEMU - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr, diff --git a/vl.c b/vl.c index f7a58ef..409ae0e 100644 --- a/vl.c +++ b/vl.c @@ -420,10 +420,7 @@ void cpu_outb(CPUState *env, int addr, int val) fprintf(logfile, "outb: %04x %02x\n", addr, val); #endif ioport_write(0, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void cpu_outw(CPUState *env, int addr, int val) @@ -433,10 +430,7 @@ void cpu_outw(CPUState *env, int addr, int val) fprintf(logfile, "outw: %04x %04x\n", addr, val); #endif ioport_write(1, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } void cpu_outl(CPUState *env, int addr, int val) @@ -446,10 +440,7 @@ void cpu_outl(CPUState *env, int addr, int val) fprintf(logfile, "outl: %04x %08x\n", addr, val); #endif ioport_write(2, addr, val); -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); } int cpu_inb(CPUState *env, int addr) @@ -460,10 +451,7 @@ int cpu_inb(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inb : %04x %02x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } @@ -475,10 +463,7 @@ int cpu_inw(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inw : %04x %04x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } @@ -490,10 +475,7 @@ int cpu_inl(CPUState *env, int addr) if (loglevel & CPU_LOG_IOPORT) fprintf(logfile, "inl : %04x %08x\n", addr, val); #endif -#ifdef USE_KQEMU - if (env) - env->last_io_time = cpu_get_time_fast(); -#endif + accel_trace_io(env); return val; } -- 1.5.5.1