From patchwork Thu Jul 22 22:00:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 59697 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C25EB1007DA for ; Fri, 23 Jul 2010 09:20:02 +1000 (EST) Received: from localhost ([127.0.0.1]:34844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oc4Oy-000500-Eh for incoming@patchwork.ozlabs.org; Thu, 22 Jul 2010 18:38:04 -0400 Received: from [140.186.70.92] (port=42713 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oc3wy-00031d-Ov for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:09:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oc3oa-00035n-ML for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:00:29 -0400 Received: from mail-qw0-f45.google.com ([209.85.216.45]:35073) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oc3oa-0002yG-IQ for qemu-devel@nongnu.org; Thu, 22 Jul 2010 18:00:28 -0400 Received: by mail-qw0-f45.google.com with SMTP id 6so3333686qwf.4 for ; Thu, 22 Jul 2010 15:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=xn5bl/m/SsGbjgVWmwYh7EX1mdNW72t6AiN493SJxrM=; b=BPE3AmZhHZ4MSV1HwwO9p3XiPP0ESN3gYl5I7c1holayV47sdC6XkqIbd12S+59DHG /atqA94u6EcQKdCJE9Rq3vRoMR0TuXcwUdOxTrHR+J2Roe0NJ5MrBB+YOFQHbG8pqj5m ZWTfFU31SdQxbRQmVqAG55LVQlPjaUe2sxyws= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=P0RyQ8022hLgeJU9CMKQrw1J+WD4s0jOvqK0IixQIAtB1LeATN/GwcO9BUKNlN368i RzoGnPw3t0KDRQMvFKVh+qiBFFpgq0rLvUYGoMSI6fUddV6KY5WOeFtKHKwbhV1es9Cr CA4iCOSufuwlcpZ3svLWJw8TkLn7JIwJJFgFw= Received: by 10.224.29.11 with SMTP id o11mr1337512qac.184.1279836028081; Thu, 22 Jul 2010 15:00:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.185.146 with HTTP; Thu, 22 Jul 2010 15:00:08 -0700 (PDT) From: Blue Swirl Date: Thu, 22 Jul 2010 22:00:08 +0000 Message-ID: To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 21/34] lsi53c895a: convert to pci_bar_map X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use pci_bar_map() and post_map_func instead of a mapping function. Signed-off-by: Blue Swirl --- hw/lsi53c895a.c | 47 ++++++++++++++++++++--------------------------- 1 files changed, 20 insertions(+), 27 deletions(-) { @@ -2026,17 +2011,19 @@ static void lsi_ram_mapfunc(PCIDevice *pci_dev, int region_num, DPRINTF("Mapping ram at %08"FMT_PCIBUS"\n", addr); s->script_ram_base = addr; - cpu_register_physical_memory(addr + 0, 0x2000, s->ram_io_addr); } -static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - LSIState *s = DO_UPCAST(LSIState, dev, pci_dev); +static IOPortWriteFunc * const lsi_io_writes[] = { + lsi_io_writeb, + lsi_io_writew, + lsi_io_writel, +}; - DPRINTF("Mapping registers at %08"FMT_PCIBUS"\n", addr); - cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr); -} +static IOPortReadFunc * const lsi_io_reads[] = { + lsi_io_readb, + lsi_io_readw, + lsi_io_readl, +}; static void lsi_scsi_reset(DeviceState *dev) { @@ -2153,6 +2140,7 @@ static int lsi_scsi_init(PCIDevice *dev) { LSIState *s = DO_UPCAST(LSIState, dev, dev); uint8_t *pci_conf; + int io_index; pci_conf = s->dev.config; @@ -2177,12 +2165,17 @@ static int lsi_scsi_init(PCIDevice *dev) lsi_ram_writefn, s); /* TODO: use dev and get rid of cast below */ - pci_register_bar((struct PCIDevice *)s, 0, 256, - PCI_BASE_ADDRESS_SPACE_IO, lsi_io_mapfunc, NULL); + pci_register_bar((struct PCIDevice *)s, 0, 256, PCI_BASE_ADDRESS_SPACE_IO, + NULL, NULL); + io_index = cpu_register_io(lsi_io_reads, lsi_io_writes, 256, s); + pci_bar_map((struct PCIDevice *)s, 0, 0, 0, 256, io_index); + pci_register_bar((struct PCIDevice *)s, 1, 0x400, - PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_mmio_mapfunc, NULL); + PCI_BASE_ADDRESS_SPACE_MEMORY, NULL, NULL); + pci_bar_map((struct PCIDevice *)s, 1, 0, 0, 0x400, s->mmio_io_addr); pci_register_bar((struct PCIDevice *)s, 2, 0x2000, - PCI_BASE_ADDRESS_SPACE_MEMORY, lsi_ram_mapfunc, NULL); + PCI_BASE_ADDRESS_SPACE_MEMORY, NULL, lsi_ram_mapfunc); + pci_bar_map((struct PCIDevice *)s, 2, 0, 0, 0x2000, s->ram_io_addr); QTAILQ_INIT(&s->queue); scsi_bus_new(&s->bus, &dev->qdev, 1, LSI_MAX_DEVS, lsi_command_complete); diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index a9cbcef..ed52db0 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -2004,21 +2004,6 @@ static void lsi_io_writel(void *opaque, uint32_t addr, uint32_t val) lsi_reg_writeb(s, addr + 3, (val >> 24) & 0xff); } -static void lsi_io_mapfunc(PCIDevice *pci_dev, int region_num, - pcibus_t addr, pcibus_t size, int type) -{ - LSIState *s = DO_UPCAST(LSIState, dev, pci_dev); - - DPRINTF("Mapping IO at %08"FMT_PCIBUS"\n", addr); - - register_ioport_write(addr, 256, 1, lsi_io_writeb, s); - register_ioport_read(addr, 256, 1, lsi_io_readb, s); - register_ioport_write(addr, 256, 2, lsi_io_writew, s); - register_ioport_read(addr, 256, 2, lsi_io_readw, s); - register_ioport_write(addr, 256, 4, lsi_io_writel, s); - register_ioport_read(addr, 256, 4, lsi_io_readl, s); -} - static void lsi_ram_mapfunc(PCIDevice *pci_dev, int region_num, pcibus_t addr, pcibus_t size, int type)