From patchwork Tue Aug 16 16:45:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 110194 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 F072DB6F72 for ; Wed, 17 Aug 2011 02:48:47 +1000 (EST) Received: from localhost ([::1]:41725 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtMoi-00059H-0b for incoming@patchwork.ozlabs.org; Tue, 16 Aug 2011 12:48:40 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtMo8-0003y7-3K for qemu-devel@nongnu.org; Tue, 16 Aug 2011 12:48:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtMo5-00025T-Ea for qemu-devel@nongnu.org; Tue, 16 Aug 2011 12:48:04 -0400 Received: from mail-vw0-f45.google.com ([209.85.212.45]:57789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtMo5-00024p-8t for qemu-devel@nongnu.org; Tue, 16 Aug 2011 12:48:01 -0400 Received: by mail-vw0-f45.google.com with SMTP id 17so96031vws.4 for ; Tue, 16 Aug 2011 09:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=TxswE4imtGyAJb2NFkCR8RgtMSVkYK6H3eO7/pn30qU=; b=cGLrRnBW+3lqzCqWtBT3qc9/EWFft0AzoI/oOjdsPIvAQQ9v1FY0hm0NAhjQXVZuyH nc1on9CmKHeIFgYvdBKSFrMSlAfftJbez8vXGdorky+kxYEDYt7WXQ8cu66Y1No6APBq 3prAEd3ZMqQ5aPoYtl7cR/1W/EFV4G8r3LNkw= Received: by 10.52.29.42 with SMTP id g10mr5196541vdh.36.1313513280996; Tue, 16 Aug 2011 09:48:00 -0700 (PDT) Received: from localhost.localdomain (c-71-227-161-214.hsd1.wa.comcast.net [71.227.161.214]) by mx.google.com with ESMTPS id gw3sm246636vdb.44.2011.08.16.09.47.59 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Aug 2011 09:48:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 16 Aug 2011 09:45:33 -0700 Message-Id: <1313513145-5348-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1313513145-5348-1-git-send-email-rth@twiddle.net> References: <1313513145-5348-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.45 Cc: avi@redhat.com Subject: [Qemu-devel] [PATCH 02/14] isa: Add isa_register_old_portio_list(). 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: Richard Henderson --- hw/isa-bus.c | 39 +++++++++++++++++++++++++++++++++++++++ hw/isa.h | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletions(-) diff --git a/hw/isa-bus.c b/hw/isa-bus.c index e9c1712..d8e1880 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ +#include #include "hw.h" #include "monitor.h" #include "sysbus.h" @@ -103,6 +104,44 @@ void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start) } } +void isa_register_old_portio_list(ISADevice *dev, uint16_t start, + const MemoryRegionPortio *pio_start, + void *opaque, const char *name) +{ + MemoryRegion *io_space = isabus->address_space_io; + const MemoryRegionPortio *pio_iter; + + /* START is how we should treat DEV, regardless of the actual + contents of the portio array. This is how the old code + actually handled e.g. the FDC device. */ + if (dev) { + isa_init_ioport(dev, start); + } + + for (; pio_start->size != 0; pio_start = pio_iter + 1) { + unsigned int off_low = UINT_MAX, off_high = 0; + MemoryRegionOps *ops; + MemoryRegion *region; + + for (pio_iter = pio_start; pio_iter->size; ++pio_iter) { + if (pio_iter->offset < off_low) { + off_low = pio_iter->offset; + } + if (pio_iter->offset + pio_iter->len > off_high) { + off_high = pio_iter->offset + pio_iter->len; + } + } + + ops = g_new(MemoryRegionOps, 1); + ops->old_portio = pio_start; + + region = g_new(MemoryRegion, 1); + memory_region_init_io(region, ops, opaque, name, off_high - off_low); + memory_region_set_offset(region, start + off_low); + memory_region_add_subregion(io_space, start + off_low, region); + } +} + static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base) { ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev); diff --git a/hw/isa.h b/hw/isa.h index c5c2618..117d8b0 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -28,7 +28,6 @@ ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); void isa_bus_irqs(qemu_irq *irqs); qemu_irq isa_get_irq(int isairq); void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); -void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); void isa_init_ioport(ISADevice *dev, uint16_t ioport); void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length); void isa_qdev_register(ISADeviceInfo *info); @@ -37,6 +36,38 @@ ISADevice *isa_create(const char *name); ISADevice *isa_try_create(const char *name); ISADevice *isa_create_simple(const char *name); +/** + * isa_register_ioport: Install an I/O port region on the ISA bus. + * + * Register an I/O port region via memory_region_add_subregion + * inside the ISA I/O address space. + * + * @dev: the ISADevice against which these are registered; may be NULL. + * @io: the #MemoryRegion being registered. + * @start: the base I/O port. + */ +void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); + +/** + * isa_register_old_portio_list: Initialize a set of ISA io ports + * + * Several ISA devices have many dis-joint I/O ports. Worse, these I/O + * ports can be interleaved with I/O ports from other devices. This + * function makes it easy to create multiple MemoryRegions for a single + * device and use the legacy portio routines. + * + * @dev: the ISADevice against which these are registered; may be NULL. + * @start: the base I/O port against which the portio->offset is applied. + * @old_portio: A concatenation of several #MemoryRegionOps old_portio + * parameters. The entire list should be terminated by a double + * PORTIO_END_OF_LIST(). + * @opaque: passed into the old_portio callbacks. + * @name: passed into memory_region_init_io. + */ +void isa_register_old_portio_list(ISADevice *dev, uint16_t start, + const MemoryRegionPortio *old_portio, + void *opaque, const char *name); + extern target_phys_addr_t isa_mem_base; void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);