1 /*
2 * Altera Nios II helper routines.
3 *
4 * Copyright (C) 2012 Chris Wulff <crwulff@gmail.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library 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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/lgpl-2.1.html>
19 */
20
21 #include "qemu/osdep.h"
22 #include "cpu.h"
23 #include "exec/helper-proto.h"
24 #include "exec/cpu_ldst.h"
25 #include "exec/exec-all.h"
26 #include "qemu/main-loop.h"
27
28 #if !defined(CONFIG_USER_ONLY)
helper_mmu_read_debug(CPUNios2State * env,uint32_t rn)29 void helper_mmu_read_debug(CPUNios2State *env, uint32_t rn)
30 {
31 mmu_read_debug(env, rn);
32 }
33
helper_mmu_write(CPUNios2State * env,uint32_t rn,uint32_t v)34 void helper_mmu_write(CPUNios2State *env, uint32_t rn, uint32_t v)
35 {
36 mmu_write(env, rn, v);
37 }
38
nios2_check_interrupts(CPUNios2State * env)39 static void nios2_check_interrupts(CPUNios2State *env)
40 {
41 if (env->irq_pending &&
42 (env->regs[CR_STATUS] & CR_STATUS_PIE)) {
43 env->irq_pending = 0;
44 cpu_interrupt(env_cpu(env), CPU_INTERRUPT_HARD);
45 }
46 }
47
helper_check_interrupts(CPUNios2State * env)48 void helper_check_interrupts(CPUNios2State *env)
49 {
50 qemu_mutex_lock_iothread();
51 nios2_check_interrupts(env);
52 qemu_mutex_unlock_iothread();
53 }
54 #endif /* !CONFIG_USER_ONLY */
55
helper_raise_exception(CPUNios2State * env,uint32_t index)56 void helper_raise_exception(CPUNios2State *env, uint32_t index)
57 {
58 CPUState *cs = env_cpu(env);
59 cs->exception_index = index;
60 cpu_loop_exit(cs);
61 }
62