Switch cpu_register_physical_memory_log() to use MemoryRegions

Still internally using ram_addr.

Signed-off-by: Avi Kivity <avi@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Avi Kivity 2012-01-02 12:17:03 +02:00
parent 0e0df1e24d
commit dd81124bf6
3 changed files with 37 additions and 53 deletions

View file

@ -36,27 +36,9 @@ int cpu_register_io_memory(CPUReadMemoryFunc * const *mem_read,
void *opaque);
void cpu_unregister_io_memory(int table_address);
void cpu_register_physical_memory_log(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
ram_addr_t region_offset,
bool log_dirty);
static inline void cpu_register_physical_memory_offset(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
ram_addr_t region_offset)
{
cpu_register_physical_memory_log(start_addr, size, phys_offset,
region_offset, false);
}
static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset)
{
cpu_register_physical_memory_offset(start_addr, size, phys_offset, 0);
}
struct MemoryRegionSection;
void cpu_register_physical_memory_log(struct MemoryRegionSection *section,
bool readable, bool readonly);
void qemu_register_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);
void qemu_unregister_coalesced_mmio(target_phys_addr_t addr, ram_addr_t size);

24
exec.c
View file

@ -2510,18 +2510,32 @@ static subpage_t *subpage_init (target_phys_addr_t base, ram_addr_t *phys,
start_addr and region_offset are rounded down to a page boundary
before calculating this offset. This should not be a problem unless
the low bits of start_addr and region_offset differ. */
void cpu_register_physical_memory_log(target_phys_addr_t start_addr,
ram_addr_t size,
ram_addr_t phys_offset,
ram_addr_t region_offset,
bool log_dirty)
void cpu_register_physical_memory_log(MemoryRegionSection *section,
bool readable, bool readonly)
{
target_phys_addr_t start_addr = section->offset_within_address_space;
ram_addr_t size = section->size;
ram_addr_t phys_offset = section->mr->ram_addr;
ram_addr_t region_offset = section->offset_within_region;
target_phys_addr_t addr, end_addr;
PhysPageDesc *p;
CPUState *env;
ram_addr_t orig_size = size;
subpage_t *subpage;
if (memory_region_is_ram(section->mr)) {
phys_offset += region_offset;
region_offset = 0;
}
if (!readable) {
phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD;
}
if (readonly) {
phys_offset |= io_mem_rom.ram_addr;
}
assert(size);
if (phys_offset == io_mem_unassigned.ram_addr) {

View file

@ -305,38 +305,26 @@ static void access_with_adjusted_size(target_phys_addr_t addr,
static void as_memory_range_add(AddressSpace *as, FlatRange *fr)
{
ram_addr_t phys_offset, region_offset;
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),
};
phys_offset = fr->mr->ram_addr;
region_offset = fr->offset_in_region;
/* cpu_register_physical_memory_log() wants region_offset for
* mmio, but prefers offseting phys_offset for RAM. Humour it.
*/
if (memory_region_is_ram(fr->mr)) {
phys_offset += region_offset;
region_offset = 0;
}
if (!fr->readable) {
phys_offset &= ~TARGET_PAGE_MASK & ~IO_MEM_ROMD;
}
if (fr->readonly) {
phys_offset |= io_mem_rom.ram_addr;
}
cpu_register_physical_memory_log(int128_get64(fr->addr.start),
int128_get64(fr->addr.size),
phys_offset,
region_offset,
fr->dirty_log_mask);
cpu_register_physical_memory_log(&section, fr->readable, fr->readonly);
}
static void as_memory_range_del(AddressSpace *as, FlatRange *fr)
{
cpu_register_physical_memory(int128_get64(fr->addr.start),
int128_get64(fr->addr.size),
io_mem_unassigned.ram_addr);
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),
};
cpu_register_physical_memory_log(&section, true, false);
}
static void as_memory_log_start(AddressSpace *as, FlatRange *fr)