From patchwork Fri Jul 15 14:58:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 2723 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CCF5923F42 for ; Fri, 15 Jul 2011 14:58:39 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9C3DFA18709 for ; Fri, 15 Jul 2011 14:58:39 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so904513qwb.11 for ; Fri, 15 Jul 2011 07:58:39 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr2944377qci.114.1310741919387; Fri, 15 Jul 2011 07:58:39 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs50445qcb; Fri, 15 Jul 2011 07:58:39 -0700 (PDT) Received: by 10.216.162.141 with SMTP id y13mr568602wek.94.1310741915552; Fri, 15 Jul 2011 07:58:35 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id y42si2860054weq.81.2011.07.15.07.58.33 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jul 2011 07:58:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QhjqU-0000Qh-MN; Fri, 15 Jul 2011 15:58:26 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio , =?UTF-8?q?Juha=20Riihim=C3=A4ki?= , andrzej zaborowski , Markus Armbruster Subject: [PATCH 11/12] hw/sysbus: Add sysbus_mmio_unmap() for unmapping a region Date: Fri, 15 Jul 2011 15:58:25 +0100 Message-Id: <1310741906-1606-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1310741906-1606-1-git-send-email-peter.maydell@linaro.org> References: <1310741906-1606-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 From: Juha Riihimäki Add support for unmapping a SysBus device's mmio region, via a new function sysbus_mmio_unmap(). This simply reverses the effect of sysbus_mmio_map(). Signed-off-by: Juha Riihimäki Signed-off-by: Peter Maydell --- hw/sysbus.c | 17 +++++++++++++++++ hw/sysbus.h | 1 + 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/sysbus.c b/hw/sysbus.c index 2e22be7..021c653 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -39,6 +39,23 @@ void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq) } } +void sysbus_mmio_unmap(SysBusDevice *dev, int n) +{ + assert(n >= 0 && n < dev->num_mmio); + + if (dev->mmio[n].addr == (target_phys_addr_t)-1) { + /* region already unmapped */ + return; + } + if (dev->mmio[n].cb) { + dev->mmio[n].cb(dev, (target_phys_addr_t)-1); + } else { + cpu_register_physical_memory(dev->mmio[n].addr, dev->mmio[n].size, + IO_MEM_UNASSIGNED); + } + dev->mmio[n].addr = (target_phys_addr_t)-1; +} + void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) { assert(n >= 0 && n < dev->num_mmio); diff --git a/hw/sysbus.h b/hw/sysbus.h index 4e8cb16..4f93b70 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -53,6 +53,7 @@ void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size); void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); +void sysbus_mmio_unmap(SysBusDevice *dev, int n); /* Legacy helper function for creating devices. */ DeviceState *sysbus_create_varargs(const char *name,