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