hw/ppc/prep_systemio: Remove &first_cpu and fix IRQ use
cover hw/ppc/prep_systemio: Remove &first_cpu and fix IRQ use
- Pass the CPU from machine as LINK property and remove one &first_cpu use.
- Call qemu_set_irq() in ResetExit handler, not in Realize.
Philippe Mathieu-Daudé (2):
hw/ppc/prep_systemio: Use link property to remove &first_cpu hw/ppc/prep_systemio: Set IOMap IRQ in ResetExit() handler
hw/ppc/prep.c | 2 ++ hw/ppc/prep_systemio.c | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
2.47.1
PATCH 1/2 hw/ppc/prep_systemio: Use link property to remove &first_cpu
In order to avoid using the &first_cpu global, pass the CPU as link property from the 40p MachineClass::init().
Declare the link type as TYPE_POWERPC_CPU to have the CPU type checked automatically.
--- hw/ppc/prep.c | 2 ++ hw/ppc/prep_systemio.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-)
hw/ppc/prep.c +2 -0
@@ -324,6 +324,8 @@ static void ibm_40p_init(MachineState *machine) dev =DEVICE (isa_dev);qdev_prop_set_uint32 (dev,"ibm-planar-id" ,0xfc );qdev_prop_set_uint32 (dev,"equipment" ,0xc0 ); +object_property_set_link (OBJECT (dev),"cpu" , +OBJECT (cpu), &error_fatal);isa_realize_and_unref (isa_dev, isa_bus, &error_fatal); dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(1, 0),
hw/ppc/prep_systemio.c +5 -3
@@ -44,7 +44,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(PrepSystemIoState, PREP_SYSTEMIO)struct PrepSystemIoState {ISADevice parent_obj; +MemoryRegion ppc_parity_mem; +CPUState *cpu;qemu_irq non_contiguous_io_map_irq;uint8_t sreset;/* 0x0092 */
@@ -255,14 +257,12 @@ static void prep_systemio_realize(DeviceState *dev, Error **errp) {ISADevice *isa =ISA_DEVICE (dev);PrepSystemIoState *s =PREP_SYSTEMIO (dev); -PowerPCCPU *cpu;qdev_init_gpio_out (dev, &s->non_contiguous_io_map_irq,1 ); s->iomap_type =PORT0850_IOMAP_NONCONTIGUOUS ;qemu_set_irq (s->non_contiguous_io_map_irq, s->iomap_type &PORT0850_IOMAP_NONCONTIGUOUS ); - cpu =POWERPC_CPU (first_cpu); - s->softreset_irq =qdev_get_gpio_in (DEVICE (cpu), PPC6xx_INPUT_HRESET); + s->softreset_irq =qdev_get_gpio_in (DEVICE (s->cpu), PPC6xx_INPUT_HRESET);isa_register_portio_list (isa, &s->portio,0x0 , ppc_io800_port_list, s,"systemio800" );
@@ -288,6 +288,8 @@ static const VMStateDescription vmstate_prep_systemio = {static const Property prep_systemio_properties[] = {DEFINE_PROP_UINT8 ("ibm-planar-id" , PrepSystemIoState, ibm_planar_id,0 ),DEFINE_PROP_UINT8 ("equipment" , PrepSystemIoState, equipment,0 ), +DEFINE_PROP_LINK ("cpu" , PrepSystemIoState, cpu, + TYPE_POWERPC_CPU, CPUState *), };static void prep_systemio_class_initfn (ObjectClass *klass,void *data)
Signature · 1 line
2.47.1
PATCH 2/2 hw/ppc/prep_systemio: Set IOMap IRQ in ResetExit() handler
In reply to Philippe Mathieu-DaudéSince the IOMap output IRQ is created in prep_systemio_realize(), it can not yet be wired before the device is realized, thus it is not reset properly. Fix by moving the qemu_set_irq() call in the ResetExit handler.
--- hw/ppc/prep_systemio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/ppc/prep_systemio.c +10 -2
@@ -260,8 +260,6 @@ static void prep_systemio_realize(DeviceState *dev, Error **errp)qdev_init_gpio_out (dev, &s->non_contiguous_io_map_irq,1 ); s->iomap_type =PORT0850_IOMAP_NONCONTIGUOUS ; -qemu_set_irq (s->non_contiguous_io_map_irq, - s->iomap_type &PORT0850_IOMAP_NONCONTIGUOUS ); s->softreset_irq =qdev_get_gpio_in (DEVICE (s->cpu), PPC6xx_INPUT_HRESET); isa_register_portio_list(isa, &s->portio, 0x0, ppc_io800_port_list, s,
@@ -273,6 +271,14 @@ static void prep_systemio_realize(DeviceState *dev, Error **errp) &s->ppc_parity_mem); } +static void prep_systemio_reset_exit (Object *obj,ResetType type) +{ +PrepSystemIoState *s =PREP_SYSTEMIO (obj); + +qemu_set_irq (s->non_contiguous_io_map_irq, + s->iomap_type &PORT0850_IOMAP_NONCONTIGUOUS ); +} +static const VMStateDescription vmstate_prep_systemio = { .name ="prep_systemio" , .version_id =1 ,
@@ -295,10 +301,12 @@ static const Property prep_systemio_properties[] = {static void prep_systemio_class_initfn (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass); +ResettableClass *rc =RESETTABLE_CLASS (klass); dc->realize = prep_systemio_realize; dc->vmsd = &vmstate_prep_systemio;device_class_set_props (dc, prep_systemio_properties); + rc->phases.exit = prep_systemio_reset_exit; }static const TypeInfo prep_systemio800_info = {
Signature · 1 line
2.47.1