From 61a0c964e611eaf72489c3049ba206b2f91ea4a9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Jun 2015 21:09:21 +0545 Subject: [PATCH] sim: syscall: unify memory helpers Almost every port implements these two callbacks in the same way, so unify them in the common layer. --- sim/bfin/ChangeLog | 7 ++++++ sim/bfin/interp.c | 31 +++---------------------- sim/common/ChangeLog | 6 +++++ sim/common/Make-common.in | 1 + sim/common/sim-syscall.c | 49 +++++++++++++++++++++++++++++++++++++++ sim/common/sim-syscall.h | 30 ++++++++++++++++++++++++ sim/cris/ChangeLog | 7 ++++++ sim/cris/traps.c | 33 +++----------------------- sim/lm32/ChangeLog | 7 ++++++ sim/lm32/traps.c | 29 +++-------------------- sim/m32r/ChangeLog | 11 +++++++++ sim/m32r/traps-linux.c | 31 ++++--------------------- sim/m32r/traps.c | 27 +++------------------ sim/mcore/ChangeLog | 7 ++++++ sim/mcore/interp.c | 27 +++------------------ sim/mn10300/ChangeLog | 8 +++++++ sim/mn10300/mn10300_sim.h | 10 -------- sim/mn10300/op_utils.c | 28 ++++------------------ sim/msp430/ChangeLog | 7 ++++++ sim/msp430/msp430-sim.c | 25 +++----------------- 20 files changed, 167 insertions(+), 214 deletions(-) create mode 100644 sim/common/sim-syscall.c create mode 100644 sim/common/sim-syscall.h diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog index eac7b332e3..d9d8403359 100644 --- a/sim/bfin/ChangeLog +++ b/sim/bfin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Mike Frysinger + + * 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 * linux-targ-map.h: Update example comments. diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c index 69b5e96d62..07030da003 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 0478f2cc75..2c67e49be9 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,9 @@ +2015-06-17 Mike Frysinger + + * 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 * callback.c (cb_target_map_entry, cb_host_map_entry): Define. diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index 2d1bb8a1a4..2f5ad89e16 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 0000000000..76812d358e --- /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 . */ + +#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 0000000000..3f231fe058 --- /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 . */ + +#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 e3a1731109..c4b94ecfdf 100644 --- a/sim/cris/ChangeLog +++ b/sim/cris/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Mike Frysinger + + * 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 * traps.c (syscall_map): Fill out name field. diff --git a/sim/cris/traps.c b/sim/cris/traps.c index 888f808665..3d22b4d16c 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 . */ #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 dd95d6acf7..4cee5daa7e 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Mike Frysinger + + * 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 * configure: Regenerate. diff --git a/sim/lm32/traps.c b/sim/lm32/traps.c index 777e7b582f..810ddf7d47 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 12e574110a..b915747f6b 100644 --- a/sim/m32r/ChangeLog +++ b/sim/m32r/ChangeLog @@ -1,3 +1,14 @@ +2015-06-17 Mike Frysinger + + * 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 * configure: Regenerate. diff --git a/sim/m32r/traps-linux.c b/sim/m32r/traps-linux.c index ba3da54717..4b6384e48d 100644 --- a/sim/m32r/traps-linux.c +++ b/sim/m32r/traps-linux.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "sim-main.h" +#include "sim-syscall.h" #include "syscall.h" #include "targ-vals.h" #include @@ -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 b0814b2e63..869b596643 100644 --- a/sim/m32r/traps.c +++ b/sim/m32r/traps.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #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 1b47b5efbb..389983d260 100644 --- a/sim/mcore/ChangeLog +++ b/sim/mcore/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Mike Frysinger + + * 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 * configure: Regenerate. diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c index c13dbd8aac..e77535b8ae 100644 --- a/sim/mcore/interp.c +++ b/sim/mcore/interp.c @@ -31,6 +31,7 @@ along with this program. If not, see . */ #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 a59869b198..1965d5fd36 100644 --- a/sim/mn10300/ChangeLog +++ b/sim/mn10300/ChangeLog @@ -1,3 +1,11 @@ +2015-06-17 Mike Frysinger + + * 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 * configure: Regenerate. diff --git a/sim/mn10300/mn10300_sim.h b/sim/mn10300/mn10300_sim.h index f021aee9c0..6e8f53a4f2 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 316cf75978..7b156f8b73 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 7f8fed667d..d26f3f401d 100644 --- a/sim/msp430/ChangeLog +++ b/sim/msp430/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Mike Frysinger + + * 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 * configure: Regenerate. diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index b652f08919..650584a666 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);