1fcf5ef2aSThomas Huth /*
2fcf5ef2aSThomas Huth * Sparc CPU init helpers
3fcf5ef2aSThomas Huth *
4fcf5ef2aSThomas Huth * Copyright (c) 2003-2005 Fabrice Bellard
5fcf5ef2aSThomas Huth *
6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or
7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public
8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either
95650b549SChetan Pant * version 2.1 of the License, or (at your option) any later version.
10fcf5ef2aSThomas Huth *
11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful,
12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of
13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14fcf5ef2aSThomas Huth * Lesser General Public License for more details.
15fcf5ef2aSThomas Huth *
16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public
17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18fcf5ef2aSThomas Huth */
19fcf5ef2aSThomas Huth
20fcf5ef2aSThomas Huth #include "qemu/osdep.h"
21fcf5ef2aSThomas Huth #include "qapi/error.h"
22fcf5ef2aSThomas Huth #include "cpu.h"
230b8fa32fSMarkus Armbruster #include "qemu/module.h"
240442428aSMarkus Armbruster #include "qemu/qemu-print.h"
25fcf5ef2aSThomas Huth #include "exec/exec-all.h"
26de05005bSIgor Mammedov #include "hw/qdev-properties.h"
27de05005bSIgor Mammedov #include "qapi/visitor.h"
28c4bf3a92SAnton Johansson #include "tcg/tcg.h"
29*4482f32dSPeter Maydell #include "fpu/softfloat.h"
30fcf5ef2aSThomas Huth
31fcf5ef2aSThomas Huth //#define DEBUG_FEATURES
32fcf5ef2aSThomas Huth
sparc_cpu_reset_hold(Object * obj,ResetType type)33ad80e367SPeter Maydell static void sparc_cpu_reset_hold(Object *obj, ResetType type)
34fcf5ef2aSThomas Huth {
35348802b5SPhilippe Mathieu-Daudé CPUState *cs = CPU(obj);
36348802b5SPhilippe Mathieu-Daudé SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj);
3777976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs);
38fcf5ef2aSThomas Huth
393b4fff1bSPeter Maydell if (scc->parent_phases.hold) {
40ad80e367SPeter Maydell scc->parent_phases.hold(obj, type);
413b4fff1bSPeter Maydell }
42fcf5ef2aSThomas Huth
431f5c00cfSAlex Bennée memset(env, 0, offsetof(CPUSPARCState, end_reset_fields));
44fcf5ef2aSThomas Huth env->cwp = 0;
45fcf5ef2aSThomas Huth #ifndef TARGET_SPARC64
46fcf5ef2aSThomas Huth env->wim = 1;
47fcf5ef2aSThomas Huth #endif
48fcf5ef2aSThomas Huth env->regwptr = env->regbase + (env->cwp * 16);
49fcf5ef2aSThomas Huth #if defined(CONFIG_USER_ONLY)
50fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
51fcf5ef2aSThomas Huth env->cleanwin = env->nwindows - 2;
52fcf5ef2aSThomas Huth env->cansave = env->nwindows - 2;
53fcf5ef2aSThomas Huth env->pstate = PS_RMO | PS_PEF | PS_IE;
54fcf5ef2aSThomas Huth env->asi = 0x82; /* Primary no-fault */
55fcf5ef2aSThomas Huth #endif
56fcf5ef2aSThomas Huth #else
57fcf5ef2aSThomas Huth #if !defined(TARGET_SPARC64)
58fcf5ef2aSThomas Huth env->psret = 0;
59fcf5ef2aSThomas Huth env->psrs = 1;
60fcf5ef2aSThomas Huth env->psrps = 1;
61fcf5ef2aSThomas Huth #endif
62fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
63cbc3a6a4SArtyom Tarasenko env->pstate = PS_PRIV | PS_RED | PS_PEF;
64cbc3a6a4SArtyom Tarasenko if (!cpu_has_hypervisor(env)) {
65cbc3a6a4SArtyom Tarasenko env->pstate |= PS_AG;
66cbc3a6a4SArtyom Tarasenko }
67fcf5ef2aSThomas Huth env->hpstate = cpu_has_hypervisor(env) ? HS_PRIV : 0;
68fcf5ef2aSThomas Huth env->tl = env->maxtl;
69cbc3a6a4SArtyom Tarasenko env->gl = 2;
70fcf5ef2aSThomas Huth cpu_tsptr(env)->tt = TT_POWER_ON_RESET;
71fcf5ef2aSThomas Huth env->lsu = 0;
72fcf5ef2aSThomas Huth #else
73fcf5ef2aSThomas Huth env->mmuregs[0] &= ~(MMU_E | MMU_NF);
74576e1c4cSIgor Mammedov env->mmuregs[0] |= env->def.mmu_bm;
75fcf5ef2aSThomas Huth #endif
76fcf5ef2aSThomas Huth env->pc = 0;
77fcf5ef2aSThomas Huth env->npc = env->pc + 4;
78fcf5ef2aSThomas Huth #endif
79fcf5ef2aSThomas Huth env->cache_control = 0;
8065c1c039SPeter Maydell cpu_put_fsr(env, 0);
81fcf5ef2aSThomas Huth }
82fcf5ef2aSThomas Huth
83798ac8b5SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY
sparc_cpu_exec_interrupt(CPUState * cs,int interrupt_request)84fcf5ef2aSThomas Huth static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
85fcf5ef2aSThomas Huth {
86fcf5ef2aSThomas Huth if (interrupt_request & CPU_INTERRUPT_HARD) {
8777976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs);
88fcf5ef2aSThomas Huth
89fcf5ef2aSThomas Huth if (cpu_interrupts_enabled(env) && env->interrupt_index > 0) {
90fcf5ef2aSThomas Huth int pil = env->interrupt_index & 0xf;
91fcf5ef2aSThomas Huth int type = env->interrupt_index & 0xf0;
92fcf5ef2aSThomas Huth
93fcf5ef2aSThomas Huth if (type != TT_EXTINT || cpu_pil_allowed(env, pil)) {
94fcf5ef2aSThomas Huth cs->exception_index = env->interrupt_index;
95fcf5ef2aSThomas Huth sparc_cpu_do_interrupt(cs);
96fcf5ef2aSThomas Huth return true;
97fcf5ef2aSThomas Huth }
98fcf5ef2aSThomas Huth }
99fcf5ef2aSThomas Huth }
100fcf5ef2aSThomas Huth return false;
101fcf5ef2aSThomas Huth }
102798ac8b5SPhilippe Mathieu-Daudé #endif /* !CONFIG_USER_ONLY */
103fcf5ef2aSThomas Huth
cpu_sparc_disas_set_info(CPUState * cpu,disassemble_info * info)104fcf5ef2aSThomas Huth static void cpu_sparc_disas_set_info(CPUState *cpu, disassemble_info *info)
105fcf5ef2aSThomas Huth {
106fcf5ef2aSThomas Huth info->print_insn = print_insn_sparc;
107fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
108fcf5ef2aSThomas Huth info->mach = bfd_mach_sparc_v9b;
109fcf5ef2aSThomas Huth #endif
110fcf5ef2aSThomas Huth }
111fcf5ef2aSThomas Huth
112d1853231SIgor Mammedov static void
cpu_add_feat_as_prop(const char * typename,const char * name,const char * val)113d1853231SIgor Mammedov cpu_add_feat_as_prop(const char *typename, const char *name, const char *val)
114fcf5ef2aSThomas Huth {
115d1853231SIgor Mammedov GlobalProperty *prop = g_new0(typeof(*prop), 1);
116d1853231SIgor Mammedov prop->driver = typename;
117d1853231SIgor Mammedov prop->property = g_strdup(name);
118d1853231SIgor Mammedov prop->value = g_strdup(val);
119d1853231SIgor Mammedov qdev_prop_register_global(prop);
120fcf5ef2aSThomas Huth }
121fcf5ef2aSThomas Huth
122d1853231SIgor Mammedov /* Parse "+feature,-feature,feature=foo" CPU feature string */
sparc_cpu_parse_features(const char * typename,char * features,Error ** errp)123d1853231SIgor Mammedov static void sparc_cpu_parse_features(const char *typename, char *features,
124d1853231SIgor Mammedov Error **errp)
125d1853231SIgor Mammedov {
126d1853231SIgor Mammedov GList *l, *plus_features = NULL, *minus_features = NULL;
127d1853231SIgor Mammedov char *featurestr; /* Single 'key=value" string being parsed */
128d1853231SIgor Mammedov static bool cpu_globals_initialized;
129d1853231SIgor Mammedov
130d1853231SIgor Mammedov if (cpu_globals_initialized) {
131d1853231SIgor Mammedov return;
132d1853231SIgor Mammedov }
133d1853231SIgor Mammedov cpu_globals_initialized = true;
134d1853231SIgor Mammedov
135d1853231SIgor Mammedov if (!features) {
136d1853231SIgor Mammedov return;
137d1853231SIgor Mammedov }
138d1853231SIgor Mammedov
139d1853231SIgor Mammedov for (featurestr = strtok(features, ",");
140d1853231SIgor Mammedov featurestr;
141d1853231SIgor Mammedov featurestr = strtok(NULL, ",")) {
142d1853231SIgor Mammedov const char *name;
143d1853231SIgor Mammedov const char *val = NULL;
144d1853231SIgor Mammedov char *eq = NULL;
145d1853231SIgor Mammedov
146d1853231SIgor Mammedov /* Compatibility syntax: */
147d1853231SIgor Mammedov if (featurestr[0] == '+') {
148d1853231SIgor Mammedov plus_features = g_list_append(plus_features,
149d1853231SIgor Mammedov g_strdup(featurestr + 1));
150d1853231SIgor Mammedov continue;
151d1853231SIgor Mammedov } else if (featurestr[0] == '-') {
152d1853231SIgor Mammedov minus_features = g_list_append(minus_features,
153d1853231SIgor Mammedov g_strdup(featurestr + 1));
154d1853231SIgor Mammedov continue;
155d1853231SIgor Mammedov }
156d1853231SIgor Mammedov
157d1853231SIgor Mammedov eq = strchr(featurestr, '=');
158d1853231SIgor Mammedov name = featurestr;
159d1853231SIgor Mammedov if (eq) {
160d1853231SIgor Mammedov *eq++ = 0;
161d1853231SIgor Mammedov val = eq;
162d1853231SIgor Mammedov
163d1853231SIgor Mammedov /*
164d1853231SIgor Mammedov * Temporarily, only +feat/-feat will be supported
165d1853231SIgor Mammedov * for boolean properties until we remove the
166d1853231SIgor Mammedov * minus-overrides-plus semantics and just follow
167d1853231SIgor Mammedov * the order options appear on the command-line.
168d1853231SIgor Mammedov *
169d1853231SIgor Mammedov * TODO: warn if user is relying on minus-override-plus semantics
170d1853231SIgor Mammedov * TODO: remove minus-override-plus semantics after
171d1853231SIgor Mammedov * warning for a few releases
172d1853231SIgor Mammedov */
173d1853231SIgor Mammedov if (!strcasecmp(val, "on") ||
174d1853231SIgor Mammedov !strcasecmp(val, "off") ||
175d1853231SIgor Mammedov !strcasecmp(val, "true") ||
176d1853231SIgor Mammedov !strcasecmp(val, "false")) {
177d1853231SIgor Mammedov error_setg(errp, "Boolean properties in format %s=%s"
178d1853231SIgor Mammedov " are not supported", name, val);
179d1853231SIgor Mammedov return;
180d1853231SIgor Mammedov }
181d1853231SIgor Mammedov } else {
182d1853231SIgor Mammedov error_setg(errp, "Unsupported property format: %s", name);
183d1853231SIgor Mammedov return;
184d1853231SIgor Mammedov }
185d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, val);
186d1853231SIgor Mammedov }
187d1853231SIgor Mammedov
188d1853231SIgor Mammedov for (l = plus_features; l; l = l->next) {
189d1853231SIgor Mammedov const char *name = l->data;
190d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, "on");
191d1853231SIgor Mammedov }
192d1853231SIgor Mammedov g_list_free_full(plus_features, g_free);
193d1853231SIgor Mammedov
194d1853231SIgor Mammedov for (l = minus_features; l; l = l->next) {
195d1853231SIgor Mammedov const char *name = l->data;
196d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, "off");
197d1853231SIgor Mammedov }
198d1853231SIgor Mammedov g_list_free_full(minus_features, g_free);
199fcf5ef2aSThomas Huth }
200fcf5ef2aSThomas Huth
cpu_sparc_set_id(CPUSPARCState * env,unsigned int cpu)201fcf5ef2aSThomas Huth void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu)
202fcf5ef2aSThomas Huth {
203fcf5ef2aSThomas Huth #if !defined(TARGET_SPARC64)
204fcf5ef2aSThomas Huth env->mxccregs[7] = ((cpu + 8) & 0xf) << 24;
205fcf5ef2aSThomas Huth #endif
206fcf5ef2aSThomas Huth }
207fcf5ef2aSThomas Huth
208fcf5ef2aSThomas Huth static const sparc_def_t sparc_defs[] = {
209fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
210fcf5ef2aSThomas Huth {
2114a7bdec3SThomas Huth .name = "Fujitsu-Sparc64",
212fcf5ef2aSThomas Huth .iu_version = ((0x04ULL << 48) | (0x02ULL << 32) | (0ULL << 24)),
213fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
214fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
215fcf5ef2aSThomas Huth .nwindows = 4,
216fcf5ef2aSThomas Huth .maxtl = 4,
217fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
218fcf5ef2aSThomas Huth },
219fcf5ef2aSThomas Huth {
2204a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-III",
221fcf5ef2aSThomas Huth .iu_version = ((0x04ULL << 48) | (0x03ULL << 32) | (0ULL << 24)),
222fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
223fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
224fcf5ef2aSThomas Huth .nwindows = 5,
225fcf5ef2aSThomas Huth .maxtl = 4,
226fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
227fcf5ef2aSThomas Huth },
228fcf5ef2aSThomas Huth {
2294a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-IV",
230fcf5ef2aSThomas Huth .iu_version = ((0x04ULL << 48) | (0x04ULL << 32) | (0ULL << 24)),
231fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
232fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
233fcf5ef2aSThomas Huth .nwindows = 8,
234fcf5ef2aSThomas Huth .maxtl = 5,
235fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
236fcf5ef2aSThomas Huth },
237fcf5ef2aSThomas Huth {
2384a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-V",
239fcf5ef2aSThomas Huth .iu_version = ((0x04ULL << 48) | (0x05ULL << 32) | (0x51ULL << 24)),
240fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
241fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
242fcf5ef2aSThomas Huth .nwindows = 8,
243fcf5ef2aSThomas Huth .maxtl = 5,
244fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
245fcf5ef2aSThomas Huth },
246fcf5ef2aSThomas Huth {
2474a7bdec3SThomas Huth .name = "TI-UltraSparc-I",
248fcf5ef2aSThomas Huth .iu_version = ((0x17ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)),
249fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
250fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
251fcf5ef2aSThomas Huth .nwindows = 8,
252fcf5ef2aSThomas Huth .maxtl = 5,
253fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
254fcf5ef2aSThomas Huth },
255fcf5ef2aSThomas Huth {
2564a7bdec3SThomas Huth .name = "TI-UltraSparc-II",
257fcf5ef2aSThomas Huth .iu_version = ((0x17ULL << 48) | (0x11ULL << 32) | (0x20ULL << 24)),
258fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
259fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
260fcf5ef2aSThomas Huth .nwindows = 8,
261fcf5ef2aSThomas Huth .maxtl = 5,
262fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
263fcf5ef2aSThomas Huth },
264fcf5ef2aSThomas Huth {
2654a7bdec3SThomas Huth .name = "TI-UltraSparc-IIi",
266fcf5ef2aSThomas Huth .iu_version = ((0x17ULL << 48) | (0x12ULL << 32) | (0x91ULL << 24)),
267fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
268fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
269fcf5ef2aSThomas Huth .nwindows = 8,
270fcf5ef2aSThomas Huth .maxtl = 5,
271fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
272fcf5ef2aSThomas Huth },
273fcf5ef2aSThomas Huth {
2744a7bdec3SThomas Huth .name = "TI-UltraSparc-IIe",
275fcf5ef2aSThomas Huth .iu_version = ((0x17ULL << 48) | (0x13ULL << 32) | (0x14ULL << 24)),
276fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
277fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
278fcf5ef2aSThomas Huth .nwindows = 8,
279fcf5ef2aSThomas Huth .maxtl = 5,
280fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
281fcf5ef2aSThomas Huth },
282fcf5ef2aSThomas Huth {
2834a7bdec3SThomas Huth .name = "Sun-UltraSparc-III",
284fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x14ULL << 32) | (0x34ULL << 24)),
285fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
286fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
287fcf5ef2aSThomas Huth .nwindows = 8,
288fcf5ef2aSThomas Huth .maxtl = 5,
289fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
290fcf5ef2aSThomas Huth },
291fcf5ef2aSThomas Huth {
2924a7bdec3SThomas Huth .name = "Sun-UltraSparc-III-Cu",
293fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x15ULL << 32) | (0x41ULL << 24)),
294fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
295fcf5ef2aSThomas Huth .mmu_version = mmu_us_3,
296fcf5ef2aSThomas Huth .nwindows = 8,
297fcf5ef2aSThomas Huth .maxtl = 5,
298fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
299fcf5ef2aSThomas Huth },
300fcf5ef2aSThomas Huth {
3014a7bdec3SThomas Huth .name = "Sun-UltraSparc-IIIi",
302fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x16ULL << 32) | (0x34ULL << 24)),
303fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
304fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
305fcf5ef2aSThomas Huth .nwindows = 8,
306fcf5ef2aSThomas Huth .maxtl = 5,
307fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
308fcf5ef2aSThomas Huth },
309fcf5ef2aSThomas Huth {
3104a7bdec3SThomas Huth .name = "Sun-UltraSparc-IV",
311fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x18ULL << 32) | (0x31ULL << 24)),
312fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
313fcf5ef2aSThomas Huth .mmu_version = mmu_us_4,
314fcf5ef2aSThomas Huth .nwindows = 8,
315fcf5ef2aSThomas Huth .maxtl = 5,
316fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
317fcf5ef2aSThomas Huth },
318fcf5ef2aSThomas Huth {
3194a7bdec3SThomas Huth .name = "Sun-UltraSparc-IV-plus",
320fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x19ULL << 32) | (0x22ULL << 24)),
321fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
322fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
323fcf5ef2aSThomas Huth .nwindows = 8,
324fcf5ef2aSThomas Huth .maxtl = 5,
325fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_CMT,
326fcf5ef2aSThomas Huth },
327fcf5ef2aSThomas Huth {
3284a7bdec3SThomas Huth .name = "Sun-UltraSparc-IIIi-plus",
329fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x22ULL << 32) | (0ULL << 24)),
330fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
331fcf5ef2aSThomas Huth .mmu_version = mmu_us_3,
332fcf5ef2aSThomas Huth .nwindows = 8,
333fcf5ef2aSThomas Huth .maxtl = 5,
334fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
335fcf5ef2aSThomas Huth },
336fcf5ef2aSThomas Huth {
3374a7bdec3SThomas Huth .name = "Sun-UltraSparc-T1",
338fcf5ef2aSThomas Huth /* defined in sparc_ifu_fdp.v and ctu.h */
339fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x23ULL << 32) | (0x02ULL << 24)),
340fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
341fcf5ef2aSThomas Huth .mmu_version = mmu_sun4v,
342fcf5ef2aSThomas Huth .nwindows = 8,
343fcf5ef2aSThomas Huth .maxtl = 6,
344fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT
345fcf5ef2aSThomas Huth | CPU_FEATURE_GL,
346fcf5ef2aSThomas Huth },
347fcf5ef2aSThomas Huth {
3484a7bdec3SThomas Huth .name = "Sun-UltraSparc-T2",
349fcf5ef2aSThomas Huth /* defined in tlu_asi_ctl.v and n2_revid_cust.v */
350fcf5ef2aSThomas Huth .iu_version = ((0x3eULL << 48) | (0x24ULL << 32) | (0x02ULL << 24)),
351fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
352fcf5ef2aSThomas Huth .mmu_version = mmu_sun4v,
353fcf5ef2aSThomas Huth .nwindows = 8,
354fcf5ef2aSThomas Huth .maxtl = 6,
355fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT
356fcf5ef2aSThomas Huth | CPU_FEATURE_GL,
357fcf5ef2aSThomas Huth },
358fcf5ef2aSThomas Huth {
3594a7bdec3SThomas Huth .name = "NEC-UltraSparc-I",
360fcf5ef2aSThomas Huth .iu_version = ((0x22ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)),
361fcf5ef2aSThomas Huth .fpu_version = 0x00000000,
362fcf5ef2aSThomas Huth .mmu_version = mmu_us_12,
363fcf5ef2aSThomas Huth .nwindows = 8,
364fcf5ef2aSThomas Huth .maxtl = 5,
365fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
366fcf5ef2aSThomas Huth },
367fcf5ef2aSThomas Huth #else
368fcf5ef2aSThomas Huth {
3694a7bdec3SThomas Huth .name = "Fujitsu-MB86904",
370fcf5ef2aSThomas Huth .iu_version = 0x04 << 24, /* Impl 0, ver 4 */
37149bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
372fcf5ef2aSThomas Huth .mmu_version = 0x04 << 24, /* Impl 0, ver 4 */
373fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
374fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0x00ffffc0,
375fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x000000ff,
376fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0x00016fff,
377fcf5ef2aSThomas Huth .mmu_trcr_mask = 0x00ffffff,
378fcf5ef2aSThomas Huth .nwindows = 8,
379fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
380fcf5ef2aSThomas Huth },
381fcf5ef2aSThomas Huth {
3824a7bdec3SThomas Huth .name = "Fujitsu-MB86907",
383fcf5ef2aSThomas Huth .iu_version = 0x05 << 24, /* Impl 0, ver 5 */
38449bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
385fcf5ef2aSThomas Huth .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */
386fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
387fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
388fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x000000ff,
389fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0x00016fff,
390fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
391fcf5ef2aSThomas Huth .nwindows = 8,
392fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
393fcf5ef2aSThomas Huth },
394fcf5ef2aSThomas Huth {
3954a7bdec3SThomas Huth .name = "TI-MicroSparc-I",
396fcf5ef2aSThomas Huth .iu_version = 0x41000000,
39749bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT,
398fcf5ef2aSThomas Huth .mmu_version = 0x41000000,
399fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
400fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0x007ffff0,
401fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000003f,
402fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0x00016fff,
403fcf5ef2aSThomas Huth .mmu_trcr_mask = 0x0000003f,
404fcf5ef2aSThomas Huth .nwindows = 7,
4055f25b383SRichard Henderson .features = CPU_FEATURE_MUL | CPU_FEATURE_DIV,
406fcf5ef2aSThomas Huth },
407fcf5ef2aSThomas Huth {
4084a7bdec3SThomas Huth .name = "TI-MicroSparc-II",
409fcf5ef2aSThomas Huth .iu_version = 0x42000000,
41049bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT,
411fcf5ef2aSThomas Huth .mmu_version = 0x02000000,
412fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
413fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0x00ffffc0,
414fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x000000ff,
415fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0x00016fff,
416fcf5ef2aSThomas Huth .mmu_trcr_mask = 0x00ffffff,
417fcf5ef2aSThomas Huth .nwindows = 8,
418fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
419fcf5ef2aSThomas Huth },
420fcf5ef2aSThomas Huth {
4214a7bdec3SThomas Huth .name = "TI-MicroSparc-IIep",
422fcf5ef2aSThomas Huth .iu_version = 0x42000000,
42349bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT,
424fcf5ef2aSThomas Huth .mmu_version = 0x04000000,
425fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
426fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0x00ffffc0,
427fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x000000ff,
428fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0x00016bff,
429fcf5ef2aSThomas Huth .mmu_trcr_mask = 0x00ffffff,
430fcf5ef2aSThomas Huth .nwindows = 8,
431fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
432fcf5ef2aSThomas Huth },
433fcf5ef2aSThomas Huth {
4344a7bdec3SThomas Huth .name = "TI-SuperSparc-40", /* STP1020NPGA */
435fcf5ef2aSThomas Huth .iu_version = 0x41000000, /* SuperSPARC 2.x */
43649bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
437fcf5ef2aSThomas Huth .mmu_version = 0x00000800, /* SuperSPARC 2.x, no MXCC */
438fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
439fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
440fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
441fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
442fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
443fcf5ef2aSThomas Huth .nwindows = 8,
444fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
445fcf5ef2aSThomas Huth },
446fcf5ef2aSThomas Huth {
4474a7bdec3SThomas Huth .name = "TI-SuperSparc-50", /* STP1020PGA */
448fcf5ef2aSThomas Huth .iu_version = 0x40000000, /* SuperSPARC 3.x */
44949bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
450fcf5ef2aSThomas Huth .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */
451fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
452fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
453fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
454fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
455fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
456fcf5ef2aSThomas Huth .nwindows = 8,
457fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
458fcf5ef2aSThomas Huth },
459fcf5ef2aSThomas Huth {
4604a7bdec3SThomas Huth .name = "TI-SuperSparc-51",
461fcf5ef2aSThomas Huth .iu_version = 0x40000000, /* SuperSPARC 3.x */
46249bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
463fcf5ef2aSThomas Huth .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */
464fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
465fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
466fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
467fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
468fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
469fcf5ef2aSThomas Huth .mxcc_version = 0x00000104,
470fcf5ef2aSThomas Huth .nwindows = 8,
471fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
472fcf5ef2aSThomas Huth },
473fcf5ef2aSThomas Huth {
4744a7bdec3SThomas Huth .name = "TI-SuperSparc-60", /* STP1020APGA */
475fcf5ef2aSThomas Huth .iu_version = 0x40000000, /* SuperSPARC 3.x */
47649bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
477fcf5ef2aSThomas Huth .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */
478fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
479fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
480fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
481fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
482fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
483fcf5ef2aSThomas Huth .nwindows = 8,
484fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
485fcf5ef2aSThomas Huth },
486fcf5ef2aSThomas Huth {
4874a7bdec3SThomas Huth .name = "TI-SuperSparc-61",
488fcf5ef2aSThomas Huth .iu_version = 0x44000000, /* SuperSPARC 3.x */
48949bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
490fcf5ef2aSThomas Huth .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */
491fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
492fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
493fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
494fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
495fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
496fcf5ef2aSThomas Huth .mxcc_version = 0x00000104,
497fcf5ef2aSThomas Huth .nwindows = 8,
498fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
499fcf5ef2aSThomas Huth },
500fcf5ef2aSThomas Huth {
5014a7bdec3SThomas Huth .name = "TI-SuperSparc-II",
502fcf5ef2aSThomas Huth .iu_version = 0x40000000, /* SuperSPARC II 1.x */
50349bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT,
504fcf5ef2aSThomas Huth .mmu_version = 0x08000000, /* SuperSPARC II 1.x, MXCC */
505fcf5ef2aSThomas Huth .mmu_bm = 0x00002000,
506fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xffffffc0,
507fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000ffff,
508fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
509fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
510fcf5ef2aSThomas Huth .mxcc_version = 0x00000104,
511fcf5ef2aSThomas Huth .nwindows = 8,
512fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES,
513fcf5ef2aSThomas Huth },
514fcf5ef2aSThomas Huth {
515fcf5ef2aSThomas Huth .name = "LEON2",
516fcf5ef2aSThomas Huth .iu_version = 0xf2000000,
51749bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
518fcf5ef2aSThomas Huth .mmu_version = 0xf2000000,
519fcf5ef2aSThomas Huth .mmu_bm = 0x00004000,
520fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0x007ffff0,
521fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x0000003f,
522fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
523fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
524fcf5ef2aSThomas Huth .nwindows = 8,
525fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN,
526fcf5ef2aSThomas Huth },
527fcf5ef2aSThomas Huth {
528fcf5ef2aSThomas Huth .name = "LEON3",
529fcf5ef2aSThomas Huth .iu_version = 0xf3000000,
53049bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */
531fcf5ef2aSThomas Huth .mmu_version = 0xf3000000,
532fcf5ef2aSThomas Huth .mmu_bm = 0x00000000,
533fcf5ef2aSThomas Huth .mmu_ctpr_mask = 0xfffffffc,
534fcf5ef2aSThomas Huth .mmu_cxr_mask = 0x000000ff,
535fcf5ef2aSThomas Huth .mmu_sfsr_mask = 0xffffffff,
536fcf5ef2aSThomas Huth .mmu_trcr_mask = 0xffffffff,
537fcf5ef2aSThomas Huth .nwindows = 8,
538fcf5ef2aSThomas Huth .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN |
539fcf5ef2aSThomas Huth CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN |
540fcf5ef2aSThomas Huth CPU_FEATURE_CASA,
541fcf5ef2aSThomas Huth },
542fcf5ef2aSThomas Huth #endif
543fcf5ef2aSThomas Huth };
544fcf5ef2aSThomas Huth
545de1f5203SRichard Henderson /* This must match sparc_cpu_properties[]. */
546fcf5ef2aSThomas Huth static const char * const feature_name[] = {
547de1f5203SRichard Henderson [CPU_FEATURE_BIT_FLOAT128] = "float128",
548554abe47SRichard Henderson #ifdef TARGET_SPARC64
549de1f5203SRichard Henderson [CPU_FEATURE_BIT_CMT] = "cmt",
550de1f5203SRichard Henderson [CPU_FEATURE_BIT_GL] = "gl",
551554abe47SRichard Henderson [CPU_FEATURE_BIT_HYPV] = "hypv",
552554abe47SRichard Henderson [CPU_FEATURE_BIT_VIS1] = "vis1",
553554abe47SRichard Henderson [CPU_FEATURE_BIT_VIS2] = "vis2",
5544fd71d19SRichard Henderson [CPU_FEATURE_BIT_FMAF] = "fmaf",
555deadbb14SRichard Henderson [CPU_FEATURE_BIT_VIS3] = "vis3",
55668a414e9SRichard Henderson [CPU_FEATURE_BIT_IMA] = "ima",
557b12b7227SRichard Henderson [CPU_FEATURE_BIT_VIS4] = "vis4",
558554abe47SRichard Henderson #else
559554abe47SRichard Henderson [CPU_FEATURE_BIT_MUL] = "mul",
560554abe47SRichard Henderson [CPU_FEATURE_BIT_DIV] = "div",
561554abe47SRichard Henderson [CPU_FEATURE_BIT_FSMULD] = "fsmuld",
562554abe47SRichard Henderson #endif
563fcf5ef2aSThomas Huth };
564fcf5ef2aSThomas Huth
print_features(uint32_t features,const char * prefix)5650442428aSMarkus Armbruster static void print_features(uint32_t features, const char *prefix)
566fcf5ef2aSThomas Huth {
567fcf5ef2aSThomas Huth unsigned int i;
568fcf5ef2aSThomas Huth
569fcf5ef2aSThomas Huth for (i = 0; i < ARRAY_SIZE(feature_name); i++) {
570fcf5ef2aSThomas Huth if (feature_name[i] && (features & (1 << i))) {
571fcf5ef2aSThomas Huth if (prefix) {
5720442428aSMarkus Armbruster qemu_printf("%s", prefix);
573fcf5ef2aSThomas Huth }
5740442428aSMarkus Armbruster qemu_printf("%s ", feature_name[i]);
575fcf5ef2aSThomas Huth }
576fcf5ef2aSThomas Huth }
577fcf5ef2aSThomas Huth }
578fcf5ef2aSThomas Huth
sparc_cpu_list(void)5790442428aSMarkus Armbruster void sparc_cpu_list(void)
580fcf5ef2aSThomas Huth {
581fcf5ef2aSThomas Huth unsigned int i;
582fcf5ef2aSThomas Huth
58347833f81SThomas Huth qemu_printf("Available CPU types:\n");
584fcf5ef2aSThomas Huth for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
58547833f81SThomas Huth qemu_printf(" %-20s (IU " TARGET_FMT_lx
58647833f81SThomas Huth " FPU %08x MMU %08x NWINS %d) ",
587fcf5ef2aSThomas Huth sparc_defs[i].name,
588fcf5ef2aSThomas Huth sparc_defs[i].iu_version,
589fcf5ef2aSThomas Huth sparc_defs[i].fpu_version,
590fcf5ef2aSThomas Huth sparc_defs[i].mmu_version,
591fcf5ef2aSThomas Huth sparc_defs[i].nwindows);
5920442428aSMarkus Armbruster print_features(CPU_DEFAULT_FEATURES & ~sparc_defs[i].features, "-");
5930442428aSMarkus Armbruster print_features(~CPU_DEFAULT_FEATURES & sparc_defs[i].features, "+");
5940442428aSMarkus Armbruster qemu_printf("\n");
595fcf5ef2aSThomas Huth }
5960442428aSMarkus Armbruster qemu_printf("Default CPU feature flags (use '-' to remove): ");
5970442428aSMarkus Armbruster print_features(CPU_DEFAULT_FEATURES, NULL);
5980442428aSMarkus Armbruster qemu_printf("\n");
5990442428aSMarkus Armbruster qemu_printf("Available CPU feature flags (use '+' to add): ");
6000442428aSMarkus Armbruster print_features(~CPU_DEFAULT_FEATURES, NULL);
6010442428aSMarkus Armbruster qemu_printf("\n");
6020442428aSMarkus Armbruster qemu_printf("Numerical features (use '=' to set): iu_version "
603fcf5ef2aSThomas Huth "fpu_version mmu_version nwindows\n");
604fcf5ef2aSThomas Huth }
605fcf5ef2aSThomas Huth
cpu_print_cc(FILE * f,uint32_t cc)60690c84c56SMarkus Armbruster static void cpu_print_cc(FILE *f, uint32_t cc)
607fcf5ef2aSThomas Huth {
60890c84c56SMarkus Armbruster qemu_fprintf(f, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-',
609fcf5ef2aSThomas Huth cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' : '-',
610fcf5ef2aSThomas Huth cc & PSR_CARRY ? 'C' : '-');
611fcf5ef2aSThomas Huth }
612fcf5ef2aSThomas Huth
613fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
614fcf5ef2aSThomas Huth #define REGS_PER_LINE 4
615fcf5ef2aSThomas Huth #else
616fcf5ef2aSThomas Huth #define REGS_PER_LINE 8
617fcf5ef2aSThomas Huth #endif
618fcf5ef2aSThomas Huth
sparc_cpu_dump_state(CPUState * cs,FILE * f,int flags)6199ac200acSPhilippe Mathieu-Daudé static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags)
620fcf5ef2aSThomas Huth {
62177976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs);
622fcf5ef2aSThomas Huth int i, x;
623fcf5ef2aSThomas Huth
62490c84c56SMarkus Armbruster qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc,
625fcf5ef2aSThomas Huth env->npc);
626fcf5ef2aSThomas Huth
627fcf5ef2aSThomas Huth for (i = 0; i < 8; i++) {
628fcf5ef2aSThomas Huth if (i % REGS_PER_LINE == 0) {
62990c84c56SMarkus Armbruster qemu_fprintf(f, "%%g%d-%d:", i, i + REGS_PER_LINE - 1);
630fcf5ef2aSThomas Huth }
63190c84c56SMarkus Armbruster qemu_fprintf(f, " " TARGET_FMT_lx, env->gregs[i]);
632fcf5ef2aSThomas Huth if (i % REGS_PER_LINE == REGS_PER_LINE - 1) {
63390c84c56SMarkus Armbruster qemu_fprintf(f, "\n");
634fcf5ef2aSThomas Huth }
635fcf5ef2aSThomas Huth }
636fcf5ef2aSThomas Huth for (x = 0; x < 3; x++) {
637fcf5ef2aSThomas Huth for (i = 0; i < 8; i++) {
638fcf5ef2aSThomas Huth if (i % REGS_PER_LINE == 0) {
63990c84c56SMarkus Armbruster qemu_fprintf(f, "%%%c%d-%d: ",
640fcf5ef2aSThomas Huth x == 0 ? 'o' : (x == 1 ? 'l' : 'i'),
641fcf5ef2aSThomas Huth i, i + REGS_PER_LINE - 1);
642fcf5ef2aSThomas Huth }
64390c84c56SMarkus Armbruster qemu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]);
644fcf5ef2aSThomas Huth if (i % REGS_PER_LINE == REGS_PER_LINE - 1) {
64590c84c56SMarkus Armbruster qemu_fprintf(f, "\n");
646fcf5ef2aSThomas Huth }
647fcf5ef2aSThomas Huth }
648fcf5ef2aSThomas Huth }
649fcf5ef2aSThomas Huth
650d13c394cSRichard Henderson if (flags & CPU_DUMP_FPU) {
651fcf5ef2aSThomas Huth for (i = 0; i < TARGET_DPREGS; i++) {
652fcf5ef2aSThomas Huth if ((i & 3) == 0) {
65390c84c56SMarkus Armbruster qemu_fprintf(f, "%%f%02d: ", i * 2);
654fcf5ef2aSThomas Huth }
65590c84c56SMarkus Armbruster qemu_fprintf(f, " %016" PRIx64, env->fpr[i].ll);
656fcf5ef2aSThomas Huth if ((i & 3) == 3) {
65790c84c56SMarkus Armbruster qemu_fprintf(f, "\n");
658fcf5ef2aSThomas Huth }
659fcf5ef2aSThomas Huth }
660d13c394cSRichard Henderson }
661d13c394cSRichard Henderson
662fcf5ef2aSThomas Huth #ifdef TARGET_SPARC64
66390c84c56SMarkus Armbruster qemu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate,
664fcf5ef2aSThomas Huth (unsigned)cpu_get_ccr(env));
66590c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_ccr(env) << PSR_CARRY_SHIFT);
66690c84c56SMarkus Armbruster qemu_fprintf(f, " xcc: ");
66790c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4));
66890c84c56SMarkus Armbruster qemu_fprintf(f, ") asi: %02x tl: %d pil: %x gl: %d\n", env->asi, env->tl,
669cbc3a6a4SArtyom Tarasenko env->psrpil, env->gl);
67090c84c56SMarkus Armbruster qemu_fprintf(f, "tbr: " TARGET_FMT_lx " hpstate: " TARGET_FMT_lx " htba: "
671cbc3a6a4SArtyom Tarasenko TARGET_FMT_lx "\n", env->tbr, env->hpstate, env->htba);
67290c84c56SMarkus Armbruster qemu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate: %d "
673fcf5ef2aSThomas Huth "cleanwin: %d cwp: %d\n",
674fcf5ef2aSThomas Huth env->cansave, env->canrestore, env->otherwin, env->wstate,
675fcf5ef2aSThomas Huth env->cleanwin, env->nwindows - 1 - env->cwp);
676ca4d5d86SPeter Maydell qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: %016x\n",
6771ccd6e13SRichard Henderson cpu_get_fsr(env), env->y, env->fprs);
678cbc3a6a4SArtyom Tarasenko
679fcf5ef2aSThomas Huth #else
68090c84c56SMarkus Armbruster qemu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env));
68190c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_psr(env));
68290c84c56SMarkus Armbruster qemu_fprintf(f, " SPE: %c%c%c) wim: %08x\n", env->psrs ? 'S' : '-',
683fcf5ef2aSThomas Huth env->psrps ? 'P' : '-', env->psret ? 'E' : '-',
684fcf5ef2aSThomas Huth env->wim);
68590c84c56SMarkus Armbruster qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx "\n",
6861ccd6e13SRichard Henderson cpu_get_fsr(env), env->y);
687fcf5ef2aSThomas Huth #endif
68890c84c56SMarkus Armbruster qemu_fprintf(f, "\n");
689fcf5ef2aSThomas Huth }
690fcf5ef2aSThomas Huth
sparc_cpu_set_pc(CPUState * cs,vaddr value)691fcf5ef2aSThomas Huth static void sparc_cpu_set_pc(CPUState *cs, vaddr value)
692fcf5ef2aSThomas Huth {
693fcf5ef2aSThomas Huth SPARCCPU *cpu = SPARC_CPU(cs);
694fcf5ef2aSThomas Huth
695fcf5ef2aSThomas Huth cpu->env.pc = value;
696fcf5ef2aSThomas Huth cpu->env.npc = value + 4;
697fcf5ef2aSThomas Huth }
698fcf5ef2aSThomas Huth
sparc_cpu_get_pc(CPUState * cs)699e4fdf9dfSRichard Henderson static vaddr sparc_cpu_get_pc(CPUState *cs)
700e4fdf9dfSRichard Henderson {
701e4fdf9dfSRichard Henderson SPARCCPU *cpu = SPARC_CPU(cs);
702e4fdf9dfSRichard Henderson
703e4fdf9dfSRichard Henderson return cpu->env.pc;
704e4fdf9dfSRichard Henderson }
705e4fdf9dfSRichard Henderson
sparc_cpu_synchronize_from_tb(CPUState * cs,const TranslationBlock * tb)70604a37d4cSRichard Henderson static void sparc_cpu_synchronize_from_tb(CPUState *cs,
70704a37d4cSRichard Henderson const TranslationBlock *tb)
708fcf5ef2aSThomas Huth {
709fcf5ef2aSThomas Huth SPARCCPU *cpu = SPARC_CPU(cs);
710fcf5ef2aSThomas Huth
711b254c342SPhilippe Mathieu-Daudé tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL));
712c4bf3a92SAnton Johansson cpu->env.pc = tb->pc;
713fcf5ef2aSThomas Huth cpu->env.npc = tb->cs_base;
714fcf5ef2aSThomas Huth }
715fcf5ef2aSThomas Huth
sparc_cpu_has_work(CPUState * cs)716fcf5ef2aSThomas Huth static bool sparc_cpu_has_work(CPUState *cs)
717fcf5ef2aSThomas Huth {
718fcf5ef2aSThomas Huth return (cs->interrupt_request & CPU_INTERRUPT_HARD) &&
71977976769SPhilippe Mathieu-Daudé cpu_interrupts_enabled(cpu_env(cs));
720fcf5ef2aSThomas Huth }
721fcf5ef2aSThomas Huth
sparc_cpu_mmu_index(CPUState * cs,bool ifetch)722a120d320SRichard Henderson static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch)
723e3547a7dSRichard Henderson {
724e3547a7dSRichard Henderson CPUSPARCState *env = cpu_env(cs);
725e3547a7dSRichard Henderson
726e3547a7dSRichard Henderson #ifndef TARGET_SPARC64
727e3547a7dSRichard Henderson if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */
728e3547a7dSRichard Henderson return MMU_PHYS_IDX;
729e3547a7dSRichard Henderson } else {
730e3547a7dSRichard Henderson return env->psrs;
731e3547a7dSRichard Henderson }
732e3547a7dSRichard Henderson #else
733e3547a7dSRichard Henderson /* IMMU or DMMU disabled. */
734e3547a7dSRichard Henderson if (ifetch
735e3547a7dSRichard Henderson ? (env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0
736e3547a7dSRichard Henderson : (env->lsu & DMMU_E) == 0) {
737e3547a7dSRichard Henderson return MMU_PHYS_IDX;
738e3547a7dSRichard Henderson } else if (cpu_hypervisor_mode(env)) {
739e3547a7dSRichard Henderson return MMU_PHYS_IDX;
740e3547a7dSRichard Henderson } else if (env->tl > 0) {
741e3547a7dSRichard Henderson return MMU_NUCLEUS_IDX;
742e3547a7dSRichard Henderson } else if (cpu_supervisor_mode(env)) {
743e3547a7dSRichard Henderson return MMU_KERNEL_IDX;
744e3547a7dSRichard Henderson } else {
745e3547a7dSRichard Henderson return MMU_USER_IDX;
746e3547a7dSRichard Henderson }
747e3547a7dSRichard Henderson #endif
748e3547a7dSRichard Henderson }
749e3547a7dSRichard Henderson
sparc_cpu_type_name(const char * cpu_model)75012a6c15eSIgor Mammedov static char *sparc_cpu_type_name(const char *cpu_model)
75112a6c15eSIgor Mammedov {
7521d4bfc54SIgor Mammedov char *name = g_strdup_printf(SPARC_CPU_TYPE_NAME("%s"), cpu_model);
75312a6c15eSIgor Mammedov char *s = name;
75412a6c15eSIgor Mammedov
75512a6c15eSIgor Mammedov /* SPARC cpu model names happen to have whitespaces,
75612a6c15eSIgor Mammedov * as type names shouldn't have spaces replace them with '-'
75712a6c15eSIgor Mammedov */
75812a6c15eSIgor Mammedov while ((s = strchr(s, ' '))) {
75912a6c15eSIgor Mammedov *s = '-';
76012a6c15eSIgor Mammedov }
76112a6c15eSIgor Mammedov
76212a6c15eSIgor Mammedov return name;
76312a6c15eSIgor Mammedov }
76412a6c15eSIgor Mammedov
sparc_cpu_class_by_name(const char * cpu_model)76512a6c15eSIgor Mammedov static ObjectClass *sparc_cpu_class_by_name(const char *cpu_model)
76612a6c15eSIgor Mammedov {
76712a6c15eSIgor Mammedov ObjectClass *oc;
76812a6c15eSIgor Mammedov char *typename;
76912a6c15eSIgor Mammedov
77012a6c15eSIgor Mammedov typename = sparc_cpu_type_name(cpu_model);
7716b568e3fSThomas Huth
7726b568e3fSThomas Huth /* Fix up legacy names with '+' in it */
7736b568e3fSThomas Huth if (g_str_equal(typename, SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IV+"))) {
7746b568e3fSThomas Huth g_free(typename);
7756b568e3fSThomas Huth typename = g_strdup(SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IV-plus"));
7766b568e3fSThomas Huth } else if (g_str_equal(typename, SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IIIi+"))) {
7776b568e3fSThomas Huth g_free(typename);
7786b568e3fSThomas Huth typename = g_strdup(SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IIIi-plus"));
7796b568e3fSThomas Huth }
7806b568e3fSThomas Huth
78112a6c15eSIgor Mammedov oc = object_class_by_name(typename);
78212a6c15eSIgor Mammedov g_free(typename);
78312a6c15eSIgor Mammedov return oc;
78412a6c15eSIgor Mammedov }
78512a6c15eSIgor Mammedov
sparc_cpu_realizefn(DeviceState * dev,Error ** errp)786fcf5ef2aSThomas Huth static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
787fcf5ef2aSThomas Huth {
788fcf5ef2aSThomas Huth CPUState *cs = CPU(dev);
789fcf5ef2aSThomas Huth SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev);
790fcf5ef2aSThomas Huth Error *local_err = NULL;
79177976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs);
792fcf5ef2aSThomas Huth
79370054962SIgor Mammedov #if defined(CONFIG_USER_ONLY)
7945f25b383SRichard Henderson /* We are emulating the kernel, which will trap and emulate float128. */
795576e1c4cSIgor Mammedov env->def.features |= CPU_FEATURE_FLOAT128;
796fcf5ef2aSThomas Huth #endif
797fcf5ef2aSThomas Huth
79870054962SIgor Mammedov env->version = env->def.iu_version;
79970054962SIgor Mammedov env->nwindows = env->def.nwindows;
80070054962SIgor Mammedov #if !defined(TARGET_SPARC64)
80170054962SIgor Mammedov env->mmuregs[0] |= env->def.mmu_version;
80270054962SIgor Mammedov cpu_sparc_set_id(env, 0);
80370054962SIgor Mammedov env->mxccregs[7] |= env->def.mxcc_version;
80470054962SIgor Mammedov #else
80570054962SIgor Mammedov env->mmu_version = env->def.mmu_version;
80670054962SIgor Mammedov env->maxtl = env->def.maxtl;
80770054962SIgor Mammedov env->version |= env->def.maxtl << 8;
80870054962SIgor Mammedov env->version |= env->def.nwindows - 1;
80970054962SIgor Mammedov #endif
81070054962SIgor Mammedov
811*4482f32dSPeter Maydell /*
812*4482f32dSPeter Maydell * Prefer SNaN over QNaN, order B then A. It's OK to do this in realize
813*4482f32dSPeter Maydell * rather than reset, because fp_status is after 'end_reset_fields' in
814*4482f32dSPeter Maydell * the CPU state struct so it won't get zeroed on reset.
815*4482f32dSPeter Maydell */
816*4482f32dSPeter Maydell set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
817*4482f32dSPeter Maydell
818fcf5ef2aSThomas Huth cpu_exec_realizefn(cs, &local_err);
819fcf5ef2aSThomas Huth if (local_err != NULL) {
820fcf5ef2aSThomas Huth error_propagate(errp, local_err);
821fcf5ef2aSThomas Huth return;
822fcf5ef2aSThomas Huth }
823fcf5ef2aSThomas Huth
824fcf5ef2aSThomas Huth qemu_init_vcpu(cs);
825fcf5ef2aSThomas Huth
826fcf5ef2aSThomas Huth scc->parent_realize(dev, errp);
827fcf5ef2aSThomas Huth }
828fcf5ef2aSThomas Huth
sparc_cpu_initfn(Object * obj)829fcf5ef2aSThomas Huth static void sparc_cpu_initfn(Object *obj)
830fcf5ef2aSThomas Huth {
831fcf5ef2aSThomas Huth SPARCCPU *cpu = SPARC_CPU(obj);
83212a6c15eSIgor Mammedov SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj);
833fcf5ef2aSThomas Huth CPUSPARCState *env = &cpu->env;
834fcf5ef2aSThomas Huth
835576e1c4cSIgor Mammedov if (scc->cpu_def) {
836576e1c4cSIgor Mammedov env->def = *scc->cpu_def;
837fcf5ef2aSThomas Huth }
838fcf5ef2aSThomas Huth }
839fcf5ef2aSThomas Huth
sparc_get_nwindows(Object * obj,Visitor * v,const char * name,void * opaque,Error ** errp)840de05005bSIgor Mammedov static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name,
841de05005bSIgor Mammedov void *opaque, Error **errp)
842de05005bSIgor Mammedov {
843de05005bSIgor Mammedov SPARCCPU *cpu = SPARC_CPU(obj);
844de05005bSIgor Mammedov int64_t value = cpu->env.def.nwindows;
845de05005bSIgor Mammedov
846de05005bSIgor Mammedov visit_type_int(v, name, &value, errp);
847de05005bSIgor Mammedov }
848de05005bSIgor Mammedov
sparc_set_nwindows(Object * obj,Visitor * v,const char * name,void * opaque,Error ** errp)849de05005bSIgor Mammedov static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name,
850de05005bSIgor Mammedov void *opaque, Error **errp)
851de05005bSIgor Mammedov {
852de05005bSIgor Mammedov const int64_t min = MIN_NWINDOWS;
853de05005bSIgor Mammedov const int64_t max = MAX_NWINDOWS;
854de05005bSIgor Mammedov SPARCCPU *cpu = SPARC_CPU(obj);
855de05005bSIgor Mammedov int64_t value;
856de05005bSIgor Mammedov
857668f62ecSMarkus Armbruster if (!visit_type_int(v, name, &value, errp)) {
858de05005bSIgor Mammedov return;
859de05005bSIgor Mammedov }
860de05005bSIgor Mammedov
861de05005bSIgor Mammedov if (value < min || value > max) {
862de05005bSIgor Mammedov error_setg(errp, "Property %s.%s doesn't take value %" PRId64
863de05005bSIgor Mammedov " (minimum: %" PRId64 ", maximum: %" PRId64 ")",
864de05005bSIgor Mammedov object_get_typename(obj), name ? name : "null",
865de05005bSIgor Mammedov value, min, max);
866de05005bSIgor Mammedov return;
867de05005bSIgor Mammedov }
868de05005bSIgor Mammedov cpu->env.def.nwindows = value;
869de05005bSIgor Mammedov }
870de05005bSIgor Mammedov
871de05005bSIgor Mammedov static PropertyInfo qdev_prop_nwindows = {
872de05005bSIgor Mammedov .name = "int",
873de05005bSIgor Mammedov .get = sparc_get_nwindows,
874de05005bSIgor Mammedov .set = sparc_set_nwindows,
875de05005bSIgor Mammedov };
876de05005bSIgor Mammedov
877de1f5203SRichard Henderson /* This must match feature_name[]. */
878de05005bSIgor Mammedov static Property sparc_cpu_properties[] = {
879de1f5203SRichard Henderson DEFINE_PROP_BIT("float128", SPARCCPU, env.def.features,
880de1f5203SRichard Henderson CPU_FEATURE_BIT_FLOAT128, false),
881554abe47SRichard Henderson #ifdef TARGET_SPARC64
882de1f5203SRichard Henderson DEFINE_PROP_BIT("cmt", SPARCCPU, env.def.features,
883de1f5203SRichard Henderson CPU_FEATURE_BIT_CMT, false),
884de1f5203SRichard Henderson DEFINE_PROP_BIT("gl", SPARCCPU, env.def.features,
885de1f5203SRichard Henderson CPU_FEATURE_BIT_GL, false),
886554abe47SRichard Henderson DEFINE_PROP_BIT("hypv", SPARCCPU, env.def.features,
887554abe47SRichard Henderson CPU_FEATURE_BIT_HYPV, false),
888554abe47SRichard Henderson DEFINE_PROP_BIT("vis1", SPARCCPU, env.def.features,
889554abe47SRichard Henderson CPU_FEATURE_BIT_VIS1, false),
890554abe47SRichard Henderson DEFINE_PROP_BIT("vis2", SPARCCPU, env.def.features,
891554abe47SRichard Henderson CPU_FEATURE_BIT_VIS2, false),
8924fd71d19SRichard Henderson DEFINE_PROP_BIT("fmaf", SPARCCPU, env.def.features,
8934fd71d19SRichard Henderson CPU_FEATURE_BIT_FMAF, false),
894deadbb14SRichard Henderson DEFINE_PROP_BIT("vis3", SPARCCPU, env.def.features,
895deadbb14SRichard Henderson CPU_FEATURE_BIT_VIS3, false),
89668a414e9SRichard Henderson DEFINE_PROP_BIT("ima", SPARCCPU, env.def.features,
89768a414e9SRichard Henderson CPU_FEATURE_BIT_IMA, false),
898b12b7227SRichard Henderson DEFINE_PROP_BIT("vis4", SPARCCPU, env.def.features,
899b12b7227SRichard Henderson CPU_FEATURE_BIT_VIS4, false),
900554abe47SRichard Henderson #else
901554abe47SRichard Henderson DEFINE_PROP_BIT("mul", SPARCCPU, env.def.features,
902554abe47SRichard Henderson CPU_FEATURE_BIT_MUL, false),
903554abe47SRichard Henderson DEFINE_PROP_BIT("div", SPARCCPU, env.def.features,
904554abe47SRichard Henderson CPU_FEATURE_BIT_DIV, false),
905554abe47SRichard Henderson DEFINE_PROP_BIT("fsmuld", SPARCCPU, env.def.features,
906554abe47SRichard Henderson CPU_FEATURE_BIT_FSMULD, false),
907554abe47SRichard Henderson #endif
908de05005bSIgor Mammedov DEFINE_PROP_UNSIGNED("iu-version", SPARCCPU, env.def.iu_version, 0,
909de05005bSIgor Mammedov qdev_prop_uint64, target_ulong),
910de05005bSIgor Mammedov DEFINE_PROP_UINT32("fpu-version", SPARCCPU, env.def.fpu_version, 0),
911de05005bSIgor Mammedov DEFINE_PROP_UINT32("mmu-version", SPARCCPU, env.def.mmu_version, 0),
91243b6ab4cSEduardo Habkost DEFINE_PROP("nwindows", SPARCCPU, env.def.nwindows,
91343b6ab4cSEduardo Habkost qdev_prop_nwindows, uint32_t),
914de05005bSIgor Mammedov DEFINE_PROP_END_OF_LIST()
915de05005bSIgor Mammedov };
916de05005bSIgor Mammedov
9178b80bd28SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY
9188b80bd28SPhilippe Mathieu-Daudé #include "hw/core/sysemu-cpu-ops.h"
9198b80bd28SPhilippe Mathieu-Daudé
9208b80bd28SPhilippe Mathieu-Daudé static const struct SysemuCPUOps sparc_sysemu_ops = {
92108928c6dSPhilippe Mathieu-Daudé .get_phys_page_debug = sparc_cpu_get_phys_page_debug,
922feece4d0SPhilippe Mathieu-Daudé .legacy_vmsd = &vmstate_sparc_cpu,
9238b80bd28SPhilippe Mathieu-Daudé };
9248b80bd28SPhilippe Mathieu-Daudé #endif
9258b80bd28SPhilippe Mathieu-Daudé
92678271684SClaudio Fontana #ifdef CONFIG_TCG
92778271684SClaudio Fontana #include "hw/core/tcg-cpu-ops.h"
92878271684SClaudio Fontana
9291764ad70SRichard Henderson static const TCGCPUOps sparc_tcg_ops = {
93078271684SClaudio Fontana .initialize = sparc_tcg_init,
93178271684SClaudio Fontana .synchronize_from_tb = sparc_cpu_synchronize_from_tb,
932f36aaa53SRichard Henderson .restore_state_to_opc = sparc_restore_state_to_opc,
93378271684SClaudio Fontana
93478271684SClaudio Fontana #ifndef CONFIG_USER_ONLY
935caac44a5SRichard Henderson .tlb_fill = sparc_cpu_tlb_fill,
936798ac8b5SPhilippe Mathieu-Daudé .cpu_exec_interrupt = sparc_cpu_exec_interrupt,
9374f7b1ecbSPeter Maydell .cpu_exec_halt = sparc_cpu_has_work,
93878271684SClaudio Fontana .do_interrupt = sparc_cpu_do_interrupt,
93978271684SClaudio Fontana .do_transaction_failed = sparc_cpu_do_transaction_failed,
94078271684SClaudio Fontana .do_unaligned_access = sparc_cpu_do_unaligned_access,
94178271684SClaudio Fontana #endif /* !CONFIG_USER_ONLY */
94278271684SClaudio Fontana };
94378271684SClaudio Fontana #endif /* CONFIG_TCG */
94478271684SClaudio Fontana
sparc_cpu_class_init(ObjectClass * oc,void * data)945fcf5ef2aSThomas Huth static void sparc_cpu_class_init(ObjectClass *oc, void *data)
946fcf5ef2aSThomas Huth {
947fcf5ef2aSThomas Huth SPARCCPUClass *scc = SPARC_CPU_CLASS(oc);
948fcf5ef2aSThomas Huth CPUClass *cc = CPU_CLASS(oc);
949fcf5ef2aSThomas Huth DeviceClass *dc = DEVICE_CLASS(oc);
9503b4fff1bSPeter Maydell ResettableClass *rc = RESETTABLE_CLASS(oc);
951fcf5ef2aSThomas Huth
952bf853881SPhilippe Mathieu-Daudé device_class_set_parent_realize(dc, sparc_cpu_realizefn,
953bf853881SPhilippe Mathieu-Daudé &scc->parent_realize);
9544f67d30bSMarc-André Lureau device_class_set_props(dc, sparc_cpu_properties);
955fcf5ef2aSThomas Huth
9563b4fff1bSPeter Maydell resettable_class_set_parent_phases(rc, NULL, sparc_cpu_reset_hold, NULL,
9573b4fff1bSPeter Maydell &scc->parent_phases);
958fcf5ef2aSThomas Huth
95912a6c15eSIgor Mammedov cc->class_by_name = sparc_cpu_class_by_name;
960d1853231SIgor Mammedov cc->parse_features = sparc_cpu_parse_features;
961fcf5ef2aSThomas Huth cc->has_work = sparc_cpu_has_work;
962e3547a7dSRichard Henderson cc->mmu_index = sparc_cpu_mmu_index;
963fcf5ef2aSThomas Huth cc->dump_state = sparc_cpu_dump_state;
964fcf5ef2aSThomas Huth #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
965fcf5ef2aSThomas Huth cc->memory_rw_debug = sparc_cpu_memory_rw_debug;
966fcf5ef2aSThomas Huth #endif
967fcf5ef2aSThomas Huth cc->set_pc = sparc_cpu_set_pc;
968e4fdf9dfSRichard Henderson cc->get_pc = sparc_cpu_get_pc;
969fcf5ef2aSThomas Huth cc->gdb_read_register = sparc_cpu_gdb_read_register;
970fcf5ef2aSThomas Huth cc->gdb_write_register = sparc_cpu_gdb_write_register;
971e84942f2SRichard Henderson #ifndef CONFIG_USER_ONLY
9728b80bd28SPhilippe Mathieu-Daudé cc->sysemu_ops = &sparc_sysemu_ops;
973fcf5ef2aSThomas Huth #endif
974fcf5ef2aSThomas Huth cc->disas_set_info = cpu_sparc_disas_set_info;
975fcf5ef2aSThomas Huth
976fcf5ef2aSThomas Huth #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
977fcf5ef2aSThomas Huth cc->gdb_num_core_regs = 86;
978fcf5ef2aSThomas Huth #else
979fcf5ef2aSThomas Huth cc->gdb_num_core_regs = 72;
980fcf5ef2aSThomas Huth #endif
98178271684SClaudio Fontana cc->tcg_ops = &sparc_tcg_ops;
982fcf5ef2aSThomas Huth }
983fcf5ef2aSThomas Huth
984fcf5ef2aSThomas Huth static const TypeInfo sparc_cpu_type_info = {
985fcf5ef2aSThomas Huth .name = TYPE_SPARC_CPU,
986fcf5ef2aSThomas Huth .parent = TYPE_CPU,
987fcf5ef2aSThomas Huth .instance_size = sizeof(SPARCCPU),
988f669c992SRichard Henderson .instance_align = __alignof(SPARCCPU),
989fcf5ef2aSThomas Huth .instance_init = sparc_cpu_initfn,
99012a6c15eSIgor Mammedov .abstract = true,
991fcf5ef2aSThomas Huth .class_size = sizeof(SPARCCPUClass),
992fcf5ef2aSThomas Huth .class_init = sparc_cpu_class_init,
993fcf5ef2aSThomas Huth };
994fcf5ef2aSThomas Huth
sparc_cpu_cpudef_class_init(ObjectClass * oc,void * data)99512a6c15eSIgor Mammedov static void sparc_cpu_cpudef_class_init(ObjectClass *oc, void *data)
99612a6c15eSIgor Mammedov {
99712a6c15eSIgor Mammedov SPARCCPUClass *scc = SPARC_CPU_CLASS(oc);
99812a6c15eSIgor Mammedov scc->cpu_def = data;
99912a6c15eSIgor Mammedov }
100012a6c15eSIgor Mammedov
sparc_register_cpudef_type(const struct sparc_def_t * def)100112a6c15eSIgor Mammedov static void sparc_register_cpudef_type(const struct sparc_def_t *def)
100212a6c15eSIgor Mammedov {
100312a6c15eSIgor Mammedov char *typename = sparc_cpu_type_name(def->name);
100412a6c15eSIgor Mammedov TypeInfo ti = {
100512a6c15eSIgor Mammedov .name = typename,
100612a6c15eSIgor Mammedov .parent = TYPE_SPARC_CPU,
100712a6c15eSIgor Mammedov .class_init = sparc_cpu_cpudef_class_init,
100812a6c15eSIgor Mammedov .class_data = (void *)def,
100912a6c15eSIgor Mammedov };
101012a6c15eSIgor Mammedov
101112a6c15eSIgor Mammedov type_register(&ti);
101212a6c15eSIgor Mammedov g_free(typename);
101312a6c15eSIgor Mammedov }
101412a6c15eSIgor Mammedov
sparc_cpu_register_types(void)1015fcf5ef2aSThomas Huth static void sparc_cpu_register_types(void)
1016fcf5ef2aSThomas Huth {
101712a6c15eSIgor Mammedov int i;
101812a6c15eSIgor Mammedov
1019fcf5ef2aSThomas Huth type_register_static(&sparc_cpu_type_info);
102012a6c15eSIgor Mammedov for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) {
102112a6c15eSIgor Mammedov sparc_register_cpudef_type(&sparc_defs[i]);
102212a6c15eSIgor Mammedov }
1023fcf5ef2aSThomas Huth }
1024fcf5ef2aSThomas Huth
1025fcf5ef2aSThomas Huth type_init(sparc_cpu_register_types)
1026