]>
git.proxmox.com Git - mirror_qemu.git/blob - linux-user/openrisc/cpu_loop.c
4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
23 #include "user-internals.h"
24 #include "cpu_loop-common.h"
25 #include "signal-common.h"
27 void cpu_loop(CPUOpenRISCState
*env
)
29 CPUState
*cs
= env_cpu(env
);
32 target_siginfo_t info
;
36 trapnr
= cpu_exec(cs
);
38 process_queued_cpu_work(cs
);
42 env
->pc
+= 4; /* 0xc00; */
44 cpu_get_gpr(env
, 11), /* return value */
45 cpu_get_gpr(env
, 3), /* r3 - r7 are params */
50 cpu_get_gpr(env
, 8), 0, 0);
51 if (ret
== -TARGET_ERESTARTSYS
) {
53 } else if (ret
!= -TARGET_QEMU_ESIGRETURN
) {
54 cpu_set_gpr(env
, 11, ret
);
59 info
.si_signo
= TARGET_SIGSEGV
;
61 info
.si_code
= TARGET_SEGV_MAPERR
;
62 info
._sifields
._sigfault
._addr
= env
->pc
;
63 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
66 info
.si_signo
= TARGET_SIGBUS
;
68 info
.si_code
= TARGET_BUS_ADRALN
;
69 info
._sifields
._sigfault
._addr
= env
->pc
;
70 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
73 info
.si_signo
= TARGET_SIGILL
;
75 info
.si_code
= TARGET_ILL_ILLOPC
;
76 info
._sifields
._sigfault
._addr
= env
->pc
;
77 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
80 /* We processed the pending cpu work above. */
83 info
.si_signo
= TARGET_SIGTRAP
;
85 info
.si_code
= TARGET_TRAP_BRKPT
;
86 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
89 cpu_exec_step_atomic(cs
);
92 /* Requires SR.OVE set, which linux-user won't do. */
93 cpu_abort(cs
, "Unexpected RANGE exception");
96 * Requires FPSCR.FPEE set. Writes to FPSCR from usermode not
97 * yet enabled in kernel ABI, so linux-user does not either.
99 cpu_abort(cs
, "Unexpected FPE exception");
101 g_assert_not_reached();
103 process_pending_signals(env
);
107 void target_cpu_copy_regs(CPUArchState
*env
, struct target_pt_regs
*regs
)
111 for (i
= 0; i
< 32; i
++) {
112 cpu_set_gpr(env
, i
, regs
->gpr
[i
]);
115 cpu_set_sr(env
, regs
->sr
);