Message ID | 20220522181836.864-27-mark.cave-ayland@ilande.co.uk |
---|---|
State | New |
Headers | show |
Series | PS2 device QOMification - part 1 | expand |
On Sun, 22 May 2022 at 19:19, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > > This enables use to expose the register memory region of the I8042_MMIO device > using sysbus_init_mmio(). > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> > --- > hw/input/pckbd.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c > index addd1f058a..c407c082e2 100644 > --- a/hw/input/pckbd.c > +++ b/hw/input/pckbd.c > @@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp) > "i8042", s->size); > } > > +static void i8042_mmio_init(Object *obj) > +{ > + MMIOKBDState *s = I8042_MMIO(obj); > + > + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region); > +} You don't initialize s->region until your device realize function; you should only call sysbus_init_mmio() after that, so this line belongs in the realize function too. thanks -- PMM
On 09/06/2022 11:53, Peter Maydell wrote: > On Sun, 22 May 2022 at 19:19, Mark Cave-Ayland > <mark.cave-ayland@ilande.co.uk> wrote: >> >> This enables use to expose the register memory region of the I8042_MMIO device >> using sysbus_init_mmio(). >> >> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> >> --- >> hw/input/pckbd.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c >> index addd1f058a..c407c082e2 100644 >> --- a/hw/input/pckbd.c >> +++ b/hw/input/pckbd.c >> @@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp) >> "i8042", s->size); >> } >> >> +static void i8042_mmio_init(Object *obj) >> +{ >> + MMIOKBDState *s = I8042_MMIO(obj); >> + >> + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region); >> +} > > You don't initialize s->region until your device realize function; > you should only call sysbus_init_mmio() after that, so this line > belongs in the realize function too. Yes indeed, I can fix this fairly easily. ATB, Mark.
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index addd1f058a..c407c082e2 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -683,6 +683,13 @@ static void i8042_mmio_realize(DeviceState *dev, Error **errp) "i8042", s->size); } +static void i8042_mmio_init(Object *obj) +{ + MMIOKBDState *s = I8042_MMIO(obj); + + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->region); +} + static Property i8042_mmio_properties[] = { DEFINE_PROP_UINT64("mask", MMIOKBDState, kbd.mask, UINT64_MAX), DEFINE_PROP_UINT32("size", MMIOKBDState, size, -1), @@ -726,6 +733,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, static const TypeInfo i8042_mmio_info = { .name = TYPE_I8042_MMIO, .parent = TYPE_SYS_BUS_DEVICE, + .instance_init = i8042_mmio_init, .instance_size = sizeof(MMIOKBDState), .class_init = i8042_mmio_class_init };
This enables use to expose the register memory region of the I8042_MMIO device using sysbus_init_mmio(). Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> --- hw/input/pckbd.c | 8 ++++++++ 1 file changed, 8 insertions(+)