aboutsummaryrefslogtreecommitdiff
path: root/sim/msp430/msp430-sim.c
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/msp430/msp430-sim.c
parent61a0c964e611eaf72489c3049ba206b2f91ea4a9 (diff)
downloadbinutils-7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3.zip
binutils-7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3.tar.gz
binutils-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/msp430/msp430-sim.c')
-rw-r--r--sim/msp430/msp430-sim.c64
1 files changed, 8 insertions, 56 deletions
diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c
index 650584a..931573e 100644
--- a/sim/msp430/msp430-sim.c
+++ b/sim/msp430/msp430-sim.c
@@ -1022,62 +1022,14 @@ maybe_perform_syscall (SIM_DESC sd, int call_addr)
{
/* Syscall! */
int syscall_num = call_addr & 0x3f;
- host_callback *cb = STATE_CALLBACK (sd);
- CB_SYSCALL sc;
-
- CB_SYSCALL_INIT (&sc);
-
- sc.func = syscall_num;
- sc.arg1 = MSP430_CPU (sd)->state.regs[12];
- sc.arg2 = MSP430_CPU (sd)->state.regs[13];
- sc.arg3 = MSP430_CPU (sd)->state.regs[14];
- sc.arg4 = MSP430_CPU (sd)->state.regs[15];
-
- if (TRACE_SYSCALL_P (MSP430_CPU (sd)))
- {
- const char *syscall_name = "*unknown*";
-
- switch (syscall_num)
- {
- case TARGET_SYS_exit:
- syscall_name = "exit(%d)";
- break;
- case TARGET_SYS_open:
- syscall_name = "open(%#x,%#x)";
- break;
- case TARGET_SYS_close:
- syscall_name = "close(%d)";
- break;
- case TARGET_SYS_read:
- syscall_name = "read(%d,%#x,%d)";
- break;
- case TARGET_SYS_write:
- syscall_name = "write(%d,%#x,%d)";
- break;
- }
- trace_generic (sd, MSP430_CPU (sd), TRACE_SYSCALL_IDX,
- syscall_name, sc.arg1, sc.arg2, sc.arg3, sc.arg4);
- }
-
- /* Handle SYS_exit here. */
- if (syscall_num == 1)
- {
- sim_engine_halt (sd, MSP430_CPU (sd), NULL,
- MSP430_CPU (sd)->state.regs[0],
- sim_exited, sc.arg1);
- return 1;
- }
-
- sc.p1 = sd;
- sc.p2 = MSP430_CPU (sd);
- sc.read_mem = sim_syscall_read_mem;
- sc.write_mem = sim_syscall_write_mem;
-
- cb_syscall (cb, &sc);
-
- TRACE_SYSCALL (MSP430_CPU (sd), "returns %ld", sc.result);
-
- MSP430_CPU (sd)->state.regs[12] = sc.result;
+ int arg1 = MSP430_CPU (sd)->state.regs[12];
+ int arg2 = MSP430_CPU (sd)->state.regs[13];
+ int arg3 = MSP430_CPU (sd)->state.regs[14];
+ int arg4 = MSP430_CPU (sd)->state.regs[15];
+
+ MSP430_CPU (sd)->state.regs[12] = sim_syscall (MSP430_CPU (sd),
+ syscall_num, arg1, arg2,
+ arg3, arg4);
return 1;
}