From patchwork Tue Oct 9 16:32:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 190389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 08DEB2C0254 for ; Wed, 10 Oct 2012 04:37:02 +1100 (EST) Received: from localhost ([::1]:47213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLclr-0006aA-1u for incoming@patchwork.ozlabs.org; Tue, 09 Oct 2012 12:35:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLckd-0004N3-8b for qemu-devel@nongnu.org; Tue, 09 Oct 2012 12:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLckO-0007h7-B9 for qemu-devel@nongnu.org; Tue, 09 Oct 2012 12:33:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLckO-0007gM-0v for qemu-devel@nongnu.org; Tue, 09 Oct 2012 12:33:32 -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 q99GXT1R030119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Oct 2012 12:33:29 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q99GWrq9008429; Tue, 9 Oct 2012 12:33:25 -0400 From: Avi Kivity To: qemu-devel@nongnu.org, Anthony Liguori , liu ping fan , "Michael S. Tsirkin" , Paolo Bonzini , Blue Swirl Date: Tue, 9 Oct 2012 18:32:31 +0200 Message-Id: <1349800368-15228-7-git-send-email-avi@redhat.com> In-Reply-To: <1349800368-15228-1-git-send-email-avi@redhat.com> References: <1349800368-15228-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 Subject: [Qemu-devel] [PATCH v3 06/23] memory: export AddressSpace 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 The DMA API will use an AddressSpace to differentiate among different initiators. Reviewed-by: Anthony Liguori Signed-off-by: Avi Kivity --- memory.c | 11 +---------- memory.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/memory.c b/memory.c index 7e9e373..431a867 100644 --- a/memory.c +++ b/memory.c @@ -216,17 +216,8 @@ struct FlatView { unsigned nr_allocated; }; -typedef struct AddressSpace AddressSpace; typedef struct AddressSpaceOps AddressSpaceOps; -/* A system address space - I/O, memory, etc. */ -struct AddressSpace { - MemoryRegion *root; - FlatView *current_map; - int ioeventfd_nb; - MemoryRegionIoeventfd *ioeventfds; -}; - #define FOR_EACH_FLAT_RANGE(var, view) \ for (var = (view)->ranges; var < (view)->ranges + (view)->nr; ++var) @@ -1510,7 +1501,7 @@ void memory_listener_unregister(MemoryListener *listener) QTAILQ_REMOVE(&memory_listeners, listener, link); } -static void address_space_init(AddressSpace *as, MemoryRegion *root) +void address_space_init(AddressSpace *as, MemoryRegion *root) { memory_region_transaction_begin(); as->root = root; diff --git a/memory.h b/memory.h index 37ce151..a1d75e7 100644 --- a/memory.h +++ b/memory.h @@ -157,6 +157,19 @@ struct MemoryRegionPortio { #define PORTIO_END_OF_LIST() { } +typedef struct AddressSpace AddressSpace; + +/** + * AddressSpace: describes a mapping of addresses to #MemoryRegion objects + */ +struct AddressSpace { + /* All fields are private. */ + MemoryRegion *root; + struct FlatView *current_map; + int ioeventfd_nb; + struct MemoryRegionIoeventfd *ioeventfds; +}; + typedef struct MemoryRegionSection MemoryRegionSection; /** @@ -776,6 +789,14 @@ void memory_global_dirty_log_stop(void); void mtree_info(fprintf_function mon_printf, void *f); +/** + * address_space_init: initializes an address space + * + * @as: an uninitialized #AddressSpace + * @root: a #MemoryRegion that routes addesses for the address space + */ +void address_space_init(AddressSpace *as, MemoryRegion *root); + #endif #endif