diff options
author | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-05-14 22:35:08 +0100 |
commit | fe7e8758d0abfb6953b5e4f5a1af17ea1598a2bb (patch) | |
tree | 9d38d14611581f6902436e66fd92dab79ef13b5c /hw/arm_gic.c | |
parent | 0027b06d0ef6450a52f96827d303865d7333b196 (diff) |
ARM GIC qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
Diffstat (limited to 'hw/arm_gic.c')
-rw-r--r-- | hw/arm_gic.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/hw/arm_gic.c b/hw/arm_gic.c index cb774d6e20..5dc9448360 100644 --- a/hw/arm_gic.c +++ b/hw/arm_gic.c @@ -32,6 +32,9 @@ static const uint8_t gic_id[] = #define GIC_BASE_IRQ 0 #endif +#define FROM_SYSBUSGIC(type, dev) \ + DO_UPCAST(type, gic, FROM_SYSBUS(gic_state, dev)) + typedef struct gic_irq_state { /* ??? The documentation seems to imply the enable bits are global, even @@ -74,6 +77,7 @@ typedef struct gic_irq_state typedef struct gic_state { + SysBusDevice busdev; qemu_irq parent_irq[NCPU]; int enabled; int cpu_enabled[NCPU]; @@ -91,10 +95,7 @@ typedef struct gic_state int running_priority[NCPU]; int current_pending[NCPU]; - qemu_irq *in; -#ifdef NVIC - void *nvic; -#endif + int iomemtype; } gic_state; /* TODO: Many places that call this routine could be optimized. */ @@ -363,7 +364,7 @@ static uint32_t gic_dist_readl(void *opaque, target_phys_addr_t offset) uint32_t addr; addr = offset; if (addr < 0x100 || addr > 0xd00) - return nvic_readl(s->nvic, addr); + return nvic_readl(s, addr); #endif val = gic_dist_readw(opaque, offset); val |= gic_dist_readw(opaque, offset + 2) << 16; @@ -523,7 +524,7 @@ static void gic_dist_writel(void *opaque, target_phys_addr_t offset, uint32_t addr; addr = offset; if (addr < 0x100 || (addr > 0xd00 && addr != 0xf00)) { - nvic_writel(s->nvic, addr, value); + nvic_writel(s, addr, value); return; } #endif @@ -716,22 +717,16 @@ static int gic_load(QEMUFile *f, void *opaque, int version_id) return 0; } -static gic_state *gic_init(uint32_t dist_base, qemu_irq *parent_irq) +static void gic_init(gic_state *s) { - gic_state *s; - int iomemtype; int i; - s = (gic_state *)qemu_mallocz(sizeof(gic_state)); - s->in = qemu_allocate_irqs(gic_set_irq, s, GIC_NIRQ); + qdev_init_irq_sink(&s->busdev.qdev, gic_set_irq, GIC_NIRQ - 32); for (i = 0; i < NCPU; i++) { - s->parent_irq[i] = parent_irq[i]; + sysbus_init_irq(&s->busdev, &s->parent_irq[i]); } - iomemtype = cpu_register_io_memory(0, gic_dist_readfn, - gic_dist_writefn, s); - cpu_register_physical_memory(dist_base, 0x00001000, - iomemtype); + s->iomemtype = cpu_register_io_memory(0, gic_dist_readfn, + gic_dist_writefn, s); gic_reset(s); register_savevm("arm_gic", -1, 1, gic_save, gic_load, s); - return s; } |