diff options
Diffstat (limited to 'target-arm')
-rw-r--r-- | target-arm/cpu.h | 2 | ||||
-rw-r--r-- | target-arm/helper.c | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 3208c138b5..b3b37ebbe5 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -209,7 +209,7 @@ static inline int arm_feature(CPUARMState *env, int feature) return (env->features & (1u << feature)) != 0; } -void cpu_arm_set_model(CPUARMState *env, uint32_t id); +void cpu_arm_set_model(CPUARMState *env, const char *name); #define ARM_CPUID_ARM1026 0x4106a262 #define ARM_CPUID_ARM926 0x41069265 diff --git a/target-arm/helper.c b/target-arm/helper.c index 5b4cd13933..093acc9af4 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -36,8 +36,35 @@ static inline void set_feature(CPUARMState *env, int feature) env->features |= 1u << feature; } -void cpu_arm_set_model(CPUARMState *env, uint32_t id) +struct arm_cpu_t { + uint32_t id; + const char *name; +}; + +static const struct arm_cpu_t arm_cpu_names[] = { + { ARM_CPUID_ARM926, "arm926"}, + { ARM_CPUID_ARM1026, "arm1026"}, + { 0, NULL} +}; + +void cpu_arm_set_model(CPUARMState *env, const char *name) { + int i; + uint32_t id; + + id = 0; + i = 0; + for (i = 0; arm_cpu_names[i].name; i++) { + if (strcmp(name, arm_cpu_names[i].name) == 0) { + id = arm_cpu_names[i].id; + break; + } + } + if (!id) { + cpu_abort(env, "Unknown CPU '%s'", name); + return; + } + env->cp15.c0_cpuid = id; switch (id) { case ARM_CPUID_ARM926: |