memory: add memory_region_is_ram()
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
62ec4832ea
commit
8ea9252abe
8
memory.c
8
memory.c
@ -832,6 +832,7 @@ void memory_region_init(MemoryRegion *mr,
|
|||||||
mr->offset = 0;
|
mr->offset = 0;
|
||||||
mr->enabled = true;
|
mr->enabled = true;
|
||||||
mr->terminates = false;
|
mr->terminates = false;
|
||||||
|
mr->ram = false;
|
||||||
mr->readable = true;
|
mr->readable = true;
|
||||||
mr->readonly = false;
|
mr->readonly = false;
|
||||||
mr->destructor = memory_region_destructor_none;
|
mr->destructor = memory_region_destructor_none;
|
||||||
@ -998,6 +999,7 @@ void memory_region_init_ram(MemoryRegion *mr,
|
|||||||
uint64_t size)
|
uint64_t size)
|
||||||
{
|
{
|
||||||
memory_region_init(mr, name, size);
|
memory_region_init(mr, name, size);
|
||||||
|
mr->ram = true;
|
||||||
mr->terminates = true;
|
mr->terminates = true;
|
||||||
mr->destructor = memory_region_destructor_ram;
|
mr->destructor = memory_region_destructor_ram;
|
||||||
mr->ram_addr = qemu_ram_alloc(dev, name, size, mr);
|
mr->ram_addr = qemu_ram_alloc(dev, name, size, mr);
|
||||||
@ -1011,6 +1013,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
|
|||||||
void *ptr)
|
void *ptr)
|
||||||
{
|
{
|
||||||
memory_region_init(mr, name, size);
|
memory_region_init(mr, name, size);
|
||||||
|
mr->ram = true;
|
||||||
mr->terminates = true;
|
mr->terminates = true;
|
||||||
mr->destructor = memory_region_destructor_ram_from_ptr;
|
mr->destructor = memory_region_destructor_ram_from_ptr;
|
||||||
mr->ram_addr = qemu_ram_alloc_from_ptr(dev, name, size, ptr, mr);
|
mr->ram_addr = qemu_ram_alloc_from_ptr(dev, name, size, ptr, mr);
|
||||||
@ -1066,6 +1069,11 @@ uint64_t memory_region_size(MemoryRegion *mr)
|
|||||||
return int128_get64(mr->size);
|
return int128_get64(mr->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool memory_region_is_ram(MemoryRegion *mr)
|
||||||
|
{
|
||||||
|
return mr->ram;
|
||||||
|
}
|
||||||
|
|
||||||
void memory_region_set_offset(MemoryRegion *mr, target_phys_addr_t offset)
|
void memory_region_set_offset(MemoryRegion *mr, target_phys_addr_t offset)
|
||||||
{
|
{
|
||||||
mr->offset = offset;
|
mr->offset = offset;
|
||||||
|
10
memory.h
10
memory.h
@ -122,6 +122,7 @@ struct MemoryRegion {
|
|||||||
IORange iorange;
|
IORange iorange;
|
||||||
bool terminates;
|
bool terminates;
|
||||||
bool readable;
|
bool readable;
|
||||||
|
bool ram;
|
||||||
bool readonly; /* For RAM regions */
|
bool readonly; /* For RAM regions */
|
||||||
bool enabled;
|
bool enabled;
|
||||||
MemoryRegion *alias;
|
MemoryRegion *alias;
|
||||||
@ -266,6 +267,15 @@ void memory_region_destroy(MemoryRegion *mr);
|
|||||||
*/
|
*/
|
||||||
uint64_t memory_region_size(MemoryRegion *mr);
|
uint64_t memory_region_size(MemoryRegion *mr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* memory_region_is_ram: check whether a memory region is random access
|
||||||
|
*
|
||||||
|
* Returns %true is a memory region is random access.
|
||||||
|
*
|
||||||
|
* @mr: the memory region being queried
|
||||||
|
*/
|
||||||
|
bool memory_region_is_ram(MemoryRegion *mr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* memory_region_get_ram_ptr: Get a pointer into a RAM memory region.
|
* memory_region_get_ram_ptr: Get a pointer into a RAM memory region.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user