Allow to inspect and manipulate MIDR variant and revision fields. Signed-off-by: Andreas Färber <afaer...@suse.de> Cc: Peter Maydell <peter.mayd...@linaro.org> --- target-arm/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 8917a20..ad33742 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -20,6 +20,7 @@ #include "cpu-qom.h" #include "qemu-common.h" +#include "qapi/qapi-visit-core.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" #endif @@ -173,6 +174,46 @@ static inline void unset_class_feature(ARMCPUClass *klass, int feature) klass->features &= ~(1u << feature); } +static void arm_cpuid_variant_get(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + int64_t value = (cpu->env.cp15.c0_cpuid >> 20) & 0xf; + + visit_type_int(v, &value, name, errp); +} + +static void arm_cpuid_variant_set(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + int64_t value; + + visit_type_int(v, &value, name, errp); + cpu->env.cp15.c0_cpuid &= ~(0xf << 20); + cpu->env.cp15.c0_cpuid |= (value << 20) & 0xf; +} + +static void arm_cpuid_revision_get(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + int64_t value = cpu->env.cp15.c0_cpuid & 0xf; + + visit_type_int(v, &value, name, errp); +} + +static void arm_cpuid_revision_set(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + int64_t value; + + visit_type_int(v, &value, name, errp); + cpu->env.cp15.c0_cpuid &= ~0xf; + cpu->env.cp15.c0_cpuid |= value & 0xf; +} + /* CPU models */ typedef struct ARMCPUInfo { @@ -554,6 +595,13 @@ static void arm_cpu_initfn(Object *obj) cpu->env.cp15.c0_cpuid = cpu_class->cp15.c0_cpuid; cpu_reset(CPU(cpu)); + + object_property_add(obj, "cpuid-variant", "uint4", + arm_cpuid_variant_get, + arm_cpuid_variant_set, NULL, NULL, NULL); + object_property_add(obj, "cpuid-revision", "uint4", + arm_cpuid_revision_get, + arm_cpuid_revision_set, NULL, NULL, NULL); } static void arm_cpu_class_init(ObjectClass *klass, void *data) -- 1.7.7