From patchwork Thu Sep 10 09:43:27 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 33304 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 8A53FB6F34 for ; Thu, 10 Sep 2009 20:47:07 +1000 (EST) Received: from localhost ([127.0.0.1]:46316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlhBA-0000z4-Dj for incoming@patchwork.ozlabs.org; Thu, 10 Sep 2009 06:47:04 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MlgC1-0008W3-Df for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MlgBv-0008T7-2y for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:51 -0400 Received: from [199.232.76.173] (port=39545 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MlgBu-0008Sw-T5 for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50963) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MlgBu-0005Vz-Bt for qemu-devel@nongnu.org; Thu, 10 Sep 2009 05:43:46 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8A9hjbF032520 for ; Thu, 10 Sep 2009 05:43:45 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-74.ams2.redhat.com [10.36.9.74]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n8A9hebt019344; Thu, 10 Sep 2009 05:43:42 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id BC330700E0; Thu, 10 Sep 2009 11:43:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 10 Sep 2009 11:43:27 +0200 Message-Id: <1252575815-7824-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1252575815-7824-1-git-send-email-kraxel@redhat.com> References: <1252575815-7824-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH v2 05/13] qdev: simplify isa irq assignments 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 isa-bus owns the isa irqs now, so it can hand them out directly. There is no need for the separate isa_connect_irqs step, drop it. Also hard-code isa interrupts which can't be configured anyway. Signed-off-by: Gerd Hoffmann --- hw/fdc.c | 6 +++--- hw/isa-bus.c | 38 +++++++++++--------------------------- hw/isa.h | 6 ++---- hw/mips_malta.c | 2 +- hw/pc.c | 2 +- hw/pckbd.c | 4 ++-- hw/sun4u.c | 2 +- 7 files changed, 21 insertions(+), 39 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index d761e62..47b1c9d 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -1875,10 +1875,9 @@ fdctrl_t *fdctrl_init_isa(BlockDriverState **fds) { fdctrl_t *fdctrl; ISADevice *dev; - int isairq = 6; int dma_chann = 2; - dev = isa_create_simple("isa-fdc", isairq, -1); + dev = isa_create_simple("isa-fdc"); fdctrl = &(DO_UPCAST(fdctrl_isabus_t, busdev, dev)->state); fdctrl->dma_chann = dma_chann; @@ -1969,6 +1968,7 @@ static int isabus_fdc_init1(ISADevice *dev) fdctrl_isabus_t *isa = DO_UPCAST(fdctrl_isabus_t, busdev, dev); fdctrl_t *fdctrl = &isa->state; int iobase = 0x3f0; + int isairq = 6; register_ioport_read(iobase + 0x01, 5, 1, &fdctrl_read_port, fdctrl); @@ -1978,7 +1978,7 @@ static int isabus_fdc_init1(ISADevice *dev) &fdctrl_write_port, fdctrl); register_ioport_write(iobase + 0x07, 1, 1, &fdctrl_write_port, fdctrl); - isa_init_irq(&isa->busdev, &fdctrl->irq); + isa_init_irq(&isa->busdev, &fdctrl->irq, isairq); return fdctrl_init_common(fdctrl); } diff --git a/hw/isa-bus.c b/hw/isa-bus.c index fde066a..bfd0fff 100644 --- a/hw/isa-bus.c +++ b/hw/isa-bus.c @@ -57,20 +57,6 @@ void isa_bus_irqs(qemu_irq *irqs) isabus->irqs = irqs; } -void isa_connect_irq(ISADevice *dev, int devnr, int isairq) -{ - assert(devnr >= 0 && devnr < dev->nirqs); - if (isabus->assigned & (1 << isairq)) { - fprintf(stderr, "isa irq %d already assigned\n", isairq); - exit(1); - } - if (dev->irqs[devnr]) { - isabus->assigned |= (1 << isairq); - dev->isairq[devnr] = isairq; - *dev->irqs[devnr] = isabus->irqs[isairq]; - } -} - /* * isa_reserve_irq() reserves the ISA irq and returns the corresponding * qemu_irq entry for the i8259. @@ -92,10 +78,16 @@ qemu_irq isa_reserve_irq(int isairq) return isabus->irqs[isairq]; } -void isa_init_irq(ISADevice *dev, qemu_irq *p) +void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq) { - assert(dev->nirqs < ARRAY_SIZE(dev->irqs)); - dev->irqs[dev->nirqs] = p; + assert(dev->nirqs < ARRAY_SIZE(dev->isairq)); + if (isabus->assigned & (1 << isairq)) { + fprintf(stderr, "isa irq %d already assigned\n", isairq); + exit(1); + } + isabus->assigned |= (1 << isairq); + dev->isairq[dev->nirqs] = isairq; + *p = isabus->irqs[isairq]; dev->nirqs++; } @@ -117,25 +109,17 @@ void isa_qdev_register(ISADeviceInfo *info) qdev_register(&info->qdev); } -ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32 irq2) +ISADevice *isa_create_simple(const char *name) { DeviceState *dev; - ISADevice *isa; if (!isabus) { fprintf(stderr, "Tried to create isa device %s with no isa bus present.\n", name); return NULL; } dev = qdev_create(&isabus->qbus, name); - isa = DO_UPCAST(ISADevice, qdev, dev); qdev_init(dev); - if (irq != -1) { - isa_connect_irq(isa, 0, irq); - } - if (irq2 != -1) { - isa_connect_irq(isa, 1, irq2); - } - return isa; + return DO_UPCAST(ISADevice, qdev, dev); } static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent) diff --git a/hw/isa.h b/hw/isa.h index 24c5c66..4582ff9 100644 --- a/hw/isa.h +++ b/hw/isa.h @@ -13,7 +13,6 @@ typedef struct ISADeviceInfo ISADeviceInfo; struct ISADevice { DeviceState qdev; uint32_t isairq[2]; - qemu_irq *irqs[2]; int nirqs; }; @@ -25,11 +24,10 @@ struct ISADeviceInfo { ISABus *isa_bus_new(DeviceState *dev); void isa_bus_irqs(qemu_irq *irqs); -void isa_connect_irq(ISADevice *dev, int devirq, int isairq); qemu_irq isa_reserve_irq(int isairq); -void isa_init_irq(ISADevice *dev, qemu_irq *p); +void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); void isa_qdev_register(ISADeviceInfo *info); -ISADevice *isa_create_simple(const char *name, uint32_t irq, uint32_t irq2); +ISADevice *isa_create_simple(const char *name); extern target_phys_addr_t isa_mem_base; diff --git a/hw/mips_malta.c b/hw/mips_malta.c index 3222e16..32c7102 100644 --- a/hw/mips_malta.c +++ b/hw/mips_malta.c @@ -921,7 +921,7 @@ void mips_malta_init (ram_addr_t ram_size, DMA_init(0); /* Super I/O */ - isa_dev = isa_create_simple("i8042", 1, 12); + isa_dev = isa_create_simple("i8042"); rtc_state = rtc_init(0x70, isa_reserve_irq(8), 2000); serial_init(0x3f8, isa_reserve_irq(4), 115200, serial_hds[0]); diff --git a/hw/pc.c b/hw/pc.c index 0219961..e1ffaa4 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -1373,7 +1373,7 @@ static void pc_init1(ram_addr_t ram_size, } } - isa_dev = isa_create_simple("i8042", 1, 12); + isa_dev = isa_create_simple("i8042"); DMA_init(0); #ifdef HAS_AUDIO audio_init(pci_enabled ? pci_bus : NULL, isa_irq); diff --git a/hw/pckbd.c b/hw/pckbd.c index b4b65a6..5acf4a6 100644 --- a/hw/pckbd.c +++ b/hw/pckbd.c @@ -450,8 +450,8 @@ static int i8042_initfn(ISADevice *dev) { KBDState *s = &(DO_UPCAST(ISAKBDState, dev, dev)->kbd); - isa_init_irq(dev, &s->irq_kbd); - isa_init_irq(dev, &s->irq_mouse); + isa_init_irq(dev, &s->irq_kbd, 1); + isa_init_irq(dev, &s->irq_mouse, 12); kbd_reset(s); register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s); diff --git a/hw/sun4u.c b/hw/sun4u.c index b71df1f..ffda4cd 100644 --- a/hw/sun4u.c +++ b/hw/sun4u.c @@ -617,7 +617,7 @@ static void sun4uv_init(ram_addr_t RAM_size, pci_cmd646_ide_init(pci_bus, hd, 1); - isa_create_simple("i8042", 1, 12); + isa_create_simple("i8042"); for(i = 0; i < MAX_FD; i++) { dinfo = drive_get(IF_FLOPPY, 0, i); fd[i] = dinfo ? dinfo->bdrv : NULL;