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 "cpu_loop-common.h"
25 void cpu_loop(CPUOpenRISCState
*env
)
27 CPUState
*cs
= env_cpu(env
);
30 target_siginfo_t info
;
34 trapnr
= cpu_exec(cs
);
36 process_queued_cpu_work(cs
);
40 env
->pc
+= 4; /* 0xc00; */
42 cpu_get_gpr(env
, 11), /* return value */
43 cpu_get_gpr(env
, 3), /* r3 - r7 are params */
48 cpu_get_gpr(env
, 8), 0, 0);
49 if (ret
== -TARGET_ERESTARTSYS
) {
51 } else if (ret
!= -TARGET_QEMU_ESIGRETURN
) {
52 cpu_set_gpr(env
, 11, ret
);
58 info
.si_signo
= TARGET_SIGSEGV
;
60 info
.si_code
= TARGET_SEGV_MAPERR
;
61 info
._sifields
._sigfault
._addr
= env
->pc
;
62 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
65 info
.si_signo
= TARGET_SIGBUS
;
67 info
.si_code
= TARGET_BUS_ADRALN
;
68 info
._sifields
._sigfault
._addr
= env
->pc
;
69 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
72 info
.si_signo
= TARGET_SIGILL
;
74 info
.si_code
= TARGET_ILL_ILLOPC
;
75 info
._sifields
._sigfault
._addr
= env
->pc
;
76 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
79 info
.si_signo
= TARGET_SIGFPE
;
82 info
._sifields
._sigfault
._addr
= env
->pc
;
83 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
86 /* We processed the pending cpu work above. */
89 info
.si_signo
= TARGET_SIGTRAP
;
91 info
.si_code
= TARGET_TRAP_BRKPT
;
92 queue_signal(env
, info
.si_signo
, QEMU_SI_FAULT
, &info
);
95 cpu_exec_step_atomic(cs
);
98 g_assert_not_reached();
100 process_pending_signals(env
);
104 void target_cpu_copy_regs(CPUArchState
*env
, struct target_pt_regs
*regs
)
108 for (i
= 0; i
< 32; i
++) {
109 cpu_set_gpr(env
, i
, regs
->gpr
[i
]);
112 cpu_set_sr(env
, regs
->sr
);