diff mbox

[v3,3/7] Move target_memory_rw_debug function.

Message ID 1ebabcf0e1af7a81774fef22f7e765089fb2685d.1484929304.git.julian@codesourcery.com
State New
Headers show

Commit Message

Julian Brown Jan. 20, 2017, 4:30 p.m. UTC
This patch moves the target_memory_rw_debug function to
include/exec/cpu-all.h, so that it can be used by the ARM semihosting
code as well as the gdbstub code. (I tried Peter Maydell's suggestion
of include/qom/cpu.h as a location for the function, but that raised
uncomfortably-many dependency problems for my taste).

Signed-off-by: Julian Brown <julian@codesourcery.com>
---
 gdbstub.c              | 11 -----------
 include/exec/cpu-all.h | 22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 11 deletions(-)

Comments

Peter Maydell Feb. 3, 2017, 3:55 p.m. UTC | #1
On 20 January 2017 at 16:30, Julian Brown <julian@codesourcery.com> wrote:
> This patch moves the target_memory_rw_debug function to
> include/exec/cpu-all.h, so that it can be used by the ARM semihosting
> code as well as the gdbstub code. (I tried Peter Maydell's suggestion
> of include/qom/cpu.h as a location for the function, but that raised
> uncomfortably-many dependency problems for my taste).
>
> Signed-off-by: Julian Brown <julian@codesourcery.com>
> ---
>  gdbstub.c              | 11 -----------
>  include/exec/cpu-all.h | 22 ++++++++++++++++++++++
>  2 files changed, 22 insertions(+), 11 deletions(-)
>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
diff mbox

Patch

diff --git a/gdbstub.c b/gdbstub.c
index 64f2696..cb77e15 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -44,17 +44,6 @@ 
 #define GDB_ATTACHED "0"
 #endif
 
-static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
-                                         uint8_t *buf, int len, bool is_write)
-{
-    CPUClass *cc = CPU_GET_CLASS(cpu);
-
-    if (cc->memory_rw_debug) {
-        return cc->memory_rw_debug(cpu, addr, buf, len, is_write);
-    }
-    return cpu_memory_rw_debug(cpu, addr, buf, len, is_write);
-}
-
 enum {
     GDB_SIGNAL_0 = 0,
     GDB_SIGNAL_INT = 2,
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index ffe43d5..700b90d 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -347,4 +347,26 @@  int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
 
 int cpu_exec(CPUState *cpu);
 
+/**
+  * target_memory_rw_debug:
+  * @cpu: The CPU to use.
+  * @addr: The target address to read or write.
+  * @buf: Host buffer to read or write from or into.
+  * @len: Length of data.
+  * @is_write: True for write, false for read.
+  *
+  * A wrapper for cpu_memory_rw_debug that can be overridden with a
+  * CPUClass-specific version if required.
+  */
+static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr,
+                                         uint8_t *buf, int len, bool is_write)
+{
+    CPUClass *cc = CPU_GET_CLASS(cpu);
+
+    if (cc->memory_rw_debug) {
+        return cc->memory_rw_debug(cpu, addr, buf, len, is_write);
+    }
+    return cpu_memory_rw_debug(cpu, addr, buf, len, is_write);
+}
+
 #endif /* CPU_ALL_H */