diff options
Diffstat (limited to 'target-ppc')
-rw-r--r-- | target-ppc/cpu.h | 11 | ||||
-rw-r--r-- | target-ppc/helper.c | 12 | ||||
-rw-r--r-- | target-ppc/translate_init.c | 32 |
3 files changed, 25 insertions, 30 deletions
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 939dbcd982..7fcdd4121f 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -675,7 +675,7 @@ struct mmu_ctx_t { }; /*****************************************************************************/ -CPUPPCState *cpu_ppc_init (void); +CPUPPCState *cpu_ppc_init (const char *cpu_model); int cpu_ppc_exec (CPUPPCState *s); void cpu_ppc_close (CPUPPCState *s); /* you can call this signal handler from your SIGBUS and SIGSEGV @@ -719,13 +719,12 @@ void ppc_store_xer (CPUPPCState *env, target_ulong value); void ppc_store_msr (CPUPPCState *env, target_ulong value); void cpu_ppc_reset (void *opaque); -CPUPPCState *cpu_ppc_init (void); -void cpu_ppc_close(CPUPPCState *env); -int ppc_find_by_name (const unsigned char *name, ppc_def_t **def); -int ppc_find_by_pvr (uint32_t apvr, ppc_def_t **def); void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); -int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def); + +const ppc_def_t *cpu_ppc_find_by_name (const unsigned char *name); +const ppc_def_t *cpu_ppc_find_by_pvr (uint32_t pvr); +int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def); /* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS diff --git a/target-ppc/helper.c b/target-ppc/helper.c index 9fd9721cde..f7df19e1c0 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -2970,20 +2970,26 @@ void cpu_ppc_reset (void *opaque) tlb_flush(env, 1); } -CPUPPCState *cpu_ppc_init (void) +CPUPPCState *cpu_ppc_init (const char *cpu_model) { CPUPPCState *env; + const ppc_def_t *def; + + def = cpu_ppc_find_by_name(cpu_model); + if (!def) + return NULL; env = qemu_mallocz(sizeof(CPUPPCState)); if (!env) return NULL; cpu_exec_init(env); - + cpu_ppc_register_internal(env, def); + cpu_ppc_reset(env); return env; } void cpu_ppc_close (CPUPPCState *env) { /* Should also remove all opcode tables... */ - free(env); + qemu_free(env); } diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index eae228b26a..973e0c5db0 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -5931,7 +5931,7 @@ static ppc_def_t ppc_defs[] = { /*****************************************************************************/ /* Generic CPU instanciation routine */ -static void init_ppc_proc (CPUPPCState *env, ppc_def_t *def) +static void init_ppc_proc (CPUPPCState *env, const ppc_def_t *def) { #if !defined(CONFIG_USER_ONLY) int i; @@ -6276,7 +6276,7 @@ static void fix_opcode_tables (opc_handler_t **ppc_opcodes) } /*****************************************************************************/ -static int create_ppc_opcodes (CPUPPCState *env, ppc_def_t *def) +static int create_ppc_opcodes (CPUPPCState *env, const ppc_def_t *def) { opcode_t *opc, *start, *end; @@ -6351,7 +6351,7 @@ static void dump_ppc_insns (CPUPPCState *env) } #endif -int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) +int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def) { env->msr_mask = def->msr_mask; env->mmu_model = def->mmu_model; @@ -6514,41 +6514,31 @@ int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) return 0; } -int ppc_find_by_name (const unsigned char *name, ppc_def_t **def) +const ppc_def_t *cpu_ppc_find_by_name (const unsigned char *name) { - int i, max, ret; + int i, max; - ret = -1; - *def = NULL; max = sizeof(ppc_defs) / sizeof(ppc_def_t); for (i = 0; i < max; i++) { if (strcasecmp(name, ppc_defs[i].name) == 0) { - *def = &ppc_defs[i]; - ret = 0; - break; + return &ppc_defs[i]; } } - - return ret; + return NULL; } -int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def) +const ppc_def_t *cpu_ppc_find_by_pvr (uint32_t pvr) { - int i, max, ret; + int i, max; - ret = -1; - *def = NULL; max = sizeof(ppc_defs) / sizeof(ppc_def_t); for (i = 0; i < max; i++) { if ((pvr & ppc_defs[i].pvr_mask) == (ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) { - *def = &ppc_defs[i]; - ret = 0; - break; + return &ppc_defs[i]; } } - - return ret; + return NULL; } void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |