Browse Source

riscv_hart: Fix crash when introspecting the device

Use the new object_initialize_child() and sysbus_init_child_obj() to
fix the issue.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Suggested-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael Clark <mjc@sifive.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
pull/73/head
Alistair Francis 8 years ago
parent
commit
5657c3f53c
  1. 7
      hw/riscv/riscv_hart.c

7
hw/riscv/riscv_hart.c

@ -45,11 +45,10 @@ static void riscv_harts_realize(DeviceState *dev, Error **errp)
s->harts = g_new0(RISCVCPU, s->num_harts); s->harts = g_new0(RISCVCPU, s->num_harts);
for (n = 0; n < s->num_harts; n++) { for (n = 0; n < s->num_harts; n++) {
object_initialize_child(OBJECT(s), "harts[*]", &s->harts[n],
object_initialize(&s->harts[n], sizeof(RISCVCPU), s->cpu_type); sizeof(RISCVCPU), s->cpu_type,
&error_abort, NULL);
s->harts[n].env.mhartid = n; s->harts[n].env.mhartid = n;
object_property_add_child(OBJECT(s), "harts[*]", OBJECT(&s->harts[n]),
&error_abort);
qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]); qemu_register_reset(riscv_harts_cpu_reset, &s->harts[n]);
object_property_set_bool(OBJECT(&s->harts[n]), true, object_property_set_bool(OBJECT(&s->harts[n]), true,
"realized", &err); "realized", &err);

Loading…
Cancel
Save