Patchwork [05/23] memory: add memory_region_is_rom()

login
register
mail settings
Submitter Avi Kivity
Date Dec. 19, 2011, 2:13 p.m.
Message ID <1324304024-11220-6-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/132237/
State New
Headers show

Comments

Avi Kivity - Dec. 19, 2011, 2:13 p.m.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
 memory.c |    5 +++++
 memory.h |    9 +++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

Patch

diff --git a/memory.c b/memory.c
index 6fd31d4..c57b7de 100644
--- a/memory.c
+++ b/memory.c
@@ -1073,6 +1073,11 @@  bool memory_region_is_ram(MemoryRegion *mr)
     return mr->ram;
 }
 
+bool memory_region_is_rom(MemoryRegion *mr)
+{
+    return mr->ram && mr->readonly;
+}
+
 void memory_region_set_offset(MemoryRegion *mr, target_phys_addr_t offset)
 {
     mr->offset = offset;
diff --git a/memory.h b/memory.h
index 13f88c0..42546c4 100644
--- a/memory.h
+++ b/memory.h
@@ -294,6 +294,15 @@  uint64_t memory_region_size(MemoryRegion *mr);
 bool memory_region_is_ram(MemoryRegion *mr);
 
 /**
+ * memory_region_is_rom: check whether a memory region is ROM
+ *
+ * Returns %true is a memory region is read-only memory.
+ *
+ * @mr: the memory region being queried
+ */
+bool memory_region_is_rom(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