From nobody Wed Nov 19 08:44:33 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu ARC-Seal: i=1; a=rsa-sha256; t=1615323793; cv=none; d=zohomail.com; s=zohoarc; b=mO7Io5n9eJEEGTAz4hWCGjczWkrS1wd7CcTirKC5Bg+tqhBkg+HVTqxcMmWdb9h9dPROnOjbH1xTYgI1bXHthT8P+2o5Fnia9bY0AOf4AYcuKu59Q+sZrwfHuC2EMSdilMBSsnxkzVMiftkaGhR3vTpD1oF1E0QSuY5qu5EXKFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615323793; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Iwwxx5yQs06unMhHu34j9I71am0RQcVIKkPWg8870RU=; b=CqULlF1OT6eTxnK2evyLzwVrsUQg3GQpzTptEtXcO8WD81pRdvjz7XY1eWusIGgxJlDUT9qApNTT5GhY9K8wA+biAcFFBQXEZmqNX20EZeTN6qGHjCRfmoyFVK4RsC0mJdSKZ/KTGOoctxdIi8mYwQ2XQsRL8GG4mmmVdS3X5zk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1615323793032754.5713033054777; Tue, 9 Mar 2021 13:03:13 -0800 (PST) Received: from localhost ([::1]:51868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJjVY-0002Q3-2o for importer@patchew.org; Tue, 09 Mar 2021 16:03:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJjAt-0001Ms-OM; Tue, 09 Mar 2021 15:41:51 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:11996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJjAp-0006Th-1B; Tue, 09 Mar 2021 15:41:51 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 046CB746354; Tue, 9 Mar 2021 21:41:44 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id BB7657456B4; Tue, 9 Mar 2021 21:41:43 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 4/8] vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it Date: Tue, 09 Mar 2021 21:28:49 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 10% Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Paolo Bonzini , f4bug@amsat.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" To allow reusing ISA bridge emulation for vt8231_isa move the device state of vt82c686b_isa emulation in an abstract via_isa class. This change breaks migration back compatibility but this is not an issue for Fuloong2E machine which is not versioned or migration supported. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 70 ++++++++++++++++++++++------------------ include/hw/pci/pci_ids.h | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 72234bc4d1..5137f97f37 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -609,24 +609,48 @@ static const TypeInfo vt8231_superio_info =3D { }; =20 =20 -OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) +#define TYPE_VIA_ISA "via-isa" +OBJECT_DECLARE_SIMPLE_TYPE(ViaISAState, VIA_ISA) =20 -struct VT82C686BISAState { +struct ViaISAState { PCIDevice dev; qemu_irq cpu_intr; ViaSuperIOState *via_sio; }; =20 +static const VMStateDescription vmstate_via =3D { + .name =3D "via-isa", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_PCI_DEVICE(dev, ViaISAState), + VMSTATE_END_OF_LIST() + } +}; + +static const TypeInfo via_isa_info =3D { + .name =3D TYPE_VIA_ISA, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(ViaISAState), + .abstract =3D true, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + static void via_isa_request_i8259_irq(void *opaque, int irq, int level) { - VT82C686BISAState *s =3D opaque; + ViaISAState *s =3D opaque; qemu_set_irq(s->cpu_intr, level); } =20 +/* TYPE_VT82C686B_ISA */ + static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len) { - VT82C686BISAState *s =3D VT82C686B_ISA(d); + ViaISAState *s =3D VIA_ISA(d); =20 trace_via_isa_write(addr, val, len); pci_default_write_config(d, addr, val, len); @@ -636,19 +660,9 @@ static void vt82c686b_write_config(PCIDevice *d, uint3= 2_t addr, } } =20 -static const VMStateDescription vmstate_via =3D { - .name =3D "vt82c686b", - .version_id =3D 1, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, VT82C686BISAState), - VMSTATE_END_OF_LIST() - } -}; - static void vt82c686b_isa_reset(DeviceState *dev) { - VT82C686BISAState *s =3D VT82C686B_ISA(dev); + ViaISAState *s =3D VIA_ISA(dev); uint8_t *pci_conf =3D s->dev.config; =20 pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); @@ -668,7 +682,7 @@ static void vt82c686b_isa_reset(DeviceState *dev) =20 static void vt82c686b_realize(PCIDevice *d, Error **errp) { - VT82C686BISAState *s =3D VT82C686B_ISA(d); + ViaISAState *s =3D VIA_ISA(d); DeviceState *dev =3D DEVICE(d); ISABus *isa_bus; qemu_irq *isa_irq; @@ -692,7 +706,7 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) } } =20 -static void via_class_init(ObjectClass *klass, void *data) +static void vt82c686b_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); @@ -700,28 +714,21 @@ static void via_class_init(ObjectClass *klass, void *= data) k->realize =3D vt82c686b_realize; k->config_write =3D vt82c686b_write_config; k->vendor_id =3D PCI_VENDOR_ID_VIA; - k->device_id =3D PCI_DEVICE_ID_VIA_ISA_BRIDGE; + k->device_id =3D PCI_DEVICE_ID_VIA_82C686B_ISA; k->class_id =3D PCI_CLASS_BRIDGE_ISA; k->revision =3D 0x40; dc->reset =3D vt82c686b_isa_reset; dc->desc =3D "ISA bridge"; dc->vmsd =3D &vmstate_via; - /* - * Reason: part of VIA VT82C686 southbridge, needs to be wired up, - * e.g. by mips_fuloong2e_init() - */ + /* Reason: part of VIA VT82C686 southbridge, needs to be wired up */ dc->user_creatable =3D false; } =20 -static const TypeInfo via_info =3D { +static const TypeInfo vt82c686b_isa_info =3D { .name =3D TYPE_VT82C686B_ISA, - .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(VT82C686BISAState), - .class_init =3D via_class_init, - .interfaces =3D (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, + .parent =3D TYPE_VIA_ISA, + .instance_size =3D sizeof(ViaISAState), + .class_init =3D vt82c686b_class_init, }; =20 =20 @@ -733,7 +740,8 @@ static void vt82c686b_register_types(void) type_register_static(&via_superio_info); type_register_static(&vt82c686b_superio_info); type_register_static(&vt8231_superio_info); - type_register_static(&via_info); + type_register_static(&via_isa_info); + type_register_static(&vt82c686b_isa_info); } =20 type_init(vt82c686b_register_types) diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index ea28dcc850..aa3f67eaa4 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -204,7 +204,7 @@ #define PCI_VENDOR_ID_XILINX 0x10ee =20 #define PCI_VENDOR_ID_VIA 0x1106 -#define PCI_DEVICE_ID_VIA_ISA_BRIDGE 0x0686 +#define PCI_DEVICE_ID_VIA_82C686B_ISA 0x0686 #define PCI_DEVICE_ID_VIA_IDE 0x0571 #define PCI_DEVICE_ID_VIA_UHCI 0x3038 #define PCI_DEVICE_ID_VIA_82C686B_PM 0x3057 --=20 2.21.3