static void pl061_write(void *opaque, target_phys_addr_t offset,

                        uint32_t value)

{

    pl061_state *s = (pl061_state *)opaque;

    uint8_t mask;



    if (offset < 0x400) {

        mask = (offset >> 2) & s->dir;

        s->data = (s->data & ~mask) | (value & mask);

        pl061_update(s);

        return;

    }

    switch (offset) {

    case 0x400: /* Direction */

        s->dir = value;

        break;

    case 0x404: /* Interrupt sense */

        s->isense = value;

        break;

    case 0x408: /* Interrupt both edges */

        s->ibe = value;

        break;

    case 0x40c: /* Interrupt event */

        s->iev = value;

        break;

    case 0x410: /* Interrupt mask */

        s->im = value;

        break;

    case 0x41c: /* Interrupt clear */

        s->istate &= ~value;

        break;

    case 0x420: /* Alternate function select */

        mask = s->cr;

        s->afsel = (s->afsel & ~mask) | (value & mask);

        break;

    case 0x500: /* 2mA drive */

        s->dr2r = value;

        break;

    case 0x504: /* 4mA drive */

        s->dr4r = value;

        break;

    case 0x508: /* 8mA drive */

        s->dr8r = value;

        break;

    case 0x50c: /* Open drain */

        s->odr = value;

        break;

    case 0x510: /* Pull-up */

        s->pur = value;

        break;

    case 0x514: /* Pull-down */

        s->pdr = value;

        break;

    case 0x518: /* Slew rate control */

        s->slr = value;

        break;

    case 0x51c: /* Digital enable */

        s->den = value;

        break;

    case 0x520: /* Lock */

        s->locked = (value != 0xacce551);

        break;

    case 0x524: /* Commit */

        if (!s->locked)

            s->cr = value;

        break;

    default:

        hw_error("pl061_write: Bad offset %x\n", (int)offset);

    }

    pl061_update(s);

}

static void pl061_write(void *opaque, target_phys_addr_t offset,

                        uint32_t value)

{

    pl061_state *s = (pl061_state *)opaque;

    uint8_t mask;



    if (offset < 0x400) {

        mask = (offset >> 2) & s->dir;

        s->data = (s->data & ~mask) | (value & mask);

        pl061_update(s);

        return;

    }

    switch (offset) {

    case 0x400: 

        s->dir = value;

        break;

    case 0x404: 

        s->isense = value;

        break;

    case 0x408: 

        s->ibe = value;

        break;

    case 0x40c: 

        s->iev = value;

        break;

    case 0x410: 

        s->im = value;

        break;

    case 0x41c: 

        s->istate &= ~value;

        break;

    case 0x420: 

        mask = s->cr;

        s->afsel = (s->afsel & ~mask) | (value & mask);

        break;

    case 0x500: 

        s->dr2r = value;

        break;

    case 0x504: 

        s->dr4r = value;

        break;

    case 0x508: 

        s->dr8r = value;

        break;

    case 0x50c: 

        s->odr = value;

        break;

    case 0x510: 

        s->pur = value;

        break;

    case 0x514: 

        s->pdr = value;

        break;

    case 0x518: 

        s->slr = value;

        break;

    case 0x51c: 

        s->den = value;

        break;

    case 0x520: 

        s->locked = (value != 0xacce551);

        break;

    case 0x524: 

        if (!s->locked)

            s->cr = value;

        break;

    default:

        hw_error("pl061_write: Bad offset %x\n", (int)offset);

    }

    pl061_update(s);

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,

                        uint32_t VAR_2)

{

    pl061_state *s = (pl061_state *)VAR_0;

    uint8_t mask;



    if (VAR_1 < 0x400) {

        mask = (VAR_1 >> 2) & s->dir;

        s->data = (s->data & ~mask) | (VAR_2 & mask);

        pl061_update(s);

        return;

    }

    switch (VAR_1) {

    case 0x400: 

        s->dir = VAR_2;

        break;

    case 0x404: 

        s->isense = VAR_2;

        break;

    case 0x408: 

        s->ibe = VAR_2;

        break;

    case 0x40c: 

        s->iev = VAR_2;

        break;

    case 0x410: 

        s->im = VAR_2;

        break;

    case 0x41c: 

        s->istate &= ~VAR_2;

        break;

    case 0x420: 

        mask = s->cr;

        s->afsel = (s->afsel & ~mask) | (VAR_2 & mask);

        break;

    case 0x500: 

        s->dr2r = VAR_2;

        break;

    case 0x504: 

        s->dr4r = VAR_2;

        break;

    case 0x508: 

        s->dr8r = VAR_2;

        break;

    case 0x50c: 

        s->odr = VAR_2;

        break;

    case 0x510: 

        s->pur = VAR_2;

        break;

    case 0x514: 

        s->pdr = VAR_2;

        break;

    case 0x518: 

        s->slr = VAR_2;

        break;

    case 0x51c: 

        s->den = VAR_2;

        break;

    case 0x520: 

        s->locked = (VAR_2 != 0xacce551);

        break;

    case 0x524: 

        if (!s->locked)

            s->cr = VAR_2;

        break;

    default:

        hw_error("FUNC_0: Bad VAR_1 %x\n", (int)VAR_1);

    }

    pl061_update(s);

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{ pl061_state *s = (pl061_state *)VAR_0; uint8_t mask; if (VAR_1 < 0x400) { mask = (VAR_1 >> 2) & s->dir; s->data = (s->data & ~mask) | (VAR_2 & mask); pl061_update(s); return; } switch (VAR_1) { case 0x400:
s->dir = VAR_2; break; case 0x404:
s->isense = VAR_2; break; case 0x408:
s->ibe = VAR_2; break; case 0x40c:
s->iev = VAR_2; break; case 0x410:
s->im = VAR_2; break; case 0x41c:
s->istate &= ~VAR_2; break; case 0x420:
mask = s->cr; s->afsel = (s->afsel & ~mask) | (VAR_2 & mask); break; case 0x500:
s->dr2r = VAR_2; break; case 0x504:
s->dr4r = VAR_2; break; case 0x508:
s->dr8r = VAR_2; break; case 0x50c:
s->odr = VAR_2; break; case 0x510:
s->pur = VAR_2; break; case 0x514:
s->pdr = VAR_2; break; case 0x518:
s->slr = VAR_2; break; case 0x51c:
s->den = VAR_2; break; case 0x520:
s->locked = (VAR_2 != 0xacce551); break; case 0x524:
if (!s->locked)
s->cr = VAR_2; break; default:
hw_error("FUNC_0: Bad VAR_1 %x\n", (int)VAR_1); } pl061_update(s); }