static void ivshmem_io_writel(void *opaque, target_phys_addr_t addr,

                                                            uint32_t val)

{

    IVShmemState *s = opaque;



    uint64_t write_one = 1;

    uint16_t dest = val >> 16;

    uint16_t vector = val & 0xff;



    addr &= 0xfc;



    IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);

    switch (addr)

    {

        case INTRMASK:

            ivshmem_IntrMask_write(s, val);

            break;



        case INTRSTATUS:

            ivshmem_IntrStatus_write(s, val);

            break;



        case DOORBELL:

            /* check that dest VM ID is reasonable */

            if ((dest < 0) || (dest > s->max_peer)) {

                IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);

                break;

            }



            /* check doorbell range */

            if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) {

                IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",

                                                    write_one, dest, vector);

                if (write(s->peers[dest].eventfds[vector],

                                                    &(write_one), 8) != 8) {

                    IVSHMEM_DPRINTF("error writing to eventfd\n");

                }

            }

            break;

        default:

            IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);

    }

}

static void ivshmem_io_writel(void *opaque, target_phys_addr_t addr,

                                                            uint32_t val)

{

    IVShmemState *s = opaque;



    uint64_t write_one = 1;

    uint16_t dest = val >> 16;

    uint16_t vector = val & 0xff;



    addr &= 0xfc;



    IVSHMEM_DPRINTF("writing to addr " TARGET_FMT_plx "\n", addr);

    switch (addr)

    {

        case INTRMASK:

            ivshmem_IntrMask_write(s, val);

            break;



        case INTRSTATUS:

            ivshmem_IntrStatus_write(s, val);

            break;



        case DOORBELL:

            

            if ((dest < 0) || (dest > s->max_peer)) {

                IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);

                break;

            }



            

            if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) {

                IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",

                                                    write_one, dest, vector);

                if (write(s->peers[dest].eventfds[vector],

                                                    &(write_one), 8) != 8) {

                    IVSHMEM_DPRINTF("error writing to eventfd\n");

                }

            }

            break;

        default:

            IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,

                                                            uint32_t VAR_2)

{

    IVShmemState *s = VAR_0;



    uint64_t write_one = 1;

    uint16_t dest = VAR_2 >> 16;

    uint16_t vector = VAR_2 & 0xff;



    VAR_1 &= 0xfc;



    IVSHMEM_DPRINTF("writing to VAR_1 " TARGET_FMT_plx "\n", VAR_1);

    switch (VAR_1)

    {

        case INTRMASK:

            ivshmem_IntrMask_write(s, VAR_2);

            break;



        case INTRSTATUS:

            ivshmem_IntrStatus_write(s, VAR_2);

            break;



        case DOORBELL:

            

            if ((dest < 0) || (dest > s->max_peer)) {

                IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest);

                break;

            }



            

            if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) {

                IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",

                                                    write_one, dest, vector);

                if (write(s->peers[dest].eventfds[vector],

                                                    &(write_one), 8) != 8) {

                    IVSHMEM_DPRINTF("error writing to eventfd\n");

                }

            }

            break;

        default:

            IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest);

    }

}

static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,
uint32_t VAR_2)
{ IVShmemState *s = VAR_0; uint64_t write_one = 1; uint16_t dest = VAR_2 >> 16; uint16_t vector = VAR_2 & 0xff; VAR_1 &= 0xfc; IVSHMEM_DPRINTF("writing to VAR_1 " TARGET_FMT_plx "\n", VAR_1); switch (VAR_1)
{ case INTRMASK:
ivshmem_IntrMask_write(s, VAR_2); break; case INTRSTATUS:
ivshmem_IntrStatus_write(s, VAR_2); break; case DOORBELL:
if ((dest < 0) || (dest > s->max_peer)) { IVSHMEM_DPRINTF("Invalid destination VM ID (%d)\n", dest); break; } if ((vector >= 0) && (vector < s->peers[dest].nb_eventfds)) { IVSHMEM_DPRINTF("Writing %" PRId64 " to VM %d on vector %d\n",
write_one, dest, vector); if (write(s->peers[dest].eventfds[vector],
&(write_one), 8) != 8) { IVSHMEM_DPRINTF("error writing to eventfd\n"); } } break; default:
IVSHMEM_DPRINTF("Invalid VM Doorbell VM %d\n", dest); } }