From patchwork Mon Dec 19 14:13:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 132252 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 CBEFBB7046 for ; Tue, 20 Dec 2011 02:08:18 +1100 (EST) Received: from localhost ([::1]:52249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdzd-0005JH-G4 for incoming@patchwork.ozlabs.org; Mon, 19 Dec 2011 09:15:05 -0500 Received: from eggs.gnu.org ([140.186.70.92]:48640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyp-0002wp-HC for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rcdyf-0001tB-RG for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rcdyf-0001sj-Fh for qemu-devel@nongnu.org; Mon, 19 Dec 2011 09:14:05 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBJEE1kI008939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Dec 2011 09:14:01 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBJEE07e032288; Mon, 19 Dec 2011 09:14:01 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 9091A250BA2; Mon, 19 Dec 2011 16:13:54 +0200 (IST) From: Avi Kivity To: Stefano Stabellini , qemu-devel@nongnu.org, "Michael S. Tsirkin" Date: Mon, 19 Dec 2011 16:13:24 +0200 Message-Id: <1324304024-11220-4-git-send-email-avi@redhat.com> In-Reply-To: <1324304024-11220-1-git-send-email-avi@redhat.com> References: <1324304024-11220-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: xen-devel@lists.xensource.com, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 03/23] memory: add memory_region_is_ram() 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 Signed-off-by: Avi Kivity --- memory.c | 8 ++++++++ memory.h | 10 ++++++++++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/memory.c b/memory.c index d8b7c27..6fd31d4 100644 --- a/memory.c +++ b/memory.c @@ -831,6 +831,7 @@ void memory_region_init(MemoryRegion *mr, mr->addr = 0; mr->offset = 0; mr->terminates = false; + mr->ram = false; mr->readable = true; mr->readonly = false; mr->destructor = memory_region_destructor_none; @@ -997,6 +998,7 @@ void memory_region_init_ram(MemoryRegion *mr, uint64_t size) { memory_region_init(mr, name, size); + mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr = qemu_ram_alloc(dev, name, size, mr); @@ -1010,6 +1012,7 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, void *ptr) { memory_region_init(mr, name, size); + mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram_from_ptr; mr->ram_addr = qemu_ram_alloc_from_ptr(dev, name, size, ptr, mr); @@ -1065,6 +1068,11 @@ uint64_t memory_region_size(MemoryRegion *mr) return int128_get64(mr->size); } +bool memory_region_is_ram(MemoryRegion *mr) +{ + return mr->ram; +} + void memory_region_set_offset(MemoryRegion *mr, target_phys_addr_t offset) { mr->offset = offset; diff --git a/memory.h b/memory.h index 1d5c414..13f88c0 100644 --- a/memory.h +++ b/memory.h @@ -122,6 +122,7 @@ struct MemoryRegion { IORange iorange; bool terminates; bool readable; + bool ram; bool readonly; /* For RAM regions */ MemoryRegion *alias; target_phys_addr_t alias_offset; @@ -284,6 +285,15 @@ void memory_region_destroy(MemoryRegion *mr); uint64_t memory_region_size(MemoryRegion *mr); /** + * memory_region_is_ram: check whether a memory region is random access + * + * Returns %true is a memory region is random access. + * + * @mr: the memory region being queried + */ +bool memory_region_is_ram(MemoryRegion *mr); + +/** * memory_region_get_ram_ptr: Get a pointer into a RAM memory region. * * Returns a host pointer to a RAM memory region (created with