Support changing cpu model for m68k

This commit is contained in:
lazymio 2021-11-04 19:16:35 +01:00
parent 172a2fbe6d
commit b0280f5e55
No known key found for this signature in database
GPG Key ID: DFF27E34A47CB873
2 changed files with 11 additions and 14 deletions

View File

@ -259,22 +259,24 @@ static struct M68kCPUInfo m68k_cpus_type_infos[] = {
{ "any", any_cpu_initfn },
};
M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model)
M68kCPU *cpu_m68k_init(struct uc_struct *uc)
{
M68kCPU *cpu;
CPUState *cs;
CPUClass *cc;
int i;
if (cpu_model == NULL) {
cpu_model = "cfv4e";
}
cpu = calloc(1, sizeof(*cpu));
if (cpu == NULL) {
return NULL;
}
if (uc->cpu_model == INT_MAX) {
uc->cpu_model = 7; // cfv4e
} else if (uc->cpu_model >= ARRAY_SIZE(m68k_cpus_type_infos)) {
free(cpu);
return NULL;
}
cs = (CPUState *)cpu;
cc = (CPUClass *)&cpu->cc;
cs->cc = cc;
@ -289,12 +291,7 @@ M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model)
m68k_cpu_initfn(uc, cs);
for (i = 0; i < ARRAY_SIZE(m68k_cpus_type_infos); i++) {
if (strcasecmp(cpu_model, m68k_cpus_type_infos[i].name) == 0) {
m68k_cpus_type_infos[i].initfn(cs);
break;
}
}
m68k_cpus_type_infos[uc->cpu_model].initfn(cs);
m68k_cpu_realizefn(cs);

View File

@ -8,7 +8,7 @@
#include "uc_priv.h"
#include "unicorn.h"
M68kCPU *cpu_m68k_init(struct uc_struct *uc, const char *cpu_model);
M68kCPU *cpu_m68k_init(struct uc_struct *uc);
static void m68k_set_pc(struct uc_struct *uc, uint64_t address)
{
@ -151,7 +151,7 @@ static int m68k_cpus_init(struct uc_struct *uc, const char *cpu_model)
{
M68kCPU *cpu;
cpu = cpu_m68k_init(uc, cpu_model);
cpu = cpu_m68k_init(uc);
if (cpu == NULL) {
return -1;
}