void gic_update(GICState *s)

{

    int best_irq;

    int best_prio;

    int irq;

    int irq_level, fiq_level;

    int cpu;

    int cm;



    for (cpu = 0; cpu < s->num_cpu; cpu++) {

        cm = 1 << cpu;

        s->current_pending[cpu] = 1023;

        if (!(s->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1))

            || !(s->cpu_ctlr[cpu] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) {

            qemu_irq_lower(s->parent_irq[cpu]);

            qemu_irq_lower(s->parent_fiq[cpu]);

            continue;

        }

        best_prio = 0x100;

        best_irq = 1023;

        for (irq = 0; irq < s->num_irq; irq++) {

            if (GIC_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm) &&

                (irq < GIC_INTERNAL || GIC_TARGET(irq) & cm)) {

                if (GIC_GET_PRIORITY(irq, cpu) < best_prio) {

                    best_prio = GIC_GET_PRIORITY(irq, cpu);

                    best_irq = irq;

                }

            }

        }



        if (best_irq != 1023) {

            trace_gic_update_bestirq(cpu, best_irq, best_prio,

                s->priority_mask[cpu], s->running_priority[cpu]);

        }



        irq_level = fiq_level = 0;



        if (best_prio < s->priority_mask[cpu]) {

            s->current_pending[cpu] = best_irq;

            if (best_prio < s->running_priority[cpu]) {

                int group = GIC_TEST_GROUP(best_irq, cm);



                if (extract32(s->ctlr, group, 1) &&

                    extract32(s->cpu_ctlr[cpu], group, 1)) {

                    if (group == 0 && s->cpu_ctlr[cpu] & GICC_CTLR_FIQ_EN) {

                        DPRINTF("Raised pending FIQ %d (cpu %d)\n",

                                best_irq, cpu);

                        fiq_level = 1;


                    } else {

                        DPRINTF("Raised pending IRQ %d (cpu %d)\n",

                                best_irq, cpu);

                        irq_level = 1;


                    }

                }

            }

        }



        qemu_set_irq(s->parent_irq[cpu], irq_level);

        qemu_set_irq(s->parent_fiq[cpu], fiq_level);

    }

}
void gic_update(GICState *s)

{

    int best_irq;

    int best_prio;

    int irq;

    int irq_level, fiq_level;

    int cpu;

    int cm;



    for (cpu = 0; cpu < s->num_cpu; cpu++) {

        cm = 1 << cpu;

        s->current_pending[cpu] = 1023;

        if (!(s->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1))

            || !(s->cpu_ctlr[cpu] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) {

            qemu_irq_lower(s->parent_irq[cpu]);

            qemu_irq_lower(s->parent_fiq[cpu]);

            continue;

        }

        best_prio = 0x100;

        best_irq = 1023;

        for (irq = 0; irq < s->num_irq; irq++) {

            if (GIC_TEST_ENABLED(irq, cm) && gic_test_pending(s, irq, cm) &&

                (irq < GIC_INTERNAL || GIC_TARGET(irq) & cm)) {

                if (GIC_GET_PRIORITY(irq, cpu) < best_prio) {

                    best_prio = GIC_GET_PRIORITY(irq, cpu);

                    best_irq = irq;

                }

            }

        }



        if (best_irq != 1023) {

            trace_gic_update_bestirq(cpu, best_irq, best_prio,

                s->priority_mask[cpu], s->running_priority[cpu]);

        }



        irq_level = fiq_level = 0;



        if (best_prio < s->priority_mask[cpu]) {

            s->current_pending[cpu] = best_irq;

            if (best_prio < s->running_priority[cpu]) {

                int group = GIC_TEST_GROUP(best_irq, cm);



                if (extract32(s->ctlr, group, 1) &&

                    extract32(s->cpu_ctlr[cpu], group, 1)) {

                    if (group == 0 && s->cpu_ctlr[cpu] & GICC_CTLR_FIQ_EN) {

                        DPRINTF("Raised pending FIQ %d (cpu %d)\n",

                                best_irq, cpu);

                        fiq_level = 1;


                    } else {

                        DPRINTF("Raised pending IRQ %d (cpu %d)\n",

                                best_irq, cpu);

                        irq_level = 1;


                    }

                }

            }

        }



        qemu_set_irq(s->parent_irq[cpu], irq_level);

        qemu_set_irq(s->parent_fiq[cpu], fiq_level);

    }

}
void FUNC_0(GICState *VAR_0)

{

    int VAR_1;

    int VAR_2;

    int VAR_3;

    int VAR_4, VAR_5;

    int VAR_6;

    int VAR_7;



    for (VAR_6 = 0; VAR_6 < VAR_0->num_cpu; VAR_6++) {

        VAR_7 = 1 << VAR_6;

        VAR_0->current_pending[VAR_6] = 1023;

        if (!(VAR_0->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1))

            || !(VAR_0->cpu_ctlr[VAR_6] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) {

            qemu_irq_lower(VAR_0->parent_irq[VAR_6]);

            qemu_irq_lower(VAR_0->parent_fiq[VAR_6]);

            continue;

        }

        VAR_2 = 0x100;

        VAR_1 = 1023;

        for (VAR_3 = 0; VAR_3 < VAR_0->num_irq; VAR_3++) {

            if (GIC_TEST_ENABLED(VAR_3, VAR_7) && gic_test_pending(VAR_0, VAR_3, VAR_7) &&

                (VAR_3 < GIC_INTERNAL || GIC_TARGET(VAR_3) & VAR_7)) {

                if (GIC_GET_PRIORITY(VAR_3, VAR_6) < VAR_2) {

                    VAR_2 = GIC_GET_PRIORITY(VAR_3, VAR_6);

                    VAR_1 = VAR_3;

                }

            }

        }



        if (VAR_1 != 1023) {

            trace_gic_update_bestirq(VAR_6, VAR_1, VAR_2,

                VAR_0->priority_mask[VAR_6], VAR_0->running_priority[VAR_6]);

        }



        VAR_4 = VAR_5 = 0;



        if (VAR_2 < VAR_0->priority_mask[VAR_6]) {

            VAR_0->current_pending[VAR_6] = VAR_1;

            if (VAR_2 < VAR_0->running_priority[VAR_6]) {

                int group = GIC_TEST_GROUP(VAR_1, VAR_7);



                if (extract32(VAR_0->ctlr, group, 1) &&

                    extract32(VAR_0->cpu_ctlr[VAR_6], group, 1)) {

                    if (group == 0 && VAR_0->cpu_ctlr[VAR_6] & GICC_CTLR_FIQ_EN) {

                        DPRINTF("Raised pending FIQ %d (VAR_6 %d)\n",

                                VAR_1, VAR_6);

                        VAR_5 = 1;


                    } else {

                        DPRINTF("Raised pending IRQ %d (VAR_6 %d)\n",

                                VAR_1, VAR_6);

                        VAR_4 = 1;


                    }

                }

            }

        }



        qemu_set_irq(VAR_0->parent_irq[VAR_6], VAR_4);

        qemu_set_irq(VAR_0->parent_fiq[VAR_6], VAR_5);

    }

}
void FUNC_0(GICState *VAR_0)
{ int VAR_1; int VAR_2; int VAR_3; int VAR_4, VAR_5; int VAR_6; int VAR_7; for (VAR_6 = 0; VAR_6 < VAR_0->num_cpu; VAR_6++) { VAR_7 = 1 << VAR_6; VAR_0->current_pending[VAR_6] = 1023; if (!(VAR_0->ctlr & (GICD_CTLR_EN_GRP0 | GICD_CTLR_EN_GRP1))
|| !(VAR_0->cpu_ctlr[VAR_6] & (GICC_CTLR_EN_GRP0 | GICC_CTLR_EN_GRP1))) { qemu_irq_lower(VAR_0->parent_irq[VAR_6]); qemu_irq_lower(VAR_0->parent_fiq[VAR_6]); continue; } VAR_2 = 0x100; VAR_1 = 1023; for (VAR_3 = 0; VAR_3 < VAR_0->num_irq; VAR_3++) { if (GIC_TEST_ENABLED(VAR_3, VAR_7) && gic_test_pending(VAR_0, VAR_3, VAR_7) &&
(VAR_3 < GIC_INTERNAL || GIC_TARGET(VAR_3) & VAR_7)) { if (GIC_GET_PRIORITY(VAR_3, VAR_6) < VAR_2) { VAR_2 = GIC_GET_PRIORITY(VAR_3, VAR_6); VAR_1 = VAR_3; } } } if (VAR_1 != 1023) { trace_gic_update_bestirq(VAR_6, VAR_1, VAR_2,
VAR_0->priority_mask[VAR_6], VAR_0->running_priority[VAR_6]); } VAR_4 = VAR_5 = 0; if (VAR_2 < VAR_0->priority_mask[VAR_6]) { VAR_0->current_pending[VAR_6] = VAR_1; if (VAR_2 < VAR_0->running_priority[VAR_6]) { int group = GIC_TEST_GROUP(VAR_1, VAR_7); if (extract32(VAR_0->ctlr, group, 1) &&
extract32(VAR_0->cpu_ctlr[VAR_6], group, 1)) { if (group == 0 && VAR_0->cpu_ctlr[VAR_6] & GICC_CTLR_FIQ_EN) { DPRINTF("Raised pending FIQ %d (VAR_6 %d)\n",
VAR_1, VAR_6); VAR_5 = 1; } else { DPRINTF("Raised pending IRQ %d (VAR_6 %d)\n",
VAR_1, VAR_6); VAR_4 = 1; } } } } qemu_set_irq(VAR_0->parent_irq[VAR_6], VAR_4); qemu_set_irq(VAR_0->parent_fiq[VAR_6], VAR_5); } }