diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-10 15:15:54 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-11-10 15:15:54 +0000 |
commit | aaed909a495e78364abc6812df672d2e764961a8 (patch) | |
tree | 704ab4280f250fa310bee6a3d0ba94e5417daef3 /target-mips | |
parent | 7d77bf200682ed8cbd0c94bdfbac64dc4b23b149 (diff) |
added cpu_model parameter to cpu_init()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3562 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-mips')
-rw-r--r-- | target-mips/cpu.h | 6 | ||||
-rw-r--r-- | target-mips/translate.c | 13 | ||||
-rw-r--r-- | target-mips/translate_init.c | 33 |
3 files changed, 23 insertions, 29 deletions
diff --git a/target-mips/cpu.h b/target-mips/cpu.h index 1c850c782b..482f27d1e2 100644 --- a/target-mips/cpu.h +++ b/target-mips/cpu.h @@ -456,7 +456,7 @@ struct CPUMIPSState { CPU_COMMON - mips_def_t *cpu_model; + const mips_def_t *cpu_model; #ifndef CONFIG_USER_ONLY void *irq[8]; #endif @@ -474,9 +474,7 @@ void r4k_do_tlbwi (void); void r4k_do_tlbwr (void); void r4k_do_tlbp (void); void r4k_do_tlbr (void); -int mips_find_by_name (const unsigned char *name, mips_def_t **def); void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); -int cpu_mips_register (CPUMIPSState *env, mips_def_t *def); void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, int unused); @@ -560,7 +558,7 @@ enum { }; int cpu_mips_exec(CPUMIPSState *s); -CPUMIPSState *cpu_mips_init(void); +CPUMIPSState *cpu_mips_init(const char *cpu_model); uint32_t cpu_mips_get_clock (void); int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); diff --git a/target-mips/translate.c b/target-mips/translate.c index 578cd9a25c..ac439d27a1 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -6725,13 +6725,21 @@ void cpu_dump_state (CPUState *env, FILE *f, #endif } -CPUMIPSState *cpu_mips_init (void) +#include "translate_init.c" + +CPUMIPSState *cpu_mips_init (const char *cpu_model) { CPUMIPSState *env; + const mips_def_t *def; + def = cpu_mips_find_by_name(cpu_model); + if (!def) + return NULL; env = qemu_mallocz(sizeof(CPUMIPSState)); if (!env) return NULL; + env->cpu_model = def; + cpu_exec_init(env); cpu_reset(env); return env; @@ -6780,6 +6788,5 @@ void cpu_reset (CPUMIPSState *env) #else env->hflags = MIPS_HFLAG_CP0; #endif + cpu_mips_register(env, env->cpu_model); } - -#include "translate_init.c" diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c index 1302b76caa..44aff7f37c 100644 --- a/target-mips/translate_init.c +++ b/target-mips/translate_init.c @@ -53,7 +53,6 @@ Define a major version 1, minor version 0. */ #define MIPS_FCR0 ((0 << FCR0_S) | (0x1 << FCR0_PRID) | (0x10 << FCR0_REV)) - struct mips_def_t { const unsigned char *name; int32_t CP0_PRid; @@ -300,21 +299,16 @@ static mips_def_t mips_defs[] = #endif }; -int mips_find_by_name (const unsigned char *name, mips_def_t **def) +static const mips_def_t *cpu_mips_find_by_name (const unsigned char *name) { - int i, ret; + int i; - ret = -1; - *def = NULL; for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { if (strcasecmp(name, mips_defs[i].name) == 0) { - *def = &mips_defs[i]; - ret = 0; - break; + return &mips_defs[i]; } } - - return ret; + return NULL; } void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) @@ -328,19 +322,19 @@ void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) } #ifndef CONFIG_USER_ONLY -static void no_mmu_init (CPUMIPSState *env, mips_def_t *def) +static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def) { env->tlb->nb_tlb = 1; env->tlb->map_address = &no_mmu_map_address; } -static void fixed_mmu_init (CPUMIPSState *env, mips_def_t *def) +static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def) { env->tlb->nb_tlb = 1; env->tlb->map_address = &fixed_mmu_map_address; } -static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) +static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def) { env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); env->tlb->map_address = &r4k_map_address; @@ -350,7 +344,7 @@ static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) env->tlb->do_tlbr = r4k_do_tlbr; } -static void mmu_init (CPUMIPSState *env, mips_def_t *def) +static void mmu_init (CPUMIPSState *env, const mips_def_t *def) { env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext)); @@ -376,7 +370,7 @@ static void mmu_init (CPUMIPSState *env, mips_def_t *def) } #endif /* CONFIG_USER_ONLY */ -static void fpu_init (CPUMIPSState *env, mips_def_t *def) +static void fpu_init (CPUMIPSState *env, const mips_def_t *def) { env->fpu = qemu_mallocz(sizeof(CPUMIPSFPUContext)); @@ -389,7 +383,7 @@ static void fpu_init (CPUMIPSState *env, mips_def_t *def) #endif } -static void mvp_init (CPUMIPSState *env, mips_def_t *def) +static void mvp_init (CPUMIPSState *env, const mips_def_t *def) { env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext)); @@ -415,13 +409,8 @@ static void mvp_init (CPUMIPSState *env, mips_def_t *def) (0x1 << CP0MVPC1_PCP1); } -int cpu_mips_register (CPUMIPSState *env, mips_def_t *def) +static int cpu_mips_register (CPUMIPSState *env, const mips_def_t *def) { - if (!def) - def = env->cpu_model; - if (!def) - cpu_abort(env, "Unable to find MIPS CPU definition\n"); - env->cpu_model = def; env->CP0_PRid = def->CP0_PRid; env->CP0_Config0 = def->CP0_Config0; #ifdef TARGET_WORDS_BIGENDIAN |