qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/2] trace io operations


From: Glauber Costa
Subject: [Qemu-devel] [PATCH 1/2] trace io operations
Date: Fri, 24 Oct 2008 13:55:15 -0200

Add fields in cpu state to trace reads and writes for both
pio and mmio. Together with it, keep track of the timestamp
in which the last io happened, whatever kind it was. This last
part is particularly useful for us to replace kqemu break-loop
tests by a generic framework without the need for an accelerator
hook.

Signed-off-by: Glauber Costa <address@hidden>
---
 cpu-defs.h         |    6 ++++++
 softmmu_template.h |    8 ++------
 target-i386/cpu.h  |    1 -
 vl.c               |   50 ++++++++++++++++++++++++++------------------------
 4 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/cpu-defs.h b/cpu-defs.h
index 5dcac74..4b401ef 100644
--- a/cpu-defs.h
+++ b/cpu-defs.h
@@ -153,6 +153,12 @@ typedef struct icount_decr_u16 {
                                 accessed */                             \
     target_ulong mem_io_vaddr; /* target virtual addr at which the      \
                                      memory was accessed */             \
+    uint32_t mmio_read_count;                                                \
+    uint32_t pio_read_count;                                                 \
+    uint32_t mmio_write_count;                                                \
+    uint32_t pio_write_count;                                                 \
+    uint64_t last_io_time;                                              \
+                                                                        \
     uint32_t halted; /* Nonzero if the CPU is in suspend state */       \
     uint32_t interrupt_request;                                         \
     /* The meaning of the MMU modes is defined in the target code. */   \
diff --git a/softmmu_template.h b/softmmu_template.h
index 98dd378..cdfcb38 100644
--- a/softmmu_template.h
+++ b/softmmu_template.h
@@ -75,9 +75,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
+    trace_mmio(env, 0);
     return res;
 }
 
@@ -220,9 +218,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
+    trace_mmio(env, 1);
 }
 
 void REGPARM glue(glue(__st, SUFFIX), MMUSUFFIX)(target_ulong addr,
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 3c11e0f..8a2d797 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -608,7 +608,6 @@ typedef struct CPUX86State {
 
 #ifdef USE_KQEMU
     int kqemu_enabled;
-    int last_io_time;
 #endif
     /* in order to simplify APIC support, we leave this pointer to the
        user */
diff --git a/vl.c b/vl.c
index 16d3e96..dfec9ff 100644
--- a/vl.c
+++ b/vl.c
@@ -263,6 +263,26 @@ PicState2 *isa_pic;
 static IOPortReadFunc default_ioport_readb, default_ioport_readw, 
default_ioport_readl;
 static IOPortWriteFunc default_ioport_writeb, default_ioport_writew, 
default_ioport_writel;
 
+void trace_pio(CPUState *env, int write)
+{
+    if (write)
+        env->pio_write_count++;
+    else
+        env->pio_read_count++;
+
+    env->last_io_time = cpu_get_real_ticks();
+}
+
+void trace_mmio(CPUState *env, int write)
+{
+    if (write)
+        env->mmio_write_count++;
+    else
+        env->mmio_read_count++;
+
+    env->last_io_time = cpu_get_real_ticks();
+}
+
 static void qemu_io_interrupt(CPUState *env)
 {
     if (env) {
@@ -422,10 +442,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
+    trace_pio(env, 1);
 }
 
 void cpu_outw(CPUState *env, int addr, int val)
@@ -435,10 +452,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
+    trace_pio(env, 1);
 }
 
 void cpu_outl(CPUState *env, int addr, int val)
@@ -448,10 +462,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
+    trace_pio(env, 1);
 }
 
 int cpu_inb(CPUState *env, int addr)
@@ -462,10 +473,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
+    trace_pio(env, 0);
     return val;
 }
 
@@ -477,10 +485,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
+    trace_pio(env, 0);
     return val;
 }
 
@@ -492,10 +497,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
+    trace_pio(env, 0);
     return val;
 }
 
-- 
1.5.5.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]