summaryrefslogtreecommitdiff
path: root/memory.h
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2012-04-09 17:38:52 +0000
committerBlue Swirl <blauwirbel@gmail.com>2012-05-01 10:45:07 +0000
commitfd06257351683ba24ebebd9793df3fd0fb59988e (patch)
tree702f85fd87c0a28510617080f74febc7482b5a34 /memory.h
parentcc5bea608df30263f8d20facfd55d8b6ce15053d (diff)
memory: move functions is_romd and section_addr to memory API
Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'memory.h')
-rw-r--r--memory.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/memory.h b/memory.h
index 53ff62b6c0..740c48e8e5 100644
--- a/memory.h
+++ b/memory.h
@@ -339,6 +339,19 @@ uint64_t memory_region_size(MemoryRegion *mr);
bool memory_region_is_ram(MemoryRegion *mr);
/**
+ * memory_region_is_romd: check whether a memory region is ROMD
+ *
+ * Returns %true is a memory region is ROMD and currently set to allow
+ * direct reads.
+ *
+ * @mr: the memory region being queried
+ */
+static inline bool memory_region_is_romd(MemoryRegion *mr)
+{
+ return mr->rom_device && mr->readable;
+}
+
+/**
* memory_region_name: get a memory region's name
*
* Returns the string that was used to initialize the memory region.
@@ -666,6 +679,22 @@ void memory_region_set_alias_offset(MemoryRegion *mr,
MemoryRegionSection memory_region_find(MemoryRegion *address_space,
target_phys_addr_t addr, uint64_t size);
+/**
+ * memory_region_section_addr: get offset within MemoryRegionSection
+ *
+ * Returns offset within MemoryRegionSection
+ *
+ * @section: the memory region section being queried
+ * @addr: address in address space
+ */
+static inline target_phys_addr_t
+memory_region_section_addr(MemoryRegionSection *section,
+ target_phys_addr_t addr)
+{
+ addr -= section->offset_within_address_space;
+ addr += section->offset_within_region;
+ return addr;
+}
/**
* memory_global_sync_dirty_bitmap: synchronize the dirty log for all memory