sim: syscall: unify memory helpers
authorMike Frysinger <vapier@gentoo.org>
Mon, 15 Jun 2015 15:24:21 +0000 (21:09 +0545)
committerMike Frysinger <vapier@gentoo.org>
Wed, 17 Jun 2015 17:19:51 +0000 (13:19 -0400)
Almost every port implements these two callbacks in the same way, so
unify them in the common layer.

20 files changed:
sim/bfin/ChangeLog
sim/bfin/interp.c
sim/common/ChangeLog
sim/common/Make-common.in
sim/common/sim-syscall.c [new file with mode: 0644]
sim/common/sim-syscall.h [new file with mode: 0644]
sim/cris/ChangeLog
sim/cris/traps.c
sim/lm32/ChangeLog
sim/lm32/traps.c
sim/m32r/ChangeLog
sim/m32r/traps-linux.c
sim/m32r/traps.c
sim/mcore/ChangeLog
sim/mcore/interp.c
sim/mn10300/ChangeLog
sim/mn10300/mn10300_sim.h
sim/mn10300/op_utils.c
sim/msp430/ChangeLog
sim/msp430/msp430-sim.c

index eac7b332e3f134f2743e51b3e86f240701f38694..d9d8403359e778086bddbfb07080aac928885df1 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (bfin_syscall): Change syscall_read_mem/syscall_write_mem to
+       sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-17  Mike Frysinger  <vapier@gentoo.org>
 
        * linux-targ-map.h: Update example comments.
index 69b5e96d627976f8ffab0502f141d9acb4bfc047..07030da0036504ffd564f031f5aa2d3d4349a818 100644 (file)
@@ -32,6 +32,7 @@
 #include "gdb/callback.h"
 #include "gdb/signals.h"
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "sim-hw.h"
 
 #include "targ-vals.h"
@@ -125,32 +126,6 @@ count_argc (const char * const *argv)
   return i;
 }
 
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  TRACE_CORE (cpu, "DBUS FETCH (syscall) %i bytes @ 0x%08lx", bytes, taddr);
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  TRACE_CORE (cpu, "DBUS STORE (syscall) %i bytes @ 0x%08lx", bytes, taddr);
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Simulate a monitor trap, put the result into r0 and errno into r1
    return offset by which to adjust pc.  */
 
@@ -192,8 +167,8 @@ bfin_syscall (SIM_CPU *cpu)
     }
   sc.p1 = (PTR) sd;
   sc.p2 = (PTR) cpu;
-  sc.read_mem = syscall_read_mem;
-  sc.write_mem = syscall_write_mem;
+  sc.read_mem = sim_syscall_read_mem;
+  sc.write_mem = sim_syscall_write_mem;
 
   /* Common cb_syscall() handles most functions.  */
   switch (cb_target_to_host_syscall (cb, sc.func))
index 0478f2cc752fa763a03872c016e110e6f52ba6c1..2c67e49be937a697d4b35cf8635364f008ce116d 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * Make-common.in (SIM_NEW_COMMON_OBJS): Add sim-syscall.o.
+       * sim-syscall.c: New file.
+       * sim-syscall.h: New file.
+
 2015-06-17  Mike Frysinger  <vapier@gentoo.org>
 
        * callback.c (cb_target_map_entry, cb_host_map_entry): Define.
index 2d1bb8a1a4108d786e678b8cf4792d0e2bc25932..2f5ad89e164f53be98cc4a88db651b0cd93e5153 100644 (file)
@@ -190,6 +190,7 @@ SIM_NEW_COMMON_OBJS = \
        sim-options.o \
        sim-profile.o \
        sim-signal.o \
+       sim-syscall.o \
        sim-trace.o \
        sim-utils.o \
        sim-watch.o \
diff --git a/sim/common/sim-syscall.c b/sim/common/sim-syscall.c
new file mode 100644 (file)
index 0000000..76812d3
--- /dev/null
@@ -0,0 +1,49 @@
+/* Simulator system call support.
+
+   Copyright 2002-2015 Free Software Foundation, Inc.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+
+#include "sim-main.h"
+#include "sim-syscall.h"
+\f
+/* Read/write functions for system call interface.  */
+
+int
+sim_syscall_read_mem (host_callback *cb ATTRIBUTE_UNUSED, struct cb_syscall *sc,
+                     unsigned long taddr, char *buf, int bytes)
+{
+  SIM_DESC sd = (SIM_DESC) sc->p1;
+  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
+
+  TRACE_MEMORY (cpu, "READ (syscall) %i bytes @ 0x%08lx", bytes, taddr);
+
+  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
+}
+
+int
+sim_syscall_write_mem (host_callback *cb ATTRIBUTE_UNUSED, struct cb_syscall *sc,
+                      unsigned long taddr, const char *buf, int bytes)
+{
+  SIM_DESC sd = (SIM_DESC) sc->p1;
+  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
+
+  TRACE_MEMORY (cpu, "WRITE (syscall) %i bytes @ 0x%08lx", bytes, taddr);
+
+  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
+}
diff --git a/sim/common/sim-syscall.h b/sim/common/sim-syscall.h
new file mode 100644 (file)
index 0000000..3f231fe
--- /dev/null
@@ -0,0 +1,30 @@
+/* Simulator system call support.
+
+   Copyright 2002-2015 Free Software Foundation, Inc.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef SIM_SYSCALL_H
+#define SIM_SYSCALL_H
+
+/* Simple memory callbacks for cb_syscall's read_mem/write_mem that assume
+   cb_syscall's p1 and p2 are set to the SIM_DESC and SIM_CPU respectively.  */
+int sim_syscall_read_mem (host_callback *, struct cb_syscall *, unsigned long,
+                         char *, int);
+int sim_syscall_write_mem (host_callback *, struct cb_syscall *, unsigned long,
+                          const char *, int);
+
+#endif
index e3a1731109fb1373bdf784360e54b4bd64e97a23..c4b94ecfdfbf42f9fcb41e80776f902c933c5fb1 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * traps.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (cris_break_13_handler): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-17  Mike Frysinger  <vapier@gentoo.org>
 
        * traps.c (syscall_map): Fill out name field.
index 888f808665f28f0b98b8a99651d28c82a69adf98..3d22b4d16ce1e21e37a5d9050adbe3caee68d448 100644 (file)
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "sim-options.h"
 #include "bfd.h"
 /* FIXME: get rid of targ-vals.h usage everywhere else.  */
@@ -763,10 +764,6 @@ static const CB_TARGET_DEFS_MAP open_map[] = {
 /* Needed for the cris_pipe_nonempty and cris_pipe_empty syscalls.  */
 static SIM_CPU *current_cpu_for_cb_callback;
 
-static int syscall_read_mem (host_callback *, struct cb_syscall *,
-                            unsigned long, char *, int);
-static int syscall_write_mem (host_callback *, struct cb_syscall *,
-                             unsigned long, const char *, int);
 static USI create_map (SIM_DESC, struct cris_sim_mmapped_page **,
                       USI addr, USI len);
 static USI unmap_pages (SIM_DESC, struct cris_sim_mmapped_page **,
@@ -776,30 +773,6 @@ static USI is_mapped (SIM_DESC, struct cris_sim_mmapped_page **,
 static void dump_statistics (SIM_CPU *current_cpu);
 static void make_first_thread (SIM_CPU *current_cpu);
 
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb ATTRIBUTE_UNUSED,
-                 struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb ATTRIBUTE_UNUSED,
-                  struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* When we risk running self-modified code (as in trampolines), this is
    called from special-case insns.  The silicon CRIS CPU:s have enough
    cache snooping implemented making this a simulator-only issue.  Tests:
@@ -1496,8 +1469,8 @@ cris_break_13_handler (SIM_CPU *current_cpu, USI callnum, USI arg1,
 
   s.p1 = (PTR) sd;
   s.p2 = (PTR) current_cpu;
-  s.read_mem = syscall_read_mem;
-  s.write_mem = syscall_write_mem;
+  s.read_mem = sim_syscall_read_mem;
+  s.write_mem = sim_syscall_write_mem;
 
   current_cpu_for_cb_callback = current_cpu;
 
index dd95d6acf7e060d7b36964d792643f9784ebe553..4cee5daa7e58434843ac879e81371b3052910a01 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * traps.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (lm32bf_scall_insn): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-12  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index 777e7b582f5a0af5248100b60ba4d4103bd7ed62..810ddf7d47e534781c37dd7f2f41fca9a4089daf 100644 (file)
 #define WANT_CPU_LM32BF
 
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "lm32-sim.h"
 #include "targ-vals.h"
 
-/* Read memory function for system call interface.  */
-
-static int
-syscall_read_mem (host_callback * cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-/* Write memory function for system call interface.  */
-
-static int
-syscall_write_mem (host_callback * cb, struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Handle invalid instructions.  */
 
 SEM_PC
@@ -159,8 +136,8 @@ lm32bf_scall_insn (SIM_CPU * current_cpu, IADDR pc)
       CB_SYSCALL_INIT (&s);
       s.p1 = (PTR) sd;
       s.p2 = (PTR) current_cpu;
-      s.read_mem = syscall_read_mem;
-      s.write_mem = syscall_write_mem;
+      s.read_mem = sim_syscall_read_mem;
+      s.write_mem = sim_syscall_write_mem;
       /* Extract parameters.  */
       s.func = GET_H_GR (8);
       s.arg1 = GET_H_GR (1);
index 12e574110a45def07e57b1be639a70f7154919bc..b915747f6b4ad2905bb75b6687de318eeb454693 100644 (file)
@@ -1,3 +1,14 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * traps-linux.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (m32r_trap): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+       * traps.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (m32r_trap): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-12  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index ba3da54717def80bef8f581f8f341fc8dfbf5c2d..4b6384e48d6f9ef93773e8581299e5298f18e713 100644 (file)
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "syscall.h"
 #include "targ-vals.h"
 #include <dirent.h>
@@ -113,28 +114,6 @@ m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
                      transfer, sig);
 }
 \f
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Translate target's address to host's address.  */
 
 static void *
@@ -249,8 +228,8 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
  
         s.p1 = (PTR) sd;
         s.p2 = (PTR) current_cpu;
-        s.read_mem = syscall_read_mem;
-        s.write_mem = syscall_write_mem;
+        s.read_mem = sim_syscall_read_mem;
+        s.write_mem = sim_syscall_write_mem;
         cb_syscall (cb, &s);
         m32rbf_h_gr_set (current_cpu, 2, s.errcode);
         m32rbf_h_gr_set (current_cpu, 0, s.result);
@@ -290,8 +269,8 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
 
         s.p1 = (PTR) sd;
         s.p2 = (PTR) current_cpu;
-        s.read_mem = syscall_read_mem;
-        s.write_mem = syscall_write_mem;
+        s.read_mem = sim_syscall_read_mem;
+        s.write_mem = sim_syscall_write_mem;
 
         result = 0;
         result2 = 0;
index b0814b2e632608ac2ab849907605cfce0ada8360..869b5966431a7197e4df987ade6fe57cb30db6ef 100644 (file)
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "targ-vals.h"
 
 #define TRAP_FLUSH_CACHE 12
@@ -92,28 +93,6 @@ m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,
                     transfer, sig);
 }
 \f
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Trap support.
    The result is the pc address to continue at.
    Preprocessing like saving the various registers has already been done.  */
@@ -165,8 +144,8 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)
 
        s.p1 = (PTR) sd;
        s.p2 = (PTR) current_cpu;
-       s.read_mem = syscall_read_mem;
-       s.write_mem = syscall_write_mem;
+       s.read_mem = sim_syscall_read_mem;
+       s.write_mem = sim_syscall_write_mem;
        cb_syscall (cb, &s);
        m32rbf_h_gr_set (current_cpu, 2, s.errcode);
        m32rbf_h_gr_set (current_cpu, 0, s.result);
index 1b47b5efbb482d53ff0efb0eb3588dc477a0bc8a..389983d2605a7b5b889ea493feddc0900526d3e0 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * interp.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (m32r_trap): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-12  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index c13dbd8aac2d6fee811593137beec7611d523e59..e77535b8ae5d77d93f0f36a068c7f5a6eed9d481 100644 (file)
@@ -31,6 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "sim-main.h"
 #include "sim-base.h"
+#include "sim-syscall.h"
 #include "sim-options.h"
 
 #define target_big_endian (CURRENT_TARGET_BYTE_ORDER == BIG_ENDIAN)
@@ -197,28 +198,6 @@ set_initial_gprs (SIM_CPU *scpu)
   cpu.gr[PARM4] = cpu.gr[0];
 }
 
-/* Read/write functions for system call interface.  */
-
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 /* Simulate a monitor trap.  */
 
 static void
@@ -237,8 +216,8 @@ handle_trap1 (SIM_DESC sd)
 
   sc.p1 = (PTR) sd;
   sc.p2 = (PTR) STATE_CPU (sd, 0);
-  sc.read_mem = syscall_read_mem;
-  sc.write_mem = syscall_write_mem;
+  sc.read_mem = sim_syscall_read_mem;
+  sc.write_mem = sim_syscall_write_mem;
 
   cb_syscall (cb, &sc);
 
index a59869b198ba47f3f227899689e0f9ef3827defb..1965d5fd365f1d9612cfa84e064ca28dad7aa374 100644 (file)
@@ -1,3 +1,11 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * mn10300_sim.h (syscall_read_mem, syscall_write_mem): Delete.
+       * op_utils.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (do_syscall): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.  Set syscall.p2.
+
 2015-06-12  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index f021aee9c00b63aa52899015516a43904b387aaf..6e8f53a4f2277a5bc8b20e8073ca1e82e844054c 100644 (file)
@@ -200,16 +200,6 @@ INLINE_SIM_MAIN (void) genericCmp (unsigned32 leftOpnd, unsigned32 rightOpnd);
 INLINE_SIM_MAIN (void) genericOr (unsigned32 source, unsigned32 destReg);
 INLINE_SIM_MAIN (void) genericXor (unsigned32 source, unsigned32 destReg);
 INLINE_SIM_MAIN (void) genericBtst (unsigned32 leftOpnd, unsigned32 rightOpnd);
-INLINE_SIM_MAIN (int) syscall_read_mem (host_callback *cb,
-                                       struct cb_syscall *sc,
-                                       unsigned long taddr,
-                                       char *buf,
-                                       int bytes);
-INLINE_SIM_MAIN (int) syscall_write_mem (host_callback *cb,
-                                        struct cb_syscall *sc,
-                                        unsigned long taddr,
-                                        const char *buf,
-                                        int bytes); 
 INLINE_SIM_MAIN (void) do_syscall (void);
 void program_interrupt (SIM_DESC sd, sim_cpu *cpu, sim_cia cia, SIM_SIGNAL sig);
 
index 316cf7597886747fd3d21369d6d7ead67aa9bfc9..7b156f8b73a24e647487f751431baa6153cf860d 100644 (file)
@@ -1,4 +1,5 @@
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "targ-vals.h"
 
 #ifdef HAVE_UTIME_H
@@ -140,28 +141,6 @@ genericBtst(unsigned32 leftOpnd, unsigned32 rightOpnd)
   PSW |= (z ? PSW_Z : 0) | (n ? PSW_N : 0);
 }
 
-/* Read/write functions for system call interface.  */
-INLINE_SIM_MAIN (int)
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  sim_cpu *cpu = STATE_CPU(sd, 0);
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-INLINE_SIM_MAIN (int)
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                  unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  sim_cpu *cpu = STATE_CPU(sd, 0);
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
-
 /* syscall */
 INLINE_SIM_MAIN (void)
 do_syscall (void)
@@ -204,8 +183,9 @@ do_syscall (void)
       syscall.arg3 = PARM3;
       syscall.func = FUNC;
       syscall.p1 = (PTR) simulator;
-      syscall.read_mem = syscall_read_mem;
-      syscall.write_mem = syscall_write_mem;
+      syscall.p2 = (PTR) STATE_CPU (simulator, 0);
+      syscall.read_mem = sim_syscall_read_mem;
+      syscall.write_mem = sim_syscall_write_mem;
       cb_syscall (STATE_CALLBACK (simulator), &syscall);
       RETERR = syscall.errcode;
       RETVAL = syscall.result;
index 7f8fed667d97c14dab1820dd66bc96fdcbb26896..d26f3f401d218507a6f163b4482092ff7b96e422 100644 (file)
@@ -1,3 +1,10 @@
+2015-06-17  Mike Frysinger  <vapier@gentoo.org>
+
+       * msp430-sim.c: Include sim-syscall.h.
+       (syscall_read_mem, syscall_write_mem): Delete.
+       (maybe_perform_syscall): Change syscall_read_mem/syscall_write_mem
+       to sim_syscall_read_mem/sim_syscall_write_mem.
+
 2015-06-12  Mike Frysinger  <vapier@gentoo.org>
 
        * configure: Regenerate.
index b652f0891993e54b527ff9e3f858e71d5da4d97c..650584a666655220e8eb0ddf2a7c3bae2b843a88 100644 (file)
@@ -29,6 +29,7 @@
 #include "bfd.h"
 #include "opcode/msp430-decode.h"
 #include "sim-main.h"
+#include "sim-syscall.h"
 #include "dis-asm.h"
 #include "targ-vals.h"
 #include "trace.h"
@@ -949,26 +950,6 @@ binary_to_bcd (int v)
   return r;
 }
 
-static int
-syscall_read_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);
-}
-
-static int
-syscall_write_mem (host_callback *cb, struct cb_syscall *sc,
-                 unsigned long taddr, const char *buf, int bytes)
-{
-  SIM_DESC sd = (SIM_DESC) sc->p1;
-  SIM_CPU *cpu = (SIM_CPU *) sc->p2;
-
-  return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);
-}
-
 static const char *
 cond_string (int cond)
 {
@@ -1089,8 +1070,8 @@ maybe_perform_syscall (SIM_DESC sd, int call_addr)
 
       sc.p1 = sd;
       sc.p2 = MSP430_CPU (sd);
-      sc.read_mem = syscall_read_mem;
-      sc.write_mem = syscall_write_mem;
+      sc.read_mem = sim_syscall_read_mem;
+      sc.write_mem = sim_syscall_write_mem;
 
       cb_syscall (cb, &sc);