GNU Binutils with patches for OS216
修訂 | 7d5c6c43ca8a5dd5491f4a58e977ec5501386ee3 (tree) |
---|---|
時間 | 2015-06-18 02:19:51 |
作者 | Mike Frysinger <vapier@gent...> |
Commiter | Mike Frysinger |
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.
@@ -1,5 +1,12 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * sim-syscall.c: Include errno.h and targ-vals.h. | |
4 | + (sim_syscall_multi, sim_syscall): Define. | |
5 | + * sim-syscall.h (sim_syscall_multi, sim_syscall): Declare. | |
6 | + * syscall.c (cb_syscall): Extend comment. | |
7 | + | |
8 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
9 | + | |
3 | 10 | * Make-common.in (SIM_NEW_COMMON_OBJS): Add sim-syscall.o. |
4 | 11 | * sim-syscall.c: New file. |
5 | 12 | * sim-syscall.h: New file. |
@@ -19,8 +19,11 @@ | ||
19 | 19 | |
20 | 20 | #include "config.h" |
21 | 21 | |
22 | +#include <errno.h> | |
23 | + | |
22 | 24 | #include "sim-main.h" |
23 | 25 | #include "sim-syscall.h" |
26 | +#include "targ-vals.h" | |
24 | 27 | |
25 | 28 | /* Read/write functions for system call interface. */ |
26 | 29 |
@@ -47,3 +50,77 @@ sim_syscall_write_mem (host_callback *cb ATTRIBUTE_UNUSED, struct cb_syscall *sc | ||
47 | 50 | |
48 | 51 | return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes); |
49 | 52 | } |
53 | + | |
54 | +/* Main syscall callback for simulators. */ | |
55 | + | |
56 | +void | |
57 | +sim_syscall_multi (SIM_CPU *cpu, int func, long arg1, long arg2, long arg3, | |
58 | + long arg4, long *result, long *result2, int *errcode) | |
59 | +{ | |
60 | + SIM_DESC sd = CPU_STATE (cpu); | |
61 | + host_callback *cb = STATE_CALLBACK (sd); | |
62 | + CB_SYSCALL sc; | |
63 | + char unknown_syscall[30]; | |
64 | + const char *syscall; | |
65 | + | |
66 | + CB_SYSCALL_INIT (&sc); | |
67 | + | |
68 | + sc.func = func; | |
69 | + sc.arg1 = arg1; | |
70 | + sc.arg2 = arg2; | |
71 | + sc.arg3 = arg3; | |
72 | + sc.arg4 = arg4; | |
73 | + | |
74 | + sc.p1 = (PTR) sd; | |
75 | + sc.p2 = (PTR) cpu; | |
76 | + sc.read_mem = sim_syscall_read_mem; | |
77 | + sc.write_mem = sim_syscall_write_mem; | |
78 | + | |
79 | + if (cb_syscall (cb, &sc) != CB_RC_OK) | |
80 | + { | |
81 | + /* The cb_syscall func never returns an error, so this is more of a | |
82 | + sanity check. */ | |
83 | + sim_engine_abort (sd, cpu, sim_pc_get (cpu), "cb_syscall failed"); | |
84 | + } | |
85 | + | |
86 | + syscall = cb_target_str_syscall (cb, func); | |
87 | + if (!syscall) | |
88 | + { | |
89 | + sprintf (unknown_syscall, "syscall_%i", func); | |
90 | + syscall = unknown_syscall; | |
91 | + } | |
92 | + | |
93 | + if (sc.result == -1) | |
94 | + TRACE_SYSCALL (cpu, "%s[%i](%#lx, %#lx, %#lx) = %li (error = %s[%i])", | |
95 | + syscall, func, arg1, arg2, arg3, sc.result, | |
96 | + cb_target_str_errno (cb, sc.errcode), sc.errcode); | |
97 | + else | |
98 | + TRACE_SYSCALL (cpu, "%s[%i](%#lx, %#lx, %#lx) = %li", | |
99 | + syscall, func, arg1, arg2, arg3, sc.result); | |
100 | + | |
101 | + if (cb_target_to_host_syscall (cb, func) == CB_SYS_exit) | |
102 | + sim_engine_halt (sd, cpu, NULL, sim_pc_get (cpu), sim_exited, arg1); | |
103 | + else if (sc.result == -1) | |
104 | + { | |
105 | + cb->last_errno = errno; | |
106 | + sc.errcode = cb->get_errno (cb); | |
107 | + } | |
108 | + | |
109 | + *result = sc.result; | |
110 | + *result2 = sc.result2; | |
111 | + *errcode = sc.errcode; | |
112 | +} | |
113 | + | |
114 | +long | |
115 | +sim_syscall (SIM_CPU *cpu, int func, long arg1, long arg2, long arg3, long arg4) | |
116 | +{ | |
117 | + long result, result2; | |
118 | + int errcode; | |
119 | + | |
120 | + sim_syscall_multi (cpu, func, arg1, arg2, arg3, arg4, &result, &result2, | |
121 | + &errcode); | |
122 | + if (result == -1) | |
123 | + return -errcode; | |
124 | + else | |
125 | + return result; | |
126 | +} |
@@ -20,6 +20,21 @@ | ||
20 | 20 | #ifndef SIM_SYSCALL_H |
21 | 21 | #define SIM_SYSCALL_H |
22 | 22 | |
23 | +/* Perform a syscall on the behalf of the target program. The error/result are | |
24 | + normalized into a single value (like a lot of operating systems do). If you | |
25 | + want the split values, see the other function below. | |
26 | + | |
27 | + Note: While cb_syscall requires you handle the exit syscall yourself, that is | |
28 | + not the case with these helpers. | |
29 | + | |
30 | + Note: Types here match the gdb callback interface. */ | |
31 | +long sim_syscall (SIM_CPU *, int func, long arg1, long arg2, long arg3, | |
32 | + long arg4); | |
33 | + | |
34 | +/* Same as sim_syscall, but return the split values by referenced. */ | |
35 | +void sim_syscall_multi (SIM_CPU *, int func, long arg1, long arg2, long arg3, | |
36 | + long arg4, long *result, long *result2, int *errcode); | |
37 | + | |
23 | 38 | /* Simple memory callbacks for cb_syscall's read_mem/write_mem that assume |
24 | 39 | cb_syscall's p1 and p2 are set to the SIM_DESC and SIM_CPU respectively. */ |
25 | 40 | int sim_syscall_read_mem (host_callback *, struct cb_syscall *, unsigned long, |
@@ -240,7 +240,7 @@ cb_syscall (host_callback *cb, CB_SYSCALL *sc) | ||
240 | 240 | #endif /* wip */ |
241 | 241 | |
242 | 242 | case CB_SYS_exit : |
243 | - /* Caller must catch and handle. */ | |
243 | + /* Caller must catch and handle; see sim_syscall as an example. */ | |
244 | 244 | break; |
245 | 245 | |
246 | 246 | case CB_SYS_open : |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * traps.c (lm32bf_scall_insn): Replace call to cb_syscall with | |
4 | + sim_syscall_multi. | |
5 | + | |
6 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
7 | + | |
3 | 8 | * traps.c: Include sim-syscall.h. |
4 | 9 | (syscall_read_mem, syscall_write_mem): Delete. |
5 | 10 | (lm32bf_scall_insn): Change syscall_read_mem/syscall_write_mem |
@@ -132,26 +132,18 @@ lm32bf_scall_insn (SIM_CPU * current_cpu, IADDR pc) | ||
132 | 132 | || (GET_H_GR (8) == TARGET_SYS_exit)) |
133 | 133 | { |
134 | 134 | /* Delegate system call to host O/S. */ |
135 | - CB_SYSCALL s; | |
136 | - CB_SYSCALL_INIT (&s); | |
137 | - s.p1 = (PTR) sd; | |
138 | - s.p2 = (PTR) current_cpu; | |
139 | - s.read_mem = sim_syscall_read_mem; | |
140 | - s.write_mem = sim_syscall_write_mem; | |
141 | - /* Extract parameters. */ | |
142 | - s.func = GET_H_GR (8); | |
143 | - s.arg1 = GET_H_GR (1); | |
144 | - s.arg2 = GET_H_GR (2); | |
145 | - s.arg3 = GET_H_GR (3); | |
146 | - /* Halt the simulator if the requested system call is _exit. */ | |
147 | - if (s.func == TARGET_SYS_exit) | |
148 | - sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1); | |
135 | + long result, result2; | |
136 | + int errcode; | |
137 | + | |
149 | 138 | /* Perform the system call. */ |
150 | - cb_syscall (cb, &s); | |
139 | + sim_syscall_multi (current_cpu, GET_H_GR (8), GET_H_GR (1), GET_H_GR (2), | |
140 | + GET_H_GR (3), GET_H_GR (4), &result, &result2, | |
141 | + &errcode); | |
151 | 142 | /* Store the return value in the CPU's registers. */ |
152 | - SET_H_GR (1, s.result); | |
153 | - SET_H_GR (2, s.result2); | |
154 | - SET_H_GR (3, s.errcode); | |
143 | + SET_H_GR (1, result); | |
144 | + SET_H_GR (2, result2); | |
145 | + SET_H_GR (3, errcode); | |
146 | + | |
155 | 147 | /* Skip over scall instruction. */ |
156 | 148 | return pc + 4; |
157 | 149 | } |
@@ -1,5 +1,11 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * traps.c (m32r_trap): Replace call to cb_syscall with | |
4 | + sim_syscall_multi. | |
5 | + * traps-linux.c (m32r_trap): Likewise. | |
6 | + | |
7 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
8 | + | |
3 | 9 | * traps-linux.c: Include sim-syscall.h. |
4 | 10 | (syscall_read_mem, syscall_write_mem): Delete. |
5 | 11 | (m32r_trap): Change syscall_read_mem/syscall_write_mem |
@@ -213,28 +213,21 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num) | ||
213 | 213 | { |
214 | 214 | case TRAP_ELF_SYSCALL : |
215 | 215 | { |
216 | - CB_SYSCALL s; | |
217 | - | |
218 | - CB_SYSCALL_INIT (&s); | |
219 | - s.func = m32rbf_h_gr_get (current_cpu, 0); | |
220 | - s.arg1 = m32rbf_h_gr_get (current_cpu, 1); | |
221 | - s.arg2 = m32rbf_h_gr_get (current_cpu, 2); | |
222 | - s.arg3 = m32rbf_h_gr_get (current_cpu, 3); | |
223 | - | |
224 | - if (s.func == TARGET_SYS_exit) | |
225 | - { | |
226 | - sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1); | |
227 | - } | |
228 | - | |
229 | - s.p1 = (PTR) sd; | |
230 | - s.p2 = (PTR) current_cpu; | |
231 | - s.read_mem = sim_syscall_read_mem; | |
232 | - s.write_mem = sim_syscall_write_mem; | |
233 | - cb_syscall (cb, &s); | |
234 | - m32rbf_h_gr_set (current_cpu, 2, s.errcode); | |
235 | - m32rbf_h_gr_set (current_cpu, 0, s.result); | |
236 | - m32rbf_h_gr_set (current_cpu, 1, s.result2); | |
237 | - break; | |
216 | + long result, result2; | |
217 | + int errcode; | |
218 | + | |
219 | + sim_syscall_multi (current_cpu, | |
220 | + m32rbf_h_gr_get (current_cpu, 0), | |
221 | + m32rbf_h_gr_get (current_cpu, 1), | |
222 | + m32rbf_h_gr_get (current_cpu, 2), | |
223 | + m32rbf_h_gr_get (current_cpu, 3), | |
224 | + m32rbf_h_gr_get (current_cpu, 4), | |
225 | + &result, &result2, &errcode); | |
226 | + | |
227 | + m32rbf_h_gr_set (current_cpu, 2, errcode); | |
228 | + m32rbf_h_gr_set (current_cpu, 0, result); | |
229 | + m32rbf_h_gr_set (current_cpu, 1, result2); | |
230 | + break; | |
238 | 231 | } |
239 | 232 | |
240 | 233 | case TRAP_LINUX_SYSCALL : |
@@ -129,27 +129,20 @@ m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num) | ||
129 | 129 | { |
130 | 130 | case TRAP_SYSCALL : |
131 | 131 | { |
132 | - CB_SYSCALL s; | |
133 | - | |
134 | - CB_SYSCALL_INIT (&s); | |
135 | - s.func = m32rbf_h_gr_get (current_cpu, 0); | |
136 | - s.arg1 = m32rbf_h_gr_get (current_cpu, 1); | |
137 | - s.arg2 = m32rbf_h_gr_get (current_cpu, 2); | |
138 | - s.arg3 = m32rbf_h_gr_get (current_cpu, 3); | |
139 | - | |
140 | - if (s.func == TARGET_SYS_exit) | |
141 | - { | |
142 | - sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1); | |
143 | - } | |
144 | - | |
145 | - s.p1 = (PTR) sd; | |
146 | - s.p2 = (PTR) current_cpu; | |
147 | - s.read_mem = sim_syscall_read_mem; | |
148 | - s.write_mem = sim_syscall_write_mem; | |
149 | - cb_syscall (cb, &s); | |
150 | - m32rbf_h_gr_set (current_cpu, 2, s.errcode); | |
151 | - m32rbf_h_gr_set (current_cpu, 0, s.result); | |
152 | - m32rbf_h_gr_set (current_cpu, 1, s.result2); | |
132 | + long result, result2; | |
133 | + int errcode; | |
134 | + | |
135 | + sim_syscall_multi (current_cpu, | |
136 | + m32rbf_h_gr_get (current_cpu, 0), | |
137 | + m32rbf_h_gr_get (current_cpu, 1), | |
138 | + m32rbf_h_gr_get (current_cpu, 2), | |
139 | + m32rbf_h_gr_get (current_cpu, 3), | |
140 | + m32rbf_h_gr_get (current_cpu, 4), | |
141 | + &result, &result2, &errcode); | |
142 | + | |
143 | + m32rbf_h_gr_set (current_cpu, 2, errcode); | |
144 | + m32rbf_h_gr_set (current_cpu, 0, result); | |
145 | + m32rbf_h_gr_set (current_cpu, 1, result2); | |
153 | 146 | break; |
154 | 147 | } |
155 | 148 |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * interp.c (handle_trap1): Replace call to cb_syscall with | |
4 | + sim_syscall. | |
5 | + | |
6 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
7 | + | |
3 | 8 | * interp.c: Include sim-syscall.h. |
4 | 9 | (syscall_read_mem, syscall_write_mem): Delete. |
5 | 10 | (m32r_trap): Change syscall_read_mem/syscall_write_mem |
@@ -203,26 +203,10 @@ set_initial_gprs (SIM_CPU *scpu) | ||
203 | 203 | static void |
204 | 204 | handle_trap1 (SIM_DESC sd) |
205 | 205 | { |
206 | - host_callback *cb = STATE_CALLBACK (sd); | |
207 | - CB_SYSCALL sc; | |
208 | - | |
209 | - CB_SYSCALL_INIT (&sc); | |
210 | - | |
211 | - sc.func = cpu.gr[TRAPCODE]; | |
212 | - sc.arg1 = cpu.gr[PARM1]; | |
213 | - sc.arg2 = cpu.gr[PARM2]; | |
214 | - sc.arg3 = cpu.gr[PARM3]; | |
215 | - sc.arg4 = cpu.gr[PARM4]; | |
216 | - | |
217 | - sc.p1 = (PTR) sd; | |
218 | - sc.p2 = (PTR) STATE_CPU (sd, 0); | |
219 | - sc.read_mem = sim_syscall_read_mem; | |
220 | - sc.write_mem = sim_syscall_write_mem; | |
221 | - | |
222 | - cb_syscall (cb, &sc); | |
223 | - | |
224 | 206 | /* XXX: We don't pass back the actual errno value. */ |
225 | - cpu.gr[RET1] = sc.result; | |
207 | + cpu.gr[RET1] = sim_syscall (STATE_CPU (sd, 0), cpu.gr[TRAPCODE], | |
208 | + cpu.gr[PARM1], cpu.gr[PARM2], cpu.gr[PARM3], | |
209 | + cpu.gr[PARM4]); | |
226 | 210 | } |
227 | 211 | |
228 | 212 | static void |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * op_utils.c (do_syscall): Replace call to cb_syscall with | |
4 | + sim_syscall_multi. | |
5 | + | |
6 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
7 | + | |
3 | 8 | * mn10300_sim.h (syscall_read_mem, syscall_write_mem): Delete. |
4 | 9 | * op_utils.c: Include sim-syscall.h. |
5 | 10 | (syscall_read_mem, syscall_write_mem): Delete. |
@@ -145,6 +145,15 @@ genericBtst(unsigned32 leftOpnd, unsigned32 rightOpnd) | ||
145 | 145 | INLINE_SIM_MAIN (void) |
146 | 146 | do_syscall (void) |
147 | 147 | { |
148 | + /* Registers passed to trap 0. */ | |
149 | + | |
150 | + /* Function number. */ | |
151 | + reg_t func = State.regs[0]; | |
152 | + /* Parameters. */ | |
153 | + reg_t parm1 = State.regs[1]; | |
154 | + reg_t parm2 = load_word (State.regs[REG_SP] + 12); | |
155 | + reg_t parm3 = load_word (State.regs[REG_SP] + 16); | |
156 | + reg_t parm4 = load_word (State.regs[REG_SP] + 20); | |
148 | 157 | |
149 | 158 | /* We use this for simulated system calls; we may need to change |
150 | 159 | it to a reserved instruction if we conflict with uses at |
@@ -152,46 +161,24 @@ do_syscall (void) | ||
152 | 161 | int save_errno = errno; |
153 | 162 | errno = 0; |
154 | 163 | |
155 | -/* Registers passed to trap 0 */ | |
156 | - | |
157 | -/* Function number. */ | |
158 | -#define FUNC (State.regs[0]) | |
159 | - | |
160 | -/* Parameters. */ | |
161 | -#define PARM1 (State.regs[1]) | |
162 | -#define PARM2 (load_word (State.regs[REG_SP] + 12)) | |
163 | -#define PARM3 (load_word (State.regs[REG_SP] + 16)) | |
164 | - | |
165 | -/* Registers set by trap 0 */ | |
166 | - | |
167 | -#define RETVAL State.regs[0] /* return value */ | |
168 | -#define RETERR State.regs[1] /* return error code */ | |
169 | - | |
170 | - if ( FUNC == TARGET_SYS_exit ) | |
164 | + if (func == TARGET_SYS_exit) | |
171 | 165 | { |
172 | - /* EXIT - caller can look in PARM1 to work out the reason */ | |
166 | + /* EXIT - caller can look in parm1 to work out the reason */ | |
173 | 167 | sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC, |
174 | - (PARM1 == 0xdead ? SIM_SIGABRT : sim_exited), PARM1); | |
168 | + (parm1 == 0xdead ? SIM_SIGABRT : sim_exited), parm1); | |
175 | 169 | } |
176 | 170 | else |
177 | 171 | { |
178 | - CB_SYSCALL syscall; | |
179 | - | |
180 | - CB_SYSCALL_INIT (&syscall); | |
181 | - syscall.arg1 = PARM1; | |
182 | - syscall.arg2 = PARM2; | |
183 | - syscall.arg3 = PARM3; | |
184 | - syscall.func = FUNC; | |
185 | - syscall.p1 = (PTR) simulator; | |
186 | - syscall.p2 = (PTR) STATE_CPU (simulator, 0); | |
187 | - syscall.read_mem = sim_syscall_read_mem; | |
188 | - syscall.write_mem = sim_syscall_write_mem; | |
189 | - cb_syscall (STATE_CALLBACK (simulator), &syscall); | |
190 | - RETERR = syscall.errcode; | |
191 | - RETVAL = syscall.result; | |
192 | - } | |
172 | + long result, result2; | |
173 | + int errcode; | |
193 | 174 | |
175 | + sim_syscall_multi (STATE_CPU (simulator, 0), func, parm1, parm2, | |
176 | + parm3, parm4, &result, &result2, &errcode); | |
177 | + | |
178 | + /* Registers set by trap 0. */ | |
179 | + State.regs[0] = errcode; | |
180 | + State.regs[1] = result; | |
181 | + } | |
194 | 182 | |
195 | 183 | errno = save_errno; |
196 | 184 | } |
197 | - |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2015-06-17 Mike Frysinger <vapier@gentoo.org> |
2 | 2 | |
3 | + * msp430-sim.c (maybe_perform_syscall): Replace call to cb_syscall | |
4 | + with sim_syscall. | |
5 | + | |
6 | +2015-06-17 Mike Frysinger <vapier@gentoo.org> | |
7 | + | |
3 | 8 | * msp430-sim.c: Include sim-syscall.h. |
4 | 9 | (syscall_read_mem, syscall_write_mem): Delete. |
5 | 10 | (maybe_perform_syscall): Change syscall_read_mem/syscall_write_mem |
@@ -1022,62 +1022,14 @@ maybe_perform_syscall (SIM_DESC sd, int call_addr) | ||
1022 | 1022 | { |
1023 | 1023 | /* Syscall! */ |
1024 | 1024 | int syscall_num = call_addr & 0x3f; |
1025 | - host_callback *cb = STATE_CALLBACK (sd); | |
1026 | - CB_SYSCALL sc; | |
1027 | - | |
1028 | - CB_SYSCALL_INIT (&sc); | |
1029 | - | |
1030 | - sc.func = syscall_num; | |
1031 | - sc.arg1 = MSP430_CPU (sd)->state.regs[12]; | |
1032 | - sc.arg2 = MSP430_CPU (sd)->state.regs[13]; | |
1033 | - sc.arg3 = MSP430_CPU (sd)->state.regs[14]; | |
1034 | - sc.arg4 = MSP430_CPU (sd)->state.regs[15]; | |
1035 | - | |
1036 | - if (TRACE_SYSCALL_P (MSP430_CPU (sd))) | |
1037 | - { | |
1038 | - const char *syscall_name = "*unknown*"; | |
1039 | - | |
1040 | - switch (syscall_num) | |
1041 | - { | |
1042 | - case TARGET_SYS_exit: | |
1043 | - syscall_name = "exit(%d)"; | |
1044 | - break; | |
1045 | - case TARGET_SYS_open: | |
1046 | - syscall_name = "open(%#x,%#x)"; | |
1047 | - break; | |
1048 | - case TARGET_SYS_close: | |
1049 | - syscall_name = "close(%d)"; | |
1050 | - break; | |
1051 | - case TARGET_SYS_read: | |
1052 | - syscall_name = "read(%d,%#x,%d)"; | |
1053 | - break; | |
1054 | - case TARGET_SYS_write: | |
1055 | - syscall_name = "write(%d,%#x,%d)"; | |
1056 | - break; | |
1057 | - } | |
1058 | - trace_generic (sd, MSP430_CPU (sd), TRACE_SYSCALL_IDX, | |
1059 | - syscall_name, sc.arg1, sc.arg2, sc.arg3, sc.arg4); | |
1060 | - } | |
1061 | - | |
1062 | - /* Handle SYS_exit here. */ | |
1063 | - if (syscall_num == 1) | |
1064 | - { | |
1065 | - sim_engine_halt (sd, MSP430_CPU (sd), NULL, | |
1066 | - MSP430_CPU (sd)->state.regs[0], | |
1067 | - sim_exited, sc.arg1); | |
1068 | - return 1; | |
1069 | - } | |
1070 | - | |
1071 | - sc.p1 = sd; | |
1072 | - sc.p2 = MSP430_CPU (sd); | |
1073 | - sc.read_mem = sim_syscall_read_mem; | |
1074 | - sc.write_mem = sim_syscall_write_mem; | |
1075 | - | |
1076 | - cb_syscall (cb, &sc); | |
1077 | - | |
1078 | - TRACE_SYSCALL (MSP430_CPU (sd), "returns %ld", sc.result); | |
1079 | - | |
1080 | - MSP430_CPU (sd)->state.regs[12] = sc.result; | |
1025 | + int arg1 = MSP430_CPU (sd)->state.regs[12]; | |
1026 | + int arg2 = MSP430_CPU (sd)->state.regs[13]; | |
1027 | + int arg3 = MSP430_CPU (sd)->state.regs[14]; | |
1028 | + int arg4 = MSP430_CPU (sd)->state.regs[15]; | |
1029 | + | |
1030 | + MSP430_CPU (sd)->state.regs[12] = sim_syscall (MSP430_CPU (sd), | |
1031 | + syscall_num, arg1, arg2, | |
1032 | + arg3, arg4); | |
1081 | 1033 | return 1; |
1082 | 1034 | } |
1083 | 1035 |