diff mbox

[v1,10/15] exec-all: Move cpu_can_do_io() to qom/cpu.h

Message ID babf886c4125c89cb3a28d2d34ff65859db071e4.1441614289.git.crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite Sept. 11, 2015, 5:39 a.m. UTC
This function has no architecture specific dependencies and should be
callable from core code. Move it to qom/cpu.h.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---

 include/qom/cpu.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Paolo Bonzini Sept. 11, 2015, 7:24 a.m. UTC | #1
On 11/09/2015 07:39, Peter Crosthwaite wrote:
> This function has no architecture specific dependencies and should be
> callable from core code.

It also does not exist anymore. :-P

Paolo
diff mbox

Patch

diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index 39712ab..7e5f3b0 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -696,6 +696,27 @@  void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 void cpu_exec_exit(CPUState *cpu);
 
+/**
+ * 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)
+{
+    if (!use_icount) {
+        return true;
+    }
+    /* If not executing code then assume we are ok.  */
+    if (cpu->current_tb == NULL) {
+        return true;
+    }
+    return cpu->can_do_io != 0;
+}
+
 #ifdef CONFIG_SOFTMMU
 extern const struct VMStateDescription vmstate_cpu_common;
 #else