From 7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Jun 2015 19:22:38 +0545 Subject: sim: syscall: add common sim_syscall helpers Many ports have the same sim syscall logic, so add some helpers to handle all the common details. The arches still have to deal with the unpacking and packing of the syscall arguments, but the rest of the sim<->callback glue is now shared. --- sim/lm32/ChangeLog | 5 +++++ sim/lm32/traps.c | 28 ++++++++++------------------ 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'sim/lm32') diff --git a/sim/lm32/ChangeLog b/sim/lm32/ChangeLog index 4cee5da..7442ba3 100644 --- a/sim/lm32/ChangeLog +++ b/sim/lm32/ChangeLog @@ -1,5 +1,10 @@ 2015-06-17 Mike Frysinger + * traps.c (lm32bf_scall_insn): Replace call to cb_syscall with + sim_syscall_multi. + +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 diff --git a/sim/lm32/traps.c b/sim/lm32/traps.c index 810ddf7..9de0910 100644 --- a/sim/lm32/traps.c +++ b/sim/lm32/traps.c @@ -132,26 +132,18 @@ lm32bf_scall_insn (SIM_CPU * current_cpu, IADDR pc) || (GET_H_GR (8) == TARGET_SYS_exit)) { /* Delegate system call to host O/S. */ - CB_SYSCALL s; - CB_SYSCALL_INIT (&s); - s.p1 = (PTR) sd; - s.p2 = (PTR) current_cpu; - 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); - s.arg2 = GET_H_GR (2); - s.arg3 = GET_H_GR (3); - /* Halt the simulator if the requested system call is _exit. */ - if (s.func == TARGET_SYS_exit) - sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1); + long result, result2; + int errcode; + /* Perform the system call. */ - cb_syscall (cb, &s); + sim_syscall_multi (current_cpu, GET_H_GR (8), GET_H_GR (1), GET_H_GR (2), + GET_H_GR (3), GET_H_GR (4), &result, &result2, + &errcode); /* Store the return value in the CPU's registers. */ - SET_H_GR (1, s.result); - SET_H_GR (2, s.result2); - SET_H_GR (3, s.errcode); + SET_H_GR (1, result); + SET_H_GR (2, result2); + SET_H_GR (3, errcode); + /* Skip over scall instruction. */ return pc + 4; } -- cgit v1.1