+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.
#include "gdb/callback.h"
#include "gdb/signals.h"
#include "sim-main.h"
+#include "sim-syscall.h"
#include "sim-hw.h"
#include "targ-vals.h"
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. */
}
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))
+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.
sim-options.o \
sim-profile.o \
sim-signal.o \
+ sim-syscall.o \
sim-trace.o \
sim-utils.o \
sim-watch.o \
--- /dev/null
+/* 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);
+}
--- /dev/null
+/* 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
+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.
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. */
/* 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 **,
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:
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;
+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.
#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
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);
+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.
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>
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 *
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);
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;
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
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. */
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);
+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.
#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)
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
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);
+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.
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);
#include "sim-main.h"
+#include "sim-syscall.h"
#include "targ-vals.h"
#ifdef HAVE_UTIME_H
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)
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;
+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.
#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"
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)
{
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);