aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-12-08 15:58:43 +0200
committerAvi Kivity <avi@redhat.com>2011-12-20 14:14:06 +0200
commit8ea9252abe08631611effb905fbb4a015ec1514c (patch)
treea2fd996baedd546dc76d687ae8f78b181e4405d8
parent62ec4832ea1093b20a8a0893a016a00ef8145496 (diff)
memory: add memory_region_is_ram()
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--memory.c8
-rw-r--r--memory.h10
2 files changed, 18 insertions, 0 deletions
diff --git a/memory.c b/memory.c
index a7e615ad15..4264b42222 100644
--- a/memory.c
+++ b/memory.c
@@ -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;
diff --git a/memory.h b/memory.h
index fe643ff05b..dccc9007df 100644
--- a/memory.h
+++ b/memory.h
@@ -122,6 +122,7 @@ struct MemoryRegion {
IORange iorange;
bool terminates;
bool readable;
+ bool ram;
bool readonly; /* For RAM regions */
bool enabled;
MemoryRegion *alias;
@@ -267,6 +268,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.
*
* Returns a host pointer to a RAM memory region (created with