Support changing cpu model for MIPS
This commit is contained in:
@ -150,28 +150,29 @@ static void mips_cpu_class_init(CPUClass *c)
|
|||||||
cc->tlb_fill = mips_cpu_tlb_fill;
|
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;
|
MIPSCPU *cpu;
|
||||||
CPUState *cs;
|
CPUState *cs;
|
||||||
CPUClass *cc;
|
CPUClass *cc;
|
||||||
CPUMIPSState *env;
|
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));
|
cpu = calloc(1, sizeof(*cpu));
|
||||||
if (cpu == NULL) {
|
if (cpu == NULL) {
|
||||||
return 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;
|
cs = (CPUState *)cpu;
|
||||||
cc = (CPUClass *)&cpu->cc;
|
cc = (CPUClass *)&cpu->cc;
|
||||||
cs->cc = 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);
|
mips_cpu_initfn(uc, cs);
|
||||||
|
|
||||||
env = &cpu->env;
|
env = &cpu->env;
|
||||||
for (i = 0; i < mips_defs_number; i++) {
|
env->cpu_model = &(mips_defs[uc->cpu_model]);
|
||||||
if (strcasecmp(cpu_model, mips_defs[i].name) == 0) {
|
|
||||||
env->cpu_model = &(mips_defs[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (env->cpu_model == NULL) {
|
if (env->cpu_model == NULL) {
|
||||||
free(cpu);
|
free(cpu);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -15,7 +15,7 @@ typedef uint64_t mipsreg_t;
|
|||||||
typedef uint32_t mipsreg_t;
|
typedef uint32_t mipsreg_t;
|
||||||
#endif
|
#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)
|
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;
|
MIPSCPU *cpu;
|
||||||
|
|
||||||
cpu = cpu_mips_init(uc, NULL);
|
cpu = cpu_mips_init(uc);
|
||||||
if (cpu == NULL) {
|
if (cpu == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user