int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)

{

    RAMBlock *block;

    uint8_t *host = ptr;



    if (xen_enabled()) {

        *ram_addr = xen_ram_addr_from_mapcache(ptr);

        return 0;

    }



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        /* This case append when the block is not mapped. */

        if (block->host == NULL) {

            continue;

        }

        if (host - block->host < block->length) {

            *ram_addr = block->offset + (host - block->host);

            return 0;

        }

    }



    return -1;

}

int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)

{

    RAMBlock *block;

    uint8_t *host = ptr;



    if (xen_enabled()) {

        *ram_addr = xen_ram_addr_from_mapcache(ptr);

        return 0;

    }



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        

        if (block->host == NULL) {

            continue;

        }

        if (host - block->host < block->length) {

            *ram_addr = block->offset + (host - block->host);

            return 0;

        }

    }



    return -1;

}

int FUNC_0(void *VAR_0, ram_addr_t *VAR_1)

{

    RAMBlock *block;

    uint8_t *host = VAR_0;



    if (xen_enabled()) {

        *VAR_1 = xen_ram_addr_from_mapcache(VAR_0);

        return 0;

    }



    QTAILQ_FOREACH(block, &ram_list.blocks, next) {

        

        if (block->host == NULL) {

            continue;

        }

        if (host - block->host < block->length) {

            *VAR_1 = block->offset + (host - block->host);

            return 0;

        }

    }



    return -1;

}

int FUNC_0(void *VAR_0, ram_addr_t *VAR_1)
{ RAMBlock *block; uint8_t *host = VAR_0; if (xen_enabled()) { *VAR_1 = xen_ram_addr_from_mapcache(VAR_0); return 0; } QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block->host == NULL) { continue; } if (host - block->host < block->length) { *VAR_1 = block->offset + (host - block->host); return 0; } } return -1; }