On 31/05/2023 16:00, Markus Armbruster wrote:

Philippe Mathieu-Daudé <phi...@linaro.org> writes:

On 31/5/23 14:53, Mark Cave-Ayland wrote:
Also change the instantiation of the CPU to use object_initialize_child()
followed by a separate realisation.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
---
   hw/m68k/q800.c         | 13 ++++++++-----
   include/hw/m68k/q800.h |  2 ++
   2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 3730b30dd1..c34b2548ca 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -364,7 +364,7 @@ static uint8_t fake_mac_rom[] = {
     static void q800_machine_init(MachineState *machine)
   {
-    M68kCPU *cpu = NULL;
+    Q800MachineState *m = Q800_MACHINE(machine);
       int linux_boot;
       int32_t kernel_size;
       uint64_t elf_entry;
@@ -407,8 +407,10 @@ static void q800_machine_init(MachineState *machine)
       }
         /* init CPUs */
-    cpu = M68K_CPU(cpu_create(machine->cpu_type));
-    qemu_register_reset(main_cpu_reset, cpu);
+    object_initialize_child(OBJECT(machine), "cpu", &m->cpu,
+                            M68K_CPU_TYPE_NAME("m68040"));
+    object_property_set_bool(OBJECT(&m->cpu), "realized", true, &error_fatal);

CPUs are QDev-based, shouldn't we use qdev_realize()?

Yes, we should.

[...]

Interesting. I remember thinking that CPUs were different, so I'm fairly sure I borrowed this from some similar code in hw/arm :)

Shouldn't the above be directly equivalent to qdev_realize(dev, NULL, &error_fatal) given that the CPU doesn't connect to a bus?


ATB,

Mark.


Reply via email to