aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2012-01-01 18:02:31 +0200
committerAvi Kivity <avi@redhat.com>2012-01-04 13:34:49 +0200
commit26a83ad0e793465b74a8b06a65f2f6fdc5615413 (patch)
treed4687b4fd7daae2a4f604b415c6eeeb92945d33b
parentacbbec5d438dcf04234519bac53e1f5263572d76 (diff)
memory: remove MemoryRegion::backend_registered
backend_registered was used to lazify the process of registering an mmio region, since the it is different for the I/O address space and the memory address space. However, it also makes registration dependent on the region being visible in the address space. This is not the case for "fake" regions, like watchpoints or IO_MEM_UNASSIGNED. Remove backend_registered and always initialize the region. If it turns out to be part of the I/O address space, we've wasted an I/O slot, but that's not too bad. In any case this will be optimized later on. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
-rw-r--r--memory.c26
-rw-r--r--memory.h1
2 files changed, 4 insertions, 23 deletions
diff --git a/memory.c b/memory.c
index 5c468332ba..63dc3dc85c 100644
--- a/memory.c
+++ b/memory.c
@@ -303,14 +303,10 @@ static void access_with_adjusted_size(target_phys_addr_t addr,
}
}
-static void memory_region_prepare_ram_addr(MemoryRegion *mr);
-
static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
{
ram_addr_t phys_offset, region_offset;
- memory_region_prepare_ram_addr(fr->mr);
-
phys_offset = fr->mr->ram_addr;
region_offset = fr->offset_in_region;
/* cpu_register_physical_memory_log() wants region_offset for
@@ -1032,19 +1028,6 @@ static CPUWriteMemoryFunc * const memory_region_write_thunk[] = {
memory_region_write_thunk_l,
};
-static void memory_region_prepare_ram_addr(MemoryRegion *mr)
-{
- if (mr->backend_registered) {
- return;
- }
-
- mr->destructor = memory_region_destructor_iomem;
- mr->ram_addr = cpu_register_io_memory(memory_region_read_thunk,
- memory_region_write_thunk,
- mr);
- mr->backend_registered = true;
-}
-
void memory_region_init_io(MemoryRegion *mr,
const MemoryRegionOps *ops,
void *opaque,
@@ -1055,7 +1038,10 @@ void memory_region_init_io(MemoryRegion *mr,
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
- mr->backend_registered = false;
+ mr->destructor = memory_region_destructor_iomem;
+ mr->ram_addr = cpu_register_io_memory(memory_region_read_thunk,
+ memory_region_write_thunk,
+ mr);
}
void memory_region_init_ram(MemoryRegion *mr,
@@ -1067,7 +1053,6 @@ void memory_region_init_ram(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram;
mr->ram_addr = qemu_ram_alloc(size, mr);
- mr->backend_registered = true;
}
void memory_region_init_ram_ptr(MemoryRegion *mr,
@@ -1080,7 +1065,6 @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
mr->terminates = true;
mr->destructor = memory_region_destructor_ram_from_ptr;
mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr);
- mr->backend_registered = true;
}
void memory_region_init_alias(MemoryRegion *mr,
@@ -1110,7 +1094,6 @@ void memory_region_init_rom_device(MemoryRegion *mr,
memory_region_write_thunk,
mr);
mr->ram_addr |= IO_MEM_ROMD;
- mr->backend_registered = true;
}
void memory_region_destroy(MemoryRegion *mr)
@@ -1453,7 +1436,6 @@ void memory_region_set_alias_offset(MemoryRegion *mr, target_phys_addr_t offset)
ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr)
{
- assert(mr->backend_registered);
return mr->ram_addr;
}
diff --git a/memory.h b/memory.h
index 8041e9028a..77984bb4e4 100644
--- a/memory.h
+++ b/memory.h
@@ -116,7 +116,6 @@ struct MemoryRegion {
Int128 size;
target_phys_addr_t addr;
target_phys_addr_t offset;
- bool backend_registered;
void (*destructor)(MemoryRegion *mr);
ram_addr_t ram_addr;
IORange iorange;