Statistics
| Branch: | Revision:

root / hw / realview_gic.c @ df0db221

History | View | Annotate | Download (1.9 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 9ee6e8bb pbrook
 * This code is licenced under the GPL.
8 9ee6e8bb pbrook
 */
9 9ee6e8bb pbrook
10 fe7e8758 Paul Brook
#include "sysbus.h"
11 9ee6e8bb pbrook
12 9ee6e8bb pbrook
#define GIC_NIRQ 96
13 9ee6e8bb pbrook
#define NCPU 1
14 9ee6e8bb pbrook
15 9ee6e8bb pbrook
/* Only a single "CPU" interface is present.  */
16 9ee6e8bb pbrook
static inline int
17 9ee6e8bb pbrook
gic_get_current_cpu(void)
18 9ee6e8bb pbrook
{
19 9ee6e8bb pbrook
  return 0;
20 9ee6e8bb pbrook
}
21 9ee6e8bb pbrook
22 9ee6e8bb pbrook
#include "arm_gic.c"
23 9ee6e8bb pbrook
24 fe7e8758 Paul Brook
typedef struct {
25 fe7e8758 Paul Brook
    gic_state gic;
26 fe7e8758 Paul Brook
    int iomemtype;
27 fe7e8758 Paul Brook
} RealViewGICState;
28 fe7e8758 Paul Brook
29 c227f099 Anthony Liguori
static uint32_t realview_gic_cpu_read(void *opaque, target_phys_addr_t offset)
30 9ee6e8bb pbrook
{
31 9ee6e8bb pbrook
    gic_state *s = (gic_state *)opaque;
32 9ee6e8bb pbrook
    return gic_cpu_read(s, gic_get_current_cpu(), offset);
33 9ee6e8bb pbrook
}
34 9ee6e8bb pbrook
35 c227f099 Anthony Liguori
static void realview_gic_cpu_write(void *opaque, target_phys_addr_t offset,
36 9ee6e8bb pbrook
                          uint32_t value)
37 9ee6e8bb pbrook
{
38 9ee6e8bb pbrook
    gic_state *s = (gic_state *)opaque;
39 9ee6e8bb pbrook
    gic_cpu_write(s, gic_get_current_cpu(), offset, value);
40 9ee6e8bb pbrook
}
41 9ee6e8bb pbrook
42 d60efc6b Blue Swirl
static CPUReadMemoryFunc * const realview_gic_cpu_readfn[] = {
43 9ee6e8bb pbrook
   realview_gic_cpu_read,
44 9ee6e8bb pbrook
   realview_gic_cpu_read,
45 9ee6e8bb pbrook
   realview_gic_cpu_read
46 9ee6e8bb pbrook
};
47 9ee6e8bb pbrook
48 d60efc6b Blue Swirl
static CPUWriteMemoryFunc * const realview_gic_cpu_writefn[] = {
49 9ee6e8bb pbrook
   realview_gic_cpu_write,
50 9ee6e8bb pbrook
   realview_gic_cpu_write,
51 9ee6e8bb pbrook
   realview_gic_cpu_write
52 9ee6e8bb pbrook
};
53 9ee6e8bb pbrook
54 c227f099 Anthony Liguori
static void realview_gic_map(SysBusDevice *dev, target_phys_addr_t base)
55 9ee6e8bb pbrook
{
56 fe7e8758 Paul Brook
    RealViewGICState *s = FROM_SYSBUSGIC(RealViewGICState, dev);
57 fe7e8758 Paul Brook
    cpu_register_physical_memory(base, 0x1000, s->iomemtype);
58 fe7e8758 Paul Brook
    cpu_register_physical_memory(base + 0x1000, 0x1000, s->gic.iomemtype);
59 fe7e8758 Paul Brook
}
60 fe7e8758 Paul Brook
61 81a322d4 Gerd Hoffmann
static int realview_gic_init(SysBusDevice *dev)
62 fe7e8758 Paul Brook
{
63 fe7e8758 Paul Brook
    RealViewGICState *s = FROM_SYSBUSGIC(RealViewGICState, dev);
64 9ee6e8bb pbrook
65 fe7e8758 Paul Brook
    gic_init(&s->gic);
66 1eed09cb Avi Kivity
    s->iomemtype = cpu_register_io_memory(realview_gic_cpu_readfn,
67 fe7e8758 Paul Brook
                                          realview_gic_cpu_writefn, s);
68 fe7e8758 Paul Brook
    sysbus_init_mmio_cb(dev, 0x2000, realview_gic_map);
69 81a322d4 Gerd Hoffmann
    return 0;
70 9ee6e8bb pbrook
}
71 fe7e8758 Paul Brook
72 fe7e8758 Paul Brook
static void realview_gic_register_devices(void)
73 fe7e8758 Paul Brook
{
74 fe7e8758 Paul Brook
    sysbus_register_dev("realview_gic", sizeof(RealViewGICState),
75 fe7e8758 Paul Brook
                        realview_gic_init);
76 fe7e8758 Paul Brook
}
77 fe7e8758 Paul Brook
78 fe7e8758 Paul Brook
device_init(realview_gic_register_devices)