Message ID | 20240208181245.96617-11-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw: Strengthen SysBus & QBus API | expand |
On Thu, 8 Feb 2024 at 18:14, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Inline cpu_create() in order to call > qdev_init_gpio_in_named_with_opaque() > before the CPU is realized. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/sparc/leon3.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c > index 0df5fc949d..0e1d749306 100644 > --- a/hw/sparc/leon3.c > +++ b/hw/sparc/leon3.c > @@ -234,8 +234,11 @@ static void leon3_generic_hw_init(MachineState *machine) > APBPnp *apb_pnp; > > /* Init CPU */ > - cpu = SPARC_CPU(cpu_create(machine->cpu_type)); > + cpu = SPARC_CPU(object_new(machine->cpu_type)); > env = &cpu->env; > + qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in, > + env, "pil", 1); > + qdev_realize(DEVICE(cpu), NULL, &error_fatal); Reviewed-by: Peter Maydell <peter.maydell@linaro.org> with a similar caveat as with the sparc64.c patch. thanks -- PMM
On 08/02/2024 18:12, Philippe Mathieu-Daudé wrote: > Inline cpu_create() in order to call > qdev_init_gpio_in_named_with_opaque() > before the CPU is realized. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > hw/sparc/leon3.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c > index 0df5fc949d..0e1d749306 100644 > --- a/hw/sparc/leon3.c > +++ b/hw/sparc/leon3.c > @@ -234,8 +234,11 @@ static void leon3_generic_hw_init(MachineState *machine) > APBPnp *apb_pnp; > > /* Init CPU */ > - cpu = SPARC_CPU(cpu_create(machine->cpu_type)); > + cpu = SPARC_CPU(object_new(machine->cpu_type)); > env = &cpu->env; > + qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in, > + env, "pil", 1); > + qdev_realize(DEVICE(cpu), NULL, &error_fatal); I know it's not part of this patch, but I think that qdev_init_gpio_in_named_with_opaque() can be replaced with just qdev_init_gpio_in_named(), and leon3_set_pil_in() updated to take CPUState. > cpu_sparc_set_id(env, 0); > > @@ -261,8 +264,6 @@ static void leon3_generic_hw_init(MachineState *machine) > > /* Allocate IRQ manager */ > irqmpdev = qdev_new(TYPE_GRLIB_IRQMP); > - qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in, > - env, "pil", 1); > sysbus_realize_and_unref(SYS_BUS_DEVICE(irqmpdev), &error_fatal); > sysbus_mmio_map(SYS_BUS_DEVICE(irqmpdev), 0, LEON3_IRQMP_OFFSET); > qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0, Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> ATB, Mark.
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 0df5fc949d..0e1d749306 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -234,8 +234,11 @@ static void leon3_generic_hw_init(MachineState *machine) APBPnp *apb_pnp; /* Init CPU */ - cpu = SPARC_CPU(cpu_create(machine->cpu_type)); + cpu = SPARC_CPU(object_new(machine->cpu_type)); env = &cpu->env; + qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in, + env, "pil", 1); + qdev_realize(DEVICE(cpu), NULL, &error_fatal); cpu_sparc_set_id(env, 0); @@ -261,8 +264,6 @@ static void leon3_generic_hw_init(MachineState *machine) /* Allocate IRQ manager */ irqmpdev = qdev_new(TYPE_GRLIB_IRQMP); - qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in, - env, "pil", 1); sysbus_realize_and_unref(SYS_BUS_DEVICE(irqmpdev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(irqmpdev), 0, LEON3_IRQMP_OFFSET); qdev_connect_gpio_out_named(irqmpdev, "grlib-irq", 0,
Inline cpu_create() in order to call qdev_init_gpio_in_named_with_opaque() before the CPU is realized. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/sparc/leon3.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)