From nobody Fri Nov 7 10:27:13 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 1548185775916806.5911904291759; Tue, 22 Jan 2019 11:36:15 -0800 (PST) Received: from localhost ([127.0.0.1]:47999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1qI-0001hm-Tr for importer@patchew.org; Tue, 22 Jan 2019 14:36:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1C2-0002SZ-GL for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm1C0-0001BM-CI for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:38 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:16216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gm1Bm-0000xC-1k; Tue, 22 Jan 2019 13:54:26 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 05CEC7456B2; Tue, 22 Jan 2019 13:55:55 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 72AA87456B3; Tue, 22 Jan 2019 13:55:54 +0100 (CET) Message-Id: <47d854e0fa41dad6861107eac61327c247965566.1548160772.git.balaton@eik.bme.hu> 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: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH 1/3] ide/via: Remove vt82c686b_init_ports() function 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" This function is only called once from vt82c686b_ide_realize() and its content is simple enough to not need a separate function but be included in realize directly (as done in other IDE models except PIIX currently). Signed-off-by: BALATON Zoltan --- hw/ide/via.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 987d99c5ec..46cac7b8d6 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -32,6 +32,15 @@ #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) { @@ -143,34 +152,12 @@ static void via_reset(void *opaque) pci_set_long(pci_conf + 0xc0, 0x00020001); } =20 -static void vt82c686b_init_ports(PCIIDEState *d) { - static const struct { - int iobase; - int iobase2; - int isairq; - } port_info[] =3D { - {0x1f0, 0x3f6, 14}, - {0x170, 0x376, 15}, - }; - int i; - - 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)); - - bmdma_init(&d->bus[i], &d->bmdma[i], d); - d->bmdma[i].bus =3D &d->bus[i]; - ide_register_restart_cb(&d->bus[i]); - } -} - /* via ide func */ static void vt82c686b_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d =3D PCI_IDE(dev); uint8_t *pci_conf =3D dev->config; + int i; =20 pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy ATA mode */ pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); @@ -181,7 +168,16 @@ static void vt82c686b_ide_realize(PCIDevice *dev, Erro= r **errp) =20 vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d); =20 - vt82c686b_init_ports(d); + 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)); + + bmdma_init(&d->bus[i], &d->bmdma[i], d); + d->bmdma[i].bus =3D &d->bus[i]; + ide_register_restart_cb(&d->bus[i]); + } } =20 static void vt82c686b_ide_exitfn(PCIDevice *dev) --=20 2.13.7 From nobody Fri Nov 7 10:27:13 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 154818454905373.10019598905251; Tue, 22 Jan 2019 11:15:49 -0800 (PST) Received: from localhost ([127.0.0.1]:47646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1WQ-0002L5-MG for importer@patchew.org; Tue, 22 Jan 2019 14:15:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1CA-0002Yh-4q for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gm1C6-0001E9-Vn for qemu-devel@nongnu.org; Tue, 22 Jan 2019 13:54:45 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:16218) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gm1C2-0000xB-Fl; Tue, 22 Jan 2019 13:54:38 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 049A07456B9; Tue, 22 Jan 2019 13:55:55 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 75BD57456B1; Tue, 22 Jan 2019 13:55:54 +0100 (CET) Message-Id: <2905ced862c8d2ad509d73152171ce2472d72605.1548160772.git.balaton@eik.bme.hu> 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: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH 2/3] ide/via: Rename functions to match device name 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 is called via-ide and the modelled IDE controller is not specific to 82C686B but is also usable independently. Therefore, change function name prefixes accordingly to match device name. Signed-off-by: BALATON Zoltan --- hw/ide/via.c | 15 +++++++-------- hw/mips/mips_fulong2e.c | 2 +- include/hw/ide.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 46cac7b8d6..c6e43a8812 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -110,7 +110,7 @@ static void bmdma_setup_bar(PCIIDEState *d) } } =20 -static void via_reset(void *opaque) +static void via_ide_reset(void *opaque) { PCIIDEState *d =3D opaque; PCIDevice *pd =3D PCI_DEVICE(d); @@ -152,8 +152,7 @@ static void via_reset(void *opaque) pci_set_long(pci_conf + 0xc0, 0x00020001); } =20 -/* via ide func */ -static void vt82c686b_ide_realize(PCIDevice *dev, Error **errp) +static void via_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d =3D PCI_IDE(dev); uint8_t *pci_conf =3D dev->config; @@ -162,7 +161,7 @@ static void vt82c686b_ide_realize(PCIDevice *dev, Error= **errp) pci_config_set_prog_interface(pci_conf, 0x8a); /* legacy ATA mode */ pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); =20 - qemu_register_reset(via_reset, d); + qemu_register_reset(via_ide_reset, d); bmdma_setup_bar(d); pci_register_bar(dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &d->bmdma_bar); =20 @@ -180,7 +179,7 @@ static void vt82c686b_ide_realize(PCIDevice *dev, Error= **errp) } } =20 -static void vt82c686b_ide_exitfn(PCIDevice *dev) +static void via_ide_exitfn(PCIDevice *dev) { PCIIDEState *d =3D PCI_IDE(dev); unsigned i; @@ -191,7 +190,7 @@ static void vt82c686b_ide_exitfn(PCIDevice *dev) } } =20 -void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) +void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) { PCIDevice *dev; =20 @@ -204,8 +203,8 @@ static void via_ide_class_init(ObjectClass *klass, void= *data) DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 - k->realize =3D vt82c686b_ide_realize; - k->exit =3D vt82c686b_ide_exitfn; + k->realize =3D via_ide_realize; + k->exit =3D via_ide_exitfn; k->vendor_id =3D PCI_VENDOR_ID_VIA; k->device_id =3D PCI_DEVICE_ID_VIA_IDE; k->revision =3D 0x06; diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 2fbba32c48..42d09f6892 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -249,7 +249,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus,= int slot, qemu_irq intc, isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO); =20 ide_drive_get(hd, ARRAY_SIZE(hd)); - vt82c686b_ide_init(pci_bus, hd, PCI_DEVFN(slot, 1)); + via_ide_init(pci_bus, hd, PCI_DEVFN(slot, 1)); =20 pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); diff --git a/include/hw/ide.h b/include/hw/ide.h index 3ae087c572..28d8a06439 100644 --- a/include/hw/ide.h +++ b/include/hw/ide.h @@ -18,7 +18,7 @@ PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo = **hd_table, int devfn); PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux); -void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); +void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); =20 /* ide-mmio.c */ void mmio_ide_init_drives(DeviceState *dev, DriveInfo *hd0, DriveInfo *hd1= ); --=20 2.13.7 From nobody Fri Nov 7 10:27:13 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