4 * Copyright (c) 2003-2005 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 #include "qemu-common.h"
31 //#define DEBUG_FEATURES
33 static int cpu_sparc_find_by_name(sparc_def_t
*cpu_def
, const char *cpu_model
);
35 /* Sparc MMU emulation */
39 static spinlock_t global_cpu_lock
= SPIN_LOCK_UNLOCKED
;
43 spin_lock(&global_cpu_lock
);
48 spin_unlock(&global_cpu_lock
);
51 #if defined(CONFIG_USER_ONLY)
53 int cpu_sparc_handle_mmu_fault(CPUState
*env1
, target_ulong address
, int rw
,
54 int mmu_idx
, int is_softmmu
)
57 env1
->exception_index
= TT_TFAULT
;
59 env1
->exception_index
= TT_DFAULT
;
65 #ifndef TARGET_SPARC64
67 * Sparc V8 Reference MMU (SRMMU)
69 static const int access_table
[8][8] = {
70 { 0, 0, 0, 0, 8, 0, 12, 12 },
71 { 0, 0, 0, 0, 8, 0, 0, 0 },
72 { 8, 8, 0, 0, 0, 8, 12, 12 },
73 { 8, 8, 0, 0, 0, 8, 0, 0 },
74 { 8, 0, 8, 0, 8, 8, 12, 12 },
75 { 8, 0, 8, 0, 8, 0, 8, 0 },
76 { 8, 8, 8, 0, 8, 8, 12, 12 },
77 { 8, 8, 8, 0, 8, 8, 8, 0 }
80 static const int perm_table
[2][8] = {
83 PAGE_READ
| PAGE_WRITE
,
84 PAGE_READ
| PAGE_EXEC
,
85 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
87 PAGE_READ
| PAGE_WRITE
,
88 PAGE_READ
| PAGE_EXEC
,
89 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
93 PAGE_READ
| PAGE_WRITE
,
94 PAGE_READ
| PAGE_EXEC
,
95 PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
,
103 static int get_physical_address(CPUState
*env
, target_phys_addr_t
*physical
,
104 int *prot
, int *access_index
,
105 target_ulong address
, int rw
, int mmu_idx
)
107 int access_perms
= 0;
108 target_phys_addr_t pde_ptr
;
110 target_ulong virt_addr
;
111 int error_code
= 0, is_dirty
, is_user
;
112 unsigned long page_offset
;
114 is_user
= mmu_idx
== MMU_USER_IDX
;
115 virt_addr
= address
& TARGET_PAGE_MASK
;
117 if ((env
->mmuregs
[0] & MMU_E
) == 0) { /* MMU disabled */
118 // Boot mode: instruction fetches are taken from PROM
119 if (rw
== 2 && (env
->mmuregs
[0] & env
->def
->mmu_bm
)) {
120 *physical
= env
->prom_addr
| (address
& 0x7ffffULL
);
121 *prot
= PAGE_READ
| PAGE_EXEC
;
125 *prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
129 *access_index
= ((rw
& 1) << 2) | (rw
& 2) | (is_user
? 0 : 1);
130 *physical
= 0xffffffffffff0000ULL
;
132 /* SPARC reference MMU table walk: Context table->L1->L2->PTE */
133 /* Context base + context number */
134 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
135 pde
= ldl_phys(pde_ptr
);
138 switch (pde
& PTE_ENTRYTYPE_MASK
) {
140 case 0: /* Invalid */
142 case 2: /* L0 PTE, maybe should not happen? */
143 case 3: /* Reserved */
146 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
147 pde
= ldl_phys(pde_ptr
);
149 switch (pde
& PTE_ENTRYTYPE_MASK
) {
151 case 0: /* Invalid */
152 return (1 << 8) | (1 << 2);
153 case 3: /* Reserved */
154 return (1 << 8) | (4 << 2);
156 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
157 pde
= ldl_phys(pde_ptr
);
159 switch (pde
& PTE_ENTRYTYPE_MASK
) {
161 case 0: /* Invalid */
162 return (2 << 8) | (1 << 2);
163 case 3: /* Reserved */
164 return (2 << 8) | (4 << 2);
166 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
167 pde
= ldl_phys(pde_ptr
);
169 switch (pde
& PTE_ENTRYTYPE_MASK
) {
171 case 0: /* Invalid */
172 return (3 << 8) | (1 << 2);
173 case 1: /* PDE, should not happen */
174 case 3: /* Reserved */
175 return (3 << 8) | (4 << 2);
177 virt_addr
= address
& TARGET_PAGE_MASK
;
178 page_offset
= (address
& TARGET_PAGE_MASK
) &
179 (TARGET_PAGE_SIZE
- 1);
183 virt_addr
= address
& ~0x3ffff;
184 page_offset
= address
& 0x3ffff;
188 virt_addr
= address
& ~0xffffff;
189 page_offset
= address
& 0xffffff;
193 /* update page modified and dirty bits */
194 is_dirty
= (rw
& 1) && !(pde
& PG_MODIFIED_MASK
);
195 if (!(pde
& PG_ACCESSED_MASK
) || is_dirty
) {
196 pde
|= PG_ACCESSED_MASK
;
198 pde
|= PG_MODIFIED_MASK
;
199 stl_phys_notdirty(pde_ptr
, pde
);
202 access_perms
= (pde
& PTE_ACCESS_MASK
) >> PTE_ACCESS_SHIFT
;
203 error_code
= access_table
[*access_index
][access_perms
];
204 if (error_code
&& !((env
->mmuregs
[0] & MMU_NF
) && is_user
))
207 /* the page can be put in the TLB */
208 *prot
= perm_table
[is_user
][access_perms
];
209 if (!(pde
& PG_MODIFIED_MASK
)) {
210 /* only set write access if already dirty... otherwise wait
212 *prot
&= ~PAGE_WRITE
;
215 /* Even if large ptes, we map only one 4KB page in the cache to
216 avoid filling it too fast */
217 *physical
= ((target_phys_addr_t
)(pde
& PTE_ADDR_MASK
) << 4) + page_offset
;
221 /* Perform address translation */
222 int cpu_sparc_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
223 int mmu_idx
, int is_softmmu
)
225 target_phys_addr_t paddr
;
227 int error_code
= 0, prot
, ret
= 0, access_index
;
229 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
230 address
, rw
, mmu_idx
);
231 if (error_code
== 0) {
232 vaddr
= address
& TARGET_PAGE_MASK
;
233 paddr
&= TARGET_PAGE_MASK
;
235 printf("Translate at " TARGET_FMT_lx
" -> " TARGET_FMT_plx
", vaddr "
236 TARGET_FMT_lx
"\n", address
, paddr
, vaddr
);
238 ret
= tlb_set_page_exec(env
, vaddr
, paddr
, prot
, mmu_idx
, is_softmmu
);
242 if (env
->mmuregs
[3]) /* Fault status register */
243 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
244 env
->mmuregs
[3] |= (access_index
<< 5) | error_code
| 2;
245 env
->mmuregs
[4] = address
; /* Fault address register */
247 if ((env
->mmuregs
[0] & MMU_NF
) || env
->psret
== 0) {
248 // No fault mode: if a mapping is available, just override
249 // permissions. If no mapping is available, redirect accesses to
250 // neverland. Fake/overridden mappings will be flushed when
251 // switching to normal mode.
252 vaddr
= address
& TARGET_PAGE_MASK
;
253 prot
= PAGE_READ
| PAGE_WRITE
| PAGE_EXEC
;
254 ret
= tlb_set_page_exec(env
, vaddr
, paddr
, prot
, mmu_idx
, is_softmmu
);
258 env
->exception_index
= TT_TFAULT
;
260 env
->exception_index
= TT_DFAULT
;
265 target_ulong
mmu_probe(CPUState
*env
, target_ulong address
, int mmulev
)
267 target_phys_addr_t pde_ptr
;
270 /* Context base + context number */
271 pde_ptr
= (target_phys_addr_t
)(env
->mmuregs
[1] << 4) +
272 (env
->mmuregs
[2] << 2);
273 pde
= ldl_phys(pde_ptr
);
275 switch (pde
& PTE_ENTRYTYPE_MASK
) {
277 case 0: /* Invalid */
278 case 2: /* PTE, maybe should not happen? */
279 case 3: /* Reserved */
284 pde_ptr
= ((address
>> 22) & ~3) + ((pde
& ~3) << 4);
285 pde
= ldl_phys(pde_ptr
);
287 switch (pde
& PTE_ENTRYTYPE_MASK
) {
289 case 0: /* Invalid */
290 case 3: /* Reserved */
297 pde_ptr
= ((address
& 0xfc0000) >> 16) + ((pde
& ~3) << 4);
298 pde
= ldl_phys(pde_ptr
);
300 switch (pde
& PTE_ENTRYTYPE_MASK
) {
302 case 0: /* Invalid */
303 case 3: /* Reserved */
310 pde_ptr
= ((address
& 0x3f000) >> 10) + ((pde
& ~3) << 4);
311 pde
= ldl_phys(pde_ptr
);
313 switch (pde
& PTE_ENTRYTYPE_MASK
) {
315 case 0: /* Invalid */
316 case 1: /* PDE, should not happen */
317 case 3: /* Reserved */
329 void dump_mmu(CPUState
*env
)
331 target_ulong va
, va1
, va2
;
332 unsigned int n
, m
, o
;
333 target_phys_addr_t pde_ptr
, pa
;
336 printf("MMU dump:\n");
337 pde_ptr
= (env
->mmuregs
[1] << 4) + (env
->mmuregs
[2] << 2);
338 pde
= ldl_phys(pde_ptr
);
339 printf("Root ptr: " TARGET_FMT_plx
", ctx: %d\n",
340 (target_phys_addr_t
)env
->mmuregs
[1] << 4, env
->mmuregs
[2]);
341 for (n
= 0, va
= 0; n
< 256; n
++, va
+= 16 * 1024 * 1024) {
342 pde
= mmu_probe(env
, va
, 2);
344 pa
= cpu_get_phys_page_debug(env
, va
);
345 printf("VA: " TARGET_FMT_lx
", PA: " TARGET_FMT_plx
346 " PDE: " TARGET_FMT_lx
"\n", va
, pa
, pde
);
347 for (m
= 0, va1
= va
; m
< 64; m
++, va1
+= 256 * 1024) {
348 pde
= mmu_probe(env
, va1
, 1);
350 pa
= cpu_get_phys_page_debug(env
, va1
);
351 printf(" VA: " TARGET_FMT_lx
", PA: " TARGET_FMT_plx
352 " PDE: " TARGET_FMT_lx
"\n", va1
, pa
, pde
);
353 for (o
= 0, va2
= va1
; o
< 64; o
++, va2
+= 4 * 1024) {
354 pde
= mmu_probe(env
, va2
, 0);
356 pa
= cpu_get_phys_page_debug(env
, va2
);
357 printf(" VA: " TARGET_FMT_lx
", PA: "
358 TARGET_FMT_plx
" PTE: " TARGET_FMT_lx
"\n",
366 printf("MMU dump ends\n");
368 #endif /* DEBUG_MMU */
370 #else /* !TARGET_SPARC64 */
372 // 41 bit physical address space
373 static inline target_phys_addr_t
ultrasparc_truncate_physical(uint64_t x
)
375 return x
& 0x1ffffffffffULL
;
379 * UltraSparc IIi I/DMMUs
382 static inline int compare_masked(uint64_t x
, uint64_t y
, uint64_t mask
)
384 return (x
& mask
) == (y
& mask
);
387 // Returns true if TTE tag is valid and matches virtual address value in context
388 // requires virtual address mask value calculated from TTE entry size
389 static inline int ultrasparc_tag_match(SparcTLBEntry
*tlb
,
390 uint64_t address
, uint64_t context
,
391 target_phys_addr_t
*physical
)
395 switch ((tlb
->tte
>> 61) & 3) {
398 mask
= 0xffffffffffffe000ULL
;
401 mask
= 0xffffffffffff0000ULL
;
404 mask
= 0xfffffffffff80000ULL
;
407 mask
= 0xffffffffffc00000ULL
;
411 // valid, context match, virtual address match?
412 if (TTE_IS_VALID(tlb
->tte
) &&
413 compare_masked(context
, tlb
->tag
, 0x1fff) &&
414 compare_masked(address
, tlb
->tag
, mask
))
416 // decode physical address
417 *physical
= ((tlb
->tte
& mask
) | (address
& ~mask
)) & 0x1ffffffe000ULL
;
424 static int get_physical_address_data(CPUState
*env
,
425 target_phys_addr_t
*physical
, int *prot
,
426 target_ulong address
, int rw
, int is_user
)
431 if ((env
->lsu
& DMMU_E
) == 0) { /* DMMU disabled */
432 *physical
= ultrasparc_truncate_physical(address
);
433 *prot
= PAGE_READ
| PAGE_WRITE
;
437 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
439 for (i
= 0; i
< 64; i
++) {
440 // ctx match, vaddr match, valid?
441 if (ultrasparc_tag_match(&env
->dtlb
[i
],
442 address
, context
, physical
)
445 if (((env
->dtlb
[i
].tte
& 0x4) && is_user
) ||
446 (!(env
->dtlb
[i
].tte
& 0x2) && (rw
== 1))) {
447 uint8_t fault_type
= 0;
449 if ((env
->dtlb
[i
].tte
& 0x4) && is_user
) {
450 fault_type
|= 1; /* privilege violation */
453 if (env
->dmmu
.sfsr
& 1) /* Fault status register */
454 env
->dmmu
.sfsr
= 2; /* overflow (not read before
457 env
->dmmu
.sfsr
|= (is_user
<< 3) | ((rw
== 1) << 2) | 1;
459 env
->dmmu
.sfsr
|= (fault_type
<< 7);
461 env
->dmmu
.sfar
= address
; /* Fault address register */
462 env
->exception_index
= TT_DFAULT
;
464 printf("DFAULT at 0x%" PRIx64
"\n", address
);
469 if (env
->dtlb
[i
].tte
& 0x2)
471 TTE_SET_USED(env
->dtlb
[i
].tte
);
476 printf("DMISS at 0x%" PRIx64
"\n", address
);
478 env
->dmmu
.tag_access
= (address
& ~0x1fffULL
) | context
;
479 env
->exception_index
= TT_DMISS
;
483 static int get_physical_address_code(CPUState
*env
,
484 target_phys_addr_t
*physical
, int *prot
,
485 target_ulong address
, int is_user
)
490 if ((env
->lsu
& IMMU_E
) == 0 || (env
->pstate
& PS_RED
) != 0) {
492 *physical
= ultrasparc_truncate_physical(address
);
497 context
= env
->dmmu
.mmu_primary_context
& 0x1fff;
499 for (i
= 0; i
< 64; i
++) {
500 // ctx match, vaddr match, valid?
501 if (ultrasparc_tag_match(&env
->itlb
[i
],
502 address
, context
, physical
)
505 if ((env
->itlb
[i
].tte
& 0x4) && is_user
) {
506 if (env
->immu
.sfsr
) /* Fault status register */
507 env
->immu
.sfsr
= 2; /* overflow (not read before
509 env
->immu
.sfsr
|= (is_user
<< 3) | 1;
510 env
->exception_index
= TT_TFAULT
;
512 printf("TFAULT at 0x%" PRIx64
"\n", address
);
517 TTE_SET_USED(env
->itlb
[i
].tte
);
522 printf("TMISS at 0x%" PRIx64
"\n", address
);
524 /* Context is stored in DMMU (dmmuregs[1]) also for IMMU */
525 env
->immu
.tag_access
= (address
& ~0x1fffULL
) | context
;
526 env
->exception_index
= TT_TMISS
;
530 static int get_physical_address(CPUState
*env
, target_phys_addr_t
*physical
,
531 int *prot
, int *access_index
,
532 target_ulong address
, int rw
, int mmu_idx
)
534 int is_user
= mmu_idx
== MMU_USER_IDX
;
537 return get_physical_address_code(env
, physical
, prot
, address
,
540 return get_physical_address_data(env
, physical
, prot
, address
, rw
,
544 /* Perform address translation */
545 int cpu_sparc_handle_mmu_fault (CPUState
*env
, target_ulong address
, int rw
,
546 int mmu_idx
, int is_softmmu
)
548 target_ulong virt_addr
, vaddr
;
549 target_phys_addr_t paddr
;
550 int error_code
= 0, prot
, ret
= 0, access_index
;
552 error_code
= get_physical_address(env
, &paddr
, &prot
, &access_index
,
553 address
, rw
, mmu_idx
);
554 if (error_code
== 0) {
555 virt_addr
= address
& TARGET_PAGE_MASK
;
556 vaddr
= virt_addr
+ ((address
& TARGET_PAGE_MASK
) &
557 (TARGET_PAGE_SIZE
- 1));
559 printf("Translate at 0x%" PRIx64
" -> 0x%" PRIx64
", vaddr 0x%" PRIx64
560 "\n", address
, paddr
, vaddr
);
562 ret
= tlb_set_page_exec(env
, vaddr
, paddr
, prot
, mmu_idx
, is_softmmu
);
570 void dump_mmu(CPUState
*env
)
575 printf("MMU contexts: Primary: %" PRId64
", Secondary: %" PRId64
"\n",
576 env
->dmmu
.mmu_primary_context
, env
->dmmu
.mmu_secondary_context
);
577 if ((env
->lsu
& DMMU_E
) == 0) {
578 printf("DMMU disabled\n");
580 printf("DMMU dump:\n");
581 for (i
= 0; i
< 64; i
++) {
582 switch ((env
->dtlb_tte
[i
] >> 61) & 3) {
597 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) != 0) {
598 printf("[%02u] VA: " PRIx64
", PA: " PRIx64
599 ", %s, %s, %s, %s, ctx %" PRId64
"\n",
601 env
->dtlb_tag
[i
] & (uint64_t)~0x1fffULL
,
602 env
->dtlb_tte
[i
] & (uint64_t)0x1ffffffe000ULL
,
604 env
->dtlb_tte
[i
] & 0x4? "priv": "user",
605 env
->dtlb_tte
[i
] & 0x2? "RW": "RO",
606 env
->dtlb_tte
[i
] & 0x40? "locked": "unlocked",
607 env
->dtlb_tag
[i
] & (uint64_t)0x1fffULL
);
611 if ((env
->lsu
& IMMU_E
) == 0) {
612 printf("IMMU disabled\n");
614 printf("IMMU dump:\n");
615 for (i
= 0; i
< 64; i
++) {
616 switch ((env
->itlb_tte
[i
] >> 61) & 3) {
631 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) != 0) {
632 printf("[%02u] VA: " PRIx64
", PA: " PRIx64
633 ", %s, %s, %s, ctx %" PRId64
"\n",
635 env
->itlb
[i
].tag
& (uint64_t)~0x1fffULL
,
636 env
->itlb_tte
[i
] & (uint64_t)0x1ffffffe000ULL
,
638 env
->itlb_tte
[i
] & 0x4? "priv": "user",
639 env
->itlb_tte
[i
] & 0x40? "locked": "unlocked",
640 env
->itlb
[i
].tag
& (uint64_t)0x1fffULL
);
645 #endif /* DEBUG_MMU */
647 #endif /* TARGET_SPARC64 */
648 #endif /* !CONFIG_USER_ONLY */
651 #if defined(CONFIG_USER_ONLY)
652 target_phys_addr_t
cpu_get_phys_page_debug(CPUState
*env
, target_ulong addr
)
658 target_phys_addr_t
cpu_get_phys_page_debug(CPUState
*env
, target_ulong addr
)
660 target_phys_addr_t phys_addr
;
661 int prot
, access_index
;
663 if (get_physical_address(env
, &phys_addr
, &prot
, &access_index
, addr
, 2,
664 MMU_KERNEL_IDX
) != 0)
665 if (get_physical_address(env
, &phys_addr
, &prot
, &access_index
, addr
,
666 0, MMU_KERNEL_IDX
) != 0)
668 if (cpu_get_physical_page_desc(phys_addr
) == IO_MEM_UNASSIGNED
)
674 void cpu_reset(CPUSPARCState
*env
)
676 if (qemu_loglevel_mask(CPU_LOG_RESET
)) {
677 qemu_log("CPU Reset (CPU %d)\n", env
->cpu_index
);
678 log_cpu_state(env
, 0);
683 #ifndef TARGET_SPARC64
686 env
->regwptr
= env
->regbase
+ (env
->cwp
* 16);
688 #if defined(CONFIG_USER_ONLY)
689 #ifdef TARGET_SPARC64
690 env
->cleanwin
= env
->nwindows
- 2;
691 env
->cansave
= env
->nwindows
- 2;
692 env
->pstate
= PS_RMO
| PS_PEF
| PS_IE
;
693 env
->asi
= 0x82; // Primary no-fault
696 #if !defined(TARGET_SPARC64)
701 #ifdef TARGET_SPARC64
702 env
->pstate
= PS_PRIV
|PS_RED
|PS_PEF
|PS_AG
;
703 env
->hpstate
= HS_PRIV
;
704 env
->tl
= env
->maxtl
;
705 cpu_tsptr(env
)->tt
= TT_POWER_ON_RESET
;
708 env
->mmuregs
[0] &= ~(MMU_E
| MMU_NF
);
709 env
->mmuregs
[0] |= env
->def
->mmu_bm
;
712 env
->npc
= env
->pc
+ 4;
716 static int cpu_sparc_register(CPUSPARCState
*env
, const char *cpu_model
)
718 sparc_def_t def1
, *def
= &def1
;
720 if (cpu_sparc_find_by_name(def
, cpu_model
) < 0)
723 env
->def
= qemu_mallocz(sizeof(*def
));
724 memcpy(env
->def
, def
, sizeof(*def
));
725 #if defined(CONFIG_USER_ONLY)
726 if ((env
->def
->features
& CPU_FEATURE_FLOAT
))
727 env
->def
->features
|= CPU_FEATURE_FLOAT128
;
729 env
->cpu_model_str
= cpu_model
;
730 env
->version
= def
->iu_version
;
731 env
->fsr
= def
->fpu_version
;
732 env
->nwindows
= def
->nwindows
;
733 #if !defined(TARGET_SPARC64)
734 env
->mmuregs
[0] |= def
->mmu_version
;
735 cpu_sparc_set_id(env
, 0);
736 env
->mxccregs
[7] |= def
->mxcc_version
;
738 env
->mmu_version
= def
->mmu_version
;
739 env
->maxtl
= def
->maxtl
;
740 env
->version
|= def
->maxtl
<< 8;
741 env
->version
|= def
->nwindows
- 1;
746 static void cpu_sparc_close(CPUSPARCState
*env
)
752 CPUSPARCState
*cpu_sparc_init(const char *cpu_model
)
756 env
= qemu_mallocz(sizeof(CPUSPARCState
));
759 gen_intermediate_code_init(env
);
761 if (cpu_sparc_register(env
, cpu_model
) < 0) {
762 cpu_sparc_close(env
);
770 void cpu_sparc_set_id(CPUSPARCState
*env
, unsigned int cpu
)
772 #if !defined(TARGET_SPARC64)
773 env
->mxccregs
[7] = ((cpu
+ 8) & 0xf) << 24;
777 static const sparc_def_t sparc_defs
[] = {
778 #ifdef TARGET_SPARC64
780 .name
= "Fujitsu Sparc64",
781 .iu_version
= ((0x04ULL
<< 48) | (0x02ULL
<< 32) | (0ULL << 24)),
782 .fpu_version
= 0x00000000,
783 .mmu_version
= mmu_us_12
,
786 .features
= CPU_DEFAULT_FEATURES
,
789 .name
= "Fujitsu Sparc64 III",
790 .iu_version
= ((0x04ULL
<< 48) | (0x03ULL
<< 32) | (0ULL << 24)),
791 .fpu_version
= 0x00000000,
792 .mmu_version
= mmu_us_12
,
795 .features
= CPU_DEFAULT_FEATURES
,
798 .name
= "Fujitsu Sparc64 IV",
799 .iu_version
= ((0x04ULL
<< 48) | (0x04ULL
<< 32) | (0ULL << 24)),
800 .fpu_version
= 0x00000000,
801 .mmu_version
= mmu_us_12
,
804 .features
= CPU_DEFAULT_FEATURES
,
807 .name
= "Fujitsu Sparc64 V",
808 .iu_version
= ((0x04ULL
<< 48) | (0x05ULL
<< 32) | (0x51ULL
<< 24)),
809 .fpu_version
= 0x00000000,
810 .mmu_version
= mmu_us_12
,
813 .features
= CPU_DEFAULT_FEATURES
,
816 .name
= "TI UltraSparc I",
817 .iu_version
= ((0x17ULL
<< 48) | (0x10ULL
<< 32) | (0x40ULL
<< 24)),
818 .fpu_version
= 0x00000000,
819 .mmu_version
= mmu_us_12
,
822 .features
= CPU_DEFAULT_FEATURES
,
825 .name
= "TI UltraSparc II",
826 .iu_version
= ((0x17ULL
<< 48) | (0x11ULL
<< 32) | (0x20ULL
<< 24)),
827 .fpu_version
= 0x00000000,
828 .mmu_version
= mmu_us_12
,
831 .features
= CPU_DEFAULT_FEATURES
,
834 .name
= "TI UltraSparc IIi",
835 .iu_version
= ((0x17ULL
<< 48) | (0x12ULL
<< 32) | (0x91ULL
<< 24)),
836 .fpu_version
= 0x00000000,
837 .mmu_version
= mmu_us_12
,
840 .features
= CPU_DEFAULT_FEATURES
,
843 .name
= "TI UltraSparc IIe",
844 .iu_version
= ((0x17ULL
<< 48) | (0x13ULL
<< 32) | (0x14ULL
<< 24)),
845 .fpu_version
= 0x00000000,
846 .mmu_version
= mmu_us_12
,
849 .features
= CPU_DEFAULT_FEATURES
,
852 .name
= "Sun UltraSparc III",
853 .iu_version
= ((0x3eULL
<< 48) | (0x14ULL
<< 32) | (0x34ULL
<< 24)),
854 .fpu_version
= 0x00000000,
855 .mmu_version
= mmu_us_12
,
858 .features
= CPU_DEFAULT_FEATURES
,
861 .name
= "Sun UltraSparc III Cu",
862 .iu_version
= ((0x3eULL
<< 48) | (0x15ULL
<< 32) | (0x41ULL
<< 24)),
863 .fpu_version
= 0x00000000,
864 .mmu_version
= mmu_us_3
,
867 .features
= CPU_DEFAULT_FEATURES
,
870 .name
= "Sun UltraSparc IIIi",
871 .iu_version
= ((0x3eULL
<< 48) | (0x16ULL
<< 32) | (0x34ULL
<< 24)),
872 .fpu_version
= 0x00000000,
873 .mmu_version
= mmu_us_12
,
876 .features
= CPU_DEFAULT_FEATURES
,
879 .name
= "Sun UltraSparc IV",
880 .iu_version
= ((0x3eULL
<< 48) | (0x18ULL
<< 32) | (0x31ULL
<< 24)),
881 .fpu_version
= 0x00000000,
882 .mmu_version
= mmu_us_4
,
885 .features
= CPU_DEFAULT_FEATURES
,
888 .name
= "Sun UltraSparc IV+",
889 .iu_version
= ((0x3eULL
<< 48) | (0x19ULL
<< 32) | (0x22ULL
<< 24)),
890 .fpu_version
= 0x00000000,
891 .mmu_version
= mmu_us_12
,
894 .features
= CPU_DEFAULT_FEATURES
| CPU_FEATURE_CMT
,
897 .name
= "Sun UltraSparc IIIi+",
898 .iu_version
= ((0x3eULL
<< 48) | (0x22ULL
<< 32) | (0ULL << 24)),
899 .fpu_version
= 0x00000000,
900 .mmu_version
= mmu_us_3
,
903 .features
= CPU_DEFAULT_FEATURES
,
906 .name
= "Sun UltraSparc T1",
907 // defined in sparc_ifu_fdp.v and ctu.h
908 .iu_version
= ((0x3eULL
<< 48) | (0x23ULL
<< 32) | (0x02ULL
<< 24)),
909 .fpu_version
= 0x00000000,
910 .mmu_version
= mmu_sun4v
,
913 .features
= CPU_DEFAULT_FEATURES
| CPU_FEATURE_HYPV
| CPU_FEATURE_CMT
917 .name
= "Sun UltraSparc T2",
918 // defined in tlu_asi_ctl.v and n2_revid_cust.v
919 .iu_version
= ((0x3eULL
<< 48) | (0x24ULL
<< 32) | (0x02ULL
<< 24)),
920 .fpu_version
= 0x00000000,
921 .mmu_version
= mmu_sun4v
,
924 .features
= CPU_DEFAULT_FEATURES
| CPU_FEATURE_HYPV
| CPU_FEATURE_CMT
928 .name
= "NEC UltraSparc I",
929 .iu_version
= ((0x22ULL
<< 48) | (0x10ULL
<< 32) | (0x40ULL
<< 24)),
930 .fpu_version
= 0x00000000,
931 .mmu_version
= mmu_us_12
,
934 .features
= CPU_DEFAULT_FEATURES
,
938 .name
= "Fujitsu MB86900",
939 .iu_version
= 0x00 << 24, /* Impl 0, ver 0 */
940 .fpu_version
= 4 << 17, /* FPU version 4 (Meiko) */
941 .mmu_version
= 0x00 << 24, /* Impl 0, ver 0 */
942 .mmu_bm
= 0x00004000,
943 .mmu_ctpr_mask
= 0x007ffff0,
944 .mmu_cxr_mask
= 0x0000003f,
945 .mmu_sfsr_mask
= 0xffffffff,
946 .mmu_trcr_mask
= 0xffffffff,
948 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_FSMULD
,
951 .name
= "Fujitsu MB86904",
952 .iu_version
= 0x04 << 24, /* Impl 0, ver 4 */
953 .fpu_version
= 4 << 17, /* FPU version 4 (Meiko) */
954 .mmu_version
= 0x04 << 24, /* Impl 0, ver 4 */
955 .mmu_bm
= 0x00004000,
956 .mmu_ctpr_mask
= 0x00ffffc0,
957 .mmu_cxr_mask
= 0x000000ff,
958 .mmu_sfsr_mask
= 0x00016fff,
959 .mmu_trcr_mask
= 0x00ffffff,
961 .features
= CPU_DEFAULT_FEATURES
,
964 .name
= "Fujitsu MB86907",
965 .iu_version
= 0x05 << 24, /* Impl 0, ver 5 */
966 .fpu_version
= 4 << 17, /* FPU version 4 (Meiko) */
967 .mmu_version
= 0x05 << 24, /* Impl 0, ver 5 */
968 .mmu_bm
= 0x00004000,
969 .mmu_ctpr_mask
= 0xffffffc0,
970 .mmu_cxr_mask
= 0x000000ff,
971 .mmu_sfsr_mask
= 0x00016fff,
972 .mmu_trcr_mask
= 0xffffffff,
974 .features
= CPU_DEFAULT_FEATURES
,
977 .name
= "LSI L64811",
978 .iu_version
= 0x10 << 24, /* Impl 1, ver 0 */
979 .fpu_version
= 1 << 17, /* FPU version 1 (LSI L64814) */
980 .mmu_version
= 0x10 << 24,
981 .mmu_bm
= 0x00004000,
982 .mmu_ctpr_mask
= 0x007ffff0,
983 .mmu_cxr_mask
= 0x0000003f,
984 .mmu_sfsr_mask
= 0xffffffff,
985 .mmu_trcr_mask
= 0xffffffff,
987 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_SWAP
| CPU_FEATURE_FSQRT
|
991 .name
= "Cypress CY7C601",
992 .iu_version
= 0x11 << 24, /* Impl 1, ver 1 */
993 .fpu_version
= 3 << 17, /* FPU version 3 (Cypress CY7C602) */
994 .mmu_version
= 0x10 << 24,
995 .mmu_bm
= 0x00004000,
996 .mmu_ctpr_mask
= 0x007ffff0,
997 .mmu_cxr_mask
= 0x0000003f,
998 .mmu_sfsr_mask
= 0xffffffff,
999 .mmu_trcr_mask
= 0xffffffff,
1001 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_SWAP
| CPU_FEATURE_FSQRT
|
1005 .name
= "Cypress CY7C611",
1006 .iu_version
= 0x13 << 24, /* Impl 1, ver 3 */
1007 .fpu_version
= 3 << 17, /* FPU version 3 (Cypress CY7C602) */
1008 .mmu_version
= 0x10 << 24,
1009 .mmu_bm
= 0x00004000,
1010 .mmu_ctpr_mask
= 0x007ffff0,
1011 .mmu_cxr_mask
= 0x0000003f,
1012 .mmu_sfsr_mask
= 0xffffffff,
1013 .mmu_trcr_mask
= 0xffffffff,
1015 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_SWAP
| CPU_FEATURE_FSQRT
|
1019 .name
= "TI MicroSparc I",
1020 .iu_version
= 0x41000000,
1021 .fpu_version
= 4 << 17,
1022 .mmu_version
= 0x41000000,
1023 .mmu_bm
= 0x00004000,
1024 .mmu_ctpr_mask
= 0x007ffff0,
1025 .mmu_cxr_mask
= 0x0000003f,
1026 .mmu_sfsr_mask
= 0x00016fff,
1027 .mmu_trcr_mask
= 0x0000003f,
1029 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_SWAP
| CPU_FEATURE_MUL
|
1030 CPU_FEATURE_DIV
| CPU_FEATURE_FLUSH
| CPU_FEATURE_FSQRT
|
1034 .name
= "TI MicroSparc II",
1035 .iu_version
= 0x42000000,
1036 .fpu_version
= 4 << 17,
1037 .mmu_version
= 0x02000000,
1038 .mmu_bm
= 0x00004000,
1039 .mmu_ctpr_mask
= 0x00ffffc0,
1040 .mmu_cxr_mask
= 0x000000ff,
1041 .mmu_sfsr_mask
= 0x00016fff,
1042 .mmu_trcr_mask
= 0x00ffffff,
1044 .features
= CPU_DEFAULT_FEATURES
,
1047 .name
= "TI MicroSparc IIep",
1048 .iu_version
= 0x42000000,
1049 .fpu_version
= 4 << 17,
1050 .mmu_version
= 0x04000000,
1051 .mmu_bm
= 0x00004000,
1052 .mmu_ctpr_mask
= 0x00ffffc0,
1053 .mmu_cxr_mask
= 0x000000ff,
1054 .mmu_sfsr_mask
= 0x00016bff,
1055 .mmu_trcr_mask
= 0x00ffffff,
1057 .features
= CPU_DEFAULT_FEATURES
,
1060 .name
= "TI SuperSparc 40", // STP1020NPGA
1061 .iu_version
= 0x41000000, // SuperSPARC 2.x
1062 .fpu_version
= 0 << 17,
1063 .mmu_version
= 0x00000800, // SuperSPARC 2.x, no MXCC
1064 .mmu_bm
= 0x00002000,
1065 .mmu_ctpr_mask
= 0xffffffc0,
1066 .mmu_cxr_mask
= 0x0000ffff,
1067 .mmu_sfsr_mask
= 0xffffffff,
1068 .mmu_trcr_mask
= 0xffffffff,
1070 .features
= CPU_DEFAULT_FEATURES
,
1073 .name
= "TI SuperSparc 50", // STP1020PGA
1074 .iu_version
= 0x40000000, // SuperSPARC 3.x
1075 .fpu_version
= 0 << 17,
1076 .mmu_version
= 0x01000800, // SuperSPARC 3.x, no MXCC
1077 .mmu_bm
= 0x00002000,
1078 .mmu_ctpr_mask
= 0xffffffc0,
1079 .mmu_cxr_mask
= 0x0000ffff,
1080 .mmu_sfsr_mask
= 0xffffffff,
1081 .mmu_trcr_mask
= 0xffffffff,
1083 .features
= CPU_DEFAULT_FEATURES
,
1086 .name
= "TI SuperSparc 51",
1087 .iu_version
= 0x40000000, // SuperSPARC 3.x
1088 .fpu_version
= 0 << 17,
1089 .mmu_version
= 0x01000000, // SuperSPARC 3.x, MXCC
1090 .mmu_bm
= 0x00002000,
1091 .mmu_ctpr_mask
= 0xffffffc0,
1092 .mmu_cxr_mask
= 0x0000ffff,
1093 .mmu_sfsr_mask
= 0xffffffff,
1094 .mmu_trcr_mask
= 0xffffffff,
1095 .mxcc_version
= 0x00000104,
1097 .features
= CPU_DEFAULT_FEATURES
,
1100 .name
= "TI SuperSparc 60", // STP1020APGA
1101 .iu_version
= 0x40000000, // SuperSPARC 3.x
1102 .fpu_version
= 0 << 17,
1103 .mmu_version
= 0x01000800, // SuperSPARC 3.x, no MXCC
1104 .mmu_bm
= 0x00002000,
1105 .mmu_ctpr_mask
= 0xffffffc0,
1106 .mmu_cxr_mask
= 0x0000ffff,
1107 .mmu_sfsr_mask
= 0xffffffff,
1108 .mmu_trcr_mask
= 0xffffffff,
1110 .features
= CPU_DEFAULT_FEATURES
,
1113 .name
= "TI SuperSparc 61",
1114 .iu_version
= 0x44000000, // SuperSPARC 3.x
1115 .fpu_version
= 0 << 17,
1116 .mmu_version
= 0x01000000, // SuperSPARC 3.x, MXCC
1117 .mmu_bm
= 0x00002000,
1118 .mmu_ctpr_mask
= 0xffffffc0,
1119 .mmu_cxr_mask
= 0x0000ffff,
1120 .mmu_sfsr_mask
= 0xffffffff,
1121 .mmu_trcr_mask
= 0xffffffff,
1122 .mxcc_version
= 0x00000104,
1124 .features
= CPU_DEFAULT_FEATURES
,
1127 .name
= "TI SuperSparc II",
1128 .iu_version
= 0x40000000, // SuperSPARC II 1.x
1129 .fpu_version
= 0 << 17,
1130 .mmu_version
= 0x08000000, // SuperSPARC II 1.x, MXCC
1131 .mmu_bm
= 0x00002000,
1132 .mmu_ctpr_mask
= 0xffffffc0,
1133 .mmu_cxr_mask
= 0x0000ffff,
1134 .mmu_sfsr_mask
= 0xffffffff,
1135 .mmu_trcr_mask
= 0xffffffff,
1136 .mxcc_version
= 0x00000104,
1138 .features
= CPU_DEFAULT_FEATURES
,
1141 .name
= "Ross RT625",
1142 .iu_version
= 0x1e000000,
1143 .fpu_version
= 1 << 17,
1144 .mmu_version
= 0x1e000000,
1145 .mmu_bm
= 0x00004000,
1146 .mmu_ctpr_mask
= 0x007ffff0,
1147 .mmu_cxr_mask
= 0x0000003f,
1148 .mmu_sfsr_mask
= 0xffffffff,
1149 .mmu_trcr_mask
= 0xffffffff,
1151 .features
= CPU_DEFAULT_FEATURES
,
1154 .name
= "Ross RT620",
1155 .iu_version
= 0x1f000000,
1156 .fpu_version
= 1 << 17,
1157 .mmu_version
= 0x1f000000,
1158 .mmu_bm
= 0x00004000,
1159 .mmu_ctpr_mask
= 0x007ffff0,
1160 .mmu_cxr_mask
= 0x0000003f,
1161 .mmu_sfsr_mask
= 0xffffffff,
1162 .mmu_trcr_mask
= 0xffffffff,
1164 .features
= CPU_DEFAULT_FEATURES
,
1167 .name
= "BIT B5010",
1168 .iu_version
= 0x20000000,
1169 .fpu_version
= 0 << 17, /* B5010/B5110/B5120/B5210 */
1170 .mmu_version
= 0x20000000,
1171 .mmu_bm
= 0x00004000,
1172 .mmu_ctpr_mask
= 0x007ffff0,
1173 .mmu_cxr_mask
= 0x0000003f,
1174 .mmu_sfsr_mask
= 0xffffffff,
1175 .mmu_trcr_mask
= 0xffffffff,
1177 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_SWAP
| CPU_FEATURE_FSQRT
|
1181 .name
= "Matsushita MN10501",
1182 .iu_version
= 0x50000000,
1183 .fpu_version
= 0 << 17,
1184 .mmu_version
= 0x50000000,
1185 .mmu_bm
= 0x00004000,
1186 .mmu_ctpr_mask
= 0x007ffff0,
1187 .mmu_cxr_mask
= 0x0000003f,
1188 .mmu_sfsr_mask
= 0xffffffff,
1189 .mmu_trcr_mask
= 0xffffffff,
1191 .features
= CPU_FEATURE_FLOAT
| CPU_FEATURE_MUL
| CPU_FEATURE_FSQRT
|
1195 .name
= "Weitek W8601",
1196 .iu_version
= 0x90 << 24, /* Impl 9, ver 0 */
1197 .fpu_version
= 3 << 17, /* FPU version 3 (Weitek WTL3170/2) */
1198 .mmu_version
= 0x10 << 24,
1199 .mmu_bm
= 0x00004000,
1200 .mmu_ctpr_mask
= 0x007ffff0,
1201 .mmu_cxr_mask
= 0x0000003f,
1202 .mmu_sfsr_mask
= 0xffffffff,
1203 .mmu_trcr_mask
= 0xffffffff,
1205 .features
= CPU_DEFAULT_FEATURES
,
1209 .iu_version
= 0xf2000000,
1210 .fpu_version
= 4 << 17, /* FPU version 4 (Meiko) */
1211 .mmu_version
= 0xf2000000,
1212 .mmu_bm
= 0x00004000,
1213 .mmu_ctpr_mask
= 0x007ffff0,
1214 .mmu_cxr_mask
= 0x0000003f,
1215 .mmu_sfsr_mask
= 0xffffffff,
1216 .mmu_trcr_mask
= 0xffffffff,
1218 .features
= CPU_DEFAULT_FEATURES
,
1222 .iu_version
= 0xf3000000,
1223 .fpu_version
= 4 << 17, /* FPU version 4 (Meiko) */
1224 .mmu_version
= 0xf3000000,
1225 .mmu_bm
= 0x00004000,
1226 .mmu_ctpr_mask
= 0x007ffff0,
1227 .mmu_cxr_mask
= 0x0000003f,
1228 .mmu_sfsr_mask
= 0xffffffff,
1229 .mmu_trcr_mask
= 0xffffffff,
1231 .features
= CPU_DEFAULT_FEATURES
,
1236 static const char * const feature_name
[] = {
1253 static void print_features(FILE *f
,
1254 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
1255 uint32_t features
, const char *prefix
)
1259 for (i
= 0; i
< ARRAY_SIZE(feature_name
); i
++)
1260 if (feature_name
[i
] && (features
& (1 << i
))) {
1262 (*cpu_fprintf
)(f
, "%s", prefix
);
1263 (*cpu_fprintf
)(f
, "%s ", feature_name
[i
]);
1267 static void add_flagname_to_bitmaps(const char *flagname
, uint32_t *features
)
1271 for (i
= 0; i
< ARRAY_SIZE(feature_name
); i
++)
1272 if (feature_name
[i
] && !strcmp(flagname
, feature_name
[i
])) {
1273 *features
|= 1 << i
;
1276 fprintf(stderr
, "CPU feature %s not found\n", flagname
);
1279 static int cpu_sparc_find_by_name(sparc_def_t
*cpu_def
, const char *cpu_model
)
1282 const sparc_def_t
*def
= NULL
;
1283 char *s
= strdup(cpu_model
);
1284 char *featurestr
, *name
= strtok(s
, ",");
1285 uint32_t plus_features
= 0;
1286 uint32_t minus_features
= 0;
1287 long long iu_version
;
1288 uint32_t fpu_version
, mmu_version
, nwindows
;
1290 for (i
= 0; i
< ARRAY_SIZE(sparc_defs
); i
++) {
1291 if (strcasecmp(name
, sparc_defs
[i
].name
) == 0) {
1292 def
= &sparc_defs
[i
];
1297 memcpy(cpu_def
, def
, sizeof(*def
));
1299 featurestr
= strtok(NULL
, ",");
1300 while (featurestr
) {
1303 if (featurestr
[0] == '+') {
1304 add_flagname_to_bitmaps(featurestr
+ 1, &plus_features
);
1305 } else if (featurestr
[0] == '-') {
1306 add_flagname_to_bitmaps(featurestr
+ 1, &minus_features
);
1307 } else if ((val
= strchr(featurestr
, '='))) {
1309 if (!strcmp(featurestr
, "iu_version")) {
1312 iu_version
= strtoll(val
, &err
, 0);
1313 if (!*val
|| *err
) {
1314 fprintf(stderr
, "bad numerical value %s\n", val
);
1317 cpu_def
->iu_version
= iu_version
;
1318 #ifdef DEBUG_FEATURES
1319 fprintf(stderr
, "iu_version %llx\n", iu_version
);
1321 } else if (!strcmp(featurestr
, "fpu_version")) {
1324 fpu_version
= strtol(val
, &err
, 0);
1325 if (!*val
|| *err
) {
1326 fprintf(stderr
, "bad numerical value %s\n", val
);
1329 cpu_def
->fpu_version
= fpu_version
;
1330 #ifdef DEBUG_FEATURES
1331 fprintf(stderr
, "fpu_version %x\n", fpu_version
);
1333 } else if (!strcmp(featurestr
, "mmu_version")) {
1336 mmu_version
= strtol(val
, &err
, 0);
1337 if (!*val
|| *err
) {
1338 fprintf(stderr
, "bad numerical value %s\n", val
);
1341 cpu_def
->mmu_version
= mmu_version
;
1342 #ifdef DEBUG_FEATURES
1343 fprintf(stderr
, "mmu_version %x\n", mmu_version
);
1345 } else if (!strcmp(featurestr
, "nwindows")) {
1348 nwindows
= strtol(val
, &err
, 0);
1349 if (!*val
|| *err
|| nwindows
> MAX_NWINDOWS
||
1350 nwindows
< MIN_NWINDOWS
) {
1351 fprintf(stderr
, "bad numerical value %s\n", val
);
1354 cpu_def
->nwindows
= nwindows
;
1355 #ifdef DEBUG_FEATURES
1356 fprintf(stderr
, "nwindows %d\n", nwindows
);
1359 fprintf(stderr
, "unrecognized feature %s\n", featurestr
);
1363 fprintf(stderr
, "feature string `%s' not in format "
1364 "(+feature|-feature|feature=xyz)\n", featurestr
);
1367 featurestr
= strtok(NULL
, ",");
1369 cpu_def
->features
|= plus_features
;
1370 cpu_def
->features
&= ~minus_features
;
1371 #ifdef DEBUG_FEATURES
1372 print_features(stderr
, fprintf
, cpu_def
->features
, NULL
);
1382 void sparc_cpu_list(FILE *f
, int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...))
1386 for (i
= 0; i
< ARRAY_SIZE(sparc_defs
); i
++) {
1387 (*cpu_fprintf
)(f
, "Sparc %16s IU " TARGET_FMT_lx
" FPU %08x MMU %08x NWINS %d ",
1389 sparc_defs
[i
].iu_version
,
1390 sparc_defs
[i
].fpu_version
,
1391 sparc_defs
[i
].mmu_version
,
1392 sparc_defs
[i
].nwindows
);
1393 print_features(f
, cpu_fprintf
, CPU_DEFAULT_FEATURES
&
1394 ~sparc_defs
[i
].features
, "-");
1395 print_features(f
, cpu_fprintf
, ~CPU_DEFAULT_FEATURES
&
1396 sparc_defs
[i
].features
, "+");
1397 (*cpu_fprintf
)(f
, "\n");
1399 (*cpu_fprintf
)(f
, "Default CPU feature flags (use '-' to remove): ");
1400 print_features(f
, cpu_fprintf
, CPU_DEFAULT_FEATURES
, NULL
);
1401 (*cpu_fprintf
)(f
, "\n");
1402 (*cpu_fprintf
)(f
, "Available CPU feature flags (use '+' to add): ");
1403 print_features(f
, cpu_fprintf
, ~CPU_DEFAULT_FEATURES
, NULL
);
1404 (*cpu_fprintf
)(f
, "\n");
1405 (*cpu_fprintf
)(f
, "Numerical features (use '=' to set): iu_version "
1406 "fpu_version mmu_version nwindows\n");
1409 void cpu_dump_state(CPUState
*env
, FILE *f
,
1410 int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...),
1415 cpu_fprintf(f
, "pc: " TARGET_FMT_lx
" npc: " TARGET_FMT_lx
"\n", env
->pc
,
1417 cpu_fprintf(f
, "General Registers:\n");
1418 for (i
= 0; i
< 4; i
++)
1419 cpu_fprintf(f
, "%%g%c: " TARGET_FMT_lx
"\t", i
+ '0', env
->gregs
[i
]);
1420 cpu_fprintf(f
, "\n");
1422 cpu_fprintf(f
, "%%g%c: " TARGET_FMT_lx
"\t", i
+ '0', env
->gregs
[i
]);
1423 cpu_fprintf(f
, "\nCurrent Register Window:\n");
1424 for (x
= 0; x
< 3; x
++) {
1425 for (i
= 0; i
< 4; i
++)
1426 cpu_fprintf(f
, "%%%c%d: " TARGET_FMT_lx
"\t",
1427 (x
== 0 ? 'o' : (x
== 1 ? 'l' : 'i')), i
,
1428 env
->regwptr
[i
+ x
* 8]);
1429 cpu_fprintf(f
, "\n");
1431 cpu_fprintf(f
, "%%%c%d: " TARGET_FMT_lx
"\t",
1432 (x
== 0 ? 'o' : x
== 1 ? 'l' : 'i'), i
,
1433 env
->regwptr
[i
+ x
* 8]);
1434 cpu_fprintf(f
, "\n");
1436 cpu_fprintf(f
, "\nFloating Point Registers:\n");
1437 for (i
= 0; i
< 32; i
++) {
1439 cpu_fprintf(f
, "%%f%02d:", i
);
1440 cpu_fprintf(f
, " %016f", *(float *)&env
->fpr
[i
]);
1442 cpu_fprintf(f
, "\n");
1444 #ifdef TARGET_SPARC64
1445 cpu_fprintf(f
, "pstate: 0x%08x ccr: 0x%02x asi: 0x%02x tl: %d fprs: %d\n",
1446 env
->pstate
, GET_CCR(env
), env
->asi
, env
->tl
, env
->fprs
);
1447 cpu_fprintf(f
, "cansave: %d canrestore: %d otherwin: %d wstate %d "
1448 "cleanwin %d cwp %d\n",
1449 env
->cansave
, env
->canrestore
, env
->otherwin
, env
->wstate
,
1450 env
->cleanwin
, env
->nwindows
- 1 - env
->cwp
);
1453 #define GET_FLAG(a,b) ((env->psr & a)?b:'-')
1455 cpu_fprintf(f
, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n",
1456 GET_PSR(env
), GET_FLAG(PSR_ZERO
, 'Z'), GET_FLAG(PSR_OVF
, 'V'),
1457 GET_FLAG(PSR_NEG
, 'N'), GET_FLAG(PSR_CARRY
, 'C'),
1458 env
->psrs
?'S':'-', env
->psrps
?'P':'-',
1459 env
->psret
?'E':'-', env
->wim
);
1461 cpu_fprintf(f
, "fsr: 0x%08x\n", env
->fsr
);