On Fri, 16 Mar 2018 12:41:20 -0700 Michael Clark <m...@sifive.com> wrote:
> - Model borrowed from target/sh4/cpu.c > - Rewrote riscv_cpu_list to use object_class_get_list > - Dropped 'struct RISCVCPUInfo' and used TypeInfo array > - Replaced riscv_cpu_register_types with DEFINE_TYPES > - Marked base class as abstract > > Cc: Igor Mammedov <imamm...@redhat.com> > Cc: Sagar Karandikar <sag...@eecs.berkeley.edu> > Cc: Bastian Koppelmann <kbast...@mail.uni-paderborn.de> > Signed-off-by: Palmer Dabbelt <pal...@sifive.com> > Signed-off-by: Michael Clark <m...@sifive.com> > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org> Reviewed-by: Igor Mammedov <imamm...@redhat.com> > --- [...] > -static void riscv_cpu_register_types(void) > +static void riscv_cpu_list_entry(gpointer data, gpointer user_data) > { > - const RISCVCPUInfo *info = riscv_cpus; > + RISCVCPUListState *s = user_data; > + const char *typename = object_class_get_name(OBJECT_CLASS(data)); > + int len = strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX); This also fixes "-cpu" output, before this patch: # qemu-system-riscv32 -cpu help any-riscv-cpu rv32gcsu-v1.9.1-riscv-cpu rv32gcsu-v1.10.0-riscv-cpu rv32imacu-nommu-riscv-cpu sifive-e31-riscv-cpu sifive-u34-riscv-cpu # qemu-system-riscv32 -cpu rv32gcsu-v1.9.1-riscv-cpu qemu-system-riscv32: unable to find CPU model 'rv32gcsu-v1.9.1-riscv-cpu' after this patch: # qemu-system-riscv32 -cpu help any rv32gcsu-v1.10.0 rv32gcsu-v1.9.1 rv32imacu-nommu sifive-e31 sifive-u34 which cpu model matches conversion rules of riscv_cpu_class_by_name() and matching cpu type is found as expected. > - type_register_static(&riscv_cpu_type_info); > + (*s->cpu_fprintf)(s->file, "%.*s\n", len, typename); > +} [...]