qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [COMMIT b4496b1] PL080 qdev conversion


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT b4496b1] PL080 qdev conversion
Date: Thu, 14 May 2009 21:41:30 -0000

From: Paul Brook <address@hidden>

Signed-off-by: Paul Brook <address@hidden>

diff --git a/hw/pl080.c b/hw/pl080.c
index d18445b..e43b11d 100644
--- a/hw/pl080.c
+++ b/hw/pl080.c
@@ -7,8 +7,7 @@
  * This code is licenced under the GPL.
  */
 
-#include "hw.h"
-#include "primecell.h"
+#include "sysbus.h"
 
 #define PL080_MAX_CHANNELS 8
 #define PL080_CONF_E    0x1
@@ -37,6 +36,7 @@ typedef struct {
 } pl080_channel;
 
 typedef struct {
+    SysBusDevice busdev;
     uint8_t tc_int;
     uint8_t tc_mask;
     uint8_t err_int;
@@ -319,19 +319,35 @@ static CPUWriteMemoryFunc *pl080_writefn[] = {
    pl080_write
 };
 
-/* The PL080 and PL081 are the same except for the number of channels
-   they implement (8 and 2 respectively).  */
-void *pl080_init(uint32_t base, qemu_irq irq, int nchannels)
+static void pl08x_init(SysBusDevice *dev, int nchannels)
 {
     int iomemtype;
-    pl080_state *s;
+    pl080_state *s = FROM_SYSBUS(pl080_state, dev);
 
-    s = (pl080_state *)qemu_mallocz(sizeof(pl080_state));
     iomemtype = cpu_register_io_memory(0, pl080_readfn,
                                        pl080_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->nchannels = nchannels;
     /* ??? Save/restore.  */
-    return s;
 }
+
+static void pl080_init(SysBusDevice *dev)
+{
+    pl08x_init(dev, 8);
+}
+
+static void pl081_init(SysBusDevice *dev)
+{
+    pl08x_init(dev, 2);
+}
+
+/* The PL080 and PL081 are the same except for the number of channels
+   they implement (8 and 2 respectively).  */
+static void pl080_register_devices(void)
+{
+    sysbus_register_dev("pl080", sizeof(pl080_state), pl080_init);
+    sysbus_register_dev("pl081", sizeof(pl080_state), pl081_init);
+}
+
+device_init(pl080_register_devices)
diff --git a/hw/realview.c b/hw/realview.c
index 24ff3c8..a482487 100644
--- a/hw/realview.c
+++ b/hw/realview.c
@@ -89,7 +89,7 @@ static void realview_init(ram_addr_t ram_size,
     sysbus_create_simple("pl011", 0x1000c000, pic[15]);
 
     /* DMA controller is optional, apparently.  */
-    pl080_init(0x10030000, pic[24], 2);
+    sysbus_create_simple("pl081", 0x10030000, pic[24]);
 
     sysbus_create_simple("sp804", 0x10011000, pic[4]);
     sysbus_create_simple("sp804", 0x10012000, pic[5]);
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 4151119..13a8e19 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -226,7 +226,7 @@ static void versatile_init(ram_addr_t ram_size,
     sysbus_create_simple("pl011", 0x101f3000, pic[14]);
     sysbus_create_simple("pl011", 0x10009000, sic[6]);
 
-    pl080_init(0x10130000, pic[17], 8);
+    sysbus_create_simple("pl080", 0x10130000, pic[17]);
     sysbus_create_simple("sp804", 0x101e2000, pic[4]);
     sysbus_create_simple("sp804", 0x101e3000, pic[5]);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]