root / target-sparc / helper.c @ 16415335
History | View | Annotate | Download (45.4 kB)
1 | e8af50a3 | bellard | /*
|
---|---|---|---|
2 | e8af50a3 | bellard | * sparc helpers
|
3 | 5fafdf24 | ths | *
|
4 | 83469015 | bellard | * Copyright (c) 2003-2005 Fabrice Bellard
|
5 | e8af50a3 | bellard | *
|
6 | e8af50a3 | bellard | * This library is free software; you can redistribute it and/or
|
7 | e8af50a3 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | e8af50a3 | bellard | * License as published by the Free Software Foundation; either
|
9 | e8af50a3 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | e8af50a3 | bellard | *
|
11 | e8af50a3 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | e8af50a3 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | e8af50a3 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | e8af50a3 | bellard | * Lesser General Public License for more details.
|
15 | e8af50a3 | bellard | *
|
16 | e8af50a3 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | e8af50a3 | bellard | */
|
19 | ee5bbe38 | bellard | #include <stdarg.h> |
20 | ee5bbe38 | bellard | #include <stdlib.h> |
21 | ee5bbe38 | bellard | #include <stdio.h> |
22 | ee5bbe38 | bellard | #include <string.h> |
23 | ee5bbe38 | bellard | #include <inttypes.h> |
24 | ee5bbe38 | bellard | #include <signal.h> |
25 | ee5bbe38 | bellard | |
26 | ee5bbe38 | bellard | #include "cpu.h" |
27 | ee5bbe38 | bellard | #include "exec-all.h" |
28 | ca10f867 | aurel32 | #include "qemu-common.h" |
29 | e8af50a3 | bellard | |
30 | e80cfcfc | bellard | //#define DEBUG_MMU
|
31 | 64a88d5d | blueswir1 | //#define DEBUG_FEATURES
|
32 | e8af50a3 | bellard | |
33 | 22548760 | blueswir1 | static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model); |
34 | c48fcb47 | blueswir1 | |
35 | e8af50a3 | bellard | /* Sparc MMU emulation */
|
36 | e8af50a3 | bellard | |
37 | e8af50a3 | bellard | /* thread support */
|
38 | e8af50a3 | bellard | |
39 | 797d5db0 | blueswir1 | static spinlock_t global_cpu_lock = SPIN_LOCK_UNLOCKED;
|
40 | e8af50a3 | bellard | |
41 | e8af50a3 | bellard | void cpu_lock(void) |
42 | e8af50a3 | bellard | { |
43 | e8af50a3 | bellard | spin_lock(&global_cpu_lock); |
44 | e8af50a3 | bellard | } |
45 | e8af50a3 | bellard | |
46 | e8af50a3 | bellard | void cpu_unlock(void) |
47 | e8af50a3 | bellard | { |
48 | e8af50a3 | bellard | spin_unlock(&global_cpu_lock); |
49 | e8af50a3 | bellard | } |
50 | e8af50a3 | bellard | |
51 | 5fafdf24 | ths | #if defined(CONFIG_USER_ONLY)
|
52 | 9d893301 | bellard | |
53 | 22548760 | blueswir1 | int cpu_sparc_handle_mmu_fault(CPUState *env1, target_ulong address, int rw, |
54 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
55 | 9d893301 | bellard | { |
56 | 878d3096 | bellard | if (rw & 2) |
57 | 22548760 | blueswir1 | env1->exception_index = TT_TFAULT; |
58 | 878d3096 | bellard | else
|
59 | 22548760 | blueswir1 | env1->exception_index = TT_DFAULT; |
60 | 9d893301 | bellard | return 1; |
61 | 9d893301 | bellard | } |
62 | 9d893301 | bellard | |
63 | 9d893301 | bellard | #else
|
64 | e8af50a3 | bellard | |
65 | 3475187d | bellard | #ifndef TARGET_SPARC64
|
66 | 83469015 | bellard | /*
|
67 | 83469015 | bellard | * Sparc V8 Reference MMU (SRMMU)
|
68 | 83469015 | bellard | */
|
69 | e8af50a3 | bellard | static const int access_table[8][8] = { |
70 | a764a566 | blueswir1 | { 0, 0, 0, 0, 8, 0, 12, 12 }, |
71 | a764a566 | blueswir1 | { 0, 0, 0, 0, 8, 0, 0, 0 }, |
72 | a764a566 | blueswir1 | { 8, 8, 0, 0, 0, 8, 12, 12 }, |
73 | a764a566 | blueswir1 | { 8, 8, 0, 0, 0, 8, 0, 0 }, |
74 | a764a566 | blueswir1 | { 8, 0, 8, 0, 8, 8, 12, 12 }, |
75 | a764a566 | blueswir1 | { 8, 0, 8, 0, 8, 0, 8, 0 }, |
76 | a764a566 | blueswir1 | { 8, 8, 8, 0, 8, 8, 12, 12 }, |
77 | a764a566 | blueswir1 | { 8, 8, 8, 0, 8, 8, 8, 0 } |
78 | e8af50a3 | bellard | }; |
79 | e8af50a3 | bellard | |
80 | 227671c9 | bellard | static const int perm_table[2][8] = { |
81 | 227671c9 | bellard | { |
82 | 227671c9 | bellard | PAGE_READ, |
83 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE, |
84 | 227671c9 | bellard | PAGE_READ | PAGE_EXEC, |
85 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE | PAGE_EXEC, |
86 | 227671c9 | bellard | PAGE_EXEC, |
87 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE, |
88 | 227671c9 | bellard | PAGE_READ | PAGE_EXEC, |
89 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE | PAGE_EXEC |
90 | 227671c9 | bellard | }, |
91 | 227671c9 | bellard | { |
92 | 227671c9 | bellard | PAGE_READ, |
93 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE, |
94 | 227671c9 | bellard | PAGE_READ | PAGE_EXEC, |
95 | 227671c9 | bellard | PAGE_READ | PAGE_WRITE | PAGE_EXEC, |
96 | 227671c9 | bellard | PAGE_EXEC, |
97 | 227671c9 | bellard | PAGE_READ, |
98 | 227671c9 | bellard | 0,
|
99 | 227671c9 | bellard | 0,
|
100 | 227671c9 | bellard | } |
101 | e8af50a3 | bellard | }; |
102 | e8af50a3 | bellard | |
103 | c48fcb47 | blueswir1 | static int get_physical_address(CPUState *env, target_phys_addr_t *physical, |
104 | c48fcb47 | blueswir1 | int *prot, int *access_index, |
105 | c48fcb47 | blueswir1 | target_ulong address, int rw, int mmu_idx) |
106 | e8af50a3 | bellard | { |
107 | e80cfcfc | bellard | int access_perms = 0; |
108 | e80cfcfc | bellard | target_phys_addr_t pde_ptr; |
109 | af7bf89b | bellard | uint32_t pde; |
110 | af7bf89b | bellard | target_ulong virt_addr; |
111 | 6ebbf390 | j_mayer | int error_code = 0, is_dirty, is_user; |
112 | e80cfcfc | bellard | unsigned long page_offset; |
113 | e8af50a3 | bellard | |
114 | 6ebbf390 | j_mayer | is_user = mmu_idx == MMU_USER_IDX; |
115 | e8af50a3 | bellard | virt_addr = address & TARGET_PAGE_MASK; |
116 | 40ce0a9a | blueswir1 | |
117 | e8af50a3 | bellard | if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */ |
118 | 40ce0a9a | blueswir1 | // Boot mode: instruction fetches are taken from PROM
|
119 | 5578ceab | blueswir1 | if (rw == 2 && (env->mmuregs[0] & env->def->mmu_bm)) { |
120 | 58a770f3 | blueswir1 | *physical = env->prom_addr | (address & 0x7ffffULL);
|
121 | 40ce0a9a | blueswir1 | *prot = PAGE_READ | PAGE_EXEC; |
122 | 40ce0a9a | blueswir1 | return 0; |
123 | 40ce0a9a | blueswir1 | } |
124 | 0f8a249a | blueswir1 | *physical = address; |
125 | 227671c9 | bellard | *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; |
126 | e80cfcfc | bellard | return 0; |
127 | e8af50a3 | bellard | } |
128 | e8af50a3 | bellard | |
129 | 7483750d | bellard | *access_index = ((rw & 1) << 2) | (rw & 2) | (is_user? 0 : 1); |
130 | 5dcb6b91 | blueswir1 | *physical = 0xffffffffffff0000ULL;
|
131 | 7483750d | bellard | |
132 | e8af50a3 | bellard | /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
|
133 | e8af50a3 | bellard | /* Context base + context number */
|
134 | 3deaeab7 | blueswir1 | pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2); |
135 | 49be8030 | bellard | pde = ldl_phys(pde_ptr); |
136 | e8af50a3 | bellard | |
137 | e8af50a3 | bellard | /* Ctx pde */
|
138 | e8af50a3 | bellard | switch (pde & PTE_ENTRYTYPE_MASK) {
|
139 | e80cfcfc | bellard | default:
|
140 | e8af50a3 | bellard | case 0: /* Invalid */ |
141 | 0f8a249a | blueswir1 | return 1 << 2; |
142 | e80cfcfc | bellard | case 2: /* L0 PTE, maybe should not happen? */ |
143 | e8af50a3 | bellard | case 3: /* Reserved */ |
144 | 7483750d | bellard | return 4 << 2; |
145 | e80cfcfc | bellard | case 1: /* L0 PDE */ |
146 | 0f8a249a | blueswir1 | pde_ptr = ((address >> 22) & ~3) + ((pde & ~3) << 4); |
147 | 49be8030 | bellard | pde = ldl_phys(pde_ptr); |
148 | e8af50a3 | bellard | |
149 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
150 | 0f8a249a | blueswir1 | default:
|
151 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
152 | 0f8a249a | blueswir1 | return (1 << 8) | (1 << 2); |
153 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
154 | 0f8a249a | blueswir1 | return (1 << 8) | (4 << 2); |
155 | 0f8a249a | blueswir1 | case 1: /* L1 PDE */ |
156 | 0f8a249a | blueswir1 | pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4); |
157 | 49be8030 | bellard | pde = ldl_phys(pde_ptr); |
158 | e8af50a3 | bellard | |
159 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
160 | 0f8a249a | blueswir1 | default:
|
161 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
162 | 0f8a249a | blueswir1 | return (2 << 8) | (1 << 2); |
163 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
164 | 0f8a249a | blueswir1 | return (2 << 8) | (4 << 2); |
165 | 0f8a249a | blueswir1 | case 1: /* L2 PDE */ |
166 | 0f8a249a | blueswir1 | pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4); |
167 | 49be8030 | bellard | pde = ldl_phys(pde_ptr); |
168 | e8af50a3 | bellard | |
169 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
170 | 0f8a249a | blueswir1 | default:
|
171 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
172 | 0f8a249a | blueswir1 | return (3 << 8) | (1 << 2); |
173 | 0f8a249a | blueswir1 | case 1: /* PDE, should not happen */ |
174 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
175 | 0f8a249a | blueswir1 | return (3 << 8) | (4 << 2); |
176 | 0f8a249a | blueswir1 | case 2: /* L3 PTE */ |
177 | 0f8a249a | blueswir1 | virt_addr = address & TARGET_PAGE_MASK; |
178 | 77f193da | blueswir1 | page_offset = (address & TARGET_PAGE_MASK) & |
179 | 77f193da | blueswir1 | (TARGET_PAGE_SIZE - 1);
|
180 | 0f8a249a | blueswir1 | } |
181 | 0f8a249a | blueswir1 | break;
|
182 | 0f8a249a | blueswir1 | case 2: /* L2 PTE */ |
183 | 0f8a249a | blueswir1 | virt_addr = address & ~0x3ffff;
|
184 | 0f8a249a | blueswir1 | page_offset = address & 0x3ffff;
|
185 | 0f8a249a | blueswir1 | } |
186 | 0f8a249a | blueswir1 | break;
|
187 | 0f8a249a | blueswir1 | case 2: /* L1 PTE */ |
188 | 0f8a249a | blueswir1 | virt_addr = address & ~0xffffff;
|
189 | 0f8a249a | blueswir1 | page_offset = address & 0xffffff;
|
190 | 0f8a249a | blueswir1 | } |
191 | e8af50a3 | bellard | } |
192 | e8af50a3 | bellard | |
193 | e8af50a3 | bellard | /* update page modified and dirty bits */
|
194 | b769d8fe | bellard | is_dirty = (rw & 1) && !(pde & PG_MODIFIED_MASK);
|
195 | e8af50a3 | bellard | if (!(pde & PG_ACCESSED_MASK) || is_dirty) {
|
196 | 0f8a249a | blueswir1 | pde |= PG_ACCESSED_MASK; |
197 | 0f8a249a | blueswir1 | if (is_dirty)
|
198 | 0f8a249a | blueswir1 | pde |= PG_MODIFIED_MASK; |
199 | 49be8030 | bellard | stl_phys_notdirty(pde_ptr, pde); |
200 | e8af50a3 | bellard | } |
201 | e8af50a3 | bellard | /* check access */
|
202 | e8af50a3 | bellard | access_perms = (pde & PTE_ACCESS_MASK) >> PTE_ACCESS_SHIFT; |
203 | e80cfcfc | bellard | error_code = access_table[*access_index][access_perms]; |
204 | d8e3326c | bellard | if (error_code && !((env->mmuregs[0] & MMU_NF) && is_user)) |
205 | 0f8a249a | blueswir1 | return error_code;
|
206 | e8af50a3 | bellard | |
207 | e8af50a3 | bellard | /* the page can be put in the TLB */
|
208 | 227671c9 | bellard | *prot = perm_table[is_user][access_perms]; |
209 | 227671c9 | bellard | if (!(pde & PG_MODIFIED_MASK)) {
|
210 | e8af50a3 | bellard | /* only set write access if already dirty... otherwise wait
|
211 | e8af50a3 | bellard | for dirty access */
|
212 | 227671c9 | bellard | *prot &= ~PAGE_WRITE; |
213 | e8af50a3 | bellard | } |
214 | e8af50a3 | bellard | |
215 | e8af50a3 | bellard | /* Even if large ptes, we map only one 4KB page in the cache to
|
216 | e8af50a3 | bellard | avoid filling it too fast */
|
217 | 5dcb6b91 | blueswir1 | *physical = ((target_phys_addr_t)(pde & PTE_ADDR_MASK) << 4) + page_offset;
|
218 | 6f7e9aec | bellard | return error_code;
|
219 | e80cfcfc | bellard | } |
220 | e80cfcfc | bellard | |
221 | e80cfcfc | bellard | /* Perform address translation */
|
222 | af7bf89b | bellard | int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
223 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
224 | e80cfcfc | bellard | { |
225 | af7bf89b | bellard | target_phys_addr_t paddr; |
226 | 5dcb6b91 | blueswir1 | target_ulong vaddr; |
227 | e80cfcfc | bellard | int error_code = 0, prot, ret = 0, access_index; |
228 | e8af50a3 | bellard | |
229 | 77f193da | blueswir1 | error_code = get_physical_address(env, &paddr, &prot, &access_index, |
230 | 77f193da | blueswir1 | address, rw, mmu_idx); |
231 | e80cfcfc | bellard | if (error_code == 0) { |
232 | 0f8a249a | blueswir1 | vaddr = address & TARGET_PAGE_MASK; |
233 | 0f8a249a | blueswir1 | paddr &= TARGET_PAGE_MASK; |
234 | 9e61bde5 | bellard | #ifdef DEBUG_MMU
|
235 | 0f8a249a | blueswir1 | printf("Translate at " TARGET_FMT_lx " -> " TARGET_FMT_plx ", vaddr " |
236 | 5dcb6b91 | blueswir1 | TARGET_FMT_lx "\n", address, paddr, vaddr);
|
237 | 9e61bde5 | bellard | #endif
|
238 | 6ebbf390 | j_mayer | ret = tlb_set_page_exec(env, vaddr, paddr, prot, mmu_idx, is_softmmu); |
239 | 0f8a249a | blueswir1 | return ret;
|
240 | e80cfcfc | bellard | } |
241 | e8af50a3 | bellard | |
242 | e8af50a3 | bellard | if (env->mmuregs[3]) /* Fault status register */ |
243 | 0f8a249a | blueswir1 | env->mmuregs[3] = 1; /* overflow (not read before another fault) */ |
244 | 7483750d | bellard | env->mmuregs[3] |= (access_index << 5) | error_code | 2; |
245 | e8af50a3 | bellard | env->mmuregs[4] = address; /* Fault address register */ |
246 | e8af50a3 | bellard | |
247 | 878d3096 | bellard | if ((env->mmuregs[0] & MMU_NF) || env->psret == 0) { |
248 | 6f7e9aec | bellard | // No fault mode: if a mapping is available, just override
|
249 | 6f7e9aec | bellard | // permissions. If no mapping is available, redirect accesses to
|
250 | 6f7e9aec | bellard | // neverland. Fake/overridden mappings will be flushed when
|
251 | 6f7e9aec | bellard | // switching to normal mode.
|
252 | 0f8a249a | blueswir1 | vaddr = address & TARGET_PAGE_MASK; |
253 | 227671c9 | bellard | prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; |
254 | 6ebbf390 | j_mayer | ret = tlb_set_page_exec(env, vaddr, paddr, prot, mmu_idx, is_softmmu); |
255 | 0f8a249a | blueswir1 | return ret;
|
256 | 7483750d | bellard | } else {
|
257 | 7483750d | bellard | if (rw & 2) |
258 | 7483750d | bellard | env->exception_index = TT_TFAULT; |
259 | 7483750d | bellard | else
|
260 | 7483750d | bellard | env->exception_index = TT_DFAULT; |
261 | 7483750d | bellard | return 1; |
262 | 878d3096 | bellard | } |
263 | e8af50a3 | bellard | } |
264 | 24741ef3 | bellard | |
265 | 24741ef3 | bellard | target_ulong mmu_probe(CPUState *env, target_ulong address, int mmulev)
|
266 | 24741ef3 | bellard | { |
267 | 24741ef3 | bellard | target_phys_addr_t pde_ptr; |
268 | 24741ef3 | bellard | uint32_t pde; |
269 | 24741ef3 | bellard | |
270 | 24741ef3 | bellard | /* Context base + context number */
|
271 | 5dcb6b91 | blueswir1 | pde_ptr = (target_phys_addr_t)(env->mmuregs[1] << 4) + |
272 | 5dcb6b91 | blueswir1 | (env->mmuregs[2] << 2); |
273 | 24741ef3 | bellard | pde = ldl_phys(pde_ptr); |
274 | 24741ef3 | bellard | |
275 | 24741ef3 | bellard | switch (pde & PTE_ENTRYTYPE_MASK) {
|
276 | 24741ef3 | bellard | default:
|
277 | 24741ef3 | bellard | case 0: /* Invalid */ |
278 | 24741ef3 | bellard | case 2: /* PTE, maybe should not happen? */ |
279 | 24741ef3 | bellard | case 3: /* Reserved */ |
280 | 0f8a249a | blueswir1 | return 0; |
281 | 24741ef3 | bellard | case 1: /* L1 PDE */ |
282 | 0f8a249a | blueswir1 | if (mmulev == 3) |
283 | 0f8a249a | blueswir1 | return pde;
|
284 | 0f8a249a | blueswir1 | pde_ptr = ((address >> 22) & ~3) + ((pde & ~3) << 4); |
285 | 24741ef3 | bellard | pde = ldl_phys(pde_ptr); |
286 | 24741ef3 | bellard | |
287 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
288 | 0f8a249a | blueswir1 | default:
|
289 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
290 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
291 | 0f8a249a | blueswir1 | return 0; |
292 | 0f8a249a | blueswir1 | case 2: /* L1 PTE */ |
293 | 0f8a249a | blueswir1 | return pde;
|
294 | 0f8a249a | blueswir1 | case 1: /* L2 PDE */ |
295 | 0f8a249a | blueswir1 | if (mmulev == 2) |
296 | 0f8a249a | blueswir1 | return pde;
|
297 | 0f8a249a | blueswir1 | pde_ptr = ((address & 0xfc0000) >> 16) + ((pde & ~3) << 4); |
298 | 24741ef3 | bellard | pde = ldl_phys(pde_ptr); |
299 | 24741ef3 | bellard | |
300 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
301 | 0f8a249a | blueswir1 | default:
|
302 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
303 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
304 | 0f8a249a | blueswir1 | return 0; |
305 | 0f8a249a | blueswir1 | case 2: /* L2 PTE */ |
306 | 0f8a249a | blueswir1 | return pde;
|
307 | 0f8a249a | blueswir1 | case 1: /* L3 PDE */ |
308 | 0f8a249a | blueswir1 | if (mmulev == 1) |
309 | 0f8a249a | blueswir1 | return pde;
|
310 | 0f8a249a | blueswir1 | pde_ptr = ((address & 0x3f000) >> 10) + ((pde & ~3) << 4); |
311 | 24741ef3 | bellard | pde = ldl_phys(pde_ptr); |
312 | 24741ef3 | bellard | |
313 | 0f8a249a | blueswir1 | switch (pde & PTE_ENTRYTYPE_MASK) {
|
314 | 0f8a249a | blueswir1 | default:
|
315 | 0f8a249a | blueswir1 | case 0: /* Invalid */ |
316 | 0f8a249a | blueswir1 | case 1: /* PDE, should not happen */ |
317 | 0f8a249a | blueswir1 | case 3: /* Reserved */ |
318 | 0f8a249a | blueswir1 | return 0; |
319 | 0f8a249a | blueswir1 | case 2: /* L3 PTE */ |
320 | 0f8a249a | blueswir1 | return pde;
|
321 | 0f8a249a | blueswir1 | } |
322 | 0f8a249a | blueswir1 | } |
323 | 0f8a249a | blueswir1 | } |
324 | 24741ef3 | bellard | } |
325 | 24741ef3 | bellard | return 0; |
326 | 24741ef3 | bellard | } |
327 | 24741ef3 | bellard | |
328 | 24741ef3 | bellard | #ifdef DEBUG_MMU
|
329 | 24741ef3 | bellard | void dump_mmu(CPUState *env)
|
330 | 24741ef3 | bellard | { |
331 | 5dcb6b91 | blueswir1 | target_ulong va, va1, va2; |
332 | 5dcb6b91 | blueswir1 | unsigned int n, m, o; |
333 | 5dcb6b91 | blueswir1 | target_phys_addr_t pde_ptr, pa; |
334 | 24741ef3 | bellard | uint32_t pde; |
335 | 24741ef3 | bellard | |
336 | 24741ef3 | bellard | printf("MMU dump:\n");
|
337 | 24741ef3 | bellard | pde_ptr = (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2); |
338 | 24741ef3 | bellard | pde = ldl_phys(pde_ptr); |
339 | 5dcb6b91 | blueswir1 | printf("Root ptr: " TARGET_FMT_plx ", ctx: %d\n", |
340 | 5dcb6b91 | blueswir1 | (target_phys_addr_t)env->mmuregs[1] << 4, env->mmuregs[2]); |
341 | 24741ef3 | bellard | for (n = 0, va = 0; n < 256; n++, va += 16 * 1024 * 1024) { |
342 | 0f8a249a | blueswir1 | pde = mmu_probe(env, va, 2);
|
343 | 0f8a249a | blueswir1 | if (pde) {
|
344 | 0f8a249a | blueswir1 | pa = cpu_get_phys_page_debug(env, va); |
345 | 0f8a249a | blueswir1 | printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx |
346 | 5dcb6b91 | blueswir1 | " PDE: " TARGET_FMT_lx "\n", va, pa, pde); |
347 | 0f8a249a | blueswir1 | for (m = 0, va1 = va; m < 64; m++, va1 += 256 * 1024) { |
348 | 0f8a249a | blueswir1 | pde = mmu_probe(env, va1, 1);
|
349 | 0f8a249a | blueswir1 | if (pde) {
|
350 | 0f8a249a | blueswir1 | pa = cpu_get_phys_page_debug(env, va1); |
351 | 0f8a249a | blueswir1 | printf(" VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx |
352 | 5dcb6b91 | blueswir1 | " PDE: " TARGET_FMT_lx "\n", va1, pa, pde); |
353 | 0f8a249a | blueswir1 | for (o = 0, va2 = va1; o < 64; o++, va2 += 4 * 1024) { |
354 | 0f8a249a | blueswir1 | pde = mmu_probe(env, va2, 0);
|
355 | 0f8a249a | blueswir1 | if (pde) {
|
356 | 0f8a249a | blueswir1 | pa = cpu_get_phys_page_debug(env, va2); |
357 | 0f8a249a | blueswir1 | printf(" VA: " TARGET_FMT_lx ", PA: " |
358 | 5dcb6b91 | blueswir1 | TARGET_FMT_plx " PTE: " TARGET_FMT_lx "\n", |
359 | 5dcb6b91 | blueswir1 | va2, pa, pde); |
360 | 0f8a249a | blueswir1 | } |
361 | 0f8a249a | blueswir1 | } |
362 | 0f8a249a | blueswir1 | } |
363 | 0f8a249a | blueswir1 | } |
364 | 0f8a249a | blueswir1 | } |
365 | 24741ef3 | bellard | } |
366 | 24741ef3 | bellard | printf("MMU dump ends\n");
|
367 | 24741ef3 | bellard | } |
368 | 24741ef3 | bellard | #endif /* DEBUG_MMU */ |
369 | 24741ef3 | bellard | |
370 | 24741ef3 | bellard | #else /* !TARGET_SPARC64 */ |
371 | e8807b14 | Igor Kovalenko | |
372 | e8807b14 | Igor Kovalenko | // 41 bit physical address space
|
373 | e8807b14 | Igor Kovalenko | static inline target_phys_addr_t ultrasparc_truncate_physical(uint64_t x) |
374 | e8807b14 | Igor Kovalenko | { |
375 | e8807b14 | Igor Kovalenko | return x & 0x1ffffffffffULL; |
376 | e8807b14 | Igor Kovalenko | } |
377 | e8807b14 | Igor Kovalenko | |
378 | 83469015 | bellard | /*
|
379 | 83469015 | bellard | * UltraSparc IIi I/DMMUs
|
380 | 83469015 | bellard | */
|
381 | 536ba015 | Igor Kovalenko | |
382 | 536ba015 | Igor Kovalenko | static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask) |
383 | 536ba015 | Igor Kovalenko | { |
384 | 536ba015 | Igor Kovalenko | return (x & mask) == (y & mask);
|
385 | 536ba015 | Igor Kovalenko | } |
386 | 536ba015 | Igor Kovalenko | |
387 | 536ba015 | Igor Kovalenko | // Returns true if TTE tag is valid and matches virtual address value in context
|
388 | 536ba015 | Igor Kovalenko | // requires virtual address mask value calculated from TTE entry size
|
389 | 536ba015 | Igor Kovalenko | static inline int ultrasparc_tag_match(uint64_t tlb_tag, uint64_t tlb_tte, |
390 | 536ba015 | Igor Kovalenko | uint64_t address, uint64_t context, |
391 | 536ba015 | Igor Kovalenko | target_phys_addr_t *physical) |
392 | 536ba015 | Igor Kovalenko | { |
393 | 536ba015 | Igor Kovalenko | uint64_t mask; |
394 | 536ba015 | Igor Kovalenko | |
395 | 536ba015 | Igor Kovalenko | switch ((tlb_tte >> 61) & 3) { |
396 | 536ba015 | Igor Kovalenko | default:
|
397 | 536ba015 | Igor Kovalenko | case 0x0: // 8k |
398 | 536ba015 | Igor Kovalenko | mask = 0xffffffffffffe000ULL;
|
399 | 536ba015 | Igor Kovalenko | break;
|
400 | 536ba015 | Igor Kovalenko | case 0x1: // 64k |
401 | 536ba015 | Igor Kovalenko | mask = 0xffffffffffff0000ULL;
|
402 | 536ba015 | Igor Kovalenko | break;
|
403 | 536ba015 | Igor Kovalenko | case 0x2: // 512k |
404 | 536ba015 | Igor Kovalenko | mask = 0xfffffffffff80000ULL;
|
405 | 536ba015 | Igor Kovalenko | break;
|
406 | 536ba015 | Igor Kovalenko | case 0x3: // 4M |
407 | 536ba015 | Igor Kovalenko | mask = 0xffffffffffc00000ULL;
|
408 | 536ba015 | Igor Kovalenko | break;
|
409 | 536ba015 | Igor Kovalenko | } |
410 | 536ba015 | Igor Kovalenko | |
411 | 536ba015 | Igor Kovalenko | // valid, context match, virtual address match?
|
412 | 536ba015 | Igor Kovalenko | if ((tlb_tte & 0x8000000000000000ULL) && |
413 | 536ba015 | Igor Kovalenko | compare_masked(context, tlb_tag, 0x1fff) &&
|
414 | 536ba015 | Igor Kovalenko | compare_masked(address, tlb_tag, mask)) |
415 | 536ba015 | Igor Kovalenko | { |
416 | 536ba015 | Igor Kovalenko | // decode physical address
|
417 | 536ba015 | Igor Kovalenko | *physical = ((tlb_tte & mask) | (address & ~mask)) & 0x1ffffffe000ULL;
|
418 | 536ba015 | Igor Kovalenko | return 1; |
419 | 536ba015 | Igor Kovalenko | } |
420 | 536ba015 | Igor Kovalenko | |
421 | 536ba015 | Igor Kovalenko | return 0; |
422 | 536ba015 | Igor Kovalenko | } |
423 | 536ba015 | Igor Kovalenko | |
424 | 77f193da | blueswir1 | static int get_physical_address_data(CPUState *env, |
425 | 77f193da | blueswir1 | target_phys_addr_t *physical, int *prot,
|
426 | 22548760 | blueswir1 | target_ulong address, int rw, int is_user) |
427 | 3475187d | bellard | { |
428 | 3475187d | bellard | unsigned int i; |
429 | 536ba015 | Igor Kovalenko | uint64_t context; |
430 | 3475187d | bellard | |
431 | 3475187d | bellard | if ((env->lsu & DMMU_E) == 0) { /* DMMU disabled */ |
432 | e8807b14 | Igor Kovalenko | *physical = ultrasparc_truncate_physical(address); |
433 | 0f8a249a | blueswir1 | *prot = PAGE_READ | PAGE_WRITE; |
434 | 3475187d | bellard | return 0; |
435 | 3475187d | bellard | } |
436 | 3475187d | bellard | |
437 | 536ba015 | Igor Kovalenko | context = env->dmmuregs[1] & 0x1fff; |
438 | 536ba015 | Igor Kovalenko | |
439 | 3475187d | bellard | for (i = 0; i < 64; i++) { |
440 | afdf8109 | blueswir1 | // ctx match, vaddr match, valid?
|
441 | 536ba015 | Igor Kovalenko | if (ultrasparc_tag_match(env->dtlb_tag[i], env->dtlb_tte[i],
|
442 | 536ba015 | Igor Kovalenko | address, context, physical) |
443 | 536ba015 | Igor Kovalenko | ) { |
444 | afdf8109 | blueswir1 | // access ok?
|
445 | afdf8109 | blueswir1 | if (((env->dtlb_tte[i] & 0x4) && is_user) || |
446 | 0f8a249a | blueswir1 | (!(env->dtlb_tte[i] & 0x2) && (rw == 1))) { |
447 | 0f8a249a | blueswir1 | if (env->dmmuregs[3]) /* Fault status register */ |
448 | 77f193da | blueswir1 | env->dmmuregs[3] = 2; /* overflow (not read before |
449 | 77f193da | blueswir1 | another fault) */
|
450 | 0f8a249a | blueswir1 | env->dmmuregs[3] |= (is_user << 3) | ((rw == 1) << 2) | 1; |
451 | 0f8a249a | blueswir1 | env->dmmuregs[4] = address; /* Fault address register */ |
452 | 0f8a249a | blueswir1 | env->exception_index = TT_DFAULT; |
453 | 83469015 | bellard | #ifdef DEBUG_MMU
|
454 | 0f8a249a | blueswir1 | printf("DFAULT at 0x%" PRIx64 "\n", address); |
455 | 83469015 | bellard | #endif
|
456 | 0f8a249a | blueswir1 | return 1; |
457 | 0f8a249a | blueswir1 | } |
458 | 0f8a249a | blueswir1 | *prot = PAGE_READ; |
459 | 0f8a249a | blueswir1 | if (env->dtlb_tte[i] & 0x2) |
460 | 0f8a249a | blueswir1 | *prot |= PAGE_WRITE; |
461 | 0f8a249a | blueswir1 | return 0; |
462 | 0f8a249a | blueswir1 | } |
463 | 3475187d | bellard | } |
464 | 83469015 | bellard | #ifdef DEBUG_MMU
|
465 | 26a76461 | bellard | printf("DMISS at 0x%" PRIx64 "\n", address); |
466 | 83469015 | bellard | #endif
|
467 | 536ba015 | Igor Kovalenko | env->dmmuregs[6] = (address & ~0x1fffULL) | context; |
468 | 83469015 | bellard | env->exception_index = TT_DMISS; |
469 | 3475187d | bellard | return 1; |
470 | 3475187d | bellard | } |
471 | 3475187d | bellard | |
472 | 77f193da | blueswir1 | static int get_physical_address_code(CPUState *env, |
473 | 77f193da | blueswir1 | target_phys_addr_t *physical, int *prot,
|
474 | 22548760 | blueswir1 | target_ulong address, int is_user)
|
475 | 3475187d | bellard | { |
476 | 3475187d | bellard | unsigned int i; |
477 | 536ba015 | Igor Kovalenko | uint64_t context; |
478 | 3475187d | bellard | |
479 | e8807b14 | Igor Kovalenko | if ((env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0) { |
480 | e8807b14 | Igor Kovalenko | /* IMMU disabled */
|
481 | e8807b14 | Igor Kovalenko | *physical = ultrasparc_truncate_physical(address); |
482 | 0f8a249a | blueswir1 | *prot = PAGE_EXEC; |
483 | 3475187d | bellard | return 0; |
484 | 3475187d | bellard | } |
485 | 83469015 | bellard | |
486 | 536ba015 | Igor Kovalenko | context = env->dmmuregs[1] & 0x1fff; |
487 | 536ba015 | Igor Kovalenko | |
488 | 3475187d | bellard | for (i = 0; i < 64; i++) { |
489 | afdf8109 | blueswir1 | // ctx match, vaddr match, valid?
|
490 | 536ba015 | Igor Kovalenko | if (ultrasparc_tag_match(env->itlb_tag[i], env->itlb_tte[i],
|
491 | 536ba015 | Igor Kovalenko | address, context, physical) |
492 | 536ba015 | Igor Kovalenko | ) { |
493 | afdf8109 | blueswir1 | // access ok?
|
494 | afdf8109 | blueswir1 | if ((env->itlb_tte[i] & 0x4) && is_user) { |
495 | 0f8a249a | blueswir1 | if (env->immuregs[3]) /* Fault status register */ |
496 | 77f193da | blueswir1 | env->immuregs[3] = 2; /* overflow (not read before |
497 | 77f193da | blueswir1 | another fault) */
|
498 | 0f8a249a | blueswir1 | env->immuregs[3] |= (is_user << 3) | 1; |
499 | 0f8a249a | blueswir1 | env->exception_index = TT_TFAULT; |
500 | 83469015 | bellard | #ifdef DEBUG_MMU
|
501 | 0f8a249a | blueswir1 | printf("TFAULT at 0x%" PRIx64 "\n", address); |
502 | 83469015 | bellard | #endif
|
503 | 0f8a249a | blueswir1 | return 1; |
504 | 0f8a249a | blueswir1 | } |
505 | 0f8a249a | blueswir1 | *prot = PAGE_EXEC; |
506 | 0f8a249a | blueswir1 | return 0; |
507 | 0f8a249a | blueswir1 | } |
508 | 3475187d | bellard | } |
509 | 83469015 | bellard | #ifdef DEBUG_MMU
|
510 | 26a76461 | bellard | printf("TMISS at 0x%" PRIx64 "\n", address); |
511 | 83469015 | bellard | #endif
|
512 | 7ab463cb | Blue Swirl | /* Context is stored in DMMU (dmmuregs[1]) also for IMMU */
|
513 | 536ba015 | Igor Kovalenko | env->immuregs[6] = (address & ~0x1fffULL) | context; |
514 | 83469015 | bellard | env->exception_index = TT_TMISS; |
515 | 3475187d | bellard | return 1; |
516 | 3475187d | bellard | } |
517 | 3475187d | bellard | |
518 | c48fcb47 | blueswir1 | static int get_physical_address(CPUState *env, target_phys_addr_t *physical, |
519 | c48fcb47 | blueswir1 | int *prot, int *access_index, |
520 | c48fcb47 | blueswir1 | target_ulong address, int rw, int mmu_idx) |
521 | 3475187d | bellard | { |
522 | 6ebbf390 | j_mayer | int is_user = mmu_idx == MMU_USER_IDX;
|
523 | 6ebbf390 | j_mayer | |
524 | 3475187d | bellard | if (rw == 2) |
525 | 22548760 | blueswir1 | return get_physical_address_code(env, physical, prot, address,
|
526 | 22548760 | blueswir1 | is_user); |
527 | 3475187d | bellard | else
|
528 | 22548760 | blueswir1 | return get_physical_address_data(env, physical, prot, address, rw,
|
529 | 22548760 | blueswir1 | is_user); |
530 | 3475187d | bellard | } |
531 | 3475187d | bellard | |
532 | 3475187d | bellard | /* Perform address translation */
|
533 | 3475187d | bellard | int cpu_sparc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
534 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
535 | 3475187d | bellard | { |
536 | 83469015 | bellard | target_ulong virt_addr, vaddr; |
537 | 3475187d | bellard | target_phys_addr_t paddr; |
538 | 3475187d | bellard | int error_code = 0, prot, ret = 0, access_index; |
539 | 3475187d | bellard | |
540 | 77f193da | blueswir1 | error_code = get_physical_address(env, &paddr, &prot, &access_index, |
541 | 77f193da | blueswir1 | address, rw, mmu_idx); |
542 | 3475187d | bellard | if (error_code == 0) { |
543 | 0f8a249a | blueswir1 | virt_addr = address & TARGET_PAGE_MASK; |
544 | 77f193da | blueswir1 | vaddr = virt_addr + ((address & TARGET_PAGE_MASK) & |
545 | 77f193da | blueswir1 | (TARGET_PAGE_SIZE - 1));
|
546 | 83469015 | bellard | #ifdef DEBUG_MMU
|
547 | 77f193da | blueswir1 | printf("Translate at 0x%" PRIx64 " -> 0x%" PRIx64 ", vaddr 0x%" PRIx64 |
548 | 77f193da | blueswir1 | "\n", address, paddr, vaddr);
|
549 | 83469015 | bellard | #endif
|
550 | 6ebbf390 | j_mayer | ret = tlb_set_page_exec(env, vaddr, paddr, prot, mmu_idx, is_softmmu); |
551 | 0f8a249a | blueswir1 | return ret;
|
552 | 3475187d | bellard | } |
553 | 3475187d | bellard | // XXX
|
554 | 3475187d | bellard | return 1; |
555 | 3475187d | bellard | } |
556 | 3475187d | bellard | |
557 | 83469015 | bellard | #ifdef DEBUG_MMU
|
558 | 83469015 | bellard | void dump_mmu(CPUState *env)
|
559 | 83469015 | bellard | { |
560 | 83469015 | bellard | unsigned int i; |
561 | 83469015 | bellard | const char *mask; |
562 | 83469015 | bellard | |
563 | 77f193da | blueswir1 | printf("MMU contexts: Primary: %" PRId64 ", Secondary: %" PRId64 "\n", |
564 | 77f193da | blueswir1 | env->dmmuregs[1], env->dmmuregs[2]); |
565 | 83469015 | bellard | if ((env->lsu & DMMU_E) == 0) { |
566 | 0f8a249a | blueswir1 | printf("DMMU disabled\n");
|
567 | 83469015 | bellard | } else {
|
568 | 0f8a249a | blueswir1 | printf("DMMU dump:\n");
|
569 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
570 | 0f8a249a | blueswir1 | switch ((env->dtlb_tte[i] >> 61) & 3) { |
571 | 0f8a249a | blueswir1 | default:
|
572 | 0f8a249a | blueswir1 | case 0x0: |
573 | 0f8a249a | blueswir1 | mask = " 8k";
|
574 | 0f8a249a | blueswir1 | break;
|
575 | 0f8a249a | blueswir1 | case 0x1: |
576 | 0f8a249a | blueswir1 | mask = " 64k";
|
577 | 0f8a249a | blueswir1 | break;
|
578 | 0f8a249a | blueswir1 | case 0x2: |
579 | 0f8a249a | blueswir1 | mask = "512k";
|
580 | 0f8a249a | blueswir1 | break;
|
581 | 0f8a249a | blueswir1 | case 0x3: |
582 | 0f8a249a | blueswir1 | mask = " 4M";
|
583 | 0f8a249a | blueswir1 | break;
|
584 | 0f8a249a | blueswir1 | } |
585 | 0f8a249a | blueswir1 | if ((env->dtlb_tte[i] & 0x8000000000000000ULL) != 0) { |
586 | 0bf9e31a | Blue Swirl | printf("VA: %" PRIx64 ", PA: %" PRIx64 |
587 | 77f193da | blueswir1 | ", %s, %s, %s, %s, ctx %" PRId64 "\n", |
588 | 0bf9e31a | Blue Swirl | env->dtlb_tag[i] & (uint64_t)~0x1fffULL,
|
589 | 0bf9e31a | Blue Swirl | env->dtlb_tte[i] & (uint64_t)0x1ffffffe000ULL,
|
590 | 0f8a249a | blueswir1 | mask, |
591 | 0f8a249a | blueswir1 | env->dtlb_tte[i] & 0x4? "priv": "user", |
592 | 0f8a249a | blueswir1 | env->dtlb_tte[i] & 0x2? "RW": "RO", |
593 | 0f8a249a | blueswir1 | env->dtlb_tte[i] & 0x40? "locked": "unlocked", |
594 | 0bf9e31a | Blue Swirl | env->dtlb_tag[i] & (uint64_t)0x1fffULL);
|
595 | 0f8a249a | blueswir1 | } |
596 | 0f8a249a | blueswir1 | } |
597 | 83469015 | bellard | } |
598 | 83469015 | bellard | if ((env->lsu & IMMU_E) == 0) { |
599 | 0f8a249a | blueswir1 | printf("IMMU disabled\n");
|
600 | 83469015 | bellard | } else {
|
601 | 0f8a249a | blueswir1 | printf("IMMU dump:\n");
|
602 | 0f8a249a | blueswir1 | for (i = 0; i < 64; i++) { |
603 | 0f8a249a | blueswir1 | switch ((env->itlb_tte[i] >> 61) & 3) { |
604 | 0f8a249a | blueswir1 | default:
|
605 | 0f8a249a | blueswir1 | case 0x0: |
606 | 0f8a249a | blueswir1 | mask = " 8k";
|
607 | 0f8a249a | blueswir1 | break;
|
608 | 0f8a249a | blueswir1 | case 0x1: |
609 | 0f8a249a | blueswir1 | mask = " 64k";
|
610 | 0f8a249a | blueswir1 | break;
|
611 | 0f8a249a | blueswir1 | case 0x2: |
612 | 0f8a249a | blueswir1 | mask = "512k";
|
613 | 0f8a249a | blueswir1 | break;
|
614 | 0f8a249a | blueswir1 | case 0x3: |
615 | 0f8a249a | blueswir1 | mask = " 4M";
|
616 | 0f8a249a | blueswir1 | break;
|
617 | 0f8a249a | blueswir1 | } |
618 | 0f8a249a | blueswir1 | if ((env->itlb_tte[i] & 0x8000000000000000ULL) != 0) { |
619 | 0bf9e31a | Blue Swirl | printf("VA: %" PRIx64 ", PA: %" PRIx64 |
620 | 77f193da | blueswir1 | ", %s, %s, %s, ctx %" PRId64 "\n", |
621 | 0bf9e31a | Blue Swirl | env->itlb_tag[i] & (uint64_t)~0x1fffULL,
|
622 | 0bf9e31a | Blue Swirl | env->itlb_tte[i] & (uint64_t)0x1ffffffe000ULL,
|
623 | 0f8a249a | blueswir1 | mask, |
624 | 0f8a249a | blueswir1 | env->itlb_tte[i] & 0x4? "priv": "user", |
625 | 0f8a249a | blueswir1 | env->itlb_tte[i] & 0x40? "locked": "unlocked", |
626 | 0bf9e31a | Blue Swirl | env->itlb_tag[i] & (uint64_t)0x1fffULL);
|
627 | 0f8a249a | blueswir1 | } |
628 | 0f8a249a | blueswir1 | } |
629 | 83469015 | bellard | } |
630 | 83469015 | bellard | } |
631 | 24741ef3 | bellard | #endif /* DEBUG_MMU */ |
632 | 24741ef3 | bellard | |
633 | 24741ef3 | bellard | #endif /* TARGET_SPARC64 */ |
634 | 24741ef3 | bellard | #endif /* !CONFIG_USER_ONLY */ |
635 | 24741ef3 | bellard | |
636 | c48fcb47 | blueswir1 | |
637 | c48fcb47 | blueswir1 | #if defined(CONFIG_USER_ONLY)
|
638 | c48fcb47 | blueswir1 | target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr) |
639 | c48fcb47 | blueswir1 | { |
640 | c48fcb47 | blueswir1 | return addr;
|
641 | c48fcb47 | blueswir1 | } |
642 | c48fcb47 | blueswir1 | |
643 | c48fcb47 | blueswir1 | #else
|
644 | c48fcb47 | blueswir1 | target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr) |
645 | c48fcb47 | blueswir1 | { |
646 | c48fcb47 | blueswir1 | target_phys_addr_t phys_addr; |
647 | c48fcb47 | blueswir1 | int prot, access_index;
|
648 | c48fcb47 | blueswir1 | |
649 | c48fcb47 | blueswir1 | if (get_physical_address(env, &phys_addr, &prot, &access_index, addr, 2, |
650 | c48fcb47 | blueswir1 | MMU_KERNEL_IDX) != 0)
|
651 | c48fcb47 | blueswir1 | if (get_physical_address(env, &phys_addr, &prot, &access_index, addr,
|
652 | c48fcb47 | blueswir1 | 0, MMU_KERNEL_IDX) != 0) |
653 | c48fcb47 | blueswir1 | return -1; |
654 | c48fcb47 | blueswir1 | if (cpu_get_physical_page_desc(phys_addr) == IO_MEM_UNASSIGNED)
|
655 | c48fcb47 | blueswir1 | return -1; |
656 | c48fcb47 | blueswir1 | return phys_addr;
|
657 | c48fcb47 | blueswir1 | } |
658 | c48fcb47 | blueswir1 | #endif
|
659 | c48fcb47 | blueswir1 | |
660 | c48fcb47 | blueswir1 | void cpu_reset(CPUSPARCState *env)
|
661 | c48fcb47 | blueswir1 | { |
662 | eca1bdf4 | aliguori | if (qemu_loglevel_mask(CPU_LOG_RESET)) {
|
663 | eca1bdf4 | aliguori | qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
|
664 | eca1bdf4 | aliguori | log_cpu_state(env, 0);
|
665 | eca1bdf4 | aliguori | } |
666 | eca1bdf4 | aliguori | |
667 | c48fcb47 | blueswir1 | tlb_flush(env, 1);
|
668 | c48fcb47 | blueswir1 | env->cwp = 0;
|
669 | 5210977a | Igor Kovalenko | #ifndef TARGET_SPARC64
|
670 | c48fcb47 | blueswir1 | env->wim = 1;
|
671 | 5210977a | Igor Kovalenko | #endif
|
672 | c48fcb47 | blueswir1 | env->regwptr = env->regbase + (env->cwp * 16);
|
673 | c48fcb47 | blueswir1 | #if defined(CONFIG_USER_ONLY)
|
674 | c48fcb47 | blueswir1 | #ifdef TARGET_SPARC64
|
675 | 1a14026e | blueswir1 | env->cleanwin = env->nwindows - 2;
|
676 | 1a14026e | blueswir1 | env->cansave = env->nwindows - 2;
|
677 | c48fcb47 | blueswir1 | env->pstate = PS_RMO | PS_PEF | PS_IE; |
678 | c48fcb47 | blueswir1 | env->asi = 0x82; // Primary no-fault |
679 | c48fcb47 | blueswir1 | #endif
|
680 | c48fcb47 | blueswir1 | #else
|
681 | 5210977a | Igor Kovalenko | #if !defined(TARGET_SPARC64)
|
682 | c48fcb47 | blueswir1 | env->psret = 0;
|
683 | 5210977a | Igor Kovalenko | #endif
|
684 | c48fcb47 | blueswir1 | env->psrs = 1;
|
685 | c48fcb47 | blueswir1 | env->psrps = 1;
|
686 | 8393617c | Blue Swirl | CC_OP = CC_OP_FLAGS; |
687 | c48fcb47 | blueswir1 | #ifdef TARGET_SPARC64
|
688 | c48fcb47 | blueswir1 | env->pstate = PS_PRIV; |
689 | c48fcb47 | blueswir1 | env->hpstate = HS_PRIV; |
690 | c19148bd | blueswir1 | env->tsptr = &env->ts[env->tl & MAXTL_MASK]; |
691 | 415fc906 | blueswir1 | env->lsu = 0;
|
692 | c48fcb47 | blueswir1 | #else
|
693 | c48fcb47 | blueswir1 | env->mmuregs[0] &= ~(MMU_E | MMU_NF);
|
694 | 5578ceab | blueswir1 | env->mmuregs[0] |= env->def->mmu_bm;
|
695 | c48fcb47 | blueswir1 | #endif
|
696 | e87231d4 | blueswir1 | env->pc = 0;
|
697 | c48fcb47 | blueswir1 | env->npc = env->pc + 4;
|
698 | c48fcb47 | blueswir1 | #endif
|
699 | c48fcb47 | blueswir1 | } |
700 | c48fcb47 | blueswir1 | |
701 | 64a88d5d | blueswir1 | static int cpu_sparc_register(CPUSPARCState *env, const char *cpu_model) |
702 | c48fcb47 | blueswir1 | { |
703 | 64a88d5d | blueswir1 | sparc_def_t def1, *def = &def1; |
704 | c48fcb47 | blueswir1 | |
705 | 64a88d5d | blueswir1 | if (cpu_sparc_find_by_name(def, cpu_model) < 0) |
706 | 64a88d5d | blueswir1 | return -1; |
707 | c48fcb47 | blueswir1 | |
708 | 5578ceab | blueswir1 | env->def = qemu_mallocz(sizeof(*def));
|
709 | 5578ceab | blueswir1 | memcpy(env->def, def, sizeof(*def));
|
710 | 5578ceab | blueswir1 | #if defined(CONFIG_USER_ONLY)
|
711 | 5578ceab | blueswir1 | if ((env->def->features & CPU_FEATURE_FLOAT))
|
712 | 5578ceab | blueswir1 | env->def->features |= CPU_FEATURE_FLOAT128; |
713 | 5578ceab | blueswir1 | #endif
|
714 | c48fcb47 | blueswir1 | env->cpu_model_str = cpu_model; |
715 | c48fcb47 | blueswir1 | env->version = def->iu_version; |
716 | c48fcb47 | blueswir1 | env->fsr = def->fpu_version; |
717 | 1a14026e | blueswir1 | env->nwindows = def->nwindows; |
718 | c48fcb47 | blueswir1 | #if !defined(TARGET_SPARC64)
|
719 | c48fcb47 | blueswir1 | env->mmuregs[0] |= def->mmu_version;
|
720 | c48fcb47 | blueswir1 | cpu_sparc_set_id(env, 0);
|
721 | 963262de | blueswir1 | env->mxccregs[7] |= def->mxcc_version;
|
722 | 1a14026e | blueswir1 | #else
|
723 | fb79ceb9 | blueswir1 | env->mmu_version = def->mmu_version; |
724 | c19148bd | blueswir1 | env->maxtl = def->maxtl; |
725 | c19148bd | blueswir1 | env->version |= def->maxtl << 8;
|
726 | 1a14026e | blueswir1 | env->version |= def->nwindows - 1;
|
727 | c48fcb47 | blueswir1 | #endif
|
728 | 64a88d5d | blueswir1 | return 0; |
729 | 64a88d5d | blueswir1 | } |
730 | 64a88d5d | blueswir1 | |
731 | 64a88d5d | blueswir1 | static void cpu_sparc_close(CPUSPARCState *env) |
732 | 64a88d5d | blueswir1 | { |
733 | 5578ceab | blueswir1 | free(env->def); |
734 | 64a88d5d | blueswir1 | free(env); |
735 | 64a88d5d | blueswir1 | } |
736 | 64a88d5d | blueswir1 | |
737 | 64a88d5d | blueswir1 | CPUSPARCState *cpu_sparc_init(const char *cpu_model) |
738 | 64a88d5d | blueswir1 | { |
739 | 64a88d5d | blueswir1 | CPUSPARCState *env; |
740 | 64a88d5d | blueswir1 | |
741 | 64a88d5d | blueswir1 | env = qemu_mallocz(sizeof(CPUSPARCState));
|
742 | 64a88d5d | blueswir1 | cpu_exec_init(env); |
743 | c48fcb47 | blueswir1 | |
744 | c48fcb47 | blueswir1 | gen_intermediate_code_init(env); |
745 | c48fcb47 | blueswir1 | |
746 | 64a88d5d | blueswir1 | if (cpu_sparc_register(env, cpu_model) < 0) { |
747 | 64a88d5d | blueswir1 | cpu_sparc_close(env); |
748 | 64a88d5d | blueswir1 | return NULL; |
749 | 64a88d5d | blueswir1 | } |
750 | c48fcb47 | blueswir1 | cpu_reset(env); |
751 | 0bf46a40 | aliguori | qemu_init_vcpu(env); |
752 | c48fcb47 | blueswir1 | |
753 | c48fcb47 | blueswir1 | return env;
|
754 | c48fcb47 | blueswir1 | } |
755 | c48fcb47 | blueswir1 | |
756 | c48fcb47 | blueswir1 | void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu) |
757 | c48fcb47 | blueswir1 | { |
758 | c48fcb47 | blueswir1 | #if !defined(TARGET_SPARC64)
|
759 | c48fcb47 | blueswir1 | env->mxccregs[7] = ((cpu + 8) & 0xf) << 24; |
760 | c48fcb47 | blueswir1 | #endif
|
761 | c48fcb47 | blueswir1 | } |
762 | c48fcb47 | blueswir1 | |
763 | c48fcb47 | blueswir1 | static const sparc_def_t sparc_defs[] = { |
764 | c48fcb47 | blueswir1 | #ifdef TARGET_SPARC64
|
765 | c48fcb47 | blueswir1 | { |
766 | c48fcb47 | blueswir1 | .name = "Fujitsu Sparc64",
|
767 | c19148bd | blueswir1 | .iu_version = ((0x04ULL << 48) | (0x02ULL << 32) | (0ULL << 24)), |
768 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
769 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
770 | 1a14026e | blueswir1 | .nwindows = 4,
|
771 | c19148bd | blueswir1 | .maxtl = 4,
|
772 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
773 | c48fcb47 | blueswir1 | }, |
774 | c48fcb47 | blueswir1 | { |
775 | c48fcb47 | blueswir1 | .name = "Fujitsu Sparc64 III",
|
776 | c19148bd | blueswir1 | .iu_version = ((0x04ULL << 48) | (0x03ULL << 32) | (0ULL << 24)), |
777 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
778 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
779 | 1a14026e | blueswir1 | .nwindows = 5,
|
780 | c19148bd | blueswir1 | .maxtl = 4,
|
781 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
782 | c48fcb47 | blueswir1 | }, |
783 | c48fcb47 | blueswir1 | { |
784 | c48fcb47 | blueswir1 | .name = "Fujitsu Sparc64 IV",
|
785 | c19148bd | blueswir1 | .iu_version = ((0x04ULL << 48) | (0x04ULL << 32) | (0ULL << 24)), |
786 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
787 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
788 | 1a14026e | blueswir1 | .nwindows = 8,
|
789 | c19148bd | blueswir1 | .maxtl = 5,
|
790 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
791 | c48fcb47 | blueswir1 | }, |
792 | c48fcb47 | blueswir1 | { |
793 | c48fcb47 | blueswir1 | .name = "Fujitsu Sparc64 V",
|
794 | c19148bd | blueswir1 | .iu_version = ((0x04ULL << 48) | (0x05ULL << 32) | (0x51ULL << 24)), |
795 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
796 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
797 | 1a14026e | blueswir1 | .nwindows = 8,
|
798 | c19148bd | blueswir1 | .maxtl = 5,
|
799 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
800 | c48fcb47 | blueswir1 | }, |
801 | c48fcb47 | blueswir1 | { |
802 | c48fcb47 | blueswir1 | .name = "TI UltraSparc I",
|
803 | c19148bd | blueswir1 | .iu_version = ((0x17ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)), |
804 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
805 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
806 | 1a14026e | blueswir1 | .nwindows = 8,
|
807 | c19148bd | blueswir1 | .maxtl = 5,
|
808 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
809 | c48fcb47 | blueswir1 | }, |
810 | c48fcb47 | blueswir1 | { |
811 | c48fcb47 | blueswir1 | .name = "TI UltraSparc II",
|
812 | c19148bd | blueswir1 | .iu_version = ((0x17ULL << 48) | (0x11ULL << 32) | (0x20ULL << 24)), |
813 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
814 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
815 | 1a14026e | blueswir1 | .nwindows = 8,
|
816 | c19148bd | blueswir1 | .maxtl = 5,
|
817 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
818 | c48fcb47 | blueswir1 | }, |
819 | c48fcb47 | blueswir1 | { |
820 | c48fcb47 | blueswir1 | .name = "TI UltraSparc IIi",
|
821 | c19148bd | blueswir1 | .iu_version = ((0x17ULL << 48) | (0x12ULL << 32) | (0x91ULL << 24)), |
822 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
823 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
824 | 1a14026e | blueswir1 | .nwindows = 8,
|
825 | c19148bd | blueswir1 | .maxtl = 5,
|
826 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
827 | c48fcb47 | blueswir1 | }, |
828 | c48fcb47 | blueswir1 | { |
829 | c48fcb47 | blueswir1 | .name = "TI UltraSparc IIe",
|
830 | c19148bd | blueswir1 | .iu_version = ((0x17ULL << 48) | (0x13ULL << 32) | (0x14ULL << 24)), |
831 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
832 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
833 | 1a14026e | blueswir1 | .nwindows = 8,
|
834 | c19148bd | blueswir1 | .maxtl = 5,
|
835 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
836 | c48fcb47 | blueswir1 | }, |
837 | c48fcb47 | blueswir1 | { |
838 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc III",
|
839 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x14ULL << 32) | (0x34ULL << 24)), |
840 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
841 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
842 | 1a14026e | blueswir1 | .nwindows = 8,
|
843 | c19148bd | blueswir1 | .maxtl = 5,
|
844 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
845 | c48fcb47 | blueswir1 | }, |
846 | c48fcb47 | blueswir1 | { |
847 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc III Cu",
|
848 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x15ULL << 32) | (0x41ULL << 24)), |
849 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
850 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_3, |
851 | 1a14026e | blueswir1 | .nwindows = 8,
|
852 | c19148bd | blueswir1 | .maxtl = 5,
|
853 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
854 | c48fcb47 | blueswir1 | }, |
855 | c48fcb47 | blueswir1 | { |
856 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc IIIi",
|
857 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x16ULL << 32) | (0x34ULL << 24)), |
858 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
859 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
860 | 1a14026e | blueswir1 | .nwindows = 8,
|
861 | c19148bd | blueswir1 | .maxtl = 5,
|
862 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
863 | c48fcb47 | blueswir1 | }, |
864 | c48fcb47 | blueswir1 | { |
865 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc IV",
|
866 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x18ULL << 32) | (0x31ULL << 24)), |
867 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
868 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_4, |
869 | 1a14026e | blueswir1 | .nwindows = 8,
|
870 | c19148bd | blueswir1 | .maxtl = 5,
|
871 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
872 | c48fcb47 | blueswir1 | }, |
873 | c48fcb47 | blueswir1 | { |
874 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc IV+",
|
875 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x19ULL << 32) | (0x22ULL << 24)), |
876 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
877 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
878 | 1a14026e | blueswir1 | .nwindows = 8,
|
879 | c19148bd | blueswir1 | .maxtl = 5,
|
880 | fb79ceb9 | blueswir1 | .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_CMT, |
881 | c48fcb47 | blueswir1 | }, |
882 | c48fcb47 | blueswir1 | { |
883 | c48fcb47 | blueswir1 | .name = "Sun UltraSparc IIIi+",
|
884 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x22ULL << 32) | (0ULL << 24)), |
885 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
886 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_3, |
887 | 1a14026e | blueswir1 | .nwindows = 8,
|
888 | c19148bd | blueswir1 | .maxtl = 5,
|
889 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
890 | c48fcb47 | blueswir1 | }, |
891 | c48fcb47 | blueswir1 | { |
892 | c7ba218d | blueswir1 | .name = "Sun UltraSparc T1",
|
893 | c7ba218d | blueswir1 | // defined in sparc_ifu_fdp.v and ctu.h
|
894 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x23ULL << 32) | (0x02ULL << 24)), |
895 | c7ba218d | blueswir1 | .fpu_version = 0x00000000,
|
896 | c7ba218d | blueswir1 | .mmu_version = mmu_sun4v, |
897 | c7ba218d | blueswir1 | .nwindows = 8,
|
898 | c19148bd | blueswir1 | .maxtl = 6,
|
899 | c7ba218d | blueswir1 | .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT |
900 | c7ba218d | blueswir1 | | CPU_FEATURE_GL, |
901 | c7ba218d | blueswir1 | }, |
902 | c7ba218d | blueswir1 | { |
903 | c7ba218d | blueswir1 | .name = "Sun UltraSparc T2",
|
904 | c7ba218d | blueswir1 | // defined in tlu_asi_ctl.v and n2_revid_cust.v
|
905 | c19148bd | blueswir1 | .iu_version = ((0x3eULL << 48) | (0x24ULL << 32) | (0x02ULL << 24)), |
906 | c7ba218d | blueswir1 | .fpu_version = 0x00000000,
|
907 | c7ba218d | blueswir1 | .mmu_version = mmu_sun4v, |
908 | c7ba218d | blueswir1 | .nwindows = 8,
|
909 | c19148bd | blueswir1 | .maxtl = 6,
|
910 | c7ba218d | blueswir1 | .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT |
911 | c7ba218d | blueswir1 | | CPU_FEATURE_GL, |
912 | c7ba218d | blueswir1 | }, |
913 | c7ba218d | blueswir1 | { |
914 | c48fcb47 | blueswir1 | .name = "NEC UltraSparc I",
|
915 | c19148bd | blueswir1 | .iu_version = ((0x22ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)), |
916 | c48fcb47 | blueswir1 | .fpu_version = 0x00000000,
|
917 | fb79ceb9 | blueswir1 | .mmu_version = mmu_us_12, |
918 | 1a14026e | blueswir1 | .nwindows = 8,
|
919 | c19148bd | blueswir1 | .maxtl = 5,
|
920 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
921 | c48fcb47 | blueswir1 | }, |
922 | c48fcb47 | blueswir1 | #else
|
923 | c48fcb47 | blueswir1 | { |
924 | c48fcb47 | blueswir1 | .name = "Fujitsu MB86900",
|
925 | c48fcb47 | blueswir1 | .iu_version = 0x00 << 24, /* Impl 0, ver 0 */ |
926 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ |
927 | c48fcb47 | blueswir1 | .mmu_version = 0x00 << 24, /* Impl 0, ver 0 */ |
928 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
929 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
930 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
931 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
932 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
933 | 1a14026e | blueswir1 | .nwindows = 7,
|
934 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_FSMULD, |
935 | c48fcb47 | blueswir1 | }, |
936 | c48fcb47 | blueswir1 | { |
937 | c48fcb47 | blueswir1 | .name = "Fujitsu MB86904",
|
938 | c48fcb47 | blueswir1 | .iu_version = 0x04 << 24, /* Impl 0, ver 4 */ |
939 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ |
940 | c48fcb47 | blueswir1 | .mmu_version = 0x04 << 24, /* Impl 0, ver 4 */ |
941 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
942 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x00ffffc0,
|
943 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x000000ff,
|
944 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0x00016fff,
|
945 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0x00ffffff,
|
946 | 1a14026e | blueswir1 | .nwindows = 8,
|
947 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
948 | c48fcb47 | blueswir1 | }, |
949 | c48fcb47 | blueswir1 | { |
950 | c48fcb47 | blueswir1 | .name = "Fujitsu MB86907",
|
951 | c48fcb47 | blueswir1 | .iu_version = 0x05 << 24, /* Impl 0, ver 5 */ |
952 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ |
953 | c48fcb47 | blueswir1 | .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */ |
954 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
955 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
956 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x000000ff,
|
957 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0x00016fff,
|
958 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
959 | 1a14026e | blueswir1 | .nwindows = 8,
|
960 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
961 | c48fcb47 | blueswir1 | }, |
962 | c48fcb47 | blueswir1 | { |
963 | c48fcb47 | blueswir1 | .name = "LSI L64811",
|
964 | c48fcb47 | blueswir1 | .iu_version = 0x10 << 24, /* Impl 1, ver 0 */ |
965 | c48fcb47 | blueswir1 | .fpu_version = 1 << 17, /* FPU version 1 (LSI L64814) */ |
966 | c48fcb47 | blueswir1 | .mmu_version = 0x10 << 24, |
967 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
968 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
969 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
970 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
971 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
972 | 1a14026e | blueswir1 | .nwindows = 8,
|
973 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT | |
974 | e30b4678 | blueswir1 | CPU_FEATURE_FSMULD, |
975 | c48fcb47 | blueswir1 | }, |
976 | c48fcb47 | blueswir1 | { |
977 | c48fcb47 | blueswir1 | .name = "Cypress CY7C601",
|
978 | c48fcb47 | blueswir1 | .iu_version = 0x11 << 24, /* Impl 1, ver 1 */ |
979 | c48fcb47 | blueswir1 | .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */ |
980 | c48fcb47 | blueswir1 | .mmu_version = 0x10 << 24, |
981 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
982 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
983 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
984 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
985 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
986 | 1a14026e | blueswir1 | .nwindows = 8,
|
987 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT | |
988 | e30b4678 | blueswir1 | CPU_FEATURE_FSMULD, |
989 | c48fcb47 | blueswir1 | }, |
990 | c48fcb47 | blueswir1 | { |
991 | c48fcb47 | blueswir1 | .name = "Cypress CY7C611",
|
992 | c48fcb47 | blueswir1 | .iu_version = 0x13 << 24, /* Impl 1, ver 3 */ |
993 | c48fcb47 | blueswir1 | .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */ |
994 | c48fcb47 | blueswir1 | .mmu_version = 0x10 << 24, |
995 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
996 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
997 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
998 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
999 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1000 | 1a14026e | blueswir1 | .nwindows = 8,
|
1001 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT | |
1002 | e30b4678 | blueswir1 | CPU_FEATURE_FSMULD, |
1003 | c48fcb47 | blueswir1 | }, |
1004 | c48fcb47 | blueswir1 | { |
1005 | c48fcb47 | blueswir1 | .name = "TI MicroSparc I",
|
1006 | c48fcb47 | blueswir1 | .iu_version = 0x41000000,
|
1007 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, |
1008 | c48fcb47 | blueswir1 | .mmu_version = 0x41000000,
|
1009 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1010 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1011 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1012 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0x00016fff,
|
1013 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0x0000003f,
|
1014 | 1a14026e | blueswir1 | .nwindows = 7,
|
1015 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_MUL | |
1016 | e30b4678 | blueswir1 | CPU_FEATURE_DIV | CPU_FEATURE_FLUSH | CPU_FEATURE_FSQRT | |
1017 | e30b4678 | blueswir1 | CPU_FEATURE_FMUL, |
1018 | c48fcb47 | blueswir1 | }, |
1019 | c48fcb47 | blueswir1 | { |
1020 | c48fcb47 | blueswir1 | .name = "TI MicroSparc II",
|
1021 | c48fcb47 | blueswir1 | .iu_version = 0x42000000,
|
1022 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, |
1023 | c48fcb47 | blueswir1 | .mmu_version = 0x02000000,
|
1024 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1025 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x00ffffc0,
|
1026 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x000000ff,
|
1027 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0x00016fff,
|
1028 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0x00ffffff,
|
1029 | 1a14026e | blueswir1 | .nwindows = 8,
|
1030 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1031 | c48fcb47 | blueswir1 | }, |
1032 | c48fcb47 | blueswir1 | { |
1033 | c48fcb47 | blueswir1 | .name = "TI MicroSparc IIep",
|
1034 | c48fcb47 | blueswir1 | .iu_version = 0x42000000,
|
1035 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, |
1036 | c48fcb47 | blueswir1 | .mmu_version = 0x04000000,
|
1037 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1038 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x00ffffc0,
|
1039 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x000000ff,
|
1040 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0x00016bff,
|
1041 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0x00ffffff,
|
1042 | 1a14026e | blueswir1 | .nwindows = 8,
|
1043 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1044 | c48fcb47 | blueswir1 | }, |
1045 | c48fcb47 | blueswir1 | { |
1046 | b5154bde | blueswir1 | .name = "TI SuperSparc 40", // STP1020NPGA |
1047 | 963262de | blueswir1 | .iu_version = 0x41000000, // SuperSPARC 2.x |
1048 | b5154bde | blueswir1 | .fpu_version = 0 << 17, |
1049 | 963262de | blueswir1 | .mmu_version = 0x00000800, // SuperSPARC 2.x, no MXCC |
1050 | b5154bde | blueswir1 | .mmu_bm = 0x00002000,
|
1051 | b5154bde | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1052 | b5154bde | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1053 | b5154bde | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1054 | b5154bde | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1055 | 1a14026e | blueswir1 | .nwindows = 8,
|
1056 | b5154bde | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1057 | b5154bde | blueswir1 | }, |
1058 | b5154bde | blueswir1 | { |
1059 | b5154bde | blueswir1 | .name = "TI SuperSparc 50", // STP1020PGA |
1060 | 963262de | blueswir1 | .iu_version = 0x40000000, // SuperSPARC 3.x |
1061 | b5154bde | blueswir1 | .fpu_version = 0 << 17, |
1062 | 963262de | blueswir1 | .mmu_version = 0x01000800, // SuperSPARC 3.x, no MXCC |
1063 | b5154bde | blueswir1 | .mmu_bm = 0x00002000,
|
1064 | b5154bde | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1065 | b5154bde | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1066 | b5154bde | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1067 | b5154bde | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1068 | 1a14026e | blueswir1 | .nwindows = 8,
|
1069 | b5154bde | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1070 | b5154bde | blueswir1 | }, |
1071 | b5154bde | blueswir1 | { |
1072 | c48fcb47 | blueswir1 | .name = "TI SuperSparc 51",
|
1073 | 963262de | blueswir1 | .iu_version = 0x40000000, // SuperSPARC 3.x |
1074 | c48fcb47 | blueswir1 | .fpu_version = 0 << 17, |
1075 | 963262de | blueswir1 | .mmu_version = 0x01000000, // SuperSPARC 3.x, MXCC |
1076 | c48fcb47 | blueswir1 | .mmu_bm = 0x00002000,
|
1077 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1078 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1079 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1080 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1081 | 963262de | blueswir1 | .mxcc_version = 0x00000104,
|
1082 | 1a14026e | blueswir1 | .nwindows = 8,
|
1083 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1084 | c48fcb47 | blueswir1 | }, |
1085 | c48fcb47 | blueswir1 | { |
1086 | b5154bde | blueswir1 | .name = "TI SuperSparc 60", // STP1020APGA |
1087 | 963262de | blueswir1 | .iu_version = 0x40000000, // SuperSPARC 3.x |
1088 | b5154bde | blueswir1 | .fpu_version = 0 << 17, |
1089 | 963262de | blueswir1 | .mmu_version = 0x01000800, // SuperSPARC 3.x, no MXCC |
1090 | b5154bde | blueswir1 | .mmu_bm = 0x00002000,
|
1091 | b5154bde | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1092 | b5154bde | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1093 | b5154bde | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1094 | b5154bde | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1095 | 1a14026e | blueswir1 | .nwindows = 8,
|
1096 | b5154bde | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1097 | b5154bde | blueswir1 | }, |
1098 | b5154bde | blueswir1 | { |
1099 | c48fcb47 | blueswir1 | .name = "TI SuperSparc 61",
|
1100 | 963262de | blueswir1 | .iu_version = 0x44000000, // SuperSPARC 3.x |
1101 | c48fcb47 | blueswir1 | .fpu_version = 0 << 17, |
1102 | 963262de | blueswir1 | .mmu_version = 0x01000000, // SuperSPARC 3.x, MXCC |
1103 | 963262de | blueswir1 | .mmu_bm = 0x00002000,
|
1104 | 963262de | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1105 | 963262de | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1106 | 963262de | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1107 | 963262de | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1108 | 963262de | blueswir1 | .mxcc_version = 0x00000104,
|
1109 | 963262de | blueswir1 | .nwindows = 8,
|
1110 | 963262de | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1111 | 963262de | blueswir1 | }, |
1112 | 963262de | blueswir1 | { |
1113 | 963262de | blueswir1 | .name = "TI SuperSparc II",
|
1114 | 963262de | blueswir1 | .iu_version = 0x40000000, // SuperSPARC II 1.x |
1115 | 963262de | blueswir1 | .fpu_version = 0 << 17, |
1116 | 963262de | blueswir1 | .mmu_version = 0x08000000, // SuperSPARC II 1.x, MXCC |
1117 | c48fcb47 | blueswir1 | .mmu_bm = 0x00002000,
|
1118 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0xffffffc0,
|
1119 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000ffff,
|
1120 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1121 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1122 | 963262de | blueswir1 | .mxcc_version = 0x00000104,
|
1123 | 1a14026e | blueswir1 | .nwindows = 8,
|
1124 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1125 | c48fcb47 | blueswir1 | }, |
1126 | c48fcb47 | blueswir1 | { |
1127 | c48fcb47 | blueswir1 | .name = "Ross RT625",
|
1128 | c48fcb47 | blueswir1 | .iu_version = 0x1e000000,
|
1129 | c48fcb47 | blueswir1 | .fpu_version = 1 << 17, |
1130 | c48fcb47 | blueswir1 | .mmu_version = 0x1e000000,
|
1131 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1132 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1133 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1134 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1135 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1136 | 1a14026e | blueswir1 | .nwindows = 8,
|
1137 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1138 | c48fcb47 | blueswir1 | }, |
1139 | c48fcb47 | blueswir1 | { |
1140 | c48fcb47 | blueswir1 | .name = "Ross RT620",
|
1141 | c48fcb47 | blueswir1 | .iu_version = 0x1f000000,
|
1142 | c48fcb47 | blueswir1 | .fpu_version = 1 << 17, |
1143 | c48fcb47 | blueswir1 | .mmu_version = 0x1f000000,
|
1144 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1145 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1146 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1147 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1148 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1149 | 1a14026e | blueswir1 | .nwindows = 8,
|
1150 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1151 | c48fcb47 | blueswir1 | }, |
1152 | c48fcb47 | blueswir1 | { |
1153 | c48fcb47 | blueswir1 | .name = "BIT B5010",
|
1154 | c48fcb47 | blueswir1 | .iu_version = 0x20000000,
|
1155 | c48fcb47 | blueswir1 | .fpu_version = 0 << 17, /* B5010/B5110/B5120/B5210 */ |
1156 | c48fcb47 | blueswir1 | .mmu_version = 0x20000000,
|
1157 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1158 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1159 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1160 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1161 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1162 | 1a14026e | blueswir1 | .nwindows = 8,
|
1163 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT | |
1164 | e30b4678 | blueswir1 | CPU_FEATURE_FSMULD, |
1165 | c48fcb47 | blueswir1 | }, |
1166 | c48fcb47 | blueswir1 | { |
1167 | c48fcb47 | blueswir1 | .name = "Matsushita MN10501",
|
1168 | c48fcb47 | blueswir1 | .iu_version = 0x50000000,
|
1169 | c48fcb47 | blueswir1 | .fpu_version = 0 << 17, |
1170 | c48fcb47 | blueswir1 | .mmu_version = 0x50000000,
|
1171 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1172 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1173 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1174 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1175 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1176 | 1a14026e | blueswir1 | .nwindows = 8,
|
1177 | e30b4678 | blueswir1 | .features = CPU_FEATURE_FLOAT | CPU_FEATURE_MUL | CPU_FEATURE_FSQRT | |
1178 | e30b4678 | blueswir1 | CPU_FEATURE_FSMULD, |
1179 | c48fcb47 | blueswir1 | }, |
1180 | c48fcb47 | blueswir1 | { |
1181 | c48fcb47 | blueswir1 | .name = "Weitek W8601",
|
1182 | c48fcb47 | blueswir1 | .iu_version = 0x90 << 24, /* Impl 9, ver 0 */ |
1183 | c48fcb47 | blueswir1 | .fpu_version = 3 << 17, /* FPU version 3 (Weitek WTL3170/2) */ |
1184 | c48fcb47 | blueswir1 | .mmu_version = 0x10 << 24, |
1185 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1186 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1187 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1188 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1189 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1190 | 1a14026e | blueswir1 | .nwindows = 8,
|
1191 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1192 | c48fcb47 | blueswir1 | }, |
1193 | c48fcb47 | blueswir1 | { |
1194 | c48fcb47 | blueswir1 | .name = "LEON2",
|
1195 | c48fcb47 | blueswir1 | .iu_version = 0xf2000000,
|
1196 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ |
1197 | c48fcb47 | blueswir1 | .mmu_version = 0xf2000000,
|
1198 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1199 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1200 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1201 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1202 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1203 | 1a14026e | blueswir1 | .nwindows = 8,
|
1204 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1205 | c48fcb47 | blueswir1 | }, |
1206 | c48fcb47 | blueswir1 | { |
1207 | c48fcb47 | blueswir1 | .name = "LEON3",
|
1208 | c48fcb47 | blueswir1 | .iu_version = 0xf3000000,
|
1209 | c48fcb47 | blueswir1 | .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ |
1210 | c48fcb47 | blueswir1 | .mmu_version = 0xf3000000,
|
1211 | c48fcb47 | blueswir1 | .mmu_bm = 0x00004000,
|
1212 | c48fcb47 | blueswir1 | .mmu_ctpr_mask = 0x007ffff0,
|
1213 | c48fcb47 | blueswir1 | .mmu_cxr_mask = 0x0000003f,
|
1214 | c48fcb47 | blueswir1 | .mmu_sfsr_mask = 0xffffffff,
|
1215 | c48fcb47 | blueswir1 | .mmu_trcr_mask = 0xffffffff,
|
1216 | 1a14026e | blueswir1 | .nwindows = 8,
|
1217 | 64a88d5d | blueswir1 | .features = CPU_DEFAULT_FEATURES, |
1218 | c48fcb47 | blueswir1 | }, |
1219 | c48fcb47 | blueswir1 | #endif
|
1220 | c48fcb47 | blueswir1 | }; |
1221 | c48fcb47 | blueswir1 | |
1222 | 64a88d5d | blueswir1 | static const char * const feature_name[] = { |
1223 | 64a88d5d | blueswir1 | "float",
|
1224 | 64a88d5d | blueswir1 | "float128",
|
1225 | 64a88d5d | blueswir1 | "swap",
|
1226 | 64a88d5d | blueswir1 | "mul",
|
1227 | 64a88d5d | blueswir1 | "div",
|
1228 | 64a88d5d | blueswir1 | "flush",
|
1229 | 64a88d5d | blueswir1 | "fsqrt",
|
1230 | 64a88d5d | blueswir1 | "fmul",
|
1231 | 64a88d5d | blueswir1 | "vis1",
|
1232 | 64a88d5d | blueswir1 | "vis2",
|
1233 | e30b4678 | blueswir1 | "fsmuld",
|
1234 | fb79ceb9 | blueswir1 | "hypv",
|
1235 | fb79ceb9 | blueswir1 | "cmt",
|
1236 | fb79ceb9 | blueswir1 | "gl",
|
1237 | 64a88d5d | blueswir1 | }; |
1238 | 64a88d5d | blueswir1 | |
1239 | 64a88d5d | blueswir1 | static void print_features(FILE *f, |
1240 | 64a88d5d | blueswir1 | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
1241 | 64a88d5d | blueswir1 | uint32_t features, const char *prefix) |
1242 | c48fcb47 | blueswir1 | { |
1243 | c48fcb47 | blueswir1 | unsigned int i; |
1244 | c48fcb47 | blueswir1 | |
1245 | 64a88d5d | blueswir1 | for (i = 0; i < ARRAY_SIZE(feature_name); i++) |
1246 | 64a88d5d | blueswir1 | if (feature_name[i] && (features & (1 << i))) { |
1247 | 64a88d5d | blueswir1 | if (prefix)
|
1248 | 64a88d5d | blueswir1 | (*cpu_fprintf)(f, "%s", prefix);
|
1249 | 64a88d5d | blueswir1 | (*cpu_fprintf)(f, "%s ", feature_name[i]);
|
1250 | 64a88d5d | blueswir1 | } |
1251 | 64a88d5d | blueswir1 | } |
1252 | 64a88d5d | blueswir1 | |
1253 | 64a88d5d | blueswir1 | static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features) |
1254 | 64a88d5d | blueswir1 | { |
1255 | 64a88d5d | blueswir1 | unsigned int i; |
1256 | 64a88d5d | blueswir1 | |
1257 | 64a88d5d | blueswir1 | for (i = 0; i < ARRAY_SIZE(feature_name); i++) |
1258 | 64a88d5d | blueswir1 | if (feature_name[i] && !strcmp(flagname, feature_name[i])) {
|
1259 | 64a88d5d | blueswir1 | *features |= 1 << i;
|
1260 | 64a88d5d | blueswir1 | return;
|
1261 | 64a88d5d | blueswir1 | } |
1262 | 64a88d5d | blueswir1 | fprintf(stderr, "CPU feature %s not found\n", flagname);
|
1263 | 64a88d5d | blueswir1 | } |
1264 | 64a88d5d | blueswir1 | |
1265 | 22548760 | blueswir1 | static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model) |
1266 | 64a88d5d | blueswir1 | { |
1267 | 64a88d5d | blueswir1 | unsigned int i; |
1268 | 64a88d5d | blueswir1 | const sparc_def_t *def = NULL; |
1269 | 64a88d5d | blueswir1 | char *s = strdup(cpu_model);
|
1270 | 64a88d5d | blueswir1 | char *featurestr, *name = strtok(s, ","); |
1271 | 64a88d5d | blueswir1 | uint32_t plus_features = 0;
|
1272 | 64a88d5d | blueswir1 | uint32_t minus_features = 0;
|
1273 | 64a88d5d | blueswir1 | long long iu_version; |
1274 | 1a14026e | blueswir1 | uint32_t fpu_version, mmu_version, nwindows; |
1275 | 64a88d5d | blueswir1 | |
1276 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { |
1277 | c48fcb47 | blueswir1 | if (strcasecmp(name, sparc_defs[i].name) == 0) { |
1278 | 64a88d5d | blueswir1 | def = &sparc_defs[i]; |
1279 | c48fcb47 | blueswir1 | } |
1280 | c48fcb47 | blueswir1 | } |
1281 | 64a88d5d | blueswir1 | if (!def)
|
1282 | 64a88d5d | blueswir1 | goto error;
|
1283 | 64a88d5d | blueswir1 | memcpy(cpu_def, def, sizeof(*def));
|
1284 | 64a88d5d | blueswir1 | |
1285 | 64a88d5d | blueswir1 | featurestr = strtok(NULL, ","); |
1286 | 64a88d5d | blueswir1 | while (featurestr) {
|
1287 | 64a88d5d | blueswir1 | char *val;
|
1288 | 64a88d5d | blueswir1 | |
1289 | 64a88d5d | blueswir1 | if (featurestr[0] == '+') { |
1290 | 64a88d5d | blueswir1 | add_flagname_to_bitmaps(featurestr + 1, &plus_features);
|
1291 | 64a88d5d | blueswir1 | } else if (featurestr[0] == '-') { |
1292 | 64a88d5d | blueswir1 | add_flagname_to_bitmaps(featurestr + 1, &minus_features);
|
1293 | 64a88d5d | blueswir1 | } else if ((val = strchr(featurestr, '='))) { |
1294 | 64a88d5d | blueswir1 | *val = 0; val++;
|
1295 | 64a88d5d | blueswir1 | if (!strcmp(featurestr, "iu_version")) { |
1296 | 64a88d5d | blueswir1 | char *err;
|
1297 | 64a88d5d | blueswir1 | |
1298 | 64a88d5d | blueswir1 | iu_version = strtoll(val, &err, 0);
|
1299 | 64a88d5d | blueswir1 | if (!*val || *err) {
|
1300 | 64a88d5d | blueswir1 | fprintf(stderr, "bad numerical value %s\n", val);
|
1301 | 64a88d5d | blueswir1 | goto error;
|
1302 | 64a88d5d | blueswir1 | } |
1303 | 64a88d5d | blueswir1 | cpu_def->iu_version = iu_version; |
1304 | 64a88d5d | blueswir1 | #ifdef DEBUG_FEATURES
|
1305 | 64a88d5d | blueswir1 | fprintf(stderr, "iu_version %llx\n", iu_version);
|
1306 | 64a88d5d | blueswir1 | #endif
|
1307 | 64a88d5d | blueswir1 | } else if (!strcmp(featurestr, "fpu_version")) { |
1308 | 64a88d5d | blueswir1 | char *err;
|
1309 | 64a88d5d | blueswir1 | |
1310 | 64a88d5d | blueswir1 | fpu_version = strtol(val, &err, 0);
|
1311 | 64a88d5d | blueswir1 | if (!*val || *err) {
|
1312 | 64a88d5d | blueswir1 | fprintf(stderr, "bad numerical value %s\n", val);
|
1313 | 64a88d5d | blueswir1 | goto error;
|
1314 | 64a88d5d | blueswir1 | } |
1315 | 64a88d5d | blueswir1 | cpu_def->fpu_version = fpu_version; |
1316 | 64a88d5d | blueswir1 | #ifdef DEBUG_FEATURES
|
1317 | 0bf9e31a | Blue Swirl | fprintf(stderr, "fpu_version %x\n", fpu_version);
|
1318 | 64a88d5d | blueswir1 | #endif
|
1319 | 64a88d5d | blueswir1 | } else if (!strcmp(featurestr, "mmu_version")) { |
1320 | 64a88d5d | blueswir1 | char *err;
|
1321 | 64a88d5d | blueswir1 | |
1322 | 64a88d5d | blueswir1 | mmu_version = strtol(val, &err, 0);
|
1323 | 64a88d5d | blueswir1 | if (!*val || *err) {
|
1324 | 64a88d5d | blueswir1 | fprintf(stderr, "bad numerical value %s\n", val);
|
1325 | 64a88d5d | blueswir1 | goto error;
|
1326 | 64a88d5d | blueswir1 | } |
1327 | 64a88d5d | blueswir1 | cpu_def->mmu_version = mmu_version; |
1328 | 64a88d5d | blueswir1 | #ifdef DEBUG_FEATURES
|
1329 | 0bf9e31a | Blue Swirl | fprintf(stderr, "mmu_version %x\n", mmu_version);
|
1330 | 64a88d5d | blueswir1 | #endif
|
1331 | 1a14026e | blueswir1 | } else if (!strcmp(featurestr, "nwindows")) { |
1332 | 1a14026e | blueswir1 | char *err;
|
1333 | 1a14026e | blueswir1 | |
1334 | 1a14026e | blueswir1 | nwindows = strtol(val, &err, 0);
|
1335 | 1a14026e | blueswir1 | if (!*val || *err || nwindows > MAX_NWINDOWS ||
|
1336 | 1a14026e | blueswir1 | nwindows < MIN_NWINDOWS) { |
1337 | 1a14026e | blueswir1 | fprintf(stderr, "bad numerical value %s\n", val);
|
1338 | 1a14026e | blueswir1 | goto error;
|
1339 | 1a14026e | blueswir1 | } |
1340 | 1a14026e | blueswir1 | cpu_def->nwindows = nwindows; |
1341 | 1a14026e | blueswir1 | #ifdef DEBUG_FEATURES
|
1342 | 1a14026e | blueswir1 | fprintf(stderr, "nwindows %d\n", nwindows);
|
1343 | 1a14026e | blueswir1 | #endif
|
1344 | 64a88d5d | blueswir1 | } else {
|
1345 | 64a88d5d | blueswir1 | fprintf(stderr, "unrecognized feature %s\n", featurestr);
|
1346 | 64a88d5d | blueswir1 | goto error;
|
1347 | 64a88d5d | blueswir1 | } |
1348 | 64a88d5d | blueswir1 | } else {
|
1349 | 77f193da | blueswir1 | fprintf(stderr, "feature string `%s' not in format "
|
1350 | 77f193da | blueswir1 | "(+feature|-feature|feature=xyz)\n", featurestr);
|
1351 | 64a88d5d | blueswir1 | goto error;
|
1352 | 64a88d5d | blueswir1 | } |
1353 | 64a88d5d | blueswir1 | featurestr = strtok(NULL, ","); |
1354 | 64a88d5d | blueswir1 | } |
1355 | 64a88d5d | blueswir1 | cpu_def->features |= plus_features; |
1356 | 64a88d5d | blueswir1 | cpu_def->features &= ~minus_features; |
1357 | 64a88d5d | blueswir1 | #ifdef DEBUG_FEATURES
|
1358 | 64a88d5d | blueswir1 | print_features(stderr, fprintf, cpu_def->features, NULL);
|
1359 | 64a88d5d | blueswir1 | #endif
|
1360 | 64a88d5d | blueswir1 | free(s); |
1361 | 64a88d5d | blueswir1 | return 0; |
1362 | 64a88d5d | blueswir1 | |
1363 | 64a88d5d | blueswir1 | error:
|
1364 | 64a88d5d | blueswir1 | free(s); |
1365 | 64a88d5d | blueswir1 | return -1; |
1366 | c48fcb47 | blueswir1 | } |
1367 | c48fcb47 | blueswir1 | |
1368 | 77f193da | blueswir1 | void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
1369 | c48fcb47 | blueswir1 | { |
1370 | c48fcb47 | blueswir1 | unsigned int i; |
1371 | c48fcb47 | blueswir1 | |
1372 | b1503cda | malc | for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { |
1373 | 1a14026e | blueswir1 | (*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x NWINS %d ", |
1374 | c48fcb47 | blueswir1 | sparc_defs[i].name, |
1375 | c48fcb47 | blueswir1 | sparc_defs[i].iu_version, |
1376 | c48fcb47 | blueswir1 | sparc_defs[i].fpu_version, |
1377 | 1a14026e | blueswir1 | sparc_defs[i].mmu_version, |
1378 | 1a14026e | blueswir1 | sparc_defs[i].nwindows); |
1379 | 77f193da | blueswir1 | print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES & |
1380 | 77f193da | blueswir1 | ~sparc_defs[i].features, "-");
|
1381 | 77f193da | blueswir1 | print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES & |
1382 | 77f193da | blueswir1 | sparc_defs[i].features, "+");
|
1383 | 64a88d5d | blueswir1 | (*cpu_fprintf)(f, "\n");
|
1384 | c48fcb47 | blueswir1 | } |
1385 | f76981b1 | blueswir1 | (*cpu_fprintf)(f, "Default CPU feature flags (use '-' to remove): ");
|
1386 | f76981b1 | blueswir1 | print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL);
|
1387 | 64a88d5d | blueswir1 | (*cpu_fprintf)(f, "\n");
|
1388 | f76981b1 | blueswir1 | (*cpu_fprintf)(f, "Available CPU feature flags (use '+' to add): ");
|
1389 | f76981b1 | blueswir1 | print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL);
|
1390 | f76981b1 | blueswir1 | (*cpu_fprintf)(f, "\n");
|
1391 | f76981b1 | blueswir1 | (*cpu_fprintf)(f, "Numerical features (use '=' to set): iu_version "
|
1392 | f76981b1 | blueswir1 | "fpu_version mmu_version nwindows\n");
|
1393 | c48fcb47 | blueswir1 | } |
1394 | c48fcb47 | blueswir1 | |
1395 | c48fcb47 | blueswir1 | void cpu_dump_state(CPUState *env, FILE *f,
|
1396 | c48fcb47 | blueswir1 | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
1397 | c48fcb47 | blueswir1 | int flags)
|
1398 | c48fcb47 | blueswir1 | { |
1399 | c48fcb47 | blueswir1 | int i, x;
|
1400 | c48fcb47 | blueswir1 | |
1401 | 77f193da | blueswir1 | cpu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, |
1402 | 77f193da | blueswir1 | env->npc); |
1403 | c48fcb47 | blueswir1 | cpu_fprintf(f, "General Registers:\n");
|
1404 | c48fcb47 | blueswir1 | for (i = 0; i < 4; i++) |
1405 | c48fcb47 | blueswir1 | cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]); |
1406 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\n");
|
1407 | c48fcb47 | blueswir1 | for (; i < 8; i++) |
1408 | c48fcb47 | blueswir1 | cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]); |
1409 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\nCurrent Register Window:\n");
|
1410 | c48fcb47 | blueswir1 | for (x = 0; x < 3; x++) { |
1411 | c48fcb47 | blueswir1 | for (i = 0; i < 4; i++) |
1412 | c48fcb47 | blueswir1 | cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t", |
1413 | c48fcb47 | blueswir1 | (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i, |
1414 | c48fcb47 | blueswir1 | env->regwptr[i + x * 8]);
|
1415 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\n");
|
1416 | c48fcb47 | blueswir1 | for (; i < 8; i++) |
1417 | c48fcb47 | blueswir1 | cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t", |
1418 | c48fcb47 | blueswir1 | (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i, |
1419 | c48fcb47 | blueswir1 | env->regwptr[i + x * 8]);
|
1420 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\n");
|
1421 | c48fcb47 | blueswir1 | } |
1422 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\nFloating Point Registers:\n");
|
1423 | c48fcb47 | blueswir1 | for (i = 0; i < 32; i++) { |
1424 | c48fcb47 | blueswir1 | if ((i & 3) == 0) |
1425 | c48fcb47 | blueswir1 | cpu_fprintf(f, "%%f%02d:", i);
|
1426 | a37ee56c | blueswir1 | cpu_fprintf(f, " %016f", *(float *)&env->fpr[i]); |
1427 | c48fcb47 | blueswir1 | if ((i & 3) == 3) |
1428 | c48fcb47 | blueswir1 | cpu_fprintf(f, "\n");
|
1429 | c48fcb47 | blueswir1 | } |
1430 | c48fcb47 | blueswir1 | #ifdef TARGET_SPARC64
|
1431 | c48fcb47 | blueswir1 | cpu_fprintf(f, "pstate: 0x%08x ccr: 0x%02x asi: 0x%02x tl: %d fprs: %d\n",
|
1432 | c48fcb47 | blueswir1 | env->pstate, GET_CCR(env), env->asi, env->tl, env->fprs); |
1433 | 77f193da | blueswir1 | cpu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate %d "
|
1434 | 77f193da | blueswir1 | "cleanwin %d cwp %d\n",
|
1435 | c48fcb47 | blueswir1 | env->cansave, env->canrestore, env->otherwin, env->wstate, |
1436 | 1a14026e | blueswir1 | env->cleanwin, env->nwindows - 1 - env->cwp);
|
1437 | c48fcb47 | blueswir1 | #else
|
1438 | d78f3995 | blueswir1 | |
1439 | d78f3995 | blueswir1 | #define GET_FLAG(a,b) ((env->psr & a)?b:'-') |
1440 | d78f3995 | blueswir1 | |
1441 | 77f193da | blueswir1 | cpu_fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n",
|
1442 | 77f193da | blueswir1 | GET_PSR(env), GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'), |
1443 | 77f193da | blueswir1 | GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'), |
1444 | 77f193da | blueswir1 | env->psrs?'S':'-', env->psrps?'P':'-', |
1445 | 77f193da | blueswir1 | env->psret?'E':'-', env->wim); |
1446 | c48fcb47 | blueswir1 | #endif
|
1447 | 3a3b925d | blueswir1 | cpu_fprintf(f, "fsr: 0x%08x\n", env->fsr);
|
1448 | c48fcb47 | blueswir1 | } |