Merge remote-tracking branch 'qemu/master'
[qemu/ar7.git] / target / alpha / mem_helper.c
blobf7502003be023d75c872a710e4445e4803992c9d
1 /*
2 * Helpers for loads and stores
4 * Copyright (c) 2007 Jocelyn Mayer
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, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "cpu.h"
22 #include "exec/helper-proto.h"
23 #include "exec/exec-all.h"
24 #include "exec/cpu_ldst.h"
26 /* Softmmu support */
27 #ifndef CONFIG_USER_ONLY
28 void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
29 MMUAccessType access_type,
30 int mmu_idx, uintptr_t retaddr)
32 AlphaCPU *cpu = ALPHA_CPU(cs);
33 CPUAlphaState *env = &cpu->env;
34 uint64_t pc;
35 uint32_t insn;
37 cpu_restore_state(cs, retaddr);
39 pc = env->pc;
40 insn = cpu_ldl_code(env, pc);
42 env->trap_arg0 = addr;
43 env->trap_arg1 = insn >> 26; /* opcode */
44 env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
45 cs->exception_index = EXCP_UNALIGN;
46 env->error_code = 0;
47 cpu_loop_exit(cs);
50 void QEMU_NORETURN
51 alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
52 vaddr addr, unsigned size,
53 MMUAccessType access_type,
54 int mmu_idx, MemTxAttrs attrs,
55 MemTxResult response, uintptr_t retaddr)
57 AlphaCPU *cpu = ALPHA_CPU(cs);
58 CPUAlphaState *env = &cpu->env;
60 cpu_restore_state(cs, retaddr);
62 env->trap_arg0 = addr;
63 env->trap_arg1 = access_type == MMU_DATA_STORE ? 1 : 0;
64 cs->exception_index = EXCP_MCHK;
65 env->error_code = 0;
66 cpu_loop_exit(cs);
69 /* try to fill the TLB and return an exception if error. If retaddr is
70 NULL, it means that the function was called in C code (i.e. not
71 from generated code or from helper.c) */
72 /* XXX: fix it to restore all registers */
73 void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
74 int mmu_idx, uintptr_t retaddr)
76 int ret;
78 ret = alpha_cpu_handle_mmu_fault(cs, addr, access_type, mmu_idx);
79 if (unlikely(ret != 0)) {
80 /* Exception index and error code are already set */
81 cpu_loop_exit_restore(cs, retaddr);
84 #endif /* CONFIG_USER_ONLY */