~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/arm_gic.c

  • Committer: pbrook
  • Date: 2007-04-07 18:14:41 UTC
  • Revision ID: git-v1:d537cf6c8624b27ce2b63431d2f8937f6356f652
Unify IRQ handling.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2635 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
 
61
61
typedef struct gic_state
62
62
{
63
 
    arm_pic_handler handler;
64
63
    uint32_t base;
65
 
    void *parent;
66
 
    int parent_irq;
 
64
    qemu_irq parent_irq;
67
65
    int enabled;
68
66
    int cpu_enabled;
69
67
 
88
86
 
89
87
    s->current_pending = 1023;
90
88
    if (!s->enabled || !s->cpu_enabled) {
91
 
        pic_set_irq_new(s->parent, s->parent_irq, 0);
 
89
        qemu_irq_lower(s->parent_irq);
92
90
        return;
93
91
    }
94
92
    best_prio = 0x100;
102
100
        }
103
101
    }
104
102
    if (best_prio > s->priority_mask) {
105
 
        pic_set_irq_new(s->parent, s->parent_irq, 0);
 
103
        qemu_irq_lower(s->parent_irq);
106
104
    } else {
107
105
        s->current_pending = best_irq;
108
106
        if (best_prio < s->running_priority) {
109
107
            DPRINTF("Raised pending IRQ %d\n", best_irq);
110
 
            pic_set_irq_new(s->parent, s->parent_irq, 1);
 
108
            qemu_irq_raise(s->parent_irq);
111
109
        }
112
110
    }
113
111
}
150
148
        DPRINTF("ACK no pending IRQ\n");
151
149
        return 1023;
152
150
    }
153
 
    pic_set_irq_new(s->parent, s->parent_irq, 0);
 
151
    qemu_irq_lower(s->parent_irq);
154
152
    s->last_active[new_irq] = s->running_irq;
155
153
    /* For level triggered interrupts we clear the pending bit while
156
154
       the interrupt is active.  */
520
518
    s->cpu_enabled = 0;
521
519
}
522
520
 
523
 
void *arm_gic_init(uint32_t base, void *parent, int parent_irq)
 
521
qemu_irq *arm_gic_init(uint32_t base, qemu_irq parent_irq)
524
522
{
525
523
    gic_state *s;
 
524
    qemu_irq *qi;
526
525
    int iomemtype;
527
526
 
528
527
    s = (gic_state *)qemu_mallocz(sizeof(gic_state));
529
528
    if (!s)
530
529
        return NULL;
531
 
    s->handler = gic_set_irq;
532
 
    s->parent = parent;
 
530
    qi = qemu_allocate_irqs(gic_set_irq, s, GIC_NIRQ);
533
531
    s->parent_irq = parent_irq;
534
532
    if (base != 0xffffffff) {
535
533
        iomemtype = cpu_register_io_memory(0, gic_cpu_readfn,
543
541
        s->base = 0;
544
542
    }
545
543
    gic_reset(s);
546
 
    return s;
 
544
    return qi;
547
545
}