Statistics
| Branch: | Revision:

root / hw / realview_gic.c @ 0dad6c35

History | View | Annotate | Download (1.6 kB)

1 9ee6e8bb pbrook
/*
2 9ee6e8bb pbrook
 * ARM RealView Emulation Baseboard Interrupt Controller
3 9ee6e8bb pbrook
 *
4 9ee6e8bb pbrook
 * Copyright (c) 2006-2007 CodeSourcery.
5 9ee6e8bb pbrook
 * Written by Paul Brook
6 9ee6e8bb pbrook
 *
7 8e31bf38 Matthew Fernandez
 * This code is licensed under the GPL.
8 9ee6e8bb pbrook
 */
9 9ee6e8bb pbrook
10 fe7e8758 Paul Brook
#include "sysbus.h"
11 9ee6e8bb pbrook
12 9ee6e8bb pbrook
#define NCPU 1
13 9ee6e8bb pbrook
14 9ee6e8bb pbrook
/* Only a single "CPU" interface is present.  */
15 9ee6e8bb pbrook
static inline int
16 9ee6e8bb pbrook
gic_get_current_cpu(void)
17 9ee6e8bb pbrook
{
18 9ee6e8bb pbrook
  return 0;
19 9ee6e8bb pbrook
}
20 9ee6e8bb pbrook
21 9ee6e8bb pbrook
#include "arm_gic.c"
22 9ee6e8bb pbrook
23 fe7e8758 Paul Brook
typedef struct {
24 fe7e8758 Paul Brook
    gic_state gic;
25 755c0802 Avi Kivity
    MemoryRegion container;
26 fe7e8758 Paul Brook
} RealViewGICState;
27 fe7e8758 Paul Brook
28 755c0802 Avi Kivity
static void realview_gic_map_setup(RealViewGICState *s)
29 9ee6e8bb pbrook
{
30 755c0802 Avi Kivity
    memory_region_init(&s->container, "realview-gic-container", 0x2000);
31 c3ffa595 Peter Maydell
    memory_region_add_subregion(&s->container, 0, &s->gic.cpuiomem[0]);
32 755c0802 Avi Kivity
    memory_region_add_subregion(&s->container, 0x1000, &s->gic.iomem);
33 fe7e8758 Paul Brook
}
34 fe7e8758 Paul Brook
35 81a322d4 Gerd Hoffmann
static int realview_gic_init(SysBusDevice *dev)
36 fe7e8758 Paul Brook
{
37 fe7e8758 Paul Brook
    RealViewGICState *s = FROM_SYSBUSGIC(RealViewGICState, dev);
38 9ee6e8bb pbrook
39 a32134aa Mark Langsdorf
    /* The GICs on the RealView boards have a fixed nonconfigurable
40 a32134aa Mark Langsdorf
     * number of interrupt lines, so we don't need to expose this as
41 a32134aa Mark Langsdorf
     * a qdev property.
42 a32134aa Mark Langsdorf
     */
43 a32134aa Mark Langsdorf
    gic_init(&s->gic, 96);
44 755c0802 Avi Kivity
    realview_gic_map_setup(s);
45 750ecd44 Avi Kivity
    sysbus_init_mmio(dev, &s->container);
46 81a322d4 Gerd Hoffmann
    return 0;
47 9ee6e8bb pbrook
}
48 fe7e8758 Paul Brook
49 999e12bb Anthony Liguori
static void realview_gic_class_init(ObjectClass *klass, void *data)
50 999e12bb Anthony Liguori
{
51 999e12bb Anthony Liguori
    SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
52 999e12bb Anthony Liguori
53 999e12bb Anthony Liguori
    sdc->init = realview_gic_init;
54 999e12bb Anthony Liguori
}
55 999e12bb Anthony Liguori
56 39bffca2 Anthony Liguori
static TypeInfo realview_gic_info = {
57 39bffca2 Anthony Liguori
    .name          = "realview_gic",
58 39bffca2 Anthony Liguori
    .parent        = TYPE_SYS_BUS_DEVICE,
59 39bffca2 Anthony Liguori
    .instance_size = sizeof(RealViewGICState),
60 39bffca2 Anthony Liguori
    .class_init    = realview_gic_class_init,
61 999e12bb Anthony Liguori
};
62 999e12bb Anthony Liguori
63 fe7e8758 Paul Brook
static void realview_gic_register_devices(void)
64 fe7e8758 Paul Brook
{
65 39bffca2 Anthony Liguori
    type_register_static(&realview_gic_info);
66 fe7e8758 Paul Brook
}
67 fe7e8758 Paul Brook
68 fe7e8758 Paul Brook
device_init(realview_gic_register_devices)