Received: from eggs.gnu.org ([208.118.235.92]:41345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsEnW-0005Ey-UH for qemu-devel@nongnu.org; Mon, 07 Jan 2013 10:39:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsEnO-0007Ej-61 for qemu-devel@nongnu.org; Mon, 07 Jan 2013 10:39:34 -0500 From: Alexander Graf Date: Mon, 7 Jan 2013 16:38:58 +0100 Message-Id: <1357573140-8877-30-git-send-email-agraf@suse.de> In-Reply-To: <1357573140-8877-1-git-send-email-agraf@suse.de> References: <1357573140-8877-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 29/31] target-ppc: Slim conversion of model definitions to QOM subclasses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Blue Swirl , qemu-ppc@nongnu.org, =?utf-8?q?Andreas=20F=C3=A4rber?= , Aurelien Jarno From: Andreas F=C3=A4rber Since the model list is highly macrofied, keep ppc_def_t for now and save a pointer to it in PowerPCCPUClass. This results in a flat list of subclasses including aliases, to be refined later. Move cpu_ppc_init() to translate_init.c and drop helper.c. Long-term the idea is to turn translate_init.c into a standalone cpu.c. Inline cpu_ppc_usable() into type registration. Split cpu_ppc_register() in two by code movement into the initfn and by turning the remaining part into a realizefn. Move qemu_init_vcpu() call into the new realizefn and adapt create_ppc_opcodes() to return an Error. Change ppc_find_by_pvr() -> ppc_cpu_class_by_pvr(). Change ppc_find_by_name() -> ppc_cpu_class_by_name(). Turn -cpu host into its own subclass. This requires to move the kvm_enabled() check in ppc_cpu_class_by_name() to avoid the class being found via the normal name lookup in the !kvm_enabled() case. Turn kvmppc_host_cpu_def() into the class_init and add an initfn that asserts KVM is in fact enabled. Implement -cpu ? and the QMP equivalent in terms of subclasses. This newly exposes -cpu host to the user, ordered last for -cpu ?. Signed-off-by: Andreas F=C3=A4rber Signed-off-by: Alexander Graf --- target-ppc/Makefile.objs | 3 +- target-ppc/cpu-qom.h | 5 + target-ppc/cpu.h | 4 - target-ppc/helper.c | 50 ------ target-ppc/kvm.c | 37 ++++- target-ppc/kvm_ppc.h | 8 +- target-ppc/translate_init.c | 345 +++++++++++++++++++++++++++++--------= ----- 7 files changed, 276 insertions(+), 176 deletions(-) delete mode 100644 target-ppc/helper.c diff --git a/target-ppc/Makefile.objs b/target-ppc/Makefile.objs index 6c11ef8..a028dcd 100644 --- a/target-ppc/Makefile.objs +++ b/target-ppc/Makefile.objs @@ -1,7 +1,6 @@ -obj-y +=3D translate.o helper.o +obj-y +=3D translate.o obj-$(CONFIG_SOFTMMU) +=3D machine.o obj-$(CONFIG_KVM) +=3D kvm.o kvm_ppc.o -obj-y +=3D helper.o obj-y +=3D excp_helper.o obj-y +=3D fpu_helper.o obj-y +=3D int_helper.o diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h index fb6b5a4..b338f8f 100644 --- a/target-ppc/cpu-qom.h +++ b/target-ppc/cpu-qom.h @@ -50,6 +50,9 @@ typedef struct PowerPCCPUClass { /*< public >*/ =20 void (*parent_reset)(CPUState *cpu); + + /* TODO inline fields here */ + ppc_def_t *info; } PowerPCCPUClass; =20 /** @@ -73,5 +76,7 @@ static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *= env) =20 #define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e)) =20 +PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr); + =20 #endif diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index dc5145b..953146e 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1158,10 +1158,6 @@ void ppc_store_msr (CPUPPCState *env, target_ulong= value); =20 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf); =20 -const ppc_def_t *ppc_find_by_pvr(uint32_t pvr); -const ppc_def_t *cpu_ppc_find_by_name (const char *name); -int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def); - /* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS uint64_t cpu_ppc_load_tbl (CPUPPCState *env); diff --git a/target-ppc/helper.c b/target-ppc/helper.c deleted file mode 100644 index 103855a..0000000 --- a/target-ppc/helper.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * PowerPC emulation helpers for QEMU. - * - * Copyright (c) 2003-2007 Jocelyn Mayer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#include "cpu.h" -#include "helper_regs.h" -#include "sysemu/kvm.h" -#include "kvm_ppc.h" -#include "sysemu/cpus.h" - -PowerPCCPU *cpu_ppc_init(const char *cpu_model) -{ - PowerPCCPU *cpu; - CPUPPCState *env; - const ppc_def_t *def; - - def =3D cpu_ppc_find_by_name(cpu_model); - if (!def) { - return NULL; - } - - cpu =3D POWERPC_CPU(object_new(TYPE_POWERPC_CPU)); - env =3D &cpu->env; - - if (tcg_enabled()) { - ppc_translate_init(); - } - - env->cpu_model_str =3D cpu_model; - cpu_ppc_register_internal(env, def); - - qemu_init_vcpu(env); - - return cpu; -} diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 9fe949f..ce7d69b 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1230,18 +1230,29 @@ static void alter_insns(uint64_t *word, uint64_t = flags, bool on) } } =20 -const ppc_def_t *kvmppc_host_cpu_def(void) +static void kvmppc_host_cpu_initfn(Object *obj) { + assert(kvm_enabled()); +} + +static void kvmppc_host_cpu_class_init(ObjectClass *oc, void *data) +{ + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); uint32_t host_pvr =3D mfpvr(); - const ppc_def_t *base_spec; + PowerPCCPUClass *pvr_pcc; ppc_def_t *spec; uint32_t vmx =3D kvmppc_get_vmx(); uint32_t dfp =3D kvmppc_get_dfp(); =20 - base_spec =3D ppc_find_by_pvr(host_pvr); - spec =3D g_malloc0(sizeof(*spec)); - memcpy(spec, base_spec, sizeof(*spec)); + + pvr_pcc =3D ppc_cpu_class_by_pvr(host_pvr); + if (pvr_pcc !=3D NULL) { + memcpy(spec, pvr_pcc->info, sizeof(*spec)); + } + pcc->info =3D spec; + /* Override the display name for -cpu ? and QMP */ + pcc->info->name =3D "host"; =20 /* Now fix up the spec with information we can query from the host *= / =20 @@ -1254,8 +1265,6 @@ const ppc_def_t *kvmppc_host_cpu_def(void) /* Only override when we know what the host supports */ alter_insns(&spec->insns_flags2, PPC2_DFP, dfp); } - - return spec; } =20 int kvmppc_fixup_cpu(CPUPPCState *env) @@ -1285,3 +1294,17 @@ int kvm_arch_on_sigbus(int code, void *addr) { return 1; } + +static const TypeInfo kvm_host_cpu_type_info =3D { + .name =3D TYPE_HOST_POWERPC_CPU, + .parent =3D TYPE_POWERPC_CPU, + .instance_init =3D kvmppc_host_cpu_initfn, + .class_init =3D kvmppc_host_cpu_class_init, +}; + +static void kvm_ppc_register_types(void) +{ + type_register_static(&kvm_host_cpu_type_info); +} + +type_init(kvm_ppc_register_types) diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index dfb4ecf..a57ec6f 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -11,6 +11,8 @@ =20 #include "exec/memory.h" =20 +#define TYPE_HOST_POWERPC_CPU "host-" TYPE_POWERPC_CPU + void kvmppc_init(void); =20 #ifdef CONFIG_KVM @@ -31,7 +33,6 @@ int kvmppc_remove_spapr_tce(void *table, int pfd, uint3= 2_t window_size); int kvmppc_reset_htab(int shift_hint); uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift)= ; #endif /* !CONFIG_USER_ONLY */ -const ppc_def_t *kvmppc_host_cpu_def(void); int kvmppc_fixup_cpu(CPUPPCState *env); =20 #else @@ -116,11 +117,6 @@ static inline int kvmppc_update_sdr1(CPUPPCState *en= v) =20 #endif /* !CONFIG_USER_ONLY */ =20 -static inline const ppc_def_t *kvmppc_host_cpu_def(void) -{ - return NULL; -} - static inline int kvmppc_fixup_cpu(CPUPPCState *env) { return -1; diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index e2eeb87..2b03756 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -9792,8 +9792,11 @@ static void fix_opcode_tables (opc_handler_t **ppc= _opcodes) } =20 /***********************************************************************= ******/ -static int create_ppc_opcodes (CPUPPCState *env, const ppc_def_t *def) +static void create_ppc_opcodes(PowerPCCPU *cpu, Error **errp) { + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + CPUPPCState *env =3D &cpu->env; + const ppc_def_t *def =3D pcc->info; opcode_t *opc; =20 fill_new_table(env->opcodes, 0x40); @@ -9801,18 +9804,16 @@ static int create_ppc_opcodes (CPUPPCState *env, = const ppc_def_t *def) if (((opc->handler.type & def->insns_flags) !=3D 0) || ((opc->handler.type2 & def->insns_flags2) !=3D 0)) { if (register_insn(env->opcodes, opc) < 0) { - printf("*** ERROR initializing PowerPC instruction " - "0x%02x 0x%02x 0x%02x\n", opc->opc1, opc->opc2, - opc->opc3); - return -1; + error_setg(errp, "ERROR initializing PowerPC instruction= " + "0x%02x 0x%02x 0x%02x\n", opc->opc1, opc->opc= 2, + opc->opc3); + return; } } } fix_opcode_tables(env->opcodes); fflush(stdout); fflush(stderr); - - return 0; } =20 #if defined(PPC_DUMP_CPU) @@ -10026,53 +10027,31 @@ static int ppc_fixup_cpu(CPUPPCState *env) return 0; } =20 -int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def) +static void ppc_cpu_realize(Object *obj, Error **errp) { - env->msr_mask =3D def->msr_mask; - env->mmu_model =3D def->mmu_model; - env->excp_model =3D def->excp_model; - env->bus_model =3D def->bus_model; - env->insns_flags =3D def->insns_flags; - env->insns_flags2 =3D def->insns_flags2; - env->flags =3D def->flags; - env->bfd_mach =3D def->bfd_mach; - env->check_pow =3D def->check_pow; - -#if defined(TARGET_PPC64) - if (def->sps) - env->sps =3D *def->sps; - else if (env->mmu_model & POWERPC_MMU_64) { - /* Use default sets of page sizes */ - static const struct ppc_segment_page_sizes defsps =3D { - .sps =3D { - { .page_shift =3D 12, /* 4K */ - .slb_enc =3D 0, - .enc =3D { { .page_shift =3D 12, .pte_enc =3D 0 } } - }, - { .page_shift =3D 24, /* 16M */ - .slb_enc =3D 0x100, - .enc =3D { { .page_shift =3D 24, .pte_enc =3D 0 } } - }, - }, - }; - env->sps =3D defsps; - } -#endif /* defined(TARGET_PPC64) */ + PowerPCCPU *cpu =3D POWERPC_CPU(obj); + CPUPPCState *env =3D &cpu->env; + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); + ppc_def_t *def =3D pcc->info; + Error *local_err =3D NULL; =20 if (kvm_enabled()) { if (kvmppc_fixup_cpu(env) !=3D 0) { - fprintf(stderr, "Unable to virtualize selected CPU with KVM\= n"); - exit(1); + error_setg(errp, "Unable to virtualize selected CPU with KVM= "); + return; } } else { if (ppc_fixup_cpu(env) !=3D 0) { - fprintf(stderr, "Unable to emulate selected CPU with TCG\n")= ; - exit(1); + error_setg(errp, "Unable to emulate selected CPU with TCG"); + return; } } =20 - if (create_ppc_opcodes(env, def) < 0) - return -1; + create_ppc_opcodes(cpu, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } init_ppc_proc(env, def); =20 if (def->insns_flags & PPC_FLOAT) { @@ -10088,6 +10067,8 @@ int cpu_ppc_register_internal (CPUPPCState *env, = const ppc_def_t *def) 34, "power-spe.xml", 0); } =20 + qemu_init_vcpu(env); + #if defined(PPC_DUMP_CPU) { const char *mmu_model, *excp_model, *bus_model; @@ -10249,50 +10230,65 @@ int cpu_ppc_register_internal (CPUPPCState *env= , const ppc_def_t *def) dump_ppc_sprs(env); fflush(stdout); #endif - - return 0; } =20 -static bool ppc_cpu_usable(const ppc_def_t *def) +static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b) { -#if defined(TARGET_PPCEMB) - /* When using the ppcemb target, we only support 440 style cores */ - if (def->mmu_model !=3D POWERPC_MMU_BOOKE) { - return false; + ObjectClass *oc =3D (ObjectClass *)a; + uint32_t pvr =3D *(uint32_t *)b; + PowerPCCPUClass *pcc =3D (PowerPCCPUClass *)a; + + /* -cpu host does a PVR lookup during construction */ + if (unlikely(strcmp(object_class_get_name(oc), + TYPE_HOST_POWERPC_CPU) =3D=3D 0)) { + return -1; } -#endif =20 - return true; + return pcc->info->pvr =3D=3D pvr ? 0 : -1; } =20 -const ppc_def_t *ppc_find_by_pvr(uint32_t pvr) +PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr) { - int i; + GSList *list, *item; + PowerPCCPUClass *pcc =3D NULL; =20 - for (i =3D 0; i < ARRAY_SIZE(ppc_defs); i++) { - if (!ppc_cpu_usable(&ppc_defs[i])) { - continue; - } - - /* If we have an exact match, we're done */ - if (pvr =3D=3D ppc_defs[i].pvr) { - return &ppc_defs[i]; - } + list =3D object_class_get_list(TYPE_POWERPC_CPU, false); + item =3D g_slist_find_custom(list, &pvr, ppc_cpu_compare_class_pvr); + if (item !=3D NULL) { + pcc =3D POWERPC_CPU_CLASS(item->data); } + g_slist_free(list); + + return pcc; +} + +static gint ppc_cpu_compare_class_name(gconstpointer a, gconstpointer b) +{ + ObjectClass *oc =3D (ObjectClass *)a; + const char *name =3D b; =20 - return NULL; + if (strncasecmp(name, object_class_get_name(oc), strlen(name)) =3D=3D= 0 && + strcmp(object_class_get_name(oc) + strlen(name), + "-" TYPE_POWERPC_CPU) =3D=3D 0) { + return 0; + } + return -1; } =20 #include =20 -const ppc_def_t *cpu_ppc_find_by_name (const char *name) +static ObjectClass *ppc_cpu_class_by_name(const char *name) { - const ppc_def_t *ret; + GSList *list, *item; + ObjectClass *ret =3D NULL; const char *p; - int i, max, len; + int i, len; =20 - if (kvm_enabled() && (strcasecmp(name, "host") =3D=3D 0)) { - return kvmppc_host_cpu_def(); + if (strcasecmp(name, "host") =3D=3D 0) { + if (kvm_enabled()) { + ret =3D object_class_by_name(TYPE_HOST_POWERPC_CPU); + } + return ret; } =20 /* Check if the given name is a PVR */ @@ -10307,63 +10303,152 @@ const ppc_def_t *cpu_ppc_find_by_name (const c= har *name) if (!qemu_isxdigit(*p++)) break; } - if (i =3D=3D 8) - return ppc_find_by_pvr(strtoul(name, NULL, 16)); - } - ret =3D NULL; - max =3D ARRAY_SIZE(ppc_defs); - for (i =3D 0; i < max; i++) { - if (!ppc_cpu_usable(&ppc_defs[i])) { - continue; + if (i =3D=3D 8) { + ret =3D OBJECT_CLASS(ppc_cpu_class_by_pvr(strtoul(name, NULL= , 16))); + return ret; } + } =20 - if (strcasecmp(name, ppc_defs[i].name) =3D=3D 0) { - ret =3D &ppc_defs[i]; - break; - } + list =3D object_class_get_list(TYPE_POWERPC_CPU, false); + item =3D g_slist_find_custom(list, name, ppc_cpu_compare_class_name)= ; + if (item !=3D NULL) { + ret =3D OBJECT_CLASS(item->data); } + g_slist_free(list); =20 return ret; } =20 -void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf) +PowerPCCPU *cpu_ppc_init(const char *cpu_model) { - int i, max; + PowerPCCPU *cpu; + CPUPPCState *env; + ObjectClass *oc; + Error *err =3D NULL; =20 - max =3D ARRAY_SIZE(ppc_defs); - for (i =3D 0; i < max; i++) { - if (!ppc_cpu_usable(&ppc_defs[i])) { - continue; - } + oc =3D ppc_cpu_class_by_name(cpu_model); + if (oc =3D=3D NULL) { + return NULL; + } =20 - (*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n", - ppc_defs[i].name, ppc_defs[i].pvr); + cpu =3D POWERPC_CPU(object_new(object_class_get_name(oc))); + env =3D &cpu->env; + + if (tcg_enabled()) { + ppc_translate_init(); } + + env->cpu_model_str =3D cpu_model; + + ppc_cpu_realize(OBJECT(cpu), &err); + if (err !=3D NULL) { + fprintf(stderr, "%s\n", error_get_pretty(err)); + error_free(err); + object_delete(OBJECT(cpu)); + return NULL; + } + + return cpu; +} + +/* Sort by PVR, ordering special case "host" last. */ +static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b) +{ + ObjectClass *oc_a =3D (ObjectClass *)a; + ObjectClass *oc_b =3D (ObjectClass *)b; + PowerPCCPUClass *pcc_a =3D POWERPC_CPU_CLASS(oc_a); + PowerPCCPUClass *pcc_b =3D POWERPC_CPU_CLASS(oc_b); + const char *name_a =3D object_class_get_name(oc_a); + const char *name_b =3D object_class_get_name(oc_b); + + if (strcmp(name_a, TYPE_HOST_POWERPC_CPU) =3D=3D 0) { + return 1; + } else if (strcmp(name_b, TYPE_HOST_POWERPC_CPU) =3D=3D 0) { + return -1; + } else { + /* Avoid an integer overflow during subtraction */ + if (pcc_a->info->pvr < pcc_b->info->pvr) { + return -1; + } else if (pcc_a->info->pvr > pcc_b->info->pvr) { + return 1; + } else { + return 0; + } + } +} + +static void ppc_cpu_list_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CPUListState *s =3D user_data; + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); + + (*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n", + pcc->info->name, pcc->info->pvr); +} + +void ppc_cpu_list(FILE *f, fprintf_function cpu_fprintf) +{ + CPUListState s =3D { + .file =3D f, + .cpu_fprintf =3D cpu_fprintf, + }; + GSList *list; + + list =3D object_class_get_list(TYPE_POWERPC_CPU, false); + list =3D g_slist_sort(list, ppc_cpu_list_compare); + g_slist_foreach(list, ppc_cpu_list_entry, &s); + g_slist_free(list); +} + +static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CpuDefinitionInfoList **first =3D user_data; + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); + CpuDefinitionInfoList *entry; + CpuDefinitionInfo *info; + + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup(pcc->info->name); + + entry =3D g_malloc0(sizeof(*entry)); + entry->value =3D info; + entry->next =3D *first; + *first =3D entry; } =20 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp) { CpuDefinitionInfoList *cpu_list =3D NULL; - int i; + GSList *list; =20 - for (i =3D 0; i < ARRAY_SIZE(ppc_defs); i++) { - CpuDefinitionInfoList *entry; - CpuDefinitionInfo *info; + list =3D object_class_get_list(TYPE_POWERPC_CPU, false); + g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); + g_slist_free(list); =20 - if (!ppc_cpu_usable(&ppc_defs[i])) { - continue; - } + return cpu_list; +} =20 - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strdup(ppc_defs[i].name); +static void ppc_cpu_def_class_init(ObjectClass *oc, void *data) +{ + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); + ppc_def_t *info =3D data; =20 - entry =3D g_malloc0(sizeof(*entry)); - entry->value =3D info; - entry->next =3D cpu_list; - cpu_list =3D entry; - } + pcc->info =3D info; +} =20 - return cpu_list; +static void ppc_cpu_register_model(const ppc_def_t *def) +{ + TypeInfo type_info =3D { + .parent =3D TYPE_POWERPC_CPU, + .class_init =3D ppc_cpu_def_class_init, + .class_data =3D (void *)def, + }; + + type_info.name =3D g_strdup_printf("%s-" TYPE_POWERPC_CPU, def->name= ), + type_register(&type_info); + g_free((gpointer)type_info.name); } =20 /* CPUClass::reset() */ @@ -10434,9 +10519,42 @@ static void ppc_cpu_reset(CPUState *s) static void ppc_cpu_initfn(Object *obj) { PowerPCCPU *cpu =3D POWERPC_CPU(obj); + PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); CPUPPCState *env =3D &cpu->env; + ppc_def_t *def =3D pcc->info; =20 cpu_exec_init(env); + + env->msr_mask =3D def->msr_mask; + env->mmu_model =3D def->mmu_model; + env->excp_model =3D def->excp_model; + env->bus_model =3D def->bus_model; + env->insns_flags =3D def->insns_flags; + env->insns_flags2 =3D def->insns_flags2; + env->flags =3D def->flags; + env->bfd_mach =3D def->bfd_mach; + env->check_pow =3D def->check_pow; + +#if defined(TARGET_PPC64) + if (def->sps) { + env->sps =3D *def->sps; + } else if (env->mmu_model & POWERPC_MMU_64) { + /* Use default sets of page sizes */ + static const struct ppc_segment_page_sizes defsps =3D { + .sps =3D { + { .page_shift =3D 12, /* 4K */ + .slb_enc =3D 0, + .enc =3D { { .page_shift =3D 12, .pte_enc =3D 0 } } + }, + { .page_shift =3D 24, /* 16M */ + .slb_enc =3D 0x100, + .enc =3D { { .page_shift =3D 24, .pte_enc =3D 0 } } + }, + }, + }; + env->sps =3D defsps; + } +#endif /* defined(TARGET_PPC64) */ } =20 static void ppc_cpu_class_init(ObjectClass *oc, void *data) @@ -10453,14 +10571,27 @@ static const TypeInfo ppc_cpu_type_info =3D { .parent =3D TYPE_CPU, .instance_size =3D sizeof(PowerPCCPU), .instance_init =3D ppc_cpu_initfn, - .abstract =3D false, + .abstract =3D true, .class_size =3D sizeof(PowerPCCPUClass), .class_init =3D ppc_cpu_class_init, }; =20 static void ppc_cpu_register_types(void) { + int i; + type_register_static(&ppc_cpu_type_info); + + for (i =3D 0; i < ARRAY_SIZE(ppc_defs); i++) { + const ppc_def_t *def =3D &ppc_defs[i]; +#if defined(TARGET_PPCEMB) + /* When using the ppcemb target, we only support 440 style cores= */ + if (def->mmu_model !=3D POWERPC_MMU_BOOKE) { + continue; + } +#endif + ppc_cpu_register_model(def); + } } =20 type_init(ppc_cpu_register_types) --=20 1.6.0.2