master
c 76 lines 2.51 KB
Raw
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 #include "accel/tcg/cpu-loop.h"
25
26 static void do_unaligned_access(CPUAlphaState *env, vaddr addr, uintptr_t retaddr)
27 {
28 CPUState *cs = env_cpu(env);
29 MemOpIdx oi = make_memop_idx(MO_LEUL, cpu_mmu_index(cs, true));
30 uint64_t pc;
31 uint32_t insn;
32
33 cpu_restore_state(env_cpu(env), retaddr);
34
35 pc = env->pc;
36 insn = cpu_ldl_code_mmu(env, pc, oi, retaddr);
37
38 env->trap_arg0 = addr;
39 env->trap_arg1 = insn >> 26; /* opcode */
40 env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
41 }
42
43 #ifdef CONFIG_USER_ONLY
44 void alpha_cpu_record_sigbus(CPUState *cs, vaddr addr,
45 MMUAccessType access_type, uintptr_t retaddr)
46 {
47 do_unaligned_access(cpu_env(cs), addr, retaddr);
48 }
49 #else
50 void alpha_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
51 MMUAccessType access_type,
52 int mmu_idx, uintptr_t retaddr)
53 {
54 CPUAlphaState *env = cpu_env(cs);
55
56 do_unaligned_access(env, addr, retaddr);
57 cs->exception_index = EXCP_UNALIGN;
58 env->error_code = 0;
59 cpu_loop_exit(cs);
60 }
61
62 void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr,
63 vaddr addr, unsigned size,
64 MMUAccessType access_type,
65 int mmu_idx, MemTxAttrs attrs,
66 MemTxResult response, uintptr_t retaddr)
67 {
68 CPUAlphaState *env = cpu_env(cs);
69
70 env->trap_arg0 = addr;
71 env->trap_arg1 = access_type == MMU_DATA_STORE ? 1 : 0;
72 cs->exception_index = EXCP_MCHK;
73 env->error_code = 0;
74 cpu_loop_exit_restore(cs, retaddr);
75 }
76 #endif /* CONFIG_USER_ONLY */