static void vfio_bar_write(void *opaque, hwaddr addr,

                           uint64_t data, unsigned size)

{

    VFIOBAR *bar = opaque;

    union {

        uint8_t byte;

        uint16_t word;

        uint32_t dword;

        uint64_t qword;

    } buf;



    switch (size) {

    case 1:

        buf.byte = data;

        break;

    case 2:

        buf.word = cpu_to_le16(data);

        break;

    case 4:

        buf.dword = cpu_to_le32(data);

        break;

    default:

        hw_error("vfio: unsupported write size, %d bytes\n", size);

        break;

    }



    if (pwrite(bar->fd, &buf, size, bar->fd_offset + addr) != size) {

        error_report("%s(,0x%"HWADDR_PRIx", 0x%"PRIx64", %d) failed: %m",

                     __func__, addr, data, size);

    }



    DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64", %d)\n",

            __func__, bar->nr, addr, data, size);



    /*

     * A read or write to a BAR always signals an INTx EOI.  This will

     * do nothing if not pending (including not in INTx mode).  We assume

     * that a BAR access is in response to an interrupt and that BAR

     * accesses will service the interrupt.  Unfortunately, we don't know

     * which access will service the interrupt, so we're potentially

     * getting quite a few host interrupts per guest interrupt.

     */

    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));

}

static void vfio_bar_write(void *opaque, hwaddr addr,

                           uint64_t data, unsigned size)

{

    VFIOBAR *bar = opaque;

    union {

        uint8_t byte;

        uint16_t word;

        uint32_t dword;

        uint64_t qword;

    } buf;



    switch (size) {

    case 1:

        buf.byte = data;

        break;

    case 2:

        buf.word = cpu_to_le16(data);

        break;

    case 4:

        buf.dword = cpu_to_le32(data);

        break;

    default:

        hw_error("vfio: unsupported write size, %d bytes\n", size);

        break;

    }



    if (pwrite(bar->fd, &buf, size, bar->fd_offset + addr) != size) {

        error_report("%s(,0x%"HWADDR_PRIx", 0x%"PRIx64", %d) failed: %m",

                     __func__, addr, data, size);

    }



    DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64", %d)\n",

            __func__, bar->nr, addr, data, size);



    















    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));

}

static void FUNC_0(void *VAR_0, hwaddr VAR_1,

                           uint64_t VAR_2, unsigned VAR_3)

{

    VFIOBAR *bar = VAR_0;

    union {

        uint8_t byte;

        uint16_t word;

        uint32_t dword;

        uint64_t qword;

    } VAR_4;



    switch (VAR_3) {

    case 1:

        VAR_4.byte = VAR_2;

        break;

    case 2:

        VAR_4.word = cpu_to_le16(VAR_2);

        break;

    case 4:

        VAR_4.dword = cpu_to_le32(VAR_2);

        break;

    default:

        hw_error("vfio: unsupported write VAR_3, %d bytes\n", VAR_3);

        break;

    }



    if (pwrite(bar->fd, &VAR_4, VAR_3, bar->fd_offset + VAR_1) != VAR_3) {

        error_report("%s(,0x%"HWADDR_PRIx", 0x%"PRIx64", %d) failed: %m",

                     __func__, VAR_1, VAR_2, VAR_3);

    }



    DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64", %d)\n",

            __func__, bar->nr, VAR_1, VAR_2, VAR_3);



    















    vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));

}

static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{ VFIOBAR *bar = VAR_0; union { uint8_t byte; uint16_t word; uint32_t dword; uint64_t qword; } VAR_4; switch (VAR_3) { case 1:
VAR_4.byte = VAR_2; break; case 2:
VAR_4.word = cpu_to_le16(VAR_2); break; case 4:
VAR_4.dword = cpu_to_le32(VAR_2); break; default:
hw_error("vfio: unsupported write VAR_3, %d bytes\n", VAR_3); break; } if (pwrite(bar->fd, &VAR_4, VAR_3, bar->fd_offset + VAR_1) != VAR_3) { error_report("%s(,0x%"HWADDR_PRIx", 0x%"PRIx64", %d) failed: %m",
__func__, VAR_1, VAR_2, VAR_3); } DPRINTF("%s(BAR%d+0x%"HWADDR_PRIx", 0x%"PRIx64", %d)\n",
__func__, bar->nr, VAR_1, VAR_2, VAR_3); vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr])); }