hw/arm_gic: Make the GIC its own sysbus device
[qemu/kevin.git] / hw / realview_gic.c
bloba3b5a0472bc8ae59dc54618b6d5138b026a05d29
1 /*
2 * ARM RealView Emulation Baseboard Interrupt Controller
4 * Copyright (c) 2006-2007 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the GPL.
8 */
10 #include "sysbus.h"
12 #define LEGACY_INCLUDED_GIC
13 #include "arm_gic.c"
15 typedef struct {
16 gic_state gic;
17 MemoryRegion container;
18 } RealViewGICState;
20 static void realview_gic_map_setup(RealViewGICState *s)
22 memory_region_init(&s->container, "realview-gic-container", 0x2000);
23 memory_region_add_subregion(&s->container, 0, &s->gic.cpuiomem[0]);
24 memory_region_add_subregion(&s->container, 0x1000, &s->gic.iomem);
27 static int realview_gic_init(SysBusDevice *dev)
29 RealViewGICState *s = FROM_SYSBUSGIC(RealViewGICState, dev);
31 /* The GICs on the RealView boards have a fixed nonconfigurable
32 * number of interrupt lines, so we don't need to expose this as
33 * a qdev property.
35 gic_init(&s->gic, 1, 96);
36 realview_gic_map_setup(s);
37 sysbus_init_mmio(dev, &s->container);
38 return 0;
41 static void realview_gic_class_init(ObjectClass *klass, void *data)
43 SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
45 sdc->init = realview_gic_init;
48 static TypeInfo realview_gic_info = {
49 .name = "realview_gic",
50 .parent = TYPE_SYS_BUS_DEVICE,
51 .instance_size = sizeof(RealViewGICState),
52 .class_init = realview_gic_class_init,
55 static void realview_gic_register_types(void)
57 type_register_static(&realview_gic_info);
60 type_init(realview_gic_register_types)