root / target-alpha / helper.c @ f97572e5
History | View | Annotate | Download (11.6 kB)
1 | 4c9649a9 | j_mayer | /*
|
---|---|---|---|
2 | 4c9649a9 | j_mayer | * Alpha emulation cpu helpers for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 4c9649a9 | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
5 | 4c9649a9 | j_mayer | *
|
6 | 4c9649a9 | j_mayer | * This library is free software; you can redistribute it and/or
|
7 | 4c9649a9 | j_mayer | * modify it under the terms of the GNU Lesser General Public
|
8 | 4c9649a9 | j_mayer | * License as published by the Free Software Foundation; either
|
9 | 4c9649a9 | j_mayer | * version 2 of the License, or (at your option) any later version.
|
10 | 4c9649a9 | j_mayer | *
|
11 | 4c9649a9 | j_mayer | * This library is distributed in the hope that it will be useful,
|
12 | 4c9649a9 | j_mayer | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4c9649a9 | j_mayer | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4c9649a9 | j_mayer | * Lesser General Public License for more details.
|
15 | 4c9649a9 | j_mayer | *
|
16 | 4c9649a9 | j_mayer | * You should have received a copy of the GNU Lesser General Public
|
17 | 4c9649a9 | j_mayer | * License along with this library; if not, write to the Free Software
|
18 | 4c9649a9 | j_mayer | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 4c9649a9 | j_mayer | */
|
20 | 4c9649a9 | j_mayer | |
21 | 4c9649a9 | j_mayer | #include <stdint.h> |
22 | 4c9649a9 | j_mayer | #include <stdlib.h> |
23 | 4c9649a9 | j_mayer | #include <stdio.h> |
24 | 4c9649a9 | j_mayer | |
25 | 4c9649a9 | j_mayer | #include "cpu.h" |
26 | 4c9649a9 | j_mayer | #include "exec-all.h" |
27 | 4c9649a9 | j_mayer | |
28 | 5fafdf24 | ths | #if defined(CONFIG_USER_ONLY)
|
29 | 4c9649a9 | j_mayer | |
30 | 4c9649a9 | j_mayer | int cpu_alpha_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
31 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
32 | 4c9649a9 | j_mayer | { |
33 | 4c9649a9 | j_mayer | if (rw == 2) |
34 | 4c9649a9 | j_mayer | env->exception_index = EXCP_ITB_MISS; |
35 | 4c9649a9 | j_mayer | else
|
36 | 4c9649a9 | j_mayer | env->exception_index = EXCP_DFAULT; |
37 | 4c9649a9 | j_mayer | env->ipr[IPR_EXC_ADDR] = address; |
38 | 3b46e624 | ths | |
39 | 4c9649a9 | j_mayer | return 1; |
40 | 4c9649a9 | j_mayer | } |
41 | 4c9649a9 | j_mayer | |
42 | 9b3c35e0 | j_mayer | target_phys_addr_t cpu_get_phys_page_debug (CPUState *env, target_ulong addr) |
43 | 4c9649a9 | j_mayer | { |
44 | 4c9649a9 | j_mayer | return addr;
|
45 | 4c9649a9 | j_mayer | } |
46 | 4c9649a9 | j_mayer | |
47 | 4c9649a9 | j_mayer | void do_interrupt (CPUState *env)
|
48 | 4c9649a9 | j_mayer | { |
49 | 4c9649a9 | j_mayer | env->exception_index = -1;
|
50 | 4c9649a9 | j_mayer | } |
51 | 4c9649a9 | j_mayer | |
52 | 4c9649a9 | j_mayer | #else
|
53 | 4c9649a9 | j_mayer | |
54 | 9b3c35e0 | j_mayer | target_phys_addr_t cpu_get_phys_page_debug (CPUState *env, target_ulong addr) |
55 | 4c9649a9 | j_mayer | { |
56 | 4c9649a9 | j_mayer | return -1; |
57 | 4c9649a9 | j_mayer | } |
58 | 4c9649a9 | j_mayer | |
59 | 4c9649a9 | j_mayer | int cpu_alpha_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
60 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
61 | 4c9649a9 | j_mayer | { |
62 | 4c9649a9 | j_mayer | uint32_t opc; |
63 | 4c9649a9 | j_mayer | |
64 | 4c9649a9 | j_mayer | if (rw == 2) { |
65 | 4c9649a9 | j_mayer | /* Instruction translation buffer miss */
|
66 | 4c9649a9 | j_mayer | env->exception_index = EXCP_ITB_MISS; |
67 | 4c9649a9 | j_mayer | } else {
|
68 | 4c9649a9 | j_mayer | if (env->ipr[IPR_EXC_ADDR] & 1) |
69 | 4c9649a9 | j_mayer | env->exception_index = EXCP_DTB_MISS_PAL; |
70 | 4c9649a9 | j_mayer | else
|
71 | 4c9649a9 | j_mayer | env->exception_index = EXCP_DTB_MISS_NATIVE; |
72 | 4c9649a9 | j_mayer | opc = (ldl_code(env->pc) >> 21) << 4; |
73 | 4c9649a9 | j_mayer | if (rw) {
|
74 | 4c9649a9 | j_mayer | opc |= 0x9;
|
75 | 4c9649a9 | j_mayer | } else {
|
76 | 4c9649a9 | j_mayer | opc |= 0x4;
|
77 | 4c9649a9 | j_mayer | } |
78 | 4c9649a9 | j_mayer | env->ipr[IPR_MM_STAT] = opc; |
79 | 4c9649a9 | j_mayer | } |
80 | 4c9649a9 | j_mayer | |
81 | 4c9649a9 | j_mayer | return 1; |
82 | 4c9649a9 | j_mayer | } |
83 | 4c9649a9 | j_mayer | |
84 | 4c9649a9 | j_mayer | int cpu_alpha_mfpr (CPUState *env, int iprn, uint64_t *valp) |
85 | 4c9649a9 | j_mayer | { |
86 | 4c9649a9 | j_mayer | uint64_t hwpcb; |
87 | 4c9649a9 | j_mayer | int ret = 0; |
88 | 4c9649a9 | j_mayer | |
89 | 4c9649a9 | j_mayer | hwpcb = env->ipr[IPR_PCBB]; |
90 | 4c9649a9 | j_mayer | switch (iprn) {
|
91 | 4c9649a9 | j_mayer | case IPR_ASN:
|
92 | 4c9649a9 | j_mayer | if (env->features & FEATURE_ASN)
|
93 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_ASN]; |
94 | 4c9649a9 | j_mayer | else
|
95 | 4c9649a9 | j_mayer | *valp = 0;
|
96 | 4c9649a9 | j_mayer | break;
|
97 | 4c9649a9 | j_mayer | case IPR_ASTEN:
|
98 | 4c9649a9 | j_mayer | *valp = ((int64_t)(env->ipr[IPR_ASTEN] << 60)) >> 60; |
99 | 4c9649a9 | j_mayer | break;
|
100 | 4c9649a9 | j_mayer | case IPR_ASTSR:
|
101 | 4c9649a9 | j_mayer | *valp = ((int64_t)(env->ipr[IPR_ASTSR] << 60)) >> 60; |
102 | 4c9649a9 | j_mayer | break;
|
103 | 4c9649a9 | j_mayer | case IPR_DATFX:
|
104 | 4c9649a9 | j_mayer | /* Write only */
|
105 | 4c9649a9 | j_mayer | ret = -1;
|
106 | 4c9649a9 | j_mayer | break;
|
107 | 4c9649a9 | j_mayer | case IPR_ESP:
|
108 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
109 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_ESP]; |
110 | 4c9649a9 | j_mayer | else
|
111 | 4c9649a9 | j_mayer | *valp = ldq_raw(hwpcb + 8);
|
112 | 4c9649a9 | j_mayer | break;
|
113 | 4c9649a9 | j_mayer | case IPR_FEN:
|
114 | 4c9649a9 | j_mayer | *valp = ((int64_t)(env->ipr[IPR_FEN] << 63)) >> 63; |
115 | 4c9649a9 | j_mayer | break;
|
116 | 4c9649a9 | j_mayer | case IPR_IPIR:
|
117 | 4c9649a9 | j_mayer | /* Write-only */
|
118 | 4c9649a9 | j_mayer | ret = -1;
|
119 | 4c9649a9 | j_mayer | break;
|
120 | 4c9649a9 | j_mayer | case IPR_IPL:
|
121 | 4c9649a9 | j_mayer | *valp = ((int64_t)(env->ipr[IPR_IPL] << 59)) >> 59; |
122 | 4c9649a9 | j_mayer | break;
|
123 | 4c9649a9 | j_mayer | case IPR_KSP:
|
124 | 4c9649a9 | j_mayer | if (!(env->ipr[IPR_EXC_ADDR] & 1)) { |
125 | 4c9649a9 | j_mayer | ret = -1;
|
126 | 4c9649a9 | j_mayer | } else {
|
127 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
128 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_KSP]; |
129 | 4c9649a9 | j_mayer | else
|
130 | 4c9649a9 | j_mayer | *valp = ldq_raw(hwpcb + 0);
|
131 | 4c9649a9 | j_mayer | } |
132 | 4c9649a9 | j_mayer | break;
|
133 | 4c9649a9 | j_mayer | case IPR_MCES:
|
134 | 4c9649a9 | j_mayer | *valp = ((int64_t)(env->ipr[IPR_MCES] << 59)) >> 59; |
135 | 4c9649a9 | j_mayer | break;
|
136 | 4c9649a9 | j_mayer | case IPR_PERFMON:
|
137 | 4c9649a9 | j_mayer | /* Implementation specific */
|
138 | 4c9649a9 | j_mayer | *valp = 0;
|
139 | 4c9649a9 | j_mayer | break;
|
140 | 4c9649a9 | j_mayer | case IPR_PCBB:
|
141 | 4c9649a9 | j_mayer | *valp = ((int64_t)env->ipr[IPR_PCBB] << 16) >> 16; |
142 | 4c9649a9 | j_mayer | break;
|
143 | 4c9649a9 | j_mayer | case IPR_PRBR:
|
144 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_PRBR]; |
145 | 4c9649a9 | j_mayer | break;
|
146 | 4c9649a9 | j_mayer | case IPR_PTBR:
|
147 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_PTBR]; |
148 | 4c9649a9 | j_mayer | break;
|
149 | 4c9649a9 | j_mayer | case IPR_SCBB:
|
150 | 4c9649a9 | j_mayer | *valp = (int64_t)((int32_t)env->ipr[IPR_SCBB]); |
151 | 4c9649a9 | j_mayer | break;
|
152 | 4c9649a9 | j_mayer | case IPR_SIRR:
|
153 | 4c9649a9 | j_mayer | /* Write-only */
|
154 | 4c9649a9 | j_mayer | ret = -1;
|
155 | 4c9649a9 | j_mayer | break;
|
156 | 4c9649a9 | j_mayer | case IPR_SISR:
|
157 | 4c9649a9 | j_mayer | *valp = (int64_t)((int16_t)env->ipr[IPR_SISR]); |
158 | 4c9649a9 | j_mayer | case IPR_SSP:
|
159 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
160 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_SSP]; |
161 | 4c9649a9 | j_mayer | else
|
162 | 4c9649a9 | j_mayer | *valp = ldq_raw(hwpcb + 16);
|
163 | 4c9649a9 | j_mayer | break;
|
164 | 4c9649a9 | j_mayer | case IPR_SYSPTBR:
|
165 | 4c9649a9 | j_mayer | if (env->features & FEATURE_VIRBND)
|
166 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_SYSPTBR]; |
167 | 4c9649a9 | j_mayer | else
|
168 | 4c9649a9 | j_mayer | ret = -1;
|
169 | 4c9649a9 | j_mayer | break;
|
170 | 4c9649a9 | j_mayer | case IPR_TBCHK:
|
171 | 4c9649a9 | j_mayer | if ((env->features & FEATURE_TBCHK)) {
|
172 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
173 | 4c9649a9 | j_mayer | *valp = 0;
|
174 | 4c9649a9 | j_mayer | ret = -1;
|
175 | 4c9649a9 | j_mayer | } else {
|
176 | 4c9649a9 | j_mayer | ret = -1;
|
177 | 4c9649a9 | j_mayer | } |
178 | 4c9649a9 | j_mayer | break;
|
179 | 4c9649a9 | j_mayer | case IPR_TBIA:
|
180 | 4c9649a9 | j_mayer | /* Write-only */
|
181 | 4c9649a9 | j_mayer | ret = -1;
|
182 | 4c9649a9 | j_mayer | break;
|
183 | 4c9649a9 | j_mayer | case IPR_TBIAP:
|
184 | 4c9649a9 | j_mayer | /* Write-only */
|
185 | 4c9649a9 | j_mayer | ret = -1;
|
186 | 4c9649a9 | j_mayer | break;
|
187 | 4c9649a9 | j_mayer | case IPR_TBIS:
|
188 | 4c9649a9 | j_mayer | /* Write-only */
|
189 | 4c9649a9 | j_mayer | ret = -1;
|
190 | 4c9649a9 | j_mayer | break;
|
191 | 4c9649a9 | j_mayer | case IPR_TBISD:
|
192 | 4c9649a9 | j_mayer | /* Write-only */
|
193 | 4c9649a9 | j_mayer | ret = -1;
|
194 | 4c9649a9 | j_mayer | break;
|
195 | 4c9649a9 | j_mayer | case IPR_TBISI:
|
196 | 4c9649a9 | j_mayer | /* Write-only */
|
197 | 4c9649a9 | j_mayer | ret = -1;
|
198 | 4c9649a9 | j_mayer | break;
|
199 | 4c9649a9 | j_mayer | case IPR_USP:
|
200 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
201 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_USP]; |
202 | 4c9649a9 | j_mayer | else
|
203 | 4c9649a9 | j_mayer | *valp = ldq_raw(hwpcb + 24);
|
204 | 4c9649a9 | j_mayer | break;
|
205 | 4c9649a9 | j_mayer | case IPR_VIRBND:
|
206 | 4c9649a9 | j_mayer | if (env->features & FEATURE_VIRBND)
|
207 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_VIRBND]; |
208 | 4c9649a9 | j_mayer | else
|
209 | 4c9649a9 | j_mayer | ret = -1;
|
210 | 4c9649a9 | j_mayer | break;
|
211 | 4c9649a9 | j_mayer | case IPR_VPTB:
|
212 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_VPTB]; |
213 | 4c9649a9 | j_mayer | break;
|
214 | 4c9649a9 | j_mayer | case IPR_WHAMI:
|
215 | 4c9649a9 | j_mayer | *valp = env->ipr[IPR_WHAMI]; |
216 | 4c9649a9 | j_mayer | break;
|
217 | 4c9649a9 | j_mayer | default:
|
218 | 4c9649a9 | j_mayer | /* Invalid */
|
219 | 4c9649a9 | j_mayer | ret = -1;
|
220 | 4c9649a9 | j_mayer | break;
|
221 | 4c9649a9 | j_mayer | } |
222 | 4c9649a9 | j_mayer | |
223 | 4c9649a9 | j_mayer | return ret;
|
224 | 4c9649a9 | j_mayer | } |
225 | 4c9649a9 | j_mayer | |
226 | 4c9649a9 | j_mayer | int cpu_alpha_mtpr (CPUState *env, int iprn, uint64_t val, uint64_t *oldvalp) |
227 | 4c9649a9 | j_mayer | { |
228 | 4c9649a9 | j_mayer | uint64_t hwpcb, tmp64; |
229 | 4c9649a9 | j_mayer | uint8_t tmp8; |
230 | 4c9649a9 | j_mayer | int ret = 0; |
231 | 4c9649a9 | j_mayer | |
232 | 4c9649a9 | j_mayer | hwpcb = env->ipr[IPR_PCBB]; |
233 | 4c9649a9 | j_mayer | switch (iprn) {
|
234 | 4c9649a9 | j_mayer | case IPR_ASN:
|
235 | 4c9649a9 | j_mayer | /* Read-only */
|
236 | 4c9649a9 | j_mayer | ret = -1;
|
237 | 4c9649a9 | j_mayer | break;
|
238 | 4c9649a9 | j_mayer | case IPR_ASTEN:
|
239 | 4c9649a9 | j_mayer | tmp8 = ((int8_t)(env->ipr[IPR_ASTEN] << 4)) >> 4; |
240 | 4c9649a9 | j_mayer | *oldvalp = tmp8; |
241 | 4c9649a9 | j_mayer | tmp8 &= val & 0xF;
|
242 | 4c9649a9 | j_mayer | tmp8 |= (val >> 4) & 0xF; |
243 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTEN] &= ~0xF;
|
244 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTEN] |= tmp8; |
245 | 4c9649a9 | j_mayer | ret = 1;
|
246 | 4c9649a9 | j_mayer | break;
|
247 | 4c9649a9 | j_mayer | case IPR_ASTSR:
|
248 | 4c9649a9 | j_mayer | tmp8 = ((int8_t)(env->ipr[IPR_ASTSR] << 4)) >> 4; |
249 | 4c9649a9 | j_mayer | *oldvalp = tmp8; |
250 | 4c9649a9 | j_mayer | tmp8 &= val & 0xF;
|
251 | 4c9649a9 | j_mayer | tmp8 |= (val >> 4) & 0xF; |
252 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTSR] &= ~0xF;
|
253 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTSR] |= tmp8; |
254 | 4c9649a9 | j_mayer | ret = 1;
|
255 | 4c9649a9 | j_mayer | case IPR_DATFX:
|
256 | 4c9649a9 | j_mayer | env->ipr[IPR_DATFX] &= ~0x1;
|
257 | 4c9649a9 | j_mayer | env->ipr[IPR_DATFX] |= val & 1;
|
258 | 4c9649a9 | j_mayer | tmp64 = ldq_raw(hwpcb + 56);
|
259 | 4c9649a9 | j_mayer | tmp64 &= ~0x8000000000000000ULL;
|
260 | 4c9649a9 | j_mayer | tmp64 |= (val & 1) << 63; |
261 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 56, tmp64);
|
262 | 4c9649a9 | j_mayer | break;
|
263 | 4c9649a9 | j_mayer | case IPR_ESP:
|
264 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
265 | 4c9649a9 | j_mayer | env->ipr[IPR_ESP] = val; |
266 | 4c9649a9 | j_mayer | else
|
267 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 8, val);
|
268 | 4c9649a9 | j_mayer | break;
|
269 | 4c9649a9 | j_mayer | case IPR_FEN:
|
270 | 4c9649a9 | j_mayer | env->ipr[IPR_FEN] = val & 1;
|
271 | 4c9649a9 | j_mayer | tmp64 = ldq_raw(hwpcb + 56);
|
272 | 4c9649a9 | j_mayer | tmp64 &= ~1;
|
273 | 4c9649a9 | j_mayer | tmp64 |= val & 1;
|
274 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 56, tmp64);
|
275 | 4c9649a9 | j_mayer | break;
|
276 | 4c9649a9 | j_mayer | case IPR_IPIR:
|
277 | 4c9649a9 | j_mayer | /* XXX: TODO: Send IRQ to CPU #ir[16] */
|
278 | 4c9649a9 | j_mayer | break;
|
279 | 4c9649a9 | j_mayer | case IPR_IPL:
|
280 | 4c9649a9 | j_mayer | *oldvalp = ((int64_t)(env->ipr[IPR_IPL] << 59)) >> 59; |
281 | 4c9649a9 | j_mayer | env->ipr[IPR_IPL] &= ~0x1F;
|
282 | 4c9649a9 | j_mayer | env->ipr[IPR_IPL] |= val & 0x1F;
|
283 | 4c9649a9 | j_mayer | /* XXX: may issue an interrupt or ASR _now_ */
|
284 | 4c9649a9 | j_mayer | ret = 1;
|
285 | 4c9649a9 | j_mayer | break;
|
286 | 4c9649a9 | j_mayer | case IPR_KSP:
|
287 | 4c9649a9 | j_mayer | if (!(env->ipr[IPR_EXC_ADDR] & 1)) { |
288 | 4c9649a9 | j_mayer | ret = -1;
|
289 | 4c9649a9 | j_mayer | } else {
|
290 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
291 | 4c9649a9 | j_mayer | env->ipr[IPR_KSP] = val; |
292 | 4c9649a9 | j_mayer | else
|
293 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 0, val);
|
294 | 4c9649a9 | j_mayer | } |
295 | 4c9649a9 | j_mayer | break;
|
296 | 4c9649a9 | j_mayer | case IPR_MCES:
|
297 | 4c9649a9 | j_mayer | env->ipr[IPR_MCES] &= ~((val & 0x7) | 0x18); |
298 | 4c9649a9 | j_mayer | env->ipr[IPR_MCES] |= val & 0x18;
|
299 | 4c9649a9 | j_mayer | break;
|
300 | 4c9649a9 | j_mayer | case IPR_PERFMON:
|
301 | 4c9649a9 | j_mayer | /* Implementation specific */
|
302 | 4c9649a9 | j_mayer | *oldvalp = 0;
|
303 | 4c9649a9 | j_mayer | ret = 1;
|
304 | 4c9649a9 | j_mayer | break;
|
305 | 4c9649a9 | j_mayer | case IPR_PCBB:
|
306 | 4c9649a9 | j_mayer | /* Read-only */
|
307 | 4c9649a9 | j_mayer | ret = -1;
|
308 | 4c9649a9 | j_mayer | break;
|
309 | 4c9649a9 | j_mayer | case IPR_PRBR:
|
310 | 4c9649a9 | j_mayer | env->ipr[IPR_PRBR] = val; |
311 | 4c9649a9 | j_mayer | break;
|
312 | 4c9649a9 | j_mayer | case IPR_PTBR:
|
313 | 4c9649a9 | j_mayer | /* Read-only */
|
314 | 4c9649a9 | j_mayer | ret = -1;
|
315 | 4c9649a9 | j_mayer | break;
|
316 | 4c9649a9 | j_mayer | case IPR_SCBB:
|
317 | 4c9649a9 | j_mayer | env->ipr[IPR_SCBB] = (uint32_t)val; |
318 | 4c9649a9 | j_mayer | break;
|
319 | 4c9649a9 | j_mayer | case IPR_SIRR:
|
320 | 4c9649a9 | j_mayer | if (val & 0xF) { |
321 | 4c9649a9 | j_mayer | env->ipr[IPR_SISR] |= 1 << (val & 0xF); |
322 | 4c9649a9 | j_mayer | /* XXX: request a software interrupt _now_ */
|
323 | 4c9649a9 | j_mayer | } |
324 | 4c9649a9 | j_mayer | break;
|
325 | 4c9649a9 | j_mayer | case IPR_SISR:
|
326 | 4c9649a9 | j_mayer | /* Read-only */
|
327 | 4c9649a9 | j_mayer | ret = -1;
|
328 | 4c9649a9 | j_mayer | break;
|
329 | 4c9649a9 | j_mayer | case IPR_SSP:
|
330 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
331 | 4c9649a9 | j_mayer | env->ipr[IPR_SSP] = val; |
332 | 4c9649a9 | j_mayer | else
|
333 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 16, val);
|
334 | 4c9649a9 | j_mayer | break;
|
335 | 4c9649a9 | j_mayer | case IPR_SYSPTBR:
|
336 | 4c9649a9 | j_mayer | if (env->features & FEATURE_VIRBND)
|
337 | 4c9649a9 | j_mayer | env->ipr[IPR_SYSPTBR] = val; |
338 | 4c9649a9 | j_mayer | else
|
339 | 4c9649a9 | j_mayer | ret = -1;
|
340 | 4c9649a9 | j_mayer | case IPR_TBCHK:
|
341 | 4c9649a9 | j_mayer | /* Read-only */
|
342 | 4c9649a9 | j_mayer | ret = -1;
|
343 | 4c9649a9 | j_mayer | break;
|
344 | 4c9649a9 | j_mayer | case IPR_TBIA:
|
345 | 4c9649a9 | j_mayer | tlb_flush(env, 1);
|
346 | 4c9649a9 | j_mayer | break;
|
347 | 4c9649a9 | j_mayer | case IPR_TBIAP:
|
348 | 4c9649a9 | j_mayer | tlb_flush(env, 1);
|
349 | 4c9649a9 | j_mayer | break;
|
350 | 4c9649a9 | j_mayer | case IPR_TBIS:
|
351 | 4c9649a9 | j_mayer | tlb_flush_page(env, val); |
352 | 4c9649a9 | j_mayer | break;
|
353 | 4c9649a9 | j_mayer | case IPR_TBISD:
|
354 | 4c9649a9 | j_mayer | tlb_flush_page(env, val); |
355 | 4c9649a9 | j_mayer | break;
|
356 | 4c9649a9 | j_mayer | case IPR_TBISI:
|
357 | 4c9649a9 | j_mayer | tlb_flush_page(env, val); |
358 | 4c9649a9 | j_mayer | break;
|
359 | 4c9649a9 | j_mayer | case IPR_USP:
|
360 | 4c9649a9 | j_mayer | if (env->features & FEATURE_SPS)
|
361 | 4c9649a9 | j_mayer | env->ipr[IPR_USP] = val; |
362 | 4c9649a9 | j_mayer | else
|
363 | 4c9649a9 | j_mayer | stq_raw(hwpcb + 24, val);
|
364 | 4c9649a9 | j_mayer | break;
|
365 | 4c9649a9 | j_mayer | case IPR_VIRBND:
|
366 | 4c9649a9 | j_mayer | if (env->features & FEATURE_VIRBND)
|
367 | 4c9649a9 | j_mayer | env->ipr[IPR_VIRBND] = val; |
368 | 4c9649a9 | j_mayer | else
|
369 | 4c9649a9 | j_mayer | ret = -1;
|
370 | 4c9649a9 | j_mayer | break;
|
371 | 4c9649a9 | j_mayer | case IPR_VPTB:
|
372 | 4c9649a9 | j_mayer | env->ipr[IPR_VPTB] = val; |
373 | 4c9649a9 | j_mayer | break;
|
374 | 4c9649a9 | j_mayer | case IPR_WHAMI:
|
375 | 4c9649a9 | j_mayer | /* Read-only */
|
376 | 4c9649a9 | j_mayer | ret = -1;
|
377 | 4c9649a9 | j_mayer | break;
|
378 | 4c9649a9 | j_mayer | default:
|
379 | 4c9649a9 | j_mayer | /* Invalid */
|
380 | 4c9649a9 | j_mayer | ret = -1;
|
381 | 4c9649a9 | j_mayer | break;
|
382 | 4c9649a9 | j_mayer | } |
383 | 4c9649a9 | j_mayer | |
384 | 4c9649a9 | j_mayer | return ret;
|
385 | 4c9649a9 | j_mayer | } |
386 | 4c9649a9 | j_mayer | |
387 | 4c9649a9 | j_mayer | void do_interrupt (CPUState *env)
|
388 | 4c9649a9 | j_mayer | { |
389 | 4c9649a9 | j_mayer | int excp;
|
390 | 4c9649a9 | j_mayer | |
391 | 4c9649a9 | j_mayer | env->ipr[IPR_EXC_ADDR] = env->pc | 1;
|
392 | 4c9649a9 | j_mayer | excp = env->exception_index; |
393 | 4c9649a9 | j_mayer | env->exception_index = 0;
|
394 | 4c9649a9 | j_mayer | env->error_code = 0;
|
395 | 4c9649a9 | j_mayer | /* XXX: disable interrupts and memory mapping */
|
396 | 4c9649a9 | j_mayer | if (env->ipr[IPR_PAL_BASE] != -1ULL) { |
397 | 4c9649a9 | j_mayer | /* We use native PALcode */
|
398 | 4c9649a9 | j_mayer | env->pc = env->ipr[IPR_PAL_BASE] + excp; |
399 | 4c9649a9 | j_mayer | } else {
|
400 | 4c9649a9 | j_mayer | /* We use emulated PALcode */
|
401 | 4c9649a9 | j_mayer | call_pal(env); |
402 | 4c9649a9 | j_mayer | /* Emulate REI */
|
403 | 4c9649a9 | j_mayer | env->pc = env->ipr[IPR_EXC_ADDR] & ~7;
|
404 | 4c9649a9 | j_mayer | env->ipr[IPR_EXC_ADDR] = env->ipr[IPR_EXC_ADDR] & 1;
|
405 | 4c9649a9 | j_mayer | /* XXX: re-enable interrupts and memory mapping */
|
406 | 4c9649a9 | j_mayer | } |
407 | 4c9649a9 | j_mayer | } |
408 | 4c9649a9 | j_mayer | #endif
|
409 | 4c9649a9 | j_mayer | |
410 | 5fafdf24 | ths | void cpu_dump_state (CPUState *env, FILE *f,
|
411 | 4c9649a9 | j_mayer | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
412 | 4c9649a9 | j_mayer | int flags)
|
413 | 4c9649a9 | j_mayer | { |
414 | 4c9649a9 | j_mayer | static unsigned char *linux_reg_names[] = { |
415 | 4c9649a9 | j_mayer | "v0 ", "t0 ", "t1 ", "t2 ", "t3 ", "t4 ", "t5 ", "t6 ", |
416 | 4c9649a9 | j_mayer | "t7 ", "s0 ", "s1 ", "s2 ", "s3 ", "s4 ", "s5 ", "fp ", |
417 | 4c9649a9 | j_mayer | "a0 ", "a1 ", "a2 ", "a3 ", "a4 ", "a5 ", "t8 ", "t9 ", |
418 | 4c9649a9 | j_mayer | "t10", "t11", "ra ", "t12", "at ", "gp ", "sp ", "zero", |
419 | 4c9649a9 | j_mayer | }; |
420 | 4c9649a9 | j_mayer | int i;
|
421 | 4c9649a9 | j_mayer | |
422 | 4c9649a9 | j_mayer | cpu_fprintf(f, " PC " TARGET_FMT_lx " PS " TARGET_FMT_lx "\n", |
423 | 4c9649a9 | j_mayer | env->pc, env->ps); |
424 | 4c9649a9 | j_mayer | for (i = 0; i < 31; i++) { |
425 | 4c9649a9 | j_mayer | cpu_fprintf(f, "IR%02d %s " TARGET_FMT_lx " ", i, |
426 | 4c9649a9 | j_mayer | linux_reg_names[i], env->ir[i]); |
427 | 4c9649a9 | j_mayer | if ((i % 3) == 2) |
428 | 4c9649a9 | j_mayer | cpu_fprintf(f, "\n");
|
429 | 4c9649a9 | j_mayer | } |
430 | 4c9649a9 | j_mayer | cpu_fprintf(f, "\n");
|
431 | 4c9649a9 | j_mayer | for (i = 0; i < 31; i++) { |
432 | 4c9649a9 | j_mayer | cpu_fprintf(f, "FIR%02d " TARGET_FMT_lx " ", i, |
433 | 4c9649a9 | j_mayer | *((uint64_t *)(&env->fir[i]))); |
434 | 4c9649a9 | j_mayer | if ((i % 3) == 2) |
435 | 4c9649a9 | j_mayer | cpu_fprintf(f, "\n");
|
436 | 4c9649a9 | j_mayer | } |
437 | 4c9649a9 | j_mayer | cpu_fprintf(f, "FT " TARGET_FMT_lx " " TARGET_FMT_lx " " TARGET_FMT_lx, |
438 | 4c9649a9 | j_mayer | *((uint64_t *)(&env->ft0)), *((uint64_t *)(&env->ft1)), |
439 | 4c9649a9 | j_mayer | *((uint64_t *)(&env->ft2))); |
440 | 4c9649a9 | j_mayer | cpu_fprintf(f, "\nMEM " TARGET_FMT_lx " %d %d\n", |
441 | 4c9649a9 | j_mayer | ldq_raw(0x000000004007df60ULL),
|
442 | 4c9649a9 | j_mayer | (uint8_t *)(&env->ft0), (uint8_t *)(&env->fir[0]));
|
443 | 4c9649a9 | j_mayer | } |
444 | 4c9649a9 | j_mayer | |
445 | 4c9649a9 | j_mayer | void cpu_dump_EA (target_ulong EA)
|
446 | 4c9649a9 | j_mayer | { |
447 | 4c9649a9 | j_mayer | FILE *f; |
448 | 4c9649a9 | j_mayer | |
449 | 4c9649a9 | j_mayer | if (logfile)
|
450 | 4c9649a9 | j_mayer | f = logfile; |
451 | 4c9649a9 | j_mayer | else
|
452 | 4c9649a9 | j_mayer | f = stdout; |
453 | 4c9649a9 | j_mayer | fprintf(f, "Memory access at address " TARGET_FMT_lx "\n", EA); |
454 | 4c9649a9 | j_mayer | } |