aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>2014-06-05 23:14:44 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2014-06-17 17:11:10 +0200
commit0598701a4947ddbc19391e008cf753f8f22f3c25 (patch)
treedc42f985fb8dc67e46224c89059f22e434636fb7
parentc9299e2fe789b085f463b2e4232507f5e77f50b4 (diff)
memory: MemoryRegion: factor out subregion add functionality
Split off the core looping code that actually adds subregions into it's own fn. This prepares support for Memory Region qomification where setting the MR address or parent via QOM will back onto this more minimal function. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> [Rename new function. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--memory.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/memory.c b/memory.c
index 3811bd16f2..15f63e8b99 100644
--- a/memory.c
+++ b/memory.c
@@ -1423,18 +1423,15 @@ void memory_region_del_eventfd(MemoryRegion *mr,
memory_region_transaction_commit();
}
-static void memory_region_add_subregion_common(MemoryRegion *mr,
- hwaddr offset,
- MemoryRegion *subregion)
+static void memory_region_update_parent_subregions(MemoryRegion *subregion)
{
+ hwaddr offset = subregion->addr;
+ MemoryRegion *mr = subregion->parent;
MemoryRegion *other;
memory_region_transaction_begin();
- assert(!subregion->parent);
memory_region_ref(subregion);
- subregion->parent = mr;
- subregion->addr = offset;
QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {
if (subregion->may_overlap || other->may_overlap) {
continue;
@@ -1468,6 +1465,15 @@ done:
memory_region_transaction_commit();
}
+static void memory_region_add_subregion_common(MemoryRegion *mr,
+ hwaddr offset,
+ MemoryRegion *subregion)
+{
+ assert(!subregion->parent);
+ subregion->parent = mr;
+ subregion->addr = offset;
+ memory_region_update_parent_subregions(subregion);
+}
void memory_region_add_subregion(MemoryRegion *mr,
hwaddr offset,