From patchwork Tue Jan 22 12:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 10776169 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E2CF746 for ; Tue, 22 Jan 2019 19:35:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D7712B838 for ; Tue, 22 Jan 2019 19:35:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21F992B84B; Tue, 22 Jan 2019 19:35:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BFF7B2B838 for ; Tue, 22 Jan 2019 19:35:40 +0000 (UTC) Received: from localhost ([127.0.0.1]:47999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1pj-0001hm-VR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 14:35:40 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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" +static const struct { + int iobase; + int iobase2; + int isairq; +} port_info[] = { + {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); } -static void vt82c686b_init_ports(PCIIDEState *d) { - static const struct { - int iobase; - int iobase2; - int isairq; - } port_info[] = { - {0x1f0, 0x3f6, 14}, - {0x170, 0x376, 15}, - }; - int i; - - for (i = 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 = &d->bus[i]; - ide_register_restart_cb(&d->bus[i]); - } -} - /* via ide func */ static void vt82c686b_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d = PCI_IDE(dev); uint8_t *pci_conf = dev->config; + int i; 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, Error **errp) vmstate_register(DEVICE(dev), 0, &vmstate_ide_pci, d); - vt82c686b_init_ports(d); + for (i = 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 = &d->bus[i]; + ide_register_restart_cb(&d->bus[i]); + } } static void vt82c686b_ide_exitfn(PCIDevice *dev) From patchwork Tue Jan 22 12:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 10776153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2C85139A for ; Tue, 22 Jan 2019 19:15:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0AA02B6D0 for ; Tue, 22 Jan 2019 19:15:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3F602B75F; Tue, 22 Jan 2019 19:15:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C07782B6D0 for ; Tue, 22 Jan 2019 19:15:05 +0000 (UTC) Received: from localhost ([127.0.0.1]:47646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm1Vo-0002L5-Vt for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 14:15:05 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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) } } -static void via_reset(void *opaque) +static void via_ide_reset(void *opaque) { PCIIDEState *d = opaque; PCIDevice *pd = PCI_DEVICE(d); @@ -152,8 +152,7 @@ static void via_reset(void *opaque) pci_set_long(pci_conf + 0xc0, 0x00020001); } -/* via ide func */ -static void vt82c686b_ide_realize(PCIDevice *dev, Error **errp) +static void via_ide_realize(PCIDevice *dev, Error **errp) { PCIIDEState *d = PCI_IDE(dev); uint8_t *pci_conf = 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); - 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); @@ -180,7 +179,7 @@ static void vt82c686b_ide_realize(PCIDevice *dev, Error **errp) } } -static void vt82c686b_ide_exitfn(PCIDevice *dev) +static void via_ide_exitfn(PCIDevice *dev) { PCIIDEState *d = PCI_IDE(dev); unsigned i; @@ -191,7 +190,7 @@ static void vt82c686b_ide_exitfn(PCIDevice *dev) } } -void vt82c686b_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) +void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) { PCIDevice *dev; @@ -204,8 +203,8 @@ static void via_ide_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - k->realize = vt82c686b_ide_realize; - k->exit = vt82c686b_ide_exitfn; + k->realize = via_ide_realize; + k->exit = via_ide_exitfn; k->vendor_id = PCI_VENDOR_ID_VIA; k->device_id = PCI_DEVICE_ID_VIA_IDE; k->revision = 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); 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)); 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); /* ide-mmio.c */ void mmio_ide_init_drives(DeviceState *dev, DriveInfo *hd0, DriveInfo *hd1); From patchwork Tue Jan 22 12:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BALATON Zoltan X-Patchwork-Id: 10776177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6303513B5 for ; Tue, 22 Jan 2019 19:52:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 525052B843 for ; Tue, 22 Jan 2019 19:52:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46D872B951; Tue, 22 Jan 2019 19:52:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7DF32B843 for ; Tue, 22 Jan 2019 19:52:33 +0000 (UTC) Received: from localhost ([127.0.0.1]:48293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gm265-0008Rw-76 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Jan 2019 14:52:33 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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" -static const struct { - int iobase; - int iobase2; - int isairq; -} port_info[] = { - {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) } } +static void via_ide_set_irq(void *opaque, int n, int level) +{ + PCIDevice *d = PCI_DEVICE(opaque); + + if (level) { + d->config[0x70 + n * 8] |= 0x80; + } else { + d->config[0x70 + n * 8] &= ~0x80; + } + + level = (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80); + n = 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 = opaque; @@ -121,7 +129,7 @@ static void via_ide_reset(void *opaque) ide_bus_reset(&d->bus[i]); } - 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); @@ -158,10 +166,28 @@ static void via_ide_realize(PCIDevice *dev, Error **errp) uint8_t *pci_conf = dev->config; int i; - 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] = 0xf; 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); @@ -169,9 +195,7 @@ static void via_ide_realize(PCIDevice *dev, Error **errp) for (i = 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)); bmdma_init(&d->bus[i], &d->bmdma[i], d); d->bmdma[i].bus = &d->bus[i];