From patchwork Fri Oct 19 06:40:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 192573 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 A42352C007D for ; Fri, 19 Oct 2012 17:41:50 +1100 (EST) Received: from localhost ([::1]:59629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP6HE-000509-Qg for incoming@patchwork.ozlabs.org; Fri, 19 Oct 2012 02:41:48 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP6Gc-0003aT-NV for qemu-devel@nongnu.org; Fri, 19 Oct 2012 02:41:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TP6GY-0003wo-Na for qemu-devel@nongnu.org; Fri, 19 Oct 2012 02:41:10 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:34089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TP6GY-0003iM-HQ for qemu-devel@nongnu.org; Fri, 19 Oct 2012 02:41:06 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so204353pbb.4 for ; Thu, 18 Oct 2012 23:41:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=FV7RtAw3iq5dLBsiC/BhPIbU8djhsGM0kI8d2bGiKdE=; b=ANibsSB5Mk24nqPzDsI4+TSXoL5xqlWJi/M68oeaUWlHzO3omMu+9JLLZh6NauUFna ZMLsN3f0OZJB8YsB3RYEf5tstFcPP2shIHjotxECnb8vkpPpkVdBo4RwkPum4ARPyHvH rBTRB0+W91GMqYvq0dhxmmbUJ4k/DmicRs3prW4WV4rLtg776ItkH0FNEblXXEeRpco8 MrbUDNF3kLAVPavo5NzLz9TP7XrCdVh7qgvCdQK2ttbaoiAv98+ll9nWvEgyJo7Bp0b+ MYOrG2RFe0dxPmKg27ojagn1qjCoMsypQryv09RgRDmSZwOqYlIPIOzi1OBjTm1Jzfdq o1zg== Received: by 10.68.135.33 with SMTP id pp1mr2749854pbb.5.1350628866145; Thu, 18 Oct 2012 23:41:06 -0700 (PDT) Received: from localhost ([124.148.20.9]) by mx.google.com with ESMTPS id y5sm598239pav.36.2012.10.18.23.41.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Oct 2012 23:41:05 -0700 (PDT) From: Peter Crosthwaite To: qemu-devel@nongnu.org, edgar.iglesias@gmail.com, peter.maydell@linaro.org Date: Fri, 19 Oct 2012 16:40:28 +1000 Message-Id: X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlqFZ7wAsIDxz2/sQUZZynTELDespFFGWqUuO4n0UWImV2TrTCdX7QN/bYV3wNZ7laZ6zb0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Peter Crosthwaite , john.williams@xilinx.com Subject: [Qemu-devel] [PATCH v1 4/7] sysbus/sysbus_mmio_map: parameterise mapped region 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 Add a variant to sysbus_mmio_map that allow specifying a target memory region. The requested device memory region is mapped within the argument target memory region rather than the default (get_system_memory()). Behaviour of original sysbus_mmio_map remains unchanged. The will probably go away or morph into something else with Anthony sysbus purge so its intended to be a bridging patch until those refactorings go live. Signed-off-by: Peter Crosthwaite --- hw/sysbus.c | 11 ++++++++--- hw/sysbus.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/sysbus.c b/hw/sysbus.c index c173840..bd45183 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -48,7 +48,8 @@ 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_map_to_region(SysBusDevice *dev, int n, + target_phys_addr_t addr, MemoryRegion *region) { assert(n >= 0 && n < dev->num_mmio); @@ -58,14 +59,18 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) } if (dev->mmio[n].addr != (target_phys_addr_t)-1) { /* Unregister previous mapping. */ - memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory); + memory_region_del_subregion(region, dev->mmio[n].memory); } dev->mmio[n].addr = addr; - memory_region_add_subregion(get_system_memory(), + memory_region_add_subregion(region, addr, dev->mmio[n].memory); } +void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) +{ + sysbus_mmio_map_to_region(dev, n, addr, get_system_memory()); +} /* Request an IRQ source. The actual IRQ object may be populated later. */ void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p) diff --git a/hw/sysbus.h b/hw/sysbus.h index acfbcfb..9cdb2b4 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -56,6 +56,8 @@ 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_to_region(SysBusDevice *dev, int n, + target_phys_addr_t addr, MemoryRegion *region); void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr, MemoryRegion *mem);