From patchwork Mon Aug 15 14:17:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 1067822 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7FEIhDs011299 for ; Mon, 15 Aug 2011 14:18:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753954Ab1HOOSU (ORCPT ); Mon, 15 Aug 2011 10:18:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21662 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753583Ab1HOORp (ORCPT ); Mon, 15 Aug 2011 10:17:45 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7FEHhmb002886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Aug 2011 10:17:43 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7FEHgLd007298; Mon, 15 Aug 2011 10:17:43 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id A2988250B57; Mon, 15 Aug 2011 17:17:40 +0300 (IDT) From: Avi Kivity To: Anthony Liguori , qemu-devel@nongnu.org Cc: kvm@vger.kernel.org Subject: [PATCH v2 15/24] sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback Date: Mon, 15 Aug 2011 17:17:29 +0300 Message-Id: <1313417858-6454-16-git-send-email-avi@redhat.com> In-Reply-To: <1313417858-6454-1-git-send-email-avi@redhat.com> References: <1313417858-6454-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 15 Aug 2011 14:18:43 +0000 (UTC) sysbus_init_mmio_cb() uses the destructive IO_MEM_UNASSIGNED to remove a region. Provide an alternative that calls an unmap callback, so the removal may be done non-destructively. Signed-off-by: Avi Kivity --- hw/sysbus.c | 15 +++++++++++++++ hw/sysbus.h | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/sysbus.c b/hw/sysbus.c index ea442ac..64749e0 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -53,6 +53,8 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) if (dev->mmio[n].memory) { memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory); + } else if (dev->mmio[n].unmap) { + dev->mmio[n].unmap(dev, dev->mmio[n].addr); } else { cpu_register_physical_memory(dev->mmio[n].addr, dev->mmio[n].size, IO_MEM_UNASSIGNED); @@ -117,6 +119,19 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size, dev->mmio[n].cb = cb; } +void sysbus_init_mmio_cb2(SysBusDevice *dev, + mmio_mapfunc cb, mmio_mapfunc unmap) +{ + int n; + + assert(dev->num_mmio < QDEV_MAX_MMIO); + n = dev->num_mmio++; + dev->mmio[n].addr = -1; + dev->mmio[n].size = 0; + dev->mmio[n].cb = cb; + dev->mmio[n].unmap = unmap; +} + void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory) { int n; diff --git a/hw/sysbus.h b/hw/sysbus.h index 5f62e2d..16fd969 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -23,6 +23,7 @@ struct SysBusDevice { target_phys_addr_t addr; target_phys_addr_t size; mmio_mapfunc cb; + mmio_mapfunc unmap; ram_addr_t iofunc; MemoryRegion *memory; } mmio[QDEV_MAX_MMIO]; @@ -48,6 +49,8 @@ void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size, ram_addr_t iofunc); void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size, mmio_mapfunc cb); +void sysbus_init_mmio_cb2(SysBusDevice *dev, + mmio_mapfunc cb, mmio_mapfunc unmap); void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory); void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p); void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);