Support changing cpu model for MIPS
This commit is contained in:
parent
94d952b410
commit
837c3be347
|
@ -150,28 +150,29 @@ static void mips_cpu_class_init(CPUClass *c)
|
|||
cc->tlb_fill = mips_cpu_tlb_fill;
|
||||
}
|
||||
|
||||
MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model)
|
||||
MIPSCPU *cpu_mips_init(struct uc_struct *uc)
|
||||
{
|
||||
MIPSCPU *cpu;
|
||||
CPUState *cs;
|
||||
CPUClass *cc;
|
||||
CPUMIPSState *env;
|
||||
int i;
|
||||
|
||||
if (cpu_model == NULL) {
|
||||
#ifdef TARGET_MIPS64
|
||||
cpu_model = "R4000";
|
||||
#else
|
||||
// Add UC_MODE_ flag to select model?
|
||||
cpu_model = "74Kf";
|
||||
#endif
|
||||
}
|
||||
|
||||
cpu = calloc(1, sizeof(*cpu));
|
||||
if (cpu == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (uc->cpu_model == INT_MAX) {
|
||||
#ifdef TARGET_MIPS64
|
||||
uc->cpu_model = 17; // R4000
|
||||
#else
|
||||
uc->cpu_model = 10; // 74kf
|
||||
#endif
|
||||
} else if (uc->cpu_model >= mips_defs_number) {
|
||||
free(cpu);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cs = (CPUState *)cpu;
|
||||
cc = (CPUClass *)&cpu->cc;
|
||||
cs->cc = cc;
|
||||
|
@ -187,12 +188,8 @@ MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model)
|
|||
mips_cpu_initfn(uc, cs);
|
||||
|
||||
env = &cpu->env;
|
||||
for (i = 0; i < mips_defs_number; i++) {
|
||||
if (strcasecmp(cpu_model, mips_defs[i].name) == 0) {
|
||||
env->cpu_model = &(mips_defs[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
env->cpu_model = &(mips_defs[uc->cpu_model]);
|
||||
|
||||
if (env->cpu_model == NULL) {
|
||||
free(cpu);
|
||||
return NULL;
|
||||
|
|
|
@ -15,7 +15,7 @@ typedef uint64_t mipsreg_t;
|
|||
typedef uint32_t mipsreg_t;
|
||||
#endif
|
||||
|
||||
MIPSCPU *cpu_mips_init(struct uc_struct *uc, const char *cpu_model);
|
||||
MIPSCPU *cpu_mips_init(struct uc_struct *uc);
|
||||
|
||||
static uint64_t mips_mem_redirect(uint64_t address)
|
||||
{
|
||||
|
@ -226,7 +226,7 @@ static int mips_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
|||
{
|
||||
MIPSCPU *cpu;
|
||||
|
||||
cpu = cpu_mips_init(uc, NULL);
|
||||
cpu = cpu_mips_init(uc);
|
||||
if (cpu == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue