mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-02 05:01:06 +00:00
exec: make qemu_ram_ptr_length more similar to qemu_get_ram_ptr
Notably, use qemu_get_ram_block to enjoy the MRU optimization. Backports commit e81bcda529378f5ed8b9b0b59bb2b24b8ee1c814 from qemu
This commit is contained in:
parent
d52f55b46d
commit
52b3120995
27
qemu/exec.c
27
qemu/exec.c
|
@ -1277,20 +1277,29 @@ void *qemu_get_ram_ptr(struct uc_struct *uc, ram_addr_t addr)
|
||||||
static void *qemu_ram_ptr_length(struct uc_struct *uc, ram_addr_t addr, hwaddr *size)
|
static void *qemu_ram_ptr_length(struct uc_struct *uc, ram_addr_t addr, hwaddr *size)
|
||||||
{
|
{
|
||||||
RAMBlock *block;
|
RAMBlock *block;
|
||||||
|
ram_addr_t offset_inside_block;
|
||||||
if (*size == 0) {
|
if (*size == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTAILQ_FOREACH(block, &uc->ram_list.blocks, next) {
|
block = qemu_get_ram_block(uc, addr);
|
||||||
if (addr - block->offset < block->max_length) {
|
offset_inside_block = addr - block->offset;
|
||||||
if (addr - block->offset + *size > block->max_length)
|
*size = MIN(*size, block->max_length - offset_inside_block);
|
||||||
*size = block->max_length - addr + block->offset;
|
|
||||||
return ramblock_ptr(block, addr - block->offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
|
// Unicorn: Commented out
|
||||||
abort();
|
//if (xen_enabled() && block->host == NULL) {
|
||||||
|
// /* We need to check if the requested address is in the RAM
|
||||||
|
// * because we don't want to map the entire memory in QEMU.
|
||||||
|
// * In that case just map the requested area.
|
||||||
|
// */
|
||||||
|
// if (block->offset == 0) {
|
||||||
|
// return xen_map_cache(addr, *size, 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// block->host = xen_map_cache(block->offset, block->max_length, 1);
|
||||||
|
//}
|
||||||
|
|
||||||
|
return ramblock_ptr(block, offset_inside_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue