diff options
-rw-r--r-- | hw/integratorcp.c | 4 | ||||
-rw-r--r-- | hw/pl050.c | 35 | ||||
-rw-r--r-- | hw/primecell.h | 3 | ||||
-rw-r--r-- | hw/realview.c | 4 | ||||
-rw-r--r-- | hw/versatilepb.c | 5 |
5 files changed, 34 insertions, 17 deletions
diff --git a/hw/integratorcp.c b/hw/integratorcp.c index 3327b5ea8e..3c7e25ff20 100644 --- a/hw/integratorcp.c +++ b/hw/integratorcp.c @@ -485,8 +485,8 @@ static void integratorcp_init(ram_addr_t ram_size, sysbus_create_simple("pl011", 0x16000000, pic[1]); sysbus_create_simple("pl011", 0x17000000, pic[2]); icp_control_init(0xcb000000); - pl050_init(0x18000000, pic[3], 0); - pl050_init(0x19000000, pic[4], 1); + sysbus_create_simple("pl050_keyboard", 0x18000000, pic[3]); + sysbus_create_simple("pl050_mouse", 0x19000000, pic[4]); sd = drive_get_index(IF_SD, 0, 0); if (sd == -1) { fprintf(stderr, "qemu: missing SecureDigital card\n"); diff --git a/hw/pl050.c b/hw/pl050.c index 0a7ef83a4f..1f8878c21e 100644 --- a/hw/pl050.c +++ b/hw/pl050.c @@ -7,11 +7,11 @@ * This code is licenced under the GPL. */ -#include "hw.h" -#include "primecell.h" +#include "sysbus.h" #include "ps2.h" typedef struct { + SysBusDevice busdev; void *dev; uint32_t cr; uint32_t clk; @@ -122,20 +122,39 @@ static CPUWriteMemoryFunc *pl050_writefn[] = { pl050_write }; -void pl050_init(uint32_t base, qemu_irq irq, int is_mouse) +static void pl050_init(SysBusDevice *dev, int is_mouse) { + pl050_state *s = FROM_SYSBUS(pl050_state, dev); int iomemtype; - pl050_state *s; - s = (pl050_state *)qemu_mallocz(sizeof(pl050_state)); iomemtype = cpu_register_io_memory(0, pl050_readfn, pl050_writefn, s); - cpu_register_physical_memory(base, 0x00001000, iomemtype); - s->irq = irq; + sysbus_init_mmio(dev, 0x1000, iomemtype); + sysbus_init_irq(dev, &s->irq); s->is_mouse = is_mouse; - if (is_mouse) + if (s->is_mouse) s->dev = ps2_mouse_init(pl050_update, s); else s->dev = ps2_kbd_init(pl050_update, s); /* ??? Save/restore. */ } + +static void pl050_init_keyboard(SysBusDevice *dev) +{ + pl050_init(dev, 0); +} + +static void pl050_init_mouse(SysBusDevice *dev) +{ + pl050_init(dev, 1); +} + +static void pl050_register_devices(void) +{ + sysbus_register_dev("pl050_keyboard", sizeof(pl050_state), + pl050_init_keyboard); + sysbus_register_dev("pl050_mouse", sizeof(pl050_state), + pl050_init_mouse); +} + +device_init(pl050_register_devices) diff --git a/hw/primecell.h b/hw/primecell.h index 714fc785ed..08364473e7 100644 --- a/hw/primecell.h +++ b/hw/primecell.h @@ -13,9 +13,6 @@ typedef int (*ssi_xfer_cb)(void *, int); void pl022_init(uint32_t base, qemu_irq irq, ssi_xfer_cb xfer_cb, void *opaque); -/* pl050.c */ -void pl050_init(uint32_t base, qemu_irq irq, int is_mouse); - /* pl061.c */ void pl061_float_high(void *opaque, uint8_t mask); qemu_irq *pl061_init(uint32_t base, qemu_irq irq, qemu_irq **out); diff --git a/hw/realview.c b/hw/realview.c index bbfa56b1c8..3ec8a3cb75 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -82,8 +82,8 @@ static void realview_init(ram_addr_t ram_size, pic = mpcore_irq_init(cpu_irq); } - pl050_init(0x10006000, pic[20], 0); - pl050_init(0x10007000, pic[21], 1); + sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); + sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); diff --git a/hw/versatilepb.c b/hw/versatilepb.c index bde07bf4ca..d9e1cfc81e 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -186,8 +186,9 @@ static void versatile_init(ram_addr_t ram_size, pic = arm_pic_init_cpu(env); pic = pl190_init(0x10140000, pic[0], pic[1]); sic = vpb_sic_init(0x10003000, pic, 31); - pl050_init(0x10006000, sic[3], 0); - pl050_init(0x10007000, sic[4], 1); + + sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]); + sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]); pci_bus = pci_vpb_init(sic, 27, 0); /* The Versatile PCI bridge does not provide access to PCI IO space, |