aboutsummaryrefslogtreecommitdiff
path: root/hw/pl031.c
diff options
context:
space:
mode:
authorPaul Brook <paul@codesourcery.com>2009-05-14 22:35:07 +0100
committerPaul Brook <paul@codesourcery.com>2009-05-14 22:35:07 +0100
commita63bdb31026648fef5d4ffb3caafc973c8ced53c (patch)
tree5b285118fb7a701312e7831f703c291cac4d4a96 /hw/pl031.c
parenta5580466257337e74e48124c185e4db9d29325ec (diff)
downloadqemu-a63bdb31026648fef5d4ffb3caafc973c8ced53c.zip
qemu-a63bdb31026648fef5d4ffb3caafc973c8ced53c.tar.gz
qemu-a63bdb31026648fef5d4ffb3caafc973c8ced53c.tar.bz2
PL031 qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/pl031.c')
-rw-r--r--hw/pl031.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/hw/pl031.c b/hw/pl031.c
index 6b27180..11ecf73 100644
--- a/hw/pl031.c
+++ b/hw/pl031.c
@@ -9,8 +9,7 @@
*
*/
-#include "hw.h"
-#include "primecell.h"
+#include "sysbus.h"
#include "qemu-timer.h"
//#define DEBUG_PL031
@@ -32,6 +31,7 @@ do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0)
#define RTC_ICR 0x1c /* Interrupt clear register */
typedef struct {
+ SysBusDevice busdev;
QEMUTimer *timer;
qemu_irq irq;
@@ -183,25 +183,30 @@ static CPUReadMemoryFunc * pl031_readfn[] = {
pl031_read
};
-void pl031_init(uint32_t base, qemu_irq irq)
+static void pl031_init(SysBusDevice *dev)
{
int iomemtype;
- pl031_state *s;
+ pl031_state *s = FROM_SYSBUS(pl031_state, dev);
struct tm tm;
- s = qemu_mallocz(sizeof(pl031_state));
-
iomemtype = cpu_register_io_memory(0, pl031_readfn, pl031_writefn, s);
if (iomemtype == -1) {
hw_error("pl031_init: Can't register I/O memory\n");
}
- cpu_register_physical_memory(base, 0x00001000, iomemtype);
+ sysbus_init_mmio(dev, 0x1000, iomemtype);
- s->irq = irq;
+ sysbus_init_irq(dev, &s->irq);
/* ??? We assume vm_clock is zero at this point. */
qemu_get_timedate(&tm, 0);
s->tick_offset = mktimegm(&tm);
s->timer = qemu_new_timer(vm_clock, pl031_interrupt, s);
}
+
+static void pl031_register_devices(void)
+{
+ sysbus_register_dev("pl031", sizeof(pl031_state), pl031_init);
+}
+
+device_init(pl031_register_devices)