This eases the transition to the new API. Reviewed-by: Anthony Liguori <aliguori@xxxxxxxxxx> Signed-off-by: Avi Kivity <avi@xxxxxxxxxx> --- memory.c | 10 ++++++++++ memory.h | 10 ++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/memory.c b/memory.c index 5f2c9ef..7dd7cac 100644 --- a/memory.c +++ b/memory.c @@ -14,6 +14,7 @@ #include "memory.h" #include "exec-memory.h" #include "ioport.h" +#include "bitops.h" #include <assert.h> typedef struct AddrRange AddrRange; @@ -506,6 +507,10 @@ static uint32_t memory_region_read_thunk_n(void *_mr, return -1U; /* FIXME: better signalling */ } + if (!mr->ops->read) { + return mr->ops->old_mmio.read[bitops_ffsl(size)](mr->opaque, addr); + } + /* FIXME: support unaligned access */ access_size_min = mr->ops->impl.min_access_size; @@ -542,6 +547,11 @@ static void memory_region_write_thunk_n(void *_mr, return; /* FIXME: better signalling */ } + if (!mr->ops->write) { + mr->ops->old_mmio.write[bitops_ffsl(size)](mr->opaque, addr, data); + return; + } + /* FIXME: support unaligned access */ access_size_min = mr->ops->impl.min_access_size; diff --git a/memory.h b/memory.h index 40ab95a..003c999 100644 --- a/memory.h +++ b/memory.h @@ -28,6 +28,7 @@ typedef struct MemoryRegionOps MemoryRegionOps; typedef struct MemoryRegion MemoryRegion; typedef struct MemoryRegionPortio MemoryRegionPortio; +typedef struct MemoryRegionMmio MemoryRegionMmio; /* Must match *_DIRTY_FLAGS in cpu-all.h. To be replaced with dynamic * registration. @@ -36,6 +37,11 @@ typedef struct MemoryRegionPortio MemoryRegionPortio; #define DIRTY_MEMORY_CODE 1 #define DIRTY_MEMORY_MIGRATION 3 +struct MemoryRegionMmio { + CPUReadMemoryFunc *read[3]; + CPUWriteMemoryFunc *write[3]; +}; + /* * Memory region callbacks */ @@ -85,6 +91,10 @@ struct MemoryRegionOps { * backwards compatibility with old portio registration */ const MemoryRegionPortio *old_portio; + /* If .read and .write are not present, old_mmio may be used for + * backwards compatibility with old mmio registration + */ + const MemoryRegionMmio old_mmio; }; typedef struct CoalescedMemoryRange CoalescedMemoryRange; -- 1.7.5.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html