On Mon, 19 Jan 2015 16:30:17 -0600 Greg Bellows <greg.bell...@linaro.org> wrote:
> Adds a CPU feature parsing function and assigns to the CPU class. The only > feature added was "-aarch64" which disabled the AArch64 execution state on a > 64-bit ARM CPU. > > Also adds stripping of features from CPU model string in acquiring the ARM CPU > by name. > > Signed-off-by: Greg Bellows <greg.bell...@linaro.org> > --- > target-arm/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/target-arm/cpu.c b/target-arm/cpu.c > index 285947f..f327dd7 100644 > --- a/target-arm/cpu.c > +++ b/target-arm/cpu.c > @@ -514,13 +514,17 @@ static ObjectClass *arm_cpu_class_by_name(const char > *cpu_model) > { > ObjectClass *oc; > char *typename; > + char *cpuname; > > if (!cpu_model) { > return NULL; > } > > - typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpu_model); > + cpuname = g_strdup(cpu_model); > + cpuname = strtok(cpuname, ","); > + typename = g_strdup_printf("%s-" TYPE_ARM_CPU, cpuname); > oc = object_class_by_name(typename); > + g_free(cpuname); > g_free(typename); > if (!oc || !object_class_dynamic_cast(oc, TYPE_ARM_CPU) || > object_class_is_abstract(oc)) { > @@ -1163,6 +1167,44 @@ static Property arm_cpu_properties[] = { > DEFINE_PROP_END_OF_LIST() > }; > > +static void arm_cpu_parse_features(CPUState *cs, char *features, > + Error **errp) > +{ > + ARMCPU *cpu = ARM_CPU(cs); > + char *featurestr; > + > + featurestr = features ? strtok(features, ",") : NULL; > + while (featurestr) { > + if (featurestr[0] == '-') { ... > + } else if (featurestr[0] == '+') { Please do not use legacy +-feature format and support only foo=val format. Other targets have it only for to being able support legacy setups which use +- format. > + /* Everything else is a bad format */ > + error_setg(errp, "CPU property string '%s' not in format " > + "(+feature|-feature|feature=xyz)", featurestr); > + return; > + } > + featurestr = strtok(NULL, ","); > + } > +} > + > static void arm_cpu_class_init(ObjectClass *oc, void *data) > { > ARMCPUClass *acc = ARM_CPU_CLASS(oc); > @@ -1183,6 +1225,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void > *data) > cc->set_pc = arm_cpu_set_pc; > cc->gdb_read_register = arm_cpu_gdb_read_register; > cc->gdb_write_register = arm_cpu_gdb_write_register; > + cc->parse_features = arm_cpu_parse_features; > #ifdef CONFIG_USER_ONLY > cc->handle_mmu_fault = arm_cpu_handle_mmu_fault; > #else