static int xen_pt_msgdata_reg_write(XenPCIPassthroughState *s,

                                    XenPTReg *cfg_entry, uint16_t *val,

                                    uint16_t dev_value, uint16_t valid_mask)

{

    XenPTRegInfo *reg = cfg_entry->reg;

    XenPTMSI *msi = s->msi;

    uint16_t writable_mask = 0;

    uint16_t old_data = cfg_entry->data;

    uint32_t offset = reg->offset;



    /* check the offset whether matches the type or not */

    if (!xen_pt_msi_check_type(offset, msi->flags, DATA)) {

        /* exit I/O emulator */

        XEN_PT_ERR(&s->dev, "the offset does not match the 32/64 bit type!\n");

        return -1;

    }



    /* modify emulate register */

    writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;

    cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);

    /* update the msi_info too */

    msi->data = cfg_entry->data;



    /* create value for writing to I/O device register */

    *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0);



    /* update MSI */

    if (cfg_entry->data != old_data) {

        if (msi->mapped) {

            xen_pt_msi_update(s);

        }

    }



    return 0;

}

static int xen_pt_msgdata_reg_write(XenPCIPassthroughState *s,

                                    XenPTReg *cfg_entry, uint16_t *val,

                                    uint16_t dev_value, uint16_t valid_mask)

{

    XenPTRegInfo *reg = cfg_entry->reg;

    XenPTMSI *msi = s->msi;

    uint16_t writable_mask = 0;

    uint16_t old_data = cfg_entry->data;

    uint32_t offset = reg->offset;



    

    if (!xen_pt_msi_check_type(offset, msi->flags, DATA)) {

        

        XEN_PT_ERR(&s->dev, "the offset does not match the 32/64 bit type!\n");

        return -1;

    }



    

    writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;

    cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);

    

    msi->data = cfg_entry->data;



    

    *val = XEN_PT_MERGE_VALUE(*val, dev_value, 0);



    

    if (cfg_entry->data != old_data) {

        if (msi->mapped) {

            xen_pt_msi_update(s);

        }

    }



    return 0;

}

static int FUNC_0(XenPCIPassthroughState *VAR_0,

                                    XenPTReg *VAR_1, uint16_t *VAR_2,

                                    uint16_t VAR_3, uint16_t VAR_4)

{

    XenPTRegInfo *reg = VAR_1->reg;

    XenPTMSI *msi = VAR_0->msi;

    uint16_t writable_mask = 0;

    uint16_t old_data = VAR_1->data;

    uint32_t offset = reg->offset;



    

    if (!xen_pt_msi_check_type(offset, msi->flags, DATA)) {

        

        XEN_PT_ERR(&VAR_0->dev, "the offset does not match the 32/64 bit type!\n");

        return -1;

    }



    

    writable_mask = reg->emu_mask & ~reg->ro_mask & VAR_4;

    VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask);

    

    msi->data = VAR_1->data;



    

    *VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, 0);



    

    if (VAR_1->data != old_data) {

        if (msi->mapped) {

            xen_pt_msi_update(VAR_0);

        }

    }



    return 0;

}

static int FUNC_0(XenPCIPassthroughState *VAR_0,
XenPTReg *VAR_1, uint16_t *VAR_2,
uint16_t VAR_3, uint16_t VAR_4)
{ XenPTRegInfo *reg = VAR_1->reg; XenPTMSI *msi = VAR_0->msi; uint16_t writable_mask = 0; uint16_t old_data = VAR_1->data; uint32_t offset = reg->offset; if (!xen_pt_msi_check_type(offset, msi->flags, DATA)) { XEN_PT_ERR(&VAR_0->dev, "the offset does not match the 32/64 bit type!\n"); return -1; } writable_mask = reg->emu_mask & ~reg->ro_mask & VAR_4; VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask); msi->data = VAR_1->data; *VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, 0); if (VAR_1->data != old_data) { if (msi->mapped) { xen_pt_msi_update(VAR_0); } } return 0; }