提交 8ea9252a 编写于 作者: A Avi Kivity

memory: add memory_region_is_ram()

Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 62ec4832
......@@ -832,6 +832,7 @@ void memory_region_init(MemoryRegion *mr,
mr->offset = 0;
mr->enabled = true;
mr->terminates = false;
mr->ram = false;
mr->readable = true;
mr->readonly = false;
mr->destructor = memory_region_destructor_none;
......@@ -998,6 +999,7 @@ void memory_region_init_ram(MemoryRegion *mr,
uint64_t size)
{
memory_region_init(mr, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(dev, name, size, mr);
......@@ -1011,6 +1013,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
void *ptr)
{
memory_region_init(mr, name, size);
mr->ram = true;
mr->terminates = true;
mr->destructor = memory_region_destructor_ram_from_ptr;
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);
}
bool memory_region_is_ram(MemoryRegion *mr)
{
return mr->ram;
}
void memory_region_set_offset(MemoryRegion *mr, target_phys_addr_t offset)
{
mr->offset = offset;
......
......@@ -122,6 +122,7 @@ struct MemoryRegion {
IORange iorange;
bool terminates;
bool readable;
bool ram;
bool readonly; /* For RAM regions */
bool enabled;
MemoryRegion *alias;
......@@ -266,6 +267,15 @@ void memory_region_destroy(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.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册