From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [Qemu-devel] [PATCH 10/23] memory: add backward compatibility for old mmio registration Date: Mon, 25 Jul 2011 14:02:50 -0500 Message-ID: <4E2DBDDA.8090501@codemonkey.ws> References: <1311602584-23409-1-git-send-email-avi@redhat.com> <1311602584-23409-11-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mail-yi0-f46.google.com ([209.85.218.46]:48334 "EHLO mail-yi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752667Ab1GYTCx (ORCPT ); Mon, 25 Jul 2011 15:02:53 -0400 Received: by yia27 with SMTP id 27so2431295yia.19 for ; Mon, 25 Jul 2011 12:02:52 -0700 (PDT) In-Reply-To: <1311602584-23409-11-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 07/25/2011 09:02 AM, Avi Kivity wrote: > This eases the transition to the new API. > > Signed-off-by: Avi Kivity Reviewed-by: Anthony Liguori Regards, Anthony Liguori > --- > memory.c | 10 ++++++++++ > memory.h | 10 ++++++++++ > 2 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/memory.c b/memory.c > index bb04952..e4446a0 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 > > typedef struct AddrRange AddrRange; > @@ -499,6 +500,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; > @@ -535,6 +540,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 f026eae..4624946 100644 > --- a/memory.h > +++ b/memory.h > @@ -15,6 +15,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. > @@ -23,6 +24,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 > */ > @@ -72,6 +78,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;