1 /*
2 * Helpers for loads and stores
3 *
4 * Copyright (c) 2007 Jocelyn Mayer
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 <http://www.gnu.org/licenses/>.
18 */
19
20 #include "qemu/osdep.h"
21 #include "cpu.h"
22 #include "exec/helper-proto.h"
23 #include "accel/tcg/cpu-ldst.h"
24
do_unaligned_access(CPUAlphaState * env,vaddr addr,uintptr_t retaddr)25 static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retaddr)
26 {
27 uint64_t pc;
28 uint32_t insn;
29
30 cpu_restore_state(env_cpu(env), retaddr);
31
32 pc = env->pc;
33 insn = cpu_ldl_code(env, pc);
34
35 env->trap_arg0 = addr;
36 env->trap_arg1 = insn >> 26; /* opcode */
37 env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
38 }
39
40 #ifdef CONFIG_USER_ONLY
alpha_cpu_record_sigbus(CPUState * cs,vaddr addr,MMUAccessType access_type,uintptr_t retaddr)41 void alpha_cpu_record_sigbus(CPUState *cs, vaddr addr,
42 MMUAccessType access_type, uintptr_t retaddr)
43 {
44 do_unaligned_access(cpu_env(cs), addr, retaddr);
45 }
46 #else
alpha_cpu_do_unaligned_access(CPUState * cs,vaddr addr,MMUAccessType access_type,int mmu_idx,uintptr_t retaddr)47 void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
48 MMUAccessType access_type,
49 int mmu_idx, uintptr_t retaddr)
50 {
51 CPUAlphaState *env = cpu_env(cs);
52
53 do_unaligned_access(env, addr, retaddr);
54 cs->exception_index = EXCP_UNALIGN;
55 env->error_code = 0;
56 cpu_loop_exit(cs);
57 }
58
alpha_cpu_do_transaction_failed(CPUState * cs,hwaddr physaddr,vaddr addr,unsigned size,MMUAccessType access_type,int mmu_idx,MemTxAttrs attrs,MemTxResult response,uintptr_t retaddr)59 void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
60 vaddr addr, unsigned size,
61 MMUAccessType access_type,
62 int mmu_idx, MemTxAttrs attrs,
63 MemTxResult response, uintptr_t retaddr)
64 {
65 CPUAlphaState *env = cpu_env(cs);
66
67 env->trap_arg0 = addr;
68 env->trap_arg1 = access_type == MMU_DATA_STORE ? 1 : 0;
69 cs->exception_index = EXCP_MCHK;
70 env->error_code = 0;
71 cpu_loop_exit_restore(cs, retaddr);
72 }
73 #endif /* CONFIG_USER_ONLY */
74