4 * Copyright (c) 2007 CodeSourcery
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 of the License, or (at your option) any later version.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #if defined(CONFIG_USER_ONLY)
24 void do_interrupt(int is_hw)
26 env->exception_index = -1;
31 #define MMUSUFFIX _mmu
32 #define GETPC() (__builtin_return_address(0))
35 #include "softmmu_template.h"
38 #include "softmmu_template.h"
41 #include "softmmu_template.h"
44 #include "softmmu_template.h"
46 /* Try to fill the TLB and return an exception if error. If retaddr is
47 NULL, it means that the function was called in C code (i.e. not
48 from generated code or from helper.c) */
49 /* XXX: fix it to restore all registers */
50 void tlb_fill (target_ulong addr, int is_write, int is_user, void *retaddr)
54 target_phys_addr_t pc;
57 /* XXX: hack to restore env in all cases, even if not called from
61 ret = cpu_m68k_handle_mmu_fault(env, addr, is_write, is_user, 1);
62 if (__builtin_expect(ret, 0)) {
64 /* now we have a real cpu fault */
65 pc = (target_phys_addr_t)retaddr;
68 /* the PC is inside the translated code. It means that we have
69 a virtual CPU fault */
70 cpu_restore_state(tb, env, pc, NULL);
78 static void do_rte(void)
85 env->pc = ldl_kernel(sp + 4);
86 sp |= (fmt >> 28) & 3;
87 env->sr = fmt & 0xffff;
88 env->aregs[7] = sp + 8;
91 void do_interrupt(int is_hw)
102 switch (env->exception_index) {
104 /* Return from an exception. */
108 if (env->exception_index >= EXCP_TRAP0
109 && env->exception_index <= EXCP_TRAP15) {
110 /* Move the PC after the trap instruction. */
115 /* TODO: Implement USP. */
118 vector = env->exception_index << 2;
121 fmt |= (sp & 3) << 28;
125 /* ??? This could cause MMU faults. */
128 stl_kernel(sp, retaddr);
134 env->sr = (env->sr & ~SR_I) | (env->pending_level << SR_I_SHIFT);
136 /* Jump to vector. */
137 env->pc = ldl_kernel(env->vbr + vector);