OSDN Git Service

memory: Implement memory_region_get_ram_addr with mr->ram_block
authorFam Zheng <famz@redhat.com>
Tue, 1 Mar 2016 06:18:20 +0000 (14:18 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 7 Mar 2016 12:18:28 +0000 (13:18 +0100)
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <1456813104-25902-4-git-send-email-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/exec/memory.h
memory.c

index d5284c2..810d2c0 100644 (file)
@@ -978,14 +978,8 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr,
 /**
  * memory_region_get_ram_addr: Get the ram address associated with a memory
  *                             region
- *
- * DO NOT USE THIS FUNCTION.  This is a temporary workaround while the Xen
- * code is being reworked.
  */
-static inline ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
-{
-    return mr->ram_addr;
-}
+ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr);
 
 uint64_t memory_region_get_alignment(const MemoryRegion *mr);
 /**
index 1aa777d..d83405b 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -1640,6 +1640,11 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr)
     return ptr + offset;
 }
 
+ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
+{
+    return mr->ram_block ? mr->ram_block->offset : RAM_ADDR_INVALID;
+}
+
 void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp)
 {
     assert(mr->ram_addr != RAM_ADDR_INVALID);