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/>.
25 #ifndef CONFIG_USER_ONLY
27 uint64_t helper_ldl_phys(CPUAlphaState *env, uint64_t p)
29 CPUState *cs = ENV_GET_CPU(env);
30 return (int32_t)ldl_phys(cs->as, p);
33 uint64_t helper_ldq_phys(CPUAlphaState *env, uint64_t p)
35 CPUState *cs = ENV_GET_CPU(env);
36 return ldq_phys(cs->as, p);
39 uint64_t helper_ldl_l_phys(CPUAlphaState *env, uint64_t p)
41 CPUState *cs = ENV_GET_CPU(env);
43 return env->lock_value = (int32_t)ldl_phys(cs->as, p);
46 uint64_t helper_ldq_l_phys(CPUAlphaState *env, uint64_t p)
48 CPUState *cs = ENV_GET_CPU(env);
50 return env->lock_value = ldq_phys(cs->as, p);
53 void helper_stl_phys(uint64_t p, uint64_t v)
58 void helper_stq_phys(uint64_t p, uint64_t v)
63 uint64_t helper_stl_c_phys(CPUAlphaState *env, uint64_t p, uint64_t v)
65 CPUState *cs = ENV_GET_CPU(env);
68 if (p == env->lock_addr) {
69 int32_t old = ldl_phys(cs->as, p);
70 if (old == (int32_t)env->lock_value) {
80 uint64_t helper_stq_c_phys(CPUAlphaState *env, uint64_t p, uint64_t v)
82 CPUState *cs = ENV_GET_CPU(env);
85 if (p == env->lock_addr) {
86 uint64_t old = ldq_phys(cs->as, p);
87 if (old == env->lock_value) {
97 static void do_unaligned_access(CPUAlphaState *env, target_ulong addr,
98 int is_write, int is_user, uintptr_t retaddr)
104 cpu_restore_state(env, retaddr);
108 insn = cpu_ldl_code(env, pc);
110 env->trap_arg0 = addr;
111 env->trap_arg1 = insn >> 26; /* opcode */
112 env->trap_arg2 = (insn >> 21) & 31; /* dest regno */
113 env->exception_index = EXCP_UNALIGN;
118 void alpha_cpu_unassigned_access(CPUState *cs, hwaddr addr,
119 bool is_write, bool is_exec, int unused,
122 AlphaCPU *cpu = ALPHA_CPU(cs);
123 CPUAlphaState *env = &cpu->env;
125 env->trap_arg0 = addr;
126 env->trap_arg1 = is_write ? 1 : 0;
127 dynamic_excp(env, 0, EXCP_MCHK, 0);
130 #include "exec/softmmu_exec.h"
132 #define MMUSUFFIX _mmu
136 #include "exec/softmmu_template.h"
139 #include "exec/softmmu_template.h"
142 #include "exec/softmmu_template.h"
145 #include "exec/softmmu_template.h"
147 /* try to fill the TLB and return an exception if error. If retaddr is
148 NULL, it means that the function was called in C code (i.e. not
149 from generated code or from helper.c) */
150 /* XXX: fix it to restore all registers */
151 void tlb_fill(CPUAlphaState *env, target_ulong addr, int is_write,
152 int mmu_idx, uintptr_t retaddr)
156 ret = cpu_alpha_handle_mmu_fault(env, addr, is_write, mmu_idx);
157 if (unlikely(ret != 0)) {
159 cpu_restore_state(env, retaddr);
161 /* Exception index and error code are already set */
165 #endif /* CONFIG_USER_ONLY */