root / linux-user / main.c @ a7037b29
History | View | Annotate | Download (62.5 kB)
1 | 31e31b8a | bellard | /*
|
---|---|---|---|
2 | 93ac68bc | bellard | * qemu user main
|
3 | 31e31b8a | bellard | *
|
4 | 31e31b8a | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 31e31b8a | bellard | *
|
6 | 31e31b8a | bellard | * This program is free software; you can redistribute it and/or modify
|
7 | 31e31b8a | bellard | * it under the terms of the GNU General Public License as published by
|
8 | 31e31b8a | bellard | * the Free Software Foundation; either version 2 of the License, or
|
9 | 31e31b8a | bellard | * (at your option) any later version.
|
10 | 31e31b8a | bellard | *
|
11 | 31e31b8a | bellard | * This program is distributed in the hope that it will be useful,
|
12 | 31e31b8a | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 31e31b8a | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 31e31b8a | bellard | * GNU General Public License for more details.
|
15 | 31e31b8a | bellard | *
|
16 | 31e31b8a | bellard | * You should have received a copy of the GNU General Public License
|
17 | 31e31b8a | bellard | * along with this program; if not, write to the Free Software
|
18 | 31e31b8a | bellard | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
19 | 31e31b8a | bellard | */
|
20 | 31e31b8a | bellard | #include <stdlib.h> |
21 | 31e31b8a | bellard | #include <stdio.h> |
22 | 31e31b8a | bellard | #include <stdarg.h> |
23 | 04369ff2 | bellard | #include <string.h> |
24 | 31e31b8a | bellard | #include <errno.h> |
25 | 0ecfa993 | bellard | #include <unistd.h> |
26 | 31e31b8a | bellard | |
27 | 3ef693a0 | bellard | #include "qemu.h" |
28 | 31e31b8a | bellard | |
29 | 3ef693a0 | bellard | #define DEBUG_LOGFILE "/tmp/qemu.log" |
30 | 586314f2 | bellard | |
31 | 83fb7adf | bellard | #ifdef __APPLE__
|
32 | 83fb7adf | bellard | #include <crt_externs.h> |
33 | 83fb7adf | bellard | # define environ (*_NSGetEnviron())
|
34 | 83fb7adf | bellard | #endif
|
35 | 83fb7adf | bellard | |
36 | 74cd30b8 | bellard | static const char *interp_prefix = CONFIG_QEMU_PREFIX; |
37 | c5937220 | pbrook | const char *qemu_uname_release = CONFIG_UNAME_RELEASE; |
38 | 586314f2 | bellard | |
39 | 3a4739d6 | bellard | #if defined(__i386__) && !defined(CONFIG_STATIC)
|
40 | f801f97e | bellard | /* Force usage of an ELF interpreter even if it is an ELF shared
|
41 | f801f97e | bellard | object ! */
|
42 | f801f97e | bellard | const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; |
43 | 4304763b | bellard | #endif
|
44 | 74cd30b8 | bellard | |
45 | 93ac68bc | bellard | /* for recent libc, we add these dummy symbols which are not declared
|
46 | 74cd30b8 | bellard | when generating a linked object (bug in ld ?) */
|
47 | fbf59244 | bellard | #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) |
48 | c6981055 | bellard | long __preinit_array_start[0]; |
49 | c6981055 | bellard | long __preinit_array_end[0]; |
50 | 74cd30b8 | bellard | long __init_array_start[0]; |
51 | 74cd30b8 | bellard | long __init_array_end[0]; |
52 | 74cd30b8 | bellard | long __fini_array_start[0]; |
53 | 74cd30b8 | bellard | long __fini_array_end[0]; |
54 | 74cd30b8 | bellard | #endif
|
55 | 74cd30b8 | bellard | |
56 | 9de5e440 | bellard | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
|
57 | 9de5e440 | bellard | we allocate a bigger stack. Need a better solution, for example
|
58 | 9de5e440 | bellard | by remapping the process stack directly at the right place */
|
59 | 9de5e440 | bellard | unsigned long x86_stack_size = 512 * 1024; |
60 | 31e31b8a | bellard | |
61 | 31e31b8a | bellard | void gemu_log(const char *fmt, ...) |
62 | 31e31b8a | bellard | { |
63 | 31e31b8a | bellard | va_list ap; |
64 | 31e31b8a | bellard | |
65 | 31e31b8a | bellard | va_start(ap, fmt); |
66 | 31e31b8a | bellard | vfprintf(stderr, fmt, ap); |
67 | 31e31b8a | bellard | va_end(ap); |
68 | 31e31b8a | bellard | } |
69 | 31e31b8a | bellard | |
70 | 61190b14 | bellard | void cpu_outb(CPUState *env, int addr, int val) |
71 | 367e86e8 | bellard | { |
72 | 367e86e8 | bellard | fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
|
73 | 367e86e8 | bellard | } |
74 | 367e86e8 | bellard | |
75 | 61190b14 | bellard | void cpu_outw(CPUState *env, int addr, int val) |
76 | 367e86e8 | bellard | { |
77 | 367e86e8 | bellard | fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
|
78 | 367e86e8 | bellard | } |
79 | 367e86e8 | bellard | |
80 | 61190b14 | bellard | void cpu_outl(CPUState *env, int addr, int val) |
81 | 367e86e8 | bellard | { |
82 | 367e86e8 | bellard | fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
|
83 | 367e86e8 | bellard | } |
84 | 367e86e8 | bellard | |
85 | 61190b14 | bellard | int cpu_inb(CPUState *env, int addr) |
86 | 367e86e8 | bellard | { |
87 | 367e86e8 | bellard | fprintf(stderr, "inb: port=0x%04x\n", addr);
|
88 | 367e86e8 | bellard | return 0; |
89 | 367e86e8 | bellard | } |
90 | 367e86e8 | bellard | |
91 | 61190b14 | bellard | int cpu_inw(CPUState *env, int addr) |
92 | 367e86e8 | bellard | { |
93 | 367e86e8 | bellard | fprintf(stderr, "inw: port=0x%04x\n", addr);
|
94 | 367e86e8 | bellard | return 0; |
95 | 367e86e8 | bellard | } |
96 | 367e86e8 | bellard | |
97 | 61190b14 | bellard | int cpu_inl(CPUState *env, int addr) |
98 | 367e86e8 | bellard | { |
99 | 367e86e8 | bellard | fprintf(stderr, "inl: port=0x%04x\n", addr);
|
100 | 367e86e8 | bellard | return 0; |
101 | 367e86e8 | bellard | } |
102 | 367e86e8 | bellard | |
103 | a541f297 | bellard | int cpu_get_pic_interrupt(CPUState *env)
|
104 | 92ccca6a | bellard | { |
105 | 92ccca6a | bellard | return -1; |
106 | 92ccca6a | bellard | } |
107 | 92ccca6a | bellard | |
108 | 28ab0e2e | bellard | /* timers for rdtsc */
|
109 | 28ab0e2e | bellard | |
110 | 1dce7c3c | bellard | #if 0
|
111 | 28ab0e2e | bellard | |
112 | 28ab0e2e | bellard | static uint64_t emu_time;
|
113 | 28ab0e2e | bellard | |
114 | 28ab0e2e | bellard | int64_t cpu_get_real_ticks(void)
|
115 | 28ab0e2e | bellard | {
|
116 | 28ab0e2e | bellard | return emu_time++;
|
117 | 28ab0e2e | bellard | }
|
118 | 28ab0e2e | bellard | |
119 | 28ab0e2e | bellard | #endif
|
120 | 28ab0e2e | bellard | |
121 | a541f297 | bellard | #ifdef TARGET_I386
|
122 | a541f297 | bellard | /***********************************************************/
|
123 | a541f297 | bellard | /* CPUX86 core interface */
|
124 | a541f297 | bellard | |
125 | 02a1602e | bellard | void cpu_smm_update(CPUState *env)
|
126 | 02a1602e | bellard | { |
127 | 02a1602e | bellard | } |
128 | 02a1602e | bellard | |
129 | 28ab0e2e | bellard | uint64_t cpu_get_tsc(CPUX86State *env) |
130 | 28ab0e2e | bellard | { |
131 | 28ab0e2e | bellard | return cpu_get_real_ticks();
|
132 | 28ab0e2e | bellard | } |
133 | 28ab0e2e | bellard | |
134 | f4beb510 | bellard | static void write_dt(void *ptr, unsigned long addr, unsigned long limit, |
135 | f4beb510 | bellard | int flags)
|
136 | 6dbad63e | bellard | { |
137 | f4beb510 | bellard | unsigned int e1, e2; |
138 | 53a5960a | pbrook | uint32_t *p; |
139 | 6dbad63e | bellard | e1 = (addr << 16) | (limit & 0xffff); |
140 | 6dbad63e | bellard | e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000); |
141 | f4beb510 | bellard | e2 |= flags; |
142 | 53a5960a | pbrook | p = ptr; |
143 | 53a5960a | pbrook | p[0] = tswapl(e1);
|
144 | 53a5960a | pbrook | p[1] = tswapl(e2);
|
145 | f4beb510 | bellard | } |
146 | f4beb510 | bellard | |
147 | f4beb510 | bellard | static void set_gate(void *ptr, unsigned int type, unsigned int dpl, |
148 | f4beb510 | bellard | unsigned long addr, unsigned int sel) |
149 | f4beb510 | bellard | { |
150 | f4beb510 | bellard | unsigned int e1, e2; |
151 | 53a5960a | pbrook | uint32_t *p; |
152 | f4beb510 | bellard | e1 = (addr & 0xffff) | (sel << 16); |
153 | f4beb510 | bellard | e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8); |
154 | 53a5960a | pbrook | p = ptr; |
155 | 53a5960a | pbrook | p[0] = tswapl(e1);
|
156 | 53a5960a | pbrook | p[1] = tswapl(e2);
|
157 | 6dbad63e | bellard | } |
158 | 6dbad63e | bellard | |
159 | 6dbad63e | bellard | uint64_t gdt_table[6];
|
160 | f4beb510 | bellard | uint64_t idt_table[256];
|
161 | f4beb510 | bellard | |
162 | f4beb510 | bellard | /* only dpl matters as we do only user space emulation */
|
163 | f4beb510 | bellard | static void set_idt(int n, unsigned int dpl) |
164 | f4beb510 | bellard | { |
165 | f4beb510 | bellard | set_gate(idt_table + n, 0, dpl, 0, 0); |
166 | f4beb510 | bellard | } |
167 | 31e31b8a | bellard | |
168 | 89e957e7 | bellard | void cpu_loop(CPUX86State *env)
|
169 | 1b6b029e | bellard | { |
170 | bc8a22cc | bellard | int trapnr;
|
171 | 80a9d035 | bellard | target_ulong pc; |
172 | 9de5e440 | bellard | target_siginfo_t info; |
173 | 851e67a1 | bellard | |
174 | 1b6b029e | bellard | for(;;) {
|
175 | bc8a22cc | bellard | trapnr = cpu_x86_exec(env); |
176 | bc8a22cc | bellard | switch(trapnr) {
|
177 | f4beb510 | bellard | case 0x80: |
178 | f4beb510 | bellard | /* linux syscall */
|
179 | f4beb510 | bellard | env->regs[R_EAX] = do_syscall(env, |
180 | f4beb510 | bellard | env->regs[R_EAX], |
181 | f4beb510 | bellard | env->regs[R_EBX], |
182 | f4beb510 | bellard | env->regs[R_ECX], |
183 | f4beb510 | bellard | env->regs[R_EDX], |
184 | f4beb510 | bellard | env->regs[R_ESI], |
185 | f4beb510 | bellard | env->regs[R_EDI], |
186 | f4beb510 | bellard | env->regs[R_EBP]); |
187 | f4beb510 | bellard | break;
|
188 | f4beb510 | bellard | case EXCP0B_NOSEG:
|
189 | f4beb510 | bellard | case EXCP0C_STACK:
|
190 | f4beb510 | bellard | info.si_signo = SIGBUS; |
191 | f4beb510 | bellard | info.si_errno = 0;
|
192 | f4beb510 | bellard | info.si_code = TARGET_SI_KERNEL; |
193 | f4beb510 | bellard | info._sifields._sigfault._addr = 0;
|
194 | f4beb510 | bellard | queue_signal(info.si_signo, &info); |
195 | f4beb510 | bellard | break;
|
196 | 1b6b029e | bellard | case EXCP0D_GPF:
|
197 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
198 | 851e67a1 | bellard | if (env->eflags & VM_MASK) {
|
199 | 89e957e7 | bellard | handle_vm86_fault(env); |
200 | 84409ddb | j_mayer | } else
|
201 | 84409ddb | j_mayer | #endif
|
202 | 84409ddb | j_mayer | { |
203 | f4beb510 | bellard | info.si_signo = SIGSEGV; |
204 | f4beb510 | bellard | info.si_errno = 0;
|
205 | f4beb510 | bellard | info.si_code = TARGET_SI_KERNEL; |
206 | f4beb510 | bellard | info._sifields._sigfault._addr = 0;
|
207 | f4beb510 | bellard | queue_signal(info.si_signo, &info); |
208 | 1b6b029e | bellard | } |
209 | 1b6b029e | bellard | break;
|
210 | b689bc57 | bellard | case EXCP0E_PAGE:
|
211 | b689bc57 | bellard | info.si_signo = SIGSEGV; |
212 | b689bc57 | bellard | info.si_errno = 0;
|
213 | b689bc57 | bellard | if (!(env->error_code & 1)) |
214 | b689bc57 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
215 | b689bc57 | bellard | else
|
216 | b689bc57 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
217 | 970a87a6 | bellard | info._sifields._sigfault._addr = env->cr[2];
|
218 | b689bc57 | bellard | queue_signal(info.si_signo, &info); |
219 | b689bc57 | bellard | break;
|
220 | 9de5e440 | bellard | case EXCP00_DIVZ:
|
221 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
222 | bc8a22cc | bellard | if (env->eflags & VM_MASK) {
|
223 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
224 | 84409ddb | j_mayer | } else
|
225 | 84409ddb | j_mayer | #endif
|
226 | 84409ddb | j_mayer | { |
227 | bc8a22cc | bellard | /* division by zero */
|
228 | bc8a22cc | bellard | info.si_signo = SIGFPE; |
229 | bc8a22cc | bellard | info.si_errno = 0;
|
230 | bc8a22cc | bellard | info.si_code = TARGET_FPE_INTDIV; |
231 | bc8a22cc | bellard | info._sifields._sigfault._addr = env->eip; |
232 | bc8a22cc | bellard | queue_signal(info.si_signo, &info); |
233 | bc8a22cc | bellard | } |
234 | 9de5e440 | bellard | break;
|
235 | 447db213 | bellard | case EXCP01_SSTP:
|
236 | 447db213 | bellard | case EXCP03_INT3:
|
237 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
238 | 447db213 | bellard | if (env->eflags & VM_MASK) {
|
239 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
240 | 84409ddb | j_mayer | } else
|
241 | 84409ddb | j_mayer | #endif
|
242 | 84409ddb | j_mayer | { |
243 | 447db213 | bellard | info.si_signo = SIGTRAP; |
244 | 447db213 | bellard | info.si_errno = 0;
|
245 | 447db213 | bellard | if (trapnr == EXCP01_SSTP) {
|
246 | 447db213 | bellard | info.si_code = TARGET_TRAP_BRKPT; |
247 | 447db213 | bellard | info._sifields._sigfault._addr = env->eip; |
248 | 447db213 | bellard | } else {
|
249 | 447db213 | bellard | info.si_code = TARGET_SI_KERNEL; |
250 | 447db213 | bellard | info._sifields._sigfault._addr = 0;
|
251 | 447db213 | bellard | } |
252 | 447db213 | bellard | queue_signal(info.si_signo, &info); |
253 | 447db213 | bellard | } |
254 | 447db213 | bellard | break;
|
255 | 9de5e440 | bellard | case EXCP04_INTO:
|
256 | 9de5e440 | bellard | case EXCP05_BOUND:
|
257 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
258 | bc8a22cc | bellard | if (env->eflags & VM_MASK) {
|
259 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
260 | 84409ddb | j_mayer | } else
|
261 | 84409ddb | j_mayer | #endif
|
262 | 84409ddb | j_mayer | { |
263 | bc8a22cc | bellard | info.si_signo = SIGSEGV; |
264 | bc8a22cc | bellard | info.si_errno = 0;
|
265 | b689bc57 | bellard | info.si_code = TARGET_SI_KERNEL; |
266 | bc8a22cc | bellard | info._sifields._sigfault._addr = 0;
|
267 | bc8a22cc | bellard | queue_signal(info.si_signo, &info); |
268 | bc8a22cc | bellard | } |
269 | 9de5e440 | bellard | break;
|
270 | 9de5e440 | bellard | case EXCP06_ILLOP:
|
271 | 9de5e440 | bellard | info.si_signo = SIGILL; |
272 | 9de5e440 | bellard | info.si_errno = 0;
|
273 | 9de5e440 | bellard | info.si_code = TARGET_ILL_ILLOPN; |
274 | 9de5e440 | bellard | info._sifields._sigfault._addr = env->eip; |
275 | 9de5e440 | bellard | queue_signal(info.si_signo, &info); |
276 | 9de5e440 | bellard | break;
|
277 | 9de5e440 | bellard | case EXCP_INTERRUPT:
|
278 | 9de5e440 | bellard | /* just indicate that signals should be handled asap */
|
279 | 9de5e440 | bellard | break;
|
280 | 1fddef4b | bellard | case EXCP_DEBUG:
|
281 | 1fddef4b | bellard | { |
282 | 1fddef4b | bellard | int sig;
|
283 | 1fddef4b | bellard | |
284 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
285 | 1fddef4b | bellard | if (sig)
|
286 | 1fddef4b | bellard | { |
287 | 1fddef4b | bellard | info.si_signo = sig; |
288 | 1fddef4b | bellard | info.si_errno = 0;
|
289 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
290 | 1fddef4b | bellard | queue_signal(info.si_signo, &info); |
291 | 1fddef4b | bellard | } |
292 | 1fddef4b | bellard | } |
293 | 1fddef4b | bellard | break;
|
294 | 1b6b029e | bellard | default:
|
295 | 970a87a6 | bellard | pc = env->segs[R_CS].base + env->eip; |
296 | bc8a22cc | bellard | fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
|
297 | bc8a22cc | bellard | (long)pc, trapnr);
|
298 | 1b6b029e | bellard | abort(); |
299 | 1b6b029e | bellard | } |
300 | 66fb9763 | bellard | process_pending_signals(env); |
301 | 1b6b029e | bellard | } |
302 | 1b6b029e | bellard | } |
303 | b346ff46 | bellard | #endif
|
304 | b346ff46 | bellard | |
305 | b346ff46 | bellard | #ifdef TARGET_ARM
|
306 | b346ff46 | bellard | |
307 | 6f1f31c0 | bellard | /* XXX: find a better solution */
|
308 | 6f1f31c0 | bellard | extern void tb_invalidate_page_range(target_ulong start, target_ulong end); |
309 | 6f1f31c0 | bellard | |
310 | 6f1f31c0 | bellard | static void arm_cache_flush(target_ulong start, target_ulong last) |
311 | 6f1f31c0 | bellard | { |
312 | 6f1f31c0 | bellard | target_ulong addr, last1; |
313 | 6f1f31c0 | bellard | |
314 | 6f1f31c0 | bellard | if (last < start)
|
315 | 6f1f31c0 | bellard | return;
|
316 | 6f1f31c0 | bellard | addr = start; |
317 | 6f1f31c0 | bellard | for(;;) {
|
318 | 6f1f31c0 | bellard | last1 = ((addr + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK) - 1;
|
319 | 6f1f31c0 | bellard | if (last1 > last)
|
320 | 6f1f31c0 | bellard | last1 = last; |
321 | 6f1f31c0 | bellard | tb_invalidate_page_range(addr, last1 + 1);
|
322 | 6f1f31c0 | bellard | if (last1 == last)
|
323 | 6f1f31c0 | bellard | break;
|
324 | 6f1f31c0 | bellard | addr = last1 + 1;
|
325 | 6f1f31c0 | bellard | } |
326 | 6f1f31c0 | bellard | } |
327 | 6f1f31c0 | bellard | |
328 | b346ff46 | bellard | void cpu_loop(CPUARMState *env)
|
329 | b346ff46 | bellard | { |
330 | b346ff46 | bellard | int trapnr;
|
331 | b346ff46 | bellard | unsigned int n, insn; |
332 | b346ff46 | bellard | target_siginfo_t info; |
333 | b5ff1b31 | bellard | uint32_t addr; |
334 | b346ff46 | bellard | |
335 | b346ff46 | bellard | for(;;) {
|
336 | b346ff46 | bellard | trapnr = cpu_arm_exec(env); |
337 | b346ff46 | bellard | switch(trapnr) {
|
338 | b346ff46 | bellard | case EXCP_UDEF:
|
339 | c6981055 | bellard | { |
340 | c6981055 | bellard | TaskState *ts = env->opaque; |
341 | c6981055 | bellard | uint32_t opcode; |
342 | c6981055 | bellard | |
343 | c6981055 | bellard | /* we handle the FPU emulation here, as Linux */
|
344 | c6981055 | bellard | /* we get the opcode */
|
345 | 53a5960a | pbrook | opcode = tget32(env->regs[15]);
|
346 | c6981055 | bellard | |
347 | 19b045de | pbrook | if (EmulateAll(opcode, &ts->fpa, env) == 0) { |
348 | c6981055 | bellard | info.si_signo = SIGILL; |
349 | c6981055 | bellard | info.si_errno = 0;
|
350 | c6981055 | bellard | info.si_code = TARGET_ILL_ILLOPN; |
351 | c6981055 | bellard | info._sifields._sigfault._addr = env->regs[15];
|
352 | c6981055 | bellard | queue_signal(info.si_signo, &info); |
353 | c6981055 | bellard | } else {
|
354 | c6981055 | bellard | /* increment PC */
|
355 | c6981055 | bellard | env->regs[15] += 4; |
356 | c6981055 | bellard | } |
357 | c6981055 | bellard | } |
358 | b346ff46 | bellard | break;
|
359 | b346ff46 | bellard | case EXCP_SWI:
|
360 | 06c949e6 | pbrook | case EXCP_BKPT:
|
361 | b346ff46 | bellard | { |
362 | ce4defa0 | pbrook | env->eabi = 1;
|
363 | b346ff46 | bellard | /* system call */
|
364 | 06c949e6 | pbrook | if (trapnr == EXCP_BKPT) {
|
365 | 06c949e6 | pbrook | if (env->thumb) {
|
366 | 53a5960a | pbrook | insn = tget16(env->regs[15]);
|
367 | 06c949e6 | pbrook | n = insn & 0xff;
|
368 | 06c949e6 | pbrook | env->regs[15] += 2; |
369 | 06c949e6 | pbrook | } else {
|
370 | 53a5960a | pbrook | insn = tget32(env->regs[15]);
|
371 | 06c949e6 | pbrook | n = (insn & 0xf) | ((insn >> 4) & 0xff0); |
372 | 06c949e6 | pbrook | env->regs[15] += 4; |
373 | 06c949e6 | pbrook | } |
374 | 192c7bd9 | bellard | } else {
|
375 | 06c949e6 | pbrook | if (env->thumb) {
|
376 | 53a5960a | pbrook | insn = tget16(env->regs[15] - 2); |
377 | 06c949e6 | pbrook | n = insn & 0xff;
|
378 | 06c949e6 | pbrook | } else {
|
379 | 53a5960a | pbrook | insn = tget32(env->regs[15] - 4); |
380 | 06c949e6 | pbrook | n = insn & 0xffffff;
|
381 | 06c949e6 | pbrook | } |
382 | 192c7bd9 | bellard | } |
383 | 192c7bd9 | bellard | |
384 | 6f1f31c0 | bellard | if (n == ARM_NR_cacheflush) {
|
385 | 6f1f31c0 | bellard | arm_cache_flush(env->regs[0], env->regs[1]); |
386 | a4f81979 | bellard | } else if (n == ARM_NR_semihosting |
387 | a4f81979 | bellard | || n == ARM_NR_thumb_semihosting) { |
388 | a4f81979 | bellard | env->regs[0] = do_arm_semihosting (env);
|
389 | ce4defa0 | pbrook | } else if (n == 0 || n >= ARM_SYSCALL_BASE |
390 | 192c7bd9 | bellard | || (env->thumb && n == ARM_THUMB_SYSCALL)) { |
391 | b346ff46 | bellard | /* linux syscall */
|
392 | ce4defa0 | pbrook | if (env->thumb || n == 0) { |
393 | 192c7bd9 | bellard | n = env->regs[7];
|
394 | 192c7bd9 | bellard | } else {
|
395 | 192c7bd9 | bellard | n -= ARM_SYSCALL_BASE; |
396 | ce4defa0 | pbrook | env->eabi = 0;
|
397 | 192c7bd9 | bellard | } |
398 | b346ff46 | bellard | env->regs[0] = do_syscall(env,
|
399 | b346ff46 | bellard | n, |
400 | b346ff46 | bellard | env->regs[0],
|
401 | b346ff46 | bellard | env->regs[1],
|
402 | b346ff46 | bellard | env->regs[2],
|
403 | b346ff46 | bellard | env->regs[3],
|
404 | b346ff46 | bellard | env->regs[4],
|
405 | e1a2849c | bellard | env->regs[5]);
|
406 | b346ff46 | bellard | } else {
|
407 | b346ff46 | bellard | goto error;
|
408 | b346ff46 | bellard | } |
409 | b346ff46 | bellard | } |
410 | b346ff46 | bellard | break;
|
411 | 43fff238 | bellard | case EXCP_INTERRUPT:
|
412 | 43fff238 | bellard | /* just indicate that signals should be handled asap */
|
413 | 43fff238 | bellard | break;
|
414 | 68016c62 | bellard | case EXCP_PREFETCH_ABORT:
|
415 | b5ff1b31 | bellard | addr = env->cp15.c6_data; |
416 | b5ff1b31 | bellard | goto do_segv;
|
417 | 68016c62 | bellard | case EXCP_DATA_ABORT:
|
418 | b5ff1b31 | bellard | addr = env->cp15.c6_insn; |
419 | b5ff1b31 | bellard | goto do_segv;
|
420 | b5ff1b31 | bellard | do_segv:
|
421 | 68016c62 | bellard | { |
422 | 68016c62 | bellard | info.si_signo = SIGSEGV; |
423 | 68016c62 | bellard | info.si_errno = 0;
|
424 | 68016c62 | bellard | /* XXX: check env->error_code */
|
425 | 68016c62 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
426 | b5ff1b31 | bellard | info._sifields._sigfault._addr = addr; |
427 | 68016c62 | bellard | queue_signal(info.si_signo, &info); |
428 | 68016c62 | bellard | } |
429 | 68016c62 | bellard | break;
|
430 | 1fddef4b | bellard | case EXCP_DEBUG:
|
431 | 1fddef4b | bellard | { |
432 | 1fddef4b | bellard | int sig;
|
433 | 1fddef4b | bellard | |
434 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
435 | 1fddef4b | bellard | if (sig)
|
436 | 1fddef4b | bellard | { |
437 | 1fddef4b | bellard | info.si_signo = sig; |
438 | 1fddef4b | bellard | info.si_errno = 0;
|
439 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
440 | 1fddef4b | bellard | queue_signal(info.si_signo, &info); |
441 | 1fddef4b | bellard | } |
442 | 1fddef4b | bellard | } |
443 | 1fddef4b | bellard | break;
|
444 | b346ff46 | bellard | default:
|
445 | b346ff46 | bellard | error:
|
446 | b346ff46 | bellard | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
447 | b346ff46 | bellard | trapnr); |
448 | 7fe48483 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
449 | b346ff46 | bellard | abort(); |
450 | b346ff46 | bellard | } |
451 | b346ff46 | bellard | process_pending_signals(env); |
452 | b346ff46 | bellard | } |
453 | b346ff46 | bellard | } |
454 | b346ff46 | bellard | |
455 | b346ff46 | bellard | #endif
|
456 | 1b6b029e | bellard | |
457 | 93ac68bc | bellard | #ifdef TARGET_SPARC
|
458 | 93ac68bc | bellard | |
459 | 060366c5 | bellard | //#define DEBUG_WIN
|
460 | 060366c5 | bellard | |
461 | 2623cbaf | bellard | /* WARNING: dealing with register windows _is_ complicated. More info
|
462 | 2623cbaf | bellard | can be found at http://www.sics.se/~psm/sparcstack.html */
|
463 | 060366c5 | bellard | static inline int get_reg_index(CPUSPARCState *env, int cwp, int index) |
464 | 060366c5 | bellard | { |
465 | 060366c5 | bellard | index = (index + cwp * 16) & (16 * NWINDOWS - 1); |
466 | 060366c5 | bellard | /* wrap handling : if cwp is on the last window, then we use the
|
467 | 060366c5 | bellard | registers 'after' the end */
|
468 | 060366c5 | bellard | if (index < 8 && env->cwp == (NWINDOWS - 1)) |
469 | 060366c5 | bellard | index += (16 * NWINDOWS);
|
470 | 060366c5 | bellard | return index;
|
471 | 060366c5 | bellard | } |
472 | 060366c5 | bellard | |
473 | 2623cbaf | bellard | /* save the register window 'cwp1' */
|
474 | 2623cbaf | bellard | static inline void save_window_offset(CPUSPARCState *env, int cwp1) |
475 | 060366c5 | bellard | { |
476 | 2623cbaf | bellard | unsigned int i; |
477 | 53a5960a | pbrook | target_ulong sp_ptr; |
478 | 060366c5 | bellard | |
479 | 53a5960a | pbrook | sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
|
480 | 060366c5 | bellard | #if defined(DEBUG_WIN)
|
481 | 060366c5 | bellard | printf("win_overflow: sp_ptr=0x%x save_cwp=%d\n",
|
482 | 060366c5 | bellard | (int)sp_ptr, cwp1);
|
483 | 060366c5 | bellard | #endif
|
484 | 2623cbaf | bellard | for(i = 0; i < 16; i++) { |
485 | 53a5960a | pbrook | tputl(sp_ptr, env->regbase[get_reg_index(env, cwp1, 8 + i)]);
|
486 | 53a5960a | pbrook | sp_ptr += sizeof(target_ulong);
|
487 | 2623cbaf | bellard | } |
488 | 060366c5 | bellard | } |
489 | 060366c5 | bellard | |
490 | 060366c5 | bellard | static void save_window(CPUSPARCState *env) |
491 | 060366c5 | bellard | { |
492 | 5ef54116 | bellard | #ifndef TARGET_SPARC64
|
493 | 2623cbaf | bellard | unsigned int new_wim; |
494 | 2623cbaf | bellard | new_wim = ((env->wim >> 1) | (env->wim << (NWINDOWS - 1))) & |
495 | 2623cbaf | bellard | ((1LL << NWINDOWS) - 1); |
496 | 2623cbaf | bellard | save_window_offset(env, (env->cwp - 2) & (NWINDOWS - 1)); |
497 | 2623cbaf | bellard | env->wim = new_wim; |
498 | 5ef54116 | bellard | #else
|
499 | 5ef54116 | bellard | save_window_offset(env, (env->cwp - 2) & (NWINDOWS - 1)); |
500 | 5ef54116 | bellard | env->cansave++; |
501 | 5ef54116 | bellard | env->canrestore--; |
502 | 5ef54116 | bellard | #endif
|
503 | 060366c5 | bellard | } |
504 | 060366c5 | bellard | |
505 | 060366c5 | bellard | static void restore_window(CPUSPARCState *env) |
506 | 060366c5 | bellard | { |
507 | 060366c5 | bellard | unsigned int new_wim, i, cwp1; |
508 | 53a5960a | pbrook | target_ulong sp_ptr; |
509 | 060366c5 | bellard | |
510 | 060366c5 | bellard | new_wim = ((env->wim << 1) | (env->wim >> (NWINDOWS - 1))) & |
511 | 060366c5 | bellard | ((1LL << NWINDOWS) - 1); |
512 | 060366c5 | bellard | |
513 | 060366c5 | bellard | /* restore the invalid window */
|
514 | 060366c5 | bellard | cwp1 = (env->cwp + 1) & (NWINDOWS - 1); |
515 | 53a5960a | pbrook | sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
|
516 | 060366c5 | bellard | #if defined(DEBUG_WIN)
|
517 | 060366c5 | bellard | printf("win_underflow: sp_ptr=0x%x load_cwp=%d\n",
|
518 | 060366c5 | bellard | (int)sp_ptr, cwp1);
|
519 | 060366c5 | bellard | #endif
|
520 | 2623cbaf | bellard | for(i = 0; i < 16; i++) { |
521 | 53a5960a | pbrook | env->regbase[get_reg_index(env, cwp1, 8 + i)] = tgetl(sp_ptr);
|
522 | 53a5960a | pbrook | sp_ptr += sizeof(target_ulong);
|
523 | 2623cbaf | bellard | } |
524 | 060366c5 | bellard | env->wim = new_wim; |
525 | 5ef54116 | bellard | #ifdef TARGET_SPARC64
|
526 | 5ef54116 | bellard | env->canrestore++; |
527 | 5ef54116 | bellard | if (env->cleanwin < NWINDOWS - 1) |
528 | 5ef54116 | bellard | env->cleanwin++; |
529 | 5ef54116 | bellard | env->cansave--; |
530 | 5ef54116 | bellard | #endif
|
531 | 060366c5 | bellard | } |
532 | 060366c5 | bellard | |
533 | 060366c5 | bellard | static void flush_windows(CPUSPARCState *env) |
534 | 060366c5 | bellard | { |
535 | 060366c5 | bellard | int offset, cwp1;
|
536 | 2623cbaf | bellard | |
537 | 2623cbaf | bellard | offset = 1;
|
538 | 060366c5 | bellard | for(;;) {
|
539 | 060366c5 | bellard | /* if restore would invoke restore_window(), then we can stop */
|
540 | 2623cbaf | bellard | cwp1 = (env->cwp + offset) & (NWINDOWS - 1);
|
541 | 060366c5 | bellard | if (env->wim & (1 << cwp1)) |
542 | 060366c5 | bellard | break;
|
543 | 2623cbaf | bellard | save_window_offset(env, cwp1); |
544 | 060366c5 | bellard | offset++; |
545 | 060366c5 | bellard | } |
546 | 2623cbaf | bellard | /* set wim so that restore will reload the registers */
|
547 | 2623cbaf | bellard | cwp1 = (env->cwp + 1) & (NWINDOWS - 1); |
548 | 2623cbaf | bellard | env->wim = 1 << cwp1;
|
549 | 2623cbaf | bellard | #if defined(DEBUG_WIN)
|
550 | 2623cbaf | bellard | printf("flush_windows: nb=%d\n", offset - 1); |
551 | 80a9d035 | bellard | #endif
|
552 | 2623cbaf | bellard | } |
553 | 060366c5 | bellard | |
554 | 93ac68bc | bellard | void cpu_loop (CPUSPARCState *env)
|
555 | 93ac68bc | bellard | { |
556 | 060366c5 | bellard | int trapnr, ret;
|
557 | 61ff6f58 | bellard | target_siginfo_t info; |
558 | 060366c5 | bellard | |
559 | 060366c5 | bellard | while (1) { |
560 | 060366c5 | bellard | trapnr = cpu_sparc_exec (env); |
561 | 060366c5 | bellard | |
562 | 060366c5 | bellard | switch (trapnr) {
|
563 | 5ef54116 | bellard | #ifndef TARGET_SPARC64
|
564 | 060366c5 | bellard | case 0x88: |
565 | 060366c5 | bellard | case 0x90: |
566 | 5ef54116 | bellard | #else
|
567 | 5ef54116 | bellard | case 0x16d: |
568 | 5ef54116 | bellard | #endif
|
569 | 060366c5 | bellard | ret = do_syscall (env, env->gregs[1],
|
570 | 060366c5 | bellard | env->regwptr[0], env->regwptr[1], |
571 | 060366c5 | bellard | env->regwptr[2], env->regwptr[3], |
572 | 060366c5 | bellard | env->regwptr[4], env->regwptr[5]); |
573 | 060366c5 | bellard | if ((unsigned int)ret >= (unsigned int)(-515)) { |
574 | 27908725 | bellard | #ifdef TARGET_SPARC64
|
575 | 27908725 | bellard | env->xcc |= PSR_CARRY; |
576 | 27908725 | bellard | #else
|
577 | 060366c5 | bellard | env->psr |= PSR_CARRY; |
578 | 27908725 | bellard | #endif
|
579 | 060366c5 | bellard | ret = -ret; |
580 | 060366c5 | bellard | } else {
|
581 | 27908725 | bellard | #ifdef TARGET_SPARC64
|
582 | 27908725 | bellard | env->xcc &= ~PSR_CARRY; |
583 | 27908725 | bellard | #else
|
584 | 060366c5 | bellard | env->psr &= ~PSR_CARRY; |
585 | 27908725 | bellard | #endif
|
586 | 060366c5 | bellard | } |
587 | 060366c5 | bellard | env->regwptr[0] = ret;
|
588 | 060366c5 | bellard | /* next instruction */
|
589 | 060366c5 | bellard | env->pc = env->npc; |
590 | 060366c5 | bellard | env->npc = env->npc + 4;
|
591 | 060366c5 | bellard | break;
|
592 | 060366c5 | bellard | case 0x83: /* flush windows */ |
593 | 2623cbaf | bellard | flush_windows(env); |
594 | 060366c5 | bellard | /* next instruction */
|
595 | 060366c5 | bellard | env->pc = env->npc; |
596 | 060366c5 | bellard | env->npc = env->npc + 4;
|
597 | 060366c5 | bellard | break;
|
598 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
599 | 060366c5 | bellard | case TT_WIN_OVF: /* window overflow */ |
600 | 060366c5 | bellard | save_window(env); |
601 | 060366c5 | bellard | break;
|
602 | 060366c5 | bellard | case TT_WIN_UNF: /* window underflow */ |
603 | 060366c5 | bellard | restore_window(env); |
604 | 060366c5 | bellard | break;
|
605 | 61ff6f58 | bellard | case TT_TFAULT:
|
606 | 61ff6f58 | bellard | case TT_DFAULT:
|
607 | 61ff6f58 | bellard | { |
608 | 61ff6f58 | bellard | info.si_signo = SIGSEGV; |
609 | 61ff6f58 | bellard | info.si_errno = 0;
|
610 | 61ff6f58 | bellard | /* XXX: check env->error_code */
|
611 | 61ff6f58 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
612 | 61ff6f58 | bellard | info._sifields._sigfault._addr = env->mmuregs[4];
|
613 | 61ff6f58 | bellard | queue_signal(info.si_signo, &info); |
614 | 61ff6f58 | bellard | } |
615 | 61ff6f58 | bellard | break;
|
616 | 3475187d | bellard | #else
|
617 | 5ef54116 | bellard | case TT_SPILL: /* window overflow */ |
618 | 5ef54116 | bellard | save_window(env); |
619 | 5ef54116 | bellard | break;
|
620 | 5ef54116 | bellard | case TT_FILL: /* window underflow */ |
621 | 5ef54116 | bellard | restore_window(env); |
622 | 5ef54116 | bellard | break;
|
623 | 3475187d | bellard | // XXX
|
624 | 3475187d | bellard | #endif
|
625 | 48dc41eb | bellard | case EXCP_INTERRUPT:
|
626 | 48dc41eb | bellard | /* just indicate that signals should be handled asap */
|
627 | 48dc41eb | bellard | break;
|
628 | 1fddef4b | bellard | case EXCP_DEBUG:
|
629 | 1fddef4b | bellard | { |
630 | 1fddef4b | bellard | int sig;
|
631 | 1fddef4b | bellard | |
632 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
633 | 1fddef4b | bellard | if (sig)
|
634 | 1fddef4b | bellard | { |
635 | 1fddef4b | bellard | info.si_signo = sig; |
636 | 1fddef4b | bellard | info.si_errno = 0;
|
637 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
638 | 1fddef4b | bellard | queue_signal(info.si_signo, &info); |
639 | 1fddef4b | bellard | } |
640 | 1fddef4b | bellard | } |
641 | 1fddef4b | bellard | break;
|
642 | 060366c5 | bellard | default:
|
643 | 060366c5 | bellard | printf ("Unhandled trap: 0x%x\n", trapnr);
|
644 | 7fe48483 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
645 | 060366c5 | bellard | exit (1);
|
646 | 060366c5 | bellard | } |
647 | 060366c5 | bellard | process_pending_signals (env); |
648 | 060366c5 | bellard | } |
649 | 93ac68bc | bellard | } |
650 | 93ac68bc | bellard | |
651 | 93ac68bc | bellard | #endif
|
652 | 93ac68bc | bellard | |
653 | 67867308 | bellard | #ifdef TARGET_PPC
|
654 | 9fddaa0c | bellard | |
655 | 9fddaa0c | bellard | static inline uint64_t cpu_ppc_get_tb (CPUState *env) |
656 | 9fddaa0c | bellard | { |
657 | 9fddaa0c | bellard | /* TO FIX */
|
658 | 9fddaa0c | bellard | return 0; |
659 | 9fddaa0c | bellard | } |
660 | 9fddaa0c | bellard | |
661 | 9fddaa0c | bellard | uint32_t cpu_ppc_load_tbl (CPUState *env) |
662 | 9fddaa0c | bellard | { |
663 | 9fddaa0c | bellard | return cpu_ppc_get_tb(env) & 0xFFFFFFFF; |
664 | 9fddaa0c | bellard | } |
665 | 9fddaa0c | bellard | |
666 | 9fddaa0c | bellard | uint32_t cpu_ppc_load_tbu (CPUState *env) |
667 | 9fddaa0c | bellard | { |
668 | 9fddaa0c | bellard | return cpu_ppc_get_tb(env) >> 32; |
669 | 9fddaa0c | bellard | } |
670 | 9fddaa0c | bellard | |
671 | 9fddaa0c | bellard | static void cpu_ppc_store_tb (CPUState *env, uint64_t value) |
672 | 9fddaa0c | bellard | { |
673 | 9fddaa0c | bellard | /* TO FIX */
|
674 | 9fddaa0c | bellard | } |
675 | 9fddaa0c | bellard | |
676 | 9fddaa0c | bellard | void cpu_ppc_store_tbu (CPUState *env, uint32_t value)
|
677 | 9fddaa0c | bellard | { |
678 | 9fddaa0c | bellard | cpu_ppc_store_tb(env, ((uint64_t)value << 32) | cpu_ppc_load_tbl(env));
|
679 | 9fddaa0c | bellard | } |
680 | 9fddaa0c | bellard | |
681 | 9fddaa0c | bellard | void cpu_ppc_store_tbl (CPUState *env, uint32_t value)
|
682 | 9fddaa0c | bellard | { |
683 | 9fddaa0c | bellard | cpu_ppc_store_tb(env, ((uint64_t)cpu_ppc_load_tbl(env) << 32) | value);
|
684 | 9fddaa0c | bellard | } |
685 | 76a66253 | j_mayer | |
686 | 76a66253 | j_mayer | void cpu_ppc601_store_rtcu (CPUState *env, uint32_t value)
|
687 | 76a66253 | j_mayer | __attribute__ (( alias ("cpu_ppc_store_tbu") ));
|
688 | 76a66253 | j_mayer | |
689 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcu (CPUState *env) |
690 | 76a66253 | j_mayer | __attribute__ (( alias ("cpu_ppc_load_tbu") ));
|
691 | 76a66253 | j_mayer | |
692 | 76a66253 | j_mayer | void cpu_ppc601_store_rtcl (CPUState *env, uint32_t value)
|
693 | 9fddaa0c | bellard | { |
694 | 76a66253 | j_mayer | cpu_ppc_store_tbl(env, value & 0x3FFFFF80);
|
695 | 9fddaa0c | bellard | } |
696 | 76a66253 | j_mayer | |
697 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcl (CPUState *env) |
698 | 9fddaa0c | bellard | { |
699 | 76a66253 | j_mayer | return cpu_ppc_load_tbl(env) & 0x3FFFFF80; |
700 | 9fddaa0c | bellard | } |
701 | 76a66253 | j_mayer | |
702 | 67867308 | bellard | void cpu_loop(CPUPPCState *env)
|
703 | 67867308 | bellard | { |
704 | 67867308 | bellard | target_siginfo_t info; |
705 | 61190b14 | bellard | int trapnr;
|
706 | 61190b14 | bellard | uint32_t ret; |
707 | 67867308 | bellard | |
708 | 67867308 | bellard | for(;;) {
|
709 | 67867308 | bellard | trapnr = cpu_ppc_exec(env); |
710 | 61190b14 | bellard | if (trapnr != EXCP_SYSCALL_USER && trapnr != EXCP_BRANCH &&
|
711 | 61190b14 | bellard | trapnr != EXCP_TRACE) { |
712 | 61190b14 | bellard | if (loglevel > 0) { |
713 | 7fe48483 | bellard | cpu_dump_state(env, logfile, fprintf, 0);
|
714 | 61190b14 | bellard | } |
715 | 61190b14 | bellard | } |
716 | 67867308 | bellard | switch(trapnr) {
|
717 | 67867308 | bellard | case EXCP_NONE:
|
718 | 67867308 | bellard | break;
|
719 | 61190b14 | bellard | case EXCP_SYSCALL_USER:
|
720 | 61190b14 | bellard | /* system call */
|
721 | 61190b14 | bellard | /* WARNING:
|
722 | 61190b14 | bellard | * PPC ABI uses overflow flag in cr0 to signal an error
|
723 | 61190b14 | bellard | * in syscalls.
|
724 | 61190b14 | bellard | */
|
725 | 67867308 | bellard | #if 0
|
726 | 61190b14 | bellard | printf("syscall %d 0x%08x 0x%08x 0x%08x 0x%08x\n", env->gpr[0],
|
727 | 61190b14 | bellard | env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6]);
|
728 | 67867308 | bellard | #endif
|
729 | 61190b14 | bellard | env->crf[0] &= ~0x1; |
730 | 61190b14 | bellard | ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4], |
731 | 61190b14 | bellard | env->gpr[5], env->gpr[6], env->gpr[7], |
732 | 61190b14 | bellard | env->gpr[8]);
|
733 | 61190b14 | bellard | if (ret > (uint32_t)(-515)) { |
734 | 61190b14 | bellard | env->crf[0] |= 0x1; |
735 | 61190b14 | bellard | ret = -ret; |
736 | 61190b14 | bellard | } |
737 | 61190b14 | bellard | env->gpr[3] = ret;
|
738 | 61190b14 | bellard | #if 0
|
739 | 61190b14 | bellard | printf("syscall returned 0x%08x (%d)\n", ret, ret);
|
740 | 61190b14 | bellard | #endif
|
741 | 61190b14 | bellard | break;
|
742 | 61190b14 | bellard | case EXCP_RESET:
|
743 | 61190b14 | bellard | /* Should not happen ! */
|
744 | 61190b14 | bellard | fprintf(stderr, "RESET asked... Stop emulation\n");
|
745 | 61190b14 | bellard | if (loglevel)
|
746 | 61190b14 | bellard | fprintf(logfile, "RESET asked... Stop emulation\n");
|
747 | 67867308 | bellard | abort(); |
748 | 61190b14 | bellard | case EXCP_MACHINE_CHECK:
|
749 | 61190b14 | bellard | fprintf(stderr, "Machine check exeption... Stop emulation\n");
|
750 | 61190b14 | bellard | if (loglevel)
|
751 | 61190b14 | bellard | fprintf(logfile, "RESET asked... Stop emulation\n");
|
752 | 61190b14 | bellard | info.si_signo = TARGET_SIGBUS; |
753 | 67867308 | bellard | info.si_errno = 0;
|
754 | 61190b14 | bellard | info.si_code = TARGET_BUS_OBJERR; |
755 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
756 | 61190b14 | bellard | queue_signal(info.si_signo, &info); |
757 | 61190b14 | bellard | case EXCP_DSI:
|
758 | e96efcfc | j_mayer | fprintf(stderr, "Invalid data memory access: 0x" ADDRX "\n", |
759 | 3fc6c082 | bellard | env->spr[SPR_DAR]); |
760 | 61190b14 | bellard | if (loglevel) {
|
761 | e96efcfc | j_mayer | fprintf(logfile, "Invalid data memory access: 0x" ADDRX "\n", |
762 | 3fc6c082 | bellard | env->spr[SPR_DAR]); |
763 | 61190b14 | bellard | } |
764 | 2be0071f | bellard | switch (env->error_code & 0xFF000000) { |
765 | 2be0071f | bellard | case 0x40000000: |
766 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
767 | 61190b14 | bellard | info.si_errno = 0;
|
768 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
769 | 61190b14 | bellard | break;
|
770 | 2be0071f | bellard | case 0x04000000: |
771 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
772 | 61190b14 | bellard | info.si_errno = 0;
|
773 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLADR; |
774 | 61190b14 | bellard | break;
|
775 | 2be0071f | bellard | case 0x08000000: |
776 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
777 | 61190b14 | bellard | info.si_errno = 0;
|
778 | 61190b14 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
779 | 61190b14 | bellard | break;
|
780 | 61190b14 | bellard | default:
|
781 | 61190b14 | bellard | /* Let's send a regular segfault... */
|
782 | 61190b14 | bellard | fprintf(stderr, "Invalid segfault errno (%02x)\n",
|
783 | 61190b14 | bellard | env->error_code); |
784 | 61190b14 | bellard | if (loglevel) {
|
785 | 61190b14 | bellard | fprintf(logfile, "Invalid segfault errno (%02x)\n",
|
786 | 61190b14 | bellard | env->error_code); |
787 | 61190b14 | bellard | } |
788 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
789 | 61190b14 | bellard | info.si_errno = 0;
|
790 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
791 | 61190b14 | bellard | break;
|
792 | 61190b14 | bellard | } |
793 | 67867308 | bellard | info._sifields._sigfault._addr = env->nip; |
794 | 67867308 | bellard | queue_signal(info.si_signo, &info); |
795 | 67867308 | bellard | break;
|
796 | 61190b14 | bellard | case EXCP_ISI:
|
797 | 67867308 | bellard | fprintf(stderr, "Invalid instruction fetch\n");
|
798 | 61190b14 | bellard | if (loglevel)
|
799 | 61190b14 | bellard | fprintf(logfile, "Invalid instruction fetch\n");
|
800 | 2be0071f | bellard | switch (env->error_code & 0xFF000000) { |
801 | 2be0071f | bellard | case 0x40000000: |
802 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
803 | 67867308 | bellard | info.si_errno = 0;
|
804 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
805 | 61190b14 | bellard | break;
|
806 | 2be0071f | bellard | case 0x10000000: |
807 | 2be0071f | bellard | case 0x08000000: |
808 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
809 | 61190b14 | bellard | info.si_errno = 0;
|
810 | 61190b14 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
811 | 61190b14 | bellard | break;
|
812 | 61190b14 | bellard | default:
|
813 | 61190b14 | bellard | /* Let's send a regular segfault... */
|
814 | 61190b14 | bellard | fprintf(stderr, "Invalid segfault errno (%02x)\n",
|
815 | 61190b14 | bellard | env->error_code); |
816 | 61190b14 | bellard | if (loglevel) {
|
817 | 61190b14 | bellard | fprintf(logfile, "Invalid segfault errno (%02x)\n",
|
818 | 61190b14 | bellard | env->error_code); |
819 | 61190b14 | bellard | } |
820 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
821 | 61190b14 | bellard | info.si_errno = 0;
|
822 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
823 | 61190b14 | bellard | break;
|
824 | 61190b14 | bellard | } |
825 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
826 | 67867308 | bellard | queue_signal(info.si_signo, &info); |
827 | 67867308 | bellard | break;
|
828 | 61190b14 | bellard | case EXCP_EXTERNAL:
|
829 | 61190b14 | bellard | /* Should not happen ! */
|
830 | 61190b14 | bellard | fprintf(stderr, "External interruption... Stop emulation\n");
|
831 | 61190b14 | bellard | if (loglevel)
|
832 | 61190b14 | bellard | fprintf(logfile, "External interruption... Stop emulation\n");
|
833 | 67867308 | bellard | abort(); |
834 | 61190b14 | bellard | case EXCP_ALIGN:
|
835 | 61190b14 | bellard | fprintf(stderr, "Invalid unaligned memory access\n");
|
836 | 61190b14 | bellard | if (loglevel)
|
837 | 61190b14 | bellard | fprintf(logfile, "Invalid unaligned memory access\n");
|
838 | 61190b14 | bellard | info.si_signo = TARGET_SIGBUS; |
839 | 67867308 | bellard | info.si_errno = 0;
|
840 | 61190b14 | bellard | info.si_code = TARGET_BUS_ADRALN; |
841 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
842 | 67867308 | bellard | queue_signal(info.si_signo, &info); |
843 | 67867308 | bellard | break;
|
844 | 61190b14 | bellard | case EXCP_PROGRAM:
|
845 | 61190b14 | bellard | switch (env->error_code & ~0xF) { |
846 | 61190b14 | bellard | case EXCP_FP:
|
847 | 61190b14 | bellard | fprintf(stderr, "Program exception\n");
|
848 | 61190b14 | bellard | if (loglevel)
|
849 | 61190b14 | bellard | fprintf(logfile, "Program exception\n");
|
850 | 61190b14 | bellard | /* Set FX */
|
851 | 61190b14 | bellard | env->fpscr[7] |= 0x8; |
852 | 61190b14 | bellard | /* Finally, update FEX */
|
853 | 61190b14 | bellard | if ((((env->fpscr[7] & 0x3) << 3) | (env->fpscr[6] >> 1)) & |
854 | 61190b14 | bellard | ((env->fpscr[1] << 1) | (env->fpscr[0] >> 3))) |
855 | 61190b14 | bellard | env->fpscr[7] |= 0x4; |
856 | 61190b14 | bellard | info.si_signo = TARGET_SIGFPE; |
857 | 61190b14 | bellard | info.si_errno = 0;
|
858 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
859 | 61190b14 | bellard | case EXCP_FP_OX:
|
860 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTOVF; |
861 | 61190b14 | bellard | break;
|
862 | 61190b14 | bellard | case EXCP_FP_UX:
|
863 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTUND; |
864 | 61190b14 | bellard | break;
|
865 | 61190b14 | bellard | case EXCP_FP_ZX:
|
866 | 61190b14 | bellard | case EXCP_FP_VXZDZ:
|
867 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTDIV; |
868 | 61190b14 | bellard | break;
|
869 | 61190b14 | bellard | case EXCP_FP_XX:
|
870 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTRES; |
871 | 61190b14 | bellard | break;
|
872 | 61190b14 | bellard | case EXCP_FP_VXSOFT:
|
873 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTINV; |
874 | 61190b14 | bellard | break;
|
875 | 61190b14 | bellard | case EXCP_FP_VXNAN:
|
876 | 61190b14 | bellard | case EXCP_FP_VXISI:
|
877 | 61190b14 | bellard | case EXCP_FP_VXIDI:
|
878 | 61190b14 | bellard | case EXCP_FP_VXIMZ:
|
879 | 61190b14 | bellard | case EXCP_FP_VXVC:
|
880 | 61190b14 | bellard | case EXCP_FP_VXSQRT:
|
881 | 61190b14 | bellard | case EXCP_FP_VXCVI:
|
882 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTSUB; |
883 | 61190b14 | bellard | break;
|
884 | 61190b14 | bellard | default:
|
885 | 61190b14 | bellard | fprintf(stderr, "Unknown floating point exception "
|
886 | 61190b14 | bellard | "(%02x)\n", env->error_code);
|
887 | 61190b14 | bellard | if (loglevel) {
|
888 | 61190b14 | bellard | fprintf(logfile, "Unknown floating point exception "
|
889 | 61190b14 | bellard | "(%02x)\n", env->error_code & 0xF); |
890 | 61190b14 | bellard | } |
891 | 61190b14 | bellard | } |
892 | 61190b14 | bellard | break;
|
893 | 67867308 | bellard | case EXCP_INVAL:
|
894 | 61190b14 | bellard | fprintf(stderr, "Invalid instruction\n");
|
895 | 61190b14 | bellard | if (loglevel)
|
896 | 61190b14 | bellard | fprintf(logfile, "Invalid instruction\n");
|
897 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
898 | 61190b14 | bellard | info.si_errno = 0;
|
899 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
900 | 61190b14 | bellard | case EXCP_INVAL_INVAL:
|
901 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLOPC; |
902 | 61190b14 | bellard | break;
|
903 | 61190b14 | bellard | case EXCP_INVAL_LSWX:
|
904 | 67867308 | bellard | info.si_code = TARGET_ILL_ILLOPN; |
905 | 61190b14 | bellard | break;
|
906 | 61190b14 | bellard | case EXCP_INVAL_SPR:
|
907 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVREG; |
908 | 61190b14 | bellard | break;
|
909 | 61190b14 | bellard | case EXCP_INVAL_FP:
|
910 | 61190b14 | bellard | info.si_code = TARGET_ILL_COPROC; |
911 | 61190b14 | bellard | break;
|
912 | 61190b14 | bellard | default:
|
913 | 61190b14 | bellard | fprintf(stderr, "Unknown invalid operation (%02x)\n",
|
914 | 61190b14 | bellard | env->error_code & 0xF);
|
915 | 61190b14 | bellard | if (loglevel) {
|
916 | 61190b14 | bellard | fprintf(logfile, "Unknown invalid operation (%02x)\n",
|
917 | 61190b14 | bellard | env->error_code & 0xF);
|
918 | 61190b14 | bellard | } |
919 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLADR; |
920 | 61190b14 | bellard | break;
|
921 | 61190b14 | bellard | } |
922 | 61190b14 | bellard | break;
|
923 | 61190b14 | bellard | case EXCP_PRIV:
|
924 | 61190b14 | bellard | fprintf(stderr, "Privilege violation\n");
|
925 | 61190b14 | bellard | if (loglevel)
|
926 | 61190b14 | bellard | fprintf(logfile, "Privilege violation\n");
|
927 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
928 | 61190b14 | bellard | info.si_errno = 0;
|
929 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
930 | 61190b14 | bellard | case EXCP_PRIV_OPC:
|
931 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVOPC; |
932 | 61190b14 | bellard | break;
|
933 | 61190b14 | bellard | case EXCP_PRIV_REG:
|
934 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVREG; |
935 | 61190b14 | bellard | break;
|
936 | 61190b14 | bellard | default:
|
937 | 61190b14 | bellard | fprintf(stderr, "Unknown privilege violation (%02x)\n",
|
938 | 61190b14 | bellard | env->error_code & 0xF);
|
939 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVOPC; |
940 | 61190b14 | bellard | break;
|
941 | 61190b14 | bellard | } |
942 | 61190b14 | bellard | break;
|
943 | 61190b14 | bellard | case EXCP_TRAP:
|
944 | 61190b14 | bellard | fprintf(stderr, "Tried to call a TRAP\n");
|
945 | 61190b14 | bellard | if (loglevel)
|
946 | 61190b14 | bellard | fprintf(logfile, "Tried to call a TRAP\n");
|
947 | 61190b14 | bellard | abort(); |
948 | 61190b14 | bellard | default:
|
949 | 61190b14 | bellard | /* Should not happen ! */
|
950 | 61190b14 | bellard | fprintf(stderr, "Unknown program exception (%02x)\n",
|
951 | 61190b14 | bellard | env->error_code); |
952 | 61190b14 | bellard | if (loglevel) {
|
953 | 61190b14 | bellard | fprintf(logfile, "Unknwon program exception (%02x)\n",
|
954 | 61190b14 | bellard | env->error_code); |
955 | 61190b14 | bellard | } |
956 | 61190b14 | bellard | abort(); |
957 | 61190b14 | bellard | } |
958 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
959 | 67867308 | bellard | queue_signal(info.si_signo, &info); |
960 | 67867308 | bellard | break;
|
961 | 61190b14 | bellard | case EXCP_NO_FP:
|
962 | 61190b14 | bellard | fprintf(stderr, "No floating point allowed\n");
|
963 | 61190b14 | bellard | if (loglevel)
|
964 | 61190b14 | bellard | fprintf(logfile, "No floating point allowed\n");
|
965 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
966 | 67867308 | bellard | info.si_errno = 0;
|
967 | 61190b14 | bellard | info.si_code = TARGET_ILL_COPROC; |
968 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
969 | 67867308 | bellard | queue_signal(info.si_signo, &info); |
970 | 67867308 | bellard | break;
|
971 | 61190b14 | bellard | case EXCP_DECR:
|
972 | 61190b14 | bellard | /* Should not happen ! */
|
973 | 61190b14 | bellard | fprintf(stderr, "Decrementer exception\n");
|
974 | 61190b14 | bellard | if (loglevel)
|
975 | 61190b14 | bellard | fprintf(logfile, "Decrementer exception\n");
|
976 | 61190b14 | bellard | abort(); |
977 | 61190b14 | bellard | case EXCP_TRACE:
|
978 | 61190b14 | bellard | /* Do nothing: we use this to trace execution */
|
979 | 67867308 | bellard | break;
|
980 | 61190b14 | bellard | case EXCP_FP_ASSIST:
|
981 | 61190b14 | bellard | /* Should not happen ! */
|
982 | 61190b14 | bellard | fprintf(stderr, "Floating point assist exception\n");
|
983 | 61190b14 | bellard | if (loglevel)
|
984 | 61190b14 | bellard | fprintf(logfile, "Floating point assist exception\n");
|
985 | 61190b14 | bellard | abort(); |
986 | 61190b14 | bellard | case EXCP_MTMSR:
|
987 | 61190b14 | bellard | /* We reloaded the msr, just go on */
|
988 | 9fddaa0c | bellard | if (msr_pr == 0) { |
989 | 61190b14 | bellard | fprintf(stderr, "Tried to go into supervisor mode !\n");
|
990 | 61190b14 | bellard | if (loglevel)
|
991 | 61190b14 | bellard | fprintf(logfile, "Tried to go into supervisor mode !\n");
|
992 | 61190b14 | bellard | abort(); |
993 | 67867308 | bellard | } |
994 | 61190b14 | bellard | break;
|
995 | 61190b14 | bellard | case EXCP_BRANCH:
|
996 | 61190b14 | bellard | /* We stopped because of a jump... */
|
997 | 61190b14 | bellard | break;
|
998 | 61190b14 | bellard | case EXCP_INTERRUPT:
|
999 | 61190b14 | bellard | /* Don't know why this should ever happen... */
|
1000 | 61190b14 | bellard | break;
|
1001 | 1fddef4b | bellard | case EXCP_DEBUG:
|
1002 | 1fddef4b | bellard | { |
1003 | 1fddef4b | bellard | int sig;
|
1004 | 1fddef4b | bellard | |
1005 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1006 | 1fddef4b | bellard | if (sig)
|
1007 | 1fddef4b | bellard | { |
1008 | 1fddef4b | bellard | info.si_signo = sig; |
1009 | 1fddef4b | bellard | info.si_errno = 0;
|
1010 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
1011 | 1fddef4b | bellard | queue_signal(info.si_signo, &info); |
1012 | 1fddef4b | bellard | } |
1013 | 1fddef4b | bellard | } |
1014 | 1fddef4b | bellard | break;
|
1015 | 67867308 | bellard | default:
|
1016 | 67867308 | bellard | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
1017 | 67867308 | bellard | trapnr); |
1018 | 61190b14 | bellard | if (loglevel) {
|
1019 | 61190b14 | bellard | fprintf(logfile, "qemu: unhandled CPU exception 0x%02x - "
|
1020 | 61190b14 | bellard | "0x%02x - aborting\n", trapnr, env->error_code);
|
1021 | 61190b14 | bellard | } |
1022 | 67867308 | bellard | abort(); |
1023 | 67867308 | bellard | } |
1024 | 67867308 | bellard | process_pending_signals(env); |
1025 | 67867308 | bellard | } |
1026 | 67867308 | bellard | } |
1027 | 67867308 | bellard | #endif
|
1028 | 67867308 | bellard | |
1029 | 048f6b4d | bellard | #ifdef TARGET_MIPS
|
1030 | 048f6b4d | bellard | |
1031 | 048f6b4d | bellard | #define MIPS_SYS(name, args) args,
|
1032 | 048f6b4d | bellard | |
1033 | 048f6b4d | bellard | static const uint8_t mips_syscall_args[] = { |
1034 | 048f6b4d | bellard | MIPS_SYS(sys_syscall , 0) /* 4000 */ |
1035 | 048f6b4d | bellard | MIPS_SYS(sys_exit , 1)
|
1036 | 048f6b4d | bellard | MIPS_SYS(sys_fork , 0)
|
1037 | 048f6b4d | bellard | MIPS_SYS(sys_read , 3)
|
1038 | 048f6b4d | bellard | MIPS_SYS(sys_write , 3)
|
1039 | 048f6b4d | bellard | MIPS_SYS(sys_open , 3) /* 4005 */ |
1040 | 048f6b4d | bellard | MIPS_SYS(sys_close , 1)
|
1041 | 048f6b4d | bellard | MIPS_SYS(sys_waitpid , 3)
|
1042 | 048f6b4d | bellard | MIPS_SYS(sys_creat , 2)
|
1043 | 048f6b4d | bellard | MIPS_SYS(sys_link , 2)
|
1044 | 048f6b4d | bellard | MIPS_SYS(sys_unlink , 1) /* 4010 */ |
1045 | 048f6b4d | bellard | MIPS_SYS(sys_execve , 0)
|
1046 | 048f6b4d | bellard | MIPS_SYS(sys_chdir , 1)
|
1047 | 048f6b4d | bellard | MIPS_SYS(sys_time , 1)
|
1048 | 048f6b4d | bellard | MIPS_SYS(sys_mknod , 3)
|
1049 | 048f6b4d | bellard | MIPS_SYS(sys_chmod , 2) /* 4015 */ |
1050 | 048f6b4d | bellard | MIPS_SYS(sys_lchown , 3)
|
1051 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1052 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_stat */ |
1053 | 048f6b4d | bellard | MIPS_SYS(sys_lseek , 3)
|
1054 | 048f6b4d | bellard | MIPS_SYS(sys_getpid , 0) /* 4020 */ |
1055 | 048f6b4d | bellard | MIPS_SYS(sys_mount , 5)
|
1056 | 048f6b4d | bellard | MIPS_SYS(sys_oldumount , 1)
|
1057 | 048f6b4d | bellard | MIPS_SYS(sys_setuid , 1)
|
1058 | 048f6b4d | bellard | MIPS_SYS(sys_getuid , 0)
|
1059 | 048f6b4d | bellard | MIPS_SYS(sys_stime , 1) /* 4025 */ |
1060 | 048f6b4d | bellard | MIPS_SYS(sys_ptrace , 4)
|
1061 | 048f6b4d | bellard | MIPS_SYS(sys_alarm , 1)
|
1062 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_fstat */ |
1063 | 048f6b4d | bellard | MIPS_SYS(sys_pause , 0)
|
1064 | 048f6b4d | bellard | MIPS_SYS(sys_utime , 2) /* 4030 */ |
1065 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1066 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1067 | 048f6b4d | bellard | MIPS_SYS(sys_access , 2)
|
1068 | 048f6b4d | bellard | MIPS_SYS(sys_nice , 1)
|
1069 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4035 */ |
1070 | 048f6b4d | bellard | MIPS_SYS(sys_sync , 0)
|
1071 | 048f6b4d | bellard | MIPS_SYS(sys_kill , 2)
|
1072 | 048f6b4d | bellard | MIPS_SYS(sys_rename , 2)
|
1073 | 048f6b4d | bellard | MIPS_SYS(sys_mkdir , 2)
|
1074 | 048f6b4d | bellard | MIPS_SYS(sys_rmdir , 1) /* 4040 */ |
1075 | 048f6b4d | bellard | MIPS_SYS(sys_dup , 1)
|
1076 | 048f6b4d | bellard | MIPS_SYS(sys_pipe , 0)
|
1077 | 048f6b4d | bellard | MIPS_SYS(sys_times , 1)
|
1078 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1079 | 048f6b4d | bellard | MIPS_SYS(sys_brk , 1) /* 4045 */ |
1080 | 048f6b4d | bellard | MIPS_SYS(sys_setgid , 1)
|
1081 | 048f6b4d | bellard | MIPS_SYS(sys_getgid , 0)
|
1082 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was signal(2) */ |
1083 | 048f6b4d | bellard | MIPS_SYS(sys_geteuid , 0)
|
1084 | 048f6b4d | bellard | MIPS_SYS(sys_getegid , 0) /* 4050 */ |
1085 | 048f6b4d | bellard | MIPS_SYS(sys_acct , 0)
|
1086 | 048f6b4d | bellard | MIPS_SYS(sys_umount , 2)
|
1087 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1088 | 048f6b4d | bellard | MIPS_SYS(sys_ioctl , 3)
|
1089 | 048f6b4d | bellard | MIPS_SYS(sys_fcntl , 3) /* 4055 */ |
1090 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 2)
|
1091 | 048f6b4d | bellard | MIPS_SYS(sys_setpgid , 2)
|
1092 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1093 | 048f6b4d | bellard | MIPS_SYS(sys_olduname , 1)
|
1094 | 048f6b4d | bellard | MIPS_SYS(sys_umask , 1) /* 4060 */ |
1095 | 048f6b4d | bellard | MIPS_SYS(sys_chroot , 1)
|
1096 | 048f6b4d | bellard | MIPS_SYS(sys_ustat , 2)
|
1097 | 048f6b4d | bellard | MIPS_SYS(sys_dup2 , 2)
|
1098 | 048f6b4d | bellard | MIPS_SYS(sys_getppid , 0)
|
1099 | 048f6b4d | bellard | MIPS_SYS(sys_getpgrp , 0) /* 4065 */ |
1100 | 048f6b4d | bellard | MIPS_SYS(sys_setsid , 0)
|
1101 | 048f6b4d | bellard | MIPS_SYS(sys_sigaction , 3)
|
1102 | 048f6b4d | bellard | MIPS_SYS(sys_sgetmask , 0)
|
1103 | 048f6b4d | bellard | MIPS_SYS(sys_ssetmask , 1)
|
1104 | 048f6b4d | bellard | MIPS_SYS(sys_setreuid , 2) /* 4070 */ |
1105 | 048f6b4d | bellard | MIPS_SYS(sys_setregid , 2)
|
1106 | 048f6b4d | bellard | MIPS_SYS(sys_sigsuspend , 0)
|
1107 | 048f6b4d | bellard | MIPS_SYS(sys_sigpending , 1)
|
1108 | 048f6b4d | bellard | MIPS_SYS(sys_sethostname , 2)
|
1109 | 048f6b4d | bellard | MIPS_SYS(sys_setrlimit , 2) /* 4075 */ |
1110 | 048f6b4d | bellard | MIPS_SYS(sys_getrlimit , 2)
|
1111 | 048f6b4d | bellard | MIPS_SYS(sys_getrusage , 2)
|
1112 | 048f6b4d | bellard | MIPS_SYS(sys_gettimeofday, 2)
|
1113 | 048f6b4d | bellard | MIPS_SYS(sys_settimeofday, 2)
|
1114 | 048f6b4d | bellard | MIPS_SYS(sys_getgroups , 2) /* 4080 */ |
1115 | 048f6b4d | bellard | MIPS_SYS(sys_setgroups , 2)
|
1116 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* old_select */ |
1117 | 048f6b4d | bellard | MIPS_SYS(sys_symlink , 2)
|
1118 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_lstat */ |
1119 | 048f6b4d | bellard | MIPS_SYS(sys_readlink , 3) /* 4085 */ |
1120 | 048f6b4d | bellard | MIPS_SYS(sys_uselib , 1)
|
1121 | 048f6b4d | bellard | MIPS_SYS(sys_swapon , 2)
|
1122 | 048f6b4d | bellard | MIPS_SYS(sys_reboot , 3)
|
1123 | 048f6b4d | bellard | MIPS_SYS(old_readdir , 3)
|
1124 | 048f6b4d | bellard | MIPS_SYS(old_mmap , 6) /* 4090 */ |
1125 | 048f6b4d | bellard | MIPS_SYS(sys_munmap , 2)
|
1126 | 048f6b4d | bellard | MIPS_SYS(sys_truncate , 2)
|
1127 | 048f6b4d | bellard | MIPS_SYS(sys_ftruncate , 2)
|
1128 | 048f6b4d | bellard | MIPS_SYS(sys_fchmod , 2)
|
1129 | 048f6b4d | bellard | MIPS_SYS(sys_fchown , 3) /* 4095 */ |
1130 | 048f6b4d | bellard | MIPS_SYS(sys_getpriority , 2)
|
1131 | 048f6b4d | bellard | MIPS_SYS(sys_setpriority , 3)
|
1132 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1133 | 048f6b4d | bellard | MIPS_SYS(sys_statfs , 2)
|
1134 | 048f6b4d | bellard | MIPS_SYS(sys_fstatfs , 2) /* 4100 */ |
1135 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was ioperm(2) */ |
1136 | 048f6b4d | bellard | MIPS_SYS(sys_socketcall , 2)
|
1137 | 048f6b4d | bellard | MIPS_SYS(sys_syslog , 3)
|
1138 | 048f6b4d | bellard | MIPS_SYS(sys_setitimer , 3)
|
1139 | 048f6b4d | bellard | MIPS_SYS(sys_getitimer , 2) /* 4105 */ |
1140 | 048f6b4d | bellard | MIPS_SYS(sys_newstat , 2)
|
1141 | 048f6b4d | bellard | MIPS_SYS(sys_newlstat , 2)
|
1142 | 048f6b4d | bellard | MIPS_SYS(sys_newfstat , 2)
|
1143 | 048f6b4d | bellard | MIPS_SYS(sys_uname , 1)
|
1144 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4110 was iopl(2) */ |
1145 | 048f6b4d | bellard | MIPS_SYS(sys_vhangup , 0)
|
1146 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_idle() */ |
1147 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_vm86 */ |
1148 | 048f6b4d | bellard | MIPS_SYS(sys_wait4 , 4)
|
1149 | 048f6b4d | bellard | MIPS_SYS(sys_swapoff , 1) /* 4115 */ |
1150 | 048f6b4d | bellard | MIPS_SYS(sys_sysinfo , 1)
|
1151 | 048f6b4d | bellard | MIPS_SYS(sys_ipc , 6)
|
1152 | 048f6b4d | bellard | MIPS_SYS(sys_fsync , 1)
|
1153 | 048f6b4d | bellard | MIPS_SYS(sys_sigreturn , 0)
|
1154 | 048f6b4d | bellard | MIPS_SYS(sys_clone , 0) /* 4120 */ |
1155 | 048f6b4d | bellard | MIPS_SYS(sys_setdomainname, 2)
|
1156 | 048f6b4d | bellard | MIPS_SYS(sys_newuname , 1)
|
1157 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_modify_ldt */ |
1158 | 048f6b4d | bellard | MIPS_SYS(sys_adjtimex , 1)
|
1159 | 048f6b4d | bellard | MIPS_SYS(sys_mprotect , 3) /* 4125 */ |
1160 | 048f6b4d | bellard | MIPS_SYS(sys_sigprocmask , 3)
|
1161 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was create_module */ |
1162 | 048f6b4d | bellard | MIPS_SYS(sys_init_module , 5)
|
1163 | 048f6b4d | bellard | MIPS_SYS(sys_delete_module, 1)
|
1164 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4130 was get_kernel_syms */ |
1165 | 048f6b4d | bellard | MIPS_SYS(sys_quotactl , 0)
|
1166 | 048f6b4d | bellard | MIPS_SYS(sys_getpgid , 1)
|
1167 | 048f6b4d | bellard | MIPS_SYS(sys_fchdir , 1)
|
1168 | 048f6b4d | bellard | MIPS_SYS(sys_bdflush , 2)
|
1169 | 048f6b4d | bellard | MIPS_SYS(sys_sysfs , 3) /* 4135 */ |
1170 | 048f6b4d | bellard | MIPS_SYS(sys_personality , 1)
|
1171 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* for afs_syscall */ |
1172 | 048f6b4d | bellard | MIPS_SYS(sys_setfsuid , 1)
|
1173 | 048f6b4d | bellard | MIPS_SYS(sys_setfsgid , 1)
|
1174 | 048f6b4d | bellard | MIPS_SYS(sys_llseek , 5) /* 4140 */ |
1175 | 048f6b4d | bellard | MIPS_SYS(sys_getdents , 3)
|
1176 | 048f6b4d | bellard | MIPS_SYS(sys_select , 5)
|
1177 | 048f6b4d | bellard | MIPS_SYS(sys_flock , 2)
|
1178 | 048f6b4d | bellard | MIPS_SYS(sys_msync , 3)
|
1179 | 048f6b4d | bellard | MIPS_SYS(sys_readv , 3) /* 4145 */ |
1180 | 048f6b4d | bellard | MIPS_SYS(sys_writev , 3)
|
1181 | 048f6b4d | bellard | MIPS_SYS(sys_cacheflush , 3)
|
1182 | 048f6b4d | bellard | MIPS_SYS(sys_cachectl , 3)
|
1183 | 048f6b4d | bellard | MIPS_SYS(sys_sysmips , 4)
|
1184 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4150 */ |
1185 | 048f6b4d | bellard | MIPS_SYS(sys_getsid , 1)
|
1186 | 048f6b4d | bellard | MIPS_SYS(sys_fdatasync , 0)
|
1187 | 048f6b4d | bellard | MIPS_SYS(sys_sysctl , 1)
|
1188 | 048f6b4d | bellard | MIPS_SYS(sys_mlock , 2)
|
1189 | 048f6b4d | bellard | MIPS_SYS(sys_munlock , 2) /* 4155 */ |
1190 | 048f6b4d | bellard | MIPS_SYS(sys_mlockall , 1)
|
1191 | 048f6b4d | bellard | MIPS_SYS(sys_munlockall , 0)
|
1192 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setparam, 2)
|
1193 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getparam, 2)
|
1194 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setscheduler, 3) /* 4160 */ |
1195 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getscheduler, 1)
|
1196 | 048f6b4d | bellard | MIPS_SYS(sys_sched_yield , 0)
|
1197 | 048f6b4d | bellard | MIPS_SYS(sys_sched_get_priority_max, 1)
|
1198 | 048f6b4d | bellard | MIPS_SYS(sys_sched_get_priority_min, 1)
|
1199 | 048f6b4d | bellard | MIPS_SYS(sys_sched_rr_get_interval, 2) /* 4165 */ |
1200 | 048f6b4d | bellard | MIPS_SYS(sys_nanosleep, 2)
|
1201 | 048f6b4d | bellard | MIPS_SYS(sys_mremap , 4)
|
1202 | 048f6b4d | bellard | MIPS_SYS(sys_accept , 3)
|
1203 | 048f6b4d | bellard | MIPS_SYS(sys_bind , 3)
|
1204 | 048f6b4d | bellard | MIPS_SYS(sys_connect , 3) /* 4170 */ |
1205 | 048f6b4d | bellard | MIPS_SYS(sys_getpeername , 3)
|
1206 | 048f6b4d | bellard | MIPS_SYS(sys_getsockname , 3)
|
1207 | 048f6b4d | bellard | MIPS_SYS(sys_getsockopt , 5)
|
1208 | 048f6b4d | bellard | MIPS_SYS(sys_listen , 2)
|
1209 | 048f6b4d | bellard | MIPS_SYS(sys_recv , 4) /* 4175 */ |
1210 | 048f6b4d | bellard | MIPS_SYS(sys_recvfrom , 6)
|
1211 | 048f6b4d | bellard | MIPS_SYS(sys_recvmsg , 3)
|
1212 | 048f6b4d | bellard | MIPS_SYS(sys_send , 4)
|
1213 | 048f6b4d | bellard | MIPS_SYS(sys_sendmsg , 3)
|
1214 | 048f6b4d | bellard | MIPS_SYS(sys_sendto , 6) /* 4180 */ |
1215 | 048f6b4d | bellard | MIPS_SYS(sys_setsockopt , 5)
|
1216 | 048f6b4d | bellard | MIPS_SYS(sys_shutdown , 2)
|
1217 | 048f6b4d | bellard | MIPS_SYS(sys_socket , 3)
|
1218 | 048f6b4d | bellard | MIPS_SYS(sys_socketpair , 4)
|
1219 | 048f6b4d | bellard | MIPS_SYS(sys_setresuid , 3) /* 4185 */ |
1220 | 048f6b4d | bellard | MIPS_SYS(sys_getresuid , 3)
|
1221 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_query_module */ |
1222 | 048f6b4d | bellard | MIPS_SYS(sys_poll , 3)
|
1223 | 048f6b4d | bellard | MIPS_SYS(sys_nfsservctl , 3)
|
1224 | 048f6b4d | bellard | MIPS_SYS(sys_setresgid , 3) /* 4190 */ |
1225 | 048f6b4d | bellard | MIPS_SYS(sys_getresgid , 3)
|
1226 | 048f6b4d | bellard | MIPS_SYS(sys_prctl , 5)
|
1227 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigreturn, 0)
|
1228 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigaction, 4)
|
1229 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigprocmask, 4) /* 4195 */ |
1230 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigpending, 2)
|
1231 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigtimedwait, 4)
|
1232 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigqueueinfo, 3)
|
1233 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigsuspend, 0)
|
1234 | 048f6b4d | bellard | MIPS_SYS(sys_pread64 , 6) /* 4200 */ |
1235 | 048f6b4d | bellard | MIPS_SYS(sys_pwrite64 , 6)
|
1236 | 048f6b4d | bellard | MIPS_SYS(sys_chown , 3)
|
1237 | 048f6b4d | bellard | MIPS_SYS(sys_getcwd , 2)
|
1238 | 048f6b4d | bellard | MIPS_SYS(sys_capget , 2)
|
1239 | 048f6b4d | bellard | MIPS_SYS(sys_capset , 2) /* 4205 */ |
1240 | 048f6b4d | bellard | MIPS_SYS(sys_sigaltstack , 0)
|
1241 | 048f6b4d | bellard | MIPS_SYS(sys_sendfile , 4)
|
1242 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1243 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1244 | 048f6b4d | bellard | MIPS_SYS(sys_mmap2 , 6) /* 4210 */ |
1245 | 048f6b4d | bellard | MIPS_SYS(sys_truncate64 , 4)
|
1246 | 048f6b4d | bellard | MIPS_SYS(sys_ftruncate64 , 4)
|
1247 | 048f6b4d | bellard | MIPS_SYS(sys_stat64 , 2)
|
1248 | 048f6b4d | bellard | MIPS_SYS(sys_lstat64 , 2)
|
1249 | 048f6b4d | bellard | MIPS_SYS(sys_fstat64 , 2) /* 4215 */ |
1250 | 048f6b4d | bellard | MIPS_SYS(sys_pivot_root , 2)
|
1251 | 048f6b4d | bellard | MIPS_SYS(sys_mincore , 3)
|
1252 | 048f6b4d | bellard | MIPS_SYS(sys_madvise , 3)
|
1253 | 048f6b4d | bellard | MIPS_SYS(sys_getdents64 , 3)
|
1254 | 048f6b4d | bellard | MIPS_SYS(sys_fcntl64 , 3) /* 4220 */ |
1255 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1256 | 048f6b4d | bellard | MIPS_SYS(sys_gettid , 0)
|
1257 | 048f6b4d | bellard | MIPS_SYS(sys_readahead , 5)
|
1258 | 048f6b4d | bellard | MIPS_SYS(sys_setxattr , 5)
|
1259 | 048f6b4d | bellard | MIPS_SYS(sys_lsetxattr , 5) /* 4225 */ |
1260 | 048f6b4d | bellard | MIPS_SYS(sys_fsetxattr , 5)
|
1261 | 048f6b4d | bellard | MIPS_SYS(sys_getxattr , 4)
|
1262 | 048f6b4d | bellard | MIPS_SYS(sys_lgetxattr , 4)
|
1263 | 048f6b4d | bellard | MIPS_SYS(sys_fgetxattr , 4)
|
1264 | 048f6b4d | bellard | MIPS_SYS(sys_listxattr , 3) /* 4230 */ |
1265 | 048f6b4d | bellard | MIPS_SYS(sys_llistxattr , 3)
|
1266 | 048f6b4d | bellard | MIPS_SYS(sys_flistxattr , 3)
|
1267 | 048f6b4d | bellard | MIPS_SYS(sys_removexattr , 2)
|
1268 | 048f6b4d | bellard | MIPS_SYS(sys_lremovexattr, 2)
|
1269 | 048f6b4d | bellard | MIPS_SYS(sys_fremovexattr, 2) /* 4235 */ |
1270 | 048f6b4d | bellard | MIPS_SYS(sys_tkill , 2)
|
1271 | 048f6b4d | bellard | MIPS_SYS(sys_sendfile64 , 5)
|
1272 | 048f6b4d | bellard | MIPS_SYS(sys_futex , 2)
|
1273 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setaffinity, 3)
|
1274 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getaffinity, 3) /* 4240 */ |
1275 | 048f6b4d | bellard | MIPS_SYS(sys_io_setup , 2)
|
1276 | 048f6b4d | bellard | MIPS_SYS(sys_io_destroy , 1)
|
1277 | 048f6b4d | bellard | MIPS_SYS(sys_io_getevents, 5)
|
1278 | 048f6b4d | bellard | MIPS_SYS(sys_io_submit , 3)
|
1279 | 048f6b4d | bellard | MIPS_SYS(sys_io_cancel , 3) /* 4245 */ |
1280 | 048f6b4d | bellard | MIPS_SYS(sys_exit_group , 1)
|
1281 | 048f6b4d | bellard | MIPS_SYS(sys_lookup_dcookie, 3)
|
1282 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_create, 1)
|
1283 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_ctl , 4)
|
1284 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_wait , 3) /* 4250 */ |
1285 | 048f6b4d | bellard | MIPS_SYS(sys_remap_file_pages, 5)
|
1286 | 048f6b4d | bellard | MIPS_SYS(sys_set_tid_address, 1)
|
1287 | 048f6b4d | bellard | MIPS_SYS(sys_restart_syscall, 0)
|
1288 | 048f6b4d | bellard | MIPS_SYS(sys_fadvise64_64, 7)
|
1289 | 048f6b4d | bellard | MIPS_SYS(sys_statfs64 , 3) /* 4255 */ |
1290 | 048f6b4d | bellard | MIPS_SYS(sys_fstatfs64 , 2)
|
1291 | 048f6b4d | bellard | MIPS_SYS(sys_timer_create, 3)
|
1292 | 048f6b4d | bellard | MIPS_SYS(sys_timer_settime, 4)
|
1293 | 048f6b4d | bellard | MIPS_SYS(sys_timer_gettime, 2)
|
1294 | 048f6b4d | bellard | MIPS_SYS(sys_timer_getoverrun, 1) /* 4260 */ |
1295 | 048f6b4d | bellard | MIPS_SYS(sys_timer_delete, 1)
|
1296 | 048f6b4d | bellard | MIPS_SYS(sys_clock_settime, 2)
|
1297 | 048f6b4d | bellard | MIPS_SYS(sys_clock_gettime, 2)
|
1298 | 048f6b4d | bellard | MIPS_SYS(sys_clock_getres, 2)
|
1299 | 048f6b4d | bellard | MIPS_SYS(sys_clock_nanosleep, 4) /* 4265 */ |
1300 | 048f6b4d | bellard | MIPS_SYS(sys_tgkill , 3)
|
1301 | 048f6b4d | bellard | MIPS_SYS(sys_utimes , 2)
|
1302 | 048f6b4d | bellard | MIPS_SYS(sys_mbind , 4)
|
1303 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_get_mempolicy */ |
1304 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4270 sys_set_mempolicy */ |
1305 | 048f6b4d | bellard | MIPS_SYS(sys_mq_open , 4)
|
1306 | 048f6b4d | bellard | MIPS_SYS(sys_mq_unlink , 1)
|
1307 | 048f6b4d | bellard | MIPS_SYS(sys_mq_timedsend, 5)
|
1308 | 048f6b4d | bellard | MIPS_SYS(sys_mq_timedreceive, 5)
|
1309 | 048f6b4d | bellard | MIPS_SYS(sys_mq_notify , 2) /* 4275 */ |
1310 | 048f6b4d | bellard | MIPS_SYS(sys_mq_getsetattr, 3)
|
1311 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_vserver */ |
1312 | 048f6b4d | bellard | MIPS_SYS(sys_waitid , 4)
|
1313 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* available, was setaltroot */ |
1314 | 048f6b4d | bellard | MIPS_SYS(sys_add_key , 5)
|
1315 | 388bb21a | ths | MIPS_SYS(sys_request_key, 4)
|
1316 | 048f6b4d | bellard | MIPS_SYS(sys_keyctl , 5)
|
1317 | 6f5b89a0 | ths | MIPS_SYS(sys_set_thread_area, 1)
|
1318 | 388bb21a | ths | MIPS_SYS(sys_inotify_init, 0)
|
1319 | 388bb21a | ths | MIPS_SYS(sys_inotify_add_watch, 3) /* 4285 */ |
1320 | 388bb21a | ths | MIPS_SYS(sys_inotify_rm_watch, 2)
|
1321 | 388bb21a | ths | MIPS_SYS(sys_migrate_pages, 4)
|
1322 | 388bb21a | ths | MIPS_SYS(sys_openat, 4)
|
1323 | 388bb21a | ths | MIPS_SYS(sys_mkdirat, 3)
|
1324 | 388bb21a | ths | MIPS_SYS(sys_mknodat, 4) /* 4290 */ |
1325 | 388bb21a | ths | MIPS_SYS(sys_fchownat, 5)
|
1326 | 388bb21a | ths | MIPS_SYS(sys_futimesat, 3)
|
1327 | 388bb21a | ths | MIPS_SYS(sys_fstatat64, 4)
|
1328 | 388bb21a | ths | MIPS_SYS(sys_unlinkat, 3)
|
1329 | 388bb21a | ths | MIPS_SYS(sys_renameat, 4) /* 4295 */ |
1330 | 388bb21a | ths | MIPS_SYS(sys_linkat, 5)
|
1331 | 388bb21a | ths | MIPS_SYS(sys_symlinkat, 3)
|
1332 | 388bb21a | ths | MIPS_SYS(sys_readlinkat, 4)
|
1333 | 388bb21a | ths | MIPS_SYS(sys_fchmodat, 3)
|
1334 | 388bb21a | ths | MIPS_SYS(sys_faccessat, 3) /* 4300 */ |
1335 | 388bb21a | ths | MIPS_SYS(sys_pselect6, 6)
|
1336 | 388bb21a | ths | MIPS_SYS(sys_ppoll, 5)
|
1337 | 388bb21a | ths | MIPS_SYS(sys_unshare, 1)
|
1338 | 388bb21a | ths | MIPS_SYS(sys_splice, 4)
|
1339 | 388bb21a | ths | MIPS_SYS(sys_sync_file_range, 7) /* 4305 */ |
1340 | 388bb21a | ths | MIPS_SYS(sys_tee, 4)
|
1341 | 388bb21a | ths | MIPS_SYS(sys_vmsplice, 4)
|
1342 | 388bb21a | ths | MIPS_SYS(sys_move_pages, 6)
|
1343 | 388bb21a | ths | MIPS_SYS(sys_set_robust_list, 2)
|
1344 | 388bb21a | ths | MIPS_SYS(sys_get_robust_list, 3) /* 4310 */ |
1345 | 388bb21a | ths | MIPS_SYS(sys_kexec_load, 4)
|
1346 | 388bb21a | ths | MIPS_SYS(sys_getcpu, 3)
|
1347 | 388bb21a | ths | MIPS_SYS(sys_epoll_pwait, 6)
|
1348 | 388bb21a | ths | MIPS_SYS(sys_ioprio_set, 3)
|
1349 | 388bb21a | ths | MIPS_SYS(sys_ioprio_get, 2)
|
1350 | 048f6b4d | bellard | }; |
1351 | 048f6b4d | bellard | |
1352 | 048f6b4d | bellard | #undef MIPS_SYS
|
1353 | 048f6b4d | bellard | |
1354 | 048f6b4d | bellard | void cpu_loop(CPUMIPSState *env)
|
1355 | 048f6b4d | bellard | { |
1356 | 048f6b4d | bellard | target_siginfo_t info; |
1357 | 388bb21a | ths | int trapnr, ret;
|
1358 | 048f6b4d | bellard | unsigned int syscall_num; |
1359 | 048f6b4d | bellard | |
1360 | 048f6b4d | bellard | for(;;) {
|
1361 | 048f6b4d | bellard | trapnr = cpu_mips_exec(env); |
1362 | 048f6b4d | bellard | switch(trapnr) {
|
1363 | 048f6b4d | bellard | case EXCP_SYSCALL:
|
1364 | 388bb21a | ths | syscall_num = env->gpr[2] - 4000; |
1365 | 388bb21a | ths | env->PC += 4;
|
1366 | 388bb21a | ths | if (syscall_num >= sizeof(mips_syscall_args)) { |
1367 | 388bb21a | ths | ret = -ENOSYS; |
1368 | 388bb21a | ths | } else {
|
1369 | 388bb21a | ths | int nb_args;
|
1370 | 388bb21a | ths | target_ulong sp_reg; |
1371 | 388bb21a | ths | target_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0; |
1372 | 388bb21a | ths | |
1373 | 388bb21a | ths | nb_args = mips_syscall_args[syscall_num]; |
1374 | 388bb21a | ths | sp_reg = env->gpr[29];
|
1375 | 388bb21a | ths | switch (nb_args) {
|
1376 | 388bb21a | ths | /* these arguments are taken from the stack */
|
1377 | 388bb21a | ths | case 8: arg8 = tgetl(sp_reg + 28); |
1378 | 388bb21a | ths | case 7: arg7 = tgetl(sp_reg + 24); |
1379 | 388bb21a | ths | case 6: arg6 = tgetl(sp_reg + 20); |
1380 | 388bb21a | ths | case 5: arg5 = tgetl(sp_reg + 16); |
1381 | 388bb21a | ths | default:
|
1382 | 388bb21a | ths | break;
|
1383 | 048f6b4d | bellard | } |
1384 | 388bb21a | ths | ret = do_syscall(env, env->gpr[2],
|
1385 | 388bb21a | ths | env->gpr[4], env->gpr[5], |
1386 | 388bb21a | ths | env->gpr[6], env->gpr[7], |
1387 | 388bb21a | ths | arg5, arg6/*, arg7, arg8*/);
|
1388 | 388bb21a | ths | } |
1389 | 388bb21a | ths | if ((unsigned int)ret >= (unsigned int)(-1133)) { |
1390 | 388bb21a | ths | env->gpr[7] = 1; /* error flag */ |
1391 | 388bb21a | ths | ret = -ret; |
1392 | 388bb21a | ths | } else {
|
1393 | 388bb21a | ths | env->gpr[7] = 0; /* error flag */ |
1394 | 048f6b4d | bellard | } |
1395 | 388bb21a | ths | env->gpr[2] = ret;
|
1396 | 048f6b4d | bellard | break;
|
1397 | ca7c2b1b | ths | case EXCP_TLBL:
|
1398 | ca7c2b1b | ths | case EXCP_TLBS:
|
1399 | 6900e84b | bellard | case EXCP_CpU:
|
1400 | 048f6b4d | bellard | case EXCP_RI:
|
1401 | bc1ad2de | bellard | info.si_signo = TARGET_SIGILL; |
1402 | bc1ad2de | bellard | info.si_errno = 0;
|
1403 | bc1ad2de | bellard | info.si_code = 0;
|
1404 | bc1ad2de | bellard | queue_signal(info.si_signo, &info); |
1405 | 048f6b4d | bellard | break;
|
1406 | 106ec879 | bellard | case EXCP_INTERRUPT:
|
1407 | 106ec879 | bellard | /* just indicate that signals should be handled asap */
|
1408 | 106ec879 | bellard | break;
|
1409 | d08b2a28 | pbrook | case EXCP_DEBUG:
|
1410 | d08b2a28 | pbrook | { |
1411 | d08b2a28 | pbrook | int sig;
|
1412 | d08b2a28 | pbrook | |
1413 | d08b2a28 | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1414 | d08b2a28 | pbrook | if (sig)
|
1415 | d08b2a28 | pbrook | { |
1416 | d08b2a28 | pbrook | info.si_signo = sig; |
1417 | d08b2a28 | pbrook | info.si_errno = 0;
|
1418 | d08b2a28 | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1419 | d08b2a28 | pbrook | queue_signal(info.si_signo, &info); |
1420 | d08b2a28 | pbrook | } |
1421 | d08b2a28 | pbrook | } |
1422 | d08b2a28 | pbrook | break;
|
1423 | 048f6b4d | bellard | default:
|
1424 | 048f6b4d | bellard | // error:
|
1425 | 048f6b4d | bellard | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
1426 | 048f6b4d | bellard | trapnr); |
1427 | 048f6b4d | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
1428 | 048f6b4d | bellard | abort(); |
1429 | 048f6b4d | bellard | } |
1430 | 048f6b4d | bellard | process_pending_signals(env); |
1431 | 048f6b4d | bellard | } |
1432 | 048f6b4d | bellard | } |
1433 | 048f6b4d | bellard | #endif
|
1434 | 048f6b4d | bellard | |
1435 | fdf9b3e8 | bellard | #ifdef TARGET_SH4
|
1436 | fdf9b3e8 | bellard | void cpu_loop (CPUState *env)
|
1437 | fdf9b3e8 | bellard | { |
1438 | fdf9b3e8 | bellard | int trapnr, ret;
|
1439 | 355fb23d | pbrook | target_siginfo_t info; |
1440 | fdf9b3e8 | bellard | |
1441 | fdf9b3e8 | bellard | while (1) { |
1442 | fdf9b3e8 | bellard | trapnr = cpu_sh4_exec (env); |
1443 | fdf9b3e8 | bellard | |
1444 | fdf9b3e8 | bellard | switch (trapnr) {
|
1445 | fdf9b3e8 | bellard | case 0x160: |
1446 | fdf9b3e8 | bellard | ret = do_syscall(env, |
1447 | 9c2a9ea1 | pbrook | env->gregs[3],
|
1448 | 9c2a9ea1 | pbrook | env->gregs[4],
|
1449 | 9c2a9ea1 | pbrook | env->gregs[5],
|
1450 | 9c2a9ea1 | pbrook | env->gregs[6],
|
1451 | 9c2a9ea1 | pbrook | env->gregs[7],
|
1452 | 9c2a9ea1 | pbrook | env->gregs[0],
|
1453 | fdf9b3e8 | bellard | 0);
|
1454 | 9c2a9ea1 | pbrook | env->gregs[0] = ret;
|
1455 | fdf9b3e8 | bellard | env->pc += 2;
|
1456 | fdf9b3e8 | bellard | break;
|
1457 | 355fb23d | pbrook | case EXCP_DEBUG:
|
1458 | 355fb23d | pbrook | { |
1459 | 355fb23d | pbrook | int sig;
|
1460 | 355fb23d | pbrook | |
1461 | 355fb23d | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1462 | 355fb23d | pbrook | if (sig)
|
1463 | 355fb23d | pbrook | { |
1464 | 355fb23d | pbrook | info.si_signo = sig; |
1465 | 355fb23d | pbrook | info.si_errno = 0;
|
1466 | 355fb23d | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1467 | 355fb23d | pbrook | queue_signal(info.si_signo, &info); |
1468 | 355fb23d | pbrook | } |
1469 | 355fb23d | pbrook | } |
1470 | 355fb23d | pbrook | break;
|
1471 | fdf9b3e8 | bellard | default:
|
1472 | fdf9b3e8 | bellard | printf ("Unhandled trap: 0x%x\n", trapnr);
|
1473 | fdf9b3e8 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
1474 | fdf9b3e8 | bellard | exit (1);
|
1475 | fdf9b3e8 | bellard | } |
1476 | fdf9b3e8 | bellard | process_pending_signals (env); |
1477 | fdf9b3e8 | bellard | } |
1478 | fdf9b3e8 | bellard | } |
1479 | fdf9b3e8 | bellard | #endif
|
1480 | fdf9b3e8 | bellard | |
1481 | e6e5906b | pbrook | #ifdef TARGET_M68K
|
1482 | e6e5906b | pbrook | |
1483 | e6e5906b | pbrook | void cpu_loop(CPUM68KState *env)
|
1484 | e6e5906b | pbrook | { |
1485 | e6e5906b | pbrook | int trapnr;
|
1486 | e6e5906b | pbrook | unsigned int n; |
1487 | e6e5906b | pbrook | target_siginfo_t info; |
1488 | e6e5906b | pbrook | TaskState *ts = env->opaque; |
1489 | e6e5906b | pbrook | |
1490 | e6e5906b | pbrook | for(;;) {
|
1491 | e6e5906b | pbrook | trapnr = cpu_m68k_exec(env); |
1492 | e6e5906b | pbrook | switch(trapnr) {
|
1493 | e6e5906b | pbrook | case EXCP_ILLEGAL:
|
1494 | e6e5906b | pbrook | { |
1495 | e6e5906b | pbrook | if (ts->sim_syscalls) {
|
1496 | e6e5906b | pbrook | uint16_t nr; |
1497 | e6e5906b | pbrook | nr = lduw(env->pc + 2);
|
1498 | e6e5906b | pbrook | env->pc += 4;
|
1499 | e6e5906b | pbrook | do_m68k_simcall(env, nr); |
1500 | e6e5906b | pbrook | } else {
|
1501 | e6e5906b | pbrook | goto do_sigill;
|
1502 | e6e5906b | pbrook | } |
1503 | e6e5906b | pbrook | } |
1504 | e6e5906b | pbrook | break;
|
1505 | a87295e8 | pbrook | case EXCP_HALT_INSN:
|
1506 | e6e5906b | pbrook | /* Semihosing syscall. */
|
1507 | a87295e8 | pbrook | env->pc += 4;
|
1508 | e6e5906b | pbrook | do_m68k_semihosting(env, env->dregs[0]);
|
1509 | e6e5906b | pbrook | break;
|
1510 | e6e5906b | pbrook | case EXCP_LINEA:
|
1511 | e6e5906b | pbrook | case EXCP_LINEF:
|
1512 | e6e5906b | pbrook | case EXCP_UNSUPPORTED:
|
1513 | e6e5906b | pbrook | do_sigill:
|
1514 | e6e5906b | pbrook | info.si_signo = SIGILL; |
1515 | e6e5906b | pbrook | info.si_errno = 0;
|
1516 | e6e5906b | pbrook | info.si_code = TARGET_ILL_ILLOPN; |
1517 | e6e5906b | pbrook | info._sifields._sigfault._addr = env->pc; |
1518 | e6e5906b | pbrook | queue_signal(info.si_signo, &info); |
1519 | e6e5906b | pbrook | break;
|
1520 | e6e5906b | pbrook | case EXCP_TRAP0:
|
1521 | e6e5906b | pbrook | { |
1522 | e6e5906b | pbrook | ts->sim_syscalls = 0;
|
1523 | e6e5906b | pbrook | n = env->dregs[0];
|
1524 | e6e5906b | pbrook | env->pc += 2;
|
1525 | e6e5906b | pbrook | env->dregs[0] = do_syscall(env,
|
1526 | e6e5906b | pbrook | n, |
1527 | e6e5906b | pbrook | env->dregs[1],
|
1528 | e6e5906b | pbrook | env->dregs[2],
|
1529 | e6e5906b | pbrook | env->dregs[3],
|
1530 | e6e5906b | pbrook | env->dregs[4],
|
1531 | e6e5906b | pbrook | env->dregs[5],
|
1532 | e6e5906b | pbrook | env->dregs[6]);
|
1533 | e6e5906b | pbrook | } |
1534 | e6e5906b | pbrook | break;
|
1535 | e6e5906b | pbrook | case EXCP_INTERRUPT:
|
1536 | e6e5906b | pbrook | /* just indicate that signals should be handled asap */
|
1537 | e6e5906b | pbrook | break;
|
1538 | e6e5906b | pbrook | case EXCP_ACCESS:
|
1539 | e6e5906b | pbrook | { |
1540 | e6e5906b | pbrook | info.si_signo = SIGSEGV; |
1541 | e6e5906b | pbrook | info.si_errno = 0;
|
1542 | e6e5906b | pbrook | /* XXX: check env->error_code */
|
1543 | e6e5906b | pbrook | info.si_code = TARGET_SEGV_MAPERR; |
1544 | e6e5906b | pbrook | info._sifields._sigfault._addr = env->mmu.ar; |
1545 | e6e5906b | pbrook | queue_signal(info.si_signo, &info); |
1546 | e6e5906b | pbrook | } |
1547 | e6e5906b | pbrook | break;
|
1548 | e6e5906b | pbrook | case EXCP_DEBUG:
|
1549 | e6e5906b | pbrook | { |
1550 | e6e5906b | pbrook | int sig;
|
1551 | e6e5906b | pbrook | |
1552 | e6e5906b | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1553 | e6e5906b | pbrook | if (sig)
|
1554 | e6e5906b | pbrook | { |
1555 | e6e5906b | pbrook | info.si_signo = sig; |
1556 | e6e5906b | pbrook | info.si_errno = 0;
|
1557 | e6e5906b | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1558 | e6e5906b | pbrook | queue_signal(info.si_signo, &info); |
1559 | e6e5906b | pbrook | } |
1560 | e6e5906b | pbrook | } |
1561 | e6e5906b | pbrook | break;
|
1562 | e6e5906b | pbrook | default:
|
1563 | e6e5906b | pbrook | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
1564 | e6e5906b | pbrook | trapnr); |
1565 | e6e5906b | pbrook | cpu_dump_state(env, stderr, fprintf, 0);
|
1566 | e6e5906b | pbrook | abort(); |
1567 | e6e5906b | pbrook | } |
1568 | e6e5906b | pbrook | process_pending_signals(env); |
1569 | e6e5906b | pbrook | } |
1570 | e6e5906b | pbrook | } |
1571 | e6e5906b | pbrook | #endif /* TARGET_M68K */ |
1572 | e6e5906b | pbrook | |
1573 | 7a3148a9 | j_mayer | #ifdef TARGET_ALPHA
|
1574 | 7a3148a9 | j_mayer | void cpu_loop (CPUState *env)
|
1575 | 7a3148a9 | j_mayer | { |
1576 | e96efcfc | j_mayer | int trapnr;
|
1577 | 7a3148a9 | j_mayer | target_siginfo_t info; |
1578 | 7a3148a9 | j_mayer | |
1579 | 7a3148a9 | j_mayer | while (1) { |
1580 | 7a3148a9 | j_mayer | trapnr = cpu_alpha_exec (env); |
1581 | 7a3148a9 | j_mayer | |
1582 | 7a3148a9 | j_mayer | switch (trapnr) {
|
1583 | 7a3148a9 | j_mayer | case EXCP_RESET:
|
1584 | 7a3148a9 | j_mayer | fprintf(stderr, "Reset requested. Exit\n");
|
1585 | 7a3148a9 | j_mayer | exit(1);
|
1586 | 7a3148a9 | j_mayer | break;
|
1587 | 7a3148a9 | j_mayer | case EXCP_MCHK:
|
1588 | 7a3148a9 | j_mayer | fprintf(stderr, "Machine check exception. Exit\n");
|
1589 | 7a3148a9 | j_mayer | exit(1);
|
1590 | 7a3148a9 | j_mayer | break;
|
1591 | 7a3148a9 | j_mayer | case EXCP_ARITH:
|
1592 | 7a3148a9 | j_mayer | fprintf(stderr, "Arithmetic trap.\n");
|
1593 | 7a3148a9 | j_mayer | exit(1);
|
1594 | 7a3148a9 | j_mayer | break;
|
1595 | 7a3148a9 | j_mayer | case EXCP_HW_INTERRUPT:
|
1596 | 7a3148a9 | j_mayer | fprintf(stderr, "External interrupt. Exit\n");
|
1597 | 7a3148a9 | j_mayer | exit(1);
|
1598 | 7a3148a9 | j_mayer | break;
|
1599 | 7a3148a9 | j_mayer | case EXCP_DFAULT:
|
1600 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data fault\n");
|
1601 | 7a3148a9 | j_mayer | exit(1);
|
1602 | 7a3148a9 | j_mayer | break;
|
1603 | 7a3148a9 | j_mayer | case EXCP_DTB_MISS_PAL:
|
1604 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data TLB miss in PALcode\n");
|
1605 | 7a3148a9 | j_mayer | exit(1);
|
1606 | 7a3148a9 | j_mayer | break;
|
1607 | 7a3148a9 | j_mayer | case EXCP_ITB_MISS:
|
1608 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU instruction TLB miss\n");
|
1609 | 7a3148a9 | j_mayer | exit(1);
|
1610 | 7a3148a9 | j_mayer | break;
|
1611 | 7a3148a9 | j_mayer | case EXCP_ITB_ACV:
|
1612 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU instruction access violation\n");
|
1613 | 7a3148a9 | j_mayer | exit(1);
|
1614 | 7a3148a9 | j_mayer | break;
|
1615 | 7a3148a9 | j_mayer | case EXCP_DTB_MISS_NATIVE:
|
1616 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data TLB miss\n");
|
1617 | 7a3148a9 | j_mayer | exit(1);
|
1618 | 7a3148a9 | j_mayer | break;
|
1619 | 7a3148a9 | j_mayer | case EXCP_UNALIGN:
|
1620 | 7a3148a9 | j_mayer | fprintf(stderr, "Unaligned access\n");
|
1621 | 7a3148a9 | j_mayer | exit(1);
|
1622 | 7a3148a9 | j_mayer | break;
|
1623 | 7a3148a9 | j_mayer | case EXCP_OPCDEC:
|
1624 | 7a3148a9 | j_mayer | fprintf(stderr, "Invalid instruction\n");
|
1625 | 7a3148a9 | j_mayer | exit(1);
|
1626 | 7a3148a9 | j_mayer | break;
|
1627 | 7a3148a9 | j_mayer | case EXCP_FEN:
|
1628 | 7a3148a9 | j_mayer | fprintf(stderr, "Floating-point not allowed\n");
|
1629 | 7a3148a9 | j_mayer | exit(1);
|
1630 | 7a3148a9 | j_mayer | break;
|
1631 | 7a3148a9 | j_mayer | case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1): |
1632 | 7a3148a9 | j_mayer | fprintf(stderr, "Call to PALcode\n");
|
1633 | 7a3148a9 | j_mayer | call_pal(env, (trapnr >> 6) | 0x80); |
1634 | 7a3148a9 | j_mayer | break;
|
1635 | 7a3148a9 | j_mayer | case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1): |
1636 | 7f75ffd3 | blueswir1 | fprintf(stderr, "Privileged call to PALcode\n");
|
1637 | 7a3148a9 | j_mayer | exit(1);
|
1638 | 7a3148a9 | j_mayer | break;
|
1639 | 7a3148a9 | j_mayer | case EXCP_DEBUG:
|
1640 | 7a3148a9 | j_mayer | { |
1641 | 7a3148a9 | j_mayer | int sig;
|
1642 | 7a3148a9 | j_mayer | |
1643 | 7a3148a9 | j_mayer | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1644 | 7a3148a9 | j_mayer | if (sig)
|
1645 | 7a3148a9 | j_mayer | { |
1646 | 7a3148a9 | j_mayer | info.si_signo = sig; |
1647 | 7a3148a9 | j_mayer | info.si_errno = 0;
|
1648 | 7a3148a9 | j_mayer | info.si_code = TARGET_TRAP_BRKPT; |
1649 | 7a3148a9 | j_mayer | queue_signal(info.si_signo, &info); |
1650 | 7a3148a9 | j_mayer | } |
1651 | 7a3148a9 | j_mayer | } |
1652 | 7a3148a9 | j_mayer | break;
|
1653 | 7a3148a9 | j_mayer | default:
|
1654 | 7a3148a9 | j_mayer | printf ("Unhandled trap: 0x%x\n", trapnr);
|
1655 | 7a3148a9 | j_mayer | cpu_dump_state(env, stderr, fprintf, 0);
|
1656 | 7a3148a9 | j_mayer | exit (1);
|
1657 | 7a3148a9 | j_mayer | } |
1658 | 7a3148a9 | j_mayer | process_pending_signals (env); |
1659 | 7a3148a9 | j_mayer | } |
1660 | 7a3148a9 | j_mayer | } |
1661 | 7a3148a9 | j_mayer | #endif /* TARGET_ALPHA */ |
1662 | 7a3148a9 | j_mayer | |
1663 | 31e31b8a | bellard | void usage(void) |
1664 | 31e31b8a | bellard | { |
1665 | 84f2e8ef | bellard | printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n" |
1666 | b1f9be31 | j_mayer | "usage: qemu-" TARGET_ARCH " [-h] [-g] [-d opts] [-L path] [-s size] [-cpu model] program [arguments...]\n" |
1667 | b346ff46 | bellard | "Linux CPU emulator (compiled for %s emulation)\n"
|
1668 | d691f669 | bellard | "\n"
|
1669 | 54936004 | bellard | "-h print this help\n"
|
1670 | 74c33bed | bellard | "-g port wait gdb connection to port\n"
|
1671 | b346ff46 | bellard | "-L path set the elf interpreter prefix (default=%s)\n"
|
1672 | b346ff46 | bellard | "-s size set the stack size in bytes (default=%ld)\n"
|
1673 | b1f9be31 | j_mayer | "-cpu model select CPU (-cpu ? for list)\n"
|
1674 | 54936004 | bellard | "\n"
|
1675 | 54936004 | bellard | "debug options:\n"
|
1676 | c6981055 | bellard | #ifdef USE_CODE_COPY
|
1677 | c6981055 | bellard | "-no-code-copy disable code copy acceleration\n"
|
1678 | c6981055 | bellard | #endif
|
1679 | 6f1f31c0 | bellard | "-d options activate log (logfile=%s)\n"
|
1680 | 54936004 | bellard | "-p pagesize set the host page size to 'pagesize'\n",
|
1681 | b346ff46 | bellard | TARGET_ARCH, |
1682 | d691f669 | bellard | interp_prefix, |
1683 | 54936004 | bellard | x86_stack_size, |
1684 | 54936004 | bellard | DEBUG_LOGFILE); |
1685 | 74cd30b8 | bellard | _exit(1);
|
1686 | 31e31b8a | bellard | } |
1687 | 31e31b8a | bellard | |
1688 | 9de5e440 | bellard | /* XXX: currently only used for async signals (see signal.c) */
|
1689 | b346ff46 | bellard | CPUState *global_env; |
1690 | 59faf6d6 | bellard | |
1691 | 851e67a1 | bellard | /* used to free thread contexts */
|
1692 | 851e67a1 | bellard | TaskState *first_task_state; |
1693 | 9de5e440 | bellard | |
1694 | 31e31b8a | bellard | int main(int argc, char **argv) |
1695 | 31e31b8a | bellard | { |
1696 | 31e31b8a | bellard | const char *filename; |
1697 | b1f9be31 | j_mayer | const char *cpu_model; |
1698 | 01ffc75b | bellard | struct target_pt_regs regs1, *regs = ®s1;
|
1699 | 31e31b8a | bellard | struct image_info info1, *info = &info1;
|
1700 | 851e67a1 | bellard | TaskState ts1, *ts = &ts1; |
1701 | b346ff46 | bellard | CPUState *env; |
1702 | 586314f2 | bellard | int optind;
|
1703 | d691f669 | bellard | const char *r; |
1704 | 74c33bed | bellard | int gdbstub_port = 0; |
1705 | d691f669 | bellard | |
1706 | 31e31b8a | bellard | if (argc <= 1) |
1707 | 31e31b8a | bellard | usage(); |
1708 | f801f97e | bellard | |
1709 | cc38b844 | bellard | /* init debug */
|
1710 | cc38b844 | bellard | cpu_set_log_filename(DEBUG_LOGFILE); |
1711 | cc38b844 | bellard | |
1712 | b1f9be31 | j_mayer | cpu_model = NULL;
|
1713 | 586314f2 | bellard | optind = 1;
|
1714 | d691f669 | bellard | for(;;) {
|
1715 | d691f669 | bellard | if (optind >= argc)
|
1716 | d691f669 | bellard | break;
|
1717 | d691f669 | bellard | r = argv[optind]; |
1718 | d691f669 | bellard | if (r[0] != '-') |
1719 | d691f669 | bellard | break;
|
1720 | 586314f2 | bellard | optind++; |
1721 | d691f669 | bellard | r++; |
1722 | d691f669 | bellard | if (!strcmp(r, "-")) { |
1723 | d691f669 | bellard | break;
|
1724 | d691f669 | bellard | } else if (!strcmp(r, "d")) { |
1725 | e19e89a5 | bellard | int mask;
|
1726 | e19e89a5 | bellard | CPULogItem *item; |
1727 | 6f1f31c0 | bellard | |
1728 | 6f1f31c0 | bellard | if (optind >= argc)
|
1729 | 6f1f31c0 | bellard | break;
|
1730 | e19e89a5 | bellard | |
1731 | 6f1f31c0 | bellard | r = argv[optind++]; |
1732 | 6f1f31c0 | bellard | mask = cpu_str_to_log_mask(r); |
1733 | e19e89a5 | bellard | if (!mask) {
|
1734 | e19e89a5 | bellard | printf("Log items (comma separated):\n");
|
1735 | e19e89a5 | bellard | for(item = cpu_log_items; item->mask != 0; item++) { |
1736 | e19e89a5 | bellard | printf("%-10s %s\n", item->name, item->help);
|
1737 | e19e89a5 | bellard | } |
1738 | e19e89a5 | bellard | exit(1);
|
1739 | e19e89a5 | bellard | } |
1740 | e19e89a5 | bellard | cpu_set_log(mask); |
1741 | d691f669 | bellard | } else if (!strcmp(r, "s")) { |
1742 | d691f669 | bellard | r = argv[optind++]; |
1743 | d691f669 | bellard | x86_stack_size = strtol(r, (char **)&r, 0); |
1744 | d691f669 | bellard | if (x86_stack_size <= 0) |
1745 | d691f669 | bellard | usage(); |
1746 | d691f669 | bellard | if (*r == 'M') |
1747 | d691f669 | bellard | x86_stack_size *= 1024 * 1024; |
1748 | d691f669 | bellard | else if (*r == 'k' || *r == 'K') |
1749 | d691f669 | bellard | x86_stack_size *= 1024;
|
1750 | d691f669 | bellard | } else if (!strcmp(r, "L")) { |
1751 | d691f669 | bellard | interp_prefix = argv[optind++]; |
1752 | 54936004 | bellard | } else if (!strcmp(r, "p")) { |
1753 | 83fb7adf | bellard | qemu_host_page_size = atoi(argv[optind++]); |
1754 | 83fb7adf | bellard | if (qemu_host_page_size == 0 || |
1755 | 83fb7adf | bellard | (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { |
1756 | 54936004 | bellard | fprintf(stderr, "page size must be a power of two\n");
|
1757 | 54936004 | bellard | exit(1);
|
1758 | 54936004 | bellard | } |
1759 | 1fddef4b | bellard | } else if (!strcmp(r, "g")) { |
1760 | 74c33bed | bellard | gdbstub_port = atoi(argv[optind++]); |
1761 | c5937220 | pbrook | } else if (!strcmp(r, "r")) { |
1762 | c5937220 | pbrook | qemu_uname_release = argv[optind++]; |
1763 | b1f9be31 | j_mayer | } else if (!strcmp(r, "cpu")) { |
1764 | b1f9be31 | j_mayer | cpu_model = argv[optind++]; |
1765 | b1f9be31 | j_mayer | if (strcmp(cpu_model, "?") == 0) { |
1766 | b1f9be31 | j_mayer | #if defined(TARGET_PPC)
|
1767 | b1f9be31 | j_mayer | ppc_cpu_list(stdout, &fprintf); |
1768 | b1f9be31 | j_mayer | #elif defined(TARGET_ARM)
|
1769 | b1f9be31 | j_mayer | arm_cpu_list(); |
1770 | b1f9be31 | j_mayer | #elif defined(TARGET_MIPS)
|
1771 | b1f9be31 | j_mayer | mips_cpu_list(stdout, &fprintf); |
1772 | 925fb139 | blueswir1 | #elif defined(TARGET_SPARC)
|
1773 | 925fb139 | blueswir1 | sparc_cpu_list(stdout, &fprintf); |
1774 | b1f9be31 | j_mayer | #endif
|
1775 | cff4cbed | ths | _exit(1);
|
1776 | b1f9be31 | j_mayer | } |
1777 | c6981055 | bellard | } else
|
1778 | c6981055 | bellard | #ifdef USE_CODE_COPY
|
1779 | c6981055 | bellard | if (!strcmp(r, "no-code-copy")) { |
1780 | c6981055 | bellard | code_copy_enabled = 0;
|
1781 | c6981055 | bellard | } else
|
1782 | c6981055 | bellard | #endif
|
1783 | c6981055 | bellard | { |
1784 | d691f669 | bellard | usage(); |
1785 | d691f669 | bellard | } |
1786 | 586314f2 | bellard | } |
1787 | d691f669 | bellard | if (optind >= argc)
|
1788 | d691f669 | bellard | usage(); |
1789 | 586314f2 | bellard | filename = argv[optind]; |
1790 | 586314f2 | bellard | |
1791 | 31e31b8a | bellard | /* Zero out regs */
|
1792 | 01ffc75b | bellard | memset(regs, 0, sizeof(struct target_pt_regs)); |
1793 | 31e31b8a | bellard | |
1794 | 31e31b8a | bellard | /* Zero out image_info */
|
1795 | 31e31b8a | bellard | memset(info, 0, sizeof(struct image_info)); |
1796 | 31e31b8a | bellard | |
1797 | 74cd30b8 | bellard | /* Scan interp_prefix dir for replacement files. */
|
1798 | 74cd30b8 | bellard | init_paths(interp_prefix); |
1799 | 74cd30b8 | bellard | |
1800 | 83fb7adf | bellard | /* NOTE: we need to init the CPU at this stage to get
|
1801 | 83fb7adf | bellard | qemu_host_page_size */
|
1802 | b346ff46 | bellard | env = cpu_init(); |
1803 | 15338fd7 | bellard | global_env = env; |
1804 | 92ccca6a | bellard | |
1805 | e5fe0c52 | pbrook | if (loader_exec(filename, argv+optind, environ, regs, info) != 0) { |
1806 | 31e31b8a | bellard | printf("Error loading %s\n", filename);
|
1807 | 74cd30b8 | bellard | _exit(1);
|
1808 | 31e31b8a | bellard | } |
1809 | 31e31b8a | bellard | |
1810 | 4b74fe1f | bellard | if (loglevel) {
|
1811 | 54936004 | bellard | page_dump(logfile); |
1812 | 54936004 | bellard | |
1813 | 4b74fe1f | bellard | fprintf(logfile, "start_brk 0x%08lx\n" , info->start_brk);
|
1814 | 4b74fe1f | bellard | fprintf(logfile, "end_code 0x%08lx\n" , info->end_code);
|
1815 | 4b74fe1f | bellard | fprintf(logfile, "start_code 0x%08lx\n" , info->start_code);
|
1816 | e5fe0c52 | pbrook | fprintf(logfile, "start_data 0x%08lx\n" , info->start_data);
|
1817 | 4b74fe1f | bellard | fprintf(logfile, "end_data 0x%08lx\n" , info->end_data);
|
1818 | 4b74fe1f | bellard | fprintf(logfile, "start_stack 0x%08lx\n" , info->start_stack);
|
1819 | 4b74fe1f | bellard | fprintf(logfile, "brk 0x%08lx\n" , info->brk);
|
1820 | b346ff46 | bellard | fprintf(logfile, "entry 0x%08lx\n" , info->entry);
|
1821 | 4b74fe1f | bellard | } |
1822 | 31e31b8a | bellard | |
1823 | 53a5960a | pbrook | target_set_brk(info->brk); |
1824 | 31e31b8a | bellard | syscall_init(); |
1825 | 66fb9763 | bellard | signal_init(); |
1826 | 31e31b8a | bellard | |
1827 | 851e67a1 | bellard | /* build Task State */
|
1828 | 851e67a1 | bellard | memset(ts, 0, sizeof(TaskState)); |
1829 | 851e67a1 | bellard | env->opaque = ts; |
1830 | 851e67a1 | bellard | ts->used = 1;
|
1831 | 978efd6a | pbrook | ts->info = info; |
1832 | 59faf6d6 | bellard | env->user_mode_only = 1;
|
1833 | 851e67a1 | bellard | |
1834 | b346ff46 | bellard | #if defined(TARGET_I386)
|
1835 | 2e255c6b | bellard | cpu_x86_set_cpl(env, 3);
|
1836 | 2e255c6b | bellard | |
1837 | 3802ce26 | bellard | env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
|
1838 | 1bde465e | bellard | env->hflags |= HF_PE_MASK; |
1839 | 1bde465e | bellard | if (env->cpuid_features & CPUID_SSE) {
|
1840 | 1bde465e | bellard | env->cr[4] |= CR4_OSFXSR_MASK;
|
1841 | 1bde465e | bellard | env->hflags |= HF_OSFXSR_MASK; |
1842 | 1bde465e | bellard | } |
1843 | 1bde465e | bellard | |
1844 | 415e561f | bellard | /* flags setup : we activate the IRQs by default as in user mode */
|
1845 | 415e561f | bellard | env->eflags |= IF_MASK; |
1846 | 415e561f | bellard | |
1847 | 6dbad63e | bellard | /* linux register setup */
|
1848 | 84409ddb | j_mayer | #if defined(TARGET_X86_64)
|
1849 | 84409ddb | j_mayer | env->regs[R_EAX] = regs->rax; |
1850 | 84409ddb | j_mayer | env->regs[R_EBX] = regs->rbx; |
1851 | 84409ddb | j_mayer | env->regs[R_ECX] = regs->rcx; |
1852 | 84409ddb | j_mayer | env->regs[R_EDX] = regs->rdx; |
1853 | 84409ddb | j_mayer | env->regs[R_ESI] = regs->rsi; |
1854 | 84409ddb | j_mayer | env->regs[R_EDI] = regs->rdi; |
1855 | 84409ddb | j_mayer | env->regs[R_EBP] = regs->rbp; |
1856 | 84409ddb | j_mayer | env->regs[R_ESP] = regs->rsp; |
1857 | 84409ddb | j_mayer | env->eip = regs->rip; |
1858 | 84409ddb | j_mayer | #else
|
1859 | 0ecfa993 | bellard | env->regs[R_EAX] = regs->eax; |
1860 | 0ecfa993 | bellard | env->regs[R_EBX] = regs->ebx; |
1861 | 0ecfa993 | bellard | env->regs[R_ECX] = regs->ecx; |
1862 | 0ecfa993 | bellard | env->regs[R_EDX] = regs->edx; |
1863 | 0ecfa993 | bellard | env->regs[R_ESI] = regs->esi; |
1864 | 0ecfa993 | bellard | env->regs[R_EDI] = regs->edi; |
1865 | 0ecfa993 | bellard | env->regs[R_EBP] = regs->ebp; |
1866 | 0ecfa993 | bellard | env->regs[R_ESP] = regs->esp; |
1867 | dab2ed99 | bellard | env->eip = regs->eip; |
1868 | 84409ddb | j_mayer | #endif
|
1869 | 31e31b8a | bellard | |
1870 | f4beb510 | bellard | /* linux interrupt setup */
|
1871 | 53a5960a | pbrook | env->idt.base = h2g(idt_table); |
1872 | f4beb510 | bellard | env->idt.limit = sizeof(idt_table) - 1; |
1873 | f4beb510 | bellard | set_idt(0, 0); |
1874 | f4beb510 | bellard | set_idt(1, 0); |
1875 | f4beb510 | bellard | set_idt(2, 0); |
1876 | f4beb510 | bellard | set_idt(3, 3); |
1877 | f4beb510 | bellard | set_idt(4, 3); |
1878 | f4beb510 | bellard | set_idt(5, 3); |
1879 | f4beb510 | bellard | set_idt(6, 0); |
1880 | f4beb510 | bellard | set_idt(7, 0); |
1881 | f4beb510 | bellard | set_idt(8, 0); |
1882 | f4beb510 | bellard | set_idt(9, 0); |
1883 | f4beb510 | bellard | set_idt(10, 0); |
1884 | f4beb510 | bellard | set_idt(11, 0); |
1885 | f4beb510 | bellard | set_idt(12, 0); |
1886 | f4beb510 | bellard | set_idt(13, 0); |
1887 | f4beb510 | bellard | set_idt(14, 0); |
1888 | f4beb510 | bellard | set_idt(15, 0); |
1889 | f4beb510 | bellard | set_idt(16, 0); |
1890 | f4beb510 | bellard | set_idt(17, 0); |
1891 | f4beb510 | bellard | set_idt(18, 0); |
1892 | f4beb510 | bellard | set_idt(19, 0); |
1893 | f4beb510 | bellard | set_idt(0x80, 3); |
1894 | f4beb510 | bellard | |
1895 | 6dbad63e | bellard | /* linux segment setup */
|
1896 | 53a5960a | pbrook | env->gdt.base = h2g(gdt_table); |
1897 | 6dbad63e | bellard | env->gdt.limit = sizeof(gdt_table) - 1; |
1898 | f4beb510 | bellard | write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, |
1899 | f4beb510 | bellard | DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | |
1900 | f4beb510 | bellard | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); |
1901 | f4beb510 | bellard | write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff, |
1902 | f4beb510 | bellard | DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | |
1903 | f4beb510 | bellard | (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT)); |
1904 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_CS, __USER_CS); |
1905 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_DS, __USER_DS); |
1906 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_ES, __USER_DS); |
1907 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_SS, __USER_DS); |
1908 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_FS, __USER_DS); |
1909 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_GS, __USER_DS); |
1910 | 92ccca6a | bellard | |
1911 | b346ff46 | bellard | #elif defined(TARGET_ARM)
|
1912 | b346ff46 | bellard | { |
1913 | b346ff46 | bellard | int i;
|
1914 | b1f9be31 | j_mayer | if (cpu_model == NULL) |
1915 | b1f9be31 | j_mayer | cpu_model = "arm926";
|
1916 | b1f9be31 | j_mayer | cpu_arm_set_model(env, cpu_model); |
1917 | b5ff1b31 | bellard | cpsr_write(env, regs->uregs[16], 0xffffffff); |
1918 | b346ff46 | bellard | for(i = 0; i < 16; i++) { |
1919 | b346ff46 | bellard | env->regs[i] = regs->uregs[i]; |
1920 | b346ff46 | bellard | } |
1921 | b346ff46 | bellard | } |
1922 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
1923 | 060366c5 | bellard | { |
1924 | 060366c5 | bellard | int i;
|
1925 | 925fb139 | blueswir1 | const sparc_def_t *def;
|
1926 | 925fb139 | blueswir1 | #ifdef TARGET_SPARC64
|
1927 | 925fb139 | blueswir1 | if (cpu_model == NULL) |
1928 | 925fb139 | blueswir1 | cpu_model = "TI UltraSparc II";
|
1929 | 925fb139 | blueswir1 | #else
|
1930 | 925fb139 | blueswir1 | if (cpu_model == NULL) |
1931 | 925fb139 | blueswir1 | cpu_model = "Fujitsu MB86904";
|
1932 | 925fb139 | blueswir1 | #endif
|
1933 | 925fb139 | blueswir1 | sparc_find_by_name(cpu_model, &def); |
1934 | 925fb139 | blueswir1 | if (def == NULL) { |
1935 | 925fb139 | blueswir1 | fprintf(stderr, "Unable to find Sparc CPU definition\n");
|
1936 | 925fb139 | blueswir1 | exit(1);
|
1937 | 925fb139 | blueswir1 | } |
1938 | 925fb139 | blueswir1 | cpu_sparc_register(env, def); |
1939 | 060366c5 | bellard | env->pc = regs->pc; |
1940 | 060366c5 | bellard | env->npc = regs->npc; |
1941 | 060366c5 | bellard | env->y = regs->y; |
1942 | 060366c5 | bellard | for(i = 0; i < 8; i++) |
1943 | 060366c5 | bellard | env->gregs[i] = regs->u_regs[i]; |
1944 | 060366c5 | bellard | for(i = 0; i < 8; i++) |
1945 | 060366c5 | bellard | env->regwptr[i] = regs->u_regs[i + 8];
|
1946 | 060366c5 | bellard | } |
1947 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
1948 | 67867308 | bellard | { |
1949 | 3fc6c082 | bellard | ppc_def_t *def; |
1950 | 67867308 | bellard | int i;
|
1951 | 3fc6c082 | bellard | |
1952 | 3fc6c082 | bellard | /* Choose and initialise CPU */
|
1953 | b1f9be31 | j_mayer | if (cpu_model == NULL) |
1954 | b1f9be31 | j_mayer | cpu_model = "750";
|
1955 | b1f9be31 | j_mayer | ppc_find_by_name(cpu_model, &def); |
1956 | 3fc6c082 | bellard | if (def == NULL) { |
1957 | c68ea704 | bellard | cpu_abort(env, |
1958 | 3fc6c082 | bellard | "Unable to find PowerPC CPU definition\n");
|
1959 | 3fc6c082 | bellard | } |
1960 | c68ea704 | bellard | cpu_ppc_register(env, def); |
1961 | 3fc6c082 | bellard | |
1962 | 61190b14 | bellard | for (i = 0; i < 32; i++) { |
1963 | 4c2e770f | bellard | if (i != 12 && i != 6 && i != 13) |
1964 | 61190b14 | bellard | env->msr[i] = (regs->msr >> i) & 1;
|
1965 | 61190b14 | bellard | } |
1966 | 84409ddb | j_mayer | #if defined(TARGET_PPC64)
|
1967 | 84409ddb | j_mayer | msr_sf = 1;
|
1968 | 84409ddb | j_mayer | #endif
|
1969 | 67867308 | bellard | env->nip = regs->nip; |
1970 | 67867308 | bellard | for(i = 0; i < 32; i++) { |
1971 | 67867308 | bellard | env->gpr[i] = regs->gpr[i]; |
1972 | 67867308 | bellard | } |
1973 | 67867308 | bellard | } |
1974 | e6e5906b | pbrook | #elif defined(TARGET_M68K)
|
1975 | e6e5906b | pbrook | { |
1976 | 0633879f | pbrook | if (cpu_model == NULL) |
1977 | 0402f767 | pbrook | cpu_model = "any";
|
1978 | 0633879f | pbrook | if (cpu_m68k_set_model(env, cpu_model)) {
|
1979 | e6e5906b | pbrook | cpu_abort(cpu_single_env, |
1980 | e6e5906b | pbrook | "Unable to find m68k CPU definition\n");
|
1981 | e6e5906b | pbrook | } |
1982 | e6e5906b | pbrook | env->pc = regs->pc; |
1983 | e6e5906b | pbrook | env->dregs[0] = regs->d0;
|
1984 | e6e5906b | pbrook | env->dregs[1] = regs->d1;
|
1985 | e6e5906b | pbrook | env->dregs[2] = regs->d2;
|
1986 | e6e5906b | pbrook | env->dregs[3] = regs->d3;
|
1987 | e6e5906b | pbrook | env->dregs[4] = regs->d4;
|
1988 | e6e5906b | pbrook | env->dregs[5] = regs->d5;
|
1989 | e6e5906b | pbrook | env->dregs[6] = regs->d6;
|
1990 | e6e5906b | pbrook | env->dregs[7] = regs->d7;
|
1991 | e6e5906b | pbrook | env->aregs[0] = regs->a0;
|
1992 | e6e5906b | pbrook | env->aregs[1] = regs->a1;
|
1993 | e6e5906b | pbrook | env->aregs[2] = regs->a2;
|
1994 | e6e5906b | pbrook | env->aregs[3] = regs->a3;
|
1995 | e6e5906b | pbrook | env->aregs[4] = regs->a4;
|
1996 | e6e5906b | pbrook | env->aregs[5] = regs->a5;
|
1997 | e6e5906b | pbrook | env->aregs[6] = regs->a6;
|
1998 | e6e5906b | pbrook | env->aregs[7] = regs->usp;
|
1999 | e6e5906b | pbrook | env->sr = regs->sr; |
2000 | e6e5906b | pbrook | ts->sim_syscalls = 1;
|
2001 | e6e5906b | pbrook | } |
2002 | 048f6b4d | bellard | #elif defined(TARGET_MIPS)
|
2003 | 048f6b4d | bellard | { |
2004 | cff4cbed | ths | mips_def_t *def; |
2005 | 048f6b4d | bellard | int i;
|
2006 | 048f6b4d | bellard | |
2007 | cff4cbed | ths | /* Choose and initialise CPU */
|
2008 | cff4cbed | ths | if (cpu_model == NULL) |
2009 | cff4cbed | ths | cpu_model = "24Kf";
|
2010 | cff4cbed | ths | mips_find_by_name(cpu_model, &def); |
2011 | cff4cbed | ths | if (def == NULL) |
2012 | cff4cbed | ths | cpu_abort(env, "Unable to find MIPS CPU definition\n");
|
2013 | cff4cbed | ths | cpu_mips_register(env, def); |
2014 | cff4cbed | ths | |
2015 | 048f6b4d | bellard | for(i = 0; i < 32; i++) { |
2016 | 048f6b4d | bellard | env->gpr[i] = regs->regs[i]; |
2017 | 048f6b4d | bellard | } |
2018 | 048f6b4d | bellard | env->PC = regs->cp0_epc; |
2019 | 36d23958 | ths | if (env->CP0_Config1 & (1 << CP0C1_FP)) { |
2020 | 36d23958 | ths | env->CP0_Status |= (1 << CP0St_CU1);
|
2021 | 36d23958 | ths | } |
2022 | 048f6b4d | bellard | } |
2023 | fdf9b3e8 | bellard | #elif defined(TARGET_SH4)
|
2024 | fdf9b3e8 | bellard | { |
2025 | fdf9b3e8 | bellard | int i;
|
2026 | fdf9b3e8 | bellard | |
2027 | fdf9b3e8 | bellard | for(i = 0; i < 16; i++) { |
2028 | fdf9b3e8 | bellard | env->gregs[i] = regs->regs[i]; |
2029 | fdf9b3e8 | bellard | } |
2030 | fdf9b3e8 | bellard | env->pc = regs->pc; |
2031 | fdf9b3e8 | bellard | } |
2032 | 7a3148a9 | j_mayer | #elif defined(TARGET_ALPHA)
|
2033 | 7a3148a9 | j_mayer | { |
2034 | 7a3148a9 | j_mayer | int i;
|
2035 | 7a3148a9 | j_mayer | |
2036 | 7a3148a9 | j_mayer | for(i = 0; i < 28; i++) { |
2037 | 7a3148a9 | j_mayer | env->ir[i] = ((target_ulong *)regs)[i]; |
2038 | 7a3148a9 | j_mayer | } |
2039 | 7a3148a9 | j_mayer | env->ipr[IPR_USP] = regs->usp; |
2040 | 7a3148a9 | j_mayer | env->ir[30] = regs->usp;
|
2041 | 7a3148a9 | j_mayer | env->pc = regs->pc; |
2042 | 7a3148a9 | j_mayer | env->unique = regs->unique; |
2043 | 7a3148a9 | j_mayer | } |
2044 | b346ff46 | bellard | #else
|
2045 | b346ff46 | bellard | #error unsupported target CPU
|
2046 | b346ff46 | bellard | #endif
|
2047 | 31e31b8a | bellard | |
2048 | a87295e8 | pbrook | #if defined(TARGET_ARM) || defined(TARGET_M68K)
|
2049 | a87295e8 | pbrook | ts->stack_base = info->start_stack; |
2050 | a87295e8 | pbrook | ts->heap_base = info->brk; |
2051 | a87295e8 | pbrook | /* This will be filled in on the first SYS_HEAPINFO call. */
|
2052 | a87295e8 | pbrook | ts->heap_limit = 0;
|
2053 | a87295e8 | pbrook | #endif
|
2054 | a87295e8 | pbrook | |
2055 | 74c33bed | bellard | if (gdbstub_port) {
|
2056 | 74c33bed | bellard | gdbserver_start (gdbstub_port); |
2057 | 1fddef4b | bellard | gdb_handlesig(env, 0);
|
2058 | 1fddef4b | bellard | } |
2059 | 1b6b029e | bellard | cpu_loop(env); |
2060 | 1b6b029e | bellard | /* never exits */
|
2061 | 31e31b8a | bellard | return 0; |
2062 | 31e31b8a | bellard | } |