From nobody Fri Nov 7 14:35:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548186799969147.10583799819653; Tue, 22 Jan 2019 11:53:19 -0800 (PST) Received: from localhost ([127.0.0.1]:48293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm26o-0008Rw-VR for importer@patchew.org; Tue, 22 Jan 2019 14:53:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1Bw-0002LZ-Hb for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm1Bu-00019F-DJ for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:32 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:16217) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gm1Ba-0000xA-94; Tue, 22 Jan 2019 13:54:12 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 116537456B1; Tue, 22 Jan 2019 13:55:55 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 792C47456B6; Tue, 22 Jan 2019 13:55:54 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Tue, 22 Jan 2019 13:39:32 +0100 To: qemu-devel@nongnu.org, qemu-block@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH 3/3] ide/via: Implement and use native PCI IDE mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The device was initialised in ISA compatibility mode and native PCI IDE mode was not implemented but no clents are known to need ISA mode but to the contrary, most clients that want to switch to and use device in native PCI IDE mode. Therefore implement native PCI mode and switch default to that. Signed-off-by: BALATON Zoltan --- hw/ide/via.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index c6e43a8812..ac9385228c 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -32,15 +32,6 @@ #include "hw/ide/pci.h" #include "trace.h" =20 -static const struct { - int iobase; - int iobase2; - int isairq; -} port_info[] =3D { - {0x1f0, 0x3f6, 14}, - {0x170, 0x376, 15}, -}; - static uint64_t bmdma_read(void *opaque, hwaddr addr, unsigned size) { @@ -110,6 +101,23 @@ static void bmdma_setup_bar(PCIIDEState *d) } } =20 +static void via_ide_set_irq(void *opaque, int n, int level) +{ + PCIDevice *d =3D PCI_DEVICE(opaque); + + if (level) { + d->config[0x70 + n * 8] |=3D 0x80; + } else { + d->config[0x70 + n * 8] &=3D ~0x80; + } + + level =3D (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80); + n =3D pci_get_byte(d->config + PCI_INTERRUPT_LINE); + if (n) { + qemu_set_irq(isa_get_irq(NULL, n), level); + } +} + static void via_ide_reset(void *opaque) { PCIIDEState *d =3D opaque; @@ -121,7 +129,7 @@ static void via_ide_reset(void *opaque) ide_bus_reset(&d->bus[i]); } =20 - pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_WAIT); + pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_WAIT= ); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); =20 @@ -158,10 +166,28 @@ static void via_ide_realize(PCIDevice *dev, Error **e= rrp) uint8_t *pci_conf =3D dev->config; int i; =20 - pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy ATA mode */ + pci_config_set_prog_interface(pci_conf, 0x8f); /* native PCI ATA mode = */ pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); + dev->wmask[PCI_INTERRUPT_LINE] =3D 0xf; =20 qemu_register_reset(via_ide_reset, d); + + memory_region_init_io(&d->data_bar[0], OBJECT(d), &pci_ide_data_le_ops, + &d->bus[0], "via-ide0-data", 8); + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &d->data_bar[0]); + + memory_region_init_io(&d->cmd_bar[0], OBJECT(d), &pci_ide_cmd_le_ops, + &d->bus[0], "via-ide0-cmd", 4); + pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->cmd_bar[0]); + + memory_region_init_io(&d->data_bar[1], OBJECT(d), &pci_ide_data_le_ops, + &d->bus[1], "via-ide1-data", 8); + pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_IO, &d->data_bar[1]); + + memory_region_init_io(&d->cmd_bar[1], OBJECT(d), &pci_ide_cmd_le_ops, + &d->bus[1], "via-ide1-cmd", 4); + pci_register_bar(dev, 3, PCI_BASE_ADDRESS_SPACE_IO, &d->cmd_bar[1]); + bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); =20 @@ -169,9 +195,7 @@ static void via_ide_realize(PCIDevice *dev, Error **err= p) =20 for (i =3D 0; i < 2; i++) { ide_bus_new(&d->bus[i], sizeof(d->bus[i]), DEVICE(d), i, 2); - ide_init_ioport(&d->bus[i], NULL, port_info[i].iobase, - port_info[i].iobase2); - ide_init2(&d->bus[i], isa_get_irq(NULL, port_info[i].isairq)); + ide_init2(&d->bus[i], qemu_allocate_irq(via_ide_set_irq, d, i)); =20 bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus =3D &d->bus[i]; --=20 2.13.7