aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-06-15 21:09:21 +0545
committerMike Frysinger <vapier@gentoo.org>2015-06-17 13:19:51 -0400
commit61a0c964e611eaf72489c3049ba206b2f91ea4a9 (patch)
tree386585a4f8d371d56225e968649dba301ec27801 /sim
parent6362a3f8757bfce133b724df2077573433823ad4 (diff)
downloadfsf-binutils-gdb-61a0c964e611eaf72489c3049ba206b2f91ea4a9.zip
fsf-binutils-gdb-61a0c964e611eaf72489c3049ba206b2f91ea4a9.tar.gz
fsf-binutils-gdb-61a0c964e611eaf72489c3049ba206b2f91ea4a9.tar.bz2
sim: syscall: unify memory helpers
Almost every port implements these two callbacks in the same way, so unify them in the common layer.
Diffstat (limited to 'sim')
-rw-r--r--sim/bfin/ChangeLog7
-rw-r--r--sim/bfin/interp.c31
-rw-r--r--sim/common/ChangeLog6
-rw-r--r--sim/common/Make-common.in1
-rw-r--r--sim/common/sim-syscall.c49
-rw-r--r--sim/common/sim-syscall.h30
-rw-r--r--sim/cris/ChangeLog7
-rw-r--r--sim/cris/traps.c33
-rw-r--r--sim/lm32/ChangeLog7
-rw-r--r--sim/lm32/traps.c29
-rw-r--r--sim/m32r/ChangeLog11
-rw-r--r--sim/m32r/traps-linux.c31
-rw-r--r--sim/m32r/traps.c27
-rw-r--r--sim/mcore/ChangeLog7
-rw-r--r--sim/mcore/interp.c27
-rw-r--r--sim/mn10300/ChangeLog8
-rw-r--r--sim/mn10300/mn10300_sim.h10
-rw-r--r--sim/mn10300/op_utils.c28
-rw-r--r--sim/msp430/ChangeLog7
-rw-r--r--sim/msp430/msp430-sim.c25
20 files changed, 167 insertions, 214 deletions
diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index eac7b33..d9d8403 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,5 +1,12 @@
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.
(cb_linux_syscall_map): Fill out name field.
(cb_linux_errno_map, cb_linux_open_map, cb_linux_signal_map):
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index 69b5e96..07030da 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -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))
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 0478f2c..2c67e49 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,11 @@
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.
(cb_target_to_host_syscall): Rewrite to use cb_target_map_entry.
(cb_host_to_target_errno): Rewrite to use cb_host_map_entry.
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 2d1bb8a..2f5ad89 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -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
index 0000000..76812d3
--- /dev/null
+++ b/sim/common/sim-syscall.c
@@ -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"
+
+/* 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
index 0000000..3f231fe
--- /dev/null
+++ b/sim/common/sim-syscall.h
@@ -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
diff --git a/sim/cris/ChangeLog b/sim/cris/ChangeLog
index e3a1731..c4b94ec 100644
--- a/sim/cris/ChangeLog
+++ b/sim/cris/ChangeLog
@@ -1,5 +1,12 @@
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.
(syscall_stat32_map, errno_map, open_map): Likewise.
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index 888f808..3d22b4d 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -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;
diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog
index dd95d6a..4cee5da 100644
--- a/sim/lm32/ChangeLog
+++ b/sim/lm32/ChangeLog
@@ -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.
diff --git a/sim/lm32/traps.c b/sim/lm32/traps.c
index 777e7b5..810ddf7 100644
--- a/sim/lm32/traps.c
+++ b/sim/lm32/traps.c
@@ -22,33 +22,10 @@
#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);
diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog
index 12e5741..b915747 100644
--- a/sim/m32r/ChangeLog
+++ b/sim/m32r/ChangeLog
@@ -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.
diff --git a/sim/m32r/traps-linux.c b/sim/m32r/traps-linux.c
index ba3da54..4b6384e 100644
--- a/sim/m32r/traps-linux.c
+++ b/sim/m32r/traps-linux.c
@@ -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);
}
-/* 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;
diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c
index b0814b2..869b596 100644
--- a/sim/m32r/traps.c
+++ b/sim/m32r/traps.c
@@ -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);
}
-/* 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);
diff --git a/sim/mcore/ChangeLog b/sim/mcore/ChangeLog
index 1b47b5e..389983d 100644
--- a/sim/mcore/ChangeLog
+++ b/sim/mcore/ChangeLog
@@ -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.
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index c13dbd8..e77535b 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -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);
diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog
index a59869b..1965d5fd 100644
--- a/sim/mn10300/ChangeLog
+++ b/sim/mn10300/ChangeLog
@@ -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.
diff --git a/sim/mn10300/mn10300_sim.h b/sim/mn10300/mn10300_sim.h
index f021aee..6e8f53a 100644
--- a/sim/mn10300/mn10300_sim.h
+++ b/sim/mn10300/mn10300_sim.h
@@ -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);
diff --git a/sim/mn10300/op_utils.c b/sim/mn10300/op_utils.c
index 316cf75..7b156f8 100644
--- a/sim/mn10300/op_utils.c
+++ b/sim/mn10300/op_utils.c
@@ -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;
diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog
index 7f8fed6..d26f3f4 100644
--- a/sim/msp430/ChangeLog
+++ b/sim/msp430/ChangeLog
@@ -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.
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index b652f08..650584a 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -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);