sim: syscall: unify memory helpers

Almost every port implements these two callbacks in the same way, so
unify them in the common layer.
This commit is contained in:
Mike Frysinger
2015-06-15 21:09:21 +05:45
parent 6362a3f875
commit 61a0c964e6
20 changed files with 167 additions and 214 deletions

View 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);
}
/* 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;