From patchwork Wed Jul 20 16:49:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 105987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0B5FB6F77 for ; Thu, 21 Jul 2011 16:50:52 +1000 (EST) Received: from localhost ([::1]:35532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjdqH-0003bc-4P for incoming@patchwork.ozlabs.org; Wed, 20 Jul 2011 16:58:05 -0400 Received: from eggs.gnu.org ([140.186.70.92]:36549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qja6y-0006zJ-SN for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:59:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QjZyv-0004wZ-SV for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:50:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QjZyt-0004tw-CD for qemu-devel@nongnu.org; Wed, 20 Jul 2011 12:50:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6KGogR0020017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 20 Jul 2011 12:50:42 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6KGofdM013949; Wed, 20 Jul 2011 12:50:41 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 0D5E1250B3D; Wed, 20 Jul 2011 19:50:39 +0300 (IDT) From: Avi Kivity To: qemu-devel@nongnu.org Date: Wed, 20 Jul 2011 19:49:21 +0300 Message-Id: <1311180636-17012-12-git-send-email-avi@redhat.com> In-Reply-To: <1311180636-17012-1-git-send-email-avi@redhat.com> References: <1311180636-17012-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [RFC v5 11/86] memory: add backward compatibility for old mmio registration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This eases the transition to the new API. Signed-off-by: Avi Kivity --- 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;