1ab3b491fSBlue Swirl /* 2ab3b491fSBlue Swirl * Sparc CPU init helpers 3ab3b491fSBlue Swirl * 4ab3b491fSBlue Swirl * Copyright (c) 2003-2005 Fabrice Bellard 5ab3b491fSBlue Swirl * 6ab3b491fSBlue Swirl * This library is free software; you can redistribute it and/or 7ab3b491fSBlue Swirl * modify it under the terms of the GNU Lesser General Public 8ab3b491fSBlue Swirl * License as published by the Free Software Foundation; either 95650b549SChetan Pant * version 2.1 of the License, or (at your option) any later version. 10ab3b491fSBlue Swirl * 11ab3b491fSBlue Swirl * This library is distributed in the hope that it will be useful, 12ab3b491fSBlue Swirl * but WITHOUT ANY WARRANTY; without even the implied warranty of 13ab3b491fSBlue Swirl * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14ab3b491fSBlue Swirl * Lesser General Public License for more details. 15ab3b491fSBlue Swirl * 16ab3b491fSBlue Swirl * You should have received a copy of the GNU Lesser General Public 17ab3b491fSBlue Swirl * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18ab3b491fSBlue Swirl */ 19ab3b491fSBlue Swirl 20db5ebe5fSPeter Maydell #include "qemu/osdep.h" 21da34e65cSMarkus Armbruster #include "qapi/error.h" 22ab3b491fSBlue Swirl #include "cpu.h" 230b8fa32fSMarkus Armbruster #include "qemu/module.h" 240442428aSMarkus Armbruster #include "qemu/qemu-print.h" 2563c91552SPaolo Bonzini #include "exec/exec-all.h" 26de05005bSIgor Mammedov #include "hw/qdev-properties.h" 27de05005bSIgor Mammedov #include "qapi/visitor.h" 28c4bf3a92SAnton Johansson #include "tcg/tcg.h" 29ab3b491fSBlue Swirl 30ab3b491fSBlue Swirl //#define DEBUG_FEATURES 31ab3b491fSBlue Swirl 32ad80e367SPeter Maydell static void sparc_cpu_reset_hold(Object *obj, ResetType type) 33ab7ab3d7SAndreas Färber { 34348802b5SPhilippe Mathieu-Daudé CPUState *cs = CPU(obj); 35348802b5SPhilippe Mathieu-Daudé SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); 3677976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs); 37ab7ab3d7SAndreas Färber 383b4fff1bSPeter Maydell if (scc->parent_phases.hold) { 39ad80e367SPeter Maydell scc->parent_phases.hold(obj, type); 403b4fff1bSPeter Maydell } 41ab7ab3d7SAndreas Färber 421f5c00cfSAlex Bennée memset(env, 0, offsetof(CPUSPARCState, end_reset_fields)); 43ab3b491fSBlue Swirl env->cwp = 0; 44ab3b491fSBlue Swirl #ifndef TARGET_SPARC64 45ab3b491fSBlue Swirl env->wim = 1; 46ab3b491fSBlue Swirl #endif 47ab3b491fSBlue Swirl env->regwptr = env->regbase + (env->cwp * 16); 48ab3b491fSBlue Swirl #if defined(CONFIG_USER_ONLY) 49ab3b491fSBlue Swirl #ifdef TARGET_SPARC64 50ab3b491fSBlue Swirl env->cleanwin = env->nwindows - 2; 51ab3b491fSBlue Swirl env->cansave = env->nwindows - 2; 52ab3b491fSBlue Swirl env->pstate = PS_RMO | PS_PEF | PS_IE; 53ab3b491fSBlue Swirl env->asi = 0x82; /* Primary no-fault */ 54ab3b491fSBlue Swirl #endif 55ab3b491fSBlue Swirl #else 56ab3b491fSBlue Swirl #if !defined(TARGET_SPARC64) 57ab3b491fSBlue Swirl env->psret = 0; 58ab3b491fSBlue Swirl env->psrs = 1; 59ab3b491fSBlue Swirl env->psrps = 1; 60ab3b491fSBlue Swirl #endif 61ab3b491fSBlue Swirl #ifdef TARGET_SPARC64 62cbc3a6a4SArtyom Tarasenko env->pstate = PS_PRIV | PS_RED | PS_PEF; 63cbc3a6a4SArtyom Tarasenko if (!cpu_has_hypervisor(env)) { 64cbc3a6a4SArtyom Tarasenko env->pstate |= PS_AG; 65cbc3a6a4SArtyom Tarasenko } 66ab3b491fSBlue Swirl env->hpstate = cpu_has_hypervisor(env) ? HS_PRIV : 0; 67ab3b491fSBlue Swirl env->tl = env->maxtl; 68cbc3a6a4SArtyom Tarasenko env->gl = 2; 69ab3b491fSBlue Swirl cpu_tsptr(env)->tt = TT_POWER_ON_RESET; 70ab3b491fSBlue Swirl env->lsu = 0; 71ab3b491fSBlue Swirl #else 72ab3b491fSBlue Swirl env->mmuregs[0] &= ~(MMU_E | MMU_NF); 73576e1c4cSIgor Mammedov env->mmuregs[0] |= env->def.mmu_bm; 74ab3b491fSBlue Swirl #endif 75ab3b491fSBlue Swirl env->pc = 0; 76ab3b491fSBlue Swirl env->npc = env->pc + 4; 77ab3b491fSBlue Swirl #endif 78ab3b491fSBlue Swirl env->cache_control = 0; 79*65c1c039SPeter Maydell cpu_put_fsr(env, 0); 80ab3b491fSBlue Swirl } 81ab3b491fSBlue Swirl 82798ac8b5SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY 8387afe467SRichard Henderson static bool sparc_cpu_exec_interrupt(CPUState *cs, int interrupt_request) 8487afe467SRichard Henderson { 8587afe467SRichard Henderson if (interrupt_request & CPU_INTERRUPT_HARD) { 8677976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs); 8787afe467SRichard Henderson 8887afe467SRichard Henderson if (cpu_interrupts_enabled(env) && env->interrupt_index > 0) { 8987afe467SRichard Henderson int pil = env->interrupt_index & 0xf; 9087afe467SRichard Henderson int type = env->interrupt_index & 0xf0; 9187afe467SRichard Henderson 9287afe467SRichard Henderson if (type != TT_EXTINT || cpu_pil_allowed(env, pil)) { 9387afe467SRichard Henderson cs->exception_index = env->interrupt_index; 9487afe467SRichard Henderson sparc_cpu_do_interrupt(cs); 9587afe467SRichard Henderson return true; 9687afe467SRichard Henderson } 9787afe467SRichard Henderson } 9887afe467SRichard Henderson } 9987afe467SRichard Henderson return false; 10087afe467SRichard Henderson } 101798ac8b5SPhilippe Mathieu-Daudé #endif /* !CONFIG_USER_ONLY */ 10287afe467SRichard Henderson 103df0900ebSPeter Crosthwaite static void cpu_sparc_disas_set_info(CPUState *cpu, disassemble_info *info) 104df0900ebSPeter Crosthwaite { 105df0900ebSPeter Crosthwaite info->print_insn = print_insn_sparc; 106df0900ebSPeter Crosthwaite #ifdef TARGET_SPARC64 107df0900ebSPeter Crosthwaite info->mach = bfd_mach_sparc_v9b; 108df0900ebSPeter Crosthwaite #endif 109df0900ebSPeter Crosthwaite } 110df0900ebSPeter Crosthwaite 111d1853231SIgor Mammedov static void 112d1853231SIgor Mammedov cpu_add_feat_as_prop(const char *typename, const char *name, const char *val) 113ab3b491fSBlue Swirl { 114d1853231SIgor Mammedov GlobalProperty *prop = g_new0(typeof(*prop), 1); 115d1853231SIgor Mammedov prop->driver = typename; 116d1853231SIgor Mammedov prop->property = g_strdup(name); 117d1853231SIgor Mammedov prop->value = g_strdup(val); 118d1853231SIgor Mammedov qdev_prop_register_global(prop); 119433ac7a9SAndreas Färber } 120433ac7a9SAndreas Färber 121d1853231SIgor Mammedov /* Parse "+feature,-feature,feature=foo" CPU feature string */ 122d1853231SIgor Mammedov static void sparc_cpu_parse_features(const char *typename, char *features, 123d1853231SIgor Mammedov Error **errp) 124d1853231SIgor Mammedov { 125d1853231SIgor Mammedov GList *l, *plus_features = NULL, *minus_features = NULL; 126d1853231SIgor Mammedov char *featurestr; /* Single 'key=value" string being parsed */ 127d1853231SIgor Mammedov static bool cpu_globals_initialized; 128d1853231SIgor Mammedov 129d1853231SIgor Mammedov if (cpu_globals_initialized) { 130d1853231SIgor Mammedov return; 131d1853231SIgor Mammedov } 132d1853231SIgor Mammedov cpu_globals_initialized = true; 133d1853231SIgor Mammedov 134d1853231SIgor Mammedov if (!features) { 135d1853231SIgor Mammedov return; 136d1853231SIgor Mammedov } 137d1853231SIgor Mammedov 138d1853231SIgor Mammedov for (featurestr = strtok(features, ","); 139d1853231SIgor Mammedov featurestr; 140d1853231SIgor Mammedov featurestr = strtok(NULL, ",")) { 141d1853231SIgor Mammedov const char *name; 142d1853231SIgor Mammedov const char *val = NULL; 143d1853231SIgor Mammedov char *eq = NULL; 144d1853231SIgor Mammedov 145d1853231SIgor Mammedov /* Compatibility syntax: */ 146d1853231SIgor Mammedov if (featurestr[0] == '+') { 147d1853231SIgor Mammedov plus_features = g_list_append(plus_features, 148d1853231SIgor Mammedov g_strdup(featurestr + 1)); 149d1853231SIgor Mammedov continue; 150d1853231SIgor Mammedov } else if (featurestr[0] == '-') { 151d1853231SIgor Mammedov minus_features = g_list_append(minus_features, 152d1853231SIgor Mammedov g_strdup(featurestr + 1)); 153d1853231SIgor Mammedov continue; 154d1853231SIgor Mammedov } 155d1853231SIgor Mammedov 156d1853231SIgor Mammedov eq = strchr(featurestr, '='); 157d1853231SIgor Mammedov name = featurestr; 158d1853231SIgor Mammedov if (eq) { 159d1853231SIgor Mammedov *eq++ = 0; 160d1853231SIgor Mammedov val = eq; 161d1853231SIgor Mammedov 162d1853231SIgor Mammedov /* 163d1853231SIgor Mammedov * Temporarily, only +feat/-feat will be supported 164d1853231SIgor Mammedov * for boolean properties until we remove the 165d1853231SIgor Mammedov * minus-overrides-plus semantics and just follow 166d1853231SIgor Mammedov * the order options appear on the command-line. 167d1853231SIgor Mammedov * 168d1853231SIgor Mammedov * TODO: warn if user is relying on minus-override-plus semantics 169d1853231SIgor Mammedov * TODO: remove minus-override-plus semantics after 170d1853231SIgor Mammedov * warning for a few releases 171d1853231SIgor Mammedov */ 172d1853231SIgor Mammedov if (!strcasecmp(val, "on") || 173d1853231SIgor Mammedov !strcasecmp(val, "off") || 174d1853231SIgor Mammedov !strcasecmp(val, "true") || 175d1853231SIgor Mammedov !strcasecmp(val, "false")) { 176d1853231SIgor Mammedov error_setg(errp, "Boolean properties in format %s=%s" 177d1853231SIgor Mammedov " are not supported", name, val); 178d1853231SIgor Mammedov return; 179d1853231SIgor Mammedov } 180d1853231SIgor Mammedov } else { 181d1853231SIgor Mammedov error_setg(errp, "Unsupported property format: %s", name); 182d1853231SIgor Mammedov return; 183d1853231SIgor Mammedov } 184d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, val); 185d1853231SIgor Mammedov } 186d1853231SIgor Mammedov 187d1853231SIgor Mammedov for (l = plus_features; l; l = l->next) { 188d1853231SIgor Mammedov const char *name = l->data; 189d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, "on"); 190d1853231SIgor Mammedov } 191d1853231SIgor Mammedov g_list_free_full(plus_features, g_free); 192d1853231SIgor Mammedov 193d1853231SIgor Mammedov for (l = minus_features; l; l = l->next) { 194d1853231SIgor Mammedov const char *name = l->data; 195d1853231SIgor Mammedov cpu_add_feat_as_prop(typename, name, "off"); 196d1853231SIgor Mammedov } 197d1853231SIgor Mammedov g_list_free_full(minus_features, g_free); 198ab3b491fSBlue Swirl } 199ab3b491fSBlue Swirl 200ab3b491fSBlue Swirl void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu) 201ab3b491fSBlue Swirl { 202ab3b491fSBlue Swirl #if !defined(TARGET_SPARC64) 203ab3b491fSBlue Swirl env->mxccregs[7] = ((cpu + 8) & 0xf) << 24; 204ab3b491fSBlue Swirl #endif 205ab3b491fSBlue Swirl } 206ab3b491fSBlue Swirl 207ab3b491fSBlue Swirl static const sparc_def_t sparc_defs[] = { 208ab3b491fSBlue Swirl #ifdef TARGET_SPARC64 209ab3b491fSBlue Swirl { 2104a7bdec3SThomas Huth .name = "Fujitsu-Sparc64", 211ab3b491fSBlue Swirl .iu_version = ((0x04ULL << 48) | (0x02ULL << 32) | (0ULL << 24)), 212ab3b491fSBlue Swirl .fpu_version = 0x00000000, 213ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 214ab3b491fSBlue Swirl .nwindows = 4, 215ab3b491fSBlue Swirl .maxtl = 4, 216ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 217ab3b491fSBlue Swirl }, 218ab3b491fSBlue Swirl { 2194a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-III", 220ab3b491fSBlue Swirl .iu_version = ((0x04ULL << 48) | (0x03ULL << 32) | (0ULL << 24)), 221ab3b491fSBlue Swirl .fpu_version = 0x00000000, 222ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 223ab3b491fSBlue Swirl .nwindows = 5, 224ab3b491fSBlue Swirl .maxtl = 4, 225ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 226ab3b491fSBlue Swirl }, 227ab3b491fSBlue Swirl { 2284a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-IV", 229ab3b491fSBlue Swirl .iu_version = ((0x04ULL << 48) | (0x04ULL << 32) | (0ULL << 24)), 230ab3b491fSBlue Swirl .fpu_version = 0x00000000, 231ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 232ab3b491fSBlue Swirl .nwindows = 8, 233ab3b491fSBlue Swirl .maxtl = 5, 234ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 235ab3b491fSBlue Swirl }, 236ab3b491fSBlue Swirl { 2374a7bdec3SThomas Huth .name = "Fujitsu-Sparc64-V", 238ab3b491fSBlue Swirl .iu_version = ((0x04ULL << 48) | (0x05ULL << 32) | (0x51ULL << 24)), 239ab3b491fSBlue Swirl .fpu_version = 0x00000000, 240ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 241ab3b491fSBlue Swirl .nwindows = 8, 242ab3b491fSBlue Swirl .maxtl = 5, 243ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 244ab3b491fSBlue Swirl }, 245ab3b491fSBlue Swirl { 2464a7bdec3SThomas Huth .name = "TI-UltraSparc-I", 247ab3b491fSBlue Swirl .iu_version = ((0x17ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)), 248ab3b491fSBlue Swirl .fpu_version = 0x00000000, 249ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 250ab3b491fSBlue Swirl .nwindows = 8, 251ab3b491fSBlue Swirl .maxtl = 5, 252ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 253ab3b491fSBlue Swirl }, 254ab3b491fSBlue Swirl { 2554a7bdec3SThomas Huth .name = "TI-UltraSparc-II", 256ab3b491fSBlue Swirl .iu_version = ((0x17ULL << 48) | (0x11ULL << 32) | (0x20ULL << 24)), 257ab3b491fSBlue Swirl .fpu_version = 0x00000000, 258ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 259ab3b491fSBlue Swirl .nwindows = 8, 260ab3b491fSBlue Swirl .maxtl = 5, 261ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 262ab3b491fSBlue Swirl }, 263ab3b491fSBlue Swirl { 2644a7bdec3SThomas Huth .name = "TI-UltraSparc-IIi", 265ab3b491fSBlue Swirl .iu_version = ((0x17ULL << 48) | (0x12ULL << 32) | (0x91ULL << 24)), 266ab3b491fSBlue Swirl .fpu_version = 0x00000000, 267ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 268ab3b491fSBlue Swirl .nwindows = 8, 269ab3b491fSBlue Swirl .maxtl = 5, 270ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 271ab3b491fSBlue Swirl }, 272ab3b491fSBlue Swirl { 2734a7bdec3SThomas Huth .name = "TI-UltraSparc-IIe", 274ab3b491fSBlue Swirl .iu_version = ((0x17ULL << 48) | (0x13ULL << 32) | (0x14ULL << 24)), 275ab3b491fSBlue Swirl .fpu_version = 0x00000000, 276ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 277ab3b491fSBlue Swirl .nwindows = 8, 278ab3b491fSBlue Swirl .maxtl = 5, 279ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 280ab3b491fSBlue Swirl }, 281ab3b491fSBlue Swirl { 2824a7bdec3SThomas Huth .name = "Sun-UltraSparc-III", 283ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x14ULL << 32) | (0x34ULL << 24)), 284ab3b491fSBlue Swirl .fpu_version = 0x00000000, 285ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 286ab3b491fSBlue Swirl .nwindows = 8, 287ab3b491fSBlue Swirl .maxtl = 5, 288ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 289ab3b491fSBlue Swirl }, 290ab3b491fSBlue Swirl { 2914a7bdec3SThomas Huth .name = "Sun-UltraSparc-III-Cu", 292ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x15ULL << 32) | (0x41ULL << 24)), 293ab3b491fSBlue Swirl .fpu_version = 0x00000000, 294ab3b491fSBlue Swirl .mmu_version = mmu_us_3, 295ab3b491fSBlue Swirl .nwindows = 8, 296ab3b491fSBlue Swirl .maxtl = 5, 297ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 298ab3b491fSBlue Swirl }, 299ab3b491fSBlue Swirl { 3004a7bdec3SThomas Huth .name = "Sun-UltraSparc-IIIi", 301ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x16ULL << 32) | (0x34ULL << 24)), 302ab3b491fSBlue Swirl .fpu_version = 0x00000000, 303ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 304ab3b491fSBlue Swirl .nwindows = 8, 305ab3b491fSBlue Swirl .maxtl = 5, 306ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 307ab3b491fSBlue Swirl }, 308ab3b491fSBlue Swirl { 3094a7bdec3SThomas Huth .name = "Sun-UltraSparc-IV", 310ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x18ULL << 32) | (0x31ULL << 24)), 311ab3b491fSBlue Swirl .fpu_version = 0x00000000, 312ab3b491fSBlue Swirl .mmu_version = mmu_us_4, 313ab3b491fSBlue Swirl .nwindows = 8, 314ab3b491fSBlue Swirl .maxtl = 5, 315ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 316ab3b491fSBlue Swirl }, 317ab3b491fSBlue Swirl { 3184a7bdec3SThomas Huth .name = "Sun-UltraSparc-IV-plus", 319ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x19ULL << 32) | (0x22ULL << 24)), 320ab3b491fSBlue Swirl .fpu_version = 0x00000000, 321ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 322ab3b491fSBlue Swirl .nwindows = 8, 323ab3b491fSBlue Swirl .maxtl = 5, 324ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_CMT, 325ab3b491fSBlue Swirl }, 326ab3b491fSBlue Swirl { 3274a7bdec3SThomas Huth .name = "Sun-UltraSparc-IIIi-plus", 328ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x22ULL << 32) | (0ULL << 24)), 329ab3b491fSBlue Swirl .fpu_version = 0x00000000, 330ab3b491fSBlue Swirl .mmu_version = mmu_us_3, 331ab3b491fSBlue Swirl .nwindows = 8, 332ab3b491fSBlue Swirl .maxtl = 5, 333ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 334ab3b491fSBlue Swirl }, 335ab3b491fSBlue Swirl { 3364a7bdec3SThomas Huth .name = "Sun-UltraSparc-T1", 337ab3b491fSBlue Swirl /* defined in sparc_ifu_fdp.v and ctu.h */ 338ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x23ULL << 32) | (0x02ULL << 24)), 339ab3b491fSBlue Swirl .fpu_version = 0x00000000, 340ab3b491fSBlue Swirl .mmu_version = mmu_sun4v, 341ab3b491fSBlue Swirl .nwindows = 8, 342ab3b491fSBlue Swirl .maxtl = 6, 343ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT 344ab3b491fSBlue Swirl | CPU_FEATURE_GL, 345ab3b491fSBlue Swirl }, 346ab3b491fSBlue Swirl { 3474a7bdec3SThomas Huth .name = "Sun-UltraSparc-T2", 348ab3b491fSBlue Swirl /* defined in tlu_asi_ctl.v and n2_revid_cust.v */ 349ab3b491fSBlue Swirl .iu_version = ((0x3eULL << 48) | (0x24ULL << 32) | (0x02ULL << 24)), 350ab3b491fSBlue Swirl .fpu_version = 0x00000000, 351ab3b491fSBlue Swirl .mmu_version = mmu_sun4v, 352ab3b491fSBlue Swirl .nwindows = 8, 353ab3b491fSBlue Swirl .maxtl = 6, 354ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_HYPV | CPU_FEATURE_CMT 355ab3b491fSBlue Swirl | CPU_FEATURE_GL, 356ab3b491fSBlue Swirl }, 357ab3b491fSBlue Swirl { 3584a7bdec3SThomas Huth .name = "NEC-UltraSparc-I", 359ab3b491fSBlue Swirl .iu_version = ((0x22ULL << 48) | (0x10ULL << 32) | (0x40ULL << 24)), 360ab3b491fSBlue Swirl .fpu_version = 0x00000000, 361ab3b491fSBlue Swirl .mmu_version = mmu_us_12, 362ab3b491fSBlue Swirl .nwindows = 8, 363ab3b491fSBlue Swirl .maxtl = 5, 364ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 365ab3b491fSBlue Swirl }, 366ab3b491fSBlue Swirl #else 367ab3b491fSBlue Swirl { 3684a7bdec3SThomas Huth .name = "Fujitsu-MB86904", 369ab3b491fSBlue Swirl .iu_version = 0x04 << 24, /* Impl 0, ver 4 */ 37049bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */ 371ab3b491fSBlue Swirl .mmu_version = 0x04 << 24, /* Impl 0, ver 4 */ 372ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 373ab3b491fSBlue Swirl .mmu_ctpr_mask = 0x00ffffc0, 374ab3b491fSBlue Swirl .mmu_cxr_mask = 0x000000ff, 375ab3b491fSBlue Swirl .mmu_sfsr_mask = 0x00016fff, 376ab3b491fSBlue Swirl .mmu_trcr_mask = 0x00ffffff, 377ab3b491fSBlue Swirl .nwindows = 8, 378ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 379ab3b491fSBlue Swirl }, 380ab3b491fSBlue Swirl { 3814a7bdec3SThomas Huth .name = "Fujitsu-MB86907", 382ab3b491fSBlue Swirl .iu_version = 0x05 << 24, /* Impl 0, ver 5 */ 38349bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */ 384ab3b491fSBlue Swirl .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */ 385ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 386ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 387ab3b491fSBlue Swirl .mmu_cxr_mask = 0x000000ff, 388ab3b491fSBlue Swirl .mmu_sfsr_mask = 0x00016fff, 389ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 390ab3b491fSBlue Swirl .nwindows = 8, 391ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 392ab3b491fSBlue Swirl }, 393ab3b491fSBlue Swirl { 3944a7bdec3SThomas Huth .name = "TI-MicroSparc-I", 395ab3b491fSBlue Swirl .iu_version = 0x41000000, 39649bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, 397ab3b491fSBlue Swirl .mmu_version = 0x41000000, 398ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 399ab3b491fSBlue Swirl .mmu_ctpr_mask = 0x007ffff0, 400ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000003f, 401ab3b491fSBlue Swirl .mmu_sfsr_mask = 0x00016fff, 402ab3b491fSBlue Swirl .mmu_trcr_mask = 0x0000003f, 403ab3b491fSBlue Swirl .nwindows = 7, 4045f25b383SRichard Henderson .features = CPU_FEATURE_MUL | CPU_FEATURE_DIV, 405ab3b491fSBlue Swirl }, 406ab3b491fSBlue Swirl { 4074a7bdec3SThomas Huth .name = "TI-MicroSparc-II", 408ab3b491fSBlue Swirl .iu_version = 0x42000000, 40949bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, 410ab3b491fSBlue Swirl .mmu_version = 0x02000000, 411ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 412ab3b491fSBlue Swirl .mmu_ctpr_mask = 0x00ffffc0, 413ab3b491fSBlue Swirl .mmu_cxr_mask = 0x000000ff, 414ab3b491fSBlue Swirl .mmu_sfsr_mask = 0x00016fff, 415ab3b491fSBlue Swirl .mmu_trcr_mask = 0x00ffffff, 416ab3b491fSBlue Swirl .nwindows = 8, 417ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 418ab3b491fSBlue Swirl }, 419ab3b491fSBlue Swirl { 4204a7bdec3SThomas Huth .name = "TI-MicroSparc-IIep", 421ab3b491fSBlue Swirl .iu_version = 0x42000000, 42249bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, 423ab3b491fSBlue Swirl .mmu_version = 0x04000000, 424ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 425ab3b491fSBlue Swirl .mmu_ctpr_mask = 0x00ffffc0, 426ab3b491fSBlue Swirl .mmu_cxr_mask = 0x000000ff, 427ab3b491fSBlue Swirl .mmu_sfsr_mask = 0x00016bff, 428ab3b491fSBlue Swirl .mmu_trcr_mask = 0x00ffffff, 429ab3b491fSBlue Swirl .nwindows = 8, 430ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 431ab3b491fSBlue Swirl }, 432ab3b491fSBlue Swirl { 4334a7bdec3SThomas Huth .name = "TI-SuperSparc-40", /* STP1020NPGA */ 434ab3b491fSBlue Swirl .iu_version = 0x41000000, /* SuperSPARC 2.x */ 43549bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 436ab3b491fSBlue Swirl .mmu_version = 0x00000800, /* SuperSPARC 2.x, no MXCC */ 437ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 438ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 439ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 440ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 441ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 442ab3b491fSBlue Swirl .nwindows = 8, 443ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 444ab3b491fSBlue Swirl }, 445ab3b491fSBlue Swirl { 4464a7bdec3SThomas Huth .name = "TI-SuperSparc-50", /* STP1020PGA */ 447ab3b491fSBlue Swirl .iu_version = 0x40000000, /* SuperSPARC 3.x */ 44849bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 449ab3b491fSBlue Swirl .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */ 450ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 451ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 452ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 453ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 454ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 455ab3b491fSBlue Swirl .nwindows = 8, 456ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 457ab3b491fSBlue Swirl }, 458ab3b491fSBlue Swirl { 4594a7bdec3SThomas Huth .name = "TI-SuperSparc-51", 460ab3b491fSBlue Swirl .iu_version = 0x40000000, /* SuperSPARC 3.x */ 46149bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 462ab3b491fSBlue Swirl .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */ 463ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 464ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 465ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 466ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 467ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 468ab3b491fSBlue Swirl .mxcc_version = 0x00000104, 469ab3b491fSBlue Swirl .nwindows = 8, 470ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 471ab3b491fSBlue Swirl }, 472ab3b491fSBlue Swirl { 4734a7bdec3SThomas Huth .name = "TI-SuperSparc-60", /* STP1020APGA */ 474ab3b491fSBlue Swirl .iu_version = 0x40000000, /* SuperSPARC 3.x */ 47549bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 476ab3b491fSBlue Swirl .mmu_version = 0x01000800, /* SuperSPARC 3.x, no MXCC */ 477ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 478ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 479ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 480ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 481ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 482ab3b491fSBlue Swirl .nwindows = 8, 483ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 484ab3b491fSBlue Swirl }, 485ab3b491fSBlue Swirl { 4864a7bdec3SThomas Huth .name = "TI-SuperSparc-61", 487ab3b491fSBlue Swirl .iu_version = 0x44000000, /* SuperSPARC 3.x */ 48849bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 489ab3b491fSBlue Swirl .mmu_version = 0x01000000, /* SuperSPARC 3.x, MXCC */ 490ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 491ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 492ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 493ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 494ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 495ab3b491fSBlue Swirl .mxcc_version = 0x00000104, 496ab3b491fSBlue Swirl .nwindows = 8, 497ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 498ab3b491fSBlue Swirl }, 499ab3b491fSBlue Swirl { 5004a7bdec3SThomas Huth .name = "TI-SuperSparc-II", 501ab3b491fSBlue Swirl .iu_version = 0x40000000, /* SuperSPARC II 1.x */ 50249bb9725SRichard Henderson .fpu_version = 0 << FSR_VER_SHIFT, 503ab3b491fSBlue Swirl .mmu_version = 0x08000000, /* SuperSPARC II 1.x, MXCC */ 504ab3b491fSBlue Swirl .mmu_bm = 0x00002000, 505ab3b491fSBlue Swirl .mmu_ctpr_mask = 0xffffffc0, 506ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000ffff, 507ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 508ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 509ab3b491fSBlue Swirl .mxcc_version = 0x00000104, 510ab3b491fSBlue Swirl .nwindows = 8, 511ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES, 512ab3b491fSBlue Swirl }, 513ab3b491fSBlue Swirl { 514ab3b491fSBlue Swirl .name = "LEON2", 515ab3b491fSBlue Swirl .iu_version = 0xf2000000, 51649bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */ 517ab3b491fSBlue Swirl .mmu_version = 0xf2000000, 518ab3b491fSBlue Swirl .mmu_bm = 0x00004000, 519ab3b491fSBlue Swirl .mmu_ctpr_mask = 0x007ffff0, 520ab3b491fSBlue Swirl .mmu_cxr_mask = 0x0000003f, 521ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 522ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 523ab3b491fSBlue Swirl .nwindows = 8, 524ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN, 525ab3b491fSBlue Swirl }, 526ab3b491fSBlue Swirl { 527ab3b491fSBlue Swirl .name = "LEON3", 528ab3b491fSBlue Swirl .iu_version = 0xf3000000, 52949bb9725SRichard Henderson .fpu_version = 4 << FSR_VER_SHIFT, /* FPU version 4 (Meiko) */ 530ab3b491fSBlue Swirl .mmu_version = 0xf3000000, 531ab3b491fSBlue Swirl .mmu_bm = 0x00000000, 5327a0a9c2cSRonald Hecht .mmu_ctpr_mask = 0xfffffffc, 5337a0a9c2cSRonald Hecht .mmu_cxr_mask = 0x000000ff, 534ab3b491fSBlue Swirl .mmu_sfsr_mask = 0xffffffff, 535ab3b491fSBlue Swirl .mmu_trcr_mask = 0xffffffff, 536ab3b491fSBlue Swirl .nwindows = 8, 537ab3b491fSBlue Swirl .features = CPU_DEFAULT_FEATURES | CPU_FEATURE_TA0_SHUTDOWN | 53816c358e9SSebastian Huber CPU_FEATURE_ASR17 | CPU_FEATURE_CACHE_CTRL | CPU_FEATURE_POWERDOWN | 53916c358e9SSebastian Huber CPU_FEATURE_CASA, 540ab3b491fSBlue Swirl }, 541ab3b491fSBlue Swirl #endif 542ab3b491fSBlue Swirl }; 543ab3b491fSBlue Swirl 544de1f5203SRichard Henderson /* This must match sparc_cpu_properties[]. */ 545ab3b491fSBlue Swirl static const char * const feature_name[] = { 546de1f5203SRichard Henderson [CPU_FEATURE_BIT_FLOAT128] = "float128", 547554abe47SRichard Henderson #ifdef TARGET_SPARC64 548de1f5203SRichard Henderson [CPU_FEATURE_BIT_CMT] = "cmt", 549de1f5203SRichard Henderson [CPU_FEATURE_BIT_GL] = "gl", 550554abe47SRichard Henderson [CPU_FEATURE_BIT_HYPV] = "hypv", 551554abe47SRichard Henderson [CPU_FEATURE_BIT_VIS1] = "vis1", 552554abe47SRichard Henderson [CPU_FEATURE_BIT_VIS2] = "vis2", 5534fd71d19SRichard Henderson [CPU_FEATURE_BIT_FMAF] = "fmaf", 554deadbb14SRichard Henderson [CPU_FEATURE_BIT_VIS3] = "vis3", 55568a414e9SRichard Henderson [CPU_FEATURE_BIT_IMA] = "ima", 556b12b7227SRichard Henderson [CPU_FEATURE_BIT_VIS4] = "vis4", 557554abe47SRichard Henderson #else 558554abe47SRichard Henderson [CPU_FEATURE_BIT_MUL] = "mul", 559554abe47SRichard Henderson [CPU_FEATURE_BIT_DIV] = "div", 560554abe47SRichard Henderson [CPU_FEATURE_BIT_FSMULD] = "fsmuld", 561554abe47SRichard Henderson #endif 562ab3b491fSBlue Swirl }; 563ab3b491fSBlue Swirl 5640442428aSMarkus Armbruster static void print_features(uint32_t features, const char *prefix) 565ab3b491fSBlue Swirl { 566ab3b491fSBlue Swirl unsigned int i; 567ab3b491fSBlue Swirl 568ab3b491fSBlue Swirl for (i = 0; i < ARRAY_SIZE(feature_name); i++) { 569ab3b491fSBlue Swirl if (feature_name[i] && (features & (1 << i))) { 570ab3b491fSBlue Swirl if (prefix) { 5710442428aSMarkus Armbruster qemu_printf("%s", prefix); 572ab3b491fSBlue Swirl } 5730442428aSMarkus Armbruster qemu_printf("%s ", feature_name[i]); 574ab3b491fSBlue Swirl } 575ab3b491fSBlue Swirl } 576ab3b491fSBlue Swirl } 577ab3b491fSBlue Swirl 5780442428aSMarkus Armbruster void sparc_cpu_list(void) 579ab3b491fSBlue Swirl { 580ab3b491fSBlue Swirl unsigned int i; 581ab3b491fSBlue Swirl 58247833f81SThomas Huth qemu_printf("Available CPU types:\n"); 583ab3b491fSBlue Swirl for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { 58447833f81SThomas Huth qemu_printf(" %-20s (IU " TARGET_FMT_lx 58547833f81SThomas Huth " FPU %08x MMU %08x NWINS %d) ", 586ab3b491fSBlue Swirl sparc_defs[i].name, 587ab3b491fSBlue Swirl sparc_defs[i].iu_version, 588ab3b491fSBlue Swirl sparc_defs[i].fpu_version, 589ab3b491fSBlue Swirl sparc_defs[i].mmu_version, 590ab3b491fSBlue Swirl sparc_defs[i].nwindows); 5910442428aSMarkus Armbruster print_features(CPU_DEFAULT_FEATURES & ~sparc_defs[i].features, "-"); 5920442428aSMarkus Armbruster print_features(~CPU_DEFAULT_FEATURES & sparc_defs[i].features, "+"); 5930442428aSMarkus Armbruster qemu_printf("\n"); 594ab3b491fSBlue Swirl } 5950442428aSMarkus Armbruster qemu_printf("Default CPU feature flags (use '-' to remove): "); 5960442428aSMarkus Armbruster print_features(CPU_DEFAULT_FEATURES, NULL); 5970442428aSMarkus Armbruster qemu_printf("\n"); 5980442428aSMarkus Armbruster qemu_printf("Available CPU feature flags (use '+' to add): "); 5990442428aSMarkus Armbruster print_features(~CPU_DEFAULT_FEATURES, NULL); 6000442428aSMarkus Armbruster qemu_printf("\n"); 6010442428aSMarkus Armbruster qemu_printf("Numerical features (use '=' to set): iu_version " 602ab3b491fSBlue Swirl "fpu_version mmu_version nwindows\n"); 603ab3b491fSBlue Swirl } 604ab3b491fSBlue Swirl 60590c84c56SMarkus Armbruster static void cpu_print_cc(FILE *f, uint32_t cc) 606ab3b491fSBlue Swirl { 60790c84c56SMarkus Armbruster qemu_fprintf(f, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-', 608ab3b491fSBlue Swirl cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' : '-', 609ab3b491fSBlue Swirl cc & PSR_CARRY ? 'C' : '-'); 610ab3b491fSBlue Swirl } 611ab3b491fSBlue Swirl 612ab3b491fSBlue Swirl #ifdef TARGET_SPARC64 613ab3b491fSBlue Swirl #define REGS_PER_LINE 4 614ab3b491fSBlue Swirl #else 615ab3b491fSBlue Swirl #define REGS_PER_LINE 8 616ab3b491fSBlue Swirl #endif 617ab3b491fSBlue Swirl 6189ac200acSPhilippe Mathieu-Daudé static void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) 619ab3b491fSBlue Swirl { 62077976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs); 621ab3b491fSBlue Swirl int i, x; 622ab3b491fSBlue Swirl 62390c84c56SMarkus Armbruster qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, 624ab3b491fSBlue Swirl env->npc); 625ab3b491fSBlue Swirl 626ab3b491fSBlue Swirl for (i = 0; i < 8; i++) { 627ab3b491fSBlue Swirl if (i % REGS_PER_LINE == 0) { 62890c84c56SMarkus Armbruster qemu_fprintf(f, "%%g%d-%d:", i, i + REGS_PER_LINE - 1); 629ab3b491fSBlue Swirl } 63090c84c56SMarkus Armbruster qemu_fprintf(f, " " TARGET_FMT_lx, env->gregs[i]); 631ab3b491fSBlue Swirl if (i % REGS_PER_LINE == REGS_PER_LINE - 1) { 63290c84c56SMarkus Armbruster qemu_fprintf(f, "\n"); 633ab3b491fSBlue Swirl } 634ab3b491fSBlue Swirl } 635ab3b491fSBlue Swirl for (x = 0; x < 3; x++) { 636ab3b491fSBlue Swirl for (i = 0; i < 8; i++) { 637ab3b491fSBlue Swirl if (i % REGS_PER_LINE == 0) { 63890c84c56SMarkus Armbruster qemu_fprintf(f, "%%%c%d-%d: ", 639ab3b491fSBlue Swirl x == 0 ? 'o' : (x == 1 ? 'l' : 'i'), 640ab3b491fSBlue Swirl i, i + REGS_PER_LINE - 1); 641ab3b491fSBlue Swirl } 64290c84c56SMarkus Armbruster qemu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]); 643ab3b491fSBlue Swirl if (i % REGS_PER_LINE == REGS_PER_LINE - 1) { 64490c84c56SMarkus Armbruster qemu_fprintf(f, "\n"); 645ab3b491fSBlue Swirl } 646ab3b491fSBlue Swirl } 647ab3b491fSBlue Swirl } 64876a23ca0SRichard Henderson 649d13c394cSRichard Henderson if (flags & CPU_DUMP_FPU) { 65030038fd8SRichard Henderson for (i = 0; i < TARGET_DPREGS; i++) { 651ab3b491fSBlue Swirl if ((i & 3) == 0) { 65290c84c56SMarkus Armbruster qemu_fprintf(f, "%%f%02d: ", i * 2); 653ab3b491fSBlue Swirl } 65490c84c56SMarkus Armbruster qemu_fprintf(f, " %016" PRIx64, env->fpr[i].ll); 655ab3b491fSBlue Swirl if ((i & 3) == 3) { 65690c84c56SMarkus Armbruster qemu_fprintf(f, "\n"); 657ab3b491fSBlue Swirl } 658ab3b491fSBlue Swirl } 659d13c394cSRichard Henderson } 660d13c394cSRichard Henderson 661ab3b491fSBlue Swirl #ifdef TARGET_SPARC64 66290c84c56SMarkus Armbruster qemu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate, 663ab3b491fSBlue Swirl (unsigned)cpu_get_ccr(env)); 66490c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_ccr(env) << PSR_CARRY_SHIFT); 66590c84c56SMarkus Armbruster qemu_fprintf(f, " xcc: "); 66690c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4)); 66790c84c56SMarkus Armbruster qemu_fprintf(f, ") asi: %02x tl: %d pil: %x gl: %d\n", env->asi, env->tl, 668cbc3a6a4SArtyom Tarasenko env->psrpil, env->gl); 66990c84c56SMarkus Armbruster qemu_fprintf(f, "tbr: " TARGET_FMT_lx " hpstate: " TARGET_FMT_lx " htba: " 670cbc3a6a4SArtyom Tarasenko TARGET_FMT_lx "\n", env->tbr, env->hpstate, env->htba); 67190c84c56SMarkus Armbruster qemu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate: %d " 672ab3b491fSBlue Swirl "cleanwin: %d cwp: %d\n", 673ab3b491fSBlue Swirl env->cansave, env->canrestore, env->otherwin, env->wstate, 674ab3b491fSBlue Swirl env->cleanwin, env->nwindows - 1 - env->cwp); 675ca4d5d86SPeter Maydell qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: %016x\n", 6761ccd6e13SRichard Henderson cpu_get_fsr(env), env->y, env->fprs); 677cbc3a6a4SArtyom Tarasenko 678ab3b491fSBlue Swirl #else 67990c84c56SMarkus Armbruster qemu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env)); 68090c84c56SMarkus Armbruster cpu_print_cc(f, cpu_get_psr(env)); 68190c84c56SMarkus Armbruster qemu_fprintf(f, " SPE: %c%c%c) wim: %08x\n", env->psrs ? 'S' : '-', 682ab3b491fSBlue Swirl env->psrps ? 'P' : '-', env->psret ? 'E' : '-', 683ab3b491fSBlue Swirl env->wim); 68490c84c56SMarkus Armbruster qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx "\n", 6851ccd6e13SRichard Henderson cpu_get_fsr(env), env->y); 686ab3b491fSBlue Swirl #endif 68790c84c56SMarkus Armbruster qemu_fprintf(f, "\n"); 688ab3b491fSBlue Swirl } 689ab7ab3d7SAndreas Färber 690f45748f1SAndreas Färber static void sparc_cpu_set_pc(CPUState *cs, vaddr value) 691f45748f1SAndreas Färber { 692f45748f1SAndreas Färber SPARCCPU *cpu = SPARC_CPU(cs); 693f45748f1SAndreas Färber 694f45748f1SAndreas Färber cpu->env.pc = value; 695f45748f1SAndreas Färber cpu->env.npc = value + 4; 696f45748f1SAndreas Färber } 697f45748f1SAndreas Färber 698e4fdf9dfSRichard Henderson static vaddr sparc_cpu_get_pc(CPUState *cs) 699e4fdf9dfSRichard Henderson { 700e4fdf9dfSRichard Henderson SPARCCPU *cpu = SPARC_CPU(cs); 701e4fdf9dfSRichard Henderson 702e4fdf9dfSRichard Henderson return cpu->env.pc; 703e4fdf9dfSRichard Henderson } 704e4fdf9dfSRichard Henderson 70504a37d4cSRichard Henderson static void sparc_cpu_synchronize_from_tb(CPUState *cs, 70604a37d4cSRichard Henderson const TranslationBlock *tb) 707bdf7ae5bSAndreas Färber { 708bdf7ae5bSAndreas Färber SPARCCPU *cpu = SPARC_CPU(cs); 709bdf7ae5bSAndreas Färber 710b254c342SPhilippe Mathieu-Daudé tcg_debug_assert(!tcg_cflags_has(cs, CF_PCREL)); 711c4bf3a92SAnton Johansson cpu->env.pc = tb->pc; 712bdf7ae5bSAndreas Färber cpu->env.npc = tb->cs_base; 713bdf7ae5bSAndreas Färber } 714bdf7ae5bSAndreas Färber 7158c2e1b00SAndreas Färber static bool sparc_cpu_has_work(CPUState *cs) 7168c2e1b00SAndreas Färber { 7178c2e1b00SAndreas Färber return (cs->interrupt_request & CPU_INTERRUPT_HARD) && 71877976769SPhilippe Mathieu-Daudé cpu_interrupts_enabled(cpu_env(cs)); 7198c2e1b00SAndreas Färber } 7208c2e1b00SAndreas Färber 721a120d320SRichard Henderson static int sparc_cpu_mmu_index(CPUState *cs, bool ifetch) 722e3547a7dSRichard Henderson { 723e3547a7dSRichard Henderson CPUSPARCState *env = cpu_env(cs); 724e3547a7dSRichard Henderson 725e3547a7dSRichard Henderson #ifndef TARGET_SPARC64 726e3547a7dSRichard Henderson if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */ 727e3547a7dSRichard Henderson return MMU_PHYS_IDX; 728e3547a7dSRichard Henderson } else { 729e3547a7dSRichard Henderson return env->psrs; 730e3547a7dSRichard Henderson } 731e3547a7dSRichard Henderson #else 732e3547a7dSRichard Henderson /* IMMU or DMMU disabled. */ 733e3547a7dSRichard Henderson if (ifetch 734e3547a7dSRichard Henderson ? (env->lsu & IMMU_E) == 0 || (env->pstate & PS_RED) != 0 735e3547a7dSRichard Henderson : (env->lsu & DMMU_E) == 0) { 736e3547a7dSRichard Henderson return MMU_PHYS_IDX; 737e3547a7dSRichard Henderson } else if (cpu_hypervisor_mode(env)) { 738e3547a7dSRichard Henderson return MMU_PHYS_IDX; 739e3547a7dSRichard Henderson } else if (env->tl > 0) { 740e3547a7dSRichard Henderson return MMU_NUCLEUS_IDX; 741e3547a7dSRichard Henderson } else if (cpu_supervisor_mode(env)) { 742e3547a7dSRichard Henderson return MMU_KERNEL_IDX; 743e3547a7dSRichard Henderson } else { 744e3547a7dSRichard Henderson return MMU_USER_IDX; 745e3547a7dSRichard Henderson } 746e3547a7dSRichard Henderson #endif 747e3547a7dSRichard Henderson } 748e3547a7dSRichard Henderson 74912a6c15eSIgor Mammedov static char *sparc_cpu_type_name(const char *cpu_model) 75012a6c15eSIgor Mammedov { 7511d4bfc54SIgor Mammedov char *name = g_strdup_printf(SPARC_CPU_TYPE_NAME("%s"), cpu_model); 75212a6c15eSIgor Mammedov char *s = name; 75312a6c15eSIgor Mammedov 75412a6c15eSIgor Mammedov /* SPARC cpu model names happen to have whitespaces, 75512a6c15eSIgor Mammedov * as type names shouldn't have spaces replace them with '-' 75612a6c15eSIgor Mammedov */ 75712a6c15eSIgor Mammedov while ((s = strchr(s, ' '))) { 75812a6c15eSIgor Mammedov *s = '-'; 75912a6c15eSIgor Mammedov } 76012a6c15eSIgor Mammedov 76112a6c15eSIgor Mammedov return name; 76212a6c15eSIgor Mammedov } 76312a6c15eSIgor Mammedov 76412a6c15eSIgor Mammedov static ObjectClass *sparc_cpu_class_by_name(const char *cpu_model) 76512a6c15eSIgor Mammedov { 76612a6c15eSIgor Mammedov ObjectClass *oc; 76712a6c15eSIgor Mammedov char *typename; 76812a6c15eSIgor Mammedov 76912a6c15eSIgor Mammedov typename = sparc_cpu_type_name(cpu_model); 7706b568e3fSThomas Huth 7716b568e3fSThomas Huth /* Fix up legacy names with '+' in it */ 7726b568e3fSThomas Huth if (g_str_equal(typename, SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IV+"))) { 7736b568e3fSThomas Huth g_free(typename); 7746b568e3fSThomas Huth typename = g_strdup(SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IV-plus")); 7756b568e3fSThomas Huth } else if (g_str_equal(typename, SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IIIi+"))) { 7766b568e3fSThomas Huth g_free(typename); 7776b568e3fSThomas Huth typename = g_strdup(SPARC_CPU_TYPE_NAME("Sun-UltraSparc-IIIi-plus")); 7786b568e3fSThomas Huth } 7796b568e3fSThomas Huth 78012a6c15eSIgor Mammedov oc = object_class_by_name(typename); 78112a6c15eSIgor Mammedov g_free(typename); 78212a6c15eSIgor Mammedov return oc; 78312a6c15eSIgor Mammedov } 78412a6c15eSIgor Mammedov 785b6e91ebfSAndreas Färber static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) 786b6e91ebfSAndreas Färber { 787ce5b1bbfSLaurent Vivier CPUState *cs = CPU(dev); 788b6e91ebfSAndreas Färber SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev); 789ce5b1bbfSLaurent Vivier Error *local_err = NULL; 79077976769SPhilippe Mathieu-Daudé CPUSPARCState *env = cpu_env(cs); 791247bf011SAndreas Färber 79270054962SIgor Mammedov #if defined(CONFIG_USER_ONLY) 7935f25b383SRichard Henderson /* We are emulating the kernel, which will trap and emulate float128. */ 794576e1c4cSIgor Mammedov env->def.features |= CPU_FEATURE_FLOAT128; 795247bf011SAndreas Färber #endif 796b6e91ebfSAndreas Färber 79770054962SIgor Mammedov env->version = env->def.iu_version; 79870054962SIgor Mammedov env->nwindows = env->def.nwindows; 79970054962SIgor Mammedov #if !defined(TARGET_SPARC64) 80070054962SIgor Mammedov env->mmuregs[0] |= env->def.mmu_version; 80170054962SIgor Mammedov cpu_sparc_set_id(env, 0); 80270054962SIgor Mammedov env->mxccregs[7] |= env->def.mxcc_version; 80370054962SIgor Mammedov #else 80470054962SIgor Mammedov env->mmu_version = env->def.mmu_version; 80570054962SIgor Mammedov env->maxtl = env->def.maxtl; 80670054962SIgor Mammedov env->version |= env->def.maxtl << 8; 80770054962SIgor Mammedov env->version |= env->def.nwindows - 1; 80870054962SIgor Mammedov #endif 80970054962SIgor Mammedov 810ce5b1bbfSLaurent Vivier cpu_exec_realizefn(cs, &local_err); 811ce5b1bbfSLaurent Vivier if (local_err != NULL) { 812ce5b1bbfSLaurent Vivier error_propagate(errp, local_err); 813ce5b1bbfSLaurent Vivier return; 814ce5b1bbfSLaurent Vivier } 815ce5b1bbfSLaurent Vivier 816ce5b1bbfSLaurent Vivier qemu_init_vcpu(cs); 81714a10fc3SAndreas Färber 818b6e91ebfSAndreas Färber scc->parent_realize(dev, errp); 819b6e91ebfSAndreas Färber } 820b6e91ebfSAndreas Färber 821ab7ab3d7SAndreas Färber static void sparc_cpu_initfn(Object *obj) 822ab7ab3d7SAndreas Färber { 823ab7ab3d7SAndreas Färber SPARCCPU *cpu = SPARC_CPU(obj); 82412a6c15eSIgor Mammedov SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj); 825ab7ab3d7SAndreas Färber CPUSPARCState *env = &cpu->env; 826ab7ab3d7SAndreas Färber 827576e1c4cSIgor Mammedov if (scc->cpu_def) { 828576e1c4cSIgor Mammedov env->def = *scc->cpu_def; 829ab7ab3d7SAndreas Färber } 830ab7ab3d7SAndreas Färber } 831ab7ab3d7SAndreas Färber 832de05005bSIgor Mammedov static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, 833de05005bSIgor Mammedov void *opaque, Error **errp) 834de05005bSIgor Mammedov { 835de05005bSIgor Mammedov SPARCCPU *cpu = SPARC_CPU(obj); 836de05005bSIgor Mammedov int64_t value = cpu->env.def.nwindows; 837de05005bSIgor Mammedov 838de05005bSIgor Mammedov visit_type_int(v, name, &value, errp); 839de05005bSIgor Mammedov } 840de05005bSIgor Mammedov 841de05005bSIgor Mammedov static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, 842de05005bSIgor Mammedov void *opaque, Error **errp) 843de05005bSIgor Mammedov { 844de05005bSIgor Mammedov const int64_t min = MIN_NWINDOWS; 845de05005bSIgor Mammedov const int64_t max = MAX_NWINDOWS; 846de05005bSIgor Mammedov SPARCCPU *cpu = SPARC_CPU(obj); 847de05005bSIgor Mammedov int64_t value; 848de05005bSIgor Mammedov 849668f62ecSMarkus Armbruster if (!visit_type_int(v, name, &value, errp)) { 850de05005bSIgor Mammedov return; 851de05005bSIgor Mammedov } 852de05005bSIgor Mammedov 853de05005bSIgor Mammedov if (value < min || value > max) { 854de05005bSIgor Mammedov error_setg(errp, "Property %s.%s doesn't take value %" PRId64 855de05005bSIgor Mammedov " (minimum: %" PRId64 ", maximum: %" PRId64 ")", 856de05005bSIgor Mammedov object_get_typename(obj), name ? name : "null", 857de05005bSIgor Mammedov value, min, max); 858de05005bSIgor Mammedov return; 859de05005bSIgor Mammedov } 860de05005bSIgor Mammedov cpu->env.def.nwindows = value; 861de05005bSIgor Mammedov } 862de05005bSIgor Mammedov 863de05005bSIgor Mammedov static PropertyInfo qdev_prop_nwindows = { 864de05005bSIgor Mammedov .name = "int", 865de05005bSIgor Mammedov .get = sparc_get_nwindows, 866de05005bSIgor Mammedov .set = sparc_set_nwindows, 867de05005bSIgor Mammedov }; 868de05005bSIgor Mammedov 869de1f5203SRichard Henderson /* This must match feature_name[]. */ 870de05005bSIgor Mammedov static Property sparc_cpu_properties[] = { 871de1f5203SRichard Henderson DEFINE_PROP_BIT("float128", SPARCCPU, env.def.features, 872de1f5203SRichard Henderson CPU_FEATURE_BIT_FLOAT128, false), 873554abe47SRichard Henderson #ifdef TARGET_SPARC64 874de1f5203SRichard Henderson DEFINE_PROP_BIT("cmt", SPARCCPU, env.def.features, 875de1f5203SRichard Henderson CPU_FEATURE_BIT_CMT, false), 876de1f5203SRichard Henderson DEFINE_PROP_BIT("gl", SPARCCPU, env.def.features, 877de1f5203SRichard Henderson CPU_FEATURE_BIT_GL, false), 878554abe47SRichard Henderson DEFINE_PROP_BIT("hypv", SPARCCPU, env.def.features, 879554abe47SRichard Henderson CPU_FEATURE_BIT_HYPV, false), 880554abe47SRichard Henderson DEFINE_PROP_BIT("vis1", SPARCCPU, env.def.features, 881554abe47SRichard Henderson CPU_FEATURE_BIT_VIS1, false), 882554abe47SRichard Henderson DEFINE_PROP_BIT("vis2", SPARCCPU, env.def.features, 883554abe47SRichard Henderson CPU_FEATURE_BIT_VIS2, false), 8844fd71d19SRichard Henderson DEFINE_PROP_BIT("fmaf", SPARCCPU, env.def.features, 8854fd71d19SRichard Henderson CPU_FEATURE_BIT_FMAF, false), 886deadbb14SRichard Henderson DEFINE_PROP_BIT("vis3", SPARCCPU, env.def.features, 887deadbb14SRichard Henderson CPU_FEATURE_BIT_VIS3, false), 88868a414e9SRichard Henderson DEFINE_PROP_BIT("ima", SPARCCPU, env.def.features, 88968a414e9SRichard Henderson CPU_FEATURE_BIT_IMA, false), 890b12b7227SRichard Henderson DEFINE_PROP_BIT("vis4", SPARCCPU, env.def.features, 891b12b7227SRichard Henderson CPU_FEATURE_BIT_VIS4, false), 892554abe47SRichard Henderson #else 893554abe47SRichard Henderson DEFINE_PROP_BIT("mul", SPARCCPU, env.def.features, 894554abe47SRichard Henderson CPU_FEATURE_BIT_MUL, false), 895554abe47SRichard Henderson DEFINE_PROP_BIT("div", SPARCCPU, env.def.features, 896554abe47SRichard Henderson CPU_FEATURE_BIT_DIV, false), 897554abe47SRichard Henderson DEFINE_PROP_BIT("fsmuld", SPARCCPU, env.def.features, 898554abe47SRichard Henderson CPU_FEATURE_BIT_FSMULD, false), 899554abe47SRichard Henderson #endif 900de05005bSIgor Mammedov DEFINE_PROP_UNSIGNED("iu-version", SPARCCPU, env.def.iu_version, 0, 901de05005bSIgor Mammedov qdev_prop_uint64, target_ulong), 902de05005bSIgor Mammedov DEFINE_PROP_UINT32("fpu-version", SPARCCPU, env.def.fpu_version, 0), 903de05005bSIgor Mammedov DEFINE_PROP_UINT32("mmu-version", SPARCCPU, env.def.mmu_version, 0), 90443b6ab4cSEduardo Habkost DEFINE_PROP("nwindows", SPARCCPU, env.def.nwindows, 90543b6ab4cSEduardo Habkost qdev_prop_nwindows, uint32_t), 906de05005bSIgor Mammedov DEFINE_PROP_END_OF_LIST() 907de05005bSIgor Mammedov }; 908de05005bSIgor Mammedov 9098b80bd28SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY 9108b80bd28SPhilippe Mathieu-Daudé #include "hw/core/sysemu-cpu-ops.h" 9118b80bd28SPhilippe Mathieu-Daudé 9128b80bd28SPhilippe Mathieu-Daudé static const struct SysemuCPUOps sparc_sysemu_ops = { 91308928c6dSPhilippe Mathieu-Daudé .get_phys_page_debug = sparc_cpu_get_phys_page_debug, 914feece4d0SPhilippe Mathieu-Daudé .legacy_vmsd = &vmstate_sparc_cpu, 9158b80bd28SPhilippe Mathieu-Daudé }; 9168b80bd28SPhilippe Mathieu-Daudé #endif 9178b80bd28SPhilippe Mathieu-Daudé 91878271684SClaudio Fontana #ifdef CONFIG_TCG 91978271684SClaudio Fontana #include "hw/core/tcg-cpu-ops.h" 92078271684SClaudio Fontana 9211764ad70SRichard Henderson static const TCGCPUOps sparc_tcg_ops = { 92278271684SClaudio Fontana .initialize = sparc_tcg_init, 92378271684SClaudio Fontana .synchronize_from_tb = sparc_cpu_synchronize_from_tb, 924f36aaa53SRichard Henderson .restore_state_to_opc = sparc_restore_state_to_opc, 92578271684SClaudio Fontana 92678271684SClaudio Fontana #ifndef CONFIG_USER_ONLY 927caac44a5SRichard Henderson .tlb_fill = sparc_cpu_tlb_fill, 928798ac8b5SPhilippe Mathieu-Daudé .cpu_exec_interrupt = sparc_cpu_exec_interrupt, 9294f7b1ecbSPeter Maydell .cpu_exec_halt = sparc_cpu_has_work, 93078271684SClaudio Fontana .do_interrupt = sparc_cpu_do_interrupt, 93178271684SClaudio Fontana .do_transaction_failed = sparc_cpu_do_transaction_failed, 93278271684SClaudio Fontana .do_unaligned_access = sparc_cpu_do_unaligned_access, 93378271684SClaudio Fontana #endif /* !CONFIG_USER_ONLY */ 93478271684SClaudio Fontana }; 93578271684SClaudio Fontana #endif /* CONFIG_TCG */ 93678271684SClaudio Fontana 937ab7ab3d7SAndreas Färber static void sparc_cpu_class_init(ObjectClass *oc, void *data) 938ab7ab3d7SAndreas Färber { 939ab7ab3d7SAndreas Färber SPARCCPUClass *scc = SPARC_CPU_CLASS(oc); 940ab7ab3d7SAndreas Färber CPUClass *cc = CPU_CLASS(oc); 941b6e91ebfSAndreas Färber DeviceClass *dc = DEVICE_CLASS(oc); 9423b4fff1bSPeter Maydell ResettableClass *rc = RESETTABLE_CLASS(oc); 943b6e91ebfSAndreas Färber 944bf853881SPhilippe Mathieu-Daudé device_class_set_parent_realize(dc, sparc_cpu_realizefn, 945bf853881SPhilippe Mathieu-Daudé &scc->parent_realize); 9464f67d30bSMarc-André Lureau device_class_set_props(dc, sparc_cpu_properties); 947ab7ab3d7SAndreas Färber 9483b4fff1bSPeter Maydell resettable_class_set_parent_phases(rc, NULL, sparc_cpu_reset_hold, NULL, 9493b4fff1bSPeter Maydell &scc->parent_phases); 95097a8ea5aSAndreas Färber 95112a6c15eSIgor Mammedov cc->class_by_name = sparc_cpu_class_by_name; 952d1853231SIgor Mammedov cc->parse_features = sparc_cpu_parse_features; 9538c2e1b00SAndreas Färber cc->has_work = sparc_cpu_has_work; 954e3547a7dSRichard Henderson cc->mmu_index = sparc_cpu_mmu_index; 955878096eeSAndreas Färber cc->dump_state = sparc_cpu_dump_state; 956f3659eeeSAndreas Färber #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) 957f3659eeeSAndreas Färber cc->memory_rw_debug = sparc_cpu_memory_rw_debug; 958f3659eeeSAndreas Färber #endif 959f45748f1SAndreas Färber cc->set_pc = sparc_cpu_set_pc; 960e4fdf9dfSRichard Henderson cc->get_pc = sparc_cpu_get_pc; 9615b50e790SAndreas Färber cc->gdb_read_register = sparc_cpu_gdb_read_register; 9625b50e790SAndreas Färber cc->gdb_write_register = sparc_cpu_gdb_write_register; 963e84942f2SRichard Henderson #ifndef CONFIG_USER_ONLY 9648b80bd28SPhilippe Mathieu-Daudé cc->sysemu_ops = &sparc_sysemu_ops; 96500b941e5SAndreas Färber #endif 966df0900ebSPeter Crosthwaite cc->disas_set_info = cpu_sparc_disas_set_info; 967a0e372f0SAndreas Färber 968a0e372f0SAndreas Färber #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) 969a0e372f0SAndreas Färber cc->gdb_num_core_regs = 86; 970a0e372f0SAndreas Färber #else 971a0e372f0SAndreas Färber cc->gdb_num_core_regs = 72; 972a0e372f0SAndreas Färber #endif 97378271684SClaudio Fontana cc->tcg_ops = &sparc_tcg_ops; 974ab7ab3d7SAndreas Färber } 975ab7ab3d7SAndreas Färber 976ab7ab3d7SAndreas Färber static const TypeInfo sparc_cpu_type_info = { 977ab7ab3d7SAndreas Färber .name = TYPE_SPARC_CPU, 978ab7ab3d7SAndreas Färber .parent = TYPE_CPU, 979ab7ab3d7SAndreas Färber .instance_size = sizeof(SPARCCPU), 980f669c992SRichard Henderson .instance_align = __alignof(SPARCCPU), 981ab7ab3d7SAndreas Färber .instance_init = sparc_cpu_initfn, 98212a6c15eSIgor Mammedov .abstract = true, 983ab7ab3d7SAndreas Färber .class_size = sizeof(SPARCCPUClass), 984ab7ab3d7SAndreas Färber .class_init = sparc_cpu_class_init, 985ab7ab3d7SAndreas Färber }; 986ab7ab3d7SAndreas Färber 98712a6c15eSIgor Mammedov static void sparc_cpu_cpudef_class_init(ObjectClass *oc, void *data) 98812a6c15eSIgor Mammedov { 98912a6c15eSIgor Mammedov SPARCCPUClass *scc = SPARC_CPU_CLASS(oc); 99012a6c15eSIgor Mammedov scc->cpu_def = data; 99112a6c15eSIgor Mammedov } 99212a6c15eSIgor Mammedov 99312a6c15eSIgor Mammedov static void sparc_register_cpudef_type(const struct sparc_def_t *def) 99412a6c15eSIgor Mammedov { 99512a6c15eSIgor Mammedov char *typename = sparc_cpu_type_name(def->name); 99612a6c15eSIgor Mammedov TypeInfo ti = { 99712a6c15eSIgor Mammedov .name = typename, 99812a6c15eSIgor Mammedov .parent = TYPE_SPARC_CPU, 99912a6c15eSIgor Mammedov .class_init = sparc_cpu_cpudef_class_init, 100012a6c15eSIgor Mammedov .class_data = (void *)def, 100112a6c15eSIgor Mammedov }; 100212a6c15eSIgor Mammedov 100312a6c15eSIgor Mammedov type_register(&ti); 100412a6c15eSIgor Mammedov g_free(typename); 100512a6c15eSIgor Mammedov } 100612a6c15eSIgor Mammedov 1007ab7ab3d7SAndreas Färber static void sparc_cpu_register_types(void) 1008ab7ab3d7SAndreas Färber { 100912a6c15eSIgor Mammedov int i; 101012a6c15eSIgor Mammedov 1011ab7ab3d7SAndreas Färber type_register_static(&sparc_cpu_type_info); 101212a6c15eSIgor Mammedov for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { 101312a6c15eSIgor Mammedov sparc_register_cpudef_type(&sparc_defs[i]); 101412a6c15eSIgor Mammedov } 1015ab7ab3d7SAndreas Färber } 1016ab7ab3d7SAndreas Färber 1017ab7ab3d7SAndreas Färber type_init(sparc_cpu_register_types) 1018