mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
memory: split memory_region_from_host from qemu_ram_addr_from_host
Move the old qemu_ram_addr_from_host to memory_region_from_host and
make it return an offset within the region. For qemu_ram_addr_from_host
return the ram_addr_t directly, similar to what it was before
commit 1b5ec23
("memory: return MemoryRegion from qemu_ram_addr_from_host",
2013-07-04).
Reviewed-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
f615f39616
commit
07bdaa4196
7 changed files with 51 additions and 20 deletions
|
@ -32,6 +32,8 @@
|
|||
#include "qom/object.h"
|
||||
#include "qemu/rcu.h"
|
||||
|
||||
#define RAM_ADDR_INVALID (~(ram_addr_t)0)
|
||||
|
||||
#define MAX_PHYS_ADDR_SPACE_BITS 62
|
||||
#define MAX_PHYS_ADDR (((hwaddr)1 << MAX_PHYS_ADDR_SPACE_BITS) - 1)
|
||||
|
||||
|
@ -677,6 +679,24 @@ int memory_region_get_fd(MemoryRegion *mr);
|
|||
*/
|
||||
void memory_region_set_fd(MemoryRegion *mr, int fd);
|
||||
|
||||
/**
|
||||
* memory_region_from_host: Convert a pointer into a RAM memory region
|
||||
* and an offset within it.
|
||||
*
|
||||
* Given a host pointer inside a RAM memory region (created with
|
||||
* memory_region_init_ram() or memory_region_init_ram_ptr()), return
|
||||
* the MemoryRegion and the offset within it.
|
||||
*
|
||||
* Use with care; by the time this function returns, the returned pointer is
|
||||
* not protected by RCU anymore. If the caller is not within an RCU critical
|
||||
* section and does not hold the iothread lock, it must have other means of
|
||||
* protecting the pointer, such as a reference to the region that includes
|
||||
* the incoming ram_addr_t.
|
||||
*
|
||||
* @mr: the memory region being queried.
|
||||
*/
|
||||
MemoryRegion *memory_region_from_host(void *ptr, ram_addr_t *offset);
|
||||
|
||||
/**
|
||||
* memory_region_get_ram_ptr: Get a pointer into a RAM memory region.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue