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