aboutsummaryrefslogtreecommitdiff
path: root/sim/mn10300
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-06-15 19:22:38 +0545
committerMike Frysinger <vapier@gentoo.org>2015-06-17 13:19:51 -0400
commit7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3 (patch)
treebc347f539bd5eb379bd6b8ce9adef4cdff2a9248 /sim/mn10300
parent61a0c964e611eaf72489c3049ba206b2f91ea4a9 (diff)
downloadgdb-7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3.zip
gdb-7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3.tar.gz
gdb-7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3.tar.bz2
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.
Diffstat (limited to 'sim/mn10300')
-rw-r--r--sim/mn10300/ChangeLog5
-rw-r--r--sim/mn10300/op_utils.c55
2 files changed, 26 insertions, 34 deletions
diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog
index 1965d5fd..ce1d326 100644
--- a/sim/mn10300/ChangeLog
+++ b/sim/mn10300/ChangeLog
@@ -1,5 +1,10 @@
2015-06-17 Mike Frysinger <vapier@gentoo.org>
+ * op_utils.c (do_syscall): Replace call to cb_syscall with
+ sim_syscall_multi.
+
+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.
diff --git a/sim/mn10300/op_utils.c b/sim/mn10300/op_utils.c
index 7b156f8..67bf9a3 100644
--- a/sim/mn10300/op_utils.c
+++ b/sim/mn10300/op_utils.c
@@ -145,6 +145,15 @@ genericBtst(unsigned32 leftOpnd, unsigned32 rightOpnd)
INLINE_SIM_MAIN (void)
do_syscall (void)
{
+ /* Registers passed to trap 0. */
+
+ /* Function number. */
+ reg_t func = State.regs[0];
+ /* Parameters. */
+ reg_t parm1 = State.regs[1];
+ reg_t parm2 = load_word (State.regs[REG_SP] + 12);
+ reg_t parm3 = load_word (State.regs[REG_SP] + 16);
+ reg_t parm4 = load_word (State.regs[REG_SP] + 20);
/* We use this for simulated system calls; we may need to change
it to a reserved instruction if we conflict with uses at
@@ -152,46 +161,24 @@ do_syscall (void)
int save_errno = errno;
errno = 0;
-/* Registers passed to trap 0 */
-
-/* Function number. */
-#define FUNC (State.regs[0])
-
-/* Parameters. */
-#define PARM1 (State.regs[1])
-#define PARM2 (load_word (State.regs[REG_SP] + 12))
-#define PARM3 (load_word (State.regs[REG_SP] + 16))
-
-/* Registers set by trap 0 */
-
-#define RETVAL State.regs[0] /* return value */
-#define RETERR State.regs[1] /* return error code */
-
- if ( FUNC == TARGET_SYS_exit )
+ if (func == TARGET_SYS_exit)
{
- /* EXIT - caller can look in PARM1 to work out the reason */
+ /* EXIT - caller can look in parm1 to work out the reason */
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
- (PARM1 == 0xdead ? SIM_SIGABRT : sim_exited), PARM1);
+ (parm1 == 0xdead ? SIM_SIGABRT : sim_exited), parm1);
}
else
{
- CB_SYSCALL syscall;
-
- CB_SYSCALL_INIT (&syscall);
- syscall.arg1 = PARM1;
- syscall.arg2 = PARM2;
- syscall.arg3 = PARM3;
- syscall.func = FUNC;
- syscall.p1 = (PTR) simulator;
- 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;
- }
+ long result, result2;
+ int errcode;
+ sim_syscall_multi (STATE_CPU (simulator, 0), func, parm1, parm2,
+ parm3, parm4, &result, &result2, &errcode);
+
+ /* Registers set by trap 0. */
+ State.regs[0] = errcode;
+ State.regs[1] = result;
+ }
errno = save_errno;
}
-