static int xen_remove_from_physmap(XenIOState *state,

                                   hwaddr start_addr,

                                   ram_addr_t size)

{

    unsigned long i = 0;

    int rc = 0;

    XenPhysmap *physmap = NULL;

    hwaddr phys_offset = 0;



    physmap = get_physmapping(state, start_addr, size);

    if (physmap == NULL) {

        return -1;

    }



    phys_offset = physmap->phys_offset;

    size = physmap->size;



    DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", from ",

            "%"HWADDR_PRIx"\n", phys_offset, phys_offset + size, start_addr);



    size >>= TARGET_PAGE_BITS;

    start_addr >>= TARGET_PAGE_BITS;

    phys_offset >>= TARGET_PAGE_BITS;

    for (i = 0; i < size; i++) {

        unsigned long idx = start_addr + i;

        xen_pfn_t gpfn = phys_offset + i;



        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);

        if (rc) {

            fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"

                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);

            return -rc;

        }

    }



    QLIST_REMOVE(physmap, list);

    if (state->log_for_dirtybit == physmap) {

        state->log_for_dirtybit = NULL;

    }

    free(physmap);



    return 0;

}

static int xen_remove_from_physmap(XenIOState *state,

                                   hwaddr start_addr,

                                   ram_addr_t size)

{

    unsigned long i = 0;

    int rc = 0;

    XenPhysmap *physmap = NULL;

    hwaddr phys_offset = 0;



    physmap = get_physmapping(state, start_addr, size);

    if (physmap == NULL) {

        return -1;

    }



    phys_offset = physmap->phys_offset;

    size = physmap->size;



    DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", from ",

            "%"HWADDR_PRIx"\n", phys_offset, phys_offset + size, start_addr);



    size >>= TARGET_PAGE_BITS;

    start_addr >>= TARGET_PAGE_BITS;

    phys_offset >>= TARGET_PAGE_BITS;

    for (i = 0; i < size; i++) {

        unsigned long idx = start_addr + i;

        xen_pfn_t gpfn = phys_offset + i;



        rc = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);

        if (rc) {

            fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"

                    PRI_xen_pfn" failed: %d\n", idx, gpfn, rc);

            return -rc;

        }

    }



    QLIST_REMOVE(physmap, list);

    if (state->log_for_dirtybit == physmap) {

        state->log_for_dirtybit = NULL;

    }

    free(physmap);



    return 0;

}

    free(physmap);
static int FUNC_0(XenIOState *VAR_0,

                                   hwaddr VAR_1,

                                   ram_addr_t VAR_2)

{

    unsigned long VAR_3 = 0;

    int VAR_4 = 0;

    XenPhysmap *physmap = NULL;

    hwaddr phys_offset = 0;



    physmap = get_physmapping(VAR_0, VAR_1, VAR_2);

    if (physmap == NULL) {

        return -1;

    }



    phys_offset = physmap->phys_offset;

    VAR_2 = physmap->VAR_2;



    DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", from ",

            "%"HWADDR_PRIx"\n", phys_offset, phys_offset + VAR_2, VAR_1);



    VAR_2 >>= TARGET_PAGE_BITS;

    VAR_1 >>= TARGET_PAGE_BITS;

    phys_offset >>= TARGET_PAGE_BITS;

    for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {

        unsigned long idx = VAR_1 + VAR_3;

        xen_pfn_t gpfn = phys_offset + VAR_3;



        VAR_4 = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn);

        if (VAR_4) {

            fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"

                    PRI_xen_pfn" failed: %d\n", idx, gpfn, VAR_4);

            return -VAR_4;

        }

    }



    QLIST_REMOVE(physmap, list);

    if (VAR_0->log_for_dirtybit == physmap) {

        VAR_0->log_for_dirtybit = NULL;

    }

    free(physmap);



    return 0;

}

static int FUNC_0(XenIOState *VAR_0,
hwaddr VAR_1,
ram_addr_t VAR_2)
{ unsigned long VAR_3 = 0; int VAR_4 = 0; XenPhysmap *physmap = NULL; hwaddr phys_offset = 0; physmap = get_physmapping(VAR_0, VAR_1, VAR_2); if (physmap == NULL) { return -1; } phys_offset = physmap->phys_offset; VAR_2 = physmap->VAR_2; DPRINTF("unmapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx", from ",
"%"HWADDR_PRIx"\n", phys_offset, phys_offset + VAR_2, VAR_1); VAR_2 >>= TARGET_PAGE_BITS; VAR_1 >>= TARGET_PAGE_BITS; phys_offset >>= TARGET_PAGE_BITS; for (VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { unsigned long idx = VAR_1 + VAR_3; xen_pfn_t gpfn = phys_offset + VAR_3; VAR_4 = xc_domain_add_to_physmap(xen_xc, xen_domid, XENMAPSPACE_gmfn, idx, gpfn); if (VAR_4) { fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN %"
PRI_xen_pfn" failed: %d\n", idx, gpfn, VAR_4); return -VAR_4; } } QLIST_REMOVE(physmap, list); if (VAR_0->log_for_dirtybit == physmap) { VAR_0->log_for_dirtybit = NULL; } free(physmap); return 0; }