diff options
author | Jan Kiszka <jan.kiszka@siemens.com> | 2011-10-23 16:01:19 +0200 |
---|---|---|
committer | Jan Kiszka <jan.kiszka@siemens.com> | 2012-01-19 12:14:41 +0100 |
commit | 1660e72d4fbbd87e34eb4017d7e7c0ff4e29ca84 (patch) | |
tree | 5678349dbb69fe984dc0a7f1168afd859b3a62f7 /memory.c | |
parent | 244ac3af234fd636141182d60a007fcffd0970dc (diff) |
memory: Introduce memory_region_init_reservation
Introduce a memory region type that can reserve I/O space. Such regions
are useful for modeling I/O that is only handled outside of QEMU, i.e.
in the context of an accelerator like KVM.
Any access to such a region from QEMU is a bug, but could theoretically
be triggered by guest code (DMA to reserved region). So only warning
about such events once, then ignore them.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Diffstat (limited to 'memory.c')
-rw-r--r-- | memory.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -1049,6 +1049,42 @@ void memory_region_init_rom_device(MemoryRegion *mr, mr->ram_addr |= cpu_register_io_memory(mr); } +static uint64_t invalid_read(void *opaque, target_phys_addr_t addr, + unsigned size) +{ + MemoryRegion *mr = opaque; + + if (!mr->warning_printed) { + fprintf(stderr, "Invalid read from memory region %s\n", mr->name); + mr->warning_printed = true; + } + return -1U; +} + +static void invalid_write(void *opaque, target_phys_addr_t addr, uint64_t data, + unsigned size) +{ + MemoryRegion *mr = opaque; + + if (!mr->warning_printed) { + fprintf(stderr, "Invalid write to memory region %s\n", mr->name); + mr->warning_printed = true; + } +} + +static const MemoryRegionOps reservation_ops = { + .read = invalid_read, + .write = invalid_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +void memory_region_init_reservation(MemoryRegion *mr, + const char *name, + uint64_t size) +{ + memory_region_init_io(mr, &reservation_ops, mr, name, size); +} + void memory_region_destroy(MemoryRegion *mr) { assert(QTAILQ_EMPTY(&mr->subregions)); |