Annotation of qemu/hw/realview_gic.c, revision 1.1.1.8

1.1       root        1: /*
                      2:  * ARM RealView Emulation Baseboard Interrupt Controller
                      3:  *
                      4:  * Copyright (c) 2006-2007 CodeSourcery.
                      5:  * Written by Paul Brook
                      6:  *
1.1.1.6   root        7:  * This code is licensed under the GPL.
1.1       root        8:  */
                      9: 
1.1.1.3   root       10: #include "sysbus.h"
1.1       root       11: 
1.1.1.3   root       12: typedef struct {
1.1.1.8 ! root       13:     SysBusDevice busdev;
        !            14:     DeviceState *gic;
1.1.1.7   root       15:     MemoryRegion container;
1.1.1.3   root       16: } RealViewGICState;
                     17: 
1.1.1.8 ! root       18: static void realview_gic_set_irq(void *opaque, int irq, int level)
1.1       root       19: {
1.1.1.8 ! root       20:     RealViewGICState *s = (RealViewGICState *)opaque;
        !            21:     qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
1.1       root       22: }
                     23: 
1.1.1.8 ! root       24: static int realview_gic_init(SysBusDevice *dev)
1.1       root       25: {
1.1.1.8 ! root       26:     RealViewGICState *s = FROM_SYSBUS(RealViewGICState, dev);
        !            27:     SysBusDevice *busdev;
        !            28:     /* The GICs on the RealView boards have a fixed nonconfigurable
        !            29:      * number of interrupt lines, so we don't need to expose this as
        !            30:      * a qdev property.
        !            31:      */
        !            32:     int numirq = 96;
        !            33: 
        !            34:     s->gic = qdev_create(NULL, "arm_gic");
        !            35:     qdev_prop_set_uint32(s->gic, "num-cpu", 1);
        !            36:     qdev_prop_set_uint32(s->gic, "num-irq", numirq);
        !            37:     qdev_init_nofail(s->gic);
        !            38:     busdev = sysbus_from_qdev(s->gic);
1.1       root       39: 
1.1.1.8 ! root       40:     /* Pass through outbound IRQ lines from the GIC */
        !            41:     sysbus_pass_irq(dev, busdev);
        !            42: 
        !            43:     /* Pass through inbound GPIO lines to the GIC */
        !            44:     qdev_init_gpio_in(&s->busdev.qdev, realview_gic_set_irq, numirq - 32);
1.1       root       45: 
1.1.1.7   root       46:     memory_region_init(&s->container, "realview-gic-container", 0x2000);
1.1.1.8 ! root       47:     memory_region_add_subregion(&s->container, 0,
        !            48:                                 sysbus_mmio_get_region(busdev, 1));
        !            49:     memory_region_add_subregion(&s->container, 0x1000,
        !            50:                                 sysbus_mmio_get_region(busdev, 0));
        !            51:     sysbus_init_mmio(dev, &s->container);
        !            52:     return 0;
1.1.1.3   root       53: }
                     54: 
1.1.1.8 ! root       55: static void realview_gic_class_init(ObjectClass *klass, void *data)
1.1.1.3   root       56: {
1.1.1.8 ! root       57:     SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
1.1       root       58: 
1.1.1.8 ! root       59:     sdc->init = realview_gic_init;
1.1       root       60: }
1.1.1.3   root       61: 
1.1.1.8 ! root       62: static TypeInfo realview_gic_info = {
        !            63:     .name          = "realview_gic",
        !            64:     .parent        = TYPE_SYS_BUS_DEVICE,
        !            65:     .instance_size = sizeof(RealViewGICState),
        !            66:     .class_init    = realview_gic_class_init,
        !            67: };
        !            68: 
        !            69: static void realview_gic_register_types(void)
1.1.1.3   root       70: {
1.1.1.8 ! root       71:     type_register_static(&realview_gic_info);
1.1.1.3   root       72: }
                     73: 
1.1.1.8 ! root       74: type_init(realview_gic_register_types)

unix.superglobalmegacorp.com