static void update_sr (AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new_sr)

{

    int event = 0;

    int level = 0;

    uint32_t new_mask = new_sr & SR_INT_MASK;

    uint32_t old_mask = r->sr & SR_INT_MASK;

    uint32_t masks[] = {GS_PIINT, GS_POINT, GS_MINT};



    if (new_mask ^ old_mask) {

        /** @todo is IRQ deasserted when only one of status bits is cleared? */

        if (!new_mask) {

            event = 1;

            level = 0;

        }

        else {

            if ((new_mask & SR_LVBCI) && (r->cr & CR_LVBIE)) {

                event = 1;

                level = 1;

            }

            if ((new_mask & SR_BCIS) && (r->cr & CR_IOCE)) {

                event = 1;

                level = 1;

            }

        }

    }



    r->sr = new_sr;



    dolog ("IOC%d LVB%d sr=%#x event=%d level=%d\n",

           r->sr & SR_BCIS, r->sr & SR_LVBCI,

           r->sr,

           event, level);



    if (!event)

        return;



    if (level) {

        s->glob_sta |= masks[r - s->bm_regs];

        dolog ("set irq level=1\n");

        qemu_set_irq (s->pci_dev->irq[0], 1);

    }

    else {

        s->glob_sta &= ~masks[r - s->bm_regs];

        dolog ("set irq level=0\n");

        qemu_set_irq (s->pci_dev->irq[0], 0);

    }

}

static void update_sr (AC97LinkState *s, AC97BusMasterRegs *r, uint32_t new_sr)

{

    int event = 0;

    int level = 0;

    uint32_t new_mask = new_sr & SR_INT_MASK;

    uint32_t old_mask = r->sr & SR_INT_MASK;

    uint32_t masks[] = {GS_PIINT, GS_POINT, GS_MINT};



    if (new_mask ^ old_mask) {

        

        if (!new_mask) {

            event = 1;

            level = 0;

        }

        else {

            if ((new_mask & SR_LVBCI) && (r->cr & CR_LVBIE)) {

                event = 1;

                level = 1;

            }

            if ((new_mask & SR_BCIS) && (r->cr & CR_IOCE)) {

                event = 1;

                level = 1;

            }

        }

    }



    r->sr = new_sr;



    dolog ("IOC%d LVB%d sr=%#x event=%d level=%d\n",

           r->sr & SR_BCIS, r->sr & SR_LVBCI,

           r->sr,

           event, level);



    if (!event)

        return;



    if (level) {

        s->glob_sta |= masks[r - s->bm_regs];

        dolog ("set irq level=1\n");

        qemu_set_irq (s->pci_dev->irq[0], 1);

    }

    else {

        s->glob_sta &= ~masks[r - s->bm_regs];

        dolog ("set irq level=0\n");

        qemu_set_irq (s->pci_dev->irq[0], 0);

    }

}

static void FUNC_0 (AC97LinkState *VAR_0, AC97BusMasterRegs *VAR_1, uint32_t VAR_2)

{

    int VAR_3 = 0;

    int VAR_4 = 0;

    uint32_t new_mask = VAR_2 & SR_INT_MASK;

    uint32_t old_mask = VAR_1->sr & SR_INT_MASK;

    uint32_t masks[] = {GS_PIINT, GS_POINT, GS_MINT};



    if (new_mask ^ old_mask) {

        

        if (!new_mask) {

            VAR_3 = 1;

            VAR_4 = 0;

        }

        else {

            if ((new_mask & SR_LVBCI) && (VAR_1->cr & CR_LVBIE)) {

                VAR_3 = 1;

                VAR_4 = 1;

            }

            if ((new_mask & SR_BCIS) && (VAR_1->cr & CR_IOCE)) {

                VAR_3 = 1;

                VAR_4 = 1;

            }

        }

    }



    VAR_1->sr = VAR_2;



    dolog ("IOC%d LVB%d sr=%#x VAR_3=%d VAR_4=%d\n",

           VAR_1->sr & SR_BCIS, VAR_1->sr & SR_LVBCI,

           VAR_1->sr,

           VAR_3, VAR_4);



    if (!VAR_3)

        return;



    if (VAR_4) {

        VAR_0->glob_sta |= masks[VAR_1 - VAR_0->bm_regs];

        dolog ("set irq VAR_4=1\n");

        qemu_set_irq (VAR_0->pci_dev->irq[0], 1);

    }

    else {

        VAR_0->glob_sta &= ~masks[VAR_1 - VAR_0->bm_regs];

        dolog ("set irq VAR_4=0\n");

        qemu_set_irq (VAR_0->pci_dev->irq[0], 0);

    }

}

static void FUNC_0 (AC97LinkState *VAR_0, AC97BusMasterRegs *VAR_1, uint32_t VAR_2)
{ int VAR_3 = 0; int VAR_4 = 0; uint32_t new_mask = VAR_2 & SR_INT_MASK; uint32_t old_mask = VAR_1->sr & SR_INT_MASK; uint32_t masks[] = {GS_PIINT, GS_POINT, GS_MINT}; if (new_mask ^ old_mask) { if (!new_mask) { VAR_3 = 1; VAR_4 = 0; } else { if ((new_mask & SR_LVBCI) && (VAR_1->cr & CR_LVBIE)) { VAR_3 = 1; VAR_4 = 1; } if ((new_mask & SR_BCIS) && (VAR_1->cr & CR_IOCE)) { VAR_3 = 1; VAR_4 = 1; } } } VAR_1->sr = VAR_2; dolog ("IOC%d LVB%d sr=%#x VAR_3=%d VAR_4=%d\n",
VAR_1->sr & SR_BCIS, VAR_1->sr & SR_LVBCI,
VAR_1->sr,
VAR_3, VAR_4); if (!VAR_3)
return; if (VAR_4) { VAR_0->glob_sta |= masks[VAR_1 - VAR_0->bm_regs]; dolog ("set irq VAR_4=1\n"); qemu_set_irq (VAR_0->pci_dev->irq[0], 1); } else { VAR_0->glob_sta &= ~masks[VAR_1 - VAR_0->bm_regs]; dolog ("set irq VAR_4=0\n"); qemu_set_irq (VAR_0->pci_dev->irq[0], 0); } }