mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
memory: MemoryRegion: factor out memory region re-adder
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 <peter.crosthwaite@xilinx.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
0598701a49
commit
67891b8a85
1 changed files with 16 additions and 10 deletions
26
memory.c
26
memory.c
|
@ -1517,21 +1517,27 @@ void memory_region_set_enabled(MemoryRegion *mr, bool enabled)
|
|||
memory_region_transaction_commit();
|
||||
}
|
||||
|
||||
void memory_region_set_address(MemoryRegion *mr, hwaddr addr)
|
||||
static void memory_region_readd_subregion(MemoryRegion *mr)
|
||||
{
|
||||
MemoryRegion *parent = mr->parent;
|
||||
|
||||
if (addr == mr->addr || !parent) {
|
||||
mr->addr = addr;
|
||||
return;
|
||||
if (parent) {
|
||||
memory_region_transaction_begin();
|
||||
memory_region_ref(mr);
|
||||
memory_region_del_subregion(parent, mr);
|
||||
mr->parent = parent;
|
||||
memory_region_update_parent_subregions(mr);
|
||||
memory_region_unref(mr);
|
||||
memory_region_transaction_commit();
|
||||
}
|
||||
}
|
||||
|
||||
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_address(MemoryRegion *mr, hwaddr addr)
|
||||
{
|
||||
if (addr != mr->addr) {
|
||||
mr->addr = addr;
|
||||
memory_region_readd_subregion(mr);
|
||||
}
|
||||
}
|
||||
|
||||
void memory_region_set_alias_offset(MemoryRegion *mr, hwaddr offset)
|
||||
|
|
Loading…
Reference in a new issue