PL050 qdev conversion
authorPaul Brook <paul@codesourcery.com>
Thu, 14 May 2009 21:35:07 +0000 (22:35 +0100)
committerPaul Brook <paul@codesourcery.com>
Thu, 14 May 2009 21:35:07 +0000 (22:35 +0100)
Signed-off-by: Paul Brook <paul@codesourcery.com>
hw/integratorcp.c
hw/pl050.c
hw/primecell.h
hw/realview.c
hw/versatilepb.c

index 3327b5ea8e03beecde86afda7115fd53f698676e..3c7e25ff2064150b59ff39cd89550a81f9c2f349 100644 (file)
@@ -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");
index 0a7ef83a4f024b1db0beab594f05c4f5a7c0664b..1f8878c21e0a792ed52c7c3fbb3dbd17ff56274d 100644 (file)
@@ -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)
index 714fc785ed851c4f69ebd6f4e9ff3a71f672f6d2..08364473e72e2c1fa112736d4d0380d3e5b7c3e5 100644 (file)
@@ -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);
index bbfa56b1c89ef8de50f625f3b02803a86ad14474..3ec8a3cb75d8361837048229b41ab2bc4a6d25a2 100644 (file)
@@ -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]);
index bde07bf4ca63730c0d7407f937d9a1f49176e885..d9e1cfc81e89be57709de6c35667d1b6fb1558f2 100644 (file)
@@ -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,