]>
Commit | Line | Data |
---|---|---|
4c9649a9 | 1 | /* |
c3082755 | 2 | * Helpers for loads and stores |
5fafdf24 | 3 | * |
4c9649a9 JM |
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 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 | |
8167ee88 | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
4c9649a9 JM |
18 | */ |
19 | ||
3e457172 | 20 | #include "cpu.h" |
a7812ae4 | 21 | #include "helper.h" |
4c9649a9 | 22 | |
4c9649a9 | 23 | |
4c9649a9 | 24 | /* Softmmu support */ |
c3082755 RH |
25 | #ifndef CONFIG_USER_ONLY |
26 | ||
2374e73e | 27 | uint64_t helper_ldl_phys(uint64_t p) |
8bb6e981 | 28 | { |
2374e73e | 29 | return (int32_t)ldl_phys(p); |
8bb6e981 AJ |
30 | } |
31 | ||
2374e73e | 32 | uint64_t helper_ldq_phys(uint64_t p) |
8bb6e981 | 33 | { |
2374e73e | 34 | return ldq_phys(p); |
8bb6e981 AJ |
35 | } |
36 | ||
c3082755 | 37 | uint64_t helper_ldl_l_phys(CPUAlphaState *env, uint64_t p) |
8bb6e981 | 38 | { |
2374e73e RH |
39 | env->lock_addr = p; |
40 | return env->lock_value = (int32_t)ldl_phys(p); | |
8bb6e981 AJ |
41 | } |
42 | ||
c3082755 | 43 | uint64_t helper_ldq_l_phys(CPUAlphaState *env, uint64_t p) |
8bb6e981 | 44 | { |
2374e73e | 45 | env->lock_addr = p; |
c3082755 | 46 | return env->lock_value = ldq_phys(p); |
8bb6e981 AJ |
47 | } |
48 | ||
2374e73e | 49 | void helper_stl_phys(uint64_t p, uint64_t v) |
8bb6e981 | 50 | { |
2374e73e | 51 | stl_phys(p, v); |
8bb6e981 AJ |
52 | } |
53 | ||
2374e73e | 54 | void helper_stq_phys(uint64_t p, uint64_t v) |
8bb6e981 | 55 | { |
2374e73e | 56 | stq_phys(p, v); |
8bb6e981 AJ |
57 | } |
58 | ||
c3082755 | 59 | uint64_t helper_stl_c_phys(CPUAlphaState *env, uint64_t p, uint64_t v) |
8bb6e981 | 60 | { |
2374e73e | 61 | uint64_t ret = 0; |
8bb6e981 | 62 | |
2374e73e RH |
63 | if (p == env->lock_addr) { |
64 | int32_t old = ldl_phys(p); | |
65 | if (old == (int32_t)env->lock_value) { | |
66 | stl_phys(p, v); | |
67 | ret = 1; | |
68 | } | |
69 | } | |
70 | env->lock_addr = -1; | |
8bb6e981 AJ |
71 | |
72 | return ret; | |
73 | } | |
74 | ||
c3082755 | 75 | uint64_t helper_stq_c_phys(CPUAlphaState *env, uint64_t p, uint64_t v) |
8bb6e981 | 76 | { |
2374e73e | 77 | uint64_t ret = 0; |
8bb6e981 | 78 | |
2374e73e RH |
79 | if (p == env->lock_addr) { |
80 | uint64_t old = ldq_phys(p); | |
81 | if (old == env->lock_value) { | |
82 | stq_phys(p, v); | |
83 | ret = 1; | |
84 | } | |
85 | } | |
86 | env->lock_addr = -1; | |
8bb6e981 AJ |
87 | |
88 | return ret; | |
4c9649a9 JM |
89 | } |
90 | ||
c3082755 | 91 | static void do_unaligned_access(CPUAlphaState *env, target_ulong addr, |
20503968 | 92 | int is_write, int is_user, uintptr_t retaddr) |
5b450407 RH |
93 | { |
94 | uint64_t pc; | |
95 | uint32_t insn; | |
96 | ||
a8a826a3 BS |
97 | if (retaddr) { |
98 | cpu_restore_state(env, retaddr); | |
99 | } | |
5b450407 RH |
100 | |
101 | pc = env->pc; | |
c3082755 | 102 | insn = cpu_ldl_code(env, pc); |
5b450407 RH |
103 | |
104 | env->trap_arg0 = addr; | |
105 | env->trap_arg1 = insn >> 26; /* opcode */ | |
106 | env->trap_arg2 = (insn >> 21) & 31; /* dest regno */ | |
b9f0923e RH |
107 | env->exception_index = EXCP_UNALIGN; |
108 | env->error_code = 0; | |
109 | cpu_loop_exit(env); | |
5b450407 RH |
110 | } |
111 | ||
a8170e5e | 112 | void cpu_unassigned_access(CPUAlphaState *env, hwaddr addr, |
c3082755 | 113 | int is_write, int is_exec, int unused, int size) |
5b450407 RH |
114 | { |
115 | env->trap_arg0 = addr; | |
116 | env->trap_arg1 = is_write; | |
20503968 | 117 | dynamic_excp(env, 0, EXCP_MCHK, 0); |
5b450407 RH |
118 | } |
119 | ||
022c62cb | 120 | #include "exec/softmmu_exec.h" |
3e457172 | 121 | |
4c9649a9 | 122 | #define MMUSUFFIX _mmu |
5b450407 | 123 | #define ALIGNED_ONLY |
4c9649a9 JM |
124 | |
125 | #define SHIFT 0 | |
022c62cb | 126 | #include "exec/softmmu_template.h" |
4c9649a9 JM |
127 | |
128 | #define SHIFT 1 | |
022c62cb | 129 | #include "exec/softmmu_template.h" |
4c9649a9 JM |
130 | |
131 | #define SHIFT 2 | |
022c62cb | 132 | #include "exec/softmmu_template.h" |
4c9649a9 JM |
133 | |
134 | #define SHIFT 3 | |
022c62cb | 135 | #include "exec/softmmu_template.h" |
4c9649a9 JM |
136 | |
137 | /* try to fill the TLB and return an exception if error. If retaddr is | |
138 | NULL, it means that the function was called in C code (i.e. not | |
139 | from generated code or from helper.c) */ | |
140 | /* XXX: fix it to restore all registers */ | |
c3082755 | 141 | void tlb_fill(CPUAlphaState *env, target_ulong addr, int is_write, |
20503968 | 142 | int mmu_idx, uintptr_t retaddr) |
4c9649a9 | 143 | { |
4c9649a9 JM |
144 | int ret; |
145 | ||
97b348e7 | 146 | ret = cpu_alpha_handle_mmu_fault(env, addr, is_write, mmu_idx); |
2d9671d3 | 147 | if (unlikely(ret != 0)) { |
a8a826a3 BS |
148 | if (retaddr) { |
149 | cpu_restore_state(env, retaddr); | |
150 | } | |
4c9649a9 | 151 | /* Exception index and error code are already set */ |
1162c041 | 152 | cpu_loop_exit(env); |
4c9649a9 | 153 | } |
4c9649a9 | 154 | } |
c3082755 | 155 | #endif /* CONFIG_USER_ONLY */ |