From 63195aa5a55a885a5c56b7103eb6e698abf2b95a Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:56 +0100 Subject: [PATCH] lasips2: implement lasips2_init() function Move the initialisation of the keyboard and mouse memory regions to lasips2_init() and expose them as SysBus memory regions. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-42-mark.cave-ayland@ilande.co.uk> --- hw/input/lasips2.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c index 85da4081e3..8d3a2d88e8 100644 --- a/hw/input/lasips2.c +++ b/hw/input/lasips2.c @@ -265,20 +265,30 @@ LASIPS2State *lasips2_initfn(MemoryRegion *address_space, s->kbd.dev = ps2_kbd_init(lasips2_port_set_irq, &s->kbd); s->mouse.dev = ps2_mouse_init(lasips2_port_set_irq, &s->mouse); - memory_region_init_io(&s->kbd.reg, NULL, &lasips2_reg_ops, &s->kbd, - "lasips2-kbd", 0x100); memory_region_add_subregion(address_space, base, &s->kbd.reg); - memory_region_init_io(&s->mouse.reg, NULL, &lasips2_reg_ops, &s->mouse, - "lasips2-mouse", 0x100); memory_region_add_subregion(address_space, base + 0x100, &s->mouse.reg); return s; } +static void lasips2_init(Object *obj) +{ + LASIPS2State *s = LASIPS2(obj); + + memory_region_init_io(&s->kbd.reg, obj, &lasips2_reg_ops, &s->kbd, + "lasips2-kbd", 0x100); + memory_region_init_io(&s->mouse.reg, obj, &lasips2_reg_ops, &s->mouse, + "lasips2-mouse", 0x100); + + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->kbd.reg); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mouse.reg); +} + static const TypeInfo lasips2_info = { .name = TYPE_LASIPS2, .parent = TYPE_SYS_BUS_DEVICE, + .instance_init = lasips2_init, .instance_size = sizeof(LASIPS2State) };