[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH memory v4 06/10] memory: MemoryRegion: factor out me
From: |
Peter Crosthwaite |
Subject: |
[Qemu-devel] [PATCH memory v4 06/10] memory: MemoryRegion: factor out memory region re-adder |
Date: |
Thu, 5 Jun 2014 23:15:18 -0700 |
memory_region_set_address is mostly just a function that deletes and
re-adds a memory region. Factor this generic functionality out into a
re-usable function. This prepares support for further QOMification
of MemoryRegion.
Signed-off-by: Peter Crosthwaite <address@hidden>
---
memory.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/memory.c b/memory.c
index f9b9745..7135299 100644
--- a/memory.c
+++ b/memory.c
@@ -828,6 +828,23 @@ static void
memory_region_destructor_rom_device(MemoryRegion *mr)
qemu_ram_free(mr->ram_addr & TARGET_PAGE_MASK);
}
+static void do_memory_region_add_subregion_common(MemoryRegion *subregion);
+
+static void memory_region_readd_subregion(MemoryRegion *mr)
+{
+ MemoryRegion *parent = mr->parent;
+
+ if (parent) {
+ memory_region_transaction_begin();
+ memory_region_ref(mr);
+ memory_region_del_subregion(parent, mr);
+ mr->parent = parent;
+ do_memory_region_add_subregion_common(mr);
+ memory_region_unref(mr);
+ memory_region_transaction_commit();
+ }
+}
+
void memory_region_init(MemoryRegion *mr,
Object *owner,
const char *name,
@@ -1506,19 +1523,10 @@ void memory_region_set_enabled(MemoryRegion *mr, bool
enabled)
void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
{
- MemoryRegion *parent = mr->parent;
-
- if (addr == mr->addr || !parent) {
+ if (addr != mr->addr) {
mr->addr = addr;
- return;
+ memory_region_readd_subregion(mr);
}
-
- memory_region_transaction_begin();
- memory_region_ref(mr);
- memory_region_del_subregion(parent, mr);
- memory_region_add_subregion_common(parent, addr, mr);
- memory_region_unref(mr);
- memory_region_transaction_commit();
}
void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset)
--
2.0.0
- [Qemu-devel] [PATCH memory v4 00/10] Memory Region QOMification, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 01/10] memory: Simplify mr_add_subregion() if-else, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 02/10] qom: add a generic mechanism to resolve paths, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 03/10] qom: object: Ignore refs/unrefs of NULL, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 04/10] qom: Publish object_resolve_link, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 05/10] memory: Coreify subregion add functionality, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 06/10] memory: MemoryRegion: factor out memory region re-adder,
Peter Crosthwaite <=
- [Qemu-devel] [PATCH memory v4 07/10] memory: MemoryRegion: QOMify, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 08/10] memory: MemoryRegion: Add container and addr props, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 09/10] memory: MemoryRegion: Add may-overlap and priority props, Peter Crosthwaite, 2014/06/06
- [Qemu-devel] [PATCH memory v4 10/10] memory: MemoryRegion: Add size property, Peter Crosthwaite, 2014/06/06
- Re: [Qemu-devel] [PATCH memory v4 00/10] Memory Region QOMification, Paolo Bonzini, 2014/06/06