root / linux-user / main.c @ 1a14026e
History | View | Annotate | Download (80.4 kB)
1 | 31e31b8a | bellard | /*
|
---|---|---|---|
2 | 93ac68bc | bellard | * qemu user main
|
3 | 5fafdf24 | ths | *
|
4 | 68d0f70e | bellard | * Copyright (c) 2003-2008 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 | ca10f867 | aurel32 | #include "qemu-common.h" |
29 | 31e31b8a | bellard | |
30 | 3ef693a0 | bellard | #define DEBUG_LOGFILE "/tmp/qemu.log" |
31 | 586314f2 | bellard | |
32 | 74cd30b8 | bellard | static const char *interp_prefix = CONFIG_QEMU_PREFIX; |
33 | c5937220 | pbrook | const char *qemu_uname_release = CONFIG_UNAME_RELEASE; |
34 | 586314f2 | bellard | |
35 | 3a4739d6 | bellard | #if defined(__i386__) && !defined(CONFIG_STATIC)
|
36 | f801f97e | bellard | /* Force usage of an ELF interpreter even if it is an ELF shared
|
37 | f801f97e | bellard | object ! */
|
38 | f801f97e | bellard | const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; |
39 | 4304763b | bellard | #endif
|
40 | 74cd30b8 | bellard | |
41 | 93ac68bc | bellard | /* for recent libc, we add these dummy symbols which are not declared
|
42 | 74cd30b8 | bellard | when generating a linked object (bug in ld ?) */
|
43 | fbf59244 | bellard | #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) |
44 | 46027c07 | bellard | asm(".globl __preinit_array_start\n" |
45 | 46027c07 | bellard | ".globl __preinit_array_end\n"
|
46 | 46027c07 | bellard | ".globl __init_array_start\n"
|
47 | 46027c07 | bellard | ".globl __init_array_end\n"
|
48 | 46027c07 | bellard | ".globl __fini_array_start\n"
|
49 | 46027c07 | bellard | ".globl __fini_array_end\n"
|
50 | 46027c07 | bellard | ".section \".rodata\"\n"
|
51 | 46027c07 | bellard | "__preinit_array_start:\n"
|
52 | 46027c07 | bellard | "__preinit_array_end:\n"
|
53 | 46027c07 | bellard | "__init_array_start:\n"
|
54 | 46027c07 | bellard | "__init_array_end:\n"
|
55 | 46027c07 | bellard | "__fini_array_start:\n"
|
56 | 46027c07 | bellard | "__fini_array_end:\n"
|
57 | 7bba1ee8 | ths | ".long 0\n"
|
58 | 7bba1ee8 | ths | ".previous\n");
|
59 | 74cd30b8 | bellard | #endif
|
60 | 74cd30b8 | bellard | |
61 | 9de5e440 | bellard | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
|
62 | 9de5e440 | bellard | we allocate a bigger stack. Need a better solution, for example
|
63 | 9de5e440 | bellard | by remapping the process stack directly at the right place */
|
64 | 9de5e440 | bellard | unsigned long x86_stack_size = 512 * 1024; |
65 | 31e31b8a | bellard | |
66 | 31e31b8a | bellard | void gemu_log(const char *fmt, ...) |
67 | 31e31b8a | bellard | { |
68 | 31e31b8a | bellard | va_list ap; |
69 | 31e31b8a | bellard | |
70 | 31e31b8a | bellard | va_start(ap, fmt); |
71 | 31e31b8a | bellard | vfprintf(stderr, fmt, ap); |
72 | 31e31b8a | bellard | va_end(ap); |
73 | 31e31b8a | bellard | } |
74 | 31e31b8a | bellard | |
75 | 61190b14 | bellard | void cpu_outb(CPUState *env, int addr, int val) |
76 | 367e86e8 | bellard | { |
77 | 367e86e8 | bellard | fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
|
78 | 367e86e8 | bellard | } |
79 | 367e86e8 | bellard | |
80 | 61190b14 | bellard | void cpu_outw(CPUState *env, int addr, int val) |
81 | 367e86e8 | bellard | { |
82 | 367e86e8 | bellard | fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
|
83 | 367e86e8 | bellard | } |
84 | 367e86e8 | bellard | |
85 | 61190b14 | bellard | void cpu_outl(CPUState *env, int addr, int val) |
86 | 367e86e8 | bellard | { |
87 | 367e86e8 | bellard | fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
|
88 | 367e86e8 | bellard | } |
89 | 367e86e8 | bellard | |
90 | 61190b14 | bellard | int cpu_inb(CPUState *env, int addr) |
91 | 367e86e8 | bellard | { |
92 | 367e86e8 | bellard | fprintf(stderr, "inb: port=0x%04x\n", addr);
|
93 | 367e86e8 | bellard | return 0; |
94 | 367e86e8 | bellard | } |
95 | 367e86e8 | bellard | |
96 | 61190b14 | bellard | int cpu_inw(CPUState *env, int addr) |
97 | 367e86e8 | bellard | { |
98 | 367e86e8 | bellard | fprintf(stderr, "inw: port=0x%04x\n", addr);
|
99 | 367e86e8 | bellard | return 0; |
100 | 367e86e8 | bellard | } |
101 | 367e86e8 | bellard | |
102 | 61190b14 | bellard | int cpu_inl(CPUState *env, int addr) |
103 | 367e86e8 | bellard | { |
104 | 367e86e8 | bellard | fprintf(stderr, "inl: port=0x%04x\n", addr);
|
105 | 367e86e8 | bellard | return 0; |
106 | 367e86e8 | bellard | } |
107 | 367e86e8 | bellard | |
108 | a541f297 | bellard | int cpu_get_pic_interrupt(CPUState *env)
|
109 | 92ccca6a | bellard | { |
110 | 92ccca6a | bellard | return -1; |
111 | 92ccca6a | bellard | } |
112 | 92ccca6a | bellard | |
113 | 28ab0e2e | bellard | /* timers for rdtsc */
|
114 | 28ab0e2e | bellard | |
115 | 1dce7c3c | bellard | #if 0
|
116 | 28ab0e2e | bellard | |
117 | 28ab0e2e | bellard | static uint64_t emu_time;
|
118 | 28ab0e2e | bellard | |
119 | 28ab0e2e | bellard | int64_t cpu_get_real_ticks(void)
|
120 | 28ab0e2e | bellard | {
|
121 | 28ab0e2e | bellard | return emu_time++;
|
122 | 28ab0e2e | bellard | }
|
123 | 28ab0e2e | bellard | |
124 | 28ab0e2e | bellard | #endif
|
125 | 28ab0e2e | bellard | |
126 | a541f297 | bellard | #ifdef TARGET_I386
|
127 | a541f297 | bellard | /***********************************************************/
|
128 | a541f297 | bellard | /* CPUX86 core interface */
|
129 | a541f297 | bellard | |
130 | 02a1602e | bellard | void cpu_smm_update(CPUState *env)
|
131 | 02a1602e | bellard | { |
132 | 02a1602e | bellard | } |
133 | 02a1602e | bellard | |
134 | 28ab0e2e | bellard | uint64_t cpu_get_tsc(CPUX86State *env) |
135 | 28ab0e2e | bellard | { |
136 | 28ab0e2e | bellard | return cpu_get_real_ticks();
|
137 | 28ab0e2e | bellard | } |
138 | 28ab0e2e | bellard | |
139 | 5fafdf24 | ths | static void write_dt(void *ptr, unsigned long addr, unsigned long limit, |
140 | f4beb510 | bellard | int flags)
|
141 | 6dbad63e | bellard | { |
142 | f4beb510 | bellard | unsigned int e1, e2; |
143 | 53a5960a | pbrook | uint32_t *p; |
144 | 6dbad63e | bellard | e1 = (addr << 16) | (limit & 0xffff); |
145 | 6dbad63e | bellard | e2 = ((addr >> 16) & 0xff) | (addr & 0xff000000) | (limit & 0x000f0000); |
146 | f4beb510 | bellard | e2 |= flags; |
147 | 53a5960a | pbrook | p = ptr; |
148 | 53a5960a | pbrook | p[0] = tswapl(e1);
|
149 | 53a5960a | pbrook | p[1] = tswapl(e2);
|
150 | f4beb510 | bellard | } |
151 | f4beb510 | bellard | |
152 | d2fd1af7 | bellard | #if TARGET_X86_64
|
153 | d2fd1af7 | bellard | uint64_t idt_table[512];
|
154 | d2fd1af7 | bellard | |
155 | d2fd1af7 | bellard | static void set_gate64(void *ptr, unsigned int type, unsigned int dpl, |
156 | d2fd1af7 | bellard | uint64_t addr, unsigned int sel) |
157 | f4beb510 | bellard | { |
158 | 4dbc422b | bellard | uint32_t *p, e1, e2; |
159 | f4beb510 | bellard | e1 = (addr & 0xffff) | (sel << 16); |
160 | f4beb510 | bellard | e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8); |
161 | 53a5960a | pbrook | p = ptr; |
162 | 4dbc422b | bellard | p[0] = tswap32(e1);
|
163 | 4dbc422b | bellard | p[1] = tswap32(e2);
|
164 | 4dbc422b | bellard | p[2] = tswap32(addr >> 32); |
165 | 4dbc422b | bellard | p[3] = 0; |
166 | 6dbad63e | bellard | } |
167 | d2fd1af7 | bellard | /* only dpl matters as we do only user space emulation */
|
168 | d2fd1af7 | bellard | static void set_idt(int n, unsigned int dpl) |
169 | d2fd1af7 | bellard | { |
170 | d2fd1af7 | bellard | set_gate64(idt_table + n * 2, 0, dpl, 0, 0); |
171 | d2fd1af7 | bellard | } |
172 | d2fd1af7 | bellard | #else
|
173 | f4beb510 | bellard | uint64_t idt_table[256];
|
174 | f4beb510 | bellard | |
175 | d2fd1af7 | bellard | static void set_gate(void *ptr, unsigned int type, unsigned int dpl, |
176 | d2fd1af7 | bellard | uint32_t addr, unsigned int sel) |
177 | d2fd1af7 | bellard | { |
178 | 4dbc422b | bellard | uint32_t *p, e1, e2; |
179 | d2fd1af7 | bellard | e1 = (addr & 0xffff) | (sel << 16); |
180 | d2fd1af7 | bellard | e2 = (addr & 0xffff0000) | 0x8000 | (dpl << 13) | (type << 8); |
181 | d2fd1af7 | bellard | p = ptr; |
182 | 4dbc422b | bellard | p[0] = tswap32(e1);
|
183 | 4dbc422b | bellard | p[1] = tswap32(e2);
|
184 | d2fd1af7 | bellard | } |
185 | d2fd1af7 | bellard | |
186 | f4beb510 | bellard | /* only dpl matters as we do only user space emulation */
|
187 | f4beb510 | bellard | static void set_idt(int n, unsigned int dpl) |
188 | f4beb510 | bellard | { |
189 | f4beb510 | bellard | set_gate(idt_table + n, 0, dpl, 0, 0); |
190 | f4beb510 | bellard | } |
191 | d2fd1af7 | bellard | #endif
|
192 | 31e31b8a | bellard | |
193 | 89e957e7 | bellard | void cpu_loop(CPUX86State *env)
|
194 | 1b6b029e | bellard | { |
195 | bc8a22cc | bellard | int trapnr;
|
196 | 992f48a0 | blueswir1 | abi_ulong pc; |
197 | 9de5e440 | bellard | target_siginfo_t info; |
198 | 851e67a1 | bellard | |
199 | 1b6b029e | bellard | for(;;) {
|
200 | bc8a22cc | bellard | trapnr = cpu_x86_exec(env); |
201 | bc8a22cc | bellard | switch(trapnr) {
|
202 | f4beb510 | bellard | case 0x80: |
203 | d2fd1af7 | bellard | /* linux syscall from int $0x80 */
|
204 | 5fafdf24 | ths | env->regs[R_EAX] = do_syscall(env, |
205 | 5fafdf24 | ths | env->regs[R_EAX], |
206 | f4beb510 | bellard | env->regs[R_EBX], |
207 | f4beb510 | bellard | env->regs[R_ECX], |
208 | f4beb510 | bellard | env->regs[R_EDX], |
209 | f4beb510 | bellard | env->regs[R_ESI], |
210 | f4beb510 | bellard | env->regs[R_EDI], |
211 | f4beb510 | bellard | env->regs[R_EBP]); |
212 | f4beb510 | bellard | break;
|
213 | d2fd1af7 | bellard | #ifndef TARGET_ABI32
|
214 | d2fd1af7 | bellard | case EXCP_SYSCALL:
|
215 | d2fd1af7 | bellard | /* linux syscall from syscall intruction */
|
216 | d2fd1af7 | bellard | env->regs[R_EAX] = do_syscall(env, |
217 | d2fd1af7 | bellard | env->regs[R_EAX], |
218 | d2fd1af7 | bellard | env->regs[R_EDI], |
219 | d2fd1af7 | bellard | env->regs[R_ESI], |
220 | d2fd1af7 | bellard | env->regs[R_EDX], |
221 | d2fd1af7 | bellard | env->regs[10],
|
222 | d2fd1af7 | bellard | env->regs[8],
|
223 | d2fd1af7 | bellard | env->regs[9]);
|
224 | d2fd1af7 | bellard | env->eip = env->exception_next_eip; |
225 | d2fd1af7 | bellard | break;
|
226 | d2fd1af7 | bellard | #endif
|
227 | f4beb510 | bellard | case EXCP0B_NOSEG:
|
228 | f4beb510 | bellard | case EXCP0C_STACK:
|
229 | f4beb510 | bellard | info.si_signo = SIGBUS; |
230 | f4beb510 | bellard | info.si_errno = 0;
|
231 | f4beb510 | bellard | info.si_code = TARGET_SI_KERNEL; |
232 | f4beb510 | bellard | info._sifields._sigfault._addr = 0;
|
233 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
234 | f4beb510 | bellard | break;
|
235 | 1b6b029e | bellard | case EXCP0D_GPF:
|
236 | d2fd1af7 | bellard | /* XXX: potential problem if ABI32 */
|
237 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
238 | 851e67a1 | bellard | if (env->eflags & VM_MASK) {
|
239 | 89e957e7 | bellard | handle_vm86_fault(env); |
240 | 84409ddb | j_mayer | } else
|
241 | 84409ddb | j_mayer | #endif
|
242 | 84409ddb | j_mayer | { |
243 | f4beb510 | bellard | info.si_signo = SIGSEGV; |
244 | f4beb510 | bellard | info.si_errno = 0;
|
245 | f4beb510 | bellard | info.si_code = TARGET_SI_KERNEL; |
246 | f4beb510 | bellard | info._sifields._sigfault._addr = 0;
|
247 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
248 | 1b6b029e | bellard | } |
249 | 1b6b029e | bellard | break;
|
250 | b689bc57 | bellard | case EXCP0E_PAGE:
|
251 | b689bc57 | bellard | info.si_signo = SIGSEGV; |
252 | b689bc57 | bellard | info.si_errno = 0;
|
253 | b689bc57 | bellard | if (!(env->error_code & 1)) |
254 | b689bc57 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
255 | b689bc57 | bellard | else
|
256 | b689bc57 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
257 | 970a87a6 | bellard | info._sifields._sigfault._addr = env->cr[2];
|
258 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
259 | b689bc57 | bellard | break;
|
260 | 9de5e440 | bellard | case EXCP00_DIVZ:
|
261 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
262 | bc8a22cc | bellard | if (env->eflags & VM_MASK) {
|
263 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
264 | 84409ddb | j_mayer | } else
|
265 | 84409ddb | j_mayer | #endif
|
266 | 84409ddb | j_mayer | { |
267 | bc8a22cc | bellard | /* division by zero */
|
268 | bc8a22cc | bellard | info.si_signo = SIGFPE; |
269 | bc8a22cc | bellard | info.si_errno = 0;
|
270 | bc8a22cc | bellard | info.si_code = TARGET_FPE_INTDIV; |
271 | bc8a22cc | bellard | info._sifields._sigfault._addr = env->eip; |
272 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
273 | bc8a22cc | bellard | } |
274 | 9de5e440 | bellard | break;
|
275 | 447db213 | bellard | case EXCP01_SSTP:
|
276 | 447db213 | bellard | case EXCP03_INT3:
|
277 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
278 | 447db213 | bellard | if (env->eflags & VM_MASK) {
|
279 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
280 | 84409ddb | j_mayer | } else
|
281 | 84409ddb | j_mayer | #endif
|
282 | 84409ddb | j_mayer | { |
283 | 447db213 | bellard | info.si_signo = SIGTRAP; |
284 | 447db213 | bellard | info.si_errno = 0;
|
285 | 447db213 | bellard | if (trapnr == EXCP01_SSTP) {
|
286 | 447db213 | bellard | info.si_code = TARGET_TRAP_BRKPT; |
287 | 447db213 | bellard | info._sifields._sigfault._addr = env->eip; |
288 | 447db213 | bellard | } else {
|
289 | 447db213 | bellard | info.si_code = TARGET_SI_KERNEL; |
290 | 447db213 | bellard | info._sifields._sigfault._addr = 0;
|
291 | 447db213 | bellard | } |
292 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
293 | 447db213 | bellard | } |
294 | 447db213 | bellard | break;
|
295 | 9de5e440 | bellard | case EXCP04_INTO:
|
296 | 9de5e440 | bellard | case EXCP05_BOUND:
|
297 | 84409ddb | j_mayer | #ifndef TARGET_X86_64
|
298 | bc8a22cc | bellard | if (env->eflags & VM_MASK) {
|
299 | 447db213 | bellard | handle_vm86_trap(env, trapnr); |
300 | 84409ddb | j_mayer | } else
|
301 | 84409ddb | j_mayer | #endif
|
302 | 84409ddb | j_mayer | { |
303 | bc8a22cc | bellard | info.si_signo = SIGSEGV; |
304 | bc8a22cc | bellard | info.si_errno = 0;
|
305 | b689bc57 | bellard | info.si_code = TARGET_SI_KERNEL; |
306 | bc8a22cc | bellard | info._sifields._sigfault._addr = 0;
|
307 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
308 | bc8a22cc | bellard | } |
309 | 9de5e440 | bellard | break;
|
310 | 9de5e440 | bellard | case EXCP06_ILLOP:
|
311 | 9de5e440 | bellard | info.si_signo = SIGILL; |
312 | 9de5e440 | bellard | info.si_errno = 0;
|
313 | 9de5e440 | bellard | info.si_code = TARGET_ILL_ILLOPN; |
314 | 9de5e440 | bellard | info._sifields._sigfault._addr = env->eip; |
315 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
316 | 9de5e440 | bellard | break;
|
317 | 9de5e440 | bellard | case EXCP_INTERRUPT:
|
318 | 9de5e440 | bellard | /* just indicate that signals should be handled asap */
|
319 | 9de5e440 | bellard | break;
|
320 | 1fddef4b | bellard | case EXCP_DEBUG:
|
321 | 1fddef4b | bellard | { |
322 | 1fddef4b | bellard | int sig;
|
323 | 1fddef4b | bellard | |
324 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
325 | 1fddef4b | bellard | if (sig)
|
326 | 1fddef4b | bellard | { |
327 | 1fddef4b | bellard | info.si_signo = sig; |
328 | 1fddef4b | bellard | info.si_errno = 0;
|
329 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
330 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
331 | 1fddef4b | bellard | } |
332 | 1fddef4b | bellard | } |
333 | 1fddef4b | bellard | break;
|
334 | 1b6b029e | bellard | default:
|
335 | 970a87a6 | bellard | pc = env->segs[R_CS].base + env->eip; |
336 | 5fafdf24 | ths | fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
|
337 | bc8a22cc | bellard | (long)pc, trapnr);
|
338 | 1b6b029e | bellard | abort(); |
339 | 1b6b029e | bellard | } |
340 | 66fb9763 | bellard | process_pending_signals(env); |
341 | 1b6b029e | bellard | } |
342 | 1b6b029e | bellard | } |
343 | b346ff46 | bellard | #endif
|
344 | b346ff46 | bellard | |
345 | b346ff46 | bellard | #ifdef TARGET_ARM
|
346 | b346ff46 | bellard | |
347 | 6f1f31c0 | bellard | /* XXX: find a better solution */
|
348 | 992f48a0 | blueswir1 | extern void tb_invalidate_page_range(abi_ulong start, abi_ulong end); |
349 | 6f1f31c0 | bellard | |
350 | 992f48a0 | blueswir1 | static void arm_cache_flush(abi_ulong start, abi_ulong last) |
351 | 6f1f31c0 | bellard | { |
352 | 992f48a0 | blueswir1 | abi_ulong addr, last1; |
353 | 6f1f31c0 | bellard | |
354 | 6f1f31c0 | bellard | if (last < start)
|
355 | 6f1f31c0 | bellard | return;
|
356 | 6f1f31c0 | bellard | addr = start; |
357 | 6f1f31c0 | bellard | for(;;) {
|
358 | 6f1f31c0 | bellard | last1 = ((addr + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK) - 1;
|
359 | 6f1f31c0 | bellard | if (last1 > last)
|
360 | 6f1f31c0 | bellard | last1 = last; |
361 | 6f1f31c0 | bellard | tb_invalidate_page_range(addr, last1 + 1);
|
362 | 6f1f31c0 | bellard | if (last1 == last)
|
363 | 6f1f31c0 | bellard | break;
|
364 | 6f1f31c0 | bellard | addr = last1 + 1;
|
365 | 6f1f31c0 | bellard | } |
366 | 6f1f31c0 | bellard | } |
367 | 6f1f31c0 | bellard | |
368 | fbb4a2e3 | pbrook | /* Handle a jump to the kernel code page. */
|
369 | fbb4a2e3 | pbrook | static int |
370 | fbb4a2e3 | pbrook | do_kernel_trap(CPUARMState *env) |
371 | fbb4a2e3 | pbrook | { |
372 | fbb4a2e3 | pbrook | uint32_t addr; |
373 | fbb4a2e3 | pbrook | uint32_t cpsr; |
374 | fbb4a2e3 | pbrook | uint32_t val; |
375 | fbb4a2e3 | pbrook | |
376 | fbb4a2e3 | pbrook | switch (env->regs[15]) { |
377 | fbb4a2e3 | pbrook | case 0xffff0fa0: /* __kernel_memory_barrier */ |
378 | fbb4a2e3 | pbrook | /* ??? No-op. Will need to do better for SMP. */
|
379 | fbb4a2e3 | pbrook | break;
|
380 | fbb4a2e3 | pbrook | case 0xffff0fc0: /* __kernel_cmpxchg */ |
381 | fbb4a2e3 | pbrook | /* ??? This is not really atomic. However we don't support
|
382 | fbb4a2e3 | pbrook | threads anyway, so it doesn't realy matter. */
|
383 | fbb4a2e3 | pbrook | cpsr = cpsr_read(env); |
384 | fbb4a2e3 | pbrook | addr = env->regs[2];
|
385 | fbb4a2e3 | pbrook | /* FIXME: This should SEGV if the access fails. */
|
386 | fbb4a2e3 | pbrook | if (get_user_u32(val, addr))
|
387 | fbb4a2e3 | pbrook | val = ~env->regs[0];
|
388 | fbb4a2e3 | pbrook | if (val == env->regs[0]) { |
389 | fbb4a2e3 | pbrook | val = env->regs[1];
|
390 | fbb4a2e3 | pbrook | /* FIXME: Check for segfaults. */
|
391 | fbb4a2e3 | pbrook | put_user_u32(val, addr); |
392 | fbb4a2e3 | pbrook | env->regs[0] = 0; |
393 | fbb4a2e3 | pbrook | cpsr |= CPSR_C; |
394 | fbb4a2e3 | pbrook | } else {
|
395 | fbb4a2e3 | pbrook | env->regs[0] = -1; |
396 | fbb4a2e3 | pbrook | cpsr &= ~CPSR_C; |
397 | fbb4a2e3 | pbrook | } |
398 | fbb4a2e3 | pbrook | cpsr_write(env, cpsr, CPSR_C); |
399 | fbb4a2e3 | pbrook | break;
|
400 | fbb4a2e3 | pbrook | case 0xffff0fe0: /* __kernel_get_tls */ |
401 | fbb4a2e3 | pbrook | env->regs[0] = env->cp15.c13_tls2;
|
402 | fbb4a2e3 | pbrook | break;
|
403 | fbb4a2e3 | pbrook | default:
|
404 | fbb4a2e3 | pbrook | return 1; |
405 | fbb4a2e3 | pbrook | } |
406 | fbb4a2e3 | pbrook | /* Jump back to the caller. */
|
407 | fbb4a2e3 | pbrook | addr = env->regs[14];
|
408 | fbb4a2e3 | pbrook | if (addr & 1) { |
409 | fbb4a2e3 | pbrook | env->thumb = 1;
|
410 | fbb4a2e3 | pbrook | addr &= ~1;
|
411 | fbb4a2e3 | pbrook | } |
412 | fbb4a2e3 | pbrook | env->regs[15] = addr;
|
413 | fbb4a2e3 | pbrook | |
414 | fbb4a2e3 | pbrook | return 0; |
415 | fbb4a2e3 | pbrook | } |
416 | fbb4a2e3 | pbrook | |
417 | b346ff46 | bellard | void cpu_loop(CPUARMState *env)
|
418 | b346ff46 | bellard | { |
419 | b346ff46 | bellard | int trapnr;
|
420 | b346ff46 | bellard | unsigned int n, insn; |
421 | b346ff46 | bellard | target_siginfo_t info; |
422 | b5ff1b31 | bellard | uint32_t addr; |
423 | 3b46e624 | ths | |
424 | b346ff46 | bellard | for(;;) {
|
425 | b346ff46 | bellard | trapnr = cpu_arm_exec(env); |
426 | b346ff46 | bellard | switch(trapnr) {
|
427 | b346ff46 | bellard | case EXCP_UDEF:
|
428 | c6981055 | bellard | { |
429 | c6981055 | bellard | TaskState *ts = env->opaque; |
430 | c6981055 | bellard | uint32_t opcode; |
431 | 6d9a42be | aurel32 | int rc;
|
432 | c6981055 | bellard | |
433 | c6981055 | bellard | /* we handle the FPU emulation here, as Linux */
|
434 | c6981055 | bellard | /* we get the opcode */
|
435 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
436 | 2f619698 | bellard | get_user_u32(opcode, env->regs[15]);
|
437 | 3b46e624 | ths | |
438 | 6d9a42be | aurel32 | rc = EmulateAll(opcode, &ts->fpa, env); |
439 | 6d9a42be | aurel32 | if (rc == 0) { /* illegal instruction */ |
440 | c6981055 | bellard | info.si_signo = SIGILL; |
441 | c6981055 | bellard | info.si_errno = 0;
|
442 | c6981055 | bellard | info.si_code = TARGET_ILL_ILLOPN; |
443 | c6981055 | bellard | info._sifields._sigfault._addr = env->regs[15];
|
444 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
445 | 6d9a42be | aurel32 | } else if (rc < 0) { /* FP exception */ |
446 | 6d9a42be | aurel32 | int arm_fpe=0; |
447 | 6d9a42be | aurel32 | |
448 | 6d9a42be | aurel32 | /* translate softfloat flags to FPSR flags */
|
449 | 6d9a42be | aurel32 | if (-rc & float_flag_invalid)
|
450 | 6d9a42be | aurel32 | arm_fpe |= BIT_IOC; |
451 | 6d9a42be | aurel32 | if (-rc & float_flag_divbyzero)
|
452 | 6d9a42be | aurel32 | arm_fpe |= BIT_DZC; |
453 | 6d9a42be | aurel32 | if (-rc & float_flag_overflow)
|
454 | 6d9a42be | aurel32 | arm_fpe |= BIT_OFC; |
455 | 6d9a42be | aurel32 | if (-rc & float_flag_underflow)
|
456 | 6d9a42be | aurel32 | arm_fpe |= BIT_UFC; |
457 | 6d9a42be | aurel32 | if (-rc & float_flag_inexact)
|
458 | 6d9a42be | aurel32 | arm_fpe |= BIT_IXC; |
459 | 6d9a42be | aurel32 | |
460 | 6d9a42be | aurel32 | FPSR fpsr = ts->fpa.fpsr; |
461 | 6d9a42be | aurel32 | //printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe);
|
462 | 6d9a42be | aurel32 | |
463 | 6d9a42be | aurel32 | if (fpsr & (arm_fpe << 16)) { /* exception enabled? */ |
464 | 6d9a42be | aurel32 | info.si_signo = SIGFPE; |
465 | 6d9a42be | aurel32 | info.si_errno = 0;
|
466 | 6d9a42be | aurel32 | |
467 | 6d9a42be | aurel32 | /* ordered by priority, least first */
|
468 | 6d9a42be | aurel32 | if (arm_fpe & BIT_IXC) info.si_code = TARGET_FPE_FLTRES;
|
469 | 6d9a42be | aurel32 | if (arm_fpe & BIT_UFC) info.si_code = TARGET_FPE_FLTUND;
|
470 | 6d9a42be | aurel32 | if (arm_fpe & BIT_OFC) info.si_code = TARGET_FPE_FLTOVF;
|
471 | 6d9a42be | aurel32 | if (arm_fpe & BIT_DZC) info.si_code = TARGET_FPE_FLTDIV;
|
472 | 6d9a42be | aurel32 | if (arm_fpe & BIT_IOC) info.si_code = TARGET_FPE_FLTINV;
|
473 | 6d9a42be | aurel32 | |
474 | 6d9a42be | aurel32 | info._sifields._sigfault._addr = env->regs[15];
|
475 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
476 | 6d9a42be | aurel32 | } else {
|
477 | 6d9a42be | aurel32 | env->regs[15] += 4; |
478 | 6d9a42be | aurel32 | } |
479 | 6d9a42be | aurel32 | |
480 | 6d9a42be | aurel32 | /* accumulate unenabled exceptions */
|
481 | 6d9a42be | aurel32 | if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC))
|
482 | 6d9a42be | aurel32 | fpsr |= BIT_IXC; |
483 | 6d9a42be | aurel32 | if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC))
|
484 | 6d9a42be | aurel32 | fpsr |= BIT_UFC; |
485 | 6d9a42be | aurel32 | if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC))
|
486 | 6d9a42be | aurel32 | fpsr |= BIT_OFC; |
487 | 6d9a42be | aurel32 | if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC))
|
488 | 6d9a42be | aurel32 | fpsr |= BIT_DZC; |
489 | 6d9a42be | aurel32 | if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC))
|
490 | 6d9a42be | aurel32 | fpsr |= BIT_IOC; |
491 | 6d9a42be | aurel32 | ts->fpa.fpsr=fpsr; |
492 | 6d9a42be | aurel32 | } else { /* everything OK */ |
493 | c6981055 | bellard | /* increment PC */
|
494 | c6981055 | bellard | env->regs[15] += 4; |
495 | c6981055 | bellard | } |
496 | c6981055 | bellard | } |
497 | b346ff46 | bellard | break;
|
498 | b346ff46 | bellard | case EXCP_SWI:
|
499 | 06c949e6 | pbrook | case EXCP_BKPT:
|
500 | b346ff46 | bellard | { |
501 | ce4defa0 | pbrook | env->eabi = 1;
|
502 | b346ff46 | bellard | /* system call */
|
503 | 06c949e6 | pbrook | if (trapnr == EXCP_BKPT) {
|
504 | 06c949e6 | pbrook | if (env->thumb) {
|
505 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
506 | 2f619698 | bellard | get_user_u16(insn, env->regs[15]);
|
507 | 06c949e6 | pbrook | n = insn & 0xff;
|
508 | 06c949e6 | pbrook | env->regs[15] += 2; |
509 | 06c949e6 | pbrook | } else {
|
510 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
511 | 2f619698 | bellard | get_user_u32(insn, env->regs[15]);
|
512 | 06c949e6 | pbrook | n = (insn & 0xf) | ((insn >> 4) & 0xff0); |
513 | 06c949e6 | pbrook | env->regs[15] += 4; |
514 | 06c949e6 | pbrook | } |
515 | 192c7bd9 | bellard | } else {
|
516 | 06c949e6 | pbrook | if (env->thumb) {
|
517 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
518 | 2f619698 | bellard | get_user_u16(insn, env->regs[15] - 2); |
519 | 06c949e6 | pbrook | n = insn & 0xff;
|
520 | 06c949e6 | pbrook | } else {
|
521 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
522 | 2f619698 | bellard | get_user_u32(insn, env->regs[15] - 4); |
523 | 06c949e6 | pbrook | n = insn & 0xffffff;
|
524 | 06c949e6 | pbrook | } |
525 | 192c7bd9 | bellard | } |
526 | 192c7bd9 | bellard | |
527 | 6f1f31c0 | bellard | if (n == ARM_NR_cacheflush) {
|
528 | 6f1f31c0 | bellard | arm_cache_flush(env->regs[0], env->regs[1]); |
529 | a4f81979 | bellard | } else if (n == ARM_NR_semihosting |
530 | a4f81979 | bellard | || n == ARM_NR_thumb_semihosting) { |
531 | a4f81979 | bellard | env->regs[0] = do_arm_semihosting (env);
|
532 | ce4defa0 | pbrook | } else if (n == 0 || n >= ARM_SYSCALL_BASE |
533 | 192c7bd9 | bellard | || (env->thumb && n == ARM_THUMB_SYSCALL)) { |
534 | b346ff46 | bellard | /* linux syscall */
|
535 | ce4defa0 | pbrook | if (env->thumb || n == 0) { |
536 | 192c7bd9 | bellard | n = env->regs[7];
|
537 | 192c7bd9 | bellard | } else {
|
538 | 192c7bd9 | bellard | n -= ARM_SYSCALL_BASE; |
539 | ce4defa0 | pbrook | env->eabi = 0;
|
540 | 192c7bd9 | bellard | } |
541 | fbb4a2e3 | pbrook | if ( n > ARM_NR_BASE) {
|
542 | fbb4a2e3 | pbrook | switch (n) {
|
543 | fbb4a2e3 | pbrook | case ARM_NR_cacheflush:
|
544 | fbb4a2e3 | pbrook | arm_cache_flush(env->regs[0], env->regs[1]); |
545 | fbb4a2e3 | pbrook | break;
|
546 | fbb4a2e3 | pbrook | case ARM_NR_set_tls:
|
547 | fbb4a2e3 | pbrook | cpu_set_tls(env, env->regs[0]);
|
548 | fbb4a2e3 | pbrook | env->regs[0] = 0; |
549 | fbb4a2e3 | pbrook | break;
|
550 | fbb4a2e3 | pbrook | default:
|
551 | fbb4a2e3 | pbrook | gemu_log("qemu: Unsupported ARM syscall: 0x%x\n",
|
552 | fbb4a2e3 | pbrook | n); |
553 | fbb4a2e3 | pbrook | env->regs[0] = -TARGET_ENOSYS;
|
554 | fbb4a2e3 | pbrook | break;
|
555 | fbb4a2e3 | pbrook | } |
556 | fbb4a2e3 | pbrook | } else {
|
557 | fbb4a2e3 | pbrook | env->regs[0] = do_syscall(env,
|
558 | fbb4a2e3 | pbrook | n, |
559 | fbb4a2e3 | pbrook | env->regs[0],
|
560 | fbb4a2e3 | pbrook | env->regs[1],
|
561 | fbb4a2e3 | pbrook | env->regs[2],
|
562 | fbb4a2e3 | pbrook | env->regs[3],
|
563 | fbb4a2e3 | pbrook | env->regs[4],
|
564 | fbb4a2e3 | pbrook | env->regs[5]);
|
565 | fbb4a2e3 | pbrook | } |
566 | b346ff46 | bellard | } else {
|
567 | b346ff46 | bellard | goto error;
|
568 | b346ff46 | bellard | } |
569 | b346ff46 | bellard | } |
570 | b346ff46 | bellard | break;
|
571 | 43fff238 | bellard | case EXCP_INTERRUPT:
|
572 | 43fff238 | bellard | /* just indicate that signals should be handled asap */
|
573 | 43fff238 | bellard | break;
|
574 | 68016c62 | bellard | case EXCP_PREFETCH_ABORT:
|
575 | b5ff1b31 | bellard | addr = env->cp15.c6_data; |
576 | b5ff1b31 | bellard | goto do_segv;
|
577 | 68016c62 | bellard | case EXCP_DATA_ABORT:
|
578 | b5ff1b31 | bellard | addr = env->cp15.c6_insn; |
579 | b5ff1b31 | bellard | goto do_segv;
|
580 | b5ff1b31 | bellard | do_segv:
|
581 | 68016c62 | bellard | { |
582 | 68016c62 | bellard | info.si_signo = SIGSEGV; |
583 | 68016c62 | bellard | info.si_errno = 0;
|
584 | 68016c62 | bellard | /* XXX: check env->error_code */
|
585 | 68016c62 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
586 | b5ff1b31 | bellard | info._sifields._sigfault._addr = addr; |
587 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
588 | 68016c62 | bellard | } |
589 | 68016c62 | bellard | break;
|
590 | 1fddef4b | bellard | case EXCP_DEBUG:
|
591 | 1fddef4b | bellard | { |
592 | 1fddef4b | bellard | int sig;
|
593 | 1fddef4b | bellard | |
594 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
595 | 1fddef4b | bellard | if (sig)
|
596 | 1fddef4b | bellard | { |
597 | 1fddef4b | bellard | info.si_signo = sig; |
598 | 1fddef4b | bellard | info.si_errno = 0;
|
599 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
600 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
601 | 1fddef4b | bellard | } |
602 | 1fddef4b | bellard | } |
603 | 1fddef4b | bellard | break;
|
604 | fbb4a2e3 | pbrook | case EXCP_KERNEL_TRAP:
|
605 | fbb4a2e3 | pbrook | if (do_kernel_trap(env))
|
606 | fbb4a2e3 | pbrook | goto error;
|
607 | fbb4a2e3 | pbrook | break;
|
608 | b346ff46 | bellard | default:
|
609 | b346ff46 | bellard | error:
|
610 | 5fafdf24 | ths | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
611 | b346ff46 | bellard | trapnr); |
612 | 7fe48483 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
613 | b346ff46 | bellard | abort(); |
614 | b346ff46 | bellard | } |
615 | b346ff46 | bellard | process_pending_signals(env); |
616 | b346ff46 | bellard | } |
617 | b346ff46 | bellard | } |
618 | b346ff46 | bellard | |
619 | b346ff46 | bellard | #endif
|
620 | 1b6b029e | bellard | |
621 | 93ac68bc | bellard | #ifdef TARGET_SPARC
|
622 | 93ac68bc | bellard | |
623 | 060366c5 | bellard | //#define DEBUG_WIN
|
624 | 060366c5 | bellard | |
625 | 2623cbaf | bellard | /* WARNING: dealing with register windows _is_ complicated. More info
|
626 | 2623cbaf | bellard | can be found at http://www.sics.se/~psm/sparcstack.html */
|
627 | 060366c5 | bellard | static inline int get_reg_index(CPUSPARCState *env, int cwp, int index) |
628 | 060366c5 | bellard | { |
629 | 1a14026e | blueswir1 | index = (index + cwp * 16) % (16 * env->nwindows); |
630 | 060366c5 | bellard | /* wrap handling : if cwp is on the last window, then we use the
|
631 | 060366c5 | bellard | registers 'after' the end */
|
632 | 1a14026e | blueswir1 | if (index < 8 && env->cwp == env->nwindows - 1) |
633 | 1a14026e | blueswir1 | index += 16 * env->nwindows;
|
634 | 060366c5 | bellard | return index;
|
635 | 060366c5 | bellard | } |
636 | 060366c5 | bellard | |
637 | 2623cbaf | bellard | /* save the register window 'cwp1' */
|
638 | 2623cbaf | bellard | static inline void save_window_offset(CPUSPARCState *env, int cwp1) |
639 | 060366c5 | bellard | { |
640 | 2623cbaf | bellard | unsigned int i; |
641 | 992f48a0 | blueswir1 | abi_ulong sp_ptr; |
642 | 3b46e624 | ths | |
643 | 53a5960a | pbrook | sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
|
644 | 060366c5 | bellard | #if defined(DEBUG_WIN)
|
645 | 5fafdf24 | ths | printf("win_overflow: sp_ptr=0x%x save_cwp=%d\n",
|
646 | 060366c5 | bellard | (int)sp_ptr, cwp1);
|
647 | 060366c5 | bellard | #endif
|
648 | 2623cbaf | bellard | for(i = 0; i < 16; i++) { |
649 | 2f619698 | bellard | /* FIXME - what to do if put_user() fails? */
|
650 | 2f619698 | bellard | put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
|
651 | 992f48a0 | blueswir1 | sp_ptr += sizeof(abi_ulong);
|
652 | 2623cbaf | bellard | } |
653 | 060366c5 | bellard | } |
654 | 060366c5 | bellard | |
655 | 060366c5 | bellard | static void save_window(CPUSPARCState *env) |
656 | 060366c5 | bellard | { |
657 | 5ef54116 | bellard | #ifndef TARGET_SPARC64
|
658 | 2623cbaf | bellard | unsigned int new_wim; |
659 | 1a14026e | blueswir1 | new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) & |
660 | 1a14026e | blueswir1 | ((1LL << env->nwindows) - 1); |
661 | 1a14026e | blueswir1 | save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
|
662 | 2623cbaf | bellard | env->wim = new_wim; |
663 | 5ef54116 | bellard | #else
|
664 | 1a14026e | blueswir1 | save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
|
665 | 5ef54116 | bellard | env->cansave++; |
666 | 5ef54116 | bellard | env->canrestore--; |
667 | 5ef54116 | bellard | #endif
|
668 | 060366c5 | bellard | } |
669 | 060366c5 | bellard | |
670 | 060366c5 | bellard | static void restore_window(CPUSPARCState *env) |
671 | 060366c5 | bellard | { |
672 | 060366c5 | bellard | unsigned int new_wim, i, cwp1; |
673 | 992f48a0 | blueswir1 | abi_ulong sp_ptr; |
674 | 3b46e624 | ths | |
675 | 1a14026e | blueswir1 | new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) & |
676 | 1a14026e | blueswir1 | ((1LL << env->nwindows) - 1); |
677 | 3b46e624 | ths | |
678 | 060366c5 | bellard | /* restore the invalid window */
|
679 | 1a14026e | blueswir1 | cwp1 = cpu_cwp_inc(env, env->cwp + 1);
|
680 | 53a5960a | pbrook | sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)];
|
681 | 060366c5 | bellard | #if defined(DEBUG_WIN)
|
682 | 5fafdf24 | ths | printf("win_underflow: sp_ptr=0x%x load_cwp=%d\n",
|
683 | 060366c5 | bellard | (int)sp_ptr, cwp1);
|
684 | 060366c5 | bellard | #endif
|
685 | 2623cbaf | bellard | for(i = 0; i < 16; i++) { |
686 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
687 | 2f619698 | bellard | get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
|
688 | 992f48a0 | blueswir1 | sp_ptr += sizeof(abi_ulong);
|
689 | 2623cbaf | bellard | } |
690 | 060366c5 | bellard | env->wim = new_wim; |
691 | 5ef54116 | bellard | #ifdef TARGET_SPARC64
|
692 | 5ef54116 | bellard | env->canrestore++; |
693 | 1a14026e | blueswir1 | if (env->cleanwin < env->nwindows - 1) |
694 | 1a14026e | blueswir1 | env->cleanwin++; |
695 | 5ef54116 | bellard | env->cansave--; |
696 | 5ef54116 | bellard | #endif
|
697 | 060366c5 | bellard | } |
698 | 060366c5 | bellard | |
699 | 060366c5 | bellard | static void flush_windows(CPUSPARCState *env) |
700 | 060366c5 | bellard | { |
701 | 060366c5 | bellard | int offset, cwp1;
|
702 | 2623cbaf | bellard | |
703 | 2623cbaf | bellard | offset = 1;
|
704 | 060366c5 | bellard | for(;;) {
|
705 | 060366c5 | bellard | /* if restore would invoke restore_window(), then we can stop */
|
706 | 1a14026e | blueswir1 | cwp1 = cpu_cwp_inc(env, env->cwp + offset); |
707 | 060366c5 | bellard | if (env->wim & (1 << cwp1)) |
708 | 060366c5 | bellard | break;
|
709 | 2623cbaf | bellard | save_window_offset(env, cwp1); |
710 | 060366c5 | bellard | offset++; |
711 | 060366c5 | bellard | } |
712 | 2623cbaf | bellard | /* set wim so that restore will reload the registers */
|
713 | 1a14026e | blueswir1 | cwp1 = cpu_cwp_inc(env, env->cwp + 1);
|
714 | 2623cbaf | bellard | env->wim = 1 << cwp1;
|
715 | 2623cbaf | bellard | #if defined(DEBUG_WIN)
|
716 | 2623cbaf | bellard | printf("flush_windows: nb=%d\n", offset - 1); |
717 | 80a9d035 | bellard | #endif
|
718 | 2623cbaf | bellard | } |
719 | 060366c5 | bellard | |
720 | 93ac68bc | bellard | void cpu_loop (CPUSPARCState *env)
|
721 | 93ac68bc | bellard | { |
722 | 060366c5 | bellard | int trapnr, ret;
|
723 | 61ff6f58 | bellard | target_siginfo_t info; |
724 | 3b46e624 | ths | |
725 | 060366c5 | bellard | while (1) { |
726 | 060366c5 | bellard | trapnr = cpu_sparc_exec (env); |
727 | 3b46e624 | ths | |
728 | 060366c5 | bellard | switch (trapnr) {
|
729 | 5ef54116 | bellard | #ifndef TARGET_SPARC64
|
730 | 5fafdf24 | ths | case 0x88: |
731 | 060366c5 | bellard | case 0x90: |
732 | 5ef54116 | bellard | #else
|
733 | cb33da57 | blueswir1 | case 0x110: |
734 | 5ef54116 | bellard | case 0x16d: |
735 | 5ef54116 | bellard | #endif
|
736 | 060366c5 | bellard | ret = do_syscall (env, env->gregs[1],
|
737 | 5fafdf24 | ths | env->regwptr[0], env->regwptr[1], |
738 | 5fafdf24 | ths | env->regwptr[2], env->regwptr[3], |
739 | 060366c5 | bellard | env->regwptr[4], env->regwptr[5]); |
740 | 060366c5 | bellard | if ((unsigned int)ret >= (unsigned int)(-515)) { |
741 | 992f48a0 | blueswir1 | #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
|
742 | 27908725 | bellard | env->xcc |= PSR_CARRY; |
743 | 27908725 | bellard | #else
|
744 | 060366c5 | bellard | env->psr |= PSR_CARRY; |
745 | 27908725 | bellard | #endif
|
746 | 060366c5 | bellard | ret = -ret; |
747 | 060366c5 | bellard | } else {
|
748 | 992f48a0 | blueswir1 | #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
|
749 | 27908725 | bellard | env->xcc &= ~PSR_CARRY; |
750 | 27908725 | bellard | #else
|
751 | 060366c5 | bellard | env->psr &= ~PSR_CARRY; |
752 | 27908725 | bellard | #endif
|
753 | 060366c5 | bellard | } |
754 | 060366c5 | bellard | env->regwptr[0] = ret;
|
755 | 060366c5 | bellard | /* next instruction */
|
756 | 060366c5 | bellard | env->pc = env->npc; |
757 | 060366c5 | bellard | env->npc = env->npc + 4;
|
758 | 060366c5 | bellard | break;
|
759 | 060366c5 | bellard | case 0x83: /* flush windows */ |
760 | 992f48a0 | blueswir1 | #ifdef TARGET_ABI32
|
761 | 992f48a0 | blueswir1 | case 0x103: |
762 | 992f48a0 | blueswir1 | #endif
|
763 | 2623cbaf | bellard | flush_windows(env); |
764 | 060366c5 | bellard | /* next instruction */
|
765 | 060366c5 | bellard | env->pc = env->npc; |
766 | 060366c5 | bellard | env->npc = env->npc + 4;
|
767 | 060366c5 | bellard | break;
|
768 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
769 | 060366c5 | bellard | case TT_WIN_OVF: /* window overflow */ |
770 | 060366c5 | bellard | save_window(env); |
771 | 060366c5 | bellard | break;
|
772 | 060366c5 | bellard | case TT_WIN_UNF: /* window underflow */ |
773 | 060366c5 | bellard | restore_window(env); |
774 | 060366c5 | bellard | break;
|
775 | 61ff6f58 | bellard | case TT_TFAULT:
|
776 | 61ff6f58 | bellard | case TT_DFAULT:
|
777 | 61ff6f58 | bellard | { |
778 | 61ff6f58 | bellard | info.si_signo = SIGSEGV; |
779 | 61ff6f58 | bellard | info.si_errno = 0;
|
780 | 61ff6f58 | bellard | /* XXX: check env->error_code */
|
781 | 61ff6f58 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
782 | 61ff6f58 | bellard | info._sifields._sigfault._addr = env->mmuregs[4];
|
783 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
784 | 61ff6f58 | bellard | } |
785 | 61ff6f58 | bellard | break;
|
786 | 3475187d | bellard | #else
|
787 | 5ef54116 | bellard | case TT_SPILL: /* window overflow */ |
788 | 5ef54116 | bellard | save_window(env); |
789 | 5ef54116 | bellard | break;
|
790 | 5ef54116 | bellard | case TT_FILL: /* window underflow */ |
791 | 5ef54116 | bellard | restore_window(env); |
792 | 5ef54116 | bellard | break;
|
793 | 7f84a729 | blueswir1 | case TT_TFAULT:
|
794 | 7f84a729 | blueswir1 | case TT_DFAULT:
|
795 | 7f84a729 | blueswir1 | { |
796 | 7f84a729 | blueswir1 | info.si_signo = SIGSEGV; |
797 | 7f84a729 | blueswir1 | info.si_errno = 0;
|
798 | 7f84a729 | blueswir1 | /* XXX: check env->error_code */
|
799 | 7f84a729 | blueswir1 | info.si_code = TARGET_SEGV_MAPERR; |
800 | 7f84a729 | blueswir1 | if (trapnr == TT_DFAULT)
|
801 | 7f84a729 | blueswir1 | info._sifields._sigfault._addr = env->dmmuregs[4];
|
802 | 7f84a729 | blueswir1 | else
|
803 | 375ee38b | blueswir1 | info._sifields._sigfault._addr = env->tsptr->tpc; |
804 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
805 | 7f84a729 | blueswir1 | } |
806 | 7f84a729 | blueswir1 | break;
|
807 | 27524dc3 | bellard | #ifndef TARGET_ABI32
|
808 | 5bfb56b2 | blueswir1 | case 0x16e: |
809 | 5bfb56b2 | blueswir1 | flush_windows(env); |
810 | 5bfb56b2 | blueswir1 | sparc64_get_context(env); |
811 | 5bfb56b2 | blueswir1 | break;
|
812 | 5bfb56b2 | blueswir1 | case 0x16f: |
813 | 5bfb56b2 | blueswir1 | flush_windows(env); |
814 | 5bfb56b2 | blueswir1 | sparc64_set_context(env); |
815 | 5bfb56b2 | blueswir1 | break;
|
816 | 3475187d | bellard | #endif
|
817 | 27524dc3 | bellard | #endif
|
818 | 48dc41eb | bellard | case EXCP_INTERRUPT:
|
819 | 48dc41eb | bellard | /* just indicate that signals should be handled asap */
|
820 | 48dc41eb | bellard | break;
|
821 | 1fddef4b | bellard | case EXCP_DEBUG:
|
822 | 1fddef4b | bellard | { |
823 | 1fddef4b | bellard | int sig;
|
824 | 1fddef4b | bellard | |
825 | 1fddef4b | bellard | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
826 | 1fddef4b | bellard | if (sig)
|
827 | 1fddef4b | bellard | { |
828 | 1fddef4b | bellard | info.si_signo = sig; |
829 | 1fddef4b | bellard | info.si_errno = 0;
|
830 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
831 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
832 | 1fddef4b | bellard | } |
833 | 1fddef4b | bellard | } |
834 | 1fddef4b | bellard | break;
|
835 | 060366c5 | bellard | default:
|
836 | 060366c5 | bellard | printf ("Unhandled trap: 0x%x\n", trapnr);
|
837 | 7fe48483 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
838 | 060366c5 | bellard | exit (1);
|
839 | 060366c5 | bellard | } |
840 | 060366c5 | bellard | process_pending_signals (env); |
841 | 060366c5 | bellard | } |
842 | 93ac68bc | bellard | } |
843 | 93ac68bc | bellard | |
844 | 93ac68bc | bellard | #endif
|
845 | 93ac68bc | bellard | |
846 | 67867308 | bellard | #ifdef TARGET_PPC
|
847 | 9fddaa0c | bellard | static inline uint64_t cpu_ppc_get_tb (CPUState *env) |
848 | 9fddaa0c | bellard | { |
849 | 9fddaa0c | bellard | /* TO FIX */
|
850 | 9fddaa0c | bellard | return 0; |
851 | 9fddaa0c | bellard | } |
852 | 3b46e624 | ths | |
853 | 9fddaa0c | bellard | uint32_t cpu_ppc_load_tbl (CPUState *env) |
854 | 9fddaa0c | bellard | { |
855 | 9fddaa0c | bellard | return cpu_ppc_get_tb(env) & 0xFFFFFFFF; |
856 | 9fddaa0c | bellard | } |
857 | 3b46e624 | ths | |
858 | 9fddaa0c | bellard | uint32_t cpu_ppc_load_tbu (CPUState *env) |
859 | 9fddaa0c | bellard | { |
860 | 9fddaa0c | bellard | return cpu_ppc_get_tb(env) >> 32; |
861 | 9fddaa0c | bellard | } |
862 | 3b46e624 | ths | |
863 | a062e36c | j_mayer | uint32_t cpu_ppc_load_atbl (CPUState *env) |
864 | 9fddaa0c | bellard | { |
865 | a062e36c | j_mayer | return cpu_ppc_get_tb(env) & 0xFFFFFFFF; |
866 | 9fddaa0c | bellard | } |
867 | 5fafdf24 | ths | |
868 | a062e36c | j_mayer | uint32_t cpu_ppc_load_atbu (CPUState *env) |
869 | 9fddaa0c | bellard | { |
870 | a062e36c | j_mayer | return cpu_ppc_get_tb(env) >> 32; |
871 | 9fddaa0c | bellard | } |
872 | 76a66253 | j_mayer | |
873 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcu (CPUState *env) |
874 | 76a66253 | j_mayer | __attribute__ (( alias ("cpu_ppc_load_tbu") ));
|
875 | 76a66253 | j_mayer | |
876 | 76a66253 | j_mayer | uint32_t cpu_ppc601_load_rtcl (CPUState *env) |
877 | 9fddaa0c | bellard | { |
878 | 76a66253 | j_mayer | return cpu_ppc_load_tbl(env) & 0x3FFFFF80; |
879 | 9fddaa0c | bellard | } |
880 | 76a66253 | j_mayer | |
881 | a750fc0b | j_mayer | /* XXX: to be fixed */
|
882 | a750fc0b | j_mayer | int ppc_dcr_read (ppc_dcr_t *dcr_env, int dcrn, target_ulong *valp) |
883 | a750fc0b | j_mayer | { |
884 | a750fc0b | j_mayer | return -1; |
885 | a750fc0b | j_mayer | } |
886 | a750fc0b | j_mayer | |
887 | a750fc0b | j_mayer | int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val) |
888 | a750fc0b | j_mayer | { |
889 | a750fc0b | j_mayer | return -1; |
890 | a750fc0b | j_mayer | } |
891 | a750fc0b | j_mayer | |
892 | e1833e1f | j_mayer | #define EXCP_DUMP(env, fmt, args...) \
|
893 | e1833e1f | j_mayer | do { \
|
894 | e1833e1f | j_mayer | fprintf(stderr, fmt , ##args); \ |
895 | e1833e1f | j_mayer | cpu_dump_state(env, stderr, fprintf, 0); \
|
896 | e1833e1f | j_mayer | if (loglevel != 0) { \ |
897 | e1833e1f | j_mayer | fprintf(logfile, fmt , ##args); \ |
898 | e1833e1f | j_mayer | cpu_dump_state(env, logfile, fprintf, 0); \
|
899 | e1833e1f | j_mayer | } \ |
900 | e1833e1f | j_mayer | } while (0) |
901 | e1833e1f | j_mayer | |
902 | 67867308 | bellard | void cpu_loop(CPUPPCState *env)
|
903 | 67867308 | bellard | { |
904 | 67867308 | bellard | target_siginfo_t info; |
905 | 61190b14 | bellard | int trapnr;
|
906 | 61190b14 | bellard | uint32_t ret; |
907 | 3b46e624 | ths | |
908 | 67867308 | bellard | for(;;) {
|
909 | 67867308 | bellard | trapnr = cpu_ppc_exec(env); |
910 | 67867308 | bellard | switch(trapnr) {
|
911 | e1833e1f | j_mayer | case POWERPC_EXCP_NONE:
|
912 | e1833e1f | j_mayer | /* Just go on */
|
913 | 67867308 | bellard | break;
|
914 | e1833e1f | j_mayer | case POWERPC_EXCP_CRITICAL: /* Critical input */ |
915 | e1833e1f | j_mayer | cpu_abort(env, "Critical interrupt while in user mode. "
|
916 | e1833e1f | j_mayer | "Aborting\n");
|
917 | 61190b14 | bellard | break;
|
918 | e1833e1f | j_mayer | case POWERPC_EXCP_MCHECK: /* Machine check exception */ |
919 | e1833e1f | j_mayer | cpu_abort(env, "Machine check exception while in user mode. "
|
920 | e1833e1f | j_mayer | "Aborting\n");
|
921 | e1833e1f | j_mayer | break;
|
922 | e1833e1f | j_mayer | case POWERPC_EXCP_DSI: /* Data storage exception */ |
923 | e1833e1f | j_mayer | EXCP_DUMP(env, "Invalid data memory access: 0x" ADDRX "\n", |
924 | e1833e1f | j_mayer | env->spr[SPR_DAR]); |
925 | e1833e1f | j_mayer | /* XXX: check this. Seems bugged */
|
926 | 2be0071f | bellard | switch (env->error_code & 0xFF000000) { |
927 | 2be0071f | bellard | case 0x40000000: |
928 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
929 | 61190b14 | bellard | info.si_errno = 0;
|
930 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
931 | 61190b14 | bellard | break;
|
932 | 2be0071f | bellard | case 0x04000000: |
933 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
934 | 61190b14 | bellard | info.si_errno = 0;
|
935 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLADR; |
936 | 61190b14 | bellard | break;
|
937 | 2be0071f | bellard | case 0x08000000: |
938 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
939 | 61190b14 | bellard | info.si_errno = 0;
|
940 | 61190b14 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
941 | 61190b14 | bellard | break;
|
942 | 61190b14 | bellard | default:
|
943 | 61190b14 | bellard | /* Let's send a regular segfault... */
|
944 | e1833e1f | j_mayer | EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
|
945 | e1833e1f | j_mayer | env->error_code); |
946 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
947 | 61190b14 | bellard | info.si_errno = 0;
|
948 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
949 | 61190b14 | bellard | break;
|
950 | 61190b14 | bellard | } |
951 | 67867308 | bellard | info._sifields._sigfault._addr = env->nip; |
952 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
953 | 67867308 | bellard | break;
|
954 | e1833e1f | j_mayer | case POWERPC_EXCP_ISI: /* Instruction storage exception */ |
955 | e1833e1f | j_mayer | EXCP_DUMP(env, "Invalid instruction fetch: 0x\n" ADDRX "\n", |
956 | f10c315f | j_mayer | env->spr[SPR_SRR0]); |
957 | e1833e1f | j_mayer | /* XXX: check this */
|
958 | 2be0071f | bellard | switch (env->error_code & 0xFF000000) { |
959 | 2be0071f | bellard | case 0x40000000: |
960 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
961 | 67867308 | bellard | info.si_errno = 0;
|
962 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
963 | 61190b14 | bellard | break;
|
964 | 2be0071f | bellard | case 0x10000000: |
965 | 2be0071f | bellard | case 0x08000000: |
966 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
967 | 61190b14 | bellard | info.si_errno = 0;
|
968 | 61190b14 | bellard | info.si_code = TARGET_SEGV_ACCERR; |
969 | 61190b14 | bellard | break;
|
970 | 61190b14 | bellard | default:
|
971 | 61190b14 | bellard | /* Let's send a regular segfault... */
|
972 | e1833e1f | j_mayer | EXCP_DUMP(env, "Invalid segfault errno (%02x)\n",
|
973 | e1833e1f | j_mayer | env->error_code); |
974 | 61190b14 | bellard | info.si_signo = TARGET_SIGSEGV; |
975 | 61190b14 | bellard | info.si_errno = 0;
|
976 | 61190b14 | bellard | info.si_code = TARGET_SEGV_MAPERR; |
977 | 61190b14 | bellard | break;
|
978 | 61190b14 | bellard | } |
979 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
980 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
981 | 67867308 | bellard | break;
|
982 | e1833e1f | j_mayer | case POWERPC_EXCP_EXTERNAL: /* External input */ |
983 | e1833e1f | j_mayer | cpu_abort(env, "External interrupt while in user mode. "
|
984 | e1833e1f | j_mayer | "Aborting\n");
|
985 | e1833e1f | j_mayer | break;
|
986 | e1833e1f | j_mayer | case POWERPC_EXCP_ALIGN: /* Alignment exception */ |
987 | e1833e1f | j_mayer | EXCP_DUMP(env, "Unaligned memory access\n");
|
988 | e1833e1f | j_mayer | /* XXX: check this */
|
989 | 61190b14 | bellard | info.si_signo = TARGET_SIGBUS; |
990 | 67867308 | bellard | info.si_errno = 0;
|
991 | 61190b14 | bellard | info.si_code = TARGET_BUS_ADRALN; |
992 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
993 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
994 | 67867308 | bellard | break;
|
995 | e1833e1f | j_mayer | case POWERPC_EXCP_PROGRAM: /* Program exception */ |
996 | e1833e1f | j_mayer | /* XXX: check this */
|
997 | 61190b14 | bellard | switch (env->error_code & ~0xF) { |
998 | e1833e1f | j_mayer | case POWERPC_EXCP_FP:
|
999 | e1833e1f | j_mayer | EXCP_DUMP(env, "Floating point program exception\n");
|
1000 | 61190b14 | bellard | info.si_signo = TARGET_SIGFPE; |
1001 | 61190b14 | bellard | info.si_errno = 0;
|
1002 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
1003 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_OX:
|
1004 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTOVF; |
1005 | 61190b14 | bellard | break;
|
1006 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_UX:
|
1007 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTUND; |
1008 | 61190b14 | bellard | break;
|
1009 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_ZX:
|
1010 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXZDZ:
|
1011 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTDIV; |
1012 | 61190b14 | bellard | break;
|
1013 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_XX:
|
1014 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTRES; |
1015 | 61190b14 | bellard | break;
|
1016 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXSOFT:
|
1017 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTINV; |
1018 | 61190b14 | bellard | break;
|
1019 | 7c58044c | j_mayer | case POWERPC_EXCP_FP_VXSNAN:
|
1020 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXISI:
|
1021 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXIDI:
|
1022 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXIMZ:
|
1023 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXVC:
|
1024 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXSQRT:
|
1025 | e1833e1f | j_mayer | case POWERPC_EXCP_FP_VXCVI:
|
1026 | 61190b14 | bellard | info.si_code = TARGET_FPE_FLTSUB; |
1027 | 61190b14 | bellard | break;
|
1028 | 61190b14 | bellard | default:
|
1029 | e1833e1f | j_mayer | EXCP_DUMP(env, "Unknown floating point exception (%02x)\n",
|
1030 | e1833e1f | j_mayer | env->error_code); |
1031 | e1833e1f | j_mayer | break;
|
1032 | 61190b14 | bellard | } |
1033 | e1833e1f | j_mayer | break;
|
1034 | e1833e1f | j_mayer | case POWERPC_EXCP_INVAL:
|
1035 | e1833e1f | j_mayer | EXCP_DUMP(env, "Invalid instruction\n");
|
1036 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
1037 | 61190b14 | bellard | info.si_errno = 0;
|
1038 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
1039 | e1833e1f | j_mayer | case POWERPC_EXCP_INVAL_INVAL:
|
1040 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLOPC; |
1041 | 61190b14 | bellard | break;
|
1042 | e1833e1f | j_mayer | case POWERPC_EXCP_INVAL_LSWX:
|
1043 | a750fc0b | j_mayer | info.si_code = TARGET_ILL_ILLOPN; |
1044 | 61190b14 | bellard | break;
|
1045 | e1833e1f | j_mayer | case POWERPC_EXCP_INVAL_SPR:
|
1046 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVREG; |
1047 | 61190b14 | bellard | break;
|
1048 | e1833e1f | j_mayer | case POWERPC_EXCP_INVAL_FP:
|
1049 | 61190b14 | bellard | info.si_code = TARGET_ILL_COPROC; |
1050 | 61190b14 | bellard | break;
|
1051 | 61190b14 | bellard | default:
|
1052 | e1833e1f | j_mayer | EXCP_DUMP(env, "Unknown invalid operation (%02x)\n",
|
1053 | e1833e1f | j_mayer | env->error_code & 0xF);
|
1054 | 61190b14 | bellard | info.si_code = TARGET_ILL_ILLADR; |
1055 | 61190b14 | bellard | break;
|
1056 | 61190b14 | bellard | } |
1057 | 61190b14 | bellard | break;
|
1058 | e1833e1f | j_mayer | case POWERPC_EXCP_PRIV:
|
1059 | e1833e1f | j_mayer | EXCP_DUMP(env, "Privilege violation\n");
|
1060 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
1061 | 61190b14 | bellard | info.si_errno = 0;
|
1062 | 61190b14 | bellard | switch (env->error_code & 0xF) { |
1063 | e1833e1f | j_mayer | case POWERPC_EXCP_PRIV_OPC:
|
1064 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVOPC; |
1065 | 61190b14 | bellard | break;
|
1066 | e1833e1f | j_mayer | case POWERPC_EXCP_PRIV_REG:
|
1067 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVREG; |
1068 | e1833e1f | j_mayer | break;
|
1069 | 61190b14 | bellard | default:
|
1070 | e1833e1f | j_mayer | EXCP_DUMP(env, "Unknown privilege violation (%02x)\n",
|
1071 | e1833e1f | j_mayer | env->error_code & 0xF);
|
1072 | 61190b14 | bellard | info.si_code = TARGET_ILL_PRVOPC; |
1073 | 61190b14 | bellard | break;
|
1074 | 61190b14 | bellard | } |
1075 | 61190b14 | bellard | break;
|
1076 | e1833e1f | j_mayer | case POWERPC_EXCP_TRAP:
|
1077 | e1833e1f | j_mayer | cpu_abort(env, "Tried to call a TRAP\n");
|
1078 | e1833e1f | j_mayer | break;
|
1079 | 61190b14 | bellard | default:
|
1080 | 61190b14 | bellard | /* Should not happen ! */
|
1081 | e1833e1f | j_mayer | cpu_abort(env, "Unknown program exception (%02x)\n",
|
1082 | e1833e1f | j_mayer | env->error_code); |
1083 | e1833e1f | j_mayer | break;
|
1084 | 61190b14 | bellard | } |
1085 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
1086 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1087 | 67867308 | bellard | break;
|
1088 | e1833e1f | j_mayer | case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */ |
1089 | e1833e1f | j_mayer | EXCP_DUMP(env, "No floating point allowed\n");
|
1090 | 61190b14 | bellard | info.si_signo = TARGET_SIGILL; |
1091 | 67867308 | bellard | info.si_errno = 0;
|
1092 | 61190b14 | bellard | info.si_code = TARGET_ILL_COPROC; |
1093 | 61190b14 | bellard | info._sifields._sigfault._addr = env->nip - 4;
|
1094 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1095 | 67867308 | bellard | break;
|
1096 | e1833e1f | j_mayer | case POWERPC_EXCP_SYSCALL: /* System call exception */ |
1097 | e1833e1f | j_mayer | cpu_abort(env, "Syscall exception while in user mode. "
|
1098 | e1833e1f | j_mayer | "Aborting\n");
|
1099 | 61190b14 | bellard | break;
|
1100 | e1833e1f | j_mayer | case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */ |
1101 | e1833e1f | j_mayer | EXCP_DUMP(env, "No APU instruction allowed\n");
|
1102 | e1833e1f | j_mayer | info.si_signo = TARGET_SIGILL; |
1103 | e1833e1f | j_mayer | info.si_errno = 0;
|
1104 | e1833e1f | j_mayer | info.si_code = TARGET_ILL_COPROC; |
1105 | e1833e1f | j_mayer | info._sifields._sigfault._addr = env->nip - 4;
|
1106 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1107 | 61190b14 | bellard | break;
|
1108 | e1833e1f | j_mayer | case POWERPC_EXCP_DECR: /* Decrementer exception */ |
1109 | e1833e1f | j_mayer | cpu_abort(env, "Decrementer interrupt while in user mode. "
|
1110 | e1833e1f | j_mayer | "Aborting\n");
|
1111 | 61190b14 | bellard | break;
|
1112 | e1833e1f | j_mayer | case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt */ |
1113 | e1833e1f | j_mayer | cpu_abort(env, "Fix interval timer interrupt while in user mode. "
|
1114 | e1833e1f | j_mayer | "Aborting\n");
|
1115 | e1833e1f | j_mayer | break;
|
1116 | e1833e1f | j_mayer | case POWERPC_EXCP_WDT: /* Watchdog timer interrupt */ |
1117 | e1833e1f | j_mayer | cpu_abort(env, "Watchdog timer interrupt while in user mode. "
|
1118 | e1833e1f | j_mayer | "Aborting\n");
|
1119 | e1833e1f | j_mayer | break;
|
1120 | e1833e1f | j_mayer | case POWERPC_EXCP_DTLB: /* Data TLB error */ |
1121 | e1833e1f | j_mayer | cpu_abort(env, "Data TLB exception while in user mode. "
|
1122 | e1833e1f | j_mayer | "Aborting\n");
|
1123 | e1833e1f | j_mayer | break;
|
1124 | e1833e1f | j_mayer | case POWERPC_EXCP_ITLB: /* Instruction TLB error */ |
1125 | e1833e1f | j_mayer | cpu_abort(env, "Instruction TLB exception while in user mode. "
|
1126 | e1833e1f | j_mayer | "Aborting\n");
|
1127 | e1833e1f | j_mayer | break;
|
1128 | e1833e1f | j_mayer | case POWERPC_EXCP_DEBUG: /* Debug interrupt */ |
1129 | e1833e1f | j_mayer | /* XXX: check this */
|
1130 | 1fddef4b | bellard | { |
1131 | 1fddef4b | bellard | int sig;
|
1132 | 1fddef4b | bellard | |
1133 | e1833e1f | j_mayer | sig = gdb_handlesig(env, TARGET_SIGTRAP); |
1134 | e1833e1f | j_mayer | if (sig) {
|
1135 | 1fddef4b | bellard | info.si_signo = sig; |
1136 | 1fddef4b | bellard | info.si_errno = 0;
|
1137 | 1fddef4b | bellard | info.si_code = TARGET_TRAP_BRKPT; |
1138 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1139 | 1fddef4b | bellard | } |
1140 | 1fddef4b | bellard | } |
1141 | 1fddef4b | bellard | break;
|
1142 | e1833e1f | j_mayer | case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavail. */ |
1143 | e1833e1f | j_mayer | EXCP_DUMP(env, "No SPE/floating-point instruction allowed\n");
|
1144 | e1833e1f | j_mayer | info.si_signo = TARGET_SIGILL; |
1145 | e1833e1f | j_mayer | info.si_errno = 0;
|
1146 | e1833e1f | j_mayer | info.si_code = TARGET_ILL_COPROC; |
1147 | e1833e1f | j_mayer | info._sifields._sigfault._addr = env->nip - 4;
|
1148 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1149 | e1833e1f | j_mayer | break;
|
1150 | e1833e1f | j_mayer | case POWERPC_EXCP_EFPDI: /* Embedded floating-point data IRQ */ |
1151 | e1833e1f | j_mayer | cpu_abort(env, "Embedded floating-point data IRQ not handled\n");
|
1152 | e1833e1f | j_mayer | break;
|
1153 | e1833e1f | j_mayer | case POWERPC_EXCP_EFPRI: /* Embedded floating-point round IRQ */ |
1154 | e1833e1f | j_mayer | cpu_abort(env, "Embedded floating-point round IRQ not handled\n");
|
1155 | e1833e1f | j_mayer | break;
|
1156 | e1833e1f | j_mayer | case POWERPC_EXCP_EPERFM: /* Embedded performance monitor IRQ */ |
1157 | e1833e1f | j_mayer | cpu_abort(env, "Performance monitor exception not handled\n");
|
1158 | e1833e1f | j_mayer | break;
|
1159 | e1833e1f | j_mayer | case POWERPC_EXCP_DOORI: /* Embedded doorbell interrupt */ |
1160 | e1833e1f | j_mayer | cpu_abort(env, "Doorbell interrupt while in user mode. "
|
1161 | e1833e1f | j_mayer | "Aborting\n");
|
1162 | e1833e1f | j_mayer | break;
|
1163 | e1833e1f | j_mayer | case POWERPC_EXCP_DOORCI: /* Embedded doorbell critical interrupt */ |
1164 | e1833e1f | j_mayer | cpu_abort(env, "Doorbell critical interrupt while in user mode. "
|
1165 | e1833e1f | j_mayer | "Aborting\n");
|
1166 | e1833e1f | j_mayer | break;
|
1167 | e1833e1f | j_mayer | case POWERPC_EXCP_RESET: /* System reset exception */ |
1168 | e1833e1f | j_mayer | cpu_abort(env, "Reset interrupt while in user mode. "
|
1169 | e1833e1f | j_mayer | "Aborting\n");
|
1170 | e1833e1f | j_mayer | break;
|
1171 | e1833e1f | j_mayer | case POWERPC_EXCP_DSEG: /* Data segment exception */ |
1172 | e1833e1f | j_mayer | cpu_abort(env, "Data segment exception while in user mode. "
|
1173 | e1833e1f | j_mayer | "Aborting\n");
|
1174 | e1833e1f | j_mayer | break;
|
1175 | e1833e1f | j_mayer | case POWERPC_EXCP_ISEG: /* Instruction segment exception */ |
1176 | e1833e1f | j_mayer | cpu_abort(env, "Instruction segment exception "
|
1177 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1178 | e1833e1f | j_mayer | break;
|
1179 | e85e7c6e | j_mayer | /* PowerPC 64 with hypervisor mode support */
|
1180 | e1833e1f | j_mayer | case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */ |
1181 | e1833e1f | j_mayer | cpu_abort(env, "Hypervisor decrementer interrupt "
|
1182 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1183 | e1833e1f | j_mayer | break;
|
1184 | e1833e1f | j_mayer | case POWERPC_EXCP_TRACE: /* Trace exception */ |
1185 | e1833e1f | j_mayer | /* Nothing to do:
|
1186 | e1833e1f | j_mayer | * we use this exception to emulate step-by-step execution mode.
|
1187 | e1833e1f | j_mayer | */
|
1188 | e1833e1f | j_mayer | break;
|
1189 | e85e7c6e | j_mayer | /* PowerPC 64 with hypervisor mode support */
|
1190 | e1833e1f | j_mayer | case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */ |
1191 | e1833e1f | j_mayer | cpu_abort(env, "Hypervisor data storage exception "
|
1192 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1193 | e1833e1f | j_mayer | break;
|
1194 | e1833e1f | j_mayer | case POWERPC_EXCP_HISI: /* Hypervisor instruction storage excp */ |
1195 | e1833e1f | j_mayer | cpu_abort(env, "Hypervisor instruction storage exception "
|
1196 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1197 | e1833e1f | j_mayer | break;
|
1198 | e1833e1f | j_mayer | case POWERPC_EXCP_HDSEG: /* Hypervisor data segment exception */ |
1199 | e1833e1f | j_mayer | cpu_abort(env, "Hypervisor data segment exception "
|
1200 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1201 | e1833e1f | j_mayer | break;
|
1202 | e1833e1f | j_mayer | case POWERPC_EXCP_HISEG: /* Hypervisor instruction segment excp */ |
1203 | e1833e1f | j_mayer | cpu_abort(env, "Hypervisor instruction segment exception "
|
1204 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1205 | e1833e1f | j_mayer | break;
|
1206 | e1833e1f | j_mayer | case POWERPC_EXCP_VPU: /* Vector unavailable exception */ |
1207 | e1833e1f | j_mayer | EXCP_DUMP(env, "No Altivec instructions allowed\n");
|
1208 | e1833e1f | j_mayer | info.si_signo = TARGET_SIGILL; |
1209 | e1833e1f | j_mayer | info.si_errno = 0;
|
1210 | e1833e1f | j_mayer | info.si_code = TARGET_ILL_COPROC; |
1211 | e1833e1f | j_mayer | info._sifields._sigfault._addr = env->nip - 4;
|
1212 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1213 | e1833e1f | j_mayer | break;
|
1214 | e1833e1f | j_mayer | case POWERPC_EXCP_PIT: /* Programmable interval timer IRQ */ |
1215 | e1833e1f | j_mayer | cpu_abort(env, "Programable interval timer interrupt "
|
1216 | e1833e1f | j_mayer | "while in user mode. Aborting\n");
|
1217 | e1833e1f | j_mayer | break;
|
1218 | e1833e1f | j_mayer | case POWERPC_EXCP_IO: /* IO error exception */ |
1219 | e1833e1f | j_mayer | cpu_abort(env, "IO error exception while in user mode. "
|
1220 | e1833e1f | j_mayer | "Aborting\n");
|
1221 | e1833e1f | j_mayer | break;
|
1222 | e1833e1f | j_mayer | case POWERPC_EXCP_RUNM: /* Run mode exception */ |
1223 | e1833e1f | j_mayer | cpu_abort(env, "Run mode exception while in user mode. "
|
1224 | e1833e1f | j_mayer | "Aborting\n");
|
1225 | e1833e1f | j_mayer | break;
|
1226 | e1833e1f | j_mayer | case POWERPC_EXCP_EMUL: /* Emulation trap exception */ |
1227 | e1833e1f | j_mayer | cpu_abort(env, "Emulation trap exception not handled\n");
|
1228 | e1833e1f | j_mayer | break;
|
1229 | e1833e1f | j_mayer | case POWERPC_EXCP_IFTLB: /* Instruction fetch TLB error */ |
1230 | e1833e1f | j_mayer | cpu_abort(env, "Instruction fetch TLB exception "
|
1231 | e1833e1f | j_mayer | "while in user-mode. Aborting");
|
1232 | e1833e1f | j_mayer | break;
|
1233 | e1833e1f | j_mayer | case POWERPC_EXCP_DLTLB: /* Data load TLB miss */ |
1234 | e1833e1f | j_mayer | cpu_abort(env, "Data load TLB exception while in user-mode. "
|
1235 | e1833e1f | j_mayer | "Aborting");
|
1236 | e1833e1f | j_mayer | break;
|
1237 | e1833e1f | j_mayer | case POWERPC_EXCP_DSTLB: /* Data store TLB miss */ |
1238 | e1833e1f | j_mayer | cpu_abort(env, "Data store TLB exception while in user-mode. "
|
1239 | e1833e1f | j_mayer | "Aborting");
|
1240 | e1833e1f | j_mayer | break;
|
1241 | e1833e1f | j_mayer | case POWERPC_EXCP_FPA: /* Floating-point assist exception */ |
1242 | e1833e1f | j_mayer | cpu_abort(env, "Floating-point assist exception not handled\n");
|
1243 | e1833e1f | j_mayer | break;
|
1244 | e1833e1f | j_mayer | case POWERPC_EXCP_IABR: /* Instruction address breakpoint */ |
1245 | e1833e1f | j_mayer | cpu_abort(env, "Instruction address breakpoint exception "
|
1246 | e1833e1f | j_mayer | "not handled\n");
|
1247 | e1833e1f | j_mayer | break;
|
1248 | e1833e1f | j_mayer | case POWERPC_EXCP_SMI: /* System management interrupt */ |
1249 | e1833e1f | j_mayer | cpu_abort(env, "System management interrupt while in user mode. "
|
1250 | e1833e1f | j_mayer | "Aborting\n");
|
1251 | e1833e1f | j_mayer | break;
|
1252 | e1833e1f | j_mayer | case POWERPC_EXCP_THERM: /* Thermal interrupt */ |
1253 | e1833e1f | j_mayer | cpu_abort(env, "Thermal interrupt interrupt while in user mode. "
|
1254 | e1833e1f | j_mayer | "Aborting\n");
|
1255 | e1833e1f | j_mayer | break;
|
1256 | e1833e1f | j_mayer | case POWERPC_EXCP_PERFM: /* Embedded performance monitor IRQ */ |
1257 | e1833e1f | j_mayer | cpu_abort(env, "Performance monitor exception not handled\n");
|
1258 | e1833e1f | j_mayer | break;
|
1259 | e1833e1f | j_mayer | case POWERPC_EXCP_VPUA: /* Vector assist exception */ |
1260 | e1833e1f | j_mayer | cpu_abort(env, "Vector assist exception not handled\n");
|
1261 | e1833e1f | j_mayer | break;
|
1262 | e1833e1f | j_mayer | case POWERPC_EXCP_SOFTP: /* Soft patch exception */ |
1263 | e1833e1f | j_mayer | cpu_abort(env, "Soft patch exception not handled\n");
|
1264 | e1833e1f | j_mayer | break;
|
1265 | e1833e1f | j_mayer | case POWERPC_EXCP_MAINT: /* Maintenance exception */ |
1266 | e1833e1f | j_mayer | cpu_abort(env, "Maintenance exception while in user mode. "
|
1267 | e1833e1f | j_mayer | "Aborting\n");
|
1268 | e1833e1f | j_mayer | break;
|
1269 | e1833e1f | j_mayer | case POWERPC_EXCP_STOP: /* stop translation */ |
1270 | e1833e1f | j_mayer | /* We did invalidate the instruction cache. Go on */
|
1271 | e1833e1f | j_mayer | break;
|
1272 | e1833e1f | j_mayer | case POWERPC_EXCP_BRANCH: /* branch instruction: */ |
1273 | e1833e1f | j_mayer | /* We just stopped because of a branch. Go on */
|
1274 | e1833e1f | j_mayer | break;
|
1275 | e1833e1f | j_mayer | case POWERPC_EXCP_SYSCALL_USER:
|
1276 | e1833e1f | j_mayer | /* system call in user-mode emulation */
|
1277 | e1833e1f | j_mayer | /* WARNING:
|
1278 | e1833e1f | j_mayer | * PPC ABI uses overflow flag in cr0 to signal an error
|
1279 | e1833e1f | j_mayer | * in syscalls.
|
1280 | e1833e1f | j_mayer | */
|
1281 | e1833e1f | j_mayer | #if 0
|
1282 | e1833e1f | j_mayer | printf("syscall %d 0x%08x 0x%08x 0x%08x 0x%08x\n", env->gpr[0],
|
1283 | e1833e1f | j_mayer | env->gpr[3], env->gpr[4], env->gpr[5], env->gpr[6]);
|
1284 | e1833e1f | j_mayer | #endif
|
1285 | e1833e1f | j_mayer | env->crf[0] &= ~0x1; |
1286 | e1833e1f | j_mayer | ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4], |
1287 | e1833e1f | j_mayer | env->gpr[5], env->gpr[6], env->gpr[7], |
1288 | e1833e1f | j_mayer | env->gpr[8]);
|
1289 | e1833e1f | j_mayer | if (ret > (uint32_t)(-515)) { |
1290 | e1833e1f | j_mayer | env->crf[0] |= 0x1; |
1291 | e1833e1f | j_mayer | ret = -ret; |
1292 | 61190b14 | bellard | } |
1293 | e1833e1f | j_mayer | env->gpr[3] = ret;
|
1294 | e1833e1f | j_mayer | #if 0
|
1295 | e1833e1f | j_mayer | printf("syscall returned 0x%08x (%d)\n", ret, ret);
|
1296 | e1833e1f | j_mayer | #endif
|
1297 | e1833e1f | j_mayer | break;
|
1298 | 56ba31ff | j_mayer | case EXCP_INTERRUPT:
|
1299 | 56ba31ff | j_mayer | /* just indicate that signals should be handled asap */
|
1300 | 56ba31ff | j_mayer | break;
|
1301 | e1833e1f | j_mayer | default:
|
1302 | e1833e1f | j_mayer | cpu_abort(env, "Unknown exception 0x%d. Aborting\n", trapnr);
|
1303 | e1833e1f | j_mayer | break;
|
1304 | 67867308 | bellard | } |
1305 | 67867308 | bellard | process_pending_signals(env); |
1306 | 67867308 | bellard | } |
1307 | 67867308 | bellard | } |
1308 | 67867308 | bellard | #endif
|
1309 | 67867308 | bellard | |
1310 | 048f6b4d | bellard | #ifdef TARGET_MIPS
|
1311 | 048f6b4d | bellard | |
1312 | 048f6b4d | bellard | #define MIPS_SYS(name, args) args,
|
1313 | 048f6b4d | bellard | |
1314 | 048f6b4d | bellard | static const uint8_t mips_syscall_args[] = { |
1315 | 048f6b4d | bellard | MIPS_SYS(sys_syscall , 0) /* 4000 */ |
1316 | 048f6b4d | bellard | MIPS_SYS(sys_exit , 1)
|
1317 | 048f6b4d | bellard | MIPS_SYS(sys_fork , 0)
|
1318 | 048f6b4d | bellard | MIPS_SYS(sys_read , 3)
|
1319 | 048f6b4d | bellard | MIPS_SYS(sys_write , 3)
|
1320 | 048f6b4d | bellard | MIPS_SYS(sys_open , 3) /* 4005 */ |
1321 | 048f6b4d | bellard | MIPS_SYS(sys_close , 1)
|
1322 | 048f6b4d | bellard | MIPS_SYS(sys_waitpid , 3)
|
1323 | 048f6b4d | bellard | MIPS_SYS(sys_creat , 2)
|
1324 | 048f6b4d | bellard | MIPS_SYS(sys_link , 2)
|
1325 | 048f6b4d | bellard | MIPS_SYS(sys_unlink , 1) /* 4010 */ |
1326 | 048f6b4d | bellard | MIPS_SYS(sys_execve , 0)
|
1327 | 048f6b4d | bellard | MIPS_SYS(sys_chdir , 1)
|
1328 | 048f6b4d | bellard | MIPS_SYS(sys_time , 1)
|
1329 | 048f6b4d | bellard | MIPS_SYS(sys_mknod , 3)
|
1330 | 048f6b4d | bellard | MIPS_SYS(sys_chmod , 2) /* 4015 */ |
1331 | 048f6b4d | bellard | MIPS_SYS(sys_lchown , 3)
|
1332 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1333 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_stat */ |
1334 | 048f6b4d | bellard | MIPS_SYS(sys_lseek , 3)
|
1335 | 048f6b4d | bellard | MIPS_SYS(sys_getpid , 0) /* 4020 */ |
1336 | 048f6b4d | bellard | MIPS_SYS(sys_mount , 5)
|
1337 | 048f6b4d | bellard | MIPS_SYS(sys_oldumount , 1)
|
1338 | 048f6b4d | bellard | MIPS_SYS(sys_setuid , 1)
|
1339 | 048f6b4d | bellard | MIPS_SYS(sys_getuid , 0)
|
1340 | 048f6b4d | bellard | MIPS_SYS(sys_stime , 1) /* 4025 */ |
1341 | 048f6b4d | bellard | MIPS_SYS(sys_ptrace , 4)
|
1342 | 048f6b4d | bellard | MIPS_SYS(sys_alarm , 1)
|
1343 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_fstat */ |
1344 | 048f6b4d | bellard | MIPS_SYS(sys_pause , 0)
|
1345 | 048f6b4d | bellard | MIPS_SYS(sys_utime , 2) /* 4030 */ |
1346 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1347 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1348 | 048f6b4d | bellard | MIPS_SYS(sys_access , 2)
|
1349 | 048f6b4d | bellard | MIPS_SYS(sys_nice , 1)
|
1350 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4035 */ |
1351 | 048f6b4d | bellard | MIPS_SYS(sys_sync , 0)
|
1352 | 048f6b4d | bellard | MIPS_SYS(sys_kill , 2)
|
1353 | 048f6b4d | bellard | MIPS_SYS(sys_rename , 2)
|
1354 | 048f6b4d | bellard | MIPS_SYS(sys_mkdir , 2)
|
1355 | 048f6b4d | bellard | MIPS_SYS(sys_rmdir , 1) /* 4040 */ |
1356 | 048f6b4d | bellard | MIPS_SYS(sys_dup , 1)
|
1357 | 048f6b4d | bellard | MIPS_SYS(sys_pipe , 0)
|
1358 | 048f6b4d | bellard | MIPS_SYS(sys_times , 1)
|
1359 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1360 | 048f6b4d | bellard | MIPS_SYS(sys_brk , 1) /* 4045 */ |
1361 | 048f6b4d | bellard | MIPS_SYS(sys_setgid , 1)
|
1362 | 048f6b4d | bellard | MIPS_SYS(sys_getgid , 0)
|
1363 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was signal(2) */ |
1364 | 048f6b4d | bellard | MIPS_SYS(sys_geteuid , 0)
|
1365 | 048f6b4d | bellard | MIPS_SYS(sys_getegid , 0) /* 4050 */ |
1366 | 048f6b4d | bellard | MIPS_SYS(sys_acct , 0)
|
1367 | 048f6b4d | bellard | MIPS_SYS(sys_umount , 2)
|
1368 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1369 | 048f6b4d | bellard | MIPS_SYS(sys_ioctl , 3)
|
1370 | 048f6b4d | bellard | MIPS_SYS(sys_fcntl , 3) /* 4055 */ |
1371 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 2)
|
1372 | 048f6b4d | bellard | MIPS_SYS(sys_setpgid , 2)
|
1373 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1374 | 048f6b4d | bellard | MIPS_SYS(sys_olduname , 1)
|
1375 | 048f6b4d | bellard | MIPS_SYS(sys_umask , 1) /* 4060 */ |
1376 | 048f6b4d | bellard | MIPS_SYS(sys_chroot , 1)
|
1377 | 048f6b4d | bellard | MIPS_SYS(sys_ustat , 2)
|
1378 | 048f6b4d | bellard | MIPS_SYS(sys_dup2 , 2)
|
1379 | 048f6b4d | bellard | MIPS_SYS(sys_getppid , 0)
|
1380 | 048f6b4d | bellard | MIPS_SYS(sys_getpgrp , 0) /* 4065 */ |
1381 | 048f6b4d | bellard | MIPS_SYS(sys_setsid , 0)
|
1382 | 048f6b4d | bellard | MIPS_SYS(sys_sigaction , 3)
|
1383 | 048f6b4d | bellard | MIPS_SYS(sys_sgetmask , 0)
|
1384 | 048f6b4d | bellard | MIPS_SYS(sys_ssetmask , 1)
|
1385 | 048f6b4d | bellard | MIPS_SYS(sys_setreuid , 2) /* 4070 */ |
1386 | 048f6b4d | bellard | MIPS_SYS(sys_setregid , 2)
|
1387 | 048f6b4d | bellard | MIPS_SYS(sys_sigsuspend , 0)
|
1388 | 048f6b4d | bellard | MIPS_SYS(sys_sigpending , 1)
|
1389 | 048f6b4d | bellard | MIPS_SYS(sys_sethostname , 2)
|
1390 | 048f6b4d | bellard | MIPS_SYS(sys_setrlimit , 2) /* 4075 */ |
1391 | 048f6b4d | bellard | MIPS_SYS(sys_getrlimit , 2)
|
1392 | 048f6b4d | bellard | MIPS_SYS(sys_getrusage , 2)
|
1393 | 048f6b4d | bellard | MIPS_SYS(sys_gettimeofday, 2)
|
1394 | 048f6b4d | bellard | MIPS_SYS(sys_settimeofday, 2)
|
1395 | 048f6b4d | bellard | MIPS_SYS(sys_getgroups , 2) /* 4080 */ |
1396 | 048f6b4d | bellard | MIPS_SYS(sys_setgroups , 2)
|
1397 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* old_select */ |
1398 | 048f6b4d | bellard | MIPS_SYS(sys_symlink , 2)
|
1399 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_lstat */ |
1400 | 048f6b4d | bellard | MIPS_SYS(sys_readlink , 3) /* 4085 */ |
1401 | 048f6b4d | bellard | MIPS_SYS(sys_uselib , 1)
|
1402 | 048f6b4d | bellard | MIPS_SYS(sys_swapon , 2)
|
1403 | 048f6b4d | bellard | MIPS_SYS(sys_reboot , 3)
|
1404 | 048f6b4d | bellard | MIPS_SYS(old_readdir , 3)
|
1405 | 048f6b4d | bellard | MIPS_SYS(old_mmap , 6) /* 4090 */ |
1406 | 048f6b4d | bellard | MIPS_SYS(sys_munmap , 2)
|
1407 | 048f6b4d | bellard | MIPS_SYS(sys_truncate , 2)
|
1408 | 048f6b4d | bellard | MIPS_SYS(sys_ftruncate , 2)
|
1409 | 048f6b4d | bellard | MIPS_SYS(sys_fchmod , 2)
|
1410 | 048f6b4d | bellard | MIPS_SYS(sys_fchown , 3) /* 4095 */ |
1411 | 048f6b4d | bellard | MIPS_SYS(sys_getpriority , 2)
|
1412 | 048f6b4d | bellard | MIPS_SYS(sys_setpriority , 3)
|
1413 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1414 | 048f6b4d | bellard | MIPS_SYS(sys_statfs , 2)
|
1415 | 048f6b4d | bellard | MIPS_SYS(sys_fstatfs , 2) /* 4100 */ |
1416 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was ioperm(2) */ |
1417 | 048f6b4d | bellard | MIPS_SYS(sys_socketcall , 2)
|
1418 | 048f6b4d | bellard | MIPS_SYS(sys_syslog , 3)
|
1419 | 048f6b4d | bellard | MIPS_SYS(sys_setitimer , 3)
|
1420 | 048f6b4d | bellard | MIPS_SYS(sys_getitimer , 2) /* 4105 */ |
1421 | 048f6b4d | bellard | MIPS_SYS(sys_newstat , 2)
|
1422 | 048f6b4d | bellard | MIPS_SYS(sys_newlstat , 2)
|
1423 | 048f6b4d | bellard | MIPS_SYS(sys_newfstat , 2)
|
1424 | 048f6b4d | bellard | MIPS_SYS(sys_uname , 1)
|
1425 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4110 was iopl(2) */ |
1426 | 048f6b4d | bellard | MIPS_SYS(sys_vhangup , 0)
|
1427 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_idle() */ |
1428 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_vm86 */ |
1429 | 048f6b4d | bellard | MIPS_SYS(sys_wait4 , 4)
|
1430 | 048f6b4d | bellard | MIPS_SYS(sys_swapoff , 1) /* 4115 */ |
1431 | 048f6b4d | bellard | MIPS_SYS(sys_sysinfo , 1)
|
1432 | 048f6b4d | bellard | MIPS_SYS(sys_ipc , 6)
|
1433 | 048f6b4d | bellard | MIPS_SYS(sys_fsync , 1)
|
1434 | 048f6b4d | bellard | MIPS_SYS(sys_sigreturn , 0)
|
1435 | 048f6b4d | bellard | MIPS_SYS(sys_clone , 0) /* 4120 */ |
1436 | 048f6b4d | bellard | MIPS_SYS(sys_setdomainname, 2)
|
1437 | 048f6b4d | bellard | MIPS_SYS(sys_newuname , 1)
|
1438 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_modify_ldt */ |
1439 | 048f6b4d | bellard | MIPS_SYS(sys_adjtimex , 1)
|
1440 | 048f6b4d | bellard | MIPS_SYS(sys_mprotect , 3) /* 4125 */ |
1441 | 048f6b4d | bellard | MIPS_SYS(sys_sigprocmask , 3)
|
1442 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was create_module */ |
1443 | 048f6b4d | bellard | MIPS_SYS(sys_init_module , 5)
|
1444 | 048f6b4d | bellard | MIPS_SYS(sys_delete_module, 1)
|
1445 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4130 was get_kernel_syms */ |
1446 | 048f6b4d | bellard | MIPS_SYS(sys_quotactl , 0)
|
1447 | 048f6b4d | bellard | MIPS_SYS(sys_getpgid , 1)
|
1448 | 048f6b4d | bellard | MIPS_SYS(sys_fchdir , 1)
|
1449 | 048f6b4d | bellard | MIPS_SYS(sys_bdflush , 2)
|
1450 | 048f6b4d | bellard | MIPS_SYS(sys_sysfs , 3) /* 4135 */ |
1451 | 048f6b4d | bellard | MIPS_SYS(sys_personality , 1)
|
1452 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* for afs_syscall */ |
1453 | 048f6b4d | bellard | MIPS_SYS(sys_setfsuid , 1)
|
1454 | 048f6b4d | bellard | MIPS_SYS(sys_setfsgid , 1)
|
1455 | 048f6b4d | bellard | MIPS_SYS(sys_llseek , 5) /* 4140 */ |
1456 | 048f6b4d | bellard | MIPS_SYS(sys_getdents , 3)
|
1457 | 048f6b4d | bellard | MIPS_SYS(sys_select , 5)
|
1458 | 048f6b4d | bellard | MIPS_SYS(sys_flock , 2)
|
1459 | 048f6b4d | bellard | MIPS_SYS(sys_msync , 3)
|
1460 | 048f6b4d | bellard | MIPS_SYS(sys_readv , 3) /* 4145 */ |
1461 | 048f6b4d | bellard | MIPS_SYS(sys_writev , 3)
|
1462 | 048f6b4d | bellard | MIPS_SYS(sys_cacheflush , 3)
|
1463 | 048f6b4d | bellard | MIPS_SYS(sys_cachectl , 3)
|
1464 | 048f6b4d | bellard | MIPS_SYS(sys_sysmips , 4)
|
1465 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4150 */ |
1466 | 048f6b4d | bellard | MIPS_SYS(sys_getsid , 1)
|
1467 | 048f6b4d | bellard | MIPS_SYS(sys_fdatasync , 0)
|
1468 | 048f6b4d | bellard | MIPS_SYS(sys_sysctl , 1)
|
1469 | 048f6b4d | bellard | MIPS_SYS(sys_mlock , 2)
|
1470 | 048f6b4d | bellard | MIPS_SYS(sys_munlock , 2) /* 4155 */ |
1471 | 048f6b4d | bellard | MIPS_SYS(sys_mlockall , 1)
|
1472 | 048f6b4d | bellard | MIPS_SYS(sys_munlockall , 0)
|
1473 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setparam, 2)
|
1474 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getparam, 2)
|
1475 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setscheduler, 3) /* 4160 */ |
1476 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getscheduler, 1)
|
1477 | 048f6b4d | bellard | MIPS_SYS(sys_sched_yield , 0)
|
1478 | 048f6b4d | bellard | MIPS_SYS(sys_sched_get_priority_max, 1)
|
1479 | 048f6b4d | bellard | MIPS_SYS(sys_sched_get_priority_min, 1)
|
1480 | 048f6b4d | bellard | MIPS_SYS(sys_sched_rr_get_interval, 2) /* 4165 */ |
1481 | 048f6b4d | bellard | MIPS_SYS(sys_nanosleep, 2)
|
1482 | 048f6b4d | bellard | MIPS_SYS(sys_mremap , 4)
|
1483 | 048f6b4d | bellard | MIPS_SYS(sys_accept , 3)
|
1484 | 048f6b4d | bellard | MIPS_SYS(sys_bind , 3)
|
1485 | 048f6b4d | bellard | MIPS_SYS(sys_connect , 3) /* 4170 */ |
1486 | 048f6b4d | bellard | MIPS_SYS(sys_getpeername , 3)
|
1487 | 048f6b4d | bellard | MIPS_SYS(sys_getsockname , 3)
|
1488 | 048f6b4d | bellard | MIPS_SYS(sys_getsockopt , 5)
|
1489 | 048f6b4d | bellard | MIPS_SYS(sys_listen , 2)
|
1490 | 048f6b4d | bellard | MIPS_SYS(sys_recv , 4) /* 4175 */ |
1491 | 048f6b4d | bellard | MIPS_SYS(sys_recvfrom , 6)
|
1492 | 048f6b4d | bellard | MIPS_SYS(sys_recvmsg , 3)
|
1493 | 048f6b4d | bellard | MIPS_SYS(sys_send , 4)
|
1494 | 048f6b4d | bellard | MIPS_SYS(sys_sendmsg , 3)
|
1495 | 048f6b4d | bellard | MIPS_SYS(sys_sendto , 6) /* 4180 */ |
1496 | 048f6b4d | bellard | MIPS_SYS(sys_setsockopt , 5)
|
1497 | 048f6b4d | bellard | MIPS_SYS(sys_shutdown , 2)
|
1498 | 048f6b4d | bellard | MIPS_SYS(sys_socket , 3)
|
1499 | 048f6b4d | bellard | MIPS_SYS(sys_socketpair , 4)
|
1500 | 048f6b4d | bellard | MIPS_SYS(sys_setresuid , 3) /* 4185 */ |
1501 | 048f6b4d | bellard | MIPS_SYS(sys_getresuid , 3)
|
1502 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* was sys_query_module */ |
1503 | 048f6b4d | bellard | MIPS_SYS(sys_poll , 3)
|
1504 | 048f6b4d | bellard | MIPS_SYS(sys_nfsservctl , 3)
|
1505 | 048f6b4d | bellard | MIPS_SYS(sys_setresgid , 3) /* 4190 */ |
1506 | 048f6b4d | bellard | MIPS_SYS(sys_getresgid , 3)
|
1507 | 048f6b4d | bellard | MIPS_SYS(sys_prctl , 5)
|
1508 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigreturn, 0)
|
1509 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigaction, 4)
|
1510 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigprocmask, 4) /* 4195 */ |
1511 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigpending, 2)
|
1512 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigtimedwait, 4)
|
1513 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigqueueinfo, 3)
|
1514 | 048f6b4d | bellard | MIPS_SYS(sys_rt_sigsuspend, 0)
|
1515 | 048f6b4d | bellard | MIPS_SYS(sys_pread64 , 6) /* 4200 */ |
1516 | 048f6b4d | bellard | MIPS_SYS(sys_pwrite64 , 6)
|
1517 | 048f6b4d | bellard | MIPS_SYS(sys_chown , 3)
|
1518 | 048f6b4d | bellard | MIPS_SYS(sys_getcwd , 2)
|
1519 | 048f6b4d | bellard | MIPS_SYS(sys_capget , 2)
|
1520 | 048f6b4d | bellard | MIPS_SYS(sys_capset , 2) /* 4205 */ |
1521 | 048f6b4d | bellard | MIPS_SYS(sys_sigaltstack , 0)
|
1522 | 048f6b4d | bellard | MIPS_SYS(sys_sendfile , 4)
|
1523 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1524 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1525 | 048f6b4d | bellard | MIPS_SYS(sys_mmap2 , 6) /* 4210 */ |
1526 | 048f6b4d | bellard | MIPS_SYS(sys_truncate64 , 4)
|
1527 | 048f6b4d | bellard | MIPS_SYS(sys_ftruncate64 , 4)
|
1528 | 048f6b4d | bellard | MIPS_SYS(sys_stat64 , 2)
|
1529 | 048f6b4d | bellard | MIPS_SYS(sys_lstat64 , 2)
|
1530 | 048f6b4d | bellard | MIPS_SYS(sys_fstat64 , 2) /* 4215 */ |
1531 | 048f6b4d | bellard | MIPS_SYS(sys_pivot_root , 2)
|
1532 | 048f6b4d | bellard | MIPS_SYS(sys_mincore , 3)
|
1533 | 048f6b4d | bellard | MIPS_SYS(sys_madvise , 3)
|
1534 | 048f6b4d | bellard | MIPS_SYS(sys_getdents64 , 3)
|
1535 | 048f6b4d | bellard | MIPS_SYS(sys_fcntl64 , 3) /* 4220 */ |
1536 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0)
|
1537 | 048f6b4d | bellard | MIPS_SYS(sys_gettid , 0)
|
1538 | 048f6b4d | bellard | MIPS_SYS(sys_readahead , 5)
|
1539 | 048f6b4d | bellard | MIPS_SYS(sys_setxattr , 5)
|
1540 | 048f6b4d | bellard | MIPS_SYS(sys_lsetxattr , 5) /* 4225 */ |
1541 | 048f6b4d | bellard | MIPS_SYS(sys_fsetxattr , 5)
|
1542 | 048f6b4d | bellard | MIPS_SYS(sys_getxattr , 4)
|
1543 | 048f6b4d | bellard | MIPS_SYS(sys_lgetxattr , 4)
|
1544 | 048f6b4d | bellard | MIPS_SYS(sys_fgetxattr , 4)
|
1545 | 048f6b4d | bellard | MIPS_SYS(sys_listxattr , 3) /* 4230 */ |
1546 | 048f6b4d | bellard | MIPS_SYS(sys_llistxattr , 3)
|
1547 | 048f6b4d | bellard | MIPS_SYS(sys_flistxattr , 3)
|
1548 | 048f6b4d | bellard | MIPS_SYS(sys_removexattr , 2)
|
1549 | 048f6b4d | bellard | MIPS_SYS(sys_lremovexattr, 2)
|
1550 | 048f6b4d | bellard | MIPS_SYS(sys_fremovexattr, 2) /* 4235 */ |
1551 | 048f6b4d | bellard | MIPS_SYS(sys_tkill , 2)
|
1552 | 048f6b4d | bellard | MIPS_SYS(sys_sendfile64 , 5)
|
1553 | 048f6b4d | bellard | MIPS_SYS(sys_futex , 2)
|
1554 | 048f6b4d | bellard | MIPS_SYS(sys_sched_setaffinity, 3)
|
1555 | 048f6b4d | bellard | MIPS_SYS(sys_sched_getaffinity, 3) /* 4240 */ |
1556 | 048f6b4d | bellard | MIPS_SYS(sys_io_setup , 2)
|
1557 | 048f6b4d | bellard | MIPS_SYS(sys_io_destroy , 1)
|
1558 | 048f6b4d | bellard | MIPS_SYS(sys_io_getevents, 5)
|
1559 | 048f6b4d | bellard | MIPS_SYS(sys_io_submit , 3)
|
1560 | 048f6b4d | bellard | MIPS_SYS(sys_io_cancel , 3) /* 4245 */ |
1561 | 048f6b4d | bellard | MIPS_SYS(sys_exit_group , 1)
|
1562 | 048f6b4d | bellard | MIPS_SYS(sys_lookup_dcookie, 3)
|
1563 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_create, 1)
|
1564 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_ctl , 4)
|
1565 | 048f6b4d | bellard | MIPS_SYS(sys_epoll_wait , 3) /* 4250 */ |
1566 | 048f6b4d | bellard | MIPS_SYS(sys_remap_file_pages, 5)
|
1567 | 048f6b4d | bellard | MIPS_SYS(sys_set_tid_address, 1)
|
1568 | 048f6b4d | bellard | MIPS_SYS(sys_restart_syscall, 0)
|
1569 | 048f6b4d | bellard | MIPS_SYS(sys_fadvise64_64, 7)
|
1570 | 048f6b4d | bellard | MIPS_SYS(sys_statfs64 , 3) /* 4255 */ |
1571 | 048f6b4d | bellard | MIPS_SYS(sys_fstatfs64 , 2)
|
1572 | 048f6b4d | bellard | MIPS_SYS(sys_timer_create, 3)
|
1573 | 048f6b4d | bellard | MIPS_SYS(sys_timer_settime, 4)
|
1574 | 048f6b4d | bellard | MIPS_SYS(sys_timer_gettime, 2)
|
1575 | 048f6b4d | bellard | MIPS_SYS(sys_timer_getoverrun, 1) /* 4260 */ |
1576 | 048f6b4d | bellard | MIPS_SYS(sys_timer_delete, 1)
|
1577 | 048f6b4d | bellard | MIPS_SYS(sys_clock_settime, 2)
|
1578 | 048f6b4d | bellard | MIPS_SYS(sys_clock_gettime, 2)
|
1579 | 048f6b4d | bellard | MIPS_SYS(sys_clock_getres, 2)
|
1580 | 048f6b4d | bellard | MIPS_SYS(sys_clock_nanosleep, 4) /* 4265 */ |
1581 | 048f6b4d | bellard | MIPS_SYS(sys_tgkill , 3)
|
1582 | 048f6b4d | bellard | MIPS_SYS(sys_utimes , 2)
|
1583 | 048f6b4d | bellard | MIPS_SYS(sys_mbind , 4)
|
1584 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_get_mempolicy */ |
1585 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* 4270 sys_set_mempolicy */ |
1586 | 048f6b4d | bellard | MIPS_SYS(sys_mq_open , 4)
|
1587 | 048f6b4d | bellard | MIPS_SYS(sys_mq_unlink , 1)
|
1588 | 048f6b4d | bellard | MIPS_SYS(sys_mq_timedsend, 5)
|
1589 | 048f6b4d | bellard | MIPS_SYS(sys_mq_timedreceive, 5)
|
1590 | 048f6b4d | bellard | MIPS_SYS(sys_mq_notify , 2) /* 4275 */ |
1591 | 048f6b4d | bellard | MIPS_SYS(sys_mq_getsetattr, 3)
|
1592 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* sys_vserver */ |
1593 | 048f6b4d | bellard | MIPS_SYS(sys_waitid , 4)
|
1594 | 048f6b4d | bellard | MIPS_SYS(sys_ni_syscall , 0) /* available, was setaltroot */ |
1595 | 048f6b4d | bellard | MIPS_SYS(sys_add_key , 5)
|
1596 | 388bb21a | ths | MIPS_SYS(sys_request_key, 4)
|
1597 | 048f6b4d | bellard | MIPS_SYS(sys_keyctl , 5)
|
1598 | 6f5b89a0 | ths | MIPS_SYS(sys_set_thread_area, 1)
|
1599 | 388bb21a | ths | MIPS_SYS(sys_inotify_init, 0)
|
1600 | 388bb21a | ths | MIPS_SYS(sys_inotify_add_watch, 3) /* 4285 */ |
1601 | 388bb21a | ths | MIPS_SYS(sys_inotify_rm_watch, 2)
|
1602 | 388bb21a | ths | MIPS_SYS(sys_migrate_pages, 4)
|
1603 | 388bb21a | ths | MIPS_SYS(sys_openat, 4)
|
1604 | 388bb21a | ths | MIPS_SYS(sys_mkdirat, 3)
|
1605 | 388bb21a | ths | MIPS_SYS(sys_mknodat, 4) /* 4290 */ |
1606 | 388bb21a | ths | MIPS_SYS(sys_fchownat, 5)
|
1607 | 388bb21a | ths | MIPS_SYS(sys_futimesat, 3)
|
1608 | 388bb21a | ths | MIPS_SYS(sys_fstatat64, 4)
|
1609 | 388bb21a | ths | MIPS_SYS(sys_unlinkat, 3)
|
1610 | 388bb21a | ths | MIPS_SYS(sys_renameat, 4) /* 4295 */ |
1611 | 388bb21a | ths | MIPS_SYS(sys_linkat, 5)
|
1612 | 388bb21a | ths | MIPS_SYS(sys_symlinkat, 3)
|
1613 | 388bb21a | ths | MIPS_SYS(sys_readlinkat, 4)
|
1614 | 388bb21a | ths | MIPS_SYS(sys_fchmodat, 3)
|
1615 | 388bb21a | ths | MIPS_SYS(sys_faccessat, 3) /* 4300 */ |
1616 | 388bb21a | ths | MIPS_SYS(sys_pselect6, 6)
|
1617 | 388bb21a | ths | MIPS_SYS(sys_ppoll, 5)
|
1618 | 388bb21a | ths | MIPS_SYS(sys_unshare, 1)
|
1619 | 388bb21a | ths | MIPS_SYS(sys_splice, 4)
|
1620 | 388bb21a | ths | MIPS_SYS(sys_sync_file_range, 7) /* 4305 */ |
1621 | 388bb21a | ths | MIPS_SYS(sys_tee, 4)
|
1622 | 388bb21a | ths | MIPS_SYS(sys_vmsplice, 4)
|
1623 | 388bb21a | ths | MIPS_SYS(sys_move_pages, 6)
|
1624 | 388bb21a | ths | MIPS_SYS(sys_set_robust_list, 2)
|
1625 | 388bb21a | ths | MIPS_SYS(sys_get_robust_list, 3) /* 4310 */ |
1626 | 388bb21a | ths | MIPS_SYS(sys_kexec_load, 4)
|
1627 | 388bb21a | ths | MIPS_SYS(sys_getcpu, 3)
|
1628 | 388bb21a | ths | MIPS_SYS(sys_epoll_pwait, 6)
|
1629 | 388bb21a | ths | MIPS_SYS(sys_ioprio_set, 3)
|
1630 | 388bb21a | ths | MIPS_SYS(sys_ioprio_get, 2)
|
1631 | 048f6b4d | bellard | }; |
1632 | 048f6b4d | bellard | |
1633 | 048f6b4d | bellard | #undef MIPS_SYS
|
1634 | 048f6b4d | bellard | |
1635 | 048f6b4d | bellard | void cpu_loop(CPUMIPSState *env)
|
1636 | 048f6b4d | bellard | { |
1637 | 048f6b4d | bellard | target_siginfo_t info; |
1638 | 388bb21a | ths | int trapnr, ret;
|
1639 | 048f6b4d | bellard | unsigned int syscall_num; |
1640 | 048f6b4d | bellard | |
1641 | 048f6b4d | bellard | for(;;) {
|
1642 | 048f6b4d | bellard | trapnr = cpu_mips_exec(env); |
1643 | 048f6b4d | bellard | switch(trapnr) {
|
1644 | 048f6b4d | bellard | case EXCP_SYSCALL:
|
1645 | d0dc7dc3 | ths | syscall_num = env->gpr[env->current_tc][2] - 4000; |
1646 | ead9360e | ths | env->PC[env->current_tc] += 4;
|
1647 | 388bb21a | ths | if (syscall_num >= sizeof(mips_syscall_args)) { |
1648 | 388bb21a | ths | ret = -ENOSYS; |
1649 | 388bb21a | ths | } else {
|
1650 | 388bb21a | ths | int nb_args;
|
1651 | 992f48a0 | blueswir1 | abi_ulong sp_reg; |
1652 | 992f48a0 | blueswir1 | abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0; |
1653 | 388bb21a | ths | |
1654 | 388bb21a | ths | nb_args = mips_syscall_args[syscall_num]; |
1655 | d0dc7dc3 | ths | sp_reg = env->gpr[env->current_tc][29];
|
1656 | 388bb21a | ths | switch (nb_args) {
|
1657 | 388bb21a | ths | /* these arguments are taken from the stack */
|
1658 | 2f619698 | bellard | /* FIXME - what to do if get_user() fails? */
|
1659 | 2f619698 | bellard | case 8: get_user_ual(arg8, sp_reg + 28); |
1660 | 2f619698 | bellard | case 7: get_user_ual(arg7, sp_reg + 24); |
1661 | 2f619698 | bellard | case 6: get_user_ual(arg6, sp_reg + 20); |
1662 | 2f619698 | bellard | case 5: get_user_ual(arg5, sp_reg + 16); |
1663 | 388bb21a | ths | default:
|
1664 | 388bb21a | ths | break;
|
1665 | 048f6b4d | bellard | } |
1666 | d0dc7dc3 | ths | ret = do_syscall(env, env->gpr[env->current_tc][2],
|
1667 | d0dc7dc3 | ths | env->gpr[env->current_tc][4],
|
1668 | d0dc7dc3 | ths | env->gpr[env->current_tc][5],
|
1669 | d0dc7dc3 | ths | env->gpr[env->current_tc][6],
|
1670 | d0dc7dc3 | ths | env->gpr[env->current_tc][7],
|
1671 | 388bb21a | ths | arg5, arg6/*, arg7, arg8*/);
|
1672 | 388bb21a | ths | } |
1673 | 388bb21a | ths | if ((unsigned int)ret >= (unsigned int)(-1133)) { |
1674 | d0dc7dc3 | ths | env->gpr[env->current_tc][7] = 1; /* error flag */ |
1675 | 388bb21a | ths | ret = -ret; |
1676 | 388bb21a | ths | } else {
|
1677 | d0dc7dc3 | ths | env->gpr[env->current_tc][7] = 0; /* error flag */ |
1678 | 048f6b4d | bellard | } |
1679 | d0dc7dc3 | ths | env->gpr[env->current_tc][2] = ret;
|
1680 | 048f6b4d | bellard | break;
|
1681 | ca7c2b1b | ths | case EXCP_TLBL:
|
1682 | ca7c2b1b | ths | case EXCP_TLBS:
|
1683 | 6900e84b | bellard | case EXCP_CpU:
|
1684 | 048f6b4d | bellard | case EXCP_RI:
|
1685 | bc1ad2de | bellard | info.si_signo = TARGET_SIGILL; |
1686 | bc1ad2de | bellard | info.si_errno = 0;
|
1687 | bc1ad2de | bellard | info.si_code = 0;
|
1688 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1689 | 048f6b4d | bellard | break;
|
1690 | 106ec879 | bellard | case EXCP_INTERRUPT:
|
1691 | 106ec879 | bellard | /* just indicate that signals should be handled asap */
|
1692 | 106ec879 | bellard | break;
|
1693 | d08b2a28 | pbrook | case EXCP_DEBUG:
|
1694 | d08b2a28 | pbrook | { |
1695 | d08b2a28 | pbrook | int sig;
|
1696 | d08b2a28 | pbrook | |
1697 | d08b2a28 | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1698 | d08b2a28 | pbrook | if (sig)
|
1699 | d08b2a28 | pbrook | { |
1700 | d08b2a28 | pbrook | info.si_signo = sig; |
1701 | d08b2a28 | pbrook | info.si_errno = 0;
|
1702 | d08b2a28 | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1703 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1704 | d08b2a28 | pbrook | } |
1705 | d08b2a28 | pbrook | } |
1706 | d08b2a28 | pbrook | break;
|
1707 | 048f6b4d | bellard | default:
|
1708 | 048f6b4d | bellard | // error:
|
1709 | 5fafdf24 | ths | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
1710 | 048f6b4d | bellard | trapnr); |
1711 | 048f6b4d | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
1712 | 048f6b4d | bellard | abort(); |
1713 | 048f6b4d | bellard | } |
1714 | 048f6b4d | bellard | process_pending_signals(env); |
1715 | 048f6b4d | bellard | } |
1716 | 048f6b4d | bellard | } |
1717 | 048f6b4d | bellard | #endif
|
1718 | 048f6b4d | bellard | |
1719 | fdf9b3e8 | bellard | #ifdef TARGET_SH4
|
1720 | fdf9b3e8 | bellard | void cpu_loop (CPUState *env)
|
1721 | fdf9b3e8 | bellard | { |
1722 | fdf9b3e8 | bellard | int trapnr, ret;
|
1723 | 355fb23d | pbrook | target_siginfo_t info; |
1724 | 3b46e624 | ths | |
1725 | fdf9b3e8 | bellard | while (1) { |
1726 | fdf9b3e8 | bellard | trapnr = cpu_sh4_exec (env); |
1727 | 3b46e624 | ths | |
1728 | fdf9b3e8 | bellard | switch (trapnr) {
|
1729 | fdf9b3e8 | bellard | case 0x160: |
1730 | 5fafdf24 | ths | ret = do_syscall(env, |
1731 | 5fafdf24 | ths | env->gregs[3],
|
1732 | 5fafdf24 | ths | env->gregs[4],
|
1733 | 5fafdf24 | ths | env->gregs[5],
|
1734 | 5fafdf24 | ths | env->gregs[6],
|
1735 | 5fafdf24 | ths | env->gregs[7],
|
1736 | 5fafdf24 | ths | env->gregs[0],
|
1737 | fca743f3 | ths | env->gregs[1]);
|
1738 | 9c2a9ea1 | pbrook | env->gregs[0] = ret;
|
1739 | fdf9b3e8 | bellard | env->pc += 2;
|
1740 | fdf9b3e8 | bellard | break;
|
1741 | c3b5bc8a | ths | case EXCP_INTERRUPT:
|
1742 | c3b5bc8a | ths | /* just indicate that signals should be handled asap */
|
1743 | c3b5bc8a | ths | break;
|
1744 | 355fb23d | pbrook | case EXCP_DEBUG:
|
1745 | 355fb23d | pbrook | { |
1746 | 355fb23d | pbrook | int sig;
|
1747 | 355fb23d | pbrook | |
1748 | 355fb23d | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1749 | 355fb23d | pbrook | if (sig)
|
1750 | 355fb23d | pbrook | { |
1751 | 355fb23d | pbrook | info.si_signo = sig; |
1752 | 355fb23d | pbrook | info.si_errno = 0;
|
1753 | 355fb23d | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1754 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1755 | 355fb23d | pbrook | } |
1756 | 355fb23d | pbrook | } |
1757 | 355fb23d | pbrook | break;
|
1758 | c3b5bc8a | ths | case 0xa0: |
1759 | c3b5bc8a | ths | case 0xc0: |
1760 | c3b5bc8a | ths | info.si_signo = SIGSEGV; |
1761 | c3b5bc8a | ths | info.si_errno = 0;
|
1762 | c3b5bc8a | ths | info.si_code = TARGET_SEGV_MAPERR; |
1763 | c3b5bc8a | ths | info._sifields._sigfault._addr = env->tea; |
1764 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1765 | c3b5bc8a | ths | break;
|
1766 | c3b5bc8a | ths | |
1767 | fdf9b3e8 | bellard | default:
|
1768 | fdf9b3e8 | bellard | printf ("Unhandled trap: 0x%x\n", trapnr);
|
1769 | fdf9b3e8 | bellard | cpu_dump_state(env, stderr, fprintf, 0);
|
1770 | fdf9b3e8 | bellard | exit (1);
|
1771 | fdf9b3e8 | bellard | } |
1772 | fdf9b3e8 | bellard | process_pending_signals (env); |
1773 | fdf9b3e8 | bellard | } |
1774 | fdf9b3e8 | bellard | } |
1775 | fdf9b3e8 | bellard | #endif
|
1776 | fdf9b3e8 | bellard | |
1777 | 48733d19 | ths | #ifdef TARGET_CRIS
|
1778 | 48733d19 | ths | void cpu_loop (CPUState *env)
|
1779 | 48733d19 | ths | { |
1780 | 48733d19 | ths | int trapnr, ret;
|
1781 | 48733d19 | ths | target_siginfo_t info; |
1782 | 48733d19 | ths | |
1783 | 48733d19 | ths | while (1) { |
1784 | 48733d19 | ths | trapnr = cpu_cris_exec (env); |
1785 | 48733d19 | ths | switch (trapnr) {
|
1786 | 48733d19 | ths | case 0xaa: |
1787 | 48733d19 | ths | { |
1788 | 48733d19 | ths | info.si_signo = SIGSEGV; |
1789 | 48733d19 | ths | info.si_errno = 0;
|
1790 | 48733d19 | ths | /* XXX: check env->error_code */
|
1791 | 48733d19 | ths | info.si_code = TARGET_SEGV_MAPERR; |
1792 | e00c1e71 | edgar_igl | info._sifields._sigfault._addr = env->pregs[PR_EDA]; |
1793 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1794 | 48733d19 | ths | } |
1795 | 48733d19 | ths | break;
|
1796 | b6d3abda | edgar_igl | case EXCP_INTERRUPT:
|
1797 | b6d3abda | edgar_igl | /* just indicate that signals should be handled asap */
|
1798 | b6d3abda | edgar_igl | break;
|
1799 | 48733d19 | ths | case EXCP_BREAK:
|
1800 | 48733d19 | ths | ret = do_syscall(env, |
1801 | 48733d19 | ths | env->regs[9],
|
1802 | 48733d19 | ths | env->regs[10],
|
1803 | 48733d19 | ths | env->regs[11],
|
1804 | 48733d19 | ths | env->regs[12],
|
1805 | 48733d19 | ths | env->regs[13],
|
1806 | 48733d19 | ths | env->pregs[7],
|
1807 | 48733d19 | ths | env->pregs[11]);
|
1808 | 48733d19 | ths | env->regs[10] = ret;
|
1809 | 48733d19 | ths | env->pc += 2;
|
1810 | 48733d19 | ths | break;
|
1811 | 48733d19 | ths | case EXCP_DEBUG:
|
1812 | 48733d19 | ths | { |
1813 | 48733d19 | ths | int sig;
|
1814 | 48733d19 | ths | |
1815 | 48733d19 | ths | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1816 | 48733d19 | ths | if (sig)
|
1817 | 48733d19 | ths | { |
1818 | 48733d19 | ths | info.si_signo = sig; |
1819 | 48733d19 | ths | info.si_errno = 0;
|
1820 | 48733d19 | ths | info.si_code = TARGET_TRAP_BRKPT; |
1821 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1822 | 48733d19 | ths | } |
1823 | 48733d19 | ths | } |
1824 | 48733d19 | ths | break;
|
1825 | 48733d19 | ths | default:
|
1826 | 48733d19 | ths | printf ("Unhandled trap: 0x%x\n", trapnr);
|
1827 | 48733d19 | ths | cpu_dump_state(env, stderr, fprintf, 0);
|
1828 | 48733d19 | ths | exit (1);
|
1829 | 48733d19 | ths | } |
1830 | 48733d19 | ths | process_pending_signals (env); |
1831 | 48733d19 | ths | } |
1832 | 48733d19 | ths | } |
1833 | 48733d19 | ths | #endif
|
1834 | 48733d19 | ths | |
1835 | e6e5906b | pbrook | #ifdef TARGET_M68K
|
1836 | e6e5906b | pbrook | |
1837 | e6e5906b | pbrook | void cpu_loop(CPUM68KState *env)
|
1838 | e6e5906b | pbrook | { |
1839 | e6e5906b | pbrook | int trapnr;
|
1840 | e6e5906b | pbrook | unsigned int n; |
1841 | e6e5906b | pbrook | target_siginfo_t info; |
1842 | e6e5906b | pbrook | TaskState *ts = env->opaque; |
1843 | 3b46e624 | ths | |
1844 | e6e5906b | pbrook | for(;;) {
|
1845 | e6e5906b | pbrook | trapnr = cpu_m68k_exec(env); |
1846 | e6e5906b | pbrook | switch(trapnr) {
|
1847 | e6e5906b | pbrook | case EXCP_ILLEGAL:
|
1848 | e6e5906b | pbrook | { |
1849 | e6e5906b | pbrook | if (ts->sim_syscalls) {
|
1850 | e6e5906b | pbrook | uint16_t nr; |
1851 | e6e5906b | pbrook | nr = lduw(env->pc + 2);
|
1852 | e6e5906b | pbrook | env->pc += 4;
|
1853 | e6e5906b | pbrook | do_m68k_simcall(env, nr); |
1854 | e6e5906b | pbrook | } else {
|
1855 | e6e5906b | pbrook | goto do_sigill;
|
1856 | e6e5906b | pbrook | } |
1857 | e6e5906b | pbrook | } |
1858 | e6e5906b | pbrook | break;
|
1859 | a87295e8 | pbrook | case EXCP_HALT_INSN:
|
1860 | e6e5906b | pbrook | /* Semihosing syscall. */
|
1861 | a87295e8 | pbrook | env->pc += 4;
|
1862 | e6e5906b | pbrook | do_m68k_semihosting(env, env->dregs[0]);
|
1863 | e6e5906b | pbrook | break;
|
1864 | e6e5906b | pbrook | case EXCP_LINEA:
|
1865 | e6e5906b | pbrook | case EXCP_LINEF:
|
1866 | e6e5906b | pbrook | case EXCP_UNSUPPORTED:
|
1867 | e6e5906b | pbrook | do_sigill:
|
1868 | e6e5906b | pbrook | info.si_signo = SIGILL; |
1869 | e6e5906b | pbrook | info.si_errno = 0;
|
1870 | e6e5906b | pbrook | info.si_code = TARGET_ILL_ILLOPN; |
1871 | e6e5906b | pbrook | info._sifields._sigfault._addr = env->pc; |
1872 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1873 | e6e5906b | pbrook | break;
|
1874 | e6e5906b | pbrook | case EXCP_TRAP0:
|
1875 | e6e5906b | pbrook | { |
1876 | e6e5906b | pbrook | ts->sim_syscalls = 0;
|
1877 | e6e5906b | pbrook | n = env->dregs[0];
|
1878 | e6e5906b | pbrook | env->pc += 2;
|
1879 | 5fafdf24 | ths | env->dregs[0] = do_syscall(env,
|
1880 | 5fafdf24 | ths | n, |
1881 | e6e5906b | pbrook | env->dregs[1],
|
1882 | e6e5906b | pbrook | env->dregs[2],
|
1883 | e6e5906b | pbrook | env->dregs[3],
|
1884 | e6e5906b | pbrook | env->dregs[4],
|
1885 | e6e5906b | pbrook | env->dregs[5],
|
1886 | bb7ec043 | pbrook | env->aregs[0]);
|
1887 | e6e5906b | pbrook | } |
1888 | e6e5906b | pbrook | break;
|
1889 | e6e5906b | pbrook | case EXCP_INTERRUPT:
|
1890 | e6e5906b | pbrook | /* just indicate that signals should be handled asap */
|
1891 | e6e5906b | pbrook | break;
|
1892 | e6e5906b | pbrook | case EXCP_ACCESS:
|
1893 | e6e5906b | pbrook | { |
1894 | e6e5906b | pbrook | info.si_signo = SIGSEGV; |
1895 | e6e5906b | pbrook | info.si_errno = 0;
|
1896 | e6e5906b | pbrook | /* XXX: check env->error_code */
|
1897 | e6e5906b | pbrook | info.si_code = TARGET_SEGV_MAPERR; |
1898 | e6e5906b | pbrook | info._sifields._sigfault._addr = env->mmu.ar; |
1899 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1900 | e6e5906b | pbrook | } |
1901 | e6e5906b | pbrook | break;
|
1902 | e6e5906b | pbrook | case EXCP_DEBUG:
|
1903 | e6e5906b | pbrook | { |
1904 | e6e5906b | pbrook | int sig;
|
1905 | e6e5906b | pbrook | |
1906 | e6e5906b | pbrook | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1907 | e6e5906b | pbrook | if (sig)
|
1908 | e6e5906b | pbrook | { |
1909 | e6e5906b | pbrook | info.si_signo = sig; |
1910 | e6e5906b | pbrook | info.si_errno = 0;
|
1911 | e6e5906b | pbrook | info.si_code = TARGET_TRAP_BRKPT; |
1912 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
1913 | e6e5906b | pbrook | } |
1914 | e6e5906b | pbrook | } |
1915 | e6e5906b | pbrook | break;
|
1916 | e6e5906b | pbrook | default:
|
1917 | 5fafdf24 | ths | fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
|
1918 | e6e5906b | pbrook | trapnr); |
1919 | e6e5906b | pbrook | cpu_dump_state(env, stderr, fprintf, 0);
|
1920 | e6e5906b | pbrook | abort(); |
1921 | e6e5906b | pbrook | } |
1922 | e6e5906b | pbrook | process_pending_signals(env); |
1923 | e6e5906b | pbrook | } |
1924 | e6e5906b | pbrook | } |
1925 | e6e5906b | pbrook | #endif /* TARGET_M68K */ |
1926 | e6e5906b | pbrook | |
1927 | 7a3148a9 | j_mayer | #ifdef TARGET_ALPHA
|
1928 | 7a3148a9 | j_mayer | void cpu_loop (CPUState *env)
|
1929 | 7a3148a9 | j_mayer | { |
1930 | e96efcfc | j_mayer | int trapnr;
|
1931 | 7a3148a9 | j_mayer | target_siginfo_t info; |
1932 | 3b46e624 | ths | |
1933 | 7a3148a9 | j_mayer | while (1) { |
1934 | 7a3148a9 | j_mayer | trapnr = cpu_alpha_exec (env); |
1935 | 3b46e624 | ths | |
1936 | 7a3148a9 | j_mayer | switch (trapnr) {
|
1937 | 7a3148a9 | j_mayer | case EXCP_RESET:
|
1938 | 7a3148a9 | j_mayer | fprintf(stderr, "Reset requested. Exit\n");
|
1939 | 7a3148a9 | j_mayer | exit(1);
|
1940 | 7a3148a9 | j_mayer | break;
|
1941 | 7a3148a9 | j_mayer | case EXCP_MCHK:
|
1942 | 7a3148a9 | j_mayer | fprintf(stderr, "Machine check exception. Exit\n");
|
1943 | 7a3148a9 | j_mayer | exit(1);
|
1944 | 7a3148a9 | j_mayer | break;
|
1945 | 7a3148a9 | j_mayer | case EXCP_ARITH:
|
1946 | 7a3148a9 | j_mayer | fprintf(stderr, "Arithmetic trap.\n");
|
1947 | 7a3148a9 | j_mayer | exit(1);
|
1948 | 7a3148a9 | j_mayer | break;
|
1949 | 7a3148a9 | j_mayer | case EXCP_HW_INTERRUPT:
|
1950 | 5fafdf24 | ths | fprintf(stderr, "External interrupt. Exit\n");
|
1951 | 7a3148a9 | j_mayer | exit(1);
|
1952 | 7a3148a9 | j_mayer | break;
|
1953 | 7a3148a9 | j_mayer | case EXCP_DFAULT:
|
1954 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data fault\n");
|
1955 | 7a3148a9 | j_mayer | exit(1);
|
1956 | 7a3148a9 | j_mayer | break;
|
1957 | 7a3148a9 | j_mayer | case EXCP_DTB_MISS_PAL:
|
1958 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data TLB miss in PALcode\n");
|
1959 | 7a3148a9 | j_mayer | exit(1);
|
1960 | 7a3148a9 | j_mayer | break;
|
1961 | 7a3148a9 | j_mayer | case EXCP_ITB_MISS:
|
1962 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU instruction TLB miss\n");
|
1963 | 7a3148a9 | j_mayer | exit(1);
|
1964 | 7a3148a9 | j_mayer | break;
|
1965 | 7a3148a9 | j_mayer | case EXCP_ITB_ACV:
|
1966 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU instruction access violation\n");
|
1967 | 7a3148a9 | j_mayer | exit(1);
|
1968 | 7a3148a9 | j_mayer | break;
|
1969 | 7a3148a9 | j_mayer | case EXCP_DTB_MISS_NATIVE:
|
1970 | 7a3148a9 | j_mayer | fprintf(stderr, "MMU data TLB miss\n");
|
1971 | 7a3148a9 | j_mayer | exit(1);
|
1972 | 7a3148a9 | j_mayer | break;
|
1973 | 7a3148a9 | j_mayer | case EXCP_UNALIGN:
|
1974 | 7a3148a9 | j_mayer | fprintf(stderr, "Unaligned access\n");
|
1975 | 7a3148a9 | j_mayer | exit(1);
|
1976 | 7a3148a9 | j_mayer | break;
|
1977 | 7a3148a9 | j_mayer | case EXCP_OPCDEC:
|
1978 | 7a3148a9 | j_mayer | fprintf(stderr, "Invalid instruction\n");
|
1979 | 7a3148a9 | j_mayer | exit(1);
|
1980 | 7a3148a9 | j_mayer | break;
|
1981 | 7a3148a9 | j_mayer | case EXCP_FEN:
|
1982 | 7a3148a9 | j_mayer | fprintf(stderr, "Floating-point not allowed\n");
|
1983 | 7a3148a9 | j_mayer | exit(1);
|
1984 | 7a3148a9 | j_mayer | break;
|
1985 | 7a3148a9 | j_mayer | case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1): |
1986 | 7a3148a9 | j_mayer | fprintf(stderr, "Call to PALcode\n");
|
1987 | 7a3148a9 | j_mayer | call_pal(env, (trapnr >> 6) | 0x80); |
1988 | 7a3148a9 | j_mayer | break;
|
1989 | 7a3148a9 | j_mayer | case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1): |
1990 | 7f75ffd3 | blueswir1 | fprintf(stderr, "Privileged call to PALcode\n");
|
1991 | 7a3148a9 | j_mayer | exit(1);
|
1992 | 7a3148a9 | j_mayer | break;
|
1993 | 7a3148a9 | j_mayer | case EXCP_DEBUG:
|
1994 | 7a3148a9 | j_mayer | { |
1995 | 7a3148a9 | j_mayer | int sig;
|
1996 | 7a3148a9 | j_mayer | |
1997 | 7a3148a9 | j_mayer | sig = gdb_handlesig (env, TARGET_SIGTRAP); |
1998 | 7a3148a9 | j_mayer | if (sig)
|
1999 | 7a3148a9 | j_mayer | { |
2000 | 7a3148a9 | j_mayer | info.si_signo = sig; |
2001 | 7a3148a9 | j_mayer | info.si_errno = 0;
|
2002 | 7a3148a9 | j_mayer | info.si_code = TARGET_TRAP_BRKPT; |
2003 | 624f7979 | pbrook | queue_signal(env, info.si_signo, &info); |
2004 | 7a3148a9 | j_mayer | } |
2005 | 7a3148a9 | j_mayer | } |
2006 | 7a3148a9 | j_mayer | break;
|
2007 | 7a3148a9 | j_mayer | default:
|
2008 | 7a3148a9 | j_mayer | printf ("Unhandled trap: 0x%x\n", trapnr);
|
2009 | 7a3148a9 | j_mayer | cpu_dump_state(env, stderr, fprintf, 0);
|
2010 | 7a3148a9 | j_mayer | exit (1);
|
2011 | 7a3148a9 | j_mayer | } |
2012 | 7a3148a9 | j_mayer | process_pending_signals (env); |
2013 | 7a3148a9 | j_mayer | } |
2014 | 7a3148a9 | j_mayer | } |
2015 | 7a3148a9 | j_mayer | #endif /* TARGET_ALPHA */ |
2016 | 7a3148a9 | j_mayer | |
2017 | 31e31b8a | bellard | void usage(void) |
2018 | 31e31b8a | bellard | { |
2019 | 68d0f70e | bellard | printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n" |
2020 | 68d0f70e | bellard | "usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n" |
2021 | b346ff46 | bellard | "Linux CPU emulator (compiled for %s emulation)\n"
|
2022 | d691f669 | bellard | "\n"
|
2023 | 68d0f70e | bellard | "Standard options:\n"
|
2024 | b12b6a18 | ths | "-h print this help\n"
|
2025 | b12b6a18 | ths | "-g port wait gdb connection to port\n"
|
2026 | b12b6a18 | ths | "-L path set the elf interpreter prefix (default=%s)\n"
|
2027 | b12b6a18 | ths | "-s size set the stack size in bytes (default=%ld)\n"
|
2028 | b12b6a18 | ths | "-cpu model select CPU (-cpu ? for list)\n"
|
2029 | b12b6a18 | ths | "-drop-ld-preload drop LD_PRELOAD for target process\n"
|
2030 | 54936004 | bellard | "\n"
|
2031 | 68d0f70e | bellard | "Debug options:\n"
|
2032 | 6f1f31c0 | bellard | "-d options activate log (logfile=%s)\n"
|
2033 | b6741956 | bellard | "-p pagesize set the host page size to 'pagesize'\n"
|
2034 | b01bcae6 | balrog | "-strace log system calls\n"
|
2035 | b01bcae6 | balrog | "\n"
|
2036 | 68d0f70e | bellard | "Environment variables:\n"
|
2037 | b01bcae6 | balrog | "QEMU_STRACE Print system calls and arguments similar to the\n"
|
2038 | b01bcae6 | balrog | " 'strace' program. Enable by setting to any value.\n"
|
2039 | b01bcae6 | balrog | , |
2040 | b346ff46 | bellard | TARGET_ARCH, |
2041 | 5fafdf24 | ths | interp_prefix, |
2042 | 54936004 | bellard | x86_stack_size, |
2043 | 54936004 | bellard | DEBUG_LOGFILE); |
2044 | 74cd30b8 | bellard | _exit(1);
|
2045 | 31e31b8a | bellard | } |
2046 | 31e31b8a | bellard | |
2047 | 9de5e440 | bellard | /* XXX: currently only used for async signals (see signal.c) */
|
2048 | b346ff46 | bellard | CPUState *global_env; |
2049 | 59faf6d6 | bellard | |
2050 | 624f7979 | pbrook | void init_task_state(TaskState *ts)
|
2051 | 624f7979 | pbrook | { |
2052 | 624f7979 | pbrook | int i;
|
2053 | 624f7979 | pbrook | |
2054 | 624f7979 | pbrook | memset(ts, 0, sizeof(TaskState)); |
2055 | 624f7979 | pbrook | ts->used = 1;
|
2056 | 624f7979 | pbrook | ts->first_free = ts->sigqueue_table; |
2057 | 624f7979 | pbrook | for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) { |
2058 | 624f7979 | pbrook | ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1];
|
2059 | 624f7979 | pbrook | } |
2060 | 624f7979 | pbrook | ts->sigqueue_table[i].next = NULL;
|
2061 | 624f7979 | pbrook | } |
2062 | 624f7979 | pbrook | |
2063 | 31e31b8a | bellard | int main(int argc, char **argv) |
2064 | 31e31b8a | bellard | { |
2065 | 31e31b8a | bellard | const char *filename; |
2066 | b1f9be31 | j_mayer | const char *cpu_model; |
2067 | 01ffc75b | bellard | struct target_pt_regs regs1, *regs = ®s1;
|
2068 | 31e31b8a | bellard | struct image_info info1, *info = &info1;
|
2069 | 851e67a1 | bellard | TaskState ts1, *ts = &ts1; |
2070 | b346ff46 | bellard | CPUState *env; |
2071 | 586314f2 | bellard | int optind;
|
2072 | d691f669 | bellard | const char *r; |
2073 | 74c33bed | bellard | int gdbstub_port = 0; |
2074 | b12b6a18 | ths | int drop_ld_preload = 0, environ_count = 0; |
2075 | b12b6a18 | ths | char **target_environ, **wrk, **dst;
|
2076 | b12b6a18 | ths | |
2077 | 31e31b8a | bellard | if (argc <= 1) |
2078 | 44de1b33 | pbrook | usage(); |
2079 | f801f97e | bellard | |
2080 | cc38b844 | bellard | /* init debug */
|
2081 | cc38b844 | bellard | cpu_set_log_filename(DEBUG_LOGFILE); |
2082 | cc38b844 | bellard | |
2083 | b1f9be31 | j_mayer | cpu_model = NULL;
|
2084 | 586314f2 | bellard | optind = 1;
|
2085 | d691f669 | bellard | for(;;) {
|
2086 | d691f669 | bellard | if (optind >= argc)
|
2087 | d691f669 | bellard | break;
|
2088 | d691f669 | bellard | r = argv[optind]; |
2089 | d691f669 | bellard | if (r[0] != '-') |
2090 | d691f669 | bellard | break;
|
2091 | 586314f2 | bellard | optind++; |
2092 | d691f669 | bellard | r++; |
2093 | d691f669 | bellard | if (!strcmp(r, "-")) { |
2094 | d691f669 | bellard | break;
|
2095 | d691f669 | bellard | } else if (!strcmp(r, "d")) { |
2096 | e19e89a5 | bellard | int mask;
|
2097 | e19e89a5 | bellard | CPULogItem *item; |
2098 | 6f1f31c0 | bellard | |
2099 | 6f1f31c0 | bellard | if (optind >= argc)
|
2100 | 6f1f31c0 | bellard | break;
|
2101 | 3b46e624 | ths | |
2102 | 6f1f31c0 | bellard | r = argv[optind++]; |
2103 | 6f1f31c0 | bellard | mask = cpu_str_to_log_mask(r); |
2104 | e19e89a5 | bellard | if (!mask) {
|
2105 | e19e89a5 | bellard | printf("Log items (comma separated):\n");
|
2106 | e19e89a5 | bellard | for(item = cpu_log_items; item->mask != 0; item++) { |
2107 | e19e89a5 | bellard | printf("%-10s %s\n", item->name, item->help);
|
2108 | e19e89a5 | bellard | } |
2109 | e19e89a5 | bellard | exit(1);
|
2110 | e19e89a5 | bellard | } |
2111 | e19e89a5 | bellard | cpu_set_log(mask); |
2112 | d691f669 | bellard | } else if (!strcmp(r, "s")) { |
2113 | d691f669 | bellard | r = argv[optind++]; |
2114 | d691f669 | bellard | x86_stack_size = strtol(r, (char **)&r, 0); |
2115 | d691f669 | bellard | if (x86_stack_size <= 0) |
2116 | 44de1b33 | pbrook | usage(); |
2117 | d691f669 | bellard | if (*r == 'M') |
2118 | d691f669 | bellard | x86_stack_size *= 1024 * 1024; |
2119 | d691f669 | bellard | else if (*r == 'k' || *r == 'K') |
2120 | d691f669 | bellard | x86_stack_size *= 1024;
|
2121 | d691f669 | bellard | } else if (!strcmp(r, "L")) { |
2122 | d691f669 | bellard | interp_prefix = argv[optind++]; |
2123 | 54936004 | bellard | } else if (!strcmp(r, "p")) { |
2124 | 83fb7adf | bellard | qemu_host_page_size = atoi(argv[optind++]); |
2125 | 83fb7adf | bellard | if (qemu_host_page_size == 0 || |
2126 | 83fb7adf | bellard | (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { |
2127 | 54936004 | bellard | fprintf(stderr, "page size must be a power of two\n");
|
2128 | 54936004 | bellard | exit(1);
|
2129 | 54936004 | bellard | } |
2130 | 1fddef4b | bellard | } else if (!strcmp(r, "g")) { |
2131 | 74c33bed | bellard | gdbstub_port = atoi(argv[optind++]); |
2132 | c5937220 | pbrook | } else if (!strcmp(r, "r")) { |
2133 | c5937220 | pbrook | qemu_uname_release = argv[optind++]; |
2134 | b1f9be31 | j_mayer | } else if (!strcmp(r, "cpu")) { |
2135 | b1f9be31 | j_mayer | cpu_model = argv[optind++]; |
2136 | b1f9be31 | j_mayer | if (strcmp(cpu_model, "?") == 0) { |
2137 | c732abe2 | j_mayer | /* XXX: implement xxx_cpu_list for targets that still miss it */
|
2138 | c732abe2 | j_mayer | #if defined(cpu_list)
|
2139 | c732abe2 | j_mayer | cpu_list(stdout, &fprintf); |
2140 | b1f9be31 | j_mayer | #endif
|
2141 | cff4cbed | ths | _exit(1);
|
2142 | b1f9be31 | j_mayer | } |
2143 | b12b6a18 | ths | } else if (!strcmp(r, "drop-ld-preload")) { |
2144 | b12b6a18 | ths | drop_ld_preload = 1;
|
2145 | b6741956 | bellard | } else if (!strcmp(r, "strace")) { |
2146 | b6741956 | bellard | do_strace = 1;
|
2147 | 5fafdf24 | ths | } else
|
2148 | c6981055 | bellard | { |
2149 | d691f669 | bellard | usage(); |
2150 | d691f669 | bellard | } |
2151 | 586314f2 | bellard | } |
2152 | d691f669 | bellard | if (optind >= argc)
|
2153 | d691f669 | bellard | usage(); |
2154 | 586314f2 | bellard | filename = argv[optind]; |
2155 | 586314f2 | bellard | |
2156 | 31e31b8a | bellard | /* Zero out regs */
|
2157 | 01ffc75b | bellard | memset(regs, 0, sizeof(struct target_pt_regs)); |
2158 | 31e31b8a | bellard | |
2159 | 31e31b8a | bellard | /* Zero out image_info */
|
2160 | 31e31b8a | bellard | memset(info, 0, sizeof(struct image_info)); |
2161 | 31e31b8a | bellard | |
2162 | 74cd30b8 | bellard | /* Scan interp_prefix dir for replacement files. */
|
2163 | 74cd30b8 | bellard | init_paths(interp_prefix); |
2164 | 74cd30b8 | bellard | |
2165 | 46027c07 | bellard | if (cpu_model == NULL) { |
2166 | aaed909a | bellard | #if defined(TARGET_I386)
|
2167 | 46027c07 | bellard | #ifdef TARGET_X86_64
|
2168 | 46027c07 | bellard | cpu_model = "qemu64";
|
2169 | 46027c07 | bellard | #else
|
2170 | 46027c07 | bellard | cpu_model = "qemu32";
|
2171 | 46027c07 | bellard | #endif
|
2172 | aaed909a | bellard | #elif defined(TARGET_ARM)
|
2173 | aaed909a | bellard | cpu_model = "arm926";
|
2174 | aaed909a | bellard | #elif defined(TARGET_M68K)
|
2175 | aaed909a | bellard | cpu_model = "any";
|
2176 | aaed909a | bellard | #elif defined(TARGET_SPARC)
|
2177 | aaed909a | bellard | #ifdef TARGET_SPARC64
|
2178 | aaed909a | bellard | cpu_model = "TI UltraSparc II";
|
2179 | aaed909a | bellard | #else
|
2180 | aaed909a | bellard | cpu_model = "Fujitsu MB86904";
|
2181 | 46027c07 | bellard | #endif
|
2182 | aaed909a | bellard | #elif defined(TARGET_MIPS)
|
2183 | aaed909a | bellard | #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)
|
2184 | aaed909a | bellard | cpu_model = "20Kc";
|
2185 | aaed909a | bellard | #else
|
2186 | aaed909a | bellard | cpu_model = "24Kf";
|
2187 | aaed909a | bellard | #endif
|
2188 | aaed909a | bellard | #elif defined(TARGET_PPC)
|
2189 | 7ded4f52 | bellard | #ifdef TARGET_PPC64
|
2190 | 7ded4f52 | bellard | cpu_model = "970";
|
2191 | 7ded4f52 | bellard | #else
|
2192 | aaed909a | bellard | cpu_model = "750";
|
2193 | 7ded4f52 | bellard | #endif
|
2194 | aaed909a | bellard | #else
|
2195 | aaed909a | bellard | cpu_model = "any";
|
2196 | aaed909a | bellard | #endif
|
2197 | aaed909a | bellard | } |
2198 | 26a5f13b | bellard | cpu_exec_init_all(0);
|
2199 | 83fb7adf | bellard | /* NOTE: we need to init the CPU at this stage to get
|
2200 | 83fb7adf | bellard | qemu_host_page_size */
|
2201 | aaed909a | bellard | env = cpu_init(cpu_model); |
2202 | aaed909a | bellard | if (!env) {
|
2203 | aaed909a | bellard | fprintf(stderr, "Unable to find CPU definition\n");
|
2204 | aaed909a | bellard | exit(1);
|
2205 | aaed909a | bellard | } |
2206 | 15338fd7 | bellard | global_env = env; |
2207 | 3b46e624 | ths | |
2208 | b6741956 | bellard | if (getenv("QEMU_STRACE")) { |
2209 | b6741956 | bellard | do_strace = 1;
|
2210 | b92c47c1 | ths | } |
2211 | b92c47c1 | ths | |
2212 | b12b6a18 | ths | wrk = environ; |
2213 | b12b6a18 | ths | while (*(wrk++))
|
2214 | b12b6a18 | ths | environ_count++; |
2215 | b12b6a18 | ths | |
2216 | b12b6a18 | ths | target_environ = malloc((environ_count + 1) * sizeof(char *)); |
2217 | b12b6a18 | ths | if (!target_environ)
|
2218 | b12b6a18 | ths | abort(); |
2219 | b12b6a18 | ths | for (wrk = environ, dst = target_environ; *wrk; wrk++) {
|
2220 | b12b6a18 | ths | if (drop_ld_preload && !strncmp(*wrk, "LD_PRELOAD=", 11)) |
2221 | b12b6a18 | ths | continue;
|
2222 | b12b6a18 | ths | *(dst++) = strdup(*wrk); |
2223 | b12b6a18 | ths | } |
2224 | 403f14ef | ths | *dst = NULL; /* NULL terminate target_environ */ |
2225 | b12b6a18 | ths | |
2226 | b12b6a18 | ths | if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) { |
2227 | b12b6a18 | ths | printf("Error loading %s\n", filename);
|
2228 | b12b6a18 | ths | _exit(1);
|
2229 | b12b6a18 | ths | } |
2230 | b12b6a18 | ths | |
2231 | b12b6a18 | ths | for (wrk = target_environ; *wrk; wrk++) {
|
2232 | b12b6a18 | ths | free(*wrk); |
2233 | 31e31b8a | bellard | } |
2234 | 3b46e624 | ths | |
2235 | b12b6a18 | ths | free(target_environ); |
2236 | b12b6a18 | ths | |
2237 | 4b74fe1f | bellard | if (loglevel) {
|
2238 | 54936004 | bellard | page_dump(logfile); |
2239 | 3b46e624 | ths | |
2240 | 8a4ed7ef | bellard | fprintf(logfile, "start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); |
2241 | 8a4ed7ef | bellard | fprintf(logfile, "end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); |
2242 | 8a4ed7ef | bellard | fprintf(logfile, "start_code 0x" TARGET_ABI_FMT_lx "\n", |
2243 | 3d177870 | j_mayer | info->start_code); |
2244 | 8a4ed7ef | bellard | fprintf(logfile, "start_data 0x" TARGET_ABI_FMT_lx "\n", |
2245 | 3d177870 | j_mayer | info->start_data); |
2246 | 8a4ed7ef | bellard | fprintf(logfile, "end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); |
2247 | 8a4ed7ef | bellard | fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n", |
2248 | 3d177870 | j_mayer | info->start_stack); |
2249 | 8a4ed7ef | bellard | fprintf(logfile, "brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); |
2250 | 8a4ed7ef | bellard | fprintf(logfile, "entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); |
2251 | 4b74fe1f | bellard | } |
2252 | 31e31b8a | bellard | |
2253 | 53a5960a | pbrook | target_set_brk(info->brk); |
2254 | 31e31b8a | bellard | syscall_init(); |
2255 | 66fb9763 | bellard | signal_init(); |
2256 | 31e31b8a | bellard | |
2257 | 851e67a1 | bellard | /* build Task State */
|
2258 | 851e67a1 | bellard | memset(ts, 0, sizeof(TaskState)); |
2259 | 624f7979 | pbrook | init_task_state(ts); |
2260 | 978efd6a | pbrook | ts->info = info; |
2261 | 624f7979 | pbrook | env->opaque = ts; |
2262 | 59faf6d6 | bellard | env->user_mode_only = 1;
|
2263 | 3b46e624 | ths | |
2264 | b346ff46 | bellard | #if defined(TARGET_I386)
|
2265 | 2e255c6b | bellard | cpu_x86_set_cpl(env, 3);
|
2266 | 2e255c6b | bellard | |
2267 | 3802ce26 | bellard | env->cr[0] = CR0_PG_MASK | CR0_WP_MASK | CR0_PE_MASK;
|
2268 | 1bde465e | bellard | env->hflags |= HF_PE_MASK; |
2269 | 1bde465e | bellard | if (env->cpuid_features & CPUID_SSE) {
|
2270 | 1bde465e | bellard | env->cr[4] |= CR4_OSFXSR_MASK;
|
2271 | 1bde465e | bellard | env->hflags |= HF_OSFXSR_MASK; |
2272 | 1bde465e | bellard | } |
2273 | d2fd1af7 | bellard | #ifndef TARGET_ABI32
|
2274 | 4dbc422b | bellard | /* enable 64 bit mode if possible */
|
2275 | 4dbc422b | bellard | if (!(env->cpuid_ext2_features & CPUID_EXT2_LM)) {
|
2276 | 4dbc422b | bellard | fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
|
2277 | 4dbc422b | bellard | exit(1);
|
2278 | 4dbc422b | bellard | } |
2279 | d2fd1af7 | bellard | env->cr[4] |= CR4_PAE_MASK;
|
2280 | 4dbc422b | bellard | env->efer |= MSR_EFER_LMA | MSR_EFER_LME; |
2281 | d2fd1af7 | bellard | env->hflags |= HF_LMA_MASK; |
2282 | d2fd1af7 | bellard | #endif
|
2283 | 1bde465e | bellard | |
2284 | 415e561f | bellard | /* flags setup : we activate the IRQs by default as in user mode */
|
2285 | 415e561f | bellard | env->eflags |= IF_MASK; |
2286 | 3b46e624 | ths | |
2287 | 6dbad63e | bellard | /* linux register setup */
|
2288 | d2fd1af7 | bellard | #ifndef TARGET_ABI32
|
2289 | 84409ddb | j_mayer | env->regs[R_EAX] = regs->rax; |
2290 | 84409ddb | j_mayer | env->regs[R_EBX] = regs->rbx; |
2291 | 84409ddb | j_mayer | env->regs[R_ECX] = regs->rcx; |
2292 | 84409ddb | j_mayer | env->regs[R_EDX] = regs->rdx; |
2293 | 84409ddb | j_mayer | env->regs[R_ESI] = regs->rsi; |
2294 | 84409ddb | j_mayer | env->regs[R_EDI] = regs->rdi; |
2295 | 84409ddb | j_mayer | env->regs[R_EBP] = regs->rbp; |
2296 | 84409ddb | j_mayer | env->regs[R_ESP] = regs->rsp; |
2297 | 84409ddb | j_mayer | env->eip = regs->rip; |
2298 | 84409ddb | j_mayer | #else
|
2299 | 0ecfa993 | bellard | env->regs[R_EAX] = regs->eax; |
2300 | 0ecfa993 | bellard | env->regs[R_EBX] = regs->ebx; |
2301 | 0ecfa993 | bellard | env->regs[R_ECX] = regs->ecx; |
2302 | 0ecfa993 | bellard | env->regs[R_EDX] = regs->edx; |
2303 | 0ecfa993 | bellard | env->regs[R_ESI] = regs->esi; |
2304 | 0ecfa993 | bellard | env->regs[R_EDI] = regs->edi; |
2305 | 0ecfa993 | bellard | env->regs[R_EBP] = regs->ebp; |
2306 | 0ecfa993 | bellard | env->regs[R_ESP] = regs->esp; |
2307 | dab2ed99 | bellard | env->eip = regs->eip; |
2308 | 84409ddb | j_mayer | #endif
|
2309 | 31e31b8a | bellard | |
2310 | f4beb510 | bellard | /* linux interrupt setup */
|
2311 | 53a5960a | pbrook | env->idt.base = h2g(idt_table); |
2312 | f4beb510 | bellard | env->idt.limit = sizeof(idt_table) - 1; |
2313 | f4beb510 | bellard | set_idt(0, 0); |
2314 | f4beb510 | bellard | set_idt(1, 0); |
2315 | f4beb510 | bellard | set_idt(2, 0); |
2316 | f4beb510 | bellard | set_idt(3, 3); |
2317 | f4beb510 | bellard | set_idt(4, 3); |
2318 | ec95da6c | bellard | set_idt(5, 0); |
2319 | f4beb510 | bellard | set_idt(6, 0); |
2320 | f4beb510 | bellard | set_idt(7, 0); |
2321 | f4beb510 | bellard | set_idt(8, 0); |
2322 | f4beb510 | bellard | set_idt(9, 0); |
2323 | f4beb510 | bellard | set_idt(10, 0); |
2324 | f4beb510 | bellard | set_idt(11, 0); |
2325 | f4beb510 | bellard | set_idt(12, 0); |
2326 | f4beb510 | bellard | set_idt(13, 0); |
2327 | f4beb510 | bellard | set_idt(14, 0); |
2328 | f4beb510 | bellard | set_idt(15, 0); |
2329 | f4beb510 | bellard | set_idt(16, 0); |
2330 | f4beb510 | bellard | set_idt(17, 0); |
2331 | f4beb510 | bellard | set_idt(18, 0); |
2332 | f4beb510 | bellard | set_idt(19, 0); |
2333 | f4beb510 | bellard | set_idt(0x80, 3); |
2334 | f4beb510 | bellard | |
2335 | 6dbad63e | bellard | /* linux segment setup */
|
2336 | 8d18e893 | bellard | { |
2337 | 8d18e893 | bellard | uint64_t *gdt_table; |
2338 | 8d18e893 | bellard | gdt_table = qemu_mallocz(sizeof(uint64_t) * TARGET_GDT_ENTRIES);
|
2339 | d2fd1af7 | bellard | env->gdt.base = h2g((unsigned long)gdt_table); |
2340 | 8d18e893 | bellard | env->gdt.limit = sizeof(uint64_t) * TARGET_GDT_ENTRIES - 1; |
2341 | d2fd1af7 | bellard | #ifdef TARGET_ABI32
|
2342 | 8d18e893 | bellard | write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, |
2343 | 8d18e893 | bellard | DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | |
2344 | 8d18e893 | bellard | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); |
2345 | d2fd1af7 | bellard | #else
|
2346 | d2fd1af7 | bellard | /* 64 bit code segment */
|
2347 | d2fd1af7 | bellard | write_dt(&gdt_table[__USER_CS >> 3], 0, 0xfffff, |
2348 | d2fd1af7 | bellard | DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | |
2349 | d2fd1af7 | bellard | DESC_L_MASK | |
2350 | d2fd1af7 | bellard | (3 << DESC_DPL_SHIFT) | (0xa << DESC_TYPE_SHIFT)); |
2351 | d2fd1af7 | bellard | #endif
|
2352 | 8d18e893 | bellard | write_dt(&gdt_table[__USER_DS >> 3], 0, 0xfffff, |
2353 | 8d18e893 | bellard | DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | DESC_S_MASK | |
2354 | 8d18e893 | bellard | (3 << DESC_DPL_SHIFT) | (0x2 << DESC_TYPE_SHIFT)); |
2355 | 8d18e893 | bellard | } |
2356 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_CS, __USER_CS); |
2357 | d2fd1af7 | bellard | cpu_x86_load_seg(env, R_SS, __USER_DS); |
2358 | d2fd1af7 | bellard | #ifdef TARGET_ABI32
|
2359 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_DS, __USER_DS); |
2360 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_ES, __USER_DS); |
2361 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_FS, __USER_DS); |
2362 | 6dbad63e | bellard | cpu_x86_load_seg(env, R_GS, __USER_DS); |
2363 | d6eb40f6 | ths | /* This hack makes Wine work... */
|
2364 | d6eb40f6 | ths | env->segs[R_FS].selector = 0;
|
2365 | d2fd1af7 | bellard | #else
|
2366 | d2fd1af7 | bellard | cpu_x86_load_seg(env, R_DS, 0);
|
2367 | d2fd1af7 | bellard | cpu_x86_load_seg(env, R_ES, 0);
|
2368 | d2fd1af7 | bellard | cpu_x86_load_seg(env, R_FS, 0);
|
2369 | d2fd1af7 | bellard | cpu_x86_load_seg(env, R_GS, 0);
|
2370 | d2fd1af7 | bellard | #endif
|
2371 | b346ff46 | bellard | #elif defined(TARGET_ARM)
|
2372 | b346ff46 | bellard | { |
2373 | b346ff46 | bellard | int i;
|
2374 | b5ff1b31 | bellard | cpsr_write(env, regs->uregs[16], 0xffffffff); |
2375 | b346ff46 | bellard | for(i = 0; i < 16; i++) { |
2376 | b346ff46 | bellard | env->regs[i] = regs->uregs[i]; |
2377 | b346ff46 | bellard | } |
2378 | b346ff46 | bellard | } |
2379 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
2380 | 060366c5 | bellard | { |
2381 | 060366c5 | bellard | int i;
|
2382 | 060366c5 | bellard | env->pc = regs->pc; |
2383 | 060366c5 | bellard | env->npc = regs->npc; |
2384 | 060366c5 | bellard | env->y = regs->y; |
2385 | 060366c5 | bellard | for(i = 0; i < 8; i++) |
2386 | 060366c5 | bellard | env->gregs[i] = regs->u_regs[i]; |
2387 | 060366c5 | bellard | for(i = 0; i < 8; i++) |
2388 | 060366c5 | bellard | env->regwptr[i] = regs->u_regs[i + 8];
|
2389 | 060366c5 | bellard | } |
2390 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
2391 | 67867308 | bellard | { |
2392 | 67867308 | bellard | int i;
|
2393 | 3fc6c082 | bellard | |
2394 | 0411a972 | j_mayer | #if defined(TARGET_PPC64)
|
2395 | 0411a972 | j_mayer | #if defined(TARGET_ABI32)
|
2396 | 0411a972 | j_mayer | env->msr &= ~((target_ulong)1 << MSR_SF);
|
2397 | e85e7c6e | j_mayer | #else
|
2398 | 0411a972 | j_mayer | env->msr |= (target_ulong)1 << MSR_SF;
|
2399 | 0411a972 | j_mayer | #endif
|
2400 | 84409ddb | j_mayer | #endif
|
2401 | 67867308 | bellard | env->nip = regs->nip; |
2402 | 67867308 | bellard | for(i = 0; i < 32; i++) { |
2403 | 67867308 | bellard | env->gpr[i] = regs->gpr[i]; |
2404 | 67867308 | bellard | } |
2405 | 67867308 | bellard | } |
2406 | e6e5906b | pbrook | #elif defined(TARGET_M68K)
|
2407 | e6e5906b | pbrook | { |
2408 | e6e5906b | pbrook | env->pc = regs->pc; |
2409 | e6e5906b | pbrook | env->dregs[0] = regs->d0;
|
2410 | e6e5906b | pbrook | env->dregs[1] = regs->d1;
|
2411 | e6e5906b | pbrook | env->dregs[2] = regs->d2;
|
2412 | e6e5906b | pbrook | env->dregs[3] = regs->d3;
|
2413 | e6e5906b | pbrook | env->dregs[4] = regs->d4;
|
2414 | e6e5906b | pbrook | env->dregs[5] = regs->d5;
|
2415 | e6e5906b | pbrook | env->dregs[6] = regs->d6;
|
2416 | e6e5906b | pbrook | env->dregs[7] = regs->d7;
|
2417 | e6e5906b | pbrook | env->aregs[0] = regs->a0;
|
2418 | e6e5906b | pbrook | env->aregs[1] = regs->a1;
|
2419 | e6e5906b | pbrook | env->aregs[2] = regs->a2;
|
2420 | e6e5906b | pbrook | env->aregs[3] = regs->a3;
|
2421 | e6e5906b | pbrook | env->aregs[4] = regs->a4;
|
2422 | e6e5906b | pbrook | env->aregs[5] = regs->a5;
|
2423 | e6e5906b | pbrook | env->aregs[6] = regs->a6;
|
2424 | e6e5906b | pbrook | env->aregs[7] = regs->usp;
|
2425 | e6e5906b | pbrook | env->sr = regs->sr; |
2426 | e6e5906b | pbrook | ts->sim_syscalls = 1;
|
2427 | e6e5906b | pbrook | } |
2428 | 048f6b4d | bellard | #elif defined(TARGET_MIPS)
|
2429 | 048f6b4d | bellard | { |
2430 | 048f6b4d | bellard | int i;
|
2431 | 048f6b4d | bellard | |
2432 | 048f6b4d | bellard | for(i = 0; i < 32; i++) { |
2433 | d0dc7dc3 | ths | env->gpr[env->current_tc][i] = regs->regs[i]; |
2434 | 048f6b4d | bellard | } |
2435 | ead9360e | ths | env->PC[env->current_tc] = regs->cp0_epc; |
2436 | 048f6b4d | bellard | } |
2437 | fdf9b3e8 | bellard | #elif defined(TARGET_SH4)
|
2438 | fdf9b3e8 | bellard | { |
2439 | fdf9b3e8 | bellard | int i;
|
2440 | fdf9b3e8 | bellard | |
2441 | fdf9b3e8 | bellard | for(i = 0; i < 16; i++) { |
2442 | fdf9b3e8 | bellard | env->gregs[i] = regs->regs[i]; |
2443 | fdf9b3e8 | bellard | } |
2444 | fdf9b3e8 | bellard | env->pc = regs->pc; |
2445 | fdf9b3e8 | bellard | } |
2446 | 7a3148a9 | j_mayer | #elif defined(TARGET_ALPHA)
|
2447 | 7a3148a9 | j_mayer | { |
2448 | 7a3148a9 | j_mayer | int i;
|
2449 | 7a3148a9 | j_mayer | |
2450 | 7a3148a9 | j_mayer | for(i = 0; i < 28; i++) { |
2451 | 992f48a0 | blueswir1 | env->ir[i] = ((abi_ulong *)regs)[i]; |
2452 | 7a3148a9 | j_mayer | } |
2453 | 7a3148a9 | j_mayer | env->ipr[IPR_USP] = regs->usp; |
2454 | 7a3148a9 | j_mayer | env->ir[30] = regs->usp;
|
2455 | 7a3148a9 | j_mayer | env->pc = regs->pc; |
2456 | 7a3148a9 | j_mayer | env->unique = regs->unique; |
2457 | 7a3148a9 | j_mayer | } |
2458 | 48733d19 | ths | #elif defined(TARGET_CRIS)
|
2459 | 48733d19 | ths | { |
2460 | 48733d19 | ths | env->regs[0] = regs->r0;
|
2461 | 48733d19 | ths | env->regs[1] = regs->r1;
|
2462 | 48733d19 | ths | env->regs[2] = regs->r2;
|
2463 | 48733d19 | ths | env->regs[3] = regs->r3;
|
2464 | 48733d19 | ths | env->regs[4] = regs->r4;
|
2465 | 48733d19 | ths | env->regs[5] = regs->r5;
|
2466 | 48733d19 | ths | env->regs[6] = regs->r6;
|
2467 | 48733d19 | ths | env->regs[7] = regs->r7;
|
2468 | 48733d19 | ths | env->regs[8] = regs->r8;
|
2469 | 48733d19 | ths | env->regs[9] = regs->r9;
|
2470 | 48733d19 | ths | env->regs[10] = regs->r10;
|
2471 | 48733d19 | ths | env->regs[11] = regs->r11;
|
2472 | 48733d19 | ths | env->regs[12] = regs->r12;
|
2473 | 48733d19 | ths | env->regs[13] = regs->r13;
|
2474 | 48733d19 | ths | env->regs[14] = info->start_stack;
|
2475 | 48733d19 | ths | env->regs[15] = regs->acr;
|
2476 | 48733d19 | ths | env->pc = regs->erp; |
2477 | 48733d19 | ths | } |
2478 | b346ff46 | bellard | #else
|
2479 | b346ff46 | bellard | #error unsupported target CPU
|
2480 | b346ff46 | bellard | #endif
|
2481 | 31e31b8a | bellard | |
2482 | a87295e8 | pbrook | #if defined(TARGET_ARM) || defined(TARGET_M68K)
|
2483 | a87295e8 | pbrook | ts->stack_base = info->start_stack; |
2484 | a87295e8 | pbrook | ts->heap_base = info->brk; |
2485 | a87295e8 | pbrook | /* This will be filled in on the first SYS_HEAPINFO call. */
|
2486 | a87295e8 | pbrook | ts->heap_limit = 0;
|
2487 | a87295e8 | pbrook | #endif
|
2488 | a87295e8 | pbrook | |
2489 | 74c33bed | bellard | if (gdbstub_port) {
|
2490 | 74c33bed | bellard | gdbserver_start (gdbstub_port); |
2491 | 1fddef4b | bellard | gdb_handlesig(env, 0);
|
2492 | 1fddef4b | bellard | } |
2493 | 1b6b029e | bellard | cpu_loop(env); |
2494 | 1b6b029e | bellard | /* never exits */
|
2495 | 31e31b8a | bellard | return 0; |
2496 | 31e31b8a | bellard | } |