aboutsummaryrefslogtreecommitdiffstats
path: root/memory.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2012-02-08 16:54:16 +0200
committerAvi Kivity <avi@redhat.com>2012-02-29 13:44:42 +0200
commit9363274709af23c499b6db3eb402b6f9aa46c40b (patch)
tree5db489178fce25d9af97354b916cee3cd5e3be10 /memory.c
parentd7ec83e6b57f48cf07f663e232e4aa2b32bc33c7 (diff)
memory: use a MemoryListener for core memory map updates too
This transforms memory.c into a library which can then be unit tested easily, by feeding it inputs and listening to its outputs. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/memory.c b/memory.c
index 85959ee54..d5591f8c2 100644
--- a/memory.c
+++ b/memory.c
@@ -338,28 +338,10 @@ static void access_with_adjusted_size(target_phys_addr_t addr,
static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
{
- MemoryRegionSection section = {
- .mr = fr->mr,
- .offset_within_address_space = int128_get64(fr->addr.start),
- .offset_within_region = fr->offset_in_region,
- .size = int128_get64(fr->addr.size),
- .readonly = fr->readonly,
- };
-
- cpu_register_physical_memory_log(&section, fr->readonly);
}
static void as_memory_range_del(AddressSpace *as, FlatRange *fr)
{
- MemoryRegionSection section = {
- .mr = &io_mem_unassigned,
- .offset_within_address_space = int128_get64(fr->addr.start),
- .offset_within_region = int128_get64(fr->addr.start),
- .size = int128_get64(fr->addr.size),
- .readonly = fr->readonly,
- };
-
- cpu_register_physical_memory_log(&section, false);
}
static void as_memory_log_start(AddressSpace *as, FlatRange *fr)
@@ -450,22 +432,17 @@ static void memory_region_iorange_write(IORange *iorange,
memory_region_write_accessor, mr);
}
-static const IORangeOps memory_region_iorange_ops = {
+const IORangeOps memory_region_iorange_ops = {
.read = memory_region_iorange_read,
.write = memory_region_iorange_write,
};
static void as_io_range_add(AddressSpace *as, FlatRange *fr)
{
- iorange_init(&fr->mr->iorange, &memory_region_iorange_ops,
- int128_get64(fr->addr.start), int128_get64(fr->addr.size));
- ioport_register(&fr->mr->iorange);
}
static void as_io_range_del(AddressSpace *as, FlatRange *fr)
{
- isa_unassign_ioport(int128_get64(fr->addr.start),
- int128_get64(fr->addr.size));
}
static const AddressSpaceOps address_space_ops_io = {
@@ -1456,7 +1433,6 @@ void memory_global_sync_dirty_bitmap(MemoryRegion *address_space)
void memory_global_dirty_log_start(void)
{
- cpu_physical_memory_set_dirty_tracking(1);
global_dirty_log = true;
MEMORY_LISTENER_CALL(log_global_start, Forward);
}
@@ -1465,7 +1441,6 @@ void memory_global_dirty_log_stop(void)
{
global_dirty_log = false;
MEMORY_LISTENER_CALL(log_global_stop, Reverse);
- cpu_physical_memory_set_dirty_tracking(0);
}
static void listener_add_address_space(MemoryListener *listener,