]> git.proxmox.com Git - mirror_qemu.git/commitdiff
cpu: Move can_do_io field from CPU_COMMON to CPUState
authorAndreas Färber <afaerber@suse.de>
Mon, 26 Aug 2013 03:15:23 +0000 (05:15 +0200)
committerAndreas Färber <afaerber@suse.de>
Thu, 13 Mar 2014 18:20:46 +0000 (19:20 +0100)
Rename can_do_io() to cpu_can_do_io() and change argument to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
cpus.c
include/exec/cpu-defs.h
include/exec/exec-all.h
include/exec/gen-icount.h
include/exec/softmmu_template.h
include/qom/cpu.h
qom/cpu.c
translate-all.c

diff --git a/cpus.c b/cpus.c
index eda6d02bcc325714d3a96000e0445d97aa394884..05016dc9c7d009f60bddab1b4a855a48fa2cfea8 100644 (file)
--- a/cpus.c
+++ b/cpus.c
@@ -140,7 +140,7 @@ static int64_t cpu_get_icount_locked(void)
     icount = qemu_icount;
     if (cpu) {
         CPUArchState *env = cpu->env_ptr;
-        if (!can_do_io(env)) {
+        if (!cpu_can_do_io(cpu)) {
             fprintf(stderr, "Bad clock read\n");
         }
         icount -= (env->icount_decr.u16.low + env->icount_extra);
index bdcfefb3fb3dcdac5d5567013ae0323084c72b8e..068b6c168fd10bcac118f2cb1451d2de0ed0789d 100644 (file)
@@ -157,7 +157,6 @@ typedef struct CPUWatchpoint {
         uint32_t u32;                                                   \
         icount_decr_u16 u16;                                            \
     } icount_decr;                                                      \
-    uint32_t can_do_io; /* nonzero if memory mapped IO is safe.  */     \
                                                                         \
     /* from this point: preserved by CPU reset */                       \
     /* ice debug support */                                             \
index a387922df405099d1eb618882a65f95108ff6f8f..2179329916026631955dca54fadea4f0738356ec 100644 (file)
@@ -380,20 +380,25 @@ extern int singlestep;
 /* cpu-exec.c */
 extern volatile sig_atomic_t exit_request;
 
-/* Deterministic execution requires that IO only be performed on the last
-   instruction of a TB so that interrupts take effect immediately.  */
-static inline int can_do_io(CPUArchState *env)
+/**
+ * cpu_can_do_io:
+ * @cpu: The CPU for which to check IO.
+ *
+ * Deterministic execution requires that IO only be performed on the last
+ * instruction of a TB so that interrupts take effect immediately.
+ *
+ * Returns: %true if memory-mapped IO is safe, %false otherwise.
+ */
+static inline bool cpu_can_do_io(CPUState *cpu)
 {
-    CPUState *cpu = ENV_GET_CPU(env);
-
     if (!use_icount) {
-        return 1;
+        return true;
     }
     /* If not executing code then assume we are ok.  */
     if (cpu->current_tb == NULL) {
-        return 1;
+        return true;
     }
-    return env->can_do_io != 0;
+    return cpu->can_do_io != 0;
 }
 
 #endif
index 39a6b61e4fede1fc1da8e2e57e3165a1255b7ba6..f0dace3034ee135797447f3c58730f8b5c5829b0 100644 (file)
@@ -51,14 +51,14 @@ static void gen_tb_end(TranslationBlock *tb, int num_insns)
 static inline void gen_io_start(void)
 {
     TCGv_i32 tmp = tcg_const_i32(1);
-    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
+    tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
     tcg_temp_free_i32(tmp);
 }
 
 static inline void gen_io_end(void)
 {
     TCGv_i32 tmp = tcg_const_i32(0);
-    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
+    tcg_gen_st_i32(tmp, cpu_env, -ENV_OFFSET + offsetof(CPUState, can_do_io));
     tcg_temp_free_i32(tmp);
 }
 
index c7cd93774d0989b6aaf81a1cda33613bd482c9cc..ac825d251c4353a7d5c6cf54d6a7499af2a495ea 100644 (file)
@@ -127,7 +127,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env,
 
     physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
     cpu->mem_io_pc = retaddr;
-    if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io(env)) {
+    if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io(cpu)) {
         cpu_io_recompile(env, retaddr);
     }
 
@@ -333,7 +333,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env,
     MemoryRegion *mr = iotlb_to_region(cpu->as, physaddr);
 
     physaddr = (physaddr & TARGET_PAGE_MASK) + addr;
-    if (mr != &io_mem_rom && mr != &io_mem_notdirty && !can_do_io(env)) {
+    if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu_can_do_io(cpu)) {
         cpu_io_recompile(env, retaddr);
     }
 
index 9d52cf3a34a478119990e945d1e329a5efb1aeb5..f80036e99b6cf6e1071de6a4daa7f1adf90a1b18 100644 (file)
@@ -157,6 +157,7 @@ struct kvm_run;
  * @tcg_exit_req: Set to force TCG to stop executing linked TBs for this
  *           CPU and return to its top level loop.
  * @singlestep_enabled: Flags for single-stepping.
+ * @can_do_io: Nonzero if memory-mapped IO is safe.
  * @env_ptr: Pointer to subclass-specific CPUArchState field.
  * @current_tb: Currently executing TB.
  * @gdb_regs: Additional GDB registers.
@@ -220,6 +221,7 @@ struct CPUState {
     /* TODO Move common fields from CPUArchState here. */
     int cpu_index; /* used by alpha TCG */
     uint32_t halted; /* used by alpha, cris, ppc TCG */
+    uint32_t can_do_io;
 };
 
 QTAILQ_HEAD(CPUTailQ, CPUState);
index 4d60c0318296087232be00480aeaee191191f1bb..e7d59997ee502c616ffe15361521b8f1e7db717a 100644 (file)
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -241,6 +241,7 @@ static void cpu_common_reset(CPUState *cpu)
     cpu->halted = 0;
     cpu->mem_io_pc = 0;
     cpu->mem_io_vaddr = 0;
+    cpu->can_do_io = 0;
 }
 
 static bool cpu_common_has_work(CPUState *cs)
index dc35caab8ea6ac8f451f1c04471c1b64a16fa4b0..a1af5ef3935f9665cf987fc5fbc2059485bdd49f 100644 (file)
@@ -200,6 +200,7 @@ int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptr
 static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,
                                      uintptr_t searched_pc)
 {
+    CPUState *cpu = ENV_GET_CPU(env);
     TCGContext *s = &tcg_ctx;
     int j;
     uintptr_t tc_ptr;
@@ -218,7 +219,7 @@ static int cpu_restore_state_from_tb(TranslationBlock *tb, CPUArchState *env,
         /* Reset the cycle counter to the start of the block.  */
         env->icount_decr.u16.low += tb->icount;
         /* Clear the IO flag.  */
-        env->can_do_io = 0;
+        cpu->can_do_io = 0;
     }
 
     /* find opc index corresponding to search_pc */
@@ -1409,7 +1410,7 @@ static void tcg_handle_interrupt(CPUState *cpu, int mask)
 
     if (use_icount) {
         env->icount_decr.u16.high = 0xffff;
-        if (!can_do_io(env)
+        if (!cpu_can_do_io(cpu)
             && (mask & ~old_mask) != 0) {
             cpu_abort(env, "Raised interrupt while not in I/O function");
         }