On Tue, 22 Oct 2019 at 17:23, Marc-André Lureau <marcandre.lur...@redhat.com> wrote: > > Split IRQ and memory region initialization in a different function to > be reused by callers that realize the serial device themself, and > connect irq/mem after. > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > hw/char/serial.c | 20 +++++++++++++------- > include/hw/char/serial.h | 3 +++ > 2 files changed, 16 insertions(+), 7 deletions(-) > > diff --git a/hw/char/serial.c b/hw/char/serial.c > index 72d48b5cd8..41548e159c 100644 > --- a/hw/char/serial.c > +++ b/hw/char/serial.c > @@ -1078,27 +1078,33 @@ static const MemoryRegionOps serial_mm_ops[3] = { > }, > }; > > +void serial_mm_connect(SerialMMState *self, enum device_endian end, > + MemoryRegion *address_space, qemu_irq irq) > +{ > + SerialState *s = SERIAL(self); > + > + qdev_connect_gpio_out_named(DEVICE(self), "serial-irq", 0, irq); > + memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], self, > + "serial", 8 << self->regshift); > + memory_region_add_subregion(address_space, s->base, &s->io); > +}
This function isn't needed if you make SerialMMState a sysbus device which provides the MMIO region and the IRQ in the usual way. thanks -- PMM